@leaflow/sdk 0.186.0 → 0.187.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (274) hide show
  1. package/README.md +15 -0
  2. package/dist/fleet/v1/generated/functions.d.ts +1717 -0
  3. package/dist/fleet/v1/generated/functions.js +1662 -0
  4. package/dist/fleet/v1/generated/models.d.ts +1534 -0
  5. package/dist/fleet/v1/generated/models.js +97 -0
  6. package/dist/fleet/v1/generated/schemas.zod.d.ts +1179 -0
  7. package/dist/fleet/v1/generated/schemas.zod.js +1298 -0
  8. package/dist/fleet/v1/generated/validators/accountList.zod.d.ts +250 -0
  9. package/dist/fleet/v1/generated/validators/accountList.zod.js +234 -0
  10. package/dist/fleet/v1/generated/validators/accountResource.zod.d.ts +244 -0
  11. package/dist/fleet/v1/generated/validators/accountResource.zod.js +242 -0
  12. package/dist/fleet/v1/generated/validators/approveEnrollmentRequest.zod.d.ts +232 -0
  13. package/dist/fleet/v1/generated/validators/approveEnrollmentRequest.zod.js +234 -0
  14. package/dist/fleet/v1/generated/validators/callMcpToolRequest.zod.d.ts +234 -0
  15. package/dist/fleet/v1/generated/validators/callMcpToolRequest.zod.js +240 -0
  16. package/dist/fleet/v1/generated/validators/callMcpToolResponse.zod.d.ts +231 -0
  17. package/dist/fleet/v1/generated/validators/callMcpToolResponse.zod.js +231 -0
  18. package/dist/fleet/v1/generated/validators/createGroupMemberRequest.zod.d.ts +231 -0
  19. package/dist/fleet/v1/generated/validators/createGroupMemberRequest.zod.js +229 -0
  20. package/dist/fleet/v1/generated/validators/createGroupRequest.zod.d.ts +231 -0
  21. package/dist/fleet/v1/generated/validators/createGroupRequest.zod.js +230 -0
  22. package/dist/fleet/v1/generated/validators/createMachineRegistrationRequest.zod.d.ts +236 -0
  23. package/dist/fleet/v1/generated/validators/createMachineRegistrationRequest.zod.js +243 -0
  24. package/dist/fleet/v1/generated/validators/createMachineRegistrationResponse.zod.d.ts +247 -0
  25. package/dist/fleet/v1/generated/validators/createMachineRegistrationResponse.zod.js +233 -0
  26. package/dist/fleet/v1/generated/validators/createParticipantRequest.zod.d.ts +248 -0
  27. package/dist/fleet/v1/generated/validators/createParticipantRequest.zod.js +261 -0
  28. package/dist/fleet/v1/generated/validators/createParticipantResponse.zod.d.ts +277 -0
  29. package/dist/fleet/v1/generated/validators/createParticipantResponse.zod.js +241 -0
  30. package/dist/fleet/v1/generated/validators/createPeerConnectionCandidatesRequest.zod.d.ts +236 -0
  31. package/dist/fleet/v1/generated/validators/createPeerConnectionCandidatesRequest.zod.js +238 -0
  32. package/dist/fleet/v1/generated/validators/createPeerConnectionRequest.zod.d.ts +232 -0
  33. package/dist/fleet/v1/generated/validators/createPeerConnectionRequest.zod.js +233 -0
  34. package/dist/fleet/v1/generated/validators/createSessionRequest.zod.d.ts +240 -0
  35. package/dist/fleet/v1/generated/validators/createSessionRequest.zod.js +231 -0
  36. package/dist/fleet/v1/generated/validators/cursorPagination.zod.d.ts +232 -0
  37. package/dist/fleet/v1/generated/validators/cursorPagination.zod.js +232 -0
  38. package/dist/fleet/v1/generated/validators/deleteMcpServerParams.zod.d.ts +232 -0
  39. package/dist/fleet/v1/generated/validators/deleteMcpServerParams.zod.js +230 -0
  40. package/dist/fleet/v1/generated/validators/desktopOptions.zod.d.ts +242 -0
  41. package/dist/fleet/v1/generated/validators/desktopOptions.zod.js +254 -0
  42. package/dist/fleet/v1/generated/validators/desktopState.zod.d.ts +235 -0
  43. package/dist/fleet/v1/generated/validators/desktopState.zod.js +231 -0
  44. package/dist/fleet/v1/generated/validators/directoryName.zod.d.ts +231 -0
  45. package/dist/fleet/v1/generated/validators/directoryName.zod.js +234 -0
  46. package/dist/fleet/v1/generated/validators/enrollmentResource.zod.d.ts +243 -0
  47. package/dist/fleet/v1/generated/validators/enrollmentResource.zod.js +241 -0
  48. package/dist/fleet/v1/generated/validators/enrollmentState.zod.d.ts +233 -0
  49. package/dist/fleet/v1/generated/validators/enrollmentState.zod.js +229 -0
  50. package/dist/fleet/v1/generated/validators/error.zod.d.ts +243 -0
  51. package/dist/fleet/v1/generated/validators/error.zod.js +232 -0
  52. package/dist/fleet/v1/generated/validators/errorStatus.zod.d.ts +241 -0
  53. package/dist/fleet/v1/generated/validators/errorStatus.zod.js +256 -0
  54. package/dist/fleet/v1/generated/validators/featureState.zod.d.ts +232 -0
  55. package/dist/fleet/v1/generated/validators/featureState.zod.js +229 -0
  56. package/dist/fleet/v1/generated/validators/fieldViolation.zod.d.ts +232 -0
  57. package/dist/fleet/v1/generated/validators/fieldViolation.zod.js +235 -0
  58. package/dist/fleet/v1/generated/validators/findEnrollmentByPairingCodeParams.zod.d.ts +232 -0
  59. package/dist/fleet/v1/generated/validators/findEnrollmentByPairingCodeParams.zod.js +230 -0
  60. package/dist/fleet/v1/generated/validators/findEnrollmentResponse.zod.d.ts +245 -0
  61. package/dist/fleet/v1/generated/validators/findEnrollmentResponse.zod.js +232 -0
  62. package/dist/fleet/v1/generated/validators/groupList.zod.d.ts +242 -0
  63. package/dist/fleet/v1/generated/validators/groupList.zod.js +234 -0
  64. package/dist/fleet/v1/generated/validators/groupResource.zod.d.ts +237 -0
  65. package/dist/fleet/v1/generated/validators/groupResource.zod.js +235 -0
  66. package/dist/fleet/v1/generated/validators/iceCandidate.zod.d.ts +234 -0
  67. package/dist/fleet/v1/generated/validators/iceCandidate.zod.js +241 -0
  68. package/dist/fleet/v1/generated/validators/iceServer.zod.d.ts +233 -0
  69. package/dist/fleet/v1/generated/validators/iceServer.zod.js +236 -0
  70. package/dist/fleet/v1/generated/validators/listAccountsParams.zod.d.ts +239 -0
  71. package/dist/fleet/v1/generated/validators/listAccountsParams.zod.js +241 -0
  72. package/dist/fleet/v1/generated/validators/listGroupMembersParams.zod.d.ts +236 -0
  73. package/dist/fleet/v1/generated/validators/listGroupMembersParams.zod.js +242 -0
  74. package/dist/fleet/v1/generated/validators/listGroupsParams.zod.d.ts +236 -0
  75. package/dist/fleet/v1/generated/validators/listGroupsParams.zod.js +238 -0
  76. package/dist/fleet/v1/generated/validators/listMachineEventsParams.zod.d.ts +240 -0
  77. package/dist/fleet/v1/generated/validators/listMachineEventsParams.zod.js +244 -0
  78. package/dist/fleet/v1/generated/validators/listMachineRegistrationsParams.zod.d.ts +236 -0
  79. package/dist/fleet/v1/generated/validators/listMachineRegistrationsParams.zod.js +242 -0
  80. package/dist/fleet/v1/generated/validators/listMachinesParams.zod.d.ts +238 -0
  81. package/dist/fleet/v1/generated/validators/listMachinesParams.zod.js +240 -0
  82. package/dist/fleet/v1/generated/validators/listMcpToolsParams.zod.d.ts +239 -0
  83. package/dist/fleet/v1/generated/validators/listMcpToolsParams.zod.js +241 -0
  84. package/dist/fleet/v1/generated/validators/listPrivilegeAutoApprovalsParams.zod.d.ts +236 -0
  85. package/dist/fleet/v1/generated/validators/listPrivilegeAutoApprovalsParams.zod.js +242 -0
  86. package/dist/fleet/v1/generated/validators/listPrivilegeRequestsParams.zod.d.ts +244 -0
  87. package/dist/fleet/v1/generated/validators/listPrivilegeRequestsParams.zod.js +245 -0
  88. package/dist/fleet/v1/generated/validators/listSessionsParams.zod.d.ts +240 -0
  89. package/dist/fleet/v1/generated/validators/listSessionsParams.zod.js +242 -0
  90. package/dist/fleet/v1/generated/validators/machineEventList.zod.d.ts +244 -0
  91. package/dist/fleet/v1/generated/validators/machineEventList.zod.js +234 -0
  92. package/dist/fleet/v1/generated/validators/machineEventResource.zod.d.ts +238 -0
  93. package/dist/fleet/v1/generated/validators/machineEventResource.zod.js +238 -0
  94. package/dist/fleet/v1/generated/validators/machineEventType.zod.d.ts +232 -0
  95. package/dist/fleet/v1/generated/validators/machineEventType.zod.js +229 -0
  96. package/dist/fleet/v1/generated/validators/machineFeature.zod.d.ts +237 -0
  97. package/dist/fleet/v1/generated/validators/machineFeature.zod.js +239 -0
  98. package/dist/fleet/v1/generated/validators/machineList.zod.d.ts +261 -0
  99. package/dist/fleet/v1/generated/validators/machineList.zod.js +234 -0
  100. package/dist/fleet/v1/generated/validators/machineRegistrationList.zod.d.ts +250 -0
  101. package/dist/fleet/v1/generated/validators/machineRegistrationList.zod.js +234 -0
  102. package/dist/fleet/v1/generated/validators/machineRegistrationResource.zod.d.ts +244 -0
  103. package/dist/fleet/v1/generated/validators/machineRegistrationResource.zod.js +249 -0
  104. package/dist/fleet/v1/generated/validators/machineRegistrationState.zod.d.ts +234 -0
  105. package/dist/fleet/v1/generated/validators/machineRegistrationState.zod.js +229 -0
  106. package/dist/fleet/v1/generated/validators/machineResource.zod.d.ts +256 -0
  107. package/dist/fleet/v1/generated/validators/machineResource.zod.js +257 -0
  108. package/dist/fleet/v1/generated/validators/mcpConfigurationFile.zod.d.ts +240 -0
  109. package/dist/fleet/v1/generated/validators/mcpConfigurationFile.zod.js +246 -0
  110. package/dist/fleet/v1/generated/validators/mcpConfigurationResource.zod.d.ts +279 -0
  111. package/dist/fleet/v1/generated/validators/mcpConfigurationResource.zod.js +232 -0
  112. package/dist/fleet/v1/generated/validators/mcpImplementation.zod.d.ts +233 -0
  113. package/dist/fleet/v1/generated/validators/mcpImplementation.zod.js +231 -0
  114. package/dist/fleet/v1/generated/validators/mcpServerFailure.zod.d.ts +237 -0
  115. package/dist/fleet/v1/generated/validators/mcpServerFailure.zod.js +237 -0
  116. package/dist/fleet/v1/generated/validators/mcpServerResource.zod.d.ts +265 -0
  117. package/dist/fleet/v1/generated/validators/mcpServerResource.zod.js +256 -0
  118. package/dist/fleet/v1/generated/validators/mcpToolList.zod.d.ts +252 -0
  119. package/dist/fleet/v1/generated/validators/mcpToolList.zod.js +235 -0
  120. package/dist/fleet/v1/generated/validators/mcpToolResource.zod.d.ts +237 -0
  121. package/dist/fleet/v1/generated/validators/mcpToolResource.zod.js +243 -0
  122. package/dist/fleet/v1/generated/validators/mcpTransport.zod.d.ts +233 -0
  123. package/dist/fleet/v1/generated/validators/mcpTransport.zod.js +229 -0
  124. package/dist/fleet/v1/generated/validators/mcpUnavailableServer.zod.d.ts +240 -0
  125. package/dist/fleet/v1/generated/validators/mcpUnavailableServer.zod.js +231 -0
  126. package/dist/fleet/v1/generated/validators/migrationStep.zod.d.ts +232 -0
  127. package/dist/fleet/v1/generated/validators/migrationStep.zod.js +233 -0
  128. package/dist/fleet/v1/generated/validators/namedIdentity.zod.d.ts +233 -0
  129. package/dist/fleet/v1/generated/validators/namedIdentity.zod.js +233 -0
  130. package/dist/fleet/v1/generated/validators/offsetPagination.zod.d.ts +234 -0
  131. package/dist/fleet/v1/generated/validators/offsetPagination.zod.js +234 -0
  132. package/dist/fleet/v1/generated/validators/operatingSystem.zod.d.ts +233 -0
  133. package/dist/fleet/v1/generated/validators/operatingSystem.zod.js +233 -0
  134. package/dist/fleet/v1/generated/validators/participantList.zod.d.ts +242 -0
  135. package/dist/fleet/v1/generated/validators/participantList.zod.js +230 -0
  136. package/dist/fleet/v1/generated/validators/participantResource.zod.d.ts +240 -0
  137. package/dist/fleet/v1/generated/validators/participantResource.zod.js +242 -0
  138. package/dist/fleet/v1/generated/validators/peerConnection.zod.d.ts +241 -0
  139. package/dist/fleet/v1/generated/validators/peerConnection.zod.js +242 -0
  140. package/dist/fleet/v1/generated/validators/privilegeAutoApprovalList.zod.d.ts +241 -0
  141. package/dist/fleet/v1/generated/validators/privilegeAutoApprovalList.zod.js +234 -0
  142. package/dist/fleet/v1/generated/validators/privilegeAutoApprovalResource.zod.d.ts +235 -0
  143. package/dist/fleet/v1/generated/validators/privilegeAutoApprovalResource.zod.js +236 -0
  144. package/dist/fleet/v1/generated/validators/privilegeDecider.zod.d.ts +232 -0
  145. package/dist/fleet/v1/generated/validators/privilegeDecider.zod.js +229 -0
  146. package/dist/fleet/v1/generated/validators/privilegeRequestList.zod.d.ts +258 -0
  147. package/dist/fleet/v1/generated/validators/privilegeRequestList.zod.js +234 -0
  148. package/dist/fleet/v1/generated/validators/privilegeRequestResource.zod.d.ts +253 -0
  149. package/dist/fleet/v1/generated/validators/privilegeRequestResource.zod.js +255 -0
  150. package/dist/fleet/v1/generated/validators/privilegeRequestState.zod.d.ts +235 -0
  151. package/dist/fleet/v1/generated/validators/privilegeRequestState.zod.js +229 -0
  152. package/dist/fleet/v1/generated/validators/publicKey.zod.d.ts +230 -0
  153. package/dist/fleet/v1/generated/validators/publicKey.zod.js +231 -0
  154. package/dist/fleet/v1/generated/validators/renewParticipantRequest.zod.d.ts +236 -0
  155. package/dist/fleet/v1/generated/validators/renewParticipantRequest.zod.js +235 -0
  156. package/dist/fleet/v1/generated/validators/renewParticipantResponse.zod.d.ts +257 -0
  157. package/dist/fleet/v1/generated/validators/renewParticipantResponse.zod.js +238 -0
  158. package/dist/fleet/v1/generated/validators/replaceMcpConfigurationRequest.zod.d.ts +233 -0
  159. package/dist/fleet/v1/generated/validators/replaceMcpConfigurationRequest.zod.js +237 -0
  160. package/dist/fleet/v1/generated/validators/rtcConfiguration.zod.d.ts +240 -0
  161. package/dist/fleet/v1/generated/validators/rtcConfiguration.zod.js +236 -0
  162. package/dist/fleet/v1/generated/validators/runCommandRequest.zod.d.ts +235 -0
  163. package/dist/fleet/v1/generated/validators/runCommandRequest.zod.js +242 -0
  164. package/dist/fleet/v1/generated/validators/runCommandResponse.zod.d.ts +237 -0
  165. package/dist/fleet/v1/generated/validators/runCommandResponse.zod.js +245 -0
  166. package/dist/fleet/v1/generated/validators/sendMcpRequestRequest.zod.d.ts +234 -0
  167. package/dist/fleet/v1/generated/validators/sendMcpRequestRequest.zod.js +239 -0
  168. package/dist/fleet/v1/generated/validators/sendMcpRequestResponse.zod.d.ts +231 -0
  169. package/dist/fleet/v1/generated/validators/sendMcpRequestResponse.zod.js +231 -0
  170. package/dist/fleet/v1/generated/validators/sessionCloseReason.zod.d.ts +242 -0
  171. package/dist/fleet/v1/generated/validators/sessionCloseReason.zod.js +242 -0
  172. package/dist/fleet/v1/generated/validators/sessionList.zod.d.ts +274 -0
  173. package/dist/fleet/v1/generated/validators/sessionList.zod.js +234 -0
  174. package/dist/fleet/v1/generated/validators/sessionMode.zod.d.ts +232 -0
  175. package/dist/fleet/v1/generated/validators/sessionMode.zod.js +229 -0
  176. package/dist/fleet/v1/generated/validators/sessionResource.zod.d.ts +268 -0
  177. package/dist/fleet/v1/generated/validators/sessionResource.zod.js +254 -0
  178. package/dist/fleet/v1/generated/validators/sessionState.zod.d.ts +234 -0
  179. package/dist/fleet/v1/generated/validators/sessionState.zod.js +229 -0
  180. package/dist/fleet/v1/generated/validators/signedMessage.zod.d.ts +233 -0
  181. package/dist/fleet/v1/generated/validators/signedMessage.zod.js +235 -0
  182. package/dist/fleet/v1/generated/validators/signingKey.zod.d.ts +232 -0
  183. package/dist/fleet/v1/generated/validators/signingKey.zod.js +233 -0
  184. package/dist/fleet/v1/generated/validators/updateAccountRequest.zod.d.ts +235 -0
  185. package/dist/fleet/v1/generated/validators/updateAccountRequest.zod.js +240 -0
  186. package/dist/fleet/v1/generated/validators/updateGroupRequest.zod.d.ts +231 -0
  187. package/dist/fleet/v1/generated/validators/updateGroupRequest.zod.js +230 -0
  188. package/dist/fleet/v1/generated/validators/updateMachineRequest.zod.d.ts +232 -0
  189. package/dist/fleet/v1/generated/validators/updateMachineRequest.zod.js +230 -0
  190. package/dist/fleet/v1/generated/validators/updateMcpServerRequest.zod.d.ts +254 -0
  191. package/dist/fleet/v1/generated/validators/updateMcpServerRequest.zod.js +282 -0
  192. package/dist/fleet/v1/generated/validators/updateMcpServerResponse.zod.d.ts +279 -0
  193. package/dist/fleet/v1/generated/validators/updateMcpServerResponse.zod.js +232 -0
  194. package/dist/fleet/v1/generated/validators/updatePrivilegeAutoApprovalRequest.zod.d.ts +231 -0
  195. package/dist/fleet/v1/generated/validators/updatePrivilegeAutoApprovalRequest.zod.js +232 -0
  196. package/dist/fleet/v1/index.d.ts +3 -0
  197. package/dist/fleet/v1/index.js +3 -0
  198. package/dist/index.d.ts +1 -0
  199. package/dist/index.js +1 -0
  200. package/dist/proto/google/rpc/status_pb.d.ts +48 -0
  201. package/dist/proto/google/rpc/status_pb.js +24 -0
  202. package/dist/proto/leaflow/fleet/audio/v1/audio_pb.d.ts +262 -0
  203. package/dist/proto/leaflow/fleet/audio/v1/audio_pb.js +51 -0
  204. package/dist/proto/leaflow/fleet/camera/v1/camera_pb.d.ts +265 -0
  205. package/dist/proto/leaflow/fleet/camera/v1/camera_pb.js +70 -0
  206. package/dist/proto/leaflow/fleet/command/v1/command_pb.d.ts +158 -0
  207. package/dist/proto/leaflow/fleet/command/v1/command_pb.js +25 -0
  208. package/dist/proto/leaflow/fleet/control/v1/control_pb.d.ts +1226 -0
  209. package/dist/proto/leaflow/fleet/control/v1/control_pb.js +354 -0
  210. package/dist/proto/leaflow/fleet/device/v1/device_pb.d.ts +422 -0
  211. package/dist/proto/leaflow/fleet/device/v1/device_pb.js +183 -0
  212. package/dist/proto/leaflow/fleet/directory/v1/directory_pb.d.ts +429 -0
  213. package/dist/proto/leaflow/fleet/directory/v1/directory_pb.js +78 -0
  214. package/dist/proto/leaflow/fleet/exec/v1/exec_pb.d.ts +287 -0
  215. package/dist/proto/leaflow/fleet/exec/v1/exec_pb.js +78 -0
  216. package/dist/proto/leaflow/fleet/filetransfer/v1/filetransfer_pb.d.ts +731 -0
  217. package/dist/proto/leaflow/fleet/filetransfer/v1/filetransfer_pb.js +163 -0
  218. package/dist/proto/leaflow/fleet/gamepad/v1/gamepad_pb.d.ts +347 -0
  219. package/dist/proto/leaflow/fleet/gamepad/v1/gamepad_pb.js +124 -0
  220. package/dist/proto/leaflow/fleet/host/v1/host_pb.d.ts +619 -0
  221. package/dist/proto/leaflow/fleet/host/v1/host_pb.js +206 -0
  222. package/dist/proto/leaflow/fleet/logs/v1/logs_pb.d.ts +293 -0
  223. package/dist/proto/leaflow/fleet/logs/v1/logs_pb.js +90 -0
  224. package/dist/proto/leaflow/fleet/machine/v1/machine_pb.d.ts +448 -0
  225. package/dist/proto/leaflow/fleet/machine/v1/machine_pb.js +157 -0
  226. package/dist/proto/leaflow/fleet/mcp/v1/mcp_pb.d.ts +898 -0
  227. package/dist/proto/leaflow/fleet/mcp/v1/mcp_pb.js +309 -0
  228. package/dist/proto/leaflow/fleet/portforward/v1/portforward_pb.d.ts +688 -0
  229. package/dist/proto/leaflow/fleet/portforward/v1/portforward_pb.js +209 -0
  230. package/dist/proto/leaflow/fleet/printing/v1/printing_pb.d.ts +741 -0
  231. package/dist/proto/leaflow/fleet/printing/v1/printing_pb.js +260 -0
  232. package/dist/proto/leaflow/fleet/privilege/v1/privilege_pb.d.ts +569 -0
  233. package/dist/proto/leaflow/fleet/privilege/v1/privilege_pb.js +168 -0
  234. package/dist/proto/leaflow/fleet/rpc/v1/rpc_pb.d.ts +234 -0
  235. package/dist/proto/leaflow/fleet/rpc/v1/rpc_pb.js +70 -0
  236. package/dist/proto/leaflow/fleet/session/v1/session_pb.d.ts +411 -0
  237. package/dist/proto/leaflow/fleet/session/v1/session_pb.js +130 -0
  238. package/dist/proto/leaflow/fleet/sshagent/v1/sshagent_pb.d.ts +163 -0
  239. package/dist/proto/leaflow/fleet/sshagent/v1/sshagent_pb.js +64 -0
  240. package/dist/proto/leaflow/fleet/terminal/v1/terminal_pb.d.ts +297 -0
  241. package/dist/proto/leaflow/fleet/terminal/v1/terminal_pb.js +54 -0
  242. package/dist/proto/leaflow/fleet/transport/v1/transport_pb.d.ts +1055 -0
  243. package/dist/proto/leaflow/fleet/transport/v1/transport_pb.js +251 -0
  244. package/dist/proto/leaflow/fleet/virtualdesktop/accessibility/v1/accessibility_pb.d.ts +1298 -0
  245. package/dist/proto/leaflow/fleet/virtualdesktop/accessibility/v1/accessibility_pb.js +437 -0
  246. package/dist/proto/leaflow/fleet/virtualdesktop/application/v1/application_pb.d.ts +888 -0
  247. package/dist/proto/leaflow/fleet/virtualdesktop/application/v1/application_pb.js +210 -0
  248. package/dist/proto/leaflow/fleet/virtualdesktop/capture/v1/capture_pb.d.ts +231 -0
  249. package/dist/proto/leaflow/fleet/virtualdesktop/capture/v1/capture_pb.js +63 -0
  250. package/dist/proto/leaflow/fleet/virtualdesktop/change/v1/change_pb.d.ts +965 -0
  251. package/dist/proto/leaflow/fleet/virtualdesktop/change/v1/change_pb.js +239 -0
  252. package/dist/proto/leaflow/fleet/virtualdesktop/cursor/v1/cursor_pb.d.ts +201 -0
  253. package/dist/proto/leaflow/fleet/virtualdesktop/cursor/v1/cursor_pb.js +34 -0
  254. package/dist/proto/leaflow/fleet/virtualdesktop/datatransfer/v1/datatransfer_pb.d.ts +1489 -0
  255. package/dist/proto/leaflow/fleet/virtualdesktop/datatransfer/v1/datatransfer_pb.js +256 -0
  256. package/dist/proto/leaflow/fleet/virtualdesktop/display/v1/display_pb.d.ts +380 -0
  257. package/dist/proto/leaflow/fleet/virtualdesktop/display/v1/display_pb.js +89 -0
  258. package/dist/proto/leaflow/fleet/virtualdesktop/draw/v1/draw_pb.d.ts +587 -0
  259. package/dist/proto/leaflow/fleet/virtualdesktop/draw/v1/draw_pb.js +139 -0
  260. package/dist/proto/leaflow/fleet/virtualdesktop/host/v1/host_pb.d.ts +69 -0
  261. package/dist/proto/leaflow/fleet/virtualdesktop/host/v1/host_pb.js +19 -0
  262. package/dist/proto/leaflow/fleet/virtualdesktop/input/v1/input_pb.d.ts +1463 -0
  263. package/dist/proto/leaflow/fleet/virtualdesktop/input/v1/input_pb.js +321 -0
  264. package/dist/proto/leaflow/fleet/virtualdesktop/lease/v1/lease_pb.d.ts +93 -0
  265. package/dist/proto/leaflow/fleet/virtualdesktop/lease/v1/lease_pb.js +24 -0
  266. package/dist/proto/leaflow/fleet/virtualdesktop/notification/v1/notification_pb.d.ts +414 -0
  267. package/dist/proto/leaflow/fleet/virtualdesktop/notification/v1/notification_pb.js +137 -0
  268. package/dist/proto/leaflow/fleet/virtualdesktop/tray/v1/tray_pb.d.ts +928 -0
  269. package/dist/proto/leaflow/fleet/virtualdesktop/tray/v1/tray_pb.js +413 -0
  270. package/dist/proto/leaflow/fleet/virtualdesktop/window/v1/window_pb.d.ts +1559 -0
  271. package/dist/proto/leaflow/fleet/virtualdesktop/window/v1/window_pb.js +664 -0
  272. package/dist/routes.d.ts +440 -0
  273. package/dist/routes.js +495 -0
  274. package/package.json +11 -3
