@arcadeai/arcadejs 0.1.2

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 (249) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/LICENSE +201 -0
  3. package/README.md +305 -0
  4. package/_shims/MultipartBody.d.ts +9 -0
  5. package/_shims/MultipartBody.d.ts.map +1 -0
  6. package/_shims/MultipartBody.js +16 -0
  7. package/_shims/MultipartBody.js.map +1 -0
  8. package/_shims/MultipartBody.mjs +12 -0
  9. package/_shims/MultipartBody.mjs.map +1 -0
  10. package/_shims/README.md +46 -0
  11. package/_shims/auto/runtime-bun.d.ts +5 -0
  12. package/_shims/auto/runtime-bun.d.ts.map +1 -0
  13. package/_shims/auto/runtime-bun.js +21 -0
  14. package/_shims/auto/runtime-bun.js.map +1 -0
  15. package/_shims/auto/runtime-bun.mjs +2 -0
  16. package/_shims/auto/runtime-bun.mjs.map +1 -0
  17. package/_shims/auto/runtime-node.d.ts +5 -0
  18. package/_shims/auto/runtime-node.d.ts.map +1 -0
  19. package/_shims/auto/runtime-node.js +21 -0
  20. package/_shims/auto/runtime-node.js.map +1 -0
  21. package/_shims/auto/runtime-node.mjs +2 -0
  22. package/_shims/auto/runtime-node.mjs.map +1 -0
  23. package/_shims/auto/runtime.d.ts +5 -0
  24. package/_shims/auto/runtime.d.ts.map +1 -0
  25. package/_shims/auto/runtime.js +21 -0
  26. package/_shims/auto/runtime.js.map +1 -0
  27. package/_shims/auto/runtime.mjs +2 -0
  28. package/_shims/auto/runtime.mjs.map +1 -0
  29. package/_shims/auto/types-node.d.ts +5 -0
  30. package/_shims/auto/types-node.d.ts.map +1 -0
  31. package/_shims/auto/types-node.js +21 -0
  32. package/_shims/auto/types-node.js.map +1 -0
  33. package/_shims/auto/types-node.mjs +2 -0
  34. package/_shims/auto/types-node.mjs.map +1 -0
  35. package/_shims/auto/types.d.ts +101 -0
  36. package/_shims/auto/types.js +3 -0
  37. package/_shims/auto/types.mjs +3 -0
  38. package/_shims/bun-runtime.d.ts +6 -0
  39. package/_shims/bun-runtime.d.ts.map +1 -0
  40. package/_shims/bun-runtime.js +14 -0
  41. package/_shims/bun-runtime.js.map +1 -0
  42. package/_shims/bun-runtime.mjs +10 -0
  43. package/_shims/bun-runtime.mjs.map +1 -0
  44. package/_shims/index.d.ts +81 -0
  45. package/_shims/index.js +13 -0
  46. package/_shims/index.mjs +7 -0
  47. package/_shims/manual-types.d.ts +12 -0
  48. package/_shims/manual-types.js +3 -0
  49. package/_shims/manual-types.mjs +3 -0
  50. package/_shims/node-runtime.d.ts +3 -0
  51. package/_shims/node-runtime.d.ts.map +1 -0
  52. package/_shims/node-runtime.js +89 -0
  53. package/_shims/node-runtime.js.map +1 -0
  54. package/_shims/node-runtime.mjs +56 -0
  55. package/_shims/node-runtime.mjs.map +1 -0
  56. package/_shims/node-types.d.ts +42 -0
  57. package/_shims/node-types.js +3 -0
  58. package/_shims/node-types.mjs +3 -0
  59. package/_shims/registry.d.ts +37 -0
  60. package/_shims/registry.d.ts.map +1 -0
  61. package/_shims/registry.js +41 -0
  62. package/_shims/registry.js.map +1 -0
  63. package/_shims/registry.mjs +37 -0
  64. package/_shims/registry.mjs.map +1 -0
  65. package/_shims/web-runtime.d.ts +5 -0
  66. package/_shims/web-runtime.d.ts.map +1 -0
  67. package/_shims/web-runtime.js +78 -0
  68. package/_shims/web-runtime.js.map +1 -0
  69. package/_shims/web-runtime.mjs +71 -0
  70. package/_shims/web-runtime.mjs.map +1 -0
  71. package/_shims/web-types.d.ts +83 -0
  72. package/_shims/web-types.js +3 -0
  73. package/_shims/web-types.mjs +3 -0
  74. package/core.d.ts +242 -0
  75. package/core.d.ts.map +1 -0
  76. package/core.js +903 -0
  77. package/core.js.map +1 -0
  78. package/core.mjs +871 -0
  79. package/core.mjs.map +1 -0
  80. package/error.d.ts +53 -0
  81. package/error.d.ts.map +1 -0
  82. package/error.js +143 -0
  83. package/error.js.map +1 -0
  84. package/error.mjs +127 -0
  85. package/error.mjs.map +1 -0
  86. package/index.d.mts +146 -0
  87. package/index.d.ts +146 -0
  88. package/index.d.ts.map +1 -0
  89. package/index.js +118 -0
  90. package/index.js.map +1 -0
  91. package/index.mjs +90 -0
  92. package/index.mjs.map +1 -0
  93. package/package.json +103 -0
  94. package/pagination.d.ts +26 -0
  95. package/pagination.d.ts.map +1 -0
  96. package/pagination.js +46 -0
  97. package/pagination.js.map +1 -0
  98. package/pagination.mjs +42 -0
  99. package/pagination.mjs.map +1 -0
  100. package/resource.d.ts +6 -0
  101. package/resource.d.ts.map +1 -0
  102. package/resource.js +11 -0
  103. package/resource.js.map +1 -0
  104. package/resource.mjs +7 -0
  105. package/resource.mjs.map +1 -0
  106. package/resources/auth.d.ts +68 -0
  107. package/resources/auth.d.ts.map +1 -0
  108. package/resources/auth.js +25 -0
  109. package/resources/auth.js.map +1 -0
  110. package/resources/auth.mjs +21 -0
  111. package/resources/auth.mjs.map +1 -0
  112. package/resources/chat/chat.d.ts +136 -0
  113. package/resources/chat/chat.d.ts.map +1 -0
  114. package/resources/chat/chat.js +40 -0
  115. package/resources/chat/chat.js.map +1 -0
  116. package/resources/chat/chat.mjs +13 -0
  117. package/resources/chat/chat.mjs.map +1 -0
  118. package/resources/chat/completions.d.ts +76 -0
  119. package/resources/chat/completions.d.ts.map +1 -0
  120. package/resources/chat/completions.js +17 -0
  121. package/resources/chat/completions.js.map +1 -0
  122. package/resources/chat/completions.mjs +13 -0
  123. package/resources/chat/completions.mjs.map +1 -0
  124. package/resources/chat/index.d.ts +3 -0
  125. package/resources/chat/index.d.ts.map +1 -0
  126. package/resources/chat/index.js +9 -0
  127. package/resources/chat/index.js.map +1 -0
  128. package/resources/chat/index.mjs +4 -0
  129. package/resources/chat/index.mjs.map +1 -0
  130. package/resources/health.d.ts +16 -0
  131. package/resources/health.d.ts.map +1 -0
  132. package/resources/health.js +17 -0
  133. package/resources/health.js.map +1 -0
  134. package/resources/health.mjs +13 -0
  135. package/resources/health.mjs.map +1 -0
  136. package/resources/index.d.ts +6 -0
  137. package/resources/index.d.ts.map +1 -0
  138. package/resources/index.js +28 -0
  139. package/resources/index.js.map +1 -0
  140. package/resources/index.mjs +7 -0
  141. package/resources/index.mjs.map +1 -0
  142. package/resources/shared.d.ts +30 -0
  143. package/resources/shared.d.ts.map +1 -0
  144. package/resources/shared.js +9 -0
  145. package/resources/shared.js.map +1 -0
  146. package/resources/shared.mjs +5 -0
  147. package/resources/shared.mjs.map +1 -0
  148. package/resources/tools/definition.d.ts +24 -0
  149. package/resources/tools/definition.d.ts.map +1 -0
  150. package/resources/tools/definition.js +17 -0
  151. package/resources/tools/definition.js.map +1 -0
  152. package/resources/tools/definition.mjs +13 -0
  153. package/resources/tools/definition.mjs.map +1 -0
  154. package/resources/tools/formatted.d.ts +48 -0
  155. package/resources/tools/formatted.d.ts.map +1 -0
  156. package/resources/tools/formatted.js +56 -0
  157. package/resources/tools/formatted.js.map +1 -0
  158. package/resources/tools/formatted.mjs +28 -0
  159. package/resources/tools/formatted.mjs.map +1 -0
  160. package/resources/tools/index.d.ts +3 -0
  161. package/resources/tools/index.d.ts.map +1 -0
  162. package/resources/tools/index.js +10 -0
  163. package/resources/tools/index.js.map +1 -0
  164. package/resources/tools/index.mjs +4 -0
  165. package/resources/tools/index.mjs.map +1 -0
  166. package/resources/tools/tools.d.ts +169 -0
  167. package/resources/tools/tools.d.ts.map +1 -0
  168. package/resources/tools/tools.js +68 -0
  169. package/resources/tools/tools.js.map +1 -0
  170. package/resources/tools/tools.mjs +41 -0
  171. package/resources/tools/tools.mjs.map +1 -0
  172. package/resources/tools.d.ts +161 -0
  173. package/resources/tools.d.ts.map +1 -0
  174. package/resources/tools.js +38 -0
  175. package/resources/tools.js.map +1 -0
  176. package/resources/tools.mjs +34 -0
  177. package/resources/tools.mjs.map +1 -0
  178. package/shims/node.d.ts +30 -0
  179. package/shims/node.d.ts.map +1 -0
  180. package/shims/node.js +31 -0
  181. package/shims/node.js.map +1 -0
  182. package/shims/node.mjs +5 -0
  183. package/shims/node.mjs.map +1 -0
  184. package/shims/web.d.ts +26 -0
  185. package/shims/web.d.ts.map +1 -0
  186. package/shims/web.js +31 -0
  187. package/shims/web.js.map +1 -0
  188. package/shims/web.mjs +5 -0
  189. package/shims/web.mjs.map +1 -0
  190. package/src/_shims/MultipartBody.ts +9 -0
  191. package/src/_shims/README.md +46 -0
  192. package/src/_shims/auto/runtime-bun.ts +4 -0
  193. package/src/_shims/auto/runtime-node.ts +4 -0
  194. package/src/_shims/auto/runtime.ts +4 -0
  195. package/src/_shims/auto/types-node.ts +4 -0
  196. package/src/_shims/auto/types.d.ts +101 -0
  197. package/src/_shims/auto/types.js +3 -0
  198. package/src/_shims/auto/types.mjs +3 -0
  199. package/src/_shims/bun-runtime.ts +14 -0
  200. package/src/_shims/index.d.ts +81 -0
  201. package/src/_shims/index.js +13 -0
  202. package/src/_shims/index.mjs +7 -0
  203. package/src/_shims/manual-types.d.ts +12 -0
  204. package/src/_shims/manual-types.js +3 -0
  205. package/src/_shims/manual-types.mjs +3 -0
  206. package/src/_shims/node-runtime.ts +81 -0
  207. package/src/_shims/node-types.d.ts +42 -0
  208. package/src/_shims/node-types.js +3 -0
  209. package/src/_shims/node-types.mjs +3 -0
  210. package/src/_shims/registry.ts +67 -0
  211. package/src/_shims/web-runtime.ts +103 -0
  212. package/src/_shims/web-types.d.ts +83 -0
  213. package/src/_shims/web-types.js +3 -0
  214. package/src/_shims/web-types.mjs +3 -0
  215. package/src/core.ts +1196 -0
  216. package/src/error.ts +146 -0
  217. package/src/index.ts +227 -0
  218. package/src/lib/.keep +4 -0
  219. package/src/pagination.ts +79 -0
  220. package/src/resource.ts +11 -0
  221. package/src/resources/auth.ts +97 -0
  222. package/src/resources/chat/chat.ts +186 -0
  223. package/src/resources/chat/completions.ts +102 -0
  224. package/src/resources/chat/index.ts +4 -0
  225. package/src/resources/health.ts +22 -0
  226. package/src/resources/index.ts +23 -0
  227. package/src/resources/shared.ts +46 -0
  228. package/src/resources/tools/definition.ts +31 -0
  229. package/src/resources/tools/formatted.ts +78 -0
  230. package/src/resources/tools/index.ts +27 -0
  231. package/src/resources/tools/tools.ts +249 -0
  232. package/src/resources/tools.ts +240 -0
  233. package/src/shims/node.ts +50 -0
  234. package/src/shims/web.ts +50 -0
  235. package/src/tsconfig.json +11 -0
  236. package/src/uploads.ts +255 -0
  237. package/src/version.ts +1 -0
  238. package/uploads.d.ts +75 -0
  239. package/uploads.d.ts.map +1 -0
  240. package/uploads.js +171 -0
  241. package/uploads.js.map +1 -0
  242. package/uploads.mjs +158 -0
  243. package/uploads.mjs.map +1 -0
  244. package/version.d.ts +2 -0
  245. package/version.d.ts.map +1 -0
  246. package/version.js +5 -0
  247. package/version.js.map +1 -0
  248. package/version.mjs +2 -0
  249. package/version.mjs.map +1 -0
