@arcadeai/arcadejs 0.2.1 → 1.0.0-rc.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 +44 -0
- package/README.md +4 -5
- package/core.d.ts.map +1 -1
- package/core.js +10 -1
- package/core.js.map +1 -1
- package/core.mjs +10 -1
- package/core.mjs.map +1 -1
- package/index.d.mts +9 -9
- package/index.d.ts +9 -9
- package/index.d.ts.map +1 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/index.mjs +2 -1
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/resources/auth.d.ts +73 -9
- package/resources/auth.d.ts.map +1 -1
- package/resources/auth.js +81 -1
- package/resources/auth.js.map +1 -1
- package/resources/auth.mjs +79 -0
- package/resources/auth.mjs.map +1 -1
- package/resources/chat/chat.d.ts +5 -2
- package/resources/chat/chat.d.ts.map +1 -1
- package/resources/chat/chat.js.map +1 -1
- package/resources/chat/chat.mjs.map +1 -1
- package/resources/chat/completions.d.ts +4 -1
- package/resources/chat/completions.d.ts.map +1 -1
- package/resources/index.d.ts +1 -1
- package/resources/index.d.ts.map +1 -1
- package/resources/index.js +3 -1
- package/resources/index.js.map +1 -1
- package/resources/index.mjs +1 -1
- package/resources/index.mjs.map +1 -1
- package/resources/shared.d.ts +8 -22
- package/resources/shared.d.ts.map +1 -1
- package/resources/shared.js +0 -5
- package/resources/shared.js.map +1 -1
- package/resources/shared.mjs +1 -3
- package/resources/shared.mjs.map +1 -1
- package/resources/tools/formatted.d.ts +4 -7
- package/resources/tools/formatted.d.ts.map +1 -1
- package/resources/tools/formatted.js +6 -6
- package/resources/tools/formatted.js.map +1 -1
- package/resources/tools/formatted.mjs +6 -6
- package/resources/tools/formatted.mjs.map +1 -1
- package/resources/tools/index.d.ts +2 -1
- package/resources/tools/index.d.ts.map +1 -1
- package/resources/tools/index.js +5 -1
- package/resources/tools/index.js.map +1 -1
- package/resources/tools/index.mjs +2 -1
- package/resources/tools/index.mjs.map +1 -1
- package/resources/tools/scheduled.d.ts +39 -0
- package/resources/tools/scheduled.d.ts.map +1 -0
- package/resources/tools/scheduled.js +24 -0
- package/resources/tools/scheduled.js.map +1 -0
- package/resources/tools/scheduled.mjs +20 -0
- package/resources/tools/scheduled.mjs.map +1 -0
- package/resources/tools/tools.d.ts +197 -72
- package/resources/tools/tools.d.ts.map +1 -1
- package/resources/tools/tools.js +16 -6
- package/resources/tools/tools.js.map +1 -1
- package/resources/tools/tools.mjs +13 -5
- package/resources/tools/tools.mjs.map +1 -1
- package/src/core.ts +11 -1
- package/src/index.ts +20 -23
- package/src/resources/auth.ts +127 -8
- package/src/resources/chat/chat.ts +6 -2
- package/src/resources/chat/completions.ts +5 -1
- package/src/resources/index.ts +7 -8
- package/src/resources/shared.ts +9 -30
- package/src/resources/tools/formatted.ts +14 -10
- package/src/resources/tools/index.ts +8 -8
- package/src/resources/tools/scheduled.ts +76 -0
- package/src/resources/tools/tools.ts +278 -86
- package/src/version.ts +1 -1
- package/version.d.ts +1 -1
- package/version.d.ts.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/version.mjs +1 -1
- package/version.mjs.map +1 -1
package/resources/tools/tools.js
CHANGED
|
@@ -24,23 +24,25 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
24
24
|
return result;
|
|
25
25
|
};
|
|
26
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
27
|
-
exports.
|
|
27
|
+
exports.ToolExecutionsOffsetPage = exports.ToolListResponsesOffsetPage = exports.Tools = void 0;
|
|
28
28
|
const resource_1 = require("../../resource.js");
|
|
29
29
|
const core_1 = require("../../core.js");
|
|
30
|
-
const shared_1 = require("../shared.js");
|
|
31
|
-
Object.defineProperty(exports, "ToolDefinitionsOffsetPage", { enumerable: true, get: function () { return shared_1.ToolDefinitionsOffsetPage; } });
|
|
32
30
|
const FormattedAPI = __importStar(require("./formatted.js"));
|
|
33
31
|
const formatted_1 = require("./formatted.js");
|
|
32
|
+
const ScheduledAPI = __importStar(require("./scheduled.js"));
|
|
33
|
+
const scheduled_1 = require("./scheduled.js");
|
|
34
|
+
const pagination_1 = require("../../pagination.js");
|
|
34
35
|
class Tools extends resource_1.APIResource {
|
|
35
36
|
constructor() {
|
|
36
37
|
super(...arguments);
|
|
38
|
+
this.scheduled = new ScheduledAPI.Scheduled(this._client);
|
|
37
39
|
this.formatted = new FormattedAPI.Formatted(this._client);
|
|
38
40
|
}
|
|
39
41
|
list(query = {}, options) {
|
|
40
42
|
if ((0, core_1.isRequestOptions)(query)) {
|
|
41
43
|
return this.list({}, query);
|
|
42
44
|
}
|
|
43
|
-
return this._client.getAPIList('/v1/tools
|
|
45
|
+
return this._client.getAPIList('/v1/tools', ToolListResponsesOffsetPage, { query, ...options });
|
|
44
46
|
}
|
|
45
47
|
/**
|
|
46
48
|
* Authorizes a user for a specific tool by name
|
|
@@ -57,11 +59,19 @@ class Tools extends resource_1.APIResource {
|
|
|
57
59
|
/**
|
|
58
60
|
* Returns the arcade tool specification for a specific tool
|
|
59
61
|
*/
|
|
60
|
-
get(
|
|
61
|
-
return this._client.get(
|
|
62
|
+
get(name, options) {
|
|
63
|
+
return this._client.get(`/v1/tools/${name}`, options);
|
|
62
64
|
}
|
|
63
65
|
}
|
|
64
66
|
exports.Tools = Tools;
|
|
67
|
+
class ToolListResponsesOffsetPage extends pagination_1.OffsetPage {
|
|
68
|
+
}
|
|
69
|
+
exports.ToolListResponsesOffsetPage = ToolListResponsesOffsetPage;
|
|
70
|
+
class ToolExecutionsOffsetPage extends pagination_1.OffsetPage {
|
|
71
|
+
}
|
|
72
|
+
exports.ToolExecutionsOffsetPage = ToolExecutionsOffsetPage;
|
|
73
|
+
Tools.ToolListResponsesOffsetPage = ToolListResponsesOffsetPage;
|
|
74
|
+
Tools.Scheduled = scheduled_1.Scheduled;
|
|
65
75
|
Tools.Formatted = formatted_1.Formatted;
|
|
66
76
|
Tools.FormattedListResponsesOffsetPage = formatted_1.FormattedListResponsesOffsetPage;
|
|
67
77
|
//# sourceMappingURL=tools.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/resources/tools/tools.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtF,gDAA6C;AAC7C,wCAA8C;
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../../src/resources/tools/tools.ts"],"names":[],"mappings":";AAAA,sFAAsF;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtF,gDAA6C;AAC7C,wCAA8C;AAI9C,6DAA4C;AAC5C,8CAOqB;AACrB,6DAA4C;AAC5C,8CAAmF;AACnF,oDAAqE;AAErE,MAAa,KAAM,SAAQ,sBAAW;IAAtC;;QACE,cAAS,GAA2B,IAAI,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7E,cAAS,GAA2B,IAAI,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IA4C/E,CAAC;IAjCC,IAAI,CACF,QAA8C,EAAE,EAChD,OAA6B;QAE7B,IAAI,IAAA,uBAAgB,EAAC,KAAK,CAAC,EAAE;YAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;SAC7B;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE,2BAA2B,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAClG,CAAC;IAED;;OAEG;IACH,SAAS,CACP,IAAyB,EACzB,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACxE,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,IAAuB,EAAE,OAA6B;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,IAAY,EAAE,OAA6B;QAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;CACF;AA9CD,sBA8CC;AAED,MAAa,2BAA4B,SAAQ,uBAA4B;CAAG;AAAhF,kEAAgF;AAEhF,MAAa,wBAAyB,SAAQ,uBAAyB;CAAG;AAA1E,4DAA0E;AA8V1E,KAAK,CAAC,2BAA2B,GAAG,2BAA2B,CAAC;AAChE,KAAK,CAAC,SAAS,GAAG,qBAAS,CAAC;AAC5B,KAAK,CAAC,SAAS,GAAG,qBAAS,CAAC;AAC5B,KAAK,CAAC,gCAAgC,GAAG,4CAAgC,CAAC"}
|
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
import { APIResource } from "../../resource.mjs";
|
|
3
3
|
import { isRequestOptions } from "../../core.mjs";
|
|
4
|
-
import { ToolDefinitionsOffsetPage } from "../shared.mjs";
|
|
5
4
|
import * as FormattedAPI from "./formatted.mjs";
|
|
6
5
|
import { Formatted, FormattedListResponsesOffsetPage, } from "./formatted.mjs";
|
|
6
|
+
import * as ScheduledAPI from "./scheduled.mjs";
|
|
7
|
+
import { Scheduled } from "./scheduled.mjs";
|
|
8
|
+
import { OffsetPage } from "../../pagination.mjs";
|
|
7
9
|
export class Tools extends APIResource {
|
|
8
10
|
constructor() {
|
|
9
11
|
super(...arguments);
|
|
12
|
+
this.scheduled = new ScheduledAPI.Scheduled(this._client);
|
|
10
13
|
this.formatted = new FormattedAPI.Formatted(this._client);
|
|
11
14
|
}
|
|
12
15
|
list(query = {}, options) {
|
|
13
16
|
if (isRequestOptions(query)) {
|
|
14
17
|
return this.list({}, query);
|
|
15
18
|
}
|
|
16
|
-
return this._client.getAPIList('/v1/tools
|
|
19
|
+
return this._client.getAPIList('/v1/tools', ToolListResponsesOffsetPage, { query, ...options });
|
|
17
20
|
}
|
|
18
21
|
/**
|
|
19
22
|
* Authorizes a user for a specific tool by name
|
|
@@ -30,11 +33,16 @@ export class Tools extends APIResource {
|
|
|
30
33
|
/**
|
|
31
34
|
* Returns the arcade tool specification for a specific tool
|
|
32
35
|
*/
|
|
33
|
-
get(
|
|
34
|
-
return this._client.get(
|
|
36
|
+
get(name, options) {
|
|
37
|
+
return this._client.get(`/v1/tools/${name}`, options);
|
|
35
38
|
}
|
|
36
39
|
}
|
|
40
|
+
export class ToolListResponsesOffsetPage extends OffsetPage {
|
|
41
|
+
}
|
|
42
|
+
export class ToolExecutionsOffsetPage extends OffsetPage {
|
|
43
|
+
}
|
|
44
|
+
Tools.ToolListResponsesOffsetPage = ToolListResponsesOffsetPage;
|
|
45
|
+
Tools.Scheduled = Scheduled;
|
|
37
46
|
Tools.Formatted = Formatted;
|
|
38
47
|
Tools.FormattedListResponsesOffsetPage = FormattedListResponsesOffsetPage;
|
|
39
|
-
export { ToolDefinitionsOffsetPage };
|
|
40
48
|
//# sourceMappingURL=tools.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.mjs","sourceRoot":"","sources":["../../src/resources/tools/tools.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OACf,EAAE,gBAAgB,EAAE;
|
|
1
|
+
{"version":3,"file":"tools.mjs","sourceRoot":"","sources":["../../src/resources/tools/tools.ts"],"names":[],"mappings":"AAAA,sFAAsF;OAE/E,EAAE,WAAW,EAAE;OACf,EAAE,gBAAgB,EAAE;OAIpB,KAAK,YAAY;OACjB,EACL,SAAS,EAKT,gCAAgC,GACjC;OACM,KAAK,YAAY;OACjB,EAAE,SAAS,EAA6C;OACxD,EAAE,UAAU,EAAyB;AAE5C,MAAM,OAAO,KAAM,SAAQ,WAAW;IAAtC;;QACE,cAAS,GAA2B,IAAI,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAC7E,cAAS,GAA2B,IAAI,YAAY,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IA4C/E,CAAC;IAjCC,IAAI,CACF,QAA8C,EAAE,EAChD,OAA6B;QAE7B,IAAI,gBAAgB,CAAC,KAAK,CAAC,EAAE;YAC3B,OAAO,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;SAC7B;QACD,OAAO,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,WAAW,EAAE,2BAA2B,EAAE,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IAClG,CAAC;IAED;;OAEG;IACH,SAAS,CACP,IAAyB,EACzB,OAA6B;QAE7B,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,qBAAqB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACxE,CAAC;IAED;;OAEG;IACH,OAAO,CAAC,IAAuB,EAAE,OAA6B;QAC5D,OAAO,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,mBAAmB,EAAE,EAAE,IAAI,EAAE,GAAG,OAAO,EAAE,CAAC,CAAC;IACtE,CAAC;IAED;;OAEG;IACH,GAAG,CAAC,IAAY,EAAE,OAA6B;QAC7C,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;IACxD,CAAC;CACF;AAED,MAAM,OAAO,2BAA4B,SAAQ,UAA4B;CAAG;AAEhF,MAAM,OAAO,wBAAyB,SAAQ,UAAyB;CAAG;AA8V1E,KAAK,CAAC,2BAA2B,GAAG,2BAA2B,CAAC;AAChE,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;AAC5B,KAAK,CAAC,SAAS,GAAG,SAAS,CAAC;AAC5B,KAAK,CAAC,gCAAgC,GAAG,gCAAgC,CAAC"}
|
package/src/core.ts
CHANGED
|
@@ -522,9 +522,19 @@ export abstract class APIClient {
|
|
|
522
522
|
|
|
523
523
|
const timeout = setTimeout(() => controller.abort(), ms);
|
|
524
524
|
|
|
525
|
+
const fetchOptions = {
|
|
526
|
+
signal: controller.signal as any,
|
|
527
|
+
...options,
|
|
528
|
+
};
|
|
529
|
+
if (fetchOptions.method) {
|
|
530
|
+
// Custom methods like 'patch' need to be uppercased
|
|
531
|
+
// See https://github.com/nodejs/undici/issues/2294
|
|
532
|
+
fetchOptions.method = fetchOptions.method.toUpperCase();
|
|
533
|
+
}
|
|
534
|
+
|
|
525
535
|
return (
|
|
526
536
|
// use undefined this binding; fetch errors if bound to something else in browser/cloudflare
|
|
527
|
-
this.fetch.call(undefined, url,
|
|
537
|
+
this.fetch.call(undefined, url, fetchOptions).finally(() => {
|
|
528
538
|
clearTimeout(timeout);
|
|
529
539
|
})
|
|
530
540
|
);
|
package/src/index.ts
CHANGED
|
@@ -13,17 +13,15 @@ import { Chat, ChatMessage, ChatRequest, ChatResponse, Choice, Usage } from './r
|
|
|
13
13
|
import {
|
|
14
14
|
AuthorizeToolRequest,
|
|
15
15
|
ExecuteToolRequest,
|
|
16
|
-
|
|
17
|
-
Output,
|
|
18
|
-
Parameter,
|
|
19
|
-
Requirements,
|
|
20
|
-
Response,
|
|
21
|
-
ResponseOutput,
|
|
16
|
+
ExecuteToolResponse,
|
|
22
17
|
ToolAuthorizeParams,
|
|
23
18
|
ToolExecuteParams,
|
|
24
|
-
|
|
19
|
+
ToolExecution,
|
|
20
|
+
ToolExecutionAttempt,
|
|
21
|
+
ToolGetResponse,
|
|
25
22
|
ToolListParams,
|
|
26
|
-
|
|
23
|
+
ToolListResponse,
|
|
24
|
+
ToolListResponsesOffsetPage,
|
|
27
25
|
Tools,
|
|
28
26
|
ValueSchema,
|
|
29
27
|
} from './resources/tools/tools';
|
|
@@ -48,7 +46,7 @@ export interface ClientOptions {
|
|
|
48
46
|
* Note that request timeouts are retried by default, so in a worst-case scenario you may wait
|
|
49
47
|
* much longer than this timeout before the promise succeeds or fails.
|
|
50
48
|
*/
|
|
51
|
-
timeout?: number;
|
|
49
|
+
timeout?: number | undefined;
|
|
52
50
|
|
|
53
51
|
/**
|
|
54
52
|
* An HTTP agent used to manage HTTP(S) connections.
|
|
@@ -56,7 +54,7 @@ export interface ClientOptions {
|
|
|
56
54
|
* If not provided, an agent will be constructed by default in the Node.js environment,
|
|
57
55
|
* otherwise no agent is used.
|
|
58
56
|
*/
|
|
59
|
-
httpAgent?: Agent;
|
|
57
|
+
httpAgent?: Agent | undefined;
|
|
60
58
|
|
|
61
59
|
/**
|
|
62
60
|
* Specify a custom `fetch` function implementation.
|
|
@@ -72,7 +70,7 @@ export interface ClientOptions {
|
|
|
72
70
|
*
|
|
73
71
|
* @default 2
|
|
74
72
|
*/
|
|
75
|
-
maxRetries?: number;
|
|
73
|
+
maxRetries?: number | undefined;
|
|
76
74
|
|
|
77
75
|
/**
|
|
78
76
|
* Default headers to include with every request to the API.
|
|
@@ -80,7 +78,7 @@ export interface ClientOptions {
|
|
|
80
78
|
* These can be removed in individual requests by explicitly setting the
|
|
81
79
|
* header to `undefined` or `null` in request options.
|
|
82
80
|
*/
|
|
83
|
-
defaultHeaders?: Core.Headers;
|
|
81
|
+
defaultHeaders?: Core.Headers | undefined;
|
|
84
82
|
|
|
85
83
|
/**
|
|
86
84
|
* Default query parameters to include with every request to the API.
|
|
@@ -88,7 +86,7 @@ export interface ClientOptions {
|
|
|
88
86
|
* These can be removed in individual requests by explicitly setting the
|
|
89
87
|
* param to `undefined` in request options.
|
|
90
88
|
*/
|
|
91
|
-
defaultQuery?: Core.DefaultQuery;
|
|
89
|
+
defaultQuery?: Core.DefaultQuery | undefined;
|
|
92
90
|
}
|
|
93
91
|
|
|
94
92
|
/**
|
|
@@ -187,6 +185,7 @@ Arcade.Auth = Auth;
|
|
|
187
185
|
Arcade.Health = Health;
|
|
188
186
|
Arcade.Chat = Chat;
|
|
189
187
|
Arcade.Tools = Tools;
|
|
188
|
+
Arcade.ToolListResponsesOffsetPage = ToolListResponsesOffsetPage;
|
|
190
189
|
export declare namespace Arcade {
|
|
191
190
|
export type RequestOptions = Core.RequestOptions;
|
|
192
191
|
|
|
@@ -215,23 +214,21 @@ export declare namespace Arcade {
|
|
|
215
214
|
Tools as Tools,
|
|
216
215
|
type AuthorizeToolRequest as AuthorizeToolRequest,
|
|
217
216
|
type ExecuteToolRequest as ExecuteToolRequest,
|
|
218
|
-
type
|
|
219
|
-
type
|
|
220
|
-
type
|
|
221
|
-
type Requirements as Requirements,
|
|
222
|
-
type Response as Response,
|
|
223
|
-
type ResponseOutput as ResponseOutput,
|
|
224
|
-
type ToolkitDefinition as ToolkitDefinition,
|
|
217
|
+
type ExecuteToolResponse as ExecuteToolResponse,
|
|
218
|
+
type ToolExecution as ToolExecution,
|
|
219
|
+
type ToolExecutionAttempt as ToolExecutionAttempt,
|
|
225
220
|
type ValueSchema as ValueSchema,
|
|
221
|
+
type ToolListResponse as ToolListResponse,
|
|
222
|
+
type ToolGetResponse as ToolGetResponse,
|
|
223
|
+
ToolListResponsesOffsetPage as ToolListResponsesOffsetPage,
|
|
226
224
|
type ToolListParams as ToolListParams,
|
|
227
225
|
type ToolAuthorizeParams as ToolAuthorizeParams,
|
|
228
226
|
type ToolExecuteParams as ToolExecuteParams,
|
|
229
|
-
type ToolGetParams as ToolGetParams,
|
|
230
227
|
};
|
|
231
228
|
|
|
232
|
-
export type
|
|
229
|
+
export type AuthAuthorizationContext = API.AuthAuthorizationContext;
|
|
230
|
+
export type AuthAuthorizationResponse = API.AuthAuthorizationResponse;
|
|
233
231
|
export type Error = API.Error;
|
|
234
|
-
export type ToolDefinition = API.ToolDefinition;
|
|
235
232
|
}
|
|
236
233
|
|
|
237
234
|
export { toFile, fileFromPath } from './uploads';
|
package/src/resources/auth.ts
CHANGED
|
@@ -1,17 +1,64 @@
|
|
|
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 Core from '../core';
|
|
5
4
|
import * as Shared from './shared';
|
|
5
|
+
import * as Core from '../core';
|
|
6
|
+
|
|
7
|
+
export const DEFAULT_LONGPOLL_WAIT_TIME = 45;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Error thrown when authorization-related operations fail
|
|
11
|
+
*/
|
|
12
|
+
export class AuthorizationError extends Error {
|
|
13
|
+
constructor(message: string) {
|
|
14
|
+
super(message);
|
|
15
|
+
this.name = 'AuthorizationError';
|
|
16
|
+
}
|
|
17
|
+
}
|
|
6
18
|
|
|
7
19
|
export class Auth extends APIResource {
|
|
20
|
+
/**
|
|
21
|
+
* Starts the authorization process for a given provider and scopes.
|
|
22
|
+
* @param userId - The user ID for which authorization is being requested
|
|
23
|
+
* @param provider - The authorization provider (e.g., 'github', 'google', 'linkedin', 'microsoft', 'slack', 'spotify', 'x', 'zoom')
|
|
24
|
+
* @param options - Optional parameters
|
|
25
|
+
* @param options.providerType - The type of authorization provider. Defaults to 'oauth2'
|
|
26
|
+
* @param options.scopes - A list of scopes required for authorization, if any. Defaults to []
|
|
27
|
+
* @returns The authorization response
|
|
28
|
+
*
|
|
29
|
+
* Example:
|
|
30
|
+
* ```ts
|
|
31
|
+
* const authResponse = await client.auth.start("user@example.com", "github");
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
start(
|
|
35
|
+
userId: string,
|
|
36
|
+
provider: string,
|
|
37
|
+
options: AuthStartOptions = {},
|
|
38
|
+
): Core.APIPromise<Shared.AuthAuthorizationResponse> {
|
|
39
|
+
const { providerType = 'oauth2', scopes = [] } = options;
|
|
40
|
+
|
|
41
|
+
const authRequirement: AuthAuthorizeParams.AuthRequirement = {
|
|
42
|
+
provider_id: provider,
|
|
43
|
+
provider_type: providerType,
|
|
44
|
+
oauth2: {
|
|
45
|
+
scopes,
|
|
46
|
+
},
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
return this.authorize({
|
|
50
|
+
auth_requirement: authRequirement,
|
|
51
|
+
user_id: userId,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
8
55
|
/**
|
|
9
56
|
* Starts the authorization process for given authorization requirements
|
|
10
57
|
*/
|
|
11
58
|
authorize(
|
|
12
59
|
body: AuthAuthorizeParams,
|
|
13
60
|
options?: Core.RequestOptions,
|
|
14
|
-
): Core.APIPromise<Shared.
|
|
61
|
+
): Core.APIPromise<Shared.AuthAuthorizationResponse> {
|
|
15
62
|
return this._client.post('/v1/auth/authorize', { body, ...options });
|
|
16
63
|
}
|
|
17
64
|
|
|
@@ -23,9 +70,55 @@ export class Auth extends APIResource {
|
|
|
23
70
|
status(
|
|
24
71
|
query: AuthStatusParams,
|
|
25
72
|
options?: Core.RequestOptions,
|
|
26
|
-
): Core.APIPromise<Shared.
|
|
73
|
+
): Core.APIPromise<Shared.AuthAuthorizationResponse> {
|
|
27
74
|
return this._client.get('/v1/auth/status', { query, ...options });
|
|
28
75
|
}
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Waits for the authorization process to complete.
|
|
79
|
+
* @param authResponseOrId - The authorization response or ID to wait for completion
|
|
80
|
+
* @returns The completed authorization response
|
|
81
|
+
* @throws {AuthorizationError} When the authorization ID is missing or invalid
|
|
82
|
+
*
|
|
83
|
+
* Example:
|
|
84
|
+
* ```ts
|
|
85
|
+
* const authResponse = await client.auth.start("user@example.com", "github");
|
|
86
|
+
* try {
|
|
87
|
+
* const completedAuth = await client.auth.waitForCompletion(authResponse);
|
|
88
|
+
* console.log('Authorization completed:', completedAuth);
|
|
89
|
+
* } catch (error) {
|
|
90
|
+
* if (error instanceof AuthorizationError) {
|
|
91
|
+
* console.error('Authorization failed:', error.message);
|
|
92
|
+
* }
|
|
93
|
+
* }
|
|
94
|
+
* ```
|
|
95
|
+
*/
|
|
96
|
+
async waitForCompletion(
|
|
97
|
+
authResponseOrId: Shared.AuthAuthorizationResponse | string,
|
|
98
|
+
): Promise<Shared.AuthAuthorizationResponse> {
|
|
99
|
+
let authId: string;
|
|
100
|
+
let authResponse: Shared.AuthAuthorizationResponse;
|
|
101
|
+
|
|
102
|
+
if (typeof authResponseOrId === 'string') {
|
|
103
|
+
authId = authResponseOrId;
|
|
104
|
+
authResponse = { status: 'pending' } as Shared.AuthAuthorizationResponse;
|
|
105
|
+
} else {
|
|
106
|
+
if (!authResponseOrId.id) {
|
|
107
|
+
throw new AuthorizationError('Authorization ID is required');
|
|
108
|
+
}
|
|
109
|
+
authId = authResponseOrId.id;
|
|
110
|
+
authResponse = authResponseOrId;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
while (authResponse.status !== 'completed') {
|
|
114
|
+
authResponse = await this.status({
|
|
115
|
+
id: authId,
|
|
116
|
+
wait: DEFAULT_LONGPOLL_WAIT_TIME,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return authResponse;
|
|
121
|
+
}
|
|
29
122
|
}
|
|
30
123
|
|
|
31
124
|
export interface AuthRequest {
|
|
@@ -36,8 +129,16 @@ export interface AuthRequest {
|
|
|
36
129
|
|
|
37
130
|
export namespace AuthRequest {
|
|
38
131
|
export interface AuthRequirement {
|
|
132
|
+
/**
|
|
133
|
+
* one of ID or ProviderID must be set
|
|
134
|
+
*/
|
|
135
|
+
id?: string;
|
|
136
|
+
|
|
39
137
|
oauth2?: AuthRequirement.Oauth2;
|
|
40
138
|
|
|
139
|
+
/**
|
|
140
|
+
* one of ID or ProviderID must be set
|
|
141
|
+
*/
|
|
41
142
|
provider_id?: string;
|
|
42
143
|
|
|
43
144
|
provider_type?: string;
|
|
@@ -58,8 +159,16 @@ export interface AuthAuthorizeParams {
|
|
|
58
159
|
|
|
59
160
|
export namespace AuthAuthorizeParams {
|
|
60
161
|
export interface AuthRequirement {
|
|
162
|
+
/**
|
|
163
|
+
* one of ID or ProviderID must be set
|
|
164
|
+
*/
|
|
165
|
+
id?: string;
|
|
166
|
+
|
|
61
167
|
oauth2?: AuthRequirement.Oauth2;
|
|
62
168
|
|
|
169
|
+
/**
|
|
170
|
+
* one of ID or ProviderID must be set
|
|
171
|
+
*/
|
|
63
172
|
provider_id?: string;
|
|
64
173
|
|
|
65
174
|
provider_type?: string;
|
|
@@ -76,17 +185,26 @@ export interface AuthStatusParams {
|
|
|
76
185
|
/**
|
|
77
186
|
* Authorization ID
|
|
78
187
|
*/
|
|
79
|
-
|
|
188
|
+
id: string;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* Timeout in seconds (max 59)
|
|
192
|
+
*/
|
|
193
|
+
wait?: number;
|
|
194
|
+
}
|
|
80
195
|
|
|
196
|
+
export interface AuthStartOptions {
|
|
81
197
|
/**
|
|
82
|
-
*
|
|
198
|
+
* The type of authorization provider
|
|
199
|
+
* @default 'oauth2'
|
|
83
200
|
*/
|
|
84
|
-
|
|
201
|
+
providerType?: string;
|
|
85
202
|
|
|
86
203
|
/**
|
|
87
|
-
*
|
|
204
|
+
* A list of scopes required for authorization
|
|
205
|
+
* @default []
|
|
88
206
|
*/
|
|
89
|
-
|
|
207
|
+
scopes?: string[];
|
|
90
208
|
}
|
|
91
209
|
|
|
92
210
|
export declare namespace Auth {
|
|
@@ -94,5 +212,6 @@ export declare namespace Auth {
|
|
|
94
212
|
type AuthRequest as AuthRequest,
|
|
95
213
|
type AuthAuthorizeParams as AuthAuthorizeParams,
|
|
96
214
|
type AuthStatusParams as AuthStatusParams,
|
|
215
|
+
type AuthStartOptions as AuthStartOptions,
|
|
97
216
|
};
|
|
98
217
|
}
|
|
@@ -88,7 +88,7 @@ export interface ChatRequest {
|
|
|
88
88
|
|
|
89
89
|
presence_penalty?: number;
|
|
90
90
|
|
|
91
|
-
response_format?:
|
|
91
|
+
response_format?: ChatRequest.ResponseFormat;
|
|
92
92
|
|
|
93
93
|
seed?: number;
|
|
94
94
|
|
|
@@ -123,6 +123,10 @@ export interface ChatRequest {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
export namespace ChatRequest {
|
|
126
|
+
export interface ResponseFormat {
|
|
127
|
+
type?: 'json_object' | 'text';
|
|
128
|
+
}
|
|
129
|
+
|
|
126
130
|
/**
|
|
127
131
|
* Options for streaming response. Only set this when you set stream: true.
|
|
128
132
|
*/
|
|
@@ -162,7 +166,7 @@ export interface Choice {
|
|
|
162
166
|
|
|
163
167
|
message?: ChatMessage;
|
|
164
168
|
|
|
165
|
-
tool_authorizations?: Array<Shared.
|
|
169
|
+
tool_authorizations?: Array<Shared.AuthAuthorizationResponse>;
|
|
166
170
|
|
|
167
171
|
tool_messages?: Array<ChatMessage>;
|
|
168
172
|
}
|
|
@@ -47,7 +47,7 @@ export interface CompletionCreateParams {
|
|
|
47
47
|
|
|
48
48
|
presence_penalty?: number;
|
|
49
49
|
|
|
50
|
-
response_format?:
|
|
50
|
+
response_format?: CompletionCreateParams.ResponseFormat;
|
|
51
51
|
|
|
52
52
|
seed?: number;
|
|
53
53
|
|
|
@@ -82,6 +82,10 @@ export interface CompletionCreateParams {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
export namespace CompletionCreateParams {
|
|
85
|
+
export interface ResponseFormat {
|
|
86
|
+
type?: 'json_object' | 'text';
|
|
87
|
+
}
|
|
88
|
+
|
|
85
89
|
/**
|
|
86
90
|
* Options for streaming response. Only set this when you set stream: true.
|
|
87
91
|
*/
|
package/src/resources/index.ts
CHANGED
|
@@ -12,19 +12,18 @@ export {
|
|
|
12
12
|
} from './chat/chat';
|
|
13
13
|
export { Health, type HealthSchema } from './health';
|
|
14
14
|
export {
|
|
15
|
+
ToolExecutionsOffsetPage,
|
|
16
|
+
ToolListResponsesOffsetPage,
|
|
15
17
|
Tools,
|
|
16
18
|
type AuthorizeToolRequest,
|
|
17
19
|
type ExecuteToolRequest,
|
|
18
|
-
type
|
|
19
|
-
type
|
|
20
|
-
type
|
|
21
|
-
type Requirements,
|
|
22
|
-
type Response,
|
|
23
|
-
type ResponseOutput,
|
|
24
|
-
type ToolkitDefinition,
|
|
20
|
+
type ExecuteToolResponse,
|
|
21
|
+
type ToolExecution,
|
|
22
|
+
type ToolExecutionAttempt,
|
|
25
23
|
type ValueSchema,
|
|
24
|
+
type ToolListResponse,
|
|
25
|
+
type ToolGetResponse,
|
|
26
26
|
type ToolListParams,
|
|
27
27
|
type ToolAuthorizeParams,
|
|
28
28
|
type ToolExecuteParams,
|
|
29
|
-
type ToolGetParams,
|
|
30
29
|
} from './tools/tools';
|
package/src/resources/shared.ts
CHANGED
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
export interface AuthAuthorizationContext {
|
|
4
|
+
token?: string;
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
user_info?: Record<string, unknown>;
|
|
7
|
+
}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
export interface AuthAuthorizationResponse {
|
|
10
|
+
id?: string;
|
|
10
11
|
|
|
11
|
-
context?:
|
|
12
|
+
context?: AuthAuthorizationContext;
|
|
12
13
|
|
|
13
14
|
provider_id?: string;
|
|
14
15
|
|
|
@@ -16,15 +17,9 @@ export interface AuthorizationResponse {
|
|
|
16
17
|
|
|
17
18
|
status?: 'pending' | 'completed' | 'failed';
|
|
18
19
|
|
|
19
|
-
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export namespace AuthorizationResponse {
|
|
23
|
-
export interface Context {
|
|
24
|
-
token?: string;
|
|
20
|
+
url?: string;
|
|
25
21
|
|
|
26
|
-
|
|
27
|
-
}
|
|
22
|
+
user_id?: string;
|
|
28
23
|
}
|
|
29
24
|
|
|
30
25
|
export interface Error {
|
|
@@ -32,19 +27,3 @@ export interface Error {
|
|
|
32
27
|
|
|
33
28
|
name?: string;
|
|
34
29
|
}
|
|
35
|
-
|
|
36
|
-
export interface ToolDefinition {
|
|
37
|
-
inputs: ToolsAPI.Inputs;
|
|
38
|
-
|
|
39
|
-
name: string;
|
|
40
|
-
|
|
41
|
-
toolkit: ToolsAPI.ToolkitDefinition;
|
|
42
|
-
|
|
43
|
-
description?: string;
|
|
44
|
-
|
|
45
|
-
output?: ToolsAPI.Output;
|
|
46
|
-
|
|
47
|
-
requirements?: ToolsAPI.Requirements;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
export class ToolDefinitionsOffsetPage extends OffsetPage<ToolDefinition> {}
|
|
@@ -7,8 +7,8 @@ import { OffsetPage, type OffsetPageParams } from '../../pagination';
|
|
|
7
7
|
|
|
8
8
|
export class Formatted extends APIResource {
|
|
9
9
|
/**
|
|
10
|
-
* Returns a page of tools
|
|
11
|
-
* specific provider
|
|
10
|
+
* Returns a page of tools from the engine configuration, optionally filtered by
|
|
11
|
+
* toolkit, formatted for a specific provider
|
|
12
12
|
*/
|
|
13
13
|
list(
|
|
14
14
|
query?: FormattedListParams,
|
|
@@ -24,7 +24,7 @@ export class Formatted extends APIResource {
|
|
|
24
24
|
if (isRequestOptions(query)) {
|
|
25
25
|
return this.list({}, query);
|
|
26
26
|
}
|
|
27
|
-
return this._client.getAPIList('/v1/
|
|
27
|
+
return this._client.getAPIList('/v1/formatted_tools', FormattedListResponsesOffsetPage, {
|
|
28
28
|
query,
|
|
29
29
|
...options,
|
|
30
30
|
});
|
|
@@ -33,8 +33,17 @@ export class Formatted extends APIResource {
|
|
|
33
33
|
/**
|
|
34
34
|
* Returns the formatted tool specification for a specific tool, given a provider
|
|
35
35
|
*/
|
|
36
|
-
get(
|
|
37
|
-
|
|
36
|
+
get(name: string, query?: FormattedGetParams, options?: Core.RequestOptions): Core.APIPromise<unknown>;
|
|
37
|
+
get(name: string, options?: Core.RequestOptions): Core.APIPromise<unknown>;
|
|
38
|
+
get(
|
|
39
|
+
name: string,
|
|
40
|
+
query: FormattedGetParams | Core.RequestOptions = {},
|
|
41
|
+
options?: Core.RequestOptions,
|
|
42
|
+
): Core.APIPromise<unknown> {
|
|
43
|
+
if (isRequestOptions(query)) {
|
|
44
|
+
return this.get(name, {}, query);
|
|
45
|
+
}
|
|
46
|
+
return this._client.get(`/v1/formatted_tools/${name}`, { query, ...options });
|
|
38
47
|
}
|
|
39
48
|
}
|
|
40
49
|
|
|
@@ -57,11 +66,6 @@ export interface FormattedListParams extends OffsetPageParams {
|
|
|
57
66
|
}
|
|
58
67
|
|
|
59
68
|
export interface FormattedGetParams {
|
|
60
|
-
/**
|
|
61
|
-
* Tool ID
|
|
62
|
-
*/
|
|
63
|
-
toolId: string;
|
|
64
|
-
|
|
65
69
|
/**
|
|
66
70
|
* Provider format
|
|
67
71
|
*/
|
|
@@ -8,20 +8,20 @@ export {
|
|
|
8
8
|
type FormattedListParams,
|
|
9
9
|
type FormattedGetParams,
|
|
10
10
|
} from './formatted';
|
|
11
|
+
export { Scheduled, type ScheduledGetResponse, type ScheduledListParams } from './scheduled';
|
|
11
12
|
export {
|
|
13
|
+
ToolExecutionsOffsetPage,
|
|
14
|
+
ToolListResponsesOffsetPage,
|
|
12
15
|
Tools,
|
|
13
16
|
type AuthorizeToolRequest,
|
|
14
17
|
type ExecuteToolRequest,
|
|
15
|
-
type
|
|
16
|
-
type
|
|
17
|
-
type
|
|
18
|
-
type Requirements,
|
|
19
|
-
type Response,
|
|
20
|
-
type ResponseOutput,
|
|
21
|
-
type ToolkitDefinition,
|
|
18
|
+
type ExecuteToolResponse,
|
|
19
|
+
type ToolExecution,
|
|
20
|
+
type ToolExecutionAttempt,
|
|
22
21
|
type ValueSchema,
|
|
22
|
+
type ToolListResponse,
|
|
23
|
+
type ToolGetResponse,
|
|
23
24
|
type ToolListParams,
|
|
24
25
|
type ToolAuthorizeParams,
|
|
25
26
|
type ToolExecuteParams,
|
|
26
|
-
type ToolGetParams,
|
|
27
27
|
} from './tools';
|