@@ -0,0 +1,1662 @@
1
+ export const getListMachinesUrl = (params) => {
2
+ const normalizedParams = new URLSearchParams();
3
+ Object.entries(params || {}).forEach(([key, value]) => {
4
+ if (value !== undefined) {
5
+ normalizedParams.append(key, value === null ? "null" : String(value));
6
+ }
7
+ });
8
+ const stringifiedParams = normalizedParams.toString();
9
+ return stringifiedParams.length > 0
10
+ ? `https://fleet.leaflow.cloud/api/v1/machines?${stringifiedParams}`
11
+ : `https://fleet.leaflow.cloud/api/v1/machines`;
12
+ };
13
+ /**
14
+ * Returns the machines of the current project, newest first.
15
+ * @summary List machines
16
+ */
17
+ export const listMachines = async (params, options, fetchFn) => {
18
+ const res = await (fetchFn ?? fetch)(getListMachinesUrl(params), {
19
+ ...options,
20
+ method: "GET",
21
+ });
22
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
23
+ const data = body ? JSON.parse(body) : {};
24
+ return { data, status: res.status, headers: res.headers };
25
+ };
26
+ export const getGetMachineUrl = (machineId) => {
27
+ return `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}`;
28
+ };
29
+ /**
30
+ * @summary Get a machine
31
+ */
32
+ export const getMachine = async (machineId, options, fetchFn) => {
33
+ const res = await (fetchFn ?? fetch)(getGetMachineUrl(machineId), {
34
+ ...options,
35
+ method: "GET",
36
+ });
37
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
38
+ const data = body ? JSON.parse(body) : {};
39
+ return { data, status: res.status, headers: res.headers };
40
+ };
41
+ export const getUpdateMachineUrl = (machineId) => {
42
+ return `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}`;
43
+ };
44
+ /**
45
+ * Changes the machine's name. Requires `fleet:machines.manage`.
46
+ * @summary Update a machine
47
+ */
48
+ export const updateMachine = async (machineId, updateMachineRequest, options, fetchFn) => {
49
+ const getHeaders = (h) => {
50
+ if (!h)
51
+ return {};
52
+ if (h instanceof Headers)
53
+ return Object.fromEntries(h.entries());
54
+ if (Symbol.iterator in h) {
55
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
56
+ }
57
+ const headers = {};
58
+ for (const [name, value] of Object.entries(h)) {
59
+ if (value !== undefined)
60
+ headers[name] = value;
61
+ }
62
+ return headers;
63
+ };
64
+ const res = await (fetchFn ?? fetch)(getUpdateMachineUrl(machineId), {
65
+ ...options,
66
+ method: "PATCH",
67
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
68
+ body: JSON.stringify(updateMachineRequest),
69
+ });
70
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
71
+ const data = body ? JSON.parse(body) : {};
72
+ return { data, status: res.status, headers: res.headers };
73
+ };
74
+ export const getDeleteMachineUrl = (machineId) => {
75
+ return `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}`;
76
+ };
77
+ /**
78
+ * Removes the machine from the project. Every participant of its sessions is disconnected at
79
+ * once and the Agent is refused from then on; to use the machine again, enroll it again.
80
+ * Sessions still open on the machine can no longer be reached and end according to their own
81
+ * timeouts. Nothing on the machine is deleted.
82
+ *
83
+ * Requires `fleet:machines.manage`.
84
+ * @summary Remove a machine
85
+ */
86
+ export const deleteMachine = async (machineId, options, fetchFn) => {
87
+ const res = await (fetchFn ?? fetch)(getDeleteMachineUrl(machineId), {
88
+ ...options,
89
+ method: "DELETE",
90
+ });
91
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
92
+ const data = body ? JSON.parse(body) : undefined;
93
+ return { data, status: res.status, headers: res.headers };
94
+ };
95
+ export const getListMachineEventsUrl = (machineId, params) => {
96
+ const normalizedParams = new URLSearchParams();
97
+ Object.entries(params || {}).forEach(([key, value]) => {
98
+ if (value !== undefined) {
99
+ normalizedParams.append(key, value === null ? "null" : String(value));
100
+ }
101
+ });
102
+ const stringifiedParams = normalizedParams.toString();
103
+ return stringifiedParams.length > 0
104
+ ? `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}/events?${stringifiedParams}`
105
+ : `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}/events`;
106
+ };
107
+ /**
108
+ * Returns what the machine reported about itself, newest first, such as a directory account
109
+ * it does not serve because a local account uses its name. Events are kept for 30 days.
110
+ * @summary List the events of a machine
111
+ */
112
+ export const listMachineEvents = async (machineId, params, options, fetchFn) => {
113
+ const res = await (fetchFn ?? fetch)(getListMachineEventsUrl(machineId, params), {
114
+ ...options,
115
+ method: "GET",
116
+ });
117
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
118
+ const data = body ? JSON.parse(body) : {};
119
+ return { data, status: res.status, headers: res.headers };
120
+ };
121
+ export const getRunMachineCommandUrl = (machineId) => {
122
+ return `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}:runCommand`;
123
+ };
124
+ /**
125
+ * Runs one command line on the machine as the caller's account, with its login shell, and
126
+ * returns once it exited or was killed, with its exit status and what it wrote. Pipes,
127
+ * redirection and `&&` work; there is no terminal and no standard input. The machine admits
128
+ * the account through PAM as for a login. The account is created if the caller has none yet.
129
+ * A command that fails is still a successful request: its exit status is its result.
130
+ *
131
+ * Inside the command, `sudo` works without a prompt while the caller has
132
+ * `fleet:machines.admin` on the machine, and refuses otherwise.
133
+ *
134
+ * The request is held until the command ends, at most `timeout_seconds` and a few seconds
135
+ * more. Neither the command nor its output is hidden from the platform: do not put secrets
136
+ * into either.
137
+ *
138
+ * Requires `fleet:machines.login` on the machine.
139
+ *
140
+ * Fails with:
141
+ * - `MACHINE_OFFLINE` when the machine is not connected and does not connect again in time;
142
+ * - `FEATURE_UNAVAILABLE` when the machine does not offer `leaflow.fleet.command.v1`;
143
+ * - `USER_NOT_FOUND`, `USER_NOT_ALLOWED`, `ACCOUNT_EXPIRED` or `PAM_PERMISSION_DENIED` when
144
+ * the machine refuses the account, as for opening a session;
145
+ * - `COMMAND_START_FAILED` when the shell could not start; nothing ran;
146
+ * - `COMMAND_LOST` when the machine lost the command while it ran. The command may have run
147
+ * in part, and its output is lost;
148
+ * - `MACHINE_TIMEOUT` when the machine did not answer in time. The command may have run.
149
+ * @summary Run a command
150
+ */
151
+ export const runMachineCommand = async (machineId, runCommandRequest, options, fetchFn) => {
152
+ const getHeaders = (h) => {
153
+ if (!h)
154
+ return {};
155
+ if (h instanceof Headers)
156
+ return Object.fromEntries(h.entries());
157
+ if (Symbol.iterator in h) {
158
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
159
+ }
160
+ const headers = {};
161
+ for (const [name, value] of Object.entries(h)) {
162
+ if (value !== undefined)
163
+ headers[name] = value;
164
+ }
165
+ return headers;
166
+ };
167
+ const res = await (fetchFn ?? fetch)(getRunMachineCommandUrl(machineId), {
168
+ ...options,
169
+ method: "POST",
170
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
171
+ body: JSON.stringify(runCommandRequest),
172
+ });
173
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
174
+ const data = body ? JSON.parse(body) : {};
175
+ return { data, status: res.status, headers: res.headers };
176
+ };
177
+ export const getGetMcpConfigurationUrl = (machineId) => {
178
+ return `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}/mcp-configuration`;
179
+ };
180
+ /**
181
+ * Returns the caller's MCP configuration file on the machine and every server in it, with
182
+ * what each is doing now. The values of `env` and `headers` are never returned, only their
183
+ * keys. Requires `fleet:machines.login` on the machine.
184
+ *
185
+ * Fails with:
186
+ * - `MACHINE_OFFLINE` when the machine is not connected and does not connect again in time;
187
+ * - `FEATURE_UNAVAILABLE` when the machine does not offer `leaflow.fleet.mcp.v1`;
188
+ * - `USER_NOT_FOUND`, `USER_NOT_ALLOWED`, `ACCOUNT_EXPIRED` or `PAM_PERMISSION_DENIED` when
189
+ * the machine refuses the account, as for opening a session;
190
+ * - `MCP_START_FAILED` when the machine could not start MCP for the caller's account;
191
+ * - `MACHINE_TIMEOUT` when the machine did not answer in time.
192
+ * @summary Get the caller's MCP configuration on a machine
193
+ */
194
+ export const getMcpConfiguration = async (machineId, options, fetchFn) => {
195
+ const res = await (fetchFn ?? fetch)(getGetMcpConfigurationUrl(machineId), {
196
+ ...options,
197
+ method: "GET",
198
+ });
199
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
200
+ const data = body ? JSON.parse(body) : {};
201
+ return { data, status: res.status, headers: res.headers };
202
+ };
203
+ export const getReplaceMcpConfigurationUrl = (machineId) => {
204
+ return `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}/mcp-configuration`;
205
+ };
206
+ /**
207
+ * Replaces the caller's MCP configuration file on the machine as a whole, also one that cannot
208
+ * be read or is not valid. The machine starts the servers that were added, stops the ones
209
+ * that were removed and restarts the ones that changed when they are next used. The account
210
+ * is created if the caller has none yet. The content, secrets included, passes through the
211
+ * platform. Requires `fleet:machines.login` on the machine.
212
+ *
213
+ * Fails with:
214
+ * - `MCP_CONFIGURATION_CHANGED` when the file is no longer at `expected_revision`;
215
+ * - `MCP_CONFIGURATION_INVALID` when `content` is not an object with an object `mcpServers`,
216
+ * with `metadata.line` and `metadata.column`;
217
+ * - `MCP_CONFIGURATION_WRITE_FAILED` when the machine could not write the file;
218
+ * - `MACHINE_OFFLINE` when the machine is not connected and does not connect again in time;
219
+ * - `FEATURE_UNAVAILABLE` when the machine does not offer `leaflow.fleet.mcp.v1`;
220
+ * - `USER_NOT_FOUND`, `USER_NOT_ALLOWED`, `ACCOUNT_EXPIRED` or `PAM_PERMISSION_DENIED` when
221
+ * the machine refuses the account, as for opening a session;
222
+ * - `MCP_START_FAILED` when the machine could not start MCP for the caller's account;
223
+ * - `MACHINE_TIMEOUT` when the machine did not answer in time.
224
+ * @summary Replace the caller's MCP configuration on a machine
225
+ */
226
+ export const replaceMcpConfiguration = async (machineId, replaceMcpConfigurationRequest, options, fetchFn) => {
227
+ const getHeaders = (h) => {
228
+ if (!h)
229
+ return {};
230
+ if (h instanceof Headers)
231
+ return Object.fromEntries(h.entries());
232
+ if (Symbol.iterator in h) {
233
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
234
+ }
235
+ const headers = {};
236
+ for (const [name, value] of Object.entries(h)) {
237
+ if (value !== undefined)
238
+ headers[name] = value;
239
+ }
240
+ return headers;
241
+ };
242
+ const res = await (fetchFn ?? fetch)(getReplaceMcpConfigurationUrl(machineId), {
243
+ ...options,
244
+ method: "PUT",
245
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
246
+ body: JSON.stringify(replaceMcpConfigurationRequest),
247
+ });
248
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
249
+ const data = body ? JSON.parse(body) : {};
250
+ return { data, status: res.status, headers: res.headers };
251
+ };
252
+ export const getUpdateMcpServerUrl = (machineId, serverName) => {
253
+ return `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}/mcp-servers/${encodeURIComponent(String(serverName))}`;
254
+ };
255
+ /**
256
+ * Adds a server to the caller's MCP configuration on the machine, or replaces the one with
257
+ * the same name. The values of `env` and `headers` the request gives, secrets included, pass
258
+ * through the platform; those named in `keep_env` and `keep_headers` stay as they are on the
259
+ * machine. The account is created if the caller has none yet. Requires
260
+ * `fleet:machines.login` on the machine.
261
+ *
262
+ * Fails with:
263
+ * - `MCP_CONFIGURATION_CHANGED` when the file is no longer at `expected_revision`;
264
+ * - `MCP_CONFIGURATION_INVALID` when the file cannot be read or is not valid; replace it
265
+ * whole first;
266
+ * - `MCP_CONFIGURATION_WRITE_FAILED` when the machine could not write the file;
267
+ * - `MACHINE_OFFLINE` when the machine is not connected and does not connect again in time;
268
+ * - `FEATURE_UNAVAILABLE` when the machine does not offer `leaflow.fleet.mcp.v1`;
269
+ * - `USER_NOT_FOUND`, `USER_NOT_ALLOWED`, `ACCOUNT_EXPIRED` or `PAM_PERMISSION_DENIED` when
270
+ * the machine refuses the account, as for opening a session;
271
+ * - `MCP_START_FAILED` when the machine could not start MCP for the caller's account;
272
+ * - `MACHINE_TIMEOUT` when the machine did not answer in time.
273
+ * @summary Add or replace an MCP server
274
+ */
275
+ export const updateMcpServer = async (machineId, serverName, updateMcpServerRequest, options, fetchFn) => {
276
+ const getHeaders = (h) => {
277
+ if (!h)
278
+ return {};
279
+ if (h instanceof Headers)
280
+ return Object.fromEntries(h.entries());
281
+ if (Symbol.iterator in h) {
282
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
283
+ }
284
+ const headers = {};
285
+ for (const [name, value] of Object.entries(h)) {
286
+ if (value !== undefined)
287
+ headers[name] = value;
288
+ }
289
+ return headers;
290
+ };
291
+ const res = await (fetchFn ?? fetch)(getUpdateMcpServerUrl(machineId, serverName), {
292
+ ...options,
293
+ method: "PUT",
294
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
295
+ body: JSON.stringify(updateMcpServerRequest),
296
+ });
297
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
298
+ const data = body ? JSON.parse(body) : {};
299
+ return { data, status: res.status, headers: res.headers };
300
+ };
301
+ export const getDeleteMcpServerUrl = (machineId, serverName, params) => {
302
+ const normalizedParams = new URLSearchParams();
303
+ Object.entries(params || {}).forEach(([key, value]) => {
304
+ if (value !== undefined) {
305
+ normalizedParams.append(key, value === null ? "null" : String(value));
306
+ }
307
+ });
308
+ const stringifiedParams = normalizedParams.toString();
309
+ return stringifiedParams.length > 0
310
+ ? `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}/mcp-servers/${encodeURIComponent(String(serverName))}?${stringifiedParams}`
311
+ : `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}/mcp-servers/${encodeURIComponent(String(serverName))}`;
312
+ };
313
+ /**
314
+ * Removes a server from the caller's MCP configuration on the machine and stops it. Removing
315
+ * one that is not configured succeeds. Requires `fleet:machines.login` on the machine.
316
+ *
317
+ * Fails as replacing a server does.
318
+ * @summary Remove an MCP server
319
+ */
320
+ export const deleteMcpServer = async (machineId, serverName, params, options, fetchFn) => {
321
+ const res = await (fetchFn ?? fetch)(getDeleteMcpServerUrl(machineId, serverName, params), {
322
+ ...options,
323
+ method: "DELETE",
324
+ });
325
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
326
+ const data = body ? JSON.parse(body) : {};
327
+ return { data, status: res.status, headers: res.headers };
328
+ };
329
+ export const getSendMcpRequestUrl = (machineId, serverName) => {
330
+ return `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}/mcp-servers/${encodeURIComponent(String(serverName))}:send`;
331
+ };
332
+ /**
333
+ * Sends one JSON-RPC request of MCP to one of the caller's servers on the machine, such as
334
+ * `tools/call`, `resources/read` or `prompts/get`, and returns the server's response. The
335
+ * machine starts or connects to the server if it is not running, and handles its
336
+ * initialization itself; a request still running when `timeout_seconds` passes is cancelled
337
+ * at the server. Requests the server makes of the client, such as for sampling, are refused,
338
+ * and its notifications, such as of progress, are dropped. A response with a JSON-RPC error
339
+ * is a successful request. Neither the request nor the response is hidden from the
340
+ * platform. Requires `fleet:machines.login` on the machine.
341
+ *
342
+ * Fails with:
343
+ * - `MCP_SERVER_NOT_FOUND` when the server is not configured;
344
+ * - `MCP_SERVER_UNAVAILABLE` when it could not be started or reached, with
345
+ * `metadata.failure`, an `McpServerFailure`;
346
+ * - `INVALID_ARGUMENT` when `request` is not one JSON-RPC request, such as a notification, or
347
+ * is one of initialization;
348
+ * - `RESULT_TOO_LARGE` when the response is larger than 8 MiB;
349
+ * - `MACHINE_OFFLINE` when the machine is not connected and does not connect again in time;
350
+ * - `FEATURE_UNAVAILABLE` when the machine does not offer `leaflow.fleet.mcp.v1`;
351
+ * - `USER_NOT_FOUND`, `USER_NOT_ALLOWED`, `ACCOUNT_EXPIRED` or `PAM_PERMISSION_DENIED` when
352
+ * the machine refuses the account, as for opening a session;
353
+ * - `MCP_START_FAILED` when the machine could not start MCP for the caller's account;
354
+ * - `MACHINE_TIMEOUT` when the machine did not answer in time.
355
+ * @summary Send an MCP request to a server
356
+ */
357
+ export const sendMcpRequest = async (machineId, serverName, sendMcpRequestRequest, options, fetchFn) => {
358
+ const getHeaders = (h) => {
359
+ if (!h)
360
+ return {};
361
+ if (h instanceof Headers)
362
+ return Object.fromEntries(h.entries());
363
+ if (Symbol.iterator in h) {
364
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
365
+ }
366
+ const headers = {};
367
+ for (const [name, value] of Object.entries(h)) {
368
+ if (value !== undefined)
369
+ headers[name] = value;
370
+ }
371
+ return headers;
372
+ };
373
+ const res = await (fetchFn ?? fetch)(getSendMcpRequestUrl(machineId, serverName), {
374
+ ...options,
375
+ method: "POST",
376
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
377
+ body: JSON.stringify(sendMcpRequestRequest),
378
+ });
379
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
380
+ const data = body ? JSON.parse(body) : {};
381
+ return { data, status: res.status, headers: res.headers };
382
+ };
383
+ export const getCallMcpToolUrl = (machineId, serverName, toolName) => {
384
+ return `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}/mcp-servers/${encodeURIComponent(String(serverName))}/tools/${encodeURIComponent(String(toolName))}:call`;
385
+ };
386
+ /**
387
+ * Calls one tool of one of the caller's servers on the machine and returns its MCP
388
+ * `CallToolResult`. A tool that reports an error, with `isError`, is a successful request. A
389
+ * tool whose name cannot appear in a path is called with `send-mcp-request`. Neither the
390
+ * arguments nor the result is hidden from the platform. Requires `fleet:machines.login` on
391
+ * the machine.
392
+ *
393
+ * Fails as sending a request does, and with `MCP_REQUEST_FAILED` when the server answers
394
+ * with a JSON-RPC error, such as for a tool it does not offer or arguments it does not
395
+ * accept, with the error's `metadata.code` and `metadata.message`.
396
+ * @summary Call an MCP tool
397
+ */
398
+ export const callMcpTool = async (machineId, serverName, toolName, callMcpToolRequest, options, fetchFn) => {
399
+ const getHeaders = (h) => {
400
+ if (!h)
401
+ return {};
402
+ if (h instanceof Headers)
403
+ return Object.fromEntries(h.entries());
404
+ if (Symbol.iterator in h) {
405
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
406
+ }
407
+ const headers = {};
408
+ for (const [name, value] of Object.entries(h)) {
409
+ if (value !== undefined)
410
+ headers[name] = value;
411
+ }
412
+ return headers;
413
+ };
414
+ const res = await (fetchFn ?? fetch)(getCallMcpToolUrl(machineId, serverName, toolName), {
415
+ ...options,
416
+ method: "POST",
417
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
418
+ body: JSON.stringify(callMcpToolRequest),
419
+ });
420
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
421
+ const data = body ? JSON.parse(body) : {};
422
+ return { data, status: res.status, headers: res.headers };
423
+ };
424
+ export const getListMcpToolsUrl = (machineId, params) => {
425
+ const normalizedParams = new URLSearchParams();
426
+ Object.entries(params || {}).forEach(([key, value]) => {
427
+ if (value !== undefined) {
428
+ normalizedParams.append(key, value === null ? "null" : String(value));
429
+ }
430
+ });
431
+ const stringifiedParams = normalizedParams.toString();
432
+ return stringifiedParams.length > 0
433
+ ? `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}/mcp-tools?${stringifiedParams}`
434
+ : `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}/mcp-tools`;
435
+ };
436
+ /**
437
+ * Lists the tools of the caller's servers on the machine, or of one of them, that match
438
+ * `query`: every word of it, ignoring case, in the tool's name, title or description. They
439
+ * are ordered by server, then by tool name. Servers that are not running are started to
440
+ * learn their tools; one that cannot be is named in `unavailable_servers`, and the others are
441
+ * listed anyway. Slow servers do not hold the request up: those still starting are named
442
+ * with `timeout` and go on starting, so that a later request lists their tools. Requires
443
+ * `fleet:machines.login` on the machine.
444
+ *
445
+ * Fails with:
446
+ * - `MCP_SERVER_NOT_FOUND` when `server` is not configured;
447
+ * - `MACHINE_OFFLINE` when the machine is not connected and does not connect again in time;
448
+ * - `FEATURE_UNAVAILABLE` when the machine does not offer `leaflow.fleet.mcp.v1`;
449
+ * - `USER_NOT_FOUND`, `USER_NOT_ALLOWED`, `ACCOUNT_EXPIRED` or `PAM_PERMISSION_DENIED` when
450
+ * the machine refuses the account, as for opening a session;
451
+ * - `MCP_START_FAILED` when the machine could not start MCP for the caller's account;
452
+ * - `MACHINE_TIMEOUT` when the machine did not answer in time.
453
+ * @summary List the caller's MCP tools on a machine
454
+ */
455
+ export const listMcpTools = async (machineId, params, options, fetchFn) => {
456
+ const res = await (fetchFn ?? fetch)(getListMcpToolsUrl(machineId, params), {
457
+ ...options,
458
+ method: "GET",
459
+ });
460
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
461
+ const data = body ? JSON.parse(body) : {};
462
+ return { data, status: res.status, headers: res.headers };
463
+ };
464
+ export const getGetPrivilegeAutoApprovalUrl = (machineId) => {
465
+ return `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}/privilege-auto-approval`;
466
+ };
467
+ /**
468
+ * Returns the caller's automatic approval of their privilege requests on the machine. Fails
469
+ * with `PRIVILEGE_AUTO_APPROVAL_NOT_FOUND` while the caller is asked every time, including
470
+ * after its `expires_at` has passed.
471
+ * @summary Get the caller's automatic approval for a machine
472
+ */
473
+ export const getPrivilegeAutoApproval = async (machineId, options, fetchFn) => {
474
+ const res = await (fetchFn ?? fetch)(getGetPrivilegeAutoApprovalUrl(machineId), {
475
+ ...options,
476
+ method: "GET",
477
+ });
478
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
479
+ const data = body ? JSON.parse(body) : {};
480
+ return { data, status: res.status, headers: res.headers };
481
+ };
482
+ export const getUpdatePrivilegeAutoApprovalUrl = (machineId) => {
483
+ return `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}/privilege-auto-approval`;
484
+ };
485
+ /**
486
+ * Approves the caller's privilege requests on the machine at once, until `expires_at`, or
487
+ * until removed when `expires_at` is null, replacing any earlier automatic approval. It
488
+ * applies to the caller's own account only, which is created if the caller has none yet,
489
+ * and only while they may become root on the machine. Fails with `INVALID_ARGUMENT` when
490
+ * `expires_at` has passed.
491
+ * @summary Approve the caller's privilege requests on a machine without asking
492
+ */
493
+ export const updatePrivilegeAutoApproval = async (machineId, updatePrivilegeAutoApprovalRequest, options, fetchFn) => {
494
+ const getHeaders = (h) => {
495
+ if (!h)
496
+ return {};
497
+ if (h instanceof Headers)
498
+ return Object.fromEntries(h.entries());
499
+ if (Symbol.iterator in h) {
500
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
501
+ }
502
+ const headers = {};
503
+ for (const [name, value] of Object.entries(h)) {
504
+ if (value !== undefined)
505
+ headers[name] = value;
506
+ }
507
+ return headers;
508
+ };
509
+ const res = await (fetchFn ?? fetch)(getUpdatePrivilegeAutoApprovalUrl(machineId), {
510
+ ...options,
511
+ method: "PUT",
512
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
513
+ body: JSON.stringify(updatePrivilegeAutoApprovalRequest),
514
+ });
515
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
516
+ const data = body ? JSON.parse(body) : {};
517
+ return { data, status: res.status, headers: res.headers };
518
+ };
519
+ export const getDeletePrivilegeAutoApprovalUrl = (machineId) => {
520
+ return `https://fleet.leaflow.cloud/api/v1/machines/${encodeURIComponent(String(machineId))}/privilege-auto-approval`;
521
+ };
522
+ /**
523
+ * Removes it: the caller is asked about every later privilege request on the machine.
524
+ * Removing one that does not exist succeeds.
525
+ * @summary Remove the caller's automatic approval for a machine
526
+ */
527
+ export const deletePrivilegeAutoApproval = async (machineId, options, fetchFn) => {
528
+ const res = await (fetchFn ?? fetch)(getDeletePrivilegeAutoApprovalUrl(machineId), {
529
+ ...options,
530
+ method: "DELETE",
531
+ });
532
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
533
+ const data = body ? JSON.parse(body) : undefined;
534
+ return { data, status: res.status, headers: res.headers };
535
+ };
536
+ export const getListPrivilegeAutoApprovalsUrl = (params) => {
537
+ const normalizedParams = new URLSearchParams();
538
+ Object.entries(params || {}).forEach(([key, value]) => {
539
+ if (value !== undefined) {
540
+ normalizedParams.append(key, value === null ? "null" : String(value));
541
+ }
542
+ });
543
+ const stringifiedParams = normalizedParams.toString();
544
+ return stringifiedParams.length > 0
545
+ ? `https://fleet.leaflow.cloud/api/v1/privilege-auto-approvals?${stringifiedParams}`
546
+ : `https://fleet.leaflow.cloud/api/v1/privilege-auto-approvals`;
547
+ };
548
+ /**
549
+ * Returns the caller's automatic approvals on the machines of the current project that are
550
+ * in effect, the most recently set first.
551
+ * @summary List the caller's automatic approvals
552
+ */
553
+ export const listPrivilegeAutoApprovals = async (params, options, fetchFn) => {
554
+ const res = await (fetchFn ?? fetch)(getListPrivilegeAutoApprovalsUrl(params), {
555
+ ...options,
556
+ method: "GET",
557
+ });
558
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
559
+ const data = body ? JSON.parse(body) : {};
560
+ return { data, status: res.status, headers: res.headers };
561
+ };
562
+ export const getListPrivilegeRequestsUrl = (params) => {
563
+ const normalizedParams = new URLSearchParams();
564
+ Object.entries(params || {}).forEach(([key, value]) => {
565
+ if (value !== undefined) {
566
+ normalizedParams.append(key, value === null ? "null" : String(value));
567
+ }
568
+ });
569
+ const stringifiedParams = normalizedParams.toString();
570
+ return stringifiedParams.length > 0
571
+ ? `https://fleet.leaflow.cloud/api/v1/privilege-requests?${stringifiedParams}`
572
+ : `https://fleet.leaflow.cloud/api/v1/privilege-requests`;
573
+ };
574
+ /**
575
+ * Returns the caller's privilege requests on the project's machines, newest first. Requests
576
+ * are kept for 30 days.
577
+ * @summary List the caller's privilege requests
578
+ */
579
+ export const listPrivilegeRequests = async (params, options, fetchFn) => {
580
+ const res = await (fetchFn ?? fetch)(getListPrivilegeRequestsUrl(params), {
581
+ ...options,
582
+ method: "GET",
583
+ });
584
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
585
+ const data = body ? JSON.parse(body) : {};
586
+ return { data, status: res.status, headers: res.headers };
587
+ };
588
+ export const getGetPrivilegeRequestUrl = (requestId) => {
589
+ return `https://fleet.leaflow.cloud/api/v1/privilege-requests/${encodeURIComponent(String(requestId))}`;
590
+ };
591
+ /**
592
+ * Returns one of the caller's privilege requests.
593
+ * @summary Get a privilege request
594
+ */
595
+ export const getPrivilegeRequest = async (requestId, options, fetchFn) => {
596
+ const res = await (fetchFn ?? fetch)(getGetPrivilegeRequestUrl(requestId), {
597
+ ...options,
598
+ method: "GET",
599
+ });
600
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
601
+ const data = body ? JSON.parse(body) : {};
602
+ return { data, status: res.status, headers: res.headers };
603
+ };
604
+ export const getApprovePrivilegeRequestUrl = (requestId) => {
605
+ return `https://fleet.leaflow.cloud/api/v1/privilege-requests/${encodeURIComponent(String(requestId))}:approve`;
606
+ };
607
+ /**
608
+ * Approves one of the caller's pending requests; the waiting sudo goes on as root. Fails with
609
+ * `PRIVILEGE_REQUEST_CLOSED` when the request is no longer pending, with `metadata.state`
610
+ * giving how it ended.
611
+ * @summary Approve a privilege request
612
+ */
613
+ export const approvePrivilegeRequest = async (requestId, options, fetchFn) => {
614
+ const res = await (fetchFn ?? fetch)(getApprovePrivilegeRequestUrl(requestId), {
615
+ ...options,
616
+ method: "POST",
617
+ });
618
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
619
+ const data = body ? JSON.parse(body) : {};
620
+ return { data, status: res.status, headers: res.headers };
621
+ };
622
+ export const getDenyPrivilegeRequestUrl = (requestId) => {
623
+ return `https://fleet.leaflow.cloud/api/v1/privilege-requests/${encodeURIComponent(String(requestId))}:deny`;
624
+ };
625
+ /**
626
+ * Denies one of the caller's pending requests; the waiting sudo fails. Fails with
627
+ * `PRIVILEGE_REQUEST_CLOSED` as for approving.
628
+ * @summary Deny a privilege request
629
+ */
630
+ export const denyPrivilegeRequest = async (requestId, options, fetchFn) => {
631
+ const res = await (fetchFn ?? fetch)(getDenyPrivilegeRequestUrl(requestId), {
632
+ ...options,
633
+ method: "POST",
634
+ });
635
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
636
+ const data = body ? JSON.parse(body) : {};
637
+ return { data, status: res.status, headers: res.headers };
638
+ };
639
+ export const getFindEnrollmentByPairingCodeUrl = (params) => {
640
+ const normalizedParams = new URLSearchParams();
641
+ Object.entries(params || {}).forEach(([key, value]) => {
642
+ if (value !== undefined) {
643
+ normalizedParams.append(key, value === null ? "null" : String(value));
644
+ }
645
+ });
646
+ const stringifiedParams = normalizedParams.toString();
647
+ return stringifiedParams.length > 0
648
+ ? `https://fleet.leaflow.cloud/api/v1/enrollments:find?${stringifiedParams}`
649
+ : `https://fleet.leaflow.cloud/api/v1/enrollments:find`;
650
+ };
651
+ /**
652
+ * Returns the pending enrollment request whose pairing code matches, or no enrollment when
653
+ * none does. Mistyped codes are expected and are not an error. Letters are matched
654
+ * case-insensitively, `I` and `L` are read as `1`, `O` as `0`, and spaces and hyphens are
655
+ * ignored.
656
+ *
657
+ * Only requests that are still pending are found. A request is pending while its machine
658
+ * keeps polling; one it stops polling expires after a few hours.
659
+ *
660
+ * Requires `fleet:machines.manage`.
661
+ * @summary Find an enrollment request by its pairing code
662
+ */
663
+ export const findEnrollmentByPairingCode = async (params, options, fetchFn) => {
664
+ const res = await (fetchFn ?? fetch)(getFindEnrollmentByPairingCodeUrl(params), {
665
+ ...options,
666
+ method: "GET",
667
+ });
668
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
669
+ const data = body ? JSON.parse(body) : {};
670
+ return { data, status: res.status, headers: res.headers };
671
+ };
672
+ export const getApproveEnrollmentUrl = (enrollmentId) => {
673
+ return `https://fleet.leaflow.cloud/api/v1/enrollments/${encodeURIComponent(String(enrollmentId))}:approve`;
674
+ };
675
+ /**
676
+ * Adds the machine to the current project under the given name and returns it. The Agent
677
+ * learns the decision the next time it polls.
678
+ *
679
+ * A request that is no longer pending is rejected with `ENROLLMENT_NOT_PENDING`.
680
+ *
681
+ * Requires `fleet:machines.manage`.
682
+ * @summary Approve an enrollment request
683
+ */
684
+ export const approveEnrollment = async (enrollmentId, approveEnrollmentRequest, options, fetchFn) => {
685
+ const getHeaders = (h) => {
686
+ if (!h)
687
+ return {};
688
+ if (h instanceof Headers)
689
+ return Object.fromEntries(h.entries());
690
+ if (Symbol.iterator in h) {
691
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
692
+ }
693
+ const headers = {};
694
+ for (const [name, value] of Object.entries(h)) {
695
+ if (value !== undefined)
696
+ headers[name] = value;
697
+ }
698
+ return headers;
699
+ };
700
+ const res = await (fetchFn ?? fetch)(getApproveEnrollmentUrl(enrollmentId), {
701
+ ...options,
702
+ method: "POST",
703
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
704
+ body: JSON.stringify(approveEnrollmentRequest),
705
+ });
706
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
707
+ const data = body ? JSON.parse(body) : {};
708
+ return { data, status: res.status, headers: res.headers };
709
+ };
710
+ export const getDenyEnrollmentUrl = (enrollmentId) => {
711
+ return `https://fleet.leaflow.cloud/api/v1/enrollments/${encodeURIComponent(String(enrollmentId))}:deny`;
712
+ };
713
+ /**
714
+ * Refuses the request. The decision is final for the machine's key: the Agent stops
715
+ * polling and reports that it was denied.
716
+ *
717
+ * A request that is no longer pending is rejected with `ENROLLMENT_NOT_PENDING`.
718
+ *
719
+ * Requires `fleet:machines.manage`.
720
+ * @summary Deny an enrollment request
721
+ */
722
+ export const denyEnrollment = async (enrollmentId, options, fetchFn) => {
723
+ const res = await (fetchFn ?? fetch)(getDenyEnrollmentUrl(enrollmentId), {
724
+ ...options,
725
+ method: "POST",
726
+ });
727
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
728
+ const data = body ? JSON.parse(body) : {};
729
+ return { data, status: res.status, headers: res.headers };
730
+ };
731
+ export const getListMachineRegistrationsUrl = (params) => {
732
+ const normalizedParams = new URLSearchParams();
733
+ Object.entries(params || {}).forEach(([key, value]) => {
734
+ if (value !== undefined) {
735
+ normalizedParams.append(key, value === null ? "null" : String(value));
736
+ }
737
+ });
738
+ const stringifiedParams = normalizedParams.toString();
739
+ return stringifiedParams.length > 0
740
+ ? `https://fleet.leaflow.cloud/api/v1/machine-registrations?${stringifiedParams}`
741
+ : `https://fleet.leaflow.cloud/api/v1/machine-registrations`;
742
+ };
743
+ /**
744
+ * Returns the registrations of the current project, newest first. Registrations are kept
745
+ * for 30 days.
746
+ *
747
+ * Requires `fleet:machines.manage`.
748
+ * @summary List machine registrations
749
+ */
750
+ export const listMachineRegistrations = async (params, options, fetchFn) => {
751
+ const res = await (fetchFn ?? fetch)(getListMachineRegistrationsUrl(params), {
752
+ ...options,
753
+ method: "GET",
754
+ });
755
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
756
+ const data = body ? JSON.parse(body) : {};
757
+ return { data, status: res.status, headers: res.headers };
758
+ };
759
+ export const getCreateMachineRegistrationUrl = () => {
760
+ return `https://fleet.leaflow.cloud/api/v1/machine-registrations`;
761
+ };
762
+ /**
763
+ * Reserves a machine in the current project under the given name and returns the
764
+ * registration with a one-time token. A machine that presents the token when it enrolls
765
+ * joins the project as `registration.machine_id` without approval. The token is returned
766
+ * only in this response and cannot be read again.
767
+ *
768
+ * Requires `fleet:machines.manage`.
769
+ * @summary Create a machine registration
770
+ */
771
+ export const createMachineRegistration = async (createMachineRegistrationRequest, options, fetchFn) => {
772
+ const getHeaders = (h) => {
773
+ if (!h)
774
+ return {};
775
+ if (h instanceof Headers)
776
+ return Object.fromEntries(h.entries());
777
+ if (Symbol.iterator in h) {
778
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
779
+ }
780
+ const headers = {};
781
+ for (const [name, value] of Object.entries(h)) {
782
+ if (value !== undefined)
783
+ headers[name] = value;
784
+ }
785
+ return headers;
786
+ };
787
+ const res = await (fetchFn ?? fetch)(getCreateMachineRegistrationUrl(), {
788
+ ...options,
789
+ method: "POST",
790
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
791
+ body: JSON.stringify(createMachineRegistrationRequest),
792
+ });
793
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
794
+ const data = body ? JSON.parse(body) : {};
795
+ return { data, status: res.status, headers: res.headers };
796
+ };
797
+ export const getGetMachineRegistrationUrl = (registrationId) => {
798
+ return `https://fleet.leaflow.cloud/api/v1/machine-registrations/${encodeURIComponent(String(registrationId))}`;
799
+ };
800
+ /**
801
+ * Requires `fleet:machines.manage`.
802
+ * @summary Get a machine registration
803
+ */
804
+ export const getMachineRegistration = async (registrationId, options, fetchFn) => {
805
+ const res = await (fetchFn ?? fetch)(getGetMachineRegistrationUrl(registrationId), {
806
+ ...options,
807
+ method: "GET",
808
+ });
809
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
810
+ const data = body ? JSON.parse(body) : {};
811
+ return { data, status: res.status, headers: res.headers };
812
+ };
813
+ export const getDeleteMachineRegistrationUrl = (registrationId) => {
814
+ return `https://fleet.leaflow.cloud/api/v1/machine-registrations/${encodeURIComponent(String(registrationId))}`;
815
+ };
816
+ /**
817
+ * Revokes the registration: its token no longer enrolls a machine. Revoking a registration
818
+ * that is already revoked or expired succeeds and changes nothing else. A registration that
819
+ * a machine has used is rejected with `MACHINE_REGISTRATION_USED`; to remove that machine,
820
+ * delete the machine.
821
+ *
822
+ * Requires `fleet:machines.manage`.
823
+ * @summary Revoke a machine registration
824
+ */
825
+ export const deleteMachineRegistration = async (registrationId, options, fetchFn) => {
826
+ const res = await (fetchFn ?? fetch)(getDeleteMachineRegistrationUrl(registrationId), {
827
+ ...options,
828
+ method: "DELETE",
829
+ });
830
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
831
+ const data = body ? JSON.parse(body) : undefined;
832
+ return { data, status: res.status, headers: res.headers };
833
+ };
834
+ export const getListAccountsUrl = (params) => {
835
+ const normalizedParams = new URLSearchParams();
836
+ Object.entries(params || {}).forEach(([key, value]) => {
837
+ if (value !== undefined) {
838
+ normalizedParams.append(key, value === null ? "null" : String(value));
839
+ }
840
+ });
841
+ const stringifiedParams = normalizedParams.toString();
842
+ return stringifiedParams.length > 0
843
+ ? `https://fleet.leaflow.cloud/api/v1/accounts?${stringifiedParams}`
844
+ : `https://fleet.leaflow.cloud/api/v1/accounts`;
845
+ };
846
+ /**
847
+ * Returns the accounts of the project's members, ordered by username. A member who has never
848
+ * been able to log in to a machine has no account yet.
849
+ * @summary List accounts
850
+ */
851
+ export const listAccounts = async (params, options, fetchFn) => {
852
+ const res = await (fetchFn ?? fetch)(getListAccountsUrl(params), {
853
+ ...options,
854
+ method: "GET",
855
+ });
856
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
857
+ const data = body ? JSON.parse(body) : {};
858
+ return { data, status: res.status, headers: res.headers };
859
+ };
860
+ export const getGetAccountUrl = (accountId) => {
861
+ return `https://fleet.leaflow.cloud/api/v1/accounts/${encodeURIComponent(String(accountId))}`;
862
+ };
863
+ /**
864
+ * Returns the account of a member of the project.
865
+ * @summary Get an account
866
+ */
867
+ export const getAccount = async (accountId, options, fetchFn) => {
868
+ const res = await (fetchFn ?? fetch)(getGetAccountUrl(accountId), {
869
+ ...options,
870
+ method: "GET",
871
+ });
872
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
873
+ const data = body ? JSON.parse(body) : {};
874
+ return { data, status: res.status, headers: res.headers };
875
+ };
876
+ export const getUpdateAccountUrl = (accountId) => {
877
+ return `https://fleet.leaflow.cloud/api/v1/accounts/${encodeURIComponent(String(accountId))}`;
878
+ };
879
+ /**
880
+ * Changes the caller's own account, only the fields present in the request. The account is
881
+ * the same in every project, and a new username takes effect on the machines of all of them
882
+ * within about a minute; the uid stays, so files keep their owner.
883
+ *
884
+ * Fails with:
885
+ * - `ACCOUNT_NOT_OWNED` when the account is another member's;
886
+ * - `DIRECTORY_NAME_TAKEN` when another account or a group uses the username.
887
+ * @summary Update an account
888
+ */
889
+ export const updateAccount = async (accountId, updateAccountRequest, options, fetchFn) => {
890
+ const getHeaders = (h) => {
891
+ if (!h)
892
+ return {};
893
+ if (h instanceof Headers)
894
+ return Object.fromEntries(h.entries());
895
+ if (Symbol.iterator in h) {
896
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
897
+ }
898
+ const headers = {};
899
+ for (const [name, value] of Object.entries(h)) {
900
+ if (value !== undefined)
901
+ headers[name] = value;
902
+ }
903
+ return headers;
904
+ };
905
+ const res = await (fetchFn ?? fetch)(getUpdateAccountUrl(accountId), {
906
+ ...options,
907
+ method: "PATCH",
908
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
909
+ body: JSON.stringify(updateAccountRequest),
910
+ });
911
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
912
+ const data = body ? JSON.parse(body) : {};
913
+ return { data, status: res.status, headers: res.headers };
914
+ };
915
+ export const getListGroupsUrl = (params) => {
916
+ const normalizedParams = new URLSearchParams();
917
+ Object.entries(params || {}).forEach(([key, value]) => {
918
+ if (value !== undefined) {
919
+ normalizedParams.append(key, value === null ? "null" : String(value));
920
+ }
921
+ });
922
+ const stringifiedParams = normalizedParams.toString();
923
+ return stringifiedParams.length > 0
924
+ ? `https://fleet.leaflow.cloud/api/v1/groups?${stringifiedParams}`
925
+ : `https://fleet.leaflow.cloud/api/v1/groups`;
926
+ };
927
+ /**
928
+ * Returns the groups of the project's directory, ordered by name.
929
+ * @summary List groups
930
+ */
931
+ export const listGroups = async (params, options, fetchFn) => {
932
+ const res = await (fetchFn ?? fetch)(getListGroupsUrl(params), {
933
+ ...options,
934
+ method: "GET",
935
+ });
936
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
937
+ const data = body ? JSON.parse(body) : {};
938
+ return { data, status: res.status, headers: res.headers };
939
+ };
940
+ export const getCreateGroupUrl = () => {
941
+ return `https://fleet.leaflow.cloud/api/v1/groups`;
942
+ };
943
+ /**
944
+ * Creates a group in the project's directory. It reaches the machines within about a minute.
945
+ *
946
+ * Fails with `DIRECTORY_NAME_TAKEN` when an account, or another group of the project, uses the
947
+ * name.
948
+ *
949
+ * Requires `fleet:directory.manage`.
950
+ * @summary Create a group
951
+ */
952
+ export const createGroup = async (createGroupRequest, options, fetchFn) => {
953
+ const getHeaders = (h) => {
954
+ if (!h)
955
+ return {};
956
+ if (h instanceof Headers)
957
+ return Object.fromEntries(h.entries());
958
+ if (Symbol.iterator in h) {
959
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
960
+ }
961
+ const headers = {};
962
+ for (const [name, value] of Object.entries(h)) {
963
+ if (value !== undefined)
964
+ headers[name] = value;
965
+ }
966
+ return headers;
967
+ };
968
+ const res = await (fetchFn ?? fetch)(getCreateGroupUrl(), {
969
+ ...options,
970
+ method: "POST",
971
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
972
+ body: JSON.stringify(createGroupRequest),
973
+ });
974
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
975
+ const data = body ? JSON.parse(body) : {};
976
+ return { data, status: res.status, headers: res.headers };
977
+ };
978
+ export const getGetGroupUrl = (groupId) => {
979
+ return `https://fleet.leaflow.cloud/api/v1/groups/${encodeURIComponent(String(groupId))}`;
980
+ };
981
+ /**
982
+ * @summary Get a group
983
+ */
984
+ export const getGroup = async (groupId, options, fetchFn) => {
985
+ const res = await (fetchFn ?? fetch)(getGetGroupUrl(groupId), {
986
+ ...options,
987
+ method: "GET",
988
+ });
989
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
990
+ const data = body ? JSON.parse(body) : {};
991
+ return { data, status: res.status, headers: res.headers };
992
+ };
993
+ export const getUpdateGroupUrl = (groupId) => {
994
+ return `https://fleet.leaflow.cloud/api/v1/groups/${encodeURIComponent(String(groupId))}`;
995
+ };
996
+ /**
997
+ * The gid stays, so files keep their group. Fails with `DIRECTORY_NAME_TAKEN` as for creating
998
+ * a group.
999
+ *
1000
+ * Requires `fleet:directory.manage`.
1001
+ * @summary Rename a group
1002
+ */
1003
+ export const updateGroup = async (groupId, updateGroupRequest, options, fetchFn) => {
1004
+ const getHeaders = (h) => {
1005
+ if (!h)
1006
+ return {};
1007
+ if (h instanceof Headers)
1008
+ return Object.fromEntries(h.entries());
1009
+ if (Symbol.iterator in h) {
1010
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1011
+ }
1012
+ const headers = {};
1013
+ for (const [name, value] of Object.entries(h)) {
1014
+ if (value !== undefined)
1015
+ headers[name] = value;
1016
+ }
1017
+ return headers;
1018
+ };
1019
+ const res = await (fetchFn ?? fetch)(getUpdateGroupUrl(groupId), {
1020
+ ...options,
1021
+ method: "PATCH",
1022
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
1023
+ body: JSON.stringify(updateGroupRequest),
1024
+ });
1025
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1026
+ const data = body ? JSON.parse(body) : {};
1027
+ return { data, status: res.status, headers: res.headers };
1028
+ };
1029
+ export const getDeleteGroupUrl = (groupId) => {
1030
+ return `https://fleet.leaflow.cloud/api/v1/groups/${encodeURIComponent(String(groupId))}`;
1031
+ };
1032
+ /**
1033
+ * Removes the group from the directory. Machines stop resolving it within about a minute;
1034
+ * files keep its gid.
1035
+ *
1036
+ * Requires `fleet:directory.manage`.
1037
+ * @summary Delete a group
1038
+ */
1039
+ export const deleteGroup = async (groupId, options, fetchFn) => {
1040
+ const res = await (fetchFn ?? fetch)(getDeleteGroupUrl(groupId), {
1041
+ ...options,
1042
+ method: "DELETE",
1043
+ });
1044
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1045
+ const data = body ? JSON.parse(body) : undefined;
1046
+ return { data, status: res.status, headers: res.headers };
1047
+ };
1048
+ export const getListGroupMembersUrl = (groupId, params) => {
1049
+ const normalizedParams = new URLSearchParams();
1050
+ Object.entries(params || {}).forEach(([key, value]) => {
1051
+ if (value !== undefined) {
1052
+ normalizedParams.append(key, value === null ? "null" : String(value));
1053
+ }
1054
+ });
1055
+ const stringifiedParams = normalizedParams.toString();
1056
+ return stringifiedParams.length > 0
1057
+ ? `https://fleet.leaflow.cloud/api/v1/groups/${encodeURIComponent(String(groupId))}/members?${stringifiedParams}`
1058
+ : `https://fleet.leaflow.cloud/api/v1/groups/${encodeURIComponent(String(groupId))}/members`;
1059
+ };
1060
+ /**
1061
+ * Returns the accounts in the group, ordered by username.
1062
+ * @summary List the members of a group
1063
+ */
1064
+ export const listGroupMembers = async (groupId, params, options, fetchFn) => {
1065
+ const res = await (fetchFn ?? fetch)(getListGroupMembersUrl(groupId, params), {
1066
+ ...options,
1067
+ method: "GET",
1068
+ });
1069
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1070
+ const data = body ? JSON.parse(body) : {};
1071
+ return { data, status: res.status, headers: res.headers };
1072
+ };
1073
+ export const getCreateGroupMemberUrl = (groupId) => {
1074
+ return `https://fleet.leaflow.cloud/api/v1/groups/${encodeURIComponent(String(groupId))}/members`;
1075
+ };
1076
+ /**
1077
+ * The account must be a member's. Fails with `GROUP_MEMBER_EXISTS` when the account is
1078
+ * already in the group.
1079
+ *
1080
+ * Requires `fleet:directory.manage`.
1081
+ * @summary Add an account to a group
1082
+ */
1083
+ export const createGroupMember = async (groupId, createGroupMemberRequest, options, fetchFn) => {
1084
+ const getHeaders = (h) => {
1085
+ if (!h)
1086
+ return {};
1087
+ if (h instanceof Headers)
1088
+ return Object.fromEntries(h.entries());
1089
+ if (Symbol.iterator in h) {
1090
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1091
+ }
1092
+ const headers = {};
1093
+ for (const [name, value] of Object.entries(h)) {
1094
+ if (value !== undefined)
1095
+ headers[name] = value;
1096
+ }
1097
+ return headers;
1098
+ };
1099
+ const res = await (fetchFn ?? fetch)(getCreateGroupMemberUrl(groupId), {
1100
+ ...options,
1101
+ method: "POST",
1102
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
1103
+ body: JSON.stringify(createGroupMemberRequest),
1104
+ });
1105
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1106
+ const data = body ? JSON.parse(body) : {};
1107
+ return { data, status: res.status, headers: res.headers };
1108
+ };
1109
+ export const getDeleteGroupMemberUrl = (groupId, accountId) => {
1110
+ return `https://fleet.leaflow.cloud/api/v1/groups/${encodeURIComponent(String(groupId))}/members/${encodeURIComponent(String(accountId))}`;
1111
+ };
1112
+ /**
1113
+ * Removing an account that is not in the group succeeds.
1114
+ *
1115
+ * Requires `fleet:directory.manage`.
1116
+ * @summary Remove an account from a group
1117
+ */
1118
+ export const deleteGroupMember = async (groupId, accountId, options, fetchFn) => {
1119
+ const res = await (fetchFn ?? fetch)(getDeleteGroupMemberUrl(groupId, accountId), {
1120
+ ...options,
1121
+ method: "DELETE",
1122
+ });
1123
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1124
+ const data = body ? JSON.parse(body) : undefined;
1125
+ return { data, status: res.status, headers: res.headers };
1126
+ };
1127
+ export const getListSessionsUrl = (params) => {
1128
+ const normalizedParams = new URLSearchParams();
1129
+ Object.entries(params || {}).forEach(([key, value]) => {
1130
+ if (value !== undefined) {
1131
+ normalizedParams.append(key, value === null ? "null" : String(value));
1132
+ }
1133
+ });
1134
+ const stringifiedParams = normalizedParams.toString();
1135
+ return stringifiedParams.length > 0
1136
+ ? `https://fleet.leaflow.cloud/api/v1/sessions?${stringifiedParams}`
1137
+ : `https://fleet.leaflow.cloud/api/v1/sessions`;
1138
+ };
1139
+ /**
1140
+ * Returns the sessions of the current project's machines, newest first. Closed sessions are
1141
+ * omitted unless `include_closed` is true.
1142
+ * @summary List sessions
1143
+ */
1144
+ export const listSessions = async (params, options, fetchFn) => {
1145
+ const res = await (fetchFn ?? fetch)(getListSessionsUrl(params), {
1146
+ ...options,
1147
+ method: "GET",
1148
+ });
1149
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1150
+ const data = body ? JSON.parse(body) : {};
1151
+ return { data, status: res.status, headers: res.headers };
1152
+ };
1153
+ export const getCreateSessionUrl = () => {
1154
+ return `https://fleet.leaflow.cloud/api/v1/sessions`;
1155
+ };
1156
+ /**
1157
+ * Opens a session for the caller on a machine, as the caller's account, and returns once it
1158
+ * is ready. With `desktop` the session has a desktop. Without, it is a terminal session: its
1159
+ * one terminal runs the caller's login shell from the start, every participant attaches to
1160
+ * that terminal, and the session ends when the shell exits; a caller who wants another
1161
+ * terminal opens another session. Either kind also offers programs, files, ports, sound,
1162
+ * devices, printers and privilege approvals. The account is created if the caller has none
1163
+ * yet. Requires `fleet:machines.login` on the machine.
1164
+ *
1165
+ * On a machine an account has at most one session with a desktop and at most 8 sessions in
1166
+ * all. Sessions without a desktop run side by side, such as one for a program and one for a
1167
+ * person; several participants can also share one session.
1168
+ *
1169
+ * Fails with:
1170
+ * - `MACHINE_OFFLINE` when the machine is not connected and does not connect again in time;
1171
+ * - `FEATURE_UNAVAILABLE` when the machine does not offer sessions, or with `desktop`,
1172
+ * desktops;
1173
+ * - `USER_HAS_DESKTOP_SESSION` with `desktop` when the account already has a session with a
1174
+ * desktop on the machine, which `metadata.sessionId` names; connect to it instead;
1175
+ * - `SESSION_LIMIT_REACHED` when the account already has 8 open sessions on the machine;
1176
+ * close one first;
1177
+ * - `USER_NOT_FOUND`, `USER_NOT_ALLOWED`, `ACCOUNT_EXPIRED` or `PAM_PERMISSION_DENIED` when
1178
+ * the machine refuses the account, such as while it has not received the account yet or a
1179
+ * local account uses its name; `PAM_PERMISSION_DENIED` carries the machine's message in
1180
+ * `metadata.pamMessage`;
1181
+ * - `SESSION_CONFLICT` with `desktop` when the account has a graphical session on the
1182
+ * machine that Fleet did not open;
1183
+ * - `DISPLAY_UNAVAILABLE` or `SESSION_START_FAILED` when the machine could not start it;
1184
+ * - `MACHINE_TIMEOUT` when the machine did not answer in time. The session may still open;
1185
+ * list the sessions before trying again.
1186
+ * @summary Open a session
1187
+ */
1188
+ export const createSession = async (createSessionRequest, options, fetchFn) => {
1189
+ const getHeaders = (h) => {
1190
+ if (!h)
1191
+ return {};
1192
+ if (h instanceof Headers)
1193
+ return Object.fromEntries(h.entries());
1194
+ if (Symbol.iterator in h) {
1195
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1196
+ }
1197
+ const headers = {};
1198
+ for (const [name, value] of Object.entries(h)) {
1199
+ if (value !== undefined)
1200
+ headers[name] = value;
1201
+ }
1202
+ return headers;
1203
+ };
1204
+ const res = await (fetchFn ?? fetch)(getCreateSessionUrl(), {
1205
+ ...options,
1206
+ method: "POST",
1207
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
1208
+ body: JSON.stringify(createSessionRequest),
1209
+ });
1210
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1211
+ const data = body ? JSON.parse(body) : {};
1212
+ return { data, status: res.status, headers: res.headers };
1213
+ };
1214
+ export const getGetSessionUrl = (sessionId) => {
1215
+ return `https://fleet.leaflow.cloud/api/v1/sessions/${encodeURIComponent(String(sessionId))}`;
1216
+ };
1217
+ /**
1218
+ * @summary Get a session
1219
+ */
1220
+ export const getSession = async (sessionId, options, fetchFn) => {
1221
+ const res = await (fetchFn ?? fetch)(getGetSessionUrl(sessionId), {
1222
+ ...options,
1223
+ method: "GET",
1224
+ });
1225
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1226
+ const data = body ? JSON.parse(body) : {};
1227
+ return { data, status: res.status, headers: res.headers };
1228
+ };
1229
+ export const getCloseSessionUrl = (sessionId) => {
1230
+ return `https://fleet.leaflow.cloud/api/v1/sessions/${encodeURIComponent(String(sessionId))}:close`;
1231
+ };
1232
+ /**
1233
+ * Ends the session in order: its applications are asked to exit and get a grace period
1234
+ * before the session is terminated. Returns once the session is closed. Closing a closed
1235
+ * session succeeds.
1236
+ *
1237
+ * The owner may close their own session; closing another member's requires
1238
+ * `fleet:sessions.manage`. Fails with `MACHINE_OFFLINE` or `MACHINE_TIMEOUT` as
1239
+ * for opening a session.
1240
+ * @summary Close a session
1241
+ */
1242
+ export const closeSession = async (sessionId, options, fetchFn) => {
1243
+ const res = await (fetchFn ?? fetch)(getCloseSessionUrl(sessionId), {
1244
+ ...options,
1245
+ method: "POST",
1246
+ });
1247
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1248
+ const data = body ? JSON.parse(body) : {};
1249
+ return { data, status: res.status, headers: res.headers };
1250
+ };
1251
+ export const getTerminateSessionUrl = (sessionId) => {
1252
+ return `https://fleet.leaflow.cloud/api/v1/sessions/${encodeURIComponent(String(sessionId))}:terminate`;
1253
+ };
1254
+ /**
1255
+ * Ends the session at once, killing every process in it. Returns once the session is
1256
+ * closed. Terminating a closed session succeeds.
1257
+ *
1258
+ * The owner may terminate their own session; terminating another member's requires
1259
+ * `fleet:sessions.manage`. Fails with `MACHINE_OFFLINE` or `MACHINE_TIMEOUT` as
1260
+ * for opening a session.
1261
+ * @summary Terminate a session
1262
+ */
1263
+ export const terminateSession = async (sessionId, options, fetchFn) => {
1264
+ const res = await (fetchFn ?? fetch)(getTerminateSessionUrl(sessionId), {
1265
+ ...options,
1266
+ method: "POST",
1267
+ });
1268
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1269
+ const data = body ? JSON.parse(body) : {};
1270
+ return { data, status: res.status, headers: res.headers };
1271
+ };
1272
+ export const getGetSessionRtcConfigurationUrl = (sessionId) => {
1273
+ return `https://fleet.leaflow.cloud/api/v1/sessions/${encodeURIComponent(String(sessionId))}/rtc-configuration`;
1274
+ };
1275
+ /**
1276
+ * Returns the STUN and TURN servers for the PeerConnections the caller starts to the session,
1277
+ * with TURN credentials of its own, and the policy for using them. Ask again once
1278
+ * `expires_at` has passed; the credentials of a PeerConnection already relayed last longer.
1279
+ *
1280
+ * Requires that the caller may join the session, as for `create-participant`.
1281
+ *
1282
+ * Fails with:
1283
+ * - `SESSION_CLOSED` when the session has ended;
1284
+ * - `SESSION_ACCESS_DENIED` when the caller may not join the session.
1285
+ * @summary Get the ICE servers for a session
1286
+ */
1287
+ export const getSessionRtcConfiguration = async (sessionId, options, fetchFn) => {
1288
+ const res = await (fetchFn ?? fetch)(getGetSessionRtcConfigurationUrl(sessionId), {
1289
+ ...options,
1290
+ method: "GET",
1291
+ });
1292
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1293
+ const data = body ? JSON.parse(body) : {};
1294
+ return { data, status: res.status, headers: res.headers };
1295
+ };
1296
+ export const getCreateParticipantUrl = (sessionId) => {
1297
+ return `https://fleet.leaflow.cloud/api/v1/sessions/${encodeURIComponent(String(sessionId))}/participants`;
1298
+ };
1299
+ /**
1300
+ * Admits one participant with the given public key to the session: signs its authorization,
1301
+ * has the session accept it, and starts its first PeerConnection with the offer. The answer
1302
+ * carries the participant, its authorization and the PeerConnection with the session's
1303
+ * answer. The participant lasts while it is renewed.
1304
+ *
1305
+ * Joining again with the public key of one of the caller's participants of the session that
1306
+ * has not ended, with the same `client_name`, `read_only` and `permissions`, returns that
1307
+ * participant with a new PeerConnection for the offer, and the session gains no second
1308
+ * participant: a request whose answer was lost, such as on an unreliable network, is sent
1309
+ * again as it was. Its earlier PeerConnection, whose answer the client never received, is
1310
+ * given up by the session once it fails.
1311
+ *
1312
+ * The owner of a session may operate it. Joining another member's session requires
1313
+ * `fleet:sessions.view`, which admits watching only, or
1314
+ * `fleet:sessions.control`, which also admits operating it. Each further capability
1315
+ * of the session — file transfer, the clipboard, terminals and programs, port forwarding,
1316
+ * devices and audio, printing, SSH agent forwarding, approving privilege requests and
1317
+ * reading logs — is granted only with its permission; a participant that may only watch gets
1318
+ * none of them. A request may ask for less: to watch only, or for some of the capabilities.
1319
+ *
1320
+ * Fails with the following, and then no participant was created:
1321
+ * - `SESSION_CLOSED` when the session has ended;
1322
+ * - `SESSION_ACCESS_DENIED` when the caller may not join the session;
1323
+ * - `OFFER_INVALID` when the offer is not an SDP offer that names a SHA-256 DTLS fingerprint;
1324
+ * - `SESSION_UNAVAILABLE` when the session's process is not connected and does not connect
1325
+ * again in time, or did not answer in time; try again after the error's `retry_delay`;
1326
+ * - `PARTICIPANT_LIMIT_REACHED` when the session has as many participants as it admits;
1327
+ * - `PARTICIPANT_REFUSED` when the session refused the participant;
1328
+ * - `PARTICIPANT_KEY_IN_USE` when the public key belongs to a participant of the session that
1329
+ * another user holds, or that was created with another `client_name`, `read_only` or
1330
+ * `permissions`; join with a new key;
1331
+ * - `PEER_CONNECTION_ABORTED` when the session gave up the PeerConnection; try again with a
1332
+ * new offer. The participant of a repeated request stays.
1333
+ * @summary Join a session
1334
+ */
1335
+ export const createParticipant = async (sessionId, createParticipantRequest, options, fetchFn) => {
1336
+ const getHeaders = (h) => {
1337
+ if (!h)
1338
+ return {};
1339
+ if (h instanceof Headers)
1340
+ return Object.fromEntries(h.entries());
1341
+ if (Symbol.iterator in h) {
1342
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1343
+ }
1344
+ const headers = {};
1345
+ for (const [name, value] of Object.entries(h)) {
1346
+ if (value !== undefined)
1347
+ headers[name] = value;
1348
+ }
1349
+ return headers;
1350
+ };
1351
+ const res = await (fetchFn ?? fetch)(getCreateParticipantUrl(sessionId), {
1352
+ ...options,
1353
+ method: "POST",
1354
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
1355
+ body: JSON.stringify(createParticipantRequest),
1356
+ });
1357
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1358
+ const data = body ? JSON.parse(body) : {};
1359
+ return { data, status: res.status, headers: res.headers };
1360
+ };
1361
+ export const getListSessionParticipantsUrl = (sessionId) => {
1362
+ return `https://fleet.leaflow.cloud/api/v1/sessions/${encodeURIComponent(String(sessionId))}/participants`;
1363
+ };
1364
+ /**
1365
+ * Returns the participants of the session, in the order they joined.
1366
+ * @summary List the participants of a session
1367
+ */
1368
+ export const listSessionParticipants = async (sessionId, options, fetchFn) => {
1369
+ const res = await (fetchFn ?? fetch)(getListSessionParticipantsUrl(sessionId), {
1370
+ ...options,
1371
+ method: "GET",
1372
+ });
1373
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1374
+ const data = body ? JSON.parse(body) : {};
1375
+ return { data, status: res.status, headers: res.headers };
1376
+ };
1377
+ export const getRenewParticipantUrl = (sessionId, participantId) => {
1378
+ return `https://fleet.leaflow.cloud/api/v1/sessions/${encodeURIComponent(String(sessionId))}/participants/${encodeURIComponent(String(participantId))}:renew`;
1379
+ };
1380
+ /**
1381
+ * Extends the participant's lease and returns renewed PeerAuthorizations for the
1382
+ * PeerConnections whose current ones the request presents. The service sends them to the
1383
+ * session as well, and the participant passes each one to the session over its PeerConnection
1384
+ * (`Packet.peer_authorization` of the transport protocol), so that the lease holds while
1385
+ * either path to the session is down. A
1386
+ * presented authorization that the service did not sign for this participant, or whose
1387
+ * PeerConnection has ended, is left out of the answer. When the participant's authorization
1388
+ * nears its end, the answer carries a renewed one, which the session already holds.
1389
+ *
1390
+ * Only the participant's user may renew it.
1391
+ *
1392
+ * Fails with:
1393
+ * - `PARTICIPANT_NOT_FOUND` when the participant has ended; create another;
1394
+ * - `PARTICIPANT_PERMISSION_REVOKED` when a permission the participant was created with has
1395
+ * been revoked from the caller; it has ended, and another can be created with the
1396
+ * permissions the caller holds now;
1397
+ * - `PROJECT_MEMBERSHIP_REQUIRED` when the caller is no longer a member of the project; the
1398
+ * participant has ended.
1399
+ * @summary Renew a participant
1400
+ */
1401
+ export const renewParticipant = async (sessionId, participantId, renewParticipantRequest, options, fetchFn) => {
1402
+ const getHeaders = (h) => {
1403
+ if (!h)
1404
+ return {};
1405
+ if (h instanceof Headers)
1406
+ return Object.fromEntries(h.entries());
1407
+ if (Symbol.iterator in h) {
1408
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1409
+ }
1410
+ const headers = {};
1411
+ for (const [name, value] of Object.entries(h)) {
1412
+ if (value !== undefined)
1413
+ headers[name] = value;
1414
+ }
1415
+ return headers;
1416
+ };
1417
+ const res = await (fetchFn ?? fetch)(getRenewParticipantUrl(sessionId, participantId), {
1418
+ ...options,
1419
+ method: "POST",
1420
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
1421
+ body: JSON.stringify(renewParticipantRequest),
1422
+ });
1423
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1424
+ const data = body ? JSON.parse(body) : {};
1425
+ return { data, status: res.status, headers: res.headers };
1426
+ };
1427
+ export const getPrepareParticipantMigrationUrl = (sessionId, participantId) => {
1428
+ return `https://fleet.leaflow.cloud/api/v1/sessions/${encodeURIComponent(String(sessionId))}/participants/${encodeURIComponent(String(participantId))}:prepareMigration`;
1429
+ };
1430
+ /**
1431
+ * Passes the participant's checkpoint for the next epoch to the session and returns the
1432
+ * session's checkpoint for it: the `prepare` and `prepared` steps of `Migration` in
1433
+ * `leaflow/fleet/transport/v1/transport.proto`. Repeating the step returns the same answer.
1434
+ *
1435
+ * Only the participant's user may migrate it.
1436
+ *
1437
+ * Fails with:
1438
+ * - `PARTICIPANT_NOT_FOUND` when the participant has ended;
1439
+ * - `CHECKPOINT_INVALID` when the checkpoint is not a serialized `Checkpoint`;
1440
+ * - `SESSION_UNAVAILABLE` when the session's process is not connected and does not connect
1441
+ * again in time, or did not answer in time; try again after the error's `retry_delay`.
1442
+ * @summary Prepare a migration
1443
+ */
1444
+ export const prepareParticipantMigration = async (sessionId, participantId, migrationStep, options, fetchFn) => {
1445
+ const getHeaders = (h) => {
1446
+ if (!h)
1447
+ return {};
1448
+ if (h instanceof Headers)
1449
+ return Object.fromEntries(h.entries());
1450
+ if (Symbol.iterator in h) {
1451
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1452
+ }
1453
+ const headers = {};
1454
+ for (const [name, value] of Object.entries(h)) {
1455
+ if (value !== undefined)
1456
+ headers[name] = value;
1457
+ }
1458
+ return headers;
1459
+ };
1460
+ const res = await (fetchFn ?? fetch)(getPrepareParticipantMigrationUrl(sessionId, participantId), {
1461
+ ...options,
1462
+ method: "POST",
1463
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
1464
+ body: JSON.stringify(migrationStep),
1465
+ });
1466
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1467
+ const data = body ? JSON.parse(body) : {};
1468
+ return { data, status: res.status, headers: res.headers };
1469
+ };
1470
+ export const getCommitParticipantMigrationUrl = (sessionId, participantId) => {
1471
+ return `https://fleet.leaflow.cloud/api/v1/sessions/${encodeURIComponent(String(sessionId))}/participants/${encodeURIComponent(String(participantId))}:commitMigration`;
1472
+ };
1473
+ /**
1474
+ * Commits the epoch the participant prepared and returns the session's checkpoint once it
1475
+ * committed it: the `commit` and `committed` steps of `Migration` in
1476
+ * `leaflow/fleet/transport/v1/transport.proto`. Repeating the step returns the same answer.
1477
+ *
1478
+ * Only the participant's user may migrate it.
1479
+ *
1480
+ * Fails with:
1481
+ * - `PARTICIPANT_NOT_FOUND` when the participant has ended;
1482
+ * - `CHECKPOINT_INVALID` when the checkpoint is not a serialized `Checkpoint`;
1483
+ * - `SESSION_UNAVAILABLE` when the session's process is not connected and does not connect
1484
+ * again in time, or did not answer in time; try again after the error's `retry_delay`.
1485
+ * @summary Commit a migration
1486
+ */
1487
+ export const commitParticipantMigration = async (sessionId, participantId, migrationStep, options, fetchFn) => {
1488
+ const getHeaders = (h) => {
1489
+ if (!h)
1490
+ return {};
1491
+ if (h instanceof Headers)
1492
+ return Object.fromEntries(h.entries());
1493
+ if (Symbol.iterator in h) {
1494
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1495
+ }
1496
+ const headers = {};
1497
+ for (const [name, value] of Object.entries(h)) {
1498
+ if (value !== undefined)
1499
+ headers[name] = value;
1500
+ }
1501
+ return headers;
1502
+ };
1503
+ const res = await (fetchFn ?? fetch)(getCommitParticipantMigrationUrl(sessionId, participantId), {
1504
+ ...options,
1505
+ method: "POST",
1506
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
1507
+ body: JSON.stringify(migrationStep),
1508
+ });
1509
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1510
+ const data = body ? JSON.parse(body) : {};
1511
+ return { data, status: res.status, headers: res.headers };
1512
+ };
1513
+ export const getCreatePeerConnectionUrl = (sessionId, participantId) => {
1514
+ return `https://fleet.leaflow.cloud/api/v1/sessions/${encodeURIComponent(String(sessionId))}/participants/${encodeURIComponent(String(participantId))}/peer-connections`;
1515
+ };
1516
+ /**
1517
+ * Starts another PeerConnection of the participant with the offer, such as after a path
1518
+ * failed, and returns the session's answer, its ICE candidates and the signed
1519
+ * PeerAuthorization. Move the participant's connection to it with
1520
+ * `prepare-participant-migration` and `commit-participant-migration`.
1521
+ *
1522
+ * Only the participant's user may start one.
1523
+ *
1524
+ * Fails with:
1525
+ * - `PARTICIPANT_NOT_FOUND` when the participant has ended;
1526
+ * - `OFFER_INVALID` when the offer is not an SDP offer that names a SHA-256 DTLS fingerprint;
1527
+ * - `RATE_LIMIT_EXCEEDED` when the participant started too many PeerConnections in the
1528
+ * last minute; try again after the error's `retry_delay`;
1529
+ * - `SESSION_UNAVAILABLE` when the session's process is not connected and does not connect
1530
+ * again in time, or did not answer in time; try again after the error's `retry_delay`;
1531
+ * - `PEER_CONNECTION_ABORTED` when the session gave up the PeerConnection; start another.
1532
+ * @summary Start a PeerConnection
1533
+ */
1534
+ export const createPeerConnection = async (sessionId, participantId, createPeerConnectionRequest, options, fetchFn) => {
1535
+ const getHeaders = (h) => {
1536
+ if (!h)
1537
+ return {};
1538
+ if (h instanceof Headers)
1539
+ return Object.fromEntries(h.entries());
1540
+ if (Symbol.iterator in h) {
1541
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1542
+ }
1543
+ const headers = {};
1544
+ for (const [name, value] of Object.entries(h)) {
1545
+ if (value !== undefined)
1546
+ headers[name] = value;
1547
+ }
1548
+ return headers;
1549
+ };
1550
+ const res = await (fetchFn ?? fetch)(getCreatePeerConnectionUrl(sessionId, participantId), {
1551
+ ...options,
1552
+ method: "POST",
1553
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
1554
+ body: JSON.stringify(createPeerConnectionRequest),
1555
+ });
1556
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1557
+ const data = body ? JSON.parse(body) : {};
1558
+ return { data, status: res.status, headers: res.headers };
1559
+ };
1560
+ export const getDeletePeerConnectionUrl = (sessionId, participantId, peerConnectionId) => {
1561
+ return `https://fleet.leaflow.cloud/api/v1/sessions/${encodeURIComponent(String(sessionId))}/participants/${encodeURIComponent(String(participantId))}/peer-connections/${encodeURIComponent(String(peerConnectionId))}`;
1562
+ };
1563
+ /**
1564
+ * Tells the session to give up the PeerConnection and close it. Abandoning a PeerConnection
1565
+ * that has ended succeeds.
1566
+ *
1567
+ * Only the participant's user may abandon it.
1568
+ *
1569
+ * Fails with `PARTICIPANT_NOT_FOUND` when the participant has ended.
1570
+ * @summary Abandon a PeerConnection
1571
+ */
1572
+ export const deletePeerConnection = async (sessionId, participantId, peerConnectionId, options, fetchFn) => {
1573
+ const res = await (fetchFn ?? fetch)(getDeletePeerConnectionUrl(sessionId, participantId, peerConnectionId), {
1574
+ ...options,
1575
+ method: "DELETE",
1576
+ });
1577
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1578
+ const data = body ? JSON.parse(body) : undefined;
1579
+ return { data, status: res.status, headers: res.headers };
1580
+ };
1581
+ export const getCreatePeerConnectionCandidatesUrl = (sessionId, participantId, peerConnectionId) => {
1582
+ return `https://fleet.leaflow.cloud/api/v1/sessions/${encodeURIComponent(String(sessionId))}/participants/${encodeURIComponent(String(participantId))}/peer-connections/${encodeURIComponent(String(peerConnectionId))}/candidates`;
1583
+ };
1584
+ /**
1585
+ * Passes the ICE candidates the participant gathered after its offer to the session, and with
1586
+ * `end_of_candidates`, that it has gathered all (RFC 8838). The session ignores those of a
1587
+ * PeerConnection that has ended.
1588
+ *
1589
+ * Only the participant's user may add them.
1590
+ *
1591
+ * Fails with:
1592
+ * - `PARTICIPANT_NOT_FOUND` when the participant has ended;
1593
+ * - `SESSION_UNAVAILABLE` when the session's process is not connected and does not connect
1594
+ * again in time; try again after the error's `retry_delay`.
1595
+ * @summary Add ICE candidates to a PeerConnection
1596
+ */
1597
+ export const createPeerConnectionCandidates = async (sessionId, participantId, peerConnectionId, createPeerConnectionCandidatesRequest, options, fetchFn) => {
1598
+ const getHeaders = (h) => {
1599
+ if (!h)
1600
+ return {};
1601
+ if (h instanceof Headers)
1602
+ return Object.fromEntries(h.entries());
1603
+ if (Symbol.iterator in h) {
1604
+ return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
1605
+ }
1606
+ const headers = {};
1607
+ for (const [name, value] of Object.entries(h)) {
1608
+ if (value !== undefined)
1609
+ headers[name] = value;
1610
+ }
1611
+ return headers;
1612
+ };
1613
+ const res = await (fetchFn ?? fetch)(getCreatePeerConnectionCandidatesUrl(sessionId, participantId, peerConnectionId), {
1614
+ ...options,
1615
+ method: "POST",
1616
+ headers: { "Content-Type": "application/json", ...getHeaders(options?.headers) },
1617
+ body: JSON.stringify(createPeerConnectionCandidatesRequest),
1618
+ });
1619
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1620
+ const data = body ? JSON.parse(body) : undefined;
1621
+ return {
1622
+ data,
1623
+ status: res.status,
1624
+ headers: res.headers,
1625
+ };
1626
+ };
1627
+ export const getGetParticipantUrl = (sessionId, participantId) => {
1628
+ return `https://fleet.leaflow.cloud/api/v1/sessions/${encodeURIComponent(String(sessionId))}/participants/${encodeURIComponent(String(participantId))}`;
1629
+ };
1630
+ /**
1631
+ * Returns a participant of the session.
1632
+ * @summary Get a participant of a session
1633
+ */
1634
+ export const getParticipant = async (sessionId, participantId, options, fetchFn) => {
1635
+ const res = await (fetchFn ?? fetch)(getGetParticipantUrl(sessionId, participantId), {
1636
+ ...options,
1637
+ method: "GET",
1638
+ });
1639
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1640
+ const data = body ? JSON.parse(body) : {};
1641
+ return { data, status: res.status, headers: res.headers };
1642
+ };
1643
+ export const getDeleteParticipantUrl = (sessionId, participantId) => {
1644
+ return `https://fleet.leaflow.cloud/api/v1/sessions/${encodeURIComponent(String(sessionId))}/participants/${encodeURIComponent(String(participantId))}`;
1645
+ };
1646
+ /**
1647
+ * Ends the participant: the session detaches it and closes its PeerConnections, and the
1648
+ * session goes on. A participant leaves this way; others are disconnected this way.
1649
+ *
1650
+ * The participant's user and the owner of the session may end it; otherwise this
1651
+ * requires `fleet:sessions.manage`.
1652
+ * @summary End a participant
1653
+ */
1654
+ export const deleteParticipant = async (sessionId, participantId, options, fetchFn) => {
1655
+ const res = await (fetchFn ?? fetch)(getDeleteParticipantUrl(sessionId, participantId), {
1656
+ ...options,
1657
+ method: "DELETE",
1658
+ });
1659
+ const body = [204, 205, 304].includes(res.status) ? null : await res.text();
1660
+ const data = body ? JSON.parse(body) : undefined;
1661
+ return { data, status: res.status, headers: res.headers };
1662
+ };