package/src/error.ts ADDED
@@ -0,0 +1,146 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { castToError, Headers } from './core';
4
+
5
+ export class ArcadeError extends Error {}
6
+
7
+ export class APIError extends ArcadeError {
8
+ readonly status: number | undefined;
9
+ readonly headers: Headers | undefined;
10
+ readonly error: Object | undefined;
11
+
12
+ constructor(
13
+ status: number | undefined,
14
+ error: Object | undefined,
15
+ message: string | undefined,
16
+ headers: Headers | undefined,
17
+ ) {
18
+ super(`${APIError.makeMessage(status, error, message)}`);
19
+ this.status = status;
20
+ this.headers = headers;
21
+ this.error = error;
22
+ }
23
+
24
+ private static makeMessage(status: number | undefined, error: any, message: string | undefined) {
25
+ const msg =
26
+ error?.message ?
27
+ typeof error.message === 'string' ?
28
+ error.message
29
+ : JSON.stringify(error.message)
30
+ : error ? JSON.stringify(error)
31
+ : message;
32
+
33
+ if (status && msg) {
34
+ return `${status} ${msg}`;
35
+ }
36
+ if (status) {
37
+ return `${status} status code (no body)`;
38
+ }
39
+ if (msg) {
40
+ return msg;
41
+ }
42
+ return '(no status code or body)';
43
+ }
44
+
45
+ static generate(
46
+ status: number | undefined,
47
+ errorResponse: Object | undefined,
48
+ message: string | undefined,
49
+ headers: Headers | undefined,
50
+ ) {
51
+ if (!status) {
52
+ return new APIConnectionError({ message, cause: castToError(errorResponse) });
53
+ }
54
+
55
+ const error = errorResponse as Record<string, any>;
56
+
57
+ if (status === 400) {
58
+ return new BadRequestError(status, error, message, headers);
59
+ }
60
+
61
+ if (status === 401) {
62
+ return new AuthenticationError(status, error, message, headers);
63
+ }
64
+
65
+ if (status === 403) {
66
+ return new PermissionDeniedError(status, error, message, headers);
67
+ }
68
+
69
+ if (status === 404) {
70
+ return new NotFoundError(status, error, message, headers);
71
+ }
72
+
73
+ if (status === 409) {
74
+ return new ConflictError(status, error, message, headers);
75
+ }
76
+
77
+ if (status === 422) {
78
+ return new UnprocessableEntityError(status, error, message, headers);
79
+ }
80
+
81
+ if (status === 429) {
82
+ return new RateLimitError(status, error, message, headers);
83
+ }
84
+
85
+ if (status >= 500) {
86
+ return new InternalServerError(status, error, message, headers);
87
+ }
88
+
89
+ return new APIError(status, error, message, headers);
90
+ }
91
+ }
92
+
93
+ export class APIUserAbortError extends APIError {
94
+ override readonly status: undefined = undefined;
95
+
96
+ constructor({ message }: { message?: string } = {}) {
97
+ super(undefined, undefined, message || 'Request was aborted.', undefined);
98
+ }
99
+ }
100
+
101
+ export class APIConnectionError extends APIError {
102
+ override readonly status: undefined = undefined;
103
+
104
+ constructor({ message, cause }: { message?: string | undefined; cause?: Error | undefined }) {
105
+ super(undefined, undefined, message || 'Connection error.', undefined);
106
+ // in some environments the 'cause' property is already declared
107
+ // @ts-ignore
108
+ if (cause) this.cause = cause;
109
+ }
110
+ }
111
+
112
+ export class APIConnectionTimeoutError extends APIConnectionError {
113
+ constructor({ message }: { message?: string } = {}) {
114
+ super({ message: message ?? 'Request timed out.' });
115
+ }
116
+ }
117
+
118
+ export class BadRequestError extends APIError {
119
+ override readonly status: 400 = 400;
120
+ }
121
+
122
+ export class AuthenticationError extends APIError {
123
+ override readonly status: 401 = 401;
124
+ }
125
+
126
+ export class PermissionDeniedError extends APIError {
127
+ override readonly status: 403 = 403;
128
+ }
129
+
130
+ export class NotFoundError extends APIError {
131
+ override readonly status: 404 = 404;
132
+ }
133
+
134
+ export class ConflictError extends APIError {
135
+ override readonly status: 409 = 409;
136
+ }
137
+
138
+ export class UnprocessableEntityError extends APIError {
139
+ override readonly status: 422 = 422;
140
+ }
141
+
142
+ export class RateLimitError extends APIError {
143
+ override readonly status: 429 = 429;
144
+ }
145
+
146
+ export class InternalServerError extends APIError {}
package/src/index.ts ADDED
@@ -0,0 +1,227 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import * as Errors from './error';
4
+ import * as Uploads from './uploads';
5
+ import { type Agent } from './_shims/index';
6
+ import * as Core from './core';
7
+ import * as Pagination from './pagination';
8
+ import * as API from './resources/index';
9
+
10
+ export interface ClientOptions {
11
+ /**
12
+ * API key used for authorization in header
13
+ */
14
+ apiKey?: string | undefined;
15
+
16
+ /**
17
+ * Override the default base URL for the API, e.g., "https://api.example.com/v2/"
18
+ *
19
+ * Defaults to process.env['ARCADE_BASE_URL'].
20
+ */
21
+ baseURL?: string | null | undefined;
22
+
23
+ /**
24
+ * The maximum amount of time (in milliseconds) that the client should wait for a response
25
+ * from the server before timing out a single request.
26
+ *
27
+ * Note that request timeouts are retried by default, so in a worst-case scenario you may wait
28
+ * much longer than this timeout before the promise succeeds or fails.
29
+ */
30
+ timeout?: number;
31
+
32
+ /**
33
+ * An HTTP agent used to manage HTTP(S) connections.
34
+ *
35
+ * If not provided, an agent will be constructed by default in the Node.js environment,
36
+ * otherwise no agent is used.
37
+ */
38
+ httpAgent?: Agent;
39
+
40
+ /**
41
+ * Specify a custom `fetch` function implementation.
42
+ *
43
+ * If not provided, we use `node-fetch` on Node.js and otherwise expect that `fetch` is
44
+ * defined globally.
45
+ */
46
+ fetch?: Core.Fetch | undefined;
47
+
48
+ /**
49
+ * The maximum number of times that the client will retry a request in case of a
50
+ * temporary failure, like a network error or a 5XX error from the server.
51
+ *
52
+ * @default 2
53
+ */
54
+ maxRetries?: number;
55
+
56
+ /**
57
+ * Default headers to include with every request to the API.
58
+ *
59
+ * These can be removed in individual requests by explicitly setting the
60
+ * header to `undefined` or `null` in request options.
61
+ */
62
+ defaultHeaders?: Core.Headers;
63
+
64
+ /**
65
+ * Default query parameters to include with every request to the API.
66
+ *
67
+ * These can be removed in individual requests by explicitly setting the
68
+ * param to `undefined` in request options.
69
+ */
70
+ defaultQuery?: Core.DefaultQuery;
71
+ }
72
+
73
+ /**
74
+ * API Client for interfacing with the Arcade API.
75
+ */
76
+ export class Arcade extends Core.APIClient {
77
+ apiKey: string;
78
+
79
+ private _options: ClientOptions;
80
+
81
+ /**
82
+ * API Client for interfacing with the Arcade API.
83
+ *
84
+ * @param {string | undefined} [opts.apiKey=process.env['ARCADE_API_KEY'] ?? undefined]
85
+ * @param {string} [opts.baseURL=process.env['ARCADE_BASE_URL'] ?? https://api.arcade-ai.com] - Override the default base URL for the API.
86
+ * @param {number} [opts.timeout=1 minute] - The maximum amount of time (in milliseconds) the client will wait for a response before timing out.
87
+ * @param {number} [opts.httpAgent] - An HTTP agent used to manage HTTP(s) connections.
88
+ * @param {Core.Fetch} [opts.fetch] - Specify a custom `fetch` function implementation.
89
+ * @param {number} [opts.maxRetries=2] - The maximum number of times the client will retry a request.
90
+ * @param {Core.Headers} opts.defaultHeaders - Default headers to include with every request to the API.
91
+ * @param {Core.DefaultQuery} opts.defaultQuery - Default query parameters to include with every request to the API.
92
+ */
93
+ constructor({
94
+ baseURL = Core.readEnv('ARCADE_BASE_URL'),
95
+ apiKey = Core.readEnv('ARCADE_API_KEY'),
96
+ ...opts
97
+ }: ClientOptions = {}) {
98
+ if (apiKey === undefined) {
99
+ throw new Errors.ArcadeError(
100
+ "The ARCADE_API_KEY environment variable is missing or empty; either provide it, or instantiate the Arcade client with an apiKey option, like new Arcade({ apiKey: 'My API Key' }).",
101
+ );
102
+ }
103
+
104
+ const options: ClientOptions = {
105
+ apiKey,
106
+ ...opts,
107
+ baseURL: baseURL || `https://api.arcade-ai.com`,
108
+ };
109
+
110
+ super({
111
+ baseURL: options.baseURL!,
112
+ timeout: options.timeout ?? 60000 /* 1 minute */,
113
+ httpAgent: options.httpAgent,
114
+ maxRetries: options.maxRetries,
115
+ fetch: options.fetch,
116
+ });
117
+
118
+ this._options = options;
119
+ this.idempotencyHeader = 'Idempotency-Key';
120
+
121
+ this.apiKey = apiKey;
122
+ }
123
+
124
+ auth: API.Auth = new API.Auth(this);
125
+ health: API.Health = new API.Health(this);
126
+ chat: API.Chat = new API.Chat(this);
127
+ tools: API.Tools = new API.Tools(this);
128
+
129
+ protected override defaultQuery(): Core.DefaultQuery | undefined {
130
+ return this._options.defaultQuery;
131
+ }
132
+
133
+ protected override defaultHeaders(opts: Core.FinalRequestOptions): Core.Headers {
134
+ return {
135
+ ...super.defaultHeaders(opts),
136
+ ...this._options.defaultHeaders,
137
+ };
138
+ }
139
+
140
+ protected override authHeaders(opts: Core.FinalRequestOptions): Core.Headers {
141
+ return { Authorization: this.apiKey };
142
+ }
143
+
144
+ static Arcade = this;
145
+ static DEFAULT_TIMEOUT = 60000; // 1 minute
146
+
147
+ static ArcadeError = Errors.ArcadeError;
148
+ static APIError = Errors.APIError;
149
+ static APIConnectionError = Errors.APIConnectionError;
150
+ static APIConnectionTimeoutError = Errors.APIConnectionTimeoutError;
151
+ static APIUserAbortError = Errors.APIUserAbortError;
152
+ static NotFoundError = Errors.NotFoundError;
153
+ static ConflictError = Errors.ConflictError;
154
+ static RateLimitError = Errors.RateLimitError;
155
+ static BadRequestError = Errors.BadRequestError;
156
+ static AuthenticationError = Errors.AuthenticationError;
157
+ static InternalServerError = Errors.InternalServerError;
158
+ static PermissionDeniedError = Errors.PermissionDeniedError;
159
+ static UnprocessableEntityError = Errors.UnprocessableEntityError;
160
+
161
+ static toFile = Uploads.toFile;
162
+ static fileFromPath = Uploads.fileFromPath;
163
+ }
164
+
165
+ export const {
166
+ ArcadeError,
167
+ APIError,
168
+ APIConnectionError,
169
+ APIConnectionTimeoutError,
170
+ APIUserAbortError,
171
+ NotFoundError,
172
+ ConflictError,
173
+ RateLimitError,
174
+ BadRequestError,
175
+ AuthenticationError,
176
+ InternalServerError,
177
+ PermissionDeniedError,
178
+ UnprocessableEntityError,
179
+ } = Errors;
180
+
181
+ export import toFile = Uploads.toFile;
182
+ export import fileFromPath = Uploads.fileFromPath;
183
+
184
+ export namespace Arcade {
185
+ export import RequestOptions = Core.RequestOptions;
186
+
187
+ export import OffsetPage = Pagination.OffsetPage;
188
+ export import OffsetPageParams = Pagination.OffsetPageParams;
189
+ export import OffsetPageResponse = Pagination.OffsetPageResponse;
190
+
191
+ export import Auth = API.Auth;
192
+ export import AuthRequest = API.AuthRequest;
193
+ export import AuthAuthorizeParams = API.AuthAuthorizeParams;
194
+ export import AuthStatusParams = API.AuthStatusParams;
195
+
196
+ export import Health = API.Health;
197
+ export import HealthSchema = API.HealthSchema;
198
+
199
+ export import Chat = API.Chat;
200
+ export import ChatMessage = API.ChatMessage;
201
+ export import ChatRequest = API.ChatRequest;
202
+ export import ChatResponse = API.ChatResponse;
203
+ export import Choice = API.Choice;
204
+ export import Usage = API.Usage;
205
+
206
+ export import Tools = API.Tools;
207
+ export import AuthorizeToolRequest = API.AuthorizeToolRequest;
208
+ export import ExecuteToolRequest = API.ExecuteToolRequest;
209
+ export import Inputs = API.Inputs;
210
+ export import Output = API.Output;
211
+ export import Parameter = API.Parameter;
212
+ export import Requirements = API.Requirements;
213
+ export import Response = API.Response;
214
+ export import ResponseOutput = API.ResponseOutput;
215
+ export import ToolkitDefinition = API.ToolkitDefinition;
216
+ export import ValueSchema = API.ValueSchema;
217
+ export import ToolListParams = API.ToolListParams;
218
+ export import ToolAuthorizeParams = API.ToolAuthorizeParams;
219
+ export import ToolExecuteParams = API.ToolExecuteParams;
220
+ export import ToolGetParams = API.ToolGetParams;
221
+
222
+ export import AuthorizationResponse = API.AuthorizationResponse;
223
+ export import Error = API.Error;
224
+ export import ToolDefinition = API.ToolDefinition;
225
+ }
226
+
227
+ export default Arcade;
package/src/lib/.keep ADDED
@@ -0,0 +1,4 @@
1
+ File generated from our OpenAPI spec by Stainless.
2
+
3
+ This directory can be used to store custom files to expand the SDK.
4
+ It is ignored by Stainless code generation and its content (other than this keep file) won't be touched.
@@ -0,0 +1,79 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { AbstractPage, Response, APIClient, FinalRequestOptions, PageInfo } from './core';
4
+
5
+ export interface OffsetPageResponse<Item> {
6
+ items: Array<Item>;
7
+
8
+ total_count: number;
9
+
10
+ offset: number;
11
+ }
12
+
13
+ export interface OffsetPageParams {
14
+ /**
15
+ * The number of elements to skip.
16
+ */
17
+ offset?: number;
18
+
19
+ /**
20
+ * The maximum number of elements to fetch.
21
+ */
22
+ limit?: number;
23
+ }
24
+
25
+ export class OffsetPage<Item> extends AbstractPage<Item> implements OffsetPageResponse<Item> {
26
+ items: Array<Item>;
27
+
28
+ total_count: number;
29
+
30
+ offset: number;
31
+
32
+ constructor(
33
+ client: APIClient,
34
+ response: Response,
35
+ body: OffsetPageResponse<Item>,
36
+ options: FinalRequestOptions,
37
+ ) {
38
+ super(client, response, body, options);
39
+
40
+ this.items = body.items || [];
41
+ this.total_count = body.total_count || 0;
42
+ this.offset = body.offset || 0;
43
+ }
44
+
45
+ getPaginatedItems(): Item[] {
46
+ return this.items ?? [];
47
+ }
48
+
49
+ // @deprecated Please use `nextPageInfo()` instead
50
+ nextPageParams(): Partial<OffsetPageParams> | null {
51
+ const info = this.nextPageInfo();
52
+ if (!info) return null;
53
+ if ('params' in info) return info.params;
54
+ const params = Object.fromEntries(info.url.searchParams);
55
+ if (!Object.keys(params).length) return null;
56
+ return params;
57
+ }
58
+
59
+ nextPageInfo(): PageInfo | null {
60
+ const offset = this.offset;
61
+ if (!offset) {
62
+ return null;
63
+ }
64
+
65
+ const length = this.getPaginatedItems().length;
66
+ const currentCount = offset + length;
67
+
68
+ const totalCount = this.total_count;
69
+ if (!totalCount) {
70
+ return null;
71
+ }
72
+
73
+ if (currentCount < totalCount) {
74
+ return { params: { offset: currentCount } };
75
+ }
76
+
77
+ return null;
78
+ }
79
+ }
@@ -0,0 +1,11 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import type { Arcade } from './index';
4
+
5
+ export class APIResource {
6
+ protected _client: Arcade;
7
+
8
+ constructor(client: Arcade) {
9
+ this._client = client;
10
+ }
11
+ }
@@ -0,0 +1,97 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../resource';
4
+ import * as Core from '../core';
5
+ import * as AuthAPI from './auth';
6
+ import * as Shared from './shared';
7
+
8
+ export class Auth extends APIResource {
9
+ /**
10
+ * Starts the authorization process for given authorization requirements
11
+ */
12
+ authorize(
13
+ body: AuthAuthorizeParams,
14
+ options?: Core.RequestOptions,
15
+ ): Core.APIPromise<Shared.AuthorizationResponse> {
16
+ return this._client.post('/v1/auth/authorize', { body, ...options });
17
+ }
18
+
19
+ /**
20
+ * Checks the status of an ongoing authorization process for a specific tool. If
21
+ * 'wait' param is present, does not respond until either the auth status becomes
22
+ * completed or the timeout is reached.
23
+ */
24
+ status(
25
+ query: AuthStatusParams,
26
+ options?: Core.RequestOptions,
27
+ ): Core.APIPromise<Shared.AuthorizationResponse> {
28
+ return this._client.get('/v1/auth/status', { query, ...options });
29
+ }
30
+ }
31
+
32
+ export interface AuthRequest {
33
+ auth_requirement: AuthRequest.AuthRequirement;
34
+
35
+ user_id: string;
36
+ }
37
+
38
+ export namespace AuthRequest {
39
+ export interface AuthRequirement {
40
+ oauth2?: AuthRequirement.Oauth2;
41
+
42
+ provider_id?: string;
43
+
44
+ provider_type?: string;
45
+ }
46
+
47
+ export namespace AuthRequirement {
48
+ export interface Oauth2 {
49
+ scopes?: Array<string>;
50
+ }
51
+ }
52
+ }
53
+
54
+ export interface AuthAuthorizeParams {
55
+ auth_requirement: AuthAuthorizeParams.AuthRequirement;
56
+
57
+ user_id: string;
58
+ }
59
+
60
+ export namespace AuthAuthorizeParams {
61
+ export interface AuthRequirement {
62
+ oauth2?: AuthRequirement.Oauth2;
63
+
64
+ provider_id?: string;
65
+
66
+ provider_type?: string;
67
+ }
68
+
69
+ export namespace AuthRequirement {
70
+ export interface Oauth2 {
71
+ scopes?: Array<string>;
72
+ }
73
+ }
74
+ }
75
+
76
+ export interface AuthStatusParams {
77
+ /**
78
+ * Authorization ID
79
+ */
80
+ authorizationId: string;
81
+
82
+ /**
83
+ * Scopes
84
+ */
85
+ scopes?: string;
86
+
87
+ /**
88
+ * Timeout in seconds (max 59)
89
+ */
90
+ wait?: number;
91
+ }
92
+
93
+ export namespace Auth {
94
+ export import AuthRequest = AuthAPI.AuthRequest;
95
+ export import AuthAuthorizeParams = AuthAPI.AuthAuthorizeParams;
96
+ export import AuthStatusParams = AuthAPI.AuthStatusParams;
97
+ }