@astralbeam/sdk 0.15.2 → 0.16.0
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/README.md +15 -7
- package/dist/api-DzeMhfHU.js +653 -0
- package/dist/api.d.ts +2 -2
- package/dist/api.js +2 -2
- package/dist/client.d.ts +21 -7
- package/dist/client.js +1 -1
- package/dist/{core-BGDo_tQ4.js → core-D84VNYWJ.js} +947 -148
- package/dist/core.d.ts +2 -2
- package/dist/core.js +1 -1
- package/dist/index-CH3RVjha.d.ts +827 -0
- package/dist/{index-DUznpmNz.d.ts → index-CM3pzsKR.d.ts} +108 -29
- package/dist/listings-dAoOEUGK.js +1 -0
- package/dist/react.d.ts +14 -6
- package/dist/react.js +22 -7
- package/dist/rolldown-runtime-Bh1tDfsg.js +1 -0
- package/dist/styles.generated-Ucyw8D9G.js +98 -0
- package/dist/widget-h5LX5aq8.js +11 -0
- package/package.json +3 -3
- package/dist/api-DUe8JSVU.d.ts +0 -372
- package/dist/api-r11gRy91.js +0 -323
- package/dist/index-BVVgDSdq.d.ts +0 -1
- package/dist/listings-6eaCXB6G.js +0 -21
- package/dist/styles.generated-Bub4csY_.js +0 -60
- package/dist/widget-Bjm0sUjE.js +0 -26
package/dist/api-r11gRy91.js
DELETED
|
@@ -1,323 +0,0 @@
|
|
|
1
|
-
//#region src/lib/constants.ts
|
|
2
|
-
/** Base URL of the AstralBeam API when the mount options give none; versioned routes hang off it. */
|
|
3
|
-
const DEFAULT_API_URL = "https://astralbeam.ai/api";
|
|
4
|
-
/** Host endpoint that mints chat JWTs when the mount options give none. */
|
|
5
|
-
const DEFAULT_CHAT_AUTH_TOKEN_URL = "/api/astralbeam/token";
|
|
6
|
-
/** Color scheme used when the mount options and the React prop give none. */
|
|
7
|
-
const DEFAULT_COLOR_SCHEME = "system";
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/api/api.ts
|
|
10
|
-
function isAstralBeamApiError(error) {
|
|
11
|
-
return error instanceof Error && error.name === "AstralBeamApiError" && "status" in error && typeof error.status === "number";
|
|
12
|
-
}
|
|
13
|
-
function resolveApiUrl(path, apiUrl = DEFAULT_API_URL) {
|
|
14
|
-
return `${apiUrl.replace(/\/+$/, "")}${path.replace(/^\/api(?=\/)/, "")}`;
|
|
15
|
-
}
|
|
16
|
-
function isApiErrorBody(value, status) {
|
|
17
|
-
if (!value || typeof value !== "object") return false;
|
|
18
|
-
const body = value;
|
|
19
|
-
return body.status === status && typeof body.type === "string" && typeof body.title === "string" && typeof body.detail === "string" && (body.issues === void 0 || Array.isArray(body.issues) && body.issues.every((issue) => issue && typeof issue.path === "string" && typeof issue.message === "string"));
|
|
20
|
-
}
|
|
21
|
-
async function apiResponse(path, options) {
|
|
22
|
-
const { apiUrl, apiKey, astralBeamToken, fetchClient = globalThis.fetch, ...init } = options;
|
|
23
|
-
const headers = new Headers();
|
|
24
|
-
const entries = init.headers instanceof Headers ? init.headers.entries() : Array.isArray(init.headers) ? init.headers : Object.entries(init.headers ?? {});
|
|
25
|
-
for (const [name, value] of entries) headers.set(name, value);
|
|
26
|
-
headers.delete("authorization");
|
|
27
|
-
headers.delete("x-api-key");
|
|
28
|
-
if (apiKey) headers.set("x-api-key", apiKey);
|
|
29
|
-
if (astralBeamToken) headers.set("authorization", `Bearer ${astralBeamToken}`);
|
|
30
|
-
const response = await fetchClient(resolveApiUrl(path, apiUrl), {
|
|
31
|
-
...init,
|
|
32
|
-
headers,
|
|
33
|
-
...apiKey ? { redirect: "error" } : {}
|
|
34
|
-
});
|
|
35
|
-
if (response.ok) return response;
|
|
36
|
-
const value = await response.json().catch((error) => {
|
|
37
|
-
if (!(error instanceof SyntaxError)) throw error;
|
|
38
|
-
});
|
|
39
|
-
const body = isApiErrorBody(value, response.status) ? value : void 0;
|
|
40
|
-
throw Object.assign(new Error(body?.detail ?? `AstralBeam API returned HTTP ${response.status}`), {
|
|
41
|
-
name: "AstralBeamApiError",
|
|
42
|
-
status: response.status,
|
|
43
|
-
headers: response.headers,
|
|
44
|
-
body
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
async function astralBeamApiFetch(path, options) {
|
|
48
|
-
return await (await apiResponse(path, options)).json();
|
|
49
|
-
}
|
|
50
|
-
function astralBeamJwtFetch(path, options) {
|
|
51
|
-
return astralBeamApiFetch(path, options);
|
|
52
|
-
}
|
|
53
|
-
function astralBeamChatFetch(path, options) {
|
|
54
|
-
return apiResponse(path, options);
|
|
55
|
-
}
|
|
56
|
-
function astralBeamFileFetch(path, options = {}) {
|
|
57
|
-
return apiResponse(path, options);
|
|
58
|
-
}
|
|
59
|
-
//#endregion
|
|
60
|
-
//#region src/api/generated/api.ts
|
|
61
|
-
/**
|
|
62
|
-
* Generated by Orval. Do not edit by hand.
|
|
63
|
-
*/
|
|
64
|
-
const ListUsersForTenantFilterAdmin = {
|
|
65
|
-
true: "true",
|
|
66
|
-
false: "false"
|
|
67
|
-
};
|
|
68
|
-
const getListTenantsUrl = (params) => {
|
|
69
|
-
const normalizedParams = new URLSearchParams();
|
|
70
|
-
Object.entries(params || {}).forEach(([key, value]) => {
|
|
71
|
-
if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
|
|
72
|
-
});
|
|
73
|
-
const stringifiedParams = normalizedParams.toString();
|
|
74
|
-
return stringifiedParams.length > 0 ? `/api/v1/tenants?${stringifiedParams}` : `/api/v1/tenants`;
|
|
75
|
-
};
|
|
76
|
-
/**
|
|
77
|
-
* List Tenants in internal ID order. q searches name or external ID as a case-insensitive literal substring. filter[external_id] adds an exact match. Organization keys and organization-management JWTs see their organization; admin tenant JWTs see only their signed Tenant. Keep filters unchanged when reusing cursors. Live listing, not a snapshot.
|
|
78
|
-
* @summary List Tenants
|
|
79
|
-
*/
|
|
80
|
-
const listTenants = (params, options) => {
|
|
81
|
-
return astralBeamApiFetch(getListTenantsUrl(params), {
|
|
82
|
-
...options,
|
|
83
|
-
method: "GET"
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
const getCreateTenantUrl = () => {
|
|
87
|
-
return `/api/v1/tenants`;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* Create a Tenant with an exact customer-provided external_id. Requires an organization API key or organization-management JWT with a current owner/developer role. An external_id already used in this organization returns 409; creation never upserts.
|
|
91
|
-
* @summary Create a Tenant
|
|
92
|
-
*/
|
|
93
|
-
const createTenant = (createTenantInput, options) => {
|
|
94
|
-
const getHeaders = (h) => {
|
|
95
|
-
if (!h) return {};
|
|
96
|
-
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
97
|
-
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
98
|
-
const headers = {};
|
|
99
|
-
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
100
|
-
return headers;
|
|
101
|
-
};
|
|
102
|
-
return astralBeamApiFetch(getCreateTenantUrl(), {
|
|
103
|
-
...options,
|
|
104
|
-
method: "POST",
|
|
105
|
-
headers: {
|
|
106
|
-
"Content-Type": "application/json",
|
|
107
|
-
...getHeaders(options?.headers)
|
|
108
|
-
},
|
|
109
|
-
body: JSON.stringify(createTenantInput)
|
|
110
|
-
});
|
|
111
|
-
};
|
|
112
|
-
const getGetTenantUrl = (id) => {
|
|
113
|
-
return `/api/v1/tenants/${encodeURIComponent(String(id))}`;
|
|
114
|
-
};
|
|
115
|
-
/**
|
|
116
|
-
* Get a Tenant by internal UUID, not external_id.
|
|
117
|
-
* @summary Get a Tenant
|
|
118
|
-
*/
|
|
119
|
-
const getTenant = (id, options) => {
|
|
120
|
-
return astralBeamApiFetch(getGetTenantUrl(id), {
|
|
121
|
-
...options,
|
|
122
|
-
method: "GET"
|
|
123
|
-
});
|
|
124
|
-
};
|
|
125
|
-
const getUpdateTenantUrl = (id) => {
|
|
126
|
-
return `/api/v1/tenants/${encodeURIComponent(String(id))}`;
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* Update supplied name/metadata fields only. Requires an organization API key or organization-management JWT with a current owner/developer role. name:null clears the name; metadata replaces the object. Last-write-wins; no upsert.
|
|
130
|
-
* @summary Update a Tenant
|
|
131
|
-
*/
|
|
132
|
-
const updateTenant = (id, updateTenantInput, options) => {
|
|
133
|
-
const getHeaders = (h) => {
|
|
134
|
-
if (!h) return {};
|
|
135
|
-
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
136
|
-
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
137
|
-
const headers = {};
|
|
138
|
-
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
139
|
-
return headers;
|
|
140
|
-
};
|
|
141
|
-
return astralBeamApiFetch(getUpdateTenantUrl(id), {
|
|
142
|
-
...options,
|
|
143
|
-
method: "PATCH",
|
|
144
|
-
headers: {
|
|
145
|
-
"Content-Type": "application/json",
|
|
146
|
-
...getHeaders(options?.headers)
|
|
147
|
-
},
|
|
148
|
-
body: JSON.stringify(updateTenantInput)
|
|
149
|
-
});
|
|
150
|
-
};
|
|
151
|
-
const getListUsersForTenantUrl = (tenantId, params) => {
|
|
152
|
-
const normalizedParams = new URLSearchParams();
|
|
153
|
-
Object.entries(params || {}).forEach(([key, value]) => {
|
|
154
|
-
if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
|
|
155
|
-
});
|
|
156
|
-
const stringifiedParams = normalizedParams.toString();
|
|
157
|
-
return stringifiedParams.length > 0 ? `/api/v1/tenants/${encodeURIComponent(String(tenantId))}/tenant_users?${stringifiedParams}` : `/api/v1/tenants/${encodeURIComponent(String(tenantId))}/tenant_users`;
|
|
158
|
-
};
|
|
159
|
-
/**
|
|
160
|
-
* List users of one Tenant in internal ID order. q searches name or external ID as a case-insensitive literal substring. Exact filter[external_id] and filter[admin] combine with AND. No matching user returns an empty page; missing and out-of-scope Tenants return 404. Cursors cannot be reused for another Tenant or filter. Live listing, not a snapshot.
|
|
161
|
-
* @summary List TenantUsers
|
|
162
|
-
*/
|
|
163
|
-
const listUsersForTenant = (tenantId, params, options) => {
|
|
164
|
-
return astralBeamApiFetch(getListUsersForTenantUrl(tenantId, params), {
|
|
165
|
-
...options,
|
|
166
|
-
method: "GET"
|
|
167
|
-
});
|
|
168
|
-
};
|
|
169
|
-
const getCreateTenantUserUrl = (tenantId) => {
|
|
170
|
-
return `/api/v1/tenants/${encodeURIComponent(String(tenantId))}/tenant_users`;
|
|
171
|
-
};
|
|
172
|
-
/**
|
|
173
|
-
* Create a TenantUser under the internal tenant_id path identifier, with a customer-provided tenant-local external_id. An external_id already used in this Tenant returns 409; the same external_id in another Tenant is allowed. Stored admin does not change signed JWT authority.
|
|
174
|
-
* @summary Create a TenantUser
|
|
175
|
-
*/
|
|
176
|
-
const createTenantUser = (tenantId, createTenantUserInput, options) => {
|
|
177
|
-
const getHeaders = (h) => {
|
|
178
|
-
if (!h) return {};
|
|
179
|
-
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
180
|
-
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
181
|
-
const headers = {};
|
|
182
|
-
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
183
|
-
return headers;
|
|
184
|
-
};
|
|
185
|
-
return astralBeamApiFetch(getCreateTenantUserUrl(tenantId), {
|
|
186
|
-
...options,
|
|
187
|
-
method: "POST",
|
|
188
|
-
headers: {
|
|
189
|
-
"Content-Type": "application/json",
|
|
190
|
-
...getHeaders(options?.headers)
|
|
191
|
-
},
|
|
192
|
-
body: JSON.stringify(createTenantUserInput)
|
|
193
|
-
});
|
|
194
|
-
};
|
|
195
|
-
const getGetTenantUserUrl = (tenantId, id) => {
|
|
196
|
-
return `/api/v1/tenants/${encodeURIComponent(String(tenantId))}/tenant_users/${encodeURIComponent(String(id))}`;
|
|
197
|
-
};
|
|
198
|
-
/**
|
|
199
|
-
* Get a TenantUser by the internal tenant_id and id pair within the authorized scope. No identity upsert.
|
|
200
|
-
* @summary Get a TenantUser
|
|
201
|
-
*/
|
|
202
|
-
const getTenantUser = (tenantId, id, options) => {
|
|
203
|
-
return astralBeamApiFetch(getGetTenantUserUrl(tenantId, id), {
|
|
204
|
-
...options,
|
|
205
|
-
method: "GET"
|
|
206
|
-
});
|
|
207
|
-
};
|
|
208
|
-
const getUpdateTenantUserUrl = (tenantId, id) => {
|
|
209
|
-
return `/api/v1/tenants/${encodeURIComponent(String(tenantId))}/tenant_users/${encodeURIComponent(String(id))}`;
|
|
210
|
-
};
|
|
211
|
-
/**
|
|
212
|
-
* Update supplied name/metadata/admin fields only. Stored admin does not grant or revoke JWT authority. name:null clears the name; metadata replaces the object.
|
|
213
|
-
* @summary Update a TenantUser
|
|
214
|
-
*/
|
|
215
|
-
const updateTenantUser = (tenantId, id, updateTenantUserInput, options) => {
|
|
216
|
-
const getHeaders = (h) => {
|
|
217
|
-
if (!h) return {};
|
|
218
|
-
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
219
|
-
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
220
|
-
const headers = {};
|
|
221
|
-
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
222
|
-
return headers;
|
|
223
|
-
};
|
|
224
|
-
return astralBeamApiFetch(getUpdateTenantUserUrl(tenantId, id), {
|
|
225
|
-
...options,
|
|
226
|
-
method: "PATCH",
|
|
227
|
-
headers: {
|
|
228
|
-
"Content-Type": "application/json",
|
|
229
|
-
...getHeaders(options?.headers)
|
|
230
|
-
},
|
|
231
|
-
body: JSON.stringify(updateTenantUserInput)
|
|
232
|
-
});
|
|
233
|
-
};
|
|
234
|
-
const getGetOrganizationUrl = () => {
|
|
235
|
-
return `/api/v1/organization`;
|
|
236
|
-
};
|
|
237
|
-
/**
|
|
238
|
-
* Return the id, name, and slug of the Organization that owns the credential. Accepts an organization API key or organization-management JWT, including a viewer's. Tenant JWTs are forbidden.
|
|
239
|
-
* @summary Get the current Organization
|
|
240
|
-
*/
|
|
241
|
-
const getOrganization = (options) => {
|
|
242
|
-
return astralBeamApiFetch(getGetOrganizationUrl(), {
|
|
243
|
-
...options,
|
|
244
|
-
method: "GET"
|
|
245
|
-
});
|
|
246
|
-
};
|
|
247
|
-
const getRunChatUrl = () => {
|
|
248
|
-
return `/api/v1/chat`;
|
|
249
|
-
};
|
|
250
|
-
/**
|
|
251
|
-
* Stream an AG-UI agent run using a tenant user JWT. No admin claim required. HTTP failures before streaming use AstralBeamApiError. Once streaming starts, failures use RUN_ERROR events. Tool results continue in a subsequent request. Disconnecting cancels the run. Limited to 20 new turns and 200 tool-result continuations per minute per organization, tenant, and user.
|
|
252
|
-
* @summary Run chat
|
|
253
|
-
*/
|
|
254
|
-
const runChat = (chatRunInput, options) => {
|
|
255
|
-
const getHeaders = (h) => {
|
|
256
|
-
if (!h) return {};
|
|
257
|
-
if (h instanceof Headers) return Object.fromEntries(h.entries());
|
|
258
|
-
if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
|
|
259
|
-
const headers = {};
|
|
260
|
-
for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
|
|
261
|
-
return headers;
|
|
262
|
-
};
|
|
263
|
-
return astralBeamChatFetch(getRunChatUrl(), {
|
|
264
|
-
...options,
|
|
265
|
-
method: "POST",
|
|
266
|
-
headers: {
|
|
267
|
-
"Content-Type": "application/json",
|
|
268
|
-
...getHeaders(options?.headers)
|
|
269
|
-
},
|
|
270
|
-
body: JSON.stringify(chatRunInput)
|
|
271
|
-
});
|
|
272
|
-
};
|
|
273
|
-
const getGetChatConfigUrl = (params) => {
|
|
274
|
-
const normalizedParams = new URLSearchParams();
|
|
275
|
-
Object.entries(params || {}).forEach(([key, value]) => {
|
|
276
|
-
if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
|
|
277
|
-
});
|
|
278
|
-
const stringifiedParams = normalizedParams.toString();
|
|
279
|
-
return stringifiedParams.length > 0 ? `/api/v1/chat/config?${stringifiedParams}` : `/api/v1/chat/config`;
|
|
280
|
-
};
|
|
281
|
-
/**
|
|
282
|
-
* Read the selected agent's attachment grant using a tenant user JWT. Omit agentId to use the organization's default agent. Client settings may narrow this grant, never widen it.
|
|
283
|
-
* @summary Get chat capabilities
|
|
284
|
-
*/
|
|
285
|
-
const getChatConfig = (params, options) => {
|
|
286
|
-
return astralBeamJwtFetch(getGetChatConfigUrl(params), {
|
|
287
|
-
...options,
|
|
288
|
-
method: "GET"
|
|
289
|
-
});
|
|
290
|
-
};
|
|
291
|
-
const getGetChatFileUrl = (params) => {
|
|
292
|
-
const normalizedParams = new URLSearchParams();
|
|
293
|
-
Object.entries(params || {}).forEach(([key, value]) => {
|
|
294
|
-
if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
|
|
295
|
-
});
|
|
296
|
-
const stringifiedParams = normalizedParams.toString();
|
|
297
|
-
return stringifiedParams.length > 0 ? `/api/v1/chat/files?${stringifiedParams}` : `/api/v1/chat/files`;
|
|
298
|
-
};
|
|
299
|
-
/**
|
|
300
|
-
* Use the signed ticket returned when chat publishes an artifact. No bearer token is required. Returns the original bytes with a content-sniffed Content-Type and Content-Disposition filename. Invalid or expired tickets, a missing sandbox, and rejected artifact checks return 404. Provider or file-read failures return 500.
|
|
301
|
-
* @summary Download a chat artifact
|
|
302
|
-
*/
|
|
303
|
-
const getChatFile = (params, options) => {
|
|
304
|
-
return astralBeamFileFetch(getGetChatFileUrl(params), {
|
|
305
|
-
...options,
|
|
306
|
-
method: "GET"
|
|
307
|
-
});
|
|
308
|
-
};
|
|
309
|
-
const getGetCurrentUserUrl = () => {
|
|
310
|
-
return `/api/v1/me`;
|
|
311
|
-
};
|
|
312
|
-
/**
|
|
313
|
-
* Use a tenant JWT to upsert its own Tenant and TenantUser atomically, without requiring admin authority. Supplied names and metadata replace stored values, omitted profile fields and admin are preserved, and an explicit admin claim updates stored admin. An organization JWT returns existing user membership and the current database role without provisioning identities. API keys and cookies are not accepted. Limited to 100 requests per five minutes per identity.
|
|
314
|
-
* @summary Get the current user
|
|
315
|
-
*/
|
|
316
|
-
const getCurrentUser = (options) => {
|
|
317
|
-
return astralBeamJwtFetch(getGetCurrentUserUrl(), {
|
|
318
|
-
...options,
|
|
319
|
-
method: "POST"
|
|
320
|
-
});
|
|
321
|
-
};
|
|
322
|
-
//#endregion
|
|
323
|
-
export { resolveApiUrl as A, listTenants as C, updateTenantUser as D, updateTenant as E, DEFAULT_COLOR_SCHEME as M, astralBeamChatFetch as O, getUpdateTenantUserUrl as S, runChat as T, getOrganization as _, getChatFile as a, getTenantUser as b, getCurrentUser as c, getGetCurrentUserUrl as d, getGetOrganizationUrl as f, getListUsersForTenantUrl as g, getListTenantsUrl as h, getChatConfig as i, DEFAULT_CHAT_AUTH_TOKEN_URL as j, isAstralBeamApiError as k, getGetChatConfigUrl as l, getGetTenantUserUrl as m, createTenant as n, getCreateTenantUrl as o, getGetTenantUrl as p, createTenantUser as r, getCreateTenantUserUrl as s, ListUsersForTenantFilterAdmin as t, getGetChatFileUrl as u, getRunChatUrl as v, listUsersForTenant as w, getUpdateTenantUrl as x, getTenant as y };
|
package/dist/index-BVVgDSdq.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|