@arcadeai/arcadejs 0.1.2 → 0.2.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.
- package/CHANGELOG.md +37 -0
- package/README.md +10 -1
- package/core.d.ts +4 -5
- package/core.d.ts.map +1 -1
- package/core.js +7 -11
- package/core.js.map +1 -1
- package/core.mjs +7 -11
- package/core.mjs.map +1 -1
- package/error.d.ts +18 -24
- package/error.d.ts.map +1 -1
- package/error.js +1 -31
- package/error.js.map +1 -1
- package/error.mjs +1 -31
- package/error.mjs.map +1 -1
- package/index.d.mts +18 -38
- package/index.d.ts +18 -38
- package/index.d.ts.map +1 -1
- package/index.js +28 -13
- package/index.js.map +1 -1
- package/index.mjs +12 -12
- package/index.mjs.map +1 -1
- package/package.json +2 -2
- package/resources/auth.d.ts +1 -4
- package/resources/auth.d.ts.map +1 -1
- package/resources/auth.js +0 -2
- package/resources/auth.js.map +1 -1
- package/resources/auth.mjs +0 -2
- package/resources/auth.mjs.map +1 -1
- package/resources/chat/chat.d.ts +3 -8
- package/resources/chat/chat.d.ts.map +1 -1
- package/resources/chat/chat.js +2 -3
- package/resources/chat/chat.js.map +1 -1
- package/resources/chat/chat.mjs +2 -3
- package/resources/chat/chat.mjs.map +1 -1
- package/resources/chat/completions.d.ts +1 -2
- package/resources/chat/completions.d.ts.map +1 -1
- package/resources/chat/completions.js +0 -2
- package/resources/chat/completions.js.map +1 -1
- package/resources/chat/completions.mjs +0 -2
- package/resources/chat/completions.mjs.map +1 -1
- package/resources/chat/index.d.ts +2 -2
- package/resources/chat/index.d.ts.map +1 -1
- package/resources/chat/index.js.map +1 -1
- package/resources/chat/index.mjs.map +1 -1
- package/resources/health.d.ts +1 -2
- package/resources/health.d.ts.map +1 -1
- package/resources/health.js +0 -2
- package/resources/health.js.map +1 -1
- package/resources/health.mjs +0 -2
- package/resources/health.mjs.map +1 -1
- package/resources/index.d.ts +4 -4
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -3
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +2 -2
- package/resources/index.mjs.map +1 -1
- package/resources/shared.d.ts +2 -0
- package/resources/shared.d.ts.map +1 -1
- package/resources/shared.js.map +1 -1
- package/resources/shared.mjs.map +1 -1
- package/resources/tools/formatted.d.ts +1 -6
- package/resources/tools/formatted.d.ts.map +1 -1
- package/resources/tools/formatted.js +1 -27
- package/resources/tools/formatted.js.map +1 -1
- package/resources/tools/formatted.mjs +1 -4
- package/resources/tools/formatted.mjs.map +1 -1
- package/resources/tools/index.d.ts +2 -2
- package/resources/tools/index.d.ts.map +1 -1
- package/resources/tools/index.js +3 -3
- package/resources/tools/index.js.map +1 -1
- package/resources/tools/index.mjs +1 -1
- package/resources/tools/index.mjs.map +1 -1
- package/resources/tools/tools.d.ts +3 -21
- package/resources/tools/tools.d.ts.map +1 -1
- package/resources/tools/tools.js +3 -4
- package/resources/tools/tools.js.map +1 -1
- package/resources/tools/tools.mjs +3 -4
- package/resources/tools/tools.mjs.map +1 -1
- package/resources/tools.d.ts +0 -160
- package/resources/tools.d.ts.map +1 -1
- package/resources/tools.js +0 -36
- package/resources/tools.js.map +1 -1
- package/resources/tools.mjs +1 -33
- package/resources/tools.mjs.map +1 -1
- package/src/core.ts +13 -19
- package/src/error.ts +25 -41
- package/src/index.ts +77 -50
- package/src/resources/auth.ts +6 -5
- package/src/resources/chat/chat.ts +13 -9
- package/src/resources/chat/completions.ts +2 -3
- package/src/resources/chat/index.ts +2 -2
- package/src/resources/health.ts +2 -3
- package/src/resources/index.ts +24 -17
- package/src/resources/shared.ts +4 -0
- package/src/resources/tools/formatted.ts +10 -7
- package/src/resources/tools/index.ts +21 -21
- package/src/resources/tools/tools.ts +37 -22
- package/src/resources/tools.ts +0 -240
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.mjs +1 -1
- package/resources/tools/definition.d.ts +0 -24
- package/resources/tools/definition.d.ts.map +0 -1
- package/resources/tools/definition.js +0 -17
- package/resources/tools/definition.js.map +0 -1
- package/resources/tools/definition.mjs +0 -13
- package/resources/tools/definition.mjs.map +0 -1
- package/src/resources/tools/definition.ts +0 -31
package/resources/tools.d.ts
CHANGED
|
@@ -1,161 +1 @@
|
|
|
1
|
-
import { APIResource } from "../resource.js";
|
|
2
|
-
import * as Core from "../core.js";
|
|
3
|
-
import * as ToolsAPI from "./tools.js";
|
|
4
|
-
import * as Shared from "./shared.js";
|
|
5
|
-
import { ToolDefinitionsOffsetPage } from "./shared.js";
|
|
6
|
-
import { type OffsetPageParams } from "../pagination.js";
|
|
7
|
-
export declare class Tools extends APIResource {
|
|
8
|
-
/**
|
|
9
|
-
* Returns a list of tools, optionally filtered by toolkit or auth provider
|
|
10
|
-
*/
|
|
11
|
-
list(query?: ToolListParams, options?: Core.RequestOptions): Core.PagePromise<ToolDefinitionsOffsetPage, Shared.ToolDefinition>;
|
|
12
|
-
list(options?: Core.RequestOptions): Core.PagePromise<ToolDefinitionsOffsetPage, Shared.ToolDefinition>;
|
|
13
|
-
/**
|
|
14
|
-
* Authorizes a user for a specific tool by name
|
|
15
|
-
*/
|
|
16
|
-
authorize(body: ToolAuthorizeParams, options?: Core.RequestOptions): Core.APIPromise<Shared.AuthorizationResponse>;
|
|
17
|
-
/**
|
|
18
|
-
* Executes a tool by name and arguments
|
|
19
|
-
*/
|
|
20
|
-
execute(body: ToolExecuteParams, options?: Core.RequestOptions): Core.APIPromise<Response>;
|
|
21
|
-
/**
|
|
22
|
-
* Returns the arcade tool specification for a specific tool
|
|
23
|
-
*/
|
|
24
|
-
get(query: ToolGetParams, options?: Core.RequestOptions): Core.APIPromise<Shared.ToolDefinition>;
|
|
25
|
-
}
|
|
26
|
-
export interface AuthorizeToolRequest {
|
|
27
|
-
tool_name: string;
|
|
28
|
-
user_id: string;
|
|
29
|
-
/**
|
|
30
|
-
* Optional: if not provided, any version is used
|
|
31
|
-
*/
|
|
32
|
-
tool_version?: string;
|
|
33
|
-
}
|
|
34
|
-
export interface ExecuteToolRequest {
|
|
35
|
-
tool_name: string;
|
|
36
|
-
/**
|
|
37
|
-
* Serialized JSON string
|
|
38
|
-
*/
|
|
39
|
-
inputs?: string;
|
|
40
|
-
/**
|
|
41
|
-
* Optional: if not provided, any version is used
|
|
42
|
-
*/
|
|
43
|
-
tool_version?: string;
|
|
44
|
-
user_id?: string;
|
|
45
|
-
}
|
|
46
|
-
export interface Inputs {
|
|
47
|
-
parameters?: Array<Parameter>;
|
|
48
|
-
}
|
|
49
|
-
export interface Output {
|
|
50
|
-
available_modes?: Array<string>;
|
|
51
|
-
description?: string;
|
|
52
|
-
value_schema?: ValueSchema;
|
|
53
|
-
}
|
|
54
|
-
export interface Parameter {
|
|
55
|
-
name: string;
|
|
56
|
-
value_schema: ValueSchema;
|
|
57
|
-
description?: string;
|
|
58
|
-
inferrable?: boolean;
|
|
59
|
-
required?: boolean;
|
|
60
|
-
}
|
|
61
|
-
export interface Requirements {
|
|
62
|
-
authorization?: Requirements.Authorization;
|
|
63
|
-
}
|
|
64
|
-
export declare namespace Requirements {
|
|
65
|
-
interface Authorization {
|
|
66
|
-
oauth2?: Authorization.Oauth2;
|
|
67
|
-
provider_id?: string;
|
|
68
|
-
provider_type?: string;
|
|
69
|
-
}
|
|
70
|
-
namespace Authorization {
|
|
71
|
-
interface Oauth2 {
|
|
72
|
-
scopes?: Array<string>;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
export interface Response {
|
|
77
|
-
invocation_id: string;
|
|
78
|
-
duration?: number;
|
|
79
|
-
finished_at?: Response.FinishedAt;
|
|
80
|
-
output?: ResponseOutput;
|
|
81
|
-
success?: boolean;
|
|
82
|
-
}
|
|
83
|
-
export declare namespace Response {
|
|
84
|
-
interface FinishedAt {
|
|
85
|
-
'time.Time'?: string;
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
export interface ResponseOutput {
|
|
89
|
-
error?: ResponseOutput.Error;
|
|
90
|
-
requires_authorization?: Shared.AuthorizationResponse;
|
|
91
|
-
value?: unknown;
|
|
92
|
-
}
|
|
93
|
-
export declare namespace ResponseOutput {
|
|
94
|
-
interface Error {
|
|
95
|
-
message: string;
|
|
96
|
-
additional_prompt_content?: string;
|
|
97
|
-
can_retry?: boolean;
|
|
98
|
-
developer_message?: string;
|
|
99
|
-
retry_after_ms?: number;
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
export interface ToolkitDefinition {
|
|
103
|
-
name: string;
|
|
104
|
-
description?: string;
|
|
105
|
-
version?: string;
|
|
106
|
-
}
|
|
107
|
-
export interface ValueSchema {
|
|
108
|
-
val_type: string;
|
|
109
|
-
enum?: Array<string>;
|
|
110
|
-
inner_val_type?: string;
|
|
111
|
-
}
|
|
112
|
-
export interface ToolListParams extends OffsetPageParams {
|
|
113
|
-
/**
|
|
114
|
-
* Toolkit name
|
|
115
|
-
*/
|
|
116
|
-
toolkit?: string;
|
|
117
|
-
}
|
|
118
|
-
export interface ToolAuthorizeParams {
|
|
119
|
-
tool_name: string;
|
|
120
|
-
user_id: string;
|
|
121
|
-
/**
|
|
122
|
-
* Optional: if not provided, any version is used
|
|
123
|
-
*/
|
|
124
|
-
tool_version?: string;
|
|
125
|
-
}
|
|
126
|
-
export interface ToolExecuteParams {
|
|
127
|
-
tool_name: string;
|
|
128
|
-
/**
|
|
129
|
-
* Serialized JSON string
|
|
130
|
-
*/
|
|
131
|
-
inputs?: string;
|
|
132
|
-
/**
|
|
133
|
-
* Optional: if not provided, any version is used
|
|
134
|
-
*/
|
|
135
|
-
tool_version?: string;
|
|
136
|
-
user_id?: string;
|
|
137
|
-
}
|
|
138
|
-
export interface ToolGetParams {
|
|
139
|
-
/**
|
|
140
|
-
* Tool ID
|
|
141
|
-
*/
|
|
142
|
-
toolId: string;
|
|
143
|
-
}
|
|
144
|
-
export declare namespace Tools {
|
|
145
|
-
export import AuthorizeToolRequest = ToolsAPI.AuthorizeToolRequest;
|
|
146
|
-
export import ExecuteToolRequest = ToolsAPI.ExecuteToolRequest;
|
|
147
|
-
export import Inputs = ToolsAPI.Inputs;
|
|
148
|
-
export import Output = ToolsAPI.Output;
|
|
149
|
-
export import Parameter = ToolsAPI.Parameter;
|
|
150
|
-
export import Requirements = ToolsAPI.Requirements;
|
|
151
|
-
export import Response = ToolsAPI.Response;
|
|
152
|
-
export import ResponseOutput = ToolsAPI.ResponseOutput;
|
|
153
|
-
export import ToolkitDefinition = ToolsAPI.ToolkitDefinition;
|
|
154
|
-
export import ValueSchema = ToolsAPI.ValueSchema;
|
|
155
|
-
export import ToolListParams = ToolsAPI.ToolListParams;
|
|
156
|
-
export import ToolAuthorizeParams = ToolsAPI.ToolAuthorizeParams;
|
|
157
|
-
export import ToolExecuteParams = ToolsAPI.ToolExecuteParams;
|
|
158
|
-
export import ToolGetParams = ToolsAPI.ToolGetParams;
|
|
159
|
-
}
|
|
160
|
-
export { ToolDefinitionsOffsetPage };
|
|
161
1
|
//# sourceMappingURL=tools.d.ts.map
|
package/resources/tools.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/resources/tools.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../src/resources/tools.ts"],"names":[],"mappings":""}
|
package/resources/tools.js
CHANGED
|
@@ -1,38 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.ToolDefinitionsOffsetPage = exports.Tools = void 0;
|
|
5
|
-
const resource_1 = require("../resource.js");
|
|
6
|
-
const core_1 = require("../core.js");
|
|
7
|
-
const shared_1 = require("./shared.js");
|
|
8
|
-
Object.defineProperty(exports, "ToolDefinitionsOffsetPage", { enumerable: true, get: function () { return shared_1.ToolDefinitionsOffsetPage; } });
|
|
9
|
-
class Tools extends resource_1.APIResource {
|
|
10
|
-
list(query = {}, options) {
|
|
11
|
-
if ((0, core_1.isRequestOptions)(query)) {
|
|
12
|
-
return this.list({}, query);
|
|
13
|
-
}
|
|
14
|
-
return this._client.getAPIList('/v1/tools/list', shared_1.ToolDefinitionsOffsetPage, { query, ...options });
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Authorizes a user for a specific tool by name
|
|
18
|
-
*/
|
|
19
|
-
authorize(body, options) {
|
|
20
|
-
return this._client.post('/v1/tools/authorize', { body, ...options });
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* Executes a tool by name and arguments
|
|
24
|
-
*/
|
|
25
|
-
execute(body, options) {
|
|
26
|
-
return this._client.post('/v1/tools/execute', { body, ...options });
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Returns the arcade tool specification for a specific tool
|
|
30
|
-
*/
|
|
31
|
-
get(query, options) {
|
|
32
|
-
return this._client.get('/v1/tools/definition', { query, ...options });
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
exports.Tools = Tools;
|
|
36
|
-
(function (Tools) {
|
|
37
|
-
})(Tools = exports.Tools || (exports.Tools = {}));
|
|
38
2
|
//# sourceMappingURL=tools.js.map
|
package/resources/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/resources/tools.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/resources/tools.ts"],"names":[],"mappings":""}
|
package/resources/tools.mjs
CHANGED
|
@@ -1,34 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { APIResource } from "../resource.mjs";
|
|
3
|
-
import { isRequestOptions } from "../core.mjs";
|
|
4
|
-
import { ToolDefinitionsOffsetPage } from "./shared.mjs";
|
|
5
|
-
export class Tools extends APIResource {
|
|
6
|
-
list(query = {}, options) {
|
|
7
|
-
if (isRequestOptions(query)) {
|
|
8
|
-
return this.list({}, query);
|
|
9
|
-
}
|
|
10
|
-
return this._client.getAPIList('/v1/tools/list', ToolDefinitionsOffsetPage, { query, ...options });
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Authorizes a user for a specific tool by name
|
|
14
|
-
*/
|
|
15
|
-
authorize(body, options) {
|
|
16
|
-
return this._client.post('/v1/tools/authorize', { body, ...options });
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Executes a tool by name and arguments
|
|
20
|
-
*/
|
|
21
|
-
execute(body, options) {
|
|
22
|
-
return this._client.post('/v1/tools/execute', { body, ...options });
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* Returns the arcade tool specification for a specific tool
|
|
26
|
-
*/
|
|
27
|
-
get(query, options) {
|
|
28
|
-
return this._client.get('/v1/tools/definition', { query, ...options });
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
(function (Tools) {
|
|
32
|
-
})(Tools || (Tools = {}));
|
|
33
|
-
export { ToolDefinitionsOffsetPage };
|
|
1
|
+
"use strict";
|
|
34
2
|
//# sourceMappingURL=tools.mjs.map
|
package/resources/tools.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.mjs","sourceRoot":"","sources":["../src/resources/tools.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tools.mjs","sourceRoot":"","sources":["../src/resources/tools.ts"],"names":[],"mappings":""}
|
package/src/core.ts
CHANGED
|
@@ -163,7 +163,7 @@ export abstract class APIClient {
|
|
|
163
163
|
maxRetries = 2,
|
|
164
164
|
timeout = 60000, // 1 minute
|
|
165
165
|
httpAgent,
|
|
166
|
-
fetch:
|
|
166
|
+
fetch: overriddenFetch,
|
|
167
167
|
}: {
|
|
168
168
|
baseURL: string;
|
|
169
169
|
maxRetries?: number | undefined;
|
|
@@ -176,7 +176,7 @@ export abstract class APIClient {
|
|
|
176
176
|
this.timeout = validatePositiveInteger('timeout', timeout);
|
|
177
177
|
this.httpAgent = httpAgent;
|
|
178
178
|
|
|
179
|
-
this.fetch =
|
|
179
|
+
this.fetch = overriddenFetch ?? fetch;
|
|
180
180
|
}
|
|
181
181
|
|
|
182
182
|
protected authHeaders(opts: FinalRequestOptions): Headers {
|
|
@@ -396,7 +396,7 @@ export abstract class APIClient {
|
|
|
396
396
|
error: Object | undefined,
|
|
397
397
|
message: string | undefined,
|
|
398
398
|
headers: Headers | undefined,
|
|
399
|
-
) {
|
|
399
|
+
): APIError {
|
|
400
400
|
return APIError.generate(status, error, message, headers);
|
|
401
401
|
}
|
|
402
402
|
|
|
@@ -523,19 +523,13 @@ export abstract class APIClient {
|
|
|
523
523
|
const timeout = setTimeout(() => controller.abort(), ms);
|
|
524
524
|
|
|
525
525
|
return (
|
|
526
|
-
this
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
clearTimeout(timeout);
|
|
531
|
-
})
|
|
526
|
+
// use undefined this binding; fetch errors if bound to something else in browser/cloudflare
|
|
527
|
+
this.fetch.call(undefined, url, { signal: controller.signal as any, ...options }).finally(() => {
|
|
528
|
+
clearTimeout(timeout);
|
|
529
|
+
})
|
|
532
530
|
);
|
|
533
531
|
}
|
|
534
532
|
|
|
535
|
-
protected getRequestClient(): RequestClient {
|
|
536
|
-
return { fetch: this.fetch };
|
|
537
|
-
}
|
|
538
|
-
|
|
539
533
|
private shouldRetry(response: Response): boolean {
|
|
540
534
|
// Note this is not a standard header.
|
|
541
535
|
const shouldRetryHeader = response.headers.get('x-should-retry');
|
|
@@ -668,9 +662,9 @@ export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
|
|
|
668
662
|
return await this.#client.requestAPIList(this.constructor as any, nextOptions);
|
|
669
663
|
}
|
|
670
664
|
|
|
671
|
-
async *iterPages() {
|
|
665
|
+
async *iterPages(): AsyncGenerator<this> {
|
|
672
666
|
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
673
|
-
let page:
|
|
667
|
+
let page: this = this;
|
|
674
668
|
yield page;
|
|
675
669
|
while (page.hasNextPage()) {
|
|
676
670
|
page = await page.getNextPage();
|
|
@@ -678,7 +672,7 @@ export abstract class AbstractPage<Item> implements AsyncIterable<Item> {
|
|
|
678
672
|
}
|
|
679
673
|
}
|
|
680
674
|
|
|
681
|
-
async *[Symbol.asyncIterator]() {
|
|
675
|
+
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
|
|
682
676
|
for await (const page of this.iterPages()) {
|
|
683
677
|
for (const item of page.getPaginatedItems()) {
|
|
684
678
|
yield item;
|
|
@@ -721,7 +715,7 @@ export class PagePromise<
|
|
|
721
715
|
* console.log(item)
|
|
722
716
|
* }
|
|
723
717
|
*/
|
|
724
|
-
async *[Symbol.asyncIterator]() {
|
|
718
|
+
async *[Symbol.asyncIterator](): AsyncGenerator<Item> {
|
|
725
719
|
const page = await this;
|
|
726
720
|
for await (const item of page) {
|
|
727
721
|
yield item;
|
|
@@ -976,8 +970,8 @@ export const safeJSON = (text: string) => {
|
|
|
976
970
|
}
|
|
977
971
|
};
|
|
978
972
|
|
|
979
|
-
// https://
|
|
980
|
-
const startsWithSchemeRegexp =
|
|
973
|
+
// https://url.spec.whatwg.org/#url-scheme-string
|
|
974
|
+
const startsWithSchemeRegexp = /^[a-z][a-z0-9+.-]*:/i;
|
|
981
975
|
const isAbsoluteURL = (url: string): boolean => {
|
|
982
976
|
return startsWithSchemeRegexp.test(url);
|
|
983
977
|
};
|
package/src/error.ts
CHANGED
|
@@ -4,17 +4,19 @@ import { castToError, Headers } from './core';
|
|
|
4
4
|
|
|
5
5
|
export class ArcadeError extends Error {}
|
|
6
6
|
|
|
7
|
-
export class APIError
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
export class APIError<
|
|
8
|
+
TStatus extends number | undefined = number | undefined,
|
|
9
|
+
THeaders extends Headers | undefined = Headers | undefined,
|
|
10
|
+
TError extends Object | undefined = Object | undefined,
|
|
11
|
+
> extends ArcadeError {
|
|
12
|
+
/** HTTP status for the response that caused the error */
|
|
13
|
+
readonly status: TStatus;
|
|
14
|
+
/** HTTP headers for the response that caused the error */
|
|
15
|
+
readonly headers: THeaders;
|
|
16
|
+
/** JSON body of the response that caused the error */
|
|
17
|
+
readonly error: TError;
|
|
18
|
+
|
|
19
|
+
constructor(status: TStatus, error: TError, message: string | undefined, headers: THeaders) {
|
|
18
20
|
super(`${APIError.makeMessage(status, error, message)}`);
|
|
19
21
|
this.status = status;
|
|
20
22
|
this.headers = headers;
|
|
@@ -47,8 +49,8 @@ export class APIError extends ArcadeError {
|
|
|
47
49
|
errorResponse: Object | undefined,
|
|
48
50
|
message: string | undefined,
|
|
49
51
|
headers: Headers | undefined,
|
|
50
|
-
) {
|
|
51
|
-
if (!status) {
|
|
52
|
+
): APIError {
|
|
53
|
+
if (!status || !headers) {
|
|
52
54
|
return new APIConnectionError({ message, cause: castToError(errorResponse) });
|
|
53
55
|
}
|
|
54
56
|
|
|
@@ -90,17 +92,13 @@ export class APIError extends ArcadeError {
|
|
|
90
92
|
}
|
|
91
93
|
}
|
|
92
94
|
|
|
93
|
-
export class APIUserAbortError extends APIError {
|
|
94
|
-
override readonly status: undefined = undefined;
|
|
95
|
-
|
|
95
|
+
export class APIUserAbortError extends APIError<undefined, undefined, undefined> {
|
|
96
96
|
constructor({ message }: { message?: string } = {}) {
|
|
97
97
|
super(undefined, undefined, message || 'Request was aborted.', undefined);
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
-
export class APIConnectionError extends APIError {
|
|
102
|
-
override readonly status: undefined = undefined;
|
|
103
|
-
|
|
101
|
+
export class APIConnectionError extends APIError<undefined, undefined, undefined> {
|
|
104
102
|
constructor({ message, cause }: { message?: string | undefined; cause?: Error | undefined }) {
|
|
105
103
|
super(undefined, undefined, message || 'Connection error.', undefined);
|
|
106
104
|
// in some environments the 'cause' property is already declared
|
|
@@ -115,32 +113,18 @@ export class APIConnectionTimeoutError extends APIConnectionError {
|
|
|
115
113
|
}
|
|
116
114
|
}
|
|
117
115
|
|
|
118
|
-
export class BadRequestError extends APIError {
|
|
119
|
-
override readonly status: 400 = 400;
|
|
120
|
-
}
|
|
116
|
+
export class BadRequestError extends APIError<400, Headers> {}
|
|
121
117
|
|
|
122
|
-
export class AuthenticationError extends APIError {
|
|
123
|
-
override readonly status: 401 = 401;
|
|
124
|
-
}
|
|
118
|
+
export class AuthenticationError extends APIError<401, Headers> {}
|
|
125
119
|
|
|
126
|
-
export class PermissionDeniedError extends APIError {
|
|
127
|
-
override readonly status: 403 = 403;
|
|
128
|
-
}
|
|
120
|
+
export class PermissionDeniedError extends APIError<403, Headers> {}
|
|
129
121
|
|
|
130
|
-
export class NotFoundError extends APIError {
|
|
131
|
-
override readonly status: 404 = 404;
|
|
132
|
-
}
|
|
122
|
+
export class NotFoundError extends APIError<404, Headers> {}
|
|
133
123
|
|
|
134
|
-
export class ConflictError extends APIError {
|
|
135
|
-
override readonly status: 409 = 409;
|
|
136
|
-
}
|
|
124
|
+
export class ConflictError extends APIError<409, Headers> {}
|
|
137
125
|
|
|
138
|
-
export class UnprocessableEntityError extends APIError {
|
|
139
|
-
override readonly status: 422 = 422;
|
|
140
|
-
}
|
|
126
|
+
export class UnprocessableEntityError extends APIError<422, Headers> {}
|
|
141
127
|
|
|
142
|
-
export class RateLimitError extends APIError {
|
|
143
|
-
override readonly status: 429 = 429;
|
|
144
|
-
}
|
|
128
|
+
export class RateLimitError extends APIError<429, Headers> {}
|
|
145
129
|
|
|
146
|
-
export class InternalServerError extends APIError {}
|
|
130
|
+
export class InternalServerError extends APIError<number, Headers> {}
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,32 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
import * as Errors from './error';
|
|
4
|
-
import * as Uploads from './uploads';
|
|
5
3
|
import { type Agent } from './_shims/index';
|
|
6
4
|
import * as Core from './core';
|
|
5
|
+
import * as Errors from './error';
|
|
7
6
|
import * as Pagination from './pagination';
|
|
7
|
+
import { type OffsetPageParams, OffsetPageResponse } from './pagination';
|
|
8
|
+
import * as Uploads from './uploads';
|
|
8
9
|
import * as API from './resources/index';
|
|
10
|
+
import { Auth, AuthAuthorizeParams, AuthRequest, AuthStatusParams } from './resources/auth';
|
|
11
|
+
import { Health, HealthSchema } from './resources/health';
|
|
12
|
+
import { Chat, ChatMessage, ChatRequest, ChatResponse, Choice, Usage } from './resources/chat/chat';
|
|
13
|
+
import {
|
|
14
|
+
AuthorizeToolRequest,
|
|
15
|
+
ExecuteToolRequest,
|
|
16
|
+
Inputs,
|
|
17
|
+
Output,
|
|
18
|
+
Parameter,
|
|
19
|
+
Requirements,
|
|
20
|
+
Response,
|
|
21
|
+
ResponseOutput,
|
|
22
|
+
ToolAuthorizeParams,
|
|
23
|
+
ToolExecuteParams,
|
|
24
|
+
ToolGetParams,
|
|
25
|
+
ToolListParams,
|
|
26
|
+
ToolkitDefinition,
|
|
27
|
+
Tools,
|
|
28
|
+
ValueSchema,
|
|
29
|
+
} from './resources/tools/tools';
|
|
9
30
|
|
|
10
31
|
export interface ClientOptions {
|
|
11
32
|
/**
|
|
@@ -162,7 +183,59 @@ export class Arcade extends Core.APIClient {
|
|
|
162
183
|
static fileFromPath = Uploads.fileFromPath;
|
|
163
184
|
}
|
|
164
185
|
|
|
165
|
-
|
|
186
|
+
Arcade.Auth = Auth;
|
|
187
|
+
Arcade.Health = Health;
|
|
188
|
+
Arcade.Chat = Chat;
|
|
189
|
+
Arcade.Tools = Tools;
|
|
190
|
+
export declare namespace Arcade {
|
|
191
|
+
export type RequestOptions = Core.RequestOptions;
|
|
192
|
+
|
|
193
|
+
export import OffsetPage = Pagination.OffsetPage;
|
|
194
|
+
export { type OffsetPageParams as OffsetPageParams, type OffsetPageResponse as OffsetPageResponse };
|
|
195
|
+
|
|
196
|
+
export {
|
|
197
|
+
Auth as Auth,
|
|
198
|
+
type AuthRequest as AuthRequest,
|
|
199
|
+
type AuthAuthorizeParams as AuthAuthorizeParams,
|
|
200
|
+
type AuthStatusParams as AuthStatusParams,
|
|
201
|
+
};
|
|
202
|
+
|
|
203
|
+
export { Health as Health, type HealthSchema as HealthSchema };
|
|
204
|
+
|
|
205
|
+
export {
|
|
206
|
+
Chat as Chat,
|
|
207
|
+
type ChatMessage as ChatMessage,
|
|
208
|
+
type ChatRequest as ChatRequest,
|
|
209
|
+
type ChatResponse as ChatResponse,
|
|
210
|
+
type Choice as Choice,
|
|
211
|
+
type Usage as Usage,
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
export {
|
|
215
|
+
Tools as Tools,
|
|
216
|
+
type AuthorizeToolRequest as AuthorizeToolRequest,
|
|
217
|
+
type ExecuteToolRequest as ExecuteToolRequest,
|
|
218
|
+
type Inputs as Inputs,
|
|
219
|
+
type Output as Output,
|
|
220
|
+
type Parameter as Parameter,
|
|
221
|
+
type Requirements as Requirements,
|
|
222
|
+
type Response as Response,
|
|
223
|
+
type ResponseOutput as ResponseOutput,
|
|
224
|
+
type ToolkitDefinition as ToolkitDefinition,
|
|
225
|
+
type ValueSchema as ValueSchema,
|
|
226
|
+
type ToolListParams as ToolListParams,
|
|
227
|
+
type ToolAuthorizeParams as ToolAuthorizeParams,
|
|
228
|
+
type ToolExecuteParams as ToolExecuteParams,
|
|
229
|
+
type ToolGetParams as ToolGetParams,
|
|
230
|
+
};
|
|
231
|
+
|
|
232
|
+
export type AuthorizationResponse = API.AuthorizationResponse;
|
|
233
|
+
export type Error = API.Error;
|
|
234
|
+
export type ToolDefinition = API.ToolDefinition;
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export { toFile, fileFromPath } from './uploads';
|
|
238
|
+
export {
|
|
166
239
|
ArcadeError,
|
|
167
240
|
APIError,
|
|
168
241
|
APIConnectionError,
|
|
@@ -176,52 +249,6 @@ export const {
|
|
|
176
249
|
InternalServerError,
|
|
177
250
|
PermissionDeniedError,
|
|
178
251
|
UnprocessableEntityError,
|
|
179
|
-
}
|
|
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
|
-
}
|
|
252
|
+
} from './error';
|
|
226
253
|
|
|
227
254
|
export default Arcade;
|
package/src/resources/auth.ts
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../resource';
|
|
4
4
|
import * as Core from '../core';
|
|
5
|
-
import * as AuthAPI from './auth';
|
|
6
5
|
import * as Shared from './shared';
|
|
7
6
|
|
|
8
7
|
export class Auth extends APIResource {
|
|
@@ -90,8 +89,10 @@ export interface AuthStatusParams {
|
|
|
90
89
|
wait?: number;
|
|
91
90
|
}
|
|
92
91
|
|
|
93
|
-
export namespace Auth {
|
|
94
|
-
export
|
|
95
|
-
|
|
96
|
-
|
|
92
|
+
export declare namespace Auth {
|
|
93
|
+
export {
|
|
94
|
+
type AuthRequest as AuthRequest,
|
|
95
|
+
type AuthAuthorizeParams as AuthAuthorizeParams,
|
|
96
|
+
type AuthStatusParams as AuthStatusParams,
|
|
97
|
+
};
|
|
97
98
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../../resource';
|
|
4
|
-
import * as ChatAPI from './chat';
|
|
5
4
|
import * as Shared from '../shared';
|
|
6
5
|
import * as CompletionsAPI from './completions';
|
|
6
|
+
import { CompletionCreateParams, Completions } from './completions';
|
|
7
7
|
|
|
8
8
|
export class Chat extends APIResource {
|
|
9
9
|
completions: CompletionsAPI.Completions = new CompletionsAPI.Completions(this._client);
|
|
@@ -175,12 +175,16 @@ export interface Usage {
|
|
|
175
175
|
total_tokens?: number;
|
|
176
176
|
}
|
|
177
177
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
export
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
178
|
+
Chat.Completions = Completions;
|
|
179
|
+
|
|
180
|
+
export declare namespace Chat {
|
|
181
|
+
export {
|
|
182
|
+
type ChatMessage as ChatMessage,
|
|
183
|
+
type ChatRequest as ChatRequest,
|
|
184
|
+
type ChatResponse as ChatResponse,
|
|
185
|
+
type Choice as Choice,
|
|
186
|
+
type Usage as Usage,
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export { Completions as Completions, type CompletionCreateParams as CompletionCreateParams };
|
|
186
190
|
}
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
import { APIResource } from '../../resource';
|
|
4
4
|
import * as Core from '../../core';
|
|
5
|
-
import * as CompletionsAPI from './completions';
|
|
6
5
|
import * as ChatAPI from './chat';
|
|
7
6
|
|
|
8
7
|
export class Completions extends APIResource {
|
|
@@ -97,6 +96,6 @@ export namespace CompletionCreateParams {
|
|
|
97
96
|
}
|
|
98
97
|
}
|
|
99
98
|
|
|
100
|
-
export namespace Completions {
|
|
101
|
-
export
|
|
99
|
+
export declare namespace Completions {
|
|
100
|
+
export { type CompletionCreateParams as CompletionCreateParams };
|
|
102
101
|
}
|