@smarter.sh/api 1.0.3 → 1.1.0-alpha.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/dist/client.d.ts +7 -2
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +8 -2
- package/dist/client.js.map +1 -1
- package/dist/core/errors.d.ts +11 -0
- package/dist/core/errors.d.ts.map +1 -1
- package/dist/core/errors.js +11 -0
- package/dist/core/errors.js.map +1 -1
- package/dist/core/http.d.ts +6 -1
- package/dist/core/http.d.ts.map +1 -1
- package/dist/core/http.js +4 -2
- package/dist/core/http.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -3
- package/dist/index.js.map +1 -1
- package/dist/models/account.d.ts +69 -1
- package/dist/models/account.d.ts.map +1 -1
- package/dist/models/account.js +69 -1
- package/dist/models/account.js.map +1 -1
- package/dist/models/extension.d.ts +408 -0
- package/dist/models/extension.d.ts.map +1 -0
- package/dist/models/extension.js +196 -0
- package/dist/models/extension.js.map +1 -0
- package/dist/models/misc.d.ts +12 -0
- package/dist/models/misc.d.ts.map +1 -1
- package/dist/models/misc.js +9 -0
- package/dist/models/misc.js.map +1 -1
- package/dist/models/sam/schemas.js +1 -1
- package/dist/models/sam/schemas.js.map +1 -1
- package/dist/models/sam/sqlconnection.d.ts +1 -1
- package/dist/resources/accounts.d.ts +74 -4
- package/dist/resources/accounts.d.ts.map +1 -1
- package/dist/resources/accounts.js +82 -4
- package/dist/resources/accounts.js.map +1 -1
- package/dist/resources/base.d.ts +11 -0
- package/dist/resources/base.d.ts.map +1 -1
- package/dist/resources/base.js +19 -0
- package/dist/resources/base.js.map +1 -1
- package/dist/resources/catalog.d.ts +30 -5
- package/dist/resources/catalog.d.ts.map +1 -1
- package/dist/resources/catalog.js +34 -3
- package/dist/resources/catalog.js.map +1 -1
- package/dist/resources/extensions.d.ts +173 -0
- package/dist/resources/extensions.d.ts.map +1 -0
- package/dist/resources/extensions.js +196 -0
- package/dist/resources/extensions.js.map +1 -0
- package/dist/resources/vectorstores.d.ts +1 -3
- package/dist/resources/vectorstores.d.ts.map +1 -1
- package/dist/resources/vectorstores.js +3 -13
- package/dist/resources/vectorstores.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,13 +1,24 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Accounts, their users, and their contacts: `/api/v1/accounts
|
|
2
|
+
* Accounts, their users, and their contacts: `/api/v1/accounts/`, and every user's own token usage and data exports.
|
|
3
3
|
*
|
|
4
|
-
* Only superusers may read
|
|
5
|
-
* created and changed with manifests (the `User` and `Account` kinds): see
|
|
4
|
+
* Only superusers may read accounts, users and contacts: the platform refuses other users with a 403.
|
|
5
|
+
* Users and accounts are created and changed with manifests (the `User` and `Account` kinds): see
|
|
6
|
+
* {@link Manifests}. Every user may read their own token usage ({@link Accounts.usage}) and export their
|
|
7
|
+
* own data ({@link DataExports}).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const usage = await client.accounts.usage({ periodicity: "7_days" });
|
|
12
|
+
* for (const point of usage.points) console.log(point.period_start, point.total_tokens, point.total_cost);
|
|
13
|
+
*
|
|
14
|
+
* const overview = await client.accounts.dataExports.overview();
|
|
15
|
+
* if (overview.exportsLeftToday > 0) await client.accounts.dataExports.start();
|
|
16
|
+
* ```
|
|
6
17
|
*/
|
|
7
18
|
import { z } from "zod";
|
|
8
19
|
import type { RequestOptions } from "../core/http.ts";
|
|
9
20
|
import type { SmarterId } from "../core/typing.ts";
|
|
10
|
-
import { Account, AccountContact, User, UserProfile } from "../models/account.ts";
|
|
21
|
+
import { Account, AccountContact, DataExport, DataExportOverview, TokenUsageSeries, User, UserProfile } from "../models/account.ts";
|
|
11
22
|
import { SmarterAPIResource, SmarterKindResource, type ResourceClient } from "./base.ts";
|
|
12
23
|
import type { Manifests } from "./manifests.ts";
|
|
13
24
|
/** A read-only REST list, and its rows by id. */
|
|
@@ -50,6 +61,49 @@ export declare class AccountContacts extends ReadOnlyResource<typeof AccountCont
|
|
|
50
61
|
/** @param client - The client. */
|
|
51
62
|
constructor(client: ResourceClient);
|
|
52
63
|
}
|
|
64
|
+
/** The window of a token usage series, e.g. `24_hours`: the current hour and the 23 before it. */
|
|
65
|
+
export type TokenUsagePeriodicity = "12_hours" | "24_hours" | "7_days" | "1_month" | "1_year";
|
|
66
|
+
/**
|
|
67
|
+
* The api key's user's data exports: `/api/v1/accounts/data-exports/`.
|
|
68
|
+
*
|
|
69
|
+
* An export is a zip file of the manifest of every resource that the user owns, in every account they
|
|
70
|
+
* belong to, with Secrets' values redacted. The platform builds it in the background, stores it, and
|
|
71
|
+
* emails the user a link to it when it is ready: the api never returns the link or the file. A user
|
|
72
|
+
* may start a few exports a day, and only one at a time.
|
|
73
|
+
*/
|
|
74
|
+
export declare class DataExports extends SmarterAPIResource {
|
|
75
|
+
/** The data exports' endpoint. */
|
|
76
|
+
readonly path = "accounts/data-exports/";
|
|
77
|
+
/**
|
|
78
|
+
* What the user may export: the address that the link is emailed to, how long the link works, how
|
|
79
|
+
* many exports are left today, and the latest export.
|
|
80
|
+
*
|
|
81
|
+
* @param options - Per-request options.
|
|
82
|
+
* @returns The overview.
|
|
83
|
+
*/
|
|
84
|
+
overview(options?: RequestOptions): Promise<DataExportOverview>;
|
|
85
|
+
/**
|
|
86
|
+
* Start a data export. A link to the zip file is emailed to the user when it is ready.
|
|
87
|
+
*
|
|
88
|
+
* If an export is already in progress, the platform returns that one instead of starting another.
|
|
89
|
+
* A refusal (429) is not retried: it means that the user has no email address, or has started too
|
|
90
|
+
* many exports today, which a retry won't change.
|
|
91
|
+
*
|
|
92
|
+
* @param options - Per-request options.
|
|
93
|
+
* @returns The new export, queued, or the one in progress.
|
|
94
|
+
* @throws {@link RateLimitError} If the user has no email address, or has started too many exports today.
|
|
95
|
+
*/
|
|
96
|
+
start(options?: RequestOptions): Promise<DataExport>;
|
|
97
|
+
/**
|
|
98
|
+
* A data export's progress.
|
|
99
|
+
*
|
|
100
|
+
* @param exportId - The export's id.
|
|
101
|
+
* @param options - Per-request options.
|
|
102
|
+
* @returns The export.
|
|
103
|
+
* @throws {@link NotFoundError} If the user has no export of that id.
|
|
104
|
+
*/
|
|
105
|
+
retrieve(exportId: number, options?: RequestOptions): Promise<DataExport>;
|
|
106
|
+
}
|
|
53
107
|
/** Accounts: `/api/v1/accounts/`, and the manifest api's `Account` kind. */
|
|
54
108
|
export declare class Accounts extends SmarterKindResource<typeof Account> {
|
|
55
109
|
readonly kind = "Account";
|
|
@@ -98,10 +152,26 @@ export declare class Accounts extends SmarterKindResource<typeof Account> {
|
|
|
98
152
|
readonly contacts: AccountContacts;
|
|
99
153
|
/** The users' memberships of accounts. */
|
|
100
154
|
readonly userProfiles: UserProfiles;
|
|
155
|
+
/** The api key's user's data exports. */
|
|
156
|
+
readonly dataExports: DataExports;
|
|
101
157
|
/** @param client - The client. */
|
|
102
158
|
constructor(client: ResourceClient & {
|
|
103
159
|
readonly manifests: Manifests;
|
|
104
160
|
});
|
|
161
|
+
/**
|
|
162
|
+
* The tokens and cost of the api key's user's LLM requests over a window of time, one point per hour,
|
|
163
|
+
* day or month, oldest first, counting the current hour's charges. Every user may read their own.
|
|
164
|
+
*
|
|
165
|
+
* The platform caches the series for five minutes. The points' fields are snake_case, as the platform
|
|
166
|
+
* sends them, e.g. `total_tokens`.
|
|
167
|
+
*
|
|
168
|
+
* @param options - `periodicity`: the window, `24_hours` (the current hour and the 23 before it) by default.
|
|
169
|
+
* @returns The series.
|
|
170
|
+
* @throws {@link BadRequestError} If the periodicity is unknown.
|
|
171
|
+
*/
|
|
172
|
+
usage(options?: RequestOptions & {
|
|
173
|
+
periodicity?: TokenUsagePeriodicity;
|
|
174
|
+
}): Promise<TokenUsageSeries>;
|
|
105
175
|
}
|
|
106
176
|
export {};
|
|
107
177
|
//# sourceMappingURL=accounts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/resources/accounts.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"accounts.d.ts","sourceRoot":"","sources":["../../src/resources/accounts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,OAAO,EACP,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,IAAI,EACJ,WAAW,EACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAc,kBAAkB,EAAE,mBAAmB,EAAE,KAAK,cAAc,EAAE,MAAM,WAAW,CAAC;AACrG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,iDAAiD;AACjD,cAAM,gBAAgB,CAAC,CAAC,SAAS,CAAC,CAAC,OAAO,CAAE,SAAQ,kBAAkB;;IAIpE;;;;OAIG;gBACS,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC;IAM1D;;;;;OAKG;IACG,IAAI,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC;IAI5D;;;;;;OAMG;IACG,QAAQ,CAAC,EAAE,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;CAG9E;AAED,qEAAqE;AACrE,qBAAa,KAAM,SAAQ,gBAAgB,CAAC,OAAO,IAAI,CAA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AAQ,CAAC,WAAW,EAAE,WAAW,CAAC;IAElC,kCAAkC;gBACtB,MAAM,EAAE,cAAc,GAAG;QAAE,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAA;KAAE;IAQtE;;;;;;;;;;OAUG;IACG,KAAK,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG;QAAE,WAAW,CAAC,EAAE,qBAAqB,CAAA;KAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC;CAM3G"}
|
|
@@ -1,11 +1,22 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Accounts, their users, and their contacts: `/api/v1/accounts
|
|
2
|
+
* Accounts, their users, and their contacts: `/api/v1/accounts/`, and every user's own token usage and data exports.
|
|
3
3
|
*
|
|
4
|
-
* Only superusers may read
|
|
5
|
-
* created and changed with manifests (the `User` and `Account` kinds): see
|
|
4
|
+
* Only superusers may read accounts, users and contacts: the platform refuses other users with a 403.
|
|
5
|
+
* Users and accounts are created and changed with manifests (the `User` and `Account` kinds): see
|
|
6
|
+
* {@link Manifests}. Every user may read their own token usage ({@link Accounts.usage}) and export their
|
|
7
|
+
* own data ({@link DataExports}).
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const usage = await client.accounts.usage({ periodicity: "7_days" });
|
|
12
|
+
* for (const point of usage.points) console.log(point.period_start, point.total_tokens, point.total_cost);
|
|
13
|
+
*
|
|
14
|
+
* const overview = await client.accounts.dataExports.overview();
|
|
15
|
+
* if (overview.exportsLeftToday > 0) await client.accounts.dataExports.start();
|
|
16
|
+
* ```
|
|
6
17
|
*/
|
|
7
18
|
import { z } from "zod";
|
|
8
|
-
import { Account, AccountContact, User, UserProfile } from "../models/account.js";
|
|
19
|
+
import { Account, AccountContact, DataExport, DataExportOverview, TokenUsageSeries, User, UserProfile, } from "../models/account.js";
|
|
9
20
|
import { resourceId, SmarterAPIResource, SmarterKindResource } from "./base.js";
|
|
10
21
|
/** A read-only REST list, and its rows by id. */
|
|
11
22
|
class ReadOnlyResource extends SmarterAPIResource {
|
|
@@ -62,6 +73,53 @@ export class AccountContacts extends ReadOnlyResource {
|
|
|
62
73
|
super(client, "accounts/contacts/", AccountContact);
|
|
63
74
|
}
|
|
64
75
|
}
|
|
76
|
+
/**
|
|
77
|
+
* The api key's user's data exports: `/api/v1/accounts/data-exports/`.
|
|
78
|
+
*
|
|
79
|
+
* An export is a zip file of the manifest of every resource that the user owns, in every account they
|
|
80
|
+
* belong to, with Secrets' values redacted. The platform builds it in the background, stores it, and
|
|
81
|
+
* emails the user a link to it when it is ready: the api never returns the link or the file. A user
|
|
82
|
+
* may start a few exports a day, and only one at a time.
|
|
83
|
+
*/
|
|
84
|
+
export class DataExports extends SmarterAPIResource {
|
|
85
|
+
/** The data exports' endpoint. */
|
|
86
|
+
path = "accounts/data-exports/";
|
|
87
|
+
/**
|
|
88
|
+
* What the user may export: the address that the link is emailed to, how long the link works, how
|
|
89
|
+
* many exports are left today, and the latest export.
|
|
90
|
+
*
|
|
91
|
+
* @param options - Per-request options.
|
|
92
|
+
* @returns The overview.
|
|
93
|
+
*/
|
|
94
|
+
async overview(options) {
|
|
95
|
+
return this.http.request("GET", this.path, DataExportOverview, options);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Start a data export. A link to the zip file is emailed to the user when it is ready.
|
|
99
|
+
*
|
|
100
|
+
* If an export is already in progress, the platform returns that one instead of starting another.
|
|
101
|
+
* A refusal (429) is not retried: it means that the user has no email address, or has started too
|
|
102
|
+
* many exports today, which a retry won't change.
|
|
103
|
+
*
|
|
104
|
+
* @param options - Per-request options.
|
|
105
|
+
* @returns The new export, queued, or the one in progress.
|
|
106
|
+
* @throws {@link RateLimitError} If the user has no email address, or has started too many exports today.
|
|
107
|
+
*/
|
|
108
|
+
async start(options) {
|
|
109
|
+
return this.http.request("POST", this.path, DataExport, { ...options, retryRateLimited: false });
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* A data export's progress.
|
|
113
|
+
*
|
|
114
|
+
* @param exportId - The export's id.
|
|
115
|
+
* @param options - Per-request options.
|
|
116
|
+
* @returns The export.
|
|
117
|
+
* @throws {@link NotFoundError} If the user has no export of that id.
|
|
118
|
+
*/
|
|
119
|
+
async retrieve(exportId, options) {
|
|
120
|
+
return this.http.request("GET", `${this.path}${resourceId(exportId)}/`, DataExport, options);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
65
123
|
/** Accounts: `/api/v1/accounts/`, and the manifest api's `Account` kind. */
|
|
66
124
|
export class Accounts extends SmarterKindResource {
|
|
67
125
|
kind = "Account";
|
|
@@ -73,12 +131,32 @@ export class Accounts extends SmarterKindResource {
|
|
|
73
131
|
contacts;
|
|
74
132
|
/** The users' memberships of accounts. */
|
|
75
133
|
userProfiles;
|
|
134
|
+
/** The api key's user's data exports. */
|
|
135
|
+
dataExports;
|
|
76
136
|
/** @param client - The client. */
|
|
77
137
|
constructor(client) {
|
|
78
138
|
super(client);
|
|
79
139
|
this.users = new Users(client);
|
|
80
140
|
this.contacts = new AccountContacts(client);
|
|
81
141
|
this.userProfiles = new UserProfiles(client);
|
|
142
|
+
this.dataExports = new DataExports(client);
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* The tokens and cost of the api key's user's LLM requests over a window of time, one point per hour,
|
|
146
|
+
* day or month, oldest first, counting the current hour's charges. Every user may read their own.
|
|
147
|
+
*
|
|
148
|
+
* The platform caches the series for five minutes. The points' fields are snake_case, as the platform
|
|
149
|
+
* sends them, e.g. `total_tokens`.
|
|
150
|
+
*
|
|
151
|
+
* @param options - `periodicity`: the window, `24_hours` (the current hour and the 23 before it) by default.
|
|
152
|
+
* @returns The series.
|
|
153
|
+
* @throws {@link BadRequestError} If the periodicity is unknown.
|
|
154
|
+
*/
|
|
155
|
+
async usage(options) {
|
|
156
|
+
return this.http.request("GET", `${this.path}usage/`, TokenUsageSeries, {
|
|
157
|
+
...options,
|
|
158
|
+
params: { periodicity: options?.periodicity ?? "24_hours" },
|
|
159
|
+
});
|
|
82
160
|
}
|
|
83
161
|
}
|
|
84
162
|
//# sourceMappingURL=accounts.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/resources/accounts.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../src/resources/accounts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,EACL,OAAO,EACP,cAAc,EACd,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,IAAI,EACJ,WAAW,GACZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,UAAU,EAAE,kBAAkB,EAAE,mBAAmB,EAAuB,MAAM,WAAW,CAAC;AAGrG,iDAAiD;AACjD,MAAM,gBAAsC,SAAQ,kBAAkB;IAC3D,KAAK,CAAS;IACd,MAAM,CAAI;IAEnB;;;;OAIG;IACH,YAAY,MAAsB,EAAE,IAAY,EAAE,KAAQ;QACxD,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;QAClB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,IAAI,CAAC,OAAwB;QACjC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,OAAO,CAAC,CAAC;IAC7E,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,QAAQ,CAAC,EAAa,EAAE,OAAwB;QACpD,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,GAAG,UAAU,CAAC,EAAE,CAAC,GAAG,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AC,IAAI,GAAG,UAAU,CAAC,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,CAAC,CAAC;IAC/F,CAAC;CACF;AAED,4EAA4E;AAC5E,MAAM,OAAO,QAAS,SAAQ,mBAAmC;IACtD,IAAI,GAAG,SAAS,CAAC;IACjB,IAAI,GAAG,WAAW,CAAC;IACnB,KAAK,GAAG,OAAO,CAAC;IACzB,2BAA2B;IAClB,KAAK,CAAQ;IACtB,8BAA8B;IACrB,QAAQ,CAAkB;IACnC,0CAA0C;IACjC,YAAY,CAAe;IACpC,yCAAyC;IAChC,WAAW,CAAc;IAElC,kCAAkC;IAClC,YAAY,MAA0D;QACpE,KAAK,CAAC,MAAM,CAAC,CAAC;QACd,IAAI,CAAC,KAAK,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;QAC/B,IAAI,CAAC,QAAQ,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;QAC5C,IAAI,CAAC,YAAY,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,IAAI,WAAW,CAAC,MAAM,CAAC,CAAC;IAC7C,CAAC;IAED;;;;;;;;;;OAUG;IACH,KAAK,CAAC,KAAK,CAAC,OAAkE;QAC5E,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,IAAI,CAAC,IAAI,QAAQ,EAAE,gBAAgB,EAAE;YACtE,GAAG,OAAO;YACV,MAAM,EAAE,EAAE,WAAW,EAAE,OAAO,EAAE,WAAW,IAAI,UAAU,EAAE;SAC5D,CAAC,CAAC;IACL,CAAC;CACF"}
|
package/dist/resources/base.d.ts
CHANGED
|
@@ -28,6 +28,17 @@ export interface ResourceClient {
|
|
|
28
28
|
* @throws {@link SmarterValueError} If the id is empty, or contains a slash.
|
|
29
29
|
*/
|
|
30
30
|
export declare function resourceId(value: SmarterId): string;
|
|
31
|
+
/** A file to upload: its path, its `file:` url, or a `File`. */
|
|
32
|
+
export type UploadInput = string | URL | File;
|
|
33
|
+
/**
|
|
34
|
+
* Add a file to a multipart form, under its own name.
|
|
35
|
+
*
|
|
36
|
+
* @param form - The form.
|
|
37
|
+
* @param field - The form's field, e.g. `files`.
|
|
38
|
+
* @param file - The file: a path, a `file:` url, or a `File`. A path is read lazily, when the form is sent.
|
|
39
|
+
* @returns Nothing: the file is appended to the form.
|
|
40
|
+
*/
|
|
41
|
+
export declare function appendUpload(form: FormData, field: string, file: UploadInput): Promise<void>;
|
|
31
42
|
/** A group of api operations. */
|
|
32
43
|
export declare class SmarterAPIResource {
|
|
33
44
|
protected readonly client: ResourceClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/resources/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/resources/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAMH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,KAAK,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAc,KAAK,QAAQ,EAAE,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtF,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAEhD,gFAAgF;AAChF,MAAM,WAAW,cAAc;IAC7B,0BAA0B;IAC1B,QAAQ,CAAC,IAAI,EAAE,iBAAiB,CAAC;IACjC,wBAAwB;IACxB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;CAC/B;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,SAA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C,MAAM,CAAC,CAAC,CAAC,CAAC;IAOxE;;;;;;;OAOG;IACG,KAAK,CAAC,QAAQ,EAAE,aAAa,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAQ9F;;;;;;OAMG;IACG,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIzE;;;;;;OAMG;IACG,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAIpF;;;;;OAKG;IACG,eAAe,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIlE;;;;;OAKG;IACG,UAAU,CAAC,OAAO,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,UAAU,CAAC;CAGhE"}
|
package/dist/resources/base.js
CHANGED
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
* REST endpoints are used to read resources, and for actions that the manifest api has no verb for,
|
|
8
8
|
* such as evaluating a Guardrail or calling an MCP tool (ADR-003).
|
|
9
9
|
*/
|
|
10
|
+
import { openAsBlob } from "node:fs";
|
|
11
|
+
import { basename } from "node:path";
|
|
12
|
+
import { fileURLToPath } from "node:url";
|
|
10
13
|
import { z } from "zod";
|
|
11
14
|
import { ResourceNotFoundError, SmarterValueError } from "../core/errors.js";
|
|
12
15
|
import { toManifest } from "../models/manifest.js";
|
|
@@ -23,6 +26,22 @@ export function resourceId(value) {
|
|
|
23
26
|
throw new SmarterValueError(`Invalid resource id: ${JSON.stringify(value)}`);
|
|
24
27
|
return encodeURIComponent(text);
|
|
25
28
|
}
|
|
29
|
+
/**
|
|
30
|
+
* Add a file to a multipart form, under its own name.
|
|
31
|
+
*
|
|
32
|
+
* @param form - The form.
|
|
33
|
+
* @param field - The form's field, e.g. `files`.
|
|
34
|
+
* @param file - The file: a path, a `file:` url, or a `File`. A path is read lazily, when the form is sent.
|
|
35
|
+
* @returns Nothing: the file is appended to the form.
|
|
36
|
+
*/
|
|
37
|
+
export async function appendUpload(form, field, file) {
|
|
38
|
+
if (file instanceof File) {
|
|
39
|
+
form.append(field, file, file.name);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const path = file instanceof URL ? fileURLToPath(file) : file;
|
|
43
|
+
form.append(field, await openAsBlob(path), basename(path));
|
|
44
|
+
}
|
|
26
45
|
/** A group of api operations. */
|
|
27
46
|
export class SmarterAPIResource {
|
|
28
47
|
client;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/resources/base.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI7E,OAAO,EAAE,UAAU,EAAqC,MAAM,uBAAuB,CAAC;AAWtF;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,KAAgB;IACzC,MAAM,IAAI,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC;IAClC,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,iBAAiB,CAAC,wBAAwB,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC9G,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;AAClC,CAAC;AAED,iCAAiC;AACjC,MAAM,OAAO,kBAAkB;IACV,MAAM,CAAiB;IAE1C;;OAEG;IACH,YAAY,MAAsB;QAChC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAED,mCAAmC;IACnC,IAAc,IAAI;QAChB,OAAO,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;IAC1B,CAAC;CACF;AAO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CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAClE,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,MAAM,CAAC,IAAY,EAAE,OAAwB;QACjD,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAChE,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,eAAe,CAAC,OAAwB;QAC5C,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,eAAe,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IACnE,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,UAAU,CAAC,OAAwB;QACvC,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAC9D,CAAC;CACF"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/** Secrets, plugins, orchestrators and vectorsearches: the kinds whose REST api
|
|
1
|
+
/** Secrets, plugins, orchestrators and vectorsearches: the kinds whose REST api lists and reads them, and runs a Vectorsearch. */
|
|
2
2
|
import type { RequestOptions } from "../core/http.ts";
|
|
3
|
-
import type { SmarterId } from "../core/typing.ts";
|
|
3
|
+
import type { JsonValue, SmarterId } from "../core/typing.ts";
|
|
4
4
|
import type { SmarterJournalMessage } from "../models/journal.ts";
|
|
5
5
|
import { Manifest, type ManifestInput } from "../models/manifest.ts";
|
|
6
|
-
import { Orchestrator, Secret, Vectorsearch } from "../models/misc.ts";
|
|
6
|
+
import { Orchestrator, Secret, Vectorsearch, VectorsearchResults } from "../models/misc.ts";
|
|
7
7
|
import { Plugin } from "../models/plugin.ts";
|
|
8
8
|
import { SmarterKindResource } from "./base.ts";
|
|
9
9
|
/** The manifest kinds of plugins. */
|
|
@@ -168,7 +168,15 @@ export declare class Orchestrators extends SmarterKindResource<typeof Orchestrat
|
|
|
168
168
|
llmclients: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodNumber>>;
|
|
169
169
|
}, import("zod/v4/core").$loose>;
|
|
170
170
|
}
|
|
171
|
-
/**
|
|
171
|
+
/**
|
|
172
|
+
* Vectorsearches: `/api/v1/vectorsearches/`, and the manifest api's `Vectorsearch` kind.
|
|
173
|
+
*
|
|
174
|
+
* @example
|
|
175
|
+
* ```ts
|
|
176
|
+
* const found = await client.vectorsearches.run(12, "How long is the refund window?");
|
|
177
|
+
* for (const result of found.results) console.log(result.score, result.text);
|
|
178
|
+
* ```
|
|
179
|
+
*/
|
|
172
180
|
export declare class Vectorsearches extends SmarterKindResource<typeof Vectorsearch> {
|
|
173
181
|
readonly kind = "Vectorsearch";
|
|
174
182
|
readonly path = "vectorsearches/";
|
|
@@ -200,10 +208,27 @@ export declare class Vectorsearches extends SmarterKindResource<typeof Vectorsea
|
|
|
200
208
|
scoreThreshold: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
|
|
201
209
|
fetchK: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
|
|
202
210
|
lambdaMult: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
|
|
203
|
-
metadataFilter: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodType<
|
|
211
|
+
metadataFilter: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodType<JsonValue, unknown, import("zod/v4/core").$ZodTypeInternals<JsonValue, unknown>>>>;
|
|
204
212
|
isEnabled: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodBoolean>>;
|
|
205
213
|
vectorstore: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
|
|
206
214
|
authSecret: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodNumber>>;
|
|
207
215
|
}, import("zod/v4/core").$loose>;
|
|
216
|
+
/**
|
|
217
|
+
* Run a Vectorsearch: search its vectorstore with a query, and the Vectorsearch's own configuration,
|
|
218
|
+
* its search type, `k`, score threshold, mmr settings and metadata filter.
|
|
219
|
+
*
|
|
220
|
+
* The query is embedded by the vectorstore's embeddings provider, which may be billable.
|
|
221
|
+
*
|
|
222
|
+
* @param id - The Vectorsearch's id or hashed id.
|
|
223
|
+
* @param query - The text to find similar chunks of.
|
|
224
|
+
* @param options - `filter`: more metadata that every result must match, besides the Vectorsearch's own
|
|
225
|
+
* `metadataFilter`, which wins where both name the same key.
|
|
226
|
+
* @returns The matching chunks, best first, and the names of the Vectorsearch and its vectorstore.
|
|
227
|
+
* @throws {@link BadRequestError} If the Vectorsearch is disabled, the query is invalid, or the search failed.
|
|
228
|
+
* @throws {@link PaymentRequiredError} If a budget forbids the search.
|
|
229
|
+
*/
|
|
230
|
+
run(id: SmarterId, query: string, options?: RequestOptions & {
|
|
231
|
+
filter?: Record<string, JsonValue> | null;
|
|
232
|
+
}): Promise<VectorsearchResults>;
|
|
208
233
|
}
|
|
209
234
|
//# sourceMappingURL=catalog.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/resources/catalog.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../src/resources/catalog.ts"],"names":[],"mappings":"AAAA,kIAAkI;AAGlI,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAA4B,KAAK,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,MA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Ac,GAAG,OAAO,CAAC,QAAQ,CAAC;CAGnF;AAED,2FAA2F;AAC3F,qBAAa,aAAc,SAAQ,mBAAmB,CAAC,OAAO,YAAY,CAAC;IACzE,QAAQ,CAAC,IAAI,kBAAkB;IAC/B,QAAQ,CAAC,IAAI,oBAAoB;IACjC,QAAQ,CAAC,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAAgB;CAC/B;AAED;;;;;;;;GAQG;AACH,qBAAa,cAAe,SAAQ,mBAAmB,CAAC,OAAO,YAAY,CAAC;IAC1E,QAAQ,CAAC,IAAI,kBAAkB;IAC/B,QAAQ,CAAC,IAAI,qBAAqB;IAClC,QAAQ,CAAC,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAAgB;IAE9B;;;;;;;;;;;;;OAaG;IACG,GAAG,CACP,EAAE,EAAE,SAAS,EACb,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,cAAc,GAAG;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,IAAI,CAAA;KAAE,GACvE,OAAO,CAAC,mBAAmB,CAAC;CAQhC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** Secrets, plugins, orchestrators and vectorsearches: the kinds whose REST api
|
|
1
|
+
/** Secrets, plugins, orchestrators and vectorsearches: the kinds whose REST api lists and reads them, and runs a Vectorsearch. */
|
|
2
2
|
import { ResourceNotFoundError, SmarterValueError } from "../core/errors.js";
|
|
3
3
|
import { Manifest, ManifestData, toManifest } from "../models/manifest.js";
|
|
4
|
-
import { Orchestrator, Secret, Vectorsearch } from "../models/misc.js";
|
|
4
|
+
import { Orchestrator, Secret, Vectorsearch, VectorsearchResults } from "../models/misc.js";
|
|
5
5
|
import { Plugin } from "../models/plugin.js";
|
|
6
6
|
import { resourceId, SmarterKindResource } from "./base.js";
|
|
7
7
|
/** The manifest kinds of plugins. */
|
|
@@ -115,10 +115,41 @@ export class Orchestrators extends SmarterKindResource {
|
|
|
115
115
|
path = "orchestrators/";
|
|
116
116
|
model = Orchestrator;
|
|
117
117
|
}
|
|
118
|
-
/**
|
|
118
|
+
/**
|
|
119
|
+
* Vectorsearches: `/api/v1/vectorsearches/`, and the manifest api's `Vectorsearch` kind.
|
|
120
|
+
*
|
|
121
|
+
* @example
|
|
122
|
+
* ```ts
|
|
123
|
+
* const found = await client.vectorsearches.run(12, "How long is the refund window?");
|
|
124
|
+
* for (const result of found.results) console.log(result.score, result.text);
|
|
125
|
+
* ```
|
|
126
|
+
*/
|
|
119
127
|
export class Vectorsearches extends SmarterKindResource {
|
|
120
128
|
kind = "Vectorsearch";
|
|
121
129
|
path = "vectorsearches/";
|
|
122
130
|
model = Vectorsearch;
|
|
131
|
+
/**
|
|
132
|
+
* Run a Vectorsearch: search its vectorstore with a query, and the Vectorsearch's own configuration,
|
|
133
|
+
* its search type, `k`, score threshold, mmr settings and metadata filter.
|
|
134
|
+
*
|
|
135
|
+
* The query is embedded by the vectorstore's embeddings provider, which may be billable.
|
|
136
|
+
*
|
|
137
|
+
* @param id - The Vectorsearch's id or hashed id.
|
|
138
|
+
* @param query - The text to find similar chunks of.
|
|
139
|
+
* @param options - `filter`: more metadata that every result must match, besides the Vectorsearch's own
|
|
140
|
+
* `metadataFilter`, which wins where both name the same key.
|
|
141
|
+
* @returns The matching chunks, best first, and the names of the Vectorsearch and its vectorstore.
|
|
142
|
+
* @throws {@link BadRequestError} If the Vectorsearch is disabled, the query is invalid, or the search failed.
|
|
143
|
+
* @throws {@link PaymentRequiredError} If a budget forbids the search.
|
|
144
|
+
*/
|
|
145
|
+
async run(id, query, options) {
|
|
146
|
+
const body = { query };
|
|
147
|
+
if (options?.filter && Object.keys(options.filter).length > 0)
|
|
148
|
+
body["filter"] = options.filter;
|
|
149
|
+
return this.http.request("POST", `${this.path}${resourceId(id)}/vectorsearch/`, VectorsearchResults, {
|
|
150
|
+
...options,
|
|
151
|
+
json: body,
|
|
152
|
+
});
|
|
153
|
+
}
|
|
123
154
|
}
|
|
124
155
|
//# sourceMappingURL=catalog.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/resources/catalog.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/resources/catalog.ts"],"names":[],"mappings":"AAAA,kIAAkI;AAElI,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAI7E,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,UAAU,EAAsB,MAAM,uBAAuB,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAC5F,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAE5D,qCAAqC;AACrC,MAAM,CAAC,MAAM,YAAY,GAAsB;IAC7C,QAAQ;IACR,WAAW;IACX,aAAa;IACb,WAAW;IACX,iBAAiB;IACjB,mBAAmB;CACpB,CAAC;AAEF;;;;GAIG;AACH,MAAM,OAAO,OAAQ,SAAQ,mBAAkC;IACpD,IAAI,GAAG,QAAQ,CAAC;IAChB,IAAI,GAAG,UAAU,CAAC;IAClB,KAAK,GAAG,MAAM,CAAC;CACzB;AAED;;;;;GAKG;AACH,MAAM,OAAO,OAAQ,SAAQ,mBAAkC;IACpD,IAAI,GAAG,QAAQ,CAAC;IAChB,IAAI,GAAG,UAAU,CAAC;IAClB,KAAK,GAAG,MAAM,CAAC;IAExB;;;;;;;OAOG;IACM,KAAK,CAAC,KAAK,CAAC,QAAuB,EAAE,OAAwB;QACpE,MAAM,MAAM,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;QACpC,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,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