@astralbeam/sdk 0.9.0 → 0.10.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/README.md +43 -51
- package/dist/api-CaNIR6Af.js +296 -0
- package/dist/api.d.ts +333 -0
- package/dist/api.js +2 -0
- package/dist/client.js +1 -1
- package/dist/{core-Eh2vyhUP.js → core-Dr2IDA6j.js} +26 -26
- package/dist/core.js +1 -1
- package/dist/debug-BSzSiibd.js +1 -0
- package/dist/react.js +2 -1
- package/dist/server.d.ts +15 -1
- package/dist/server.js +23 -6
- package/dist/widget-B6YT3G1i.js +79 -0
- package/package.json +15 -4
- package/dist/debug-66ETHfXh.js +0 -1
- package/dist/widget-DLUt14KM.js +0 -79
package/dist/api.d.ts
ADDED
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
//#region src/api/api.d.ts
|
|
2
|
+
interface ApiRequestOptions extends RequestInit {
|
|
3
|
+
apiUrl?: string | undefined;
|
|
4
|
+
fetchClient?: typeof globalThis.fetch;
|
|
5
|
+
}
|
|
6
|
+
type ApiKeyOptions = ApiRequestOptions & {
|
|
7
|
+
apiKey: string;
|
|
8
|
+
astralBeamToken?: never;
|
|
9
|
+
};
|
|
10
|
+
type JwtOptions = ApiRequestOptions & {
|
|
11
|
+
astralBeamToken: string;
|
|
12
|
+
apiKey?: never;
|
|
13
|
+
};
|
|
14
|
+
type ApiOptions = ApiKeyOptions | JwtOptions;
|
|
15
|
+
type FileOptions = ApiRequestOptions & {
|
|
16
|
+
apiKey?: never;
|
|
17
|
+
astralBeamToken?: never;
|
|
18
|
+
};
|
|
19
|
+
interface AstralBeamApiError extends Error {
|
|
20
|
+
name: "AstralBeamApiError";
|
|
21
|
+
status: number;
|
|
22
|
+
headers: Headers;
|
|
23
|
+
body?: AstralBeamApiError$1;
|
|
24
|
+
}
|
|
25
|
+
declare function isAstralBeamApiError(error: unknown): error is AstralBeamApiError;
|
|
26
|
+
declare function astralBeamApiFetch<T>(path: string, options: ApiOptions): Promise<T>;
|
|
27
|
+
declare function astralBeamJwtFetch<T>(path: string, options: JwtOptions): Promise<T>;
|
|
28
|
+
declare function astralBeamChatFetch<_T>(path: string, options: JwtOptions): Promise<Response>;
|
|
29
|
+
declare function astralBeamFileFetch<_T>(path: string, options?: FileOptions): Promise<Response>;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/api/generated/api.d.ts
|
|
32
|
+
/**
|
|
33
|
+
* Customer-defined JSON object; keys are preserved.
|
|
34
|
+
*/
|
|
35
|
+
type TenantRecordEncodedMetadata = {
|
|
36
|
+
[key: string]: unknown;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Persisted Tenant; id is internal, external_id is the customer's exact identity.
|
|
40
|
+
*/
|
|
41
|
+
interface TenantRecordEncoded {
|
|
42
|
+
id: string;
|
|
43
|
+
external_id: string;
|
|
44
|
+
name: string | null;
|
|
45
|
+
/** Customer-defined JSON object; keys are preserved. */
|
|
46
|
+
metadata: TenantRecordEncodedMetadata;
|
|
47
|
+
created_at: string;
|
|
48
|
+
updated_at: string;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Live keyset page. Pass either non-null continuation value as the same-named request parameter.
|
|
52
|
+
*/
|
|
53
|
+
interface TenantPage {
|
|
54
|
+
items: TenantRecordEncoded[];
|
|
55
|
+
/** Pass as page_after to fetch the next page; null means no next page. */
|
|
56
|
+
page_after: string | null;
|
|
57
|
+
/** Pass as page_before to fetch the previous page; null means no previous page. */
|
|
58
|
+
page_before: string | null;
|
|
59
|
+
}
|
|
60
|
+
type AstralBeamApiErrorIssuesItem = {
|
|
61
|
+
path: string;
|
|
62
|
+
message: string;
|
|
63
|
+
};
|
|
64
|
+
interface AstralBeamApiError$1 {
|
|
65
|
+
type: string;
|
|
66
|
+
title: string;
|
|
67
|
+
status: number;
|
|
68
|
+
detail: string;
|
|
69
|
+
issues?: AstralBeamApiErrorIssuesItem[];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Customer-defined JSON object; keys are preserved. Defaults to {} on creation. Updates replace the entire object.
|
|
73
|
+
*/
|
|
74
|
+
type CreateTenantInputMetadata = {
|
|
75
|
+
[key: string]: unknown;
|
|
76
|
+
};
|
|
77
|
+
interface CreateTenantInput {
|
|
78
|
+
/**
|
|
79
|
+
* Your stable external identity. Exact and case-sensitive; whitespace is preserved. Immutable after creation.
|
|
80
|
+
* @minLength 1
|
|
81
|
+
* @maxLength 255
|
|
82
|
+
*/
|
|
83
|
+
external_id: string;
|
|
84
|
+
/** Defaults to null on creation. Send null to clear the name. */
|
|
85
|
+
name?: string | null;
|
|
86
|
+
/** Customer-defined JSON object; keys are preserved. Defaults to {} on creation. Updates replace the entire object. */
|
|
87
|
+
metadata?: CreateTenantInputMetadata;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Customer-defined JSON object; keys are preserved. Defaults to {} on creation. Updates replace the entire object.
|
|
91
|
+
*/
|
|
92
|
+
type UpdateTenantInputMetadata = {
|
|
93
|
+
[key: string]: unknown;
|
|
94
|
+
};
|
|
95
|
+
interface UpdateTenantInput {
|
|
96
|
+
/** Defaults to null on creation. Send null to clear the name. */
|
|
97
|
+
name?: string | null;
|
|
98
|
+
/** Customer-defined JSON object; keys are preserved. Defaults to {} on creation. Updates replace the entire object. */
|
|
99
|
+
metadata?: UpdateTenantInputMetadata;
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Customer-defined JSON object; keys are preserved.
|
|
103
|
+
*/
|
|
104
|
+
type TenantUserRecordEncodedMetadata = {
|
|
105
|
+
[key: string]: unknown;
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Persisted TenantUser. Stored admin does not grant or revoke signed JWT authority.
|
|
109
|
+
*/
|
|
110
|
+
interface TenantUserRecordEncoded {
|
|
111
|
+
id: string;
|
|
112
|
+
external_id: string;
|
|
113
|
+
name: string | null;
|
|
114
|
+
/** Customer-defined JSON object; keys are preserved. */
|
|
115
|
+
metadata: TenantUserRecordEncodedMetadata;
|
|
116
|
+
created_at: string;
|
|
117
|
+
updated_at: string;
|
|
118
|
+
tenant_id: string;
|
|
119
|
+
admin: boolean;
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Live keyset page in ascending ID order within one Tenant. Pass either non-null continuation value as the same-named request parameter.
|
|
123
|
+
*/
|
|
124
|
+
interface TenantUserPage {
|
|
125
|
+
items: TenantUserRecordEncoded[];
|
|
126
|
+
/** Pass as page_after to fetch the next page; null means no next page. */
|
|
127
|
+
page_after: string | null;
|
|
128
|
+
/** Pass as page_before to fetch the previous page; null means no previous page. */
|
|
129
|
+
page_before: string | null;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Customer-defined JSON object; keys are preserved. Defaults to {} on creation. Updates replace the entire object.
|
|
133
|
+
*/
|
|
134
|
+
type CreateTenantUserInputMetadata = {
|
|
135
|
+
[key: string]: unknown;
|
|
136
|
+
};
|
|
137
|
+
interface CreateTenantUserInput {
|
|
138
|
+
/**
|
|
139
|
+
* Your stable external identity. Exact and case-sensitive; whitespace is preserved. Immutable after creation.
|
|
140
|
+
* @minLength 1
|
|
141
|
+
* @maxLength 255
|
|
142
|
+
*/
|
|
143
|
+
external_id: string;
|
|
144
|
+
/** Defaults to null on creation. Send null to clear the name. */
|
|
145
|
+
name?: string | null;
|
|
146
|
+
/** Customer-defined JSON object; keys are preserved. Defaults to {} on creation. Updates replace the entire object. */
|
|
147
|
+
metadata?: CreateTenantUserInputMetadata;
|
|
148
|
+
/** Defaults to false on creation. Stored admin does not change signed JWT authority. */
|
|
149
|
+
admin?: boolean;
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Customer-defined JSON object; keys are preserved. Defaults to {} on creation. Updates replace the entire object.
|
|
153
|
+
*/
|
|
154
|
+
type UpdateTenantUserInputMetadata = {
|
|
155
|
+
[key: string]: unknown;
|
|
156
|
+
};
|
|
157
|
+
interface UpdateTenantUserInput {
|
|
158
|
+
/** Defaults to null on creation. Send null to clear the name. */
|
|
159
|
+
name?: string | null;
|
|
160
|
+
/** Customer-defined JSON object; keys are preserved. Defaults to {} on creation. Updates replace the entire object. */
|
|
161
|
+
metadata?: UpdateTenantUserInputMetadata;
|
|
162
|
+
/** Defaults to false on creation. Stored admin does not change signed JWT authority. */
|
|
163
|
+
admin?: boolean;
|
|
164
|
+
}
|
|
165
|
+
type ChatRunInputForwardedProps = {
|
|
166
|
+
[key: string]: unknown;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* Legacy mirror of forwardedProps sent by TanStack AI clients.
|
|
170
|
+
*/
|
|
171
|
+
type ChatRunInputData = {
|
|
172
|
+
[key: string]: unknown;
|
|
173
|
+
};
|
|
174
|
+
/**
|
|
175
|
+
* AG-UI RunAgentInput, validated by TanStack AI. Messages, tools, context, and resume entries follow AG-UI. forwardedProps accepts agentId and development-only debug. systemPrompt is rejected. Maximum request size: 32 MiB.
|
|
176
|
+
*/
|
|
177
|
+
interface ChatRunInput {
|
|
178
|
+
threadId: string;
|
|
179
|
+
runId: string;
|
|
180
|
+
messages: unknown[];
|
|
181
|
+
tools: unknown[];
|
|
182
|
+
context: unknown[];
|
|
183
|
+
forwardedProps?: ChatRunInputForwardedProps;
|
|
184
|
+
/** Legacy mirror of forwardedProps sent by TanStack AI clients. */
|
|
185
|
+
data?: ChatRunInputData;
|
|
186
|
+
state?: unknown;
|
|
187
|
+
parentRunId?: string;
|
|
188
|
+
resume?: unknown[];
|
|
189
|
+
}
|
|
190
|
+
type ChatConfigurationCapabilities = {
|
|
191
|
+
attachments: boolean;
|
|
192
|
+
};
|
|
193
|
+
interface ChatConfiguration {
|
|
194
|
+
capabilities: ChatConfigurationCapabilities;
|
|
195
|
+
}
|
|
196
|
+
type ListTenantsParams = {
|
|
197
|
+
/**
|
|
198
|
+
* Case-insensitive literal substring of name or external_id. Trimmed, blank means no search.
|
|
199
|
+
* @maxLength 255
|
|
200
|
+
* @pattern ^[^\u0000]*$
|
|
201
|
+
*/
|
|
202
|
+
q?: string;
|
|
203
|
+
/**
|
|
204
|
+
* Exact, case-sensitive external ID; whitespace is preserved. Returns zero or one item.
|
|
205
|
+
* @minLength 1
|
|
206
|
+
* @maxLength 255
|
|
207
|
+
*/
|
|
208
|
+
"filter[external_id]"?: string;
|
|
209
|
+
/**
|
|
210
|
+
* Positive integer, default 20. Values above 100 are accepted and capped. page_after and page_before are mutually exclusive.
|
|
211
|
+
* @minimum 1
|
|
212
|
+
*/
|
|
213
|
+
page_size?: number;
|
|
214
|
+
/**
|
|
215
|
+
* @minLength 1
|
|
216
|
+
* @maxLength 2048
|
|
217
|
+
*/
|
|
218
|
+
page_after?: string;
|
|
219
|
+
/**
|
|
220
|
+
* @minLength 1
|
|
221
|
+
* @maxLength 2048
|
|
222
|
+
*/
|
|
223
|
+
page_before?: string;
|
|
224
|
+
};
|
|
225
|
+
type ListUsersForTenantParams = {
|
|
226
|
+
/**
|
|
227
|
+
* Case-insensitive literal substring of name or external_id. Trimmed, blank means no search.
|
|
228
|
+
* @maxLength 255
|
|
229
|
+
* @pattern ^[^\u0000]*$
|
|
230
|
+
*/
|
|
231
|
+
q?: string;
|
|
232
|
+
/**
|
|
233
|
+
* Exact, case-sensitive external ID; whitespace is preserved. Returns zero or one item.
|
|
234
|
+
* @minLength 1
|
|
235
|
+
* @maxLength 255
|
|
236
|
+
*/
|
|
237
|
+
"filter[external_id]"?: string;
|
|
238
|
+
/**
|
|
239
|
+
* Positive integer, default 20. Values above 100 are accepted and capped. page_after and page_before are mutually exclusive.
|
|
240
|
+
* @minimum 1
|
|
241
|
+
*/
|
|
242
|
+
page_size?: number;
|
|
243
|
+
/**
|
|
244
|
+
* @minLength 1
|
|
245
|
+
* @maxLength 2048
|
|
246
|
+
*/
|
|
247
|
+
page_after?: string;
|
|
248
|
+
/**
|
|
249
|
+
* @minLength 1
|
|
250
|
+
* @maxLength 2048
|
|
251
|
+
*/
|
|
252
|
+
page_before?: string;
|
|
253
|
+
"filter[admin]"?: ListUsersForTenantFilterAdmin;
|
|
254
|
+
};
|
|
255
|
+
type ListUsersForTenantFilterAdmin = typeof ListUsersForTenantFilterAdmin[keyof typeof ListUsersForTenantFilterAdmin];
|
|
256
|
+
declare const ListUsersForTenantFilterAdmin: {
|
|
257
|
+
readonly true: "true";
|
|
258
|
+
readonly false: "false";
|
|
259
|
+
};
|
|
260
|
+
type GetChatConfigParams = {
|
|
261
|
+
agentId?: string;
|
|
262
|
+
};
|
|
263
|
+
type GetChatFileParams = {
|
|
264
|
+
ticket: string;
|
|
265
|
+
};
|
|
266
|
+
declare const getListTenantsUrl: (params: ListTenantsParams) => string;
|
|
267
|
+
/**
|
|
268
|
+
* 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.
|
|
269
|
+
* @summary List Tenants
|
|
270
|
+
*/
|
|
271
|
+
declare const listTenants: (params: ListTenantsParams, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantPage>;
|
|
272
|
+
declare const getCreateTenantUrl: () => string;
|
|
273
|
+
/**
|
|
274
|
+
* 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.
|
|
275
|
+
* @summary Create a Tenant
|
|
276
|
+
*/
|
|
277
|
+
declare const createTenant: (createTenantInput: CreateTenantInput, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantRecordEncoded>;
|
|
278
|
+
declare const getGetTenantUrl: (id: string) => string;
|
|
279
|
+
/**
|
|
280
|
+
* Get a Tenant by internal UUID, not external_id.
|
|
281
|
+
* @summary Get a Tenant
|
|
282
|
+
*/
|
|
283
|
+
declare const getTenant: (id: string, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantRecordEncoded>;
|
|
284
|
+
declare const getUpdateTenantUrl: (id: string) => string;
|
|
285
|
+
/**
|
|
286
|
+
* 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.
|
|
287
|
+
* @summary Update a Tenant
|
|
288
|
+
*/
|
|
289
|
+
declare const updateTenant: (id: string, updateTenantInput: UpdateTenantInput, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantRecordEncoded>;
|
|
290
|
+
declare const getListUsersForTenantUrl: (tenantId: string, params: ListUsersForTenantParams) => string;
|
|
291
|
+
/**
|
|
292
|
+
* 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.
|
|
293
|
+
* @summary List TenantUsers
|
|
294
|
+
*/
|
|
295
|
+
declare const listUsersForTenant: (tenantId: string, params: ListUsersForTenantParams, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantUserPage>;
|
|
296
|
+
declare const getCreateTenantUserUrl: (tenantId: string) => string;
|
|
297
|
+
/**
|
|
298
|
+
* 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.
|
|
299
|
+
* @summary Create a TenantUser
|
|
300
|
+
*/
|
|
301
|
+
declare const createTenantUser: (tenantId: string, createTenantUserInput: CreateTenantUserInput, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantUserRecordEncoded>;
|
|
302
|
+
declare const getGetTenantUserUrl: (tenantId: string, id: string) => string;
|
|
303
|
+
/**
|
|
304
|
+
* Get a TenantUser by the internal tenant_id and id pair within the authorized scope. No identity upsert.
|
|
305
|
+
* @summary Get a TenantUser
|
|
306
|
+
*/
|
|
307
|
+
declare const getTenantUser: (tenantId: string, id: string, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantUserRecordEncoded>;
|
|
308
|
+
declare const getUpdateTenantUserUrl: (tenantId: string, id: string) => string;
|
|
309
|
+
/**
|
|
310
|
+
* 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.
|
|
311
|
+
* @summary Update a TenantUser
|
|
312
|
+
*/
|
|
313
|
+
declare const updateTenantUser: (tenantId: string, id: string, updateTenantUserInput: UpdateTenantUserInput, options: Parameters<typeof astralBeamApiFetch>[1]) => Promise<TenantUserRecordEncoded>;
|
|
314
|
+
declare const getRunChatUrl: () => string;
|
|
315
|
+
/**
|
|
316
|
+
* 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 requests per minute per organization, tenant, and user.
|
|
317
|
+
* @summary Run chat
|
|
318
|
+
*/
|
|
319
|
+
declare const runChat: (chatRunInput: ChatRunInput, options: Parameters<typeof astralBeamChatFetch>[1]) => Promise<Response>;
|
|
320
|
+
declare const getGetChatConfigUrl: (params: GetChatConfigParams) => string;
|
|
321
|
+
/**
|
|
322
|
+
* 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.
|
|
323
|
+
* @summary Get chat capabilities
|
|
324
|
+
*/
|
|
325
|
+
declare const getChatConfig: (params: GetChatConfigParams, options: Parameters<typeof astralBeamJwtFetch>[1]) => Promise<ChatConfiguration>;
|
|
326
|
+
declare const getGetChatFileUrl: (params: GetChatFileParams) => string;
|
|
327
|
+
/**
|
|
328
|
+
* 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.
|
|
329
|
+
* @summary Download a chat artifact
|
|
330
|
+
*/
|
|
331
|
+
declare const getChatFile: (params: GetChatFileParams, options?: Parameters<typeof astralBeamFileFetch>[1]) => Promise<Response>;
|
|
332
|
+
//#endregion
|
|
333
|
+
export { type ApiKeyOptions, type ApiOptions, type ApiRequestOptions, AstralBeamApiError, type AstralBeamApiError$1 as AstralBeamApiErrorBody, AstralBeamApiErrorIssuesItem, ChatConfiguration, ChatConfigurationCapabilities, ChatRunInput, ChatRunInputData, ChatRunInputForwardedProps, CreateTenantInput, CreateTenantInputMetadata, CreateTenantUserInput, CreateTenantUserInputMetadata, type FileOptions, GetChatConfigParams, GetChatFileParams, type JwtOptions, ListTenantsParams, ListUsersForTenantFilterAdmin, ListUsersForTenantParams, TenantPage, TenantRecordEncoded, TenantRecordEncodedMetadata, TenantUserPage, TenantUserRecordEncoded, TenantUserRecordEncodedMetadata, UpdateTenantInput, UpdateTenantInputMetadata, UpdateTenantUserInput, UpdateTenantUserInputMetadata, createTenant, createTenantUser, getChatConfig, getChatFile, getCreateTenantUrl, getCreateTenantUserUrl, getGetChatConfigUrl, getGetChatFileUrl, getGetTenantUrl, getGetTenantUserUrl, getListTenantsUrl, getListUsersForTenantUrl, getRunChatUrl, getTenant, getTenantUser, getUpdateTenantUrl, getUpdateTenantUserUrl, isAstralBeamApiError, listTenants, listUsersForTenant, runChat, updateTenant, updateTenantUser };
|
package/dist/api.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { C as updateTenantUser, S as updateTenant, T as isAstralBeamApiError, _ as getUpdateTenantUrl, a as getChatFile, b as listUsersForTenant, c as getGetChatConfigUrl, d as getGetTenantUserUrl, f as getListTenantsUrl, g as getTenantUser, h as getTenant, i as getChatConfig, l as getGetChatFileUrl, m as getRunChatUrl, n as createTenant, o as getCreateTenantUrl, p as getListUsersForTenantUrl, r as createTenantUser, s as getCreateTenantUserUrl, t as ListUsersForTenantFilterAdmin, u as getGetTenantUrl, v as getUpdateTenantUserUrl, x as runChat, y as listTenants } from "./api-CaNIR6Af.js";
|
|
2
|
+
export { ListUsersForTenantFilterAdmin, createTenant, createTenantUser, getChatConfig, getChatFile, getCreateTenantUrl, getCreateTenantUserUrl, getGetChatConfigUrl, getGetChatFileUrl, getGetTenantUrl, getGetTenantUserUrl, getListTenantsUrl, getListUsersForTenantUrl, getRunChatUrl, getTenant, getTenantUser, getUpdateTenantUrl, getUpdateTenantUserUrl, isAstralBeamApiError, listTenants, listUsersForTenant, runChat, updateTenant, updateTenantUser };
|
package/dist/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as e,t}from"./debug-
|
|
1
|
+
import{c as e,t}from"./debug-BSzSiibd.js";function n(e){return e}function r(e){return e}function i(n,r){let i={...r},a=t(i.debug);a?.(`mount`,`mounting chat widget`,{agentId:i.agentId??`(organization default)`,title:i.title??`AstralBeam`,showHeader:i.showHeader??!0,emptyTitle:i.emptyTitle??`Ask the assistant`,emptyDescription:i.emptyDescription??`It can answer questions and act through this app's own tools and widgets.`,apiUrl:i.apiUrl??`https://app.astralbeam.ai/api`,authentication:`configured`,colorScheme:i.colorScheme??`system`,theme:i.theme,tools:Object.keys(i.tools??{}),widgets:Object.keys(i.widgets??{}),attachments:i.attachments??!0});let o=n.shadowRoot??n.attachShadow({mode:`open`}),s=document.createElement(`div`);s.className=e,s.style.height=`100%`,o.append(s);let c=matchMedia(`(prefers-color-scheme: dark)`),l=new Set,u=e=>{for(let e of l)s.style.removeProperty(e);l.clear();let t={...i.theme?.light,...e?i.theme?.dark:void 0};for(let[e,n]of Object.entries(t))e.startsWith(`--`)&&(s.style.setProperty(e,n),l.add(e))},d=()=>{let e=i.colorScheme??`system`,t=e===`dark`||e===`system`&&c.matches;s.classList.toggle(`dark`,t),u(t),a?.(`theme`,`color scheme "${e}" resolved to ${t?`dark`:`light`}`,{themeVariables:[...l]})};d(),c.addEventListener(`change`,d);let f=!1,p;return import(`./widget-B6YT3G1i.js`).then(({renderChat:e})=>{a?.(`mount`,`chat chunk loaded`),f||(p=e(o,s,i))}),{update:e=>{i={...i,...e},a=t(i.debug),a?.(`mount`,`options updated`,{changed:Object.keys(e)}),d(),p?.update(i)},reset:()=>p?.reset(),stop:()=>p?.stop(),unmount:()=>{a?.(`mount`,`unmounting chat widget`),f=!0,c.removeEventListener(`change`,d),p?.dispose(),p=void 0,s.remove()}}}export{n as defineTool,r as defineWidget,i as mountAstralBeamChat};
|
|
@@ -1,19 +1,6 @@
|
|
|
1
|
+
import { E as resolveApiUrl, T as isAstralBeamApiError, i as getChatConfig, m as getRunChatUrl, w as astralBeamChatFetch } from "./api-CaNIR6Af.js";
|
|
1
2
|
//#region \0rolldown/runtime.js
|
|
2
3
|
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
3
|
-
/**
|
|
4
|
-
* The chat API's URLs under an API base: the stream itself, the agent capability handshake,
|
|
5
|
-
* and artifact downloads. Chat is one API under the base; others will sit beside it.
|
|
6
|
-
*/
|
|
7
|
-
function chatApiUrls(apiUrl) {
|
|
8
|
-
const chat = `${(apiUrl ?? "https://app.astralbeam.ai/api").replace(/\/+$/, "")}/v1/chat`;
|
|
9
|
-
return {
|
|
10
|
-
chat,
|
|
11
|
-
config: `${chat}/config`,
|
|
12
|
-
files: `${chat}/files`
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
/** Color scheme used when the mount options and the React prop give none. */
|
|
16
|
-
const DEFAULT_COLOR_SCHEME = "system";
|
|
17
4
|
//#endregion
|
|
18
5
|
//#region node_modules/.deno/@tanstack+ai-client@0.28.0/node_modules/@tanstack/ai-client/dist/esm/response-stream.js
|
|
19
6
|
var UnsupportedResponseStreamError = class extends Error {
|
|
@@ -8134,12 +8121,11 @@ function createAstralBeamChat(options) {
|
|
|
8134
8121
|
const resolveCapabilities = async () => {
|
|
8135
8122
|
const generation = ++capabilitiesGeneration;
|
|
8136
8123
|
try {
|
|
8137
|
-
const url = new URL(chatApiUrls(live.apiUrl).config, globalThis.location?.href);
|
|
8138
|
-
if (live.agentId) url.searchParams.set("agentId", live.agentId);
|
|
8139
8124
|
const token = await getValidChatAuthToken(authentication);
|
|
8140
|
-
const
|
|
8141
|
-
|
|
8142
|
-
|
|
8125
|
+
const body = await getChatConfig(live.agentId ? { agentId: live.agentId } : {}, {
|
|
8126
|
+
apiUrl: live.apiUrl,
|
|
8127
|
+
astralBeamToken: token
|
|
8128
|
+
});
|
|
8143
8129
|
if (generation !== capabilitiesGeneration) return;
|
|
8144
8130
|
const attachments = body.capabilities?.attachments !== false;
|
|
8145
8131
|
update({ capabilities: { attachments } });
|
|
@@ -8198,15 +8184,29 @@ function createAstralBeamChat(options) {
|
|
|
8198
8184
|
...live.agentId ? { agentId: live.agentId } : {},
|
|
8199
8185
|
...live.debug ? { debug: true } : {}
|
|
8200
8186
|
});
|
|
8201
|
-
const
|
|
8202
|
-
|
|
8203
|
-
|
|
8204
|
-
|
|
8187
|
+
const connection = fetchServerSentEvents(() => resolveApiUrl(getRunChatUrl(), live.apiUrl), async () => {
|
|
8188
|
+
const token = await getValidChatAuthToken(authentication);
|
|
8189
|
+
return { fetchClient: (_input, init) => astralBeamChatFetch(getRunChatUrl(), {
|
|
8190
|
+
...init,
|
|
8191
|
+
apiUrl: live.apiUrl,
|
|
8192
|
+
astralBeamToken: token,
|
|
8193
|
+
fetchClient: (input, request) => fetchAuthenticatedChat({
|
|
8205
8194
|
...authentication,
|
|
8206
8195
|
input,
|
|
8207
|
-
init
|
|
8196
|
+
init: request
|
|
8208
8197
|
})
|
|
8209
|
-
})
|
|
8198
|
+
}) };
|
|
8199
|
+
});
|
|
8200
|
+
const connect = connection.connect;
|
|
8201
|
+
connection.connect = async function* (...args) {
|
|
8202
|
+
try {
|
|
8203
|
+
yield* connect(...args);
|
|
8204
|
+
} catch (error) {
|
|
8205
|
+
throw error instanceof Error && isAstralBeamApiError(error.cause) ? error.cause : error;
|
|
8206
|
+
}
|
|
8207
|
+
};
|
|
8208
|
+
const client = new ChatClient({
|
|
8209
|
+
connection,
|
|
8210
8210
|
tools: declareTools(),
|
|
8211
8211
|
forwardedProps: forwardedProps(),
|
|
8212
8212
|
onMessagesChange: (messages) => {
|
|
@@ -8323,4 +8323,4 @@ function defineTool(tool) {
|
|
|
8323
8323
|
return tool;
|
|
8324
8324
|
}
|
|
8325
8325
|
//#endregion
|
|
8326
|
-
export {
|
|
8326
|
+
export { SANDBOX_WRITE_FILE_TOOL as S, SANDBOX_LIST_FILES_TOOL as _, describeSandboxCommandRun as a, SANDBOX_RUN_COMMAND_TOOL as b, readSandboxCommandRun as c, hasPendingToolRun as d, isSettledToolCall as f, RENDER_WIDGET_TOOL as g, ASK_QUESTIONNAIRE_TOOL as h, collectSandboxActivity as i, readSandboxFileWrite as l, buildAgentTools as m, CORE_OPTION_KEYS as n, isSandboxTool as o, lastPartInProgress as p, createAstralBeamChat as r, readSandboxArtifact as s, defineTool as t, sandboxRefusal as u, SANDBOX_PUBLISH_ARTIFACT_TOOL as v, SANDBOX_STATUS_EVENT as x, SANDBOX_READ_FILE_TOOL as y };
|
package/dist/core.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { S as SANDBOX_WRITE_FILE_TOOL, _ as SANDBOX_LIST_FILES_TOOL, a as describeSandboxCommandRun, b as SANDBOX_RUN_COMMAND_TOOL, c as readSandboxCommandRun, d as hasPendingToolRun, f as isSettledToolCall, g as RENDER_WIDGET_TOOL, h as ASK_QUESTIONNAIRE_TOOL, i as collectSandboxActivity, l as readSandboxFileWrite, m as buildAgentTools, o as isSandboxTool, p as lastPartInProgress, r as createAstralBeamChat, s as readSandboxArtifact, t as defineTool, u as sandboxRefusal, v as SANDBOX_PUBLISH_ARTIFACT_TOOL, x as SANDBOX_STATUS_EVENT, y as SANDBOX_READ_FILE_TOOL } from "./core-
|
|
1
|
+
import { S as SANDBOX_WRITE_FILE_TOOL, _ as SANDBOX_LIST_FILES_TOOL, a as describeSandboxCommandRun, b as SANDBOX_RUN_COMMAND_TOOL, c as readSandboxCommandRun, d as hasPendingToolRun, f as isSettledToolCall, g as RENDER_WIDGET_TOOL, h as ASK_QUESTIONNAIRE_TOOL, i as collectSandboxActivity, l as readSandboxFileWrite, m as buildAgentTools, o as isSandboxTool, p as lastPartInProgress, r as createAstralBeamChat, s as readSandboxArtifact, t as defineTool, u as sandboxRefusal, v as SANDBOX_PUBLISH_ARTIFACT_TOOL, x as SANDBOX_STATUS_EVENT, y as SANDBOX_READ_FILE_TOOL } from "./core-Dr2IDA6j.js";
|
|
2
2
|
export { ASK_QUESTIONNAIRE_TOOL, RENDER_WIDGET_TOOL, SANDBOX_LIST_FILES_TOOL, SANDBOX_PUBLISH_ARTIFACT_TOOL, SANDBOX_READ_FILE_TOOL, SANDBOX_RUN_COMMAND_TOOL, SANDBOX_STATUS_EVENT, SANDBOX_WRITE_FILE_TOOL, buildAgentTools, collectSandboxActivity, createAstralBeamChat, defineTool, describeSandboxCommandRun, hasPendingToolRun, isSandboxTool, isSettledToolCall, lastPartInProgress, readSandboxArtifact, readSandboxCommandRun, readSandboxFileWrite, sandboxRefusal };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=`AstralBeam`,t=`Ask the assistant`,n=`It can answer questions and act through this app's own tools and widgets.`,r=`https://app.astralbeam.ai/api`,i=`/api/astralbeam/token`,a=`system`,o=`astralbeam-root`,s=e=>`background:${e};color:#fff;border-radius:3px;padding:1px 5px`,c=`${s(`#7c3aed`)};font-weight:600`,l={mount:`#7c3aed`,auth:`#be185d`,theme:`#8b5cf6`,send:`#2563eb`,run:`#0891b2`,stream:`#0e7490`,text:`#16a34a`,reasoning:`#64748b`,tool:`#d97706`,widget:`#db2777`,attachment:`#0d9488`,sandbox:`#0369a1`,questionnaire:`#9333ea`,status:`#475569`,error:`#dc2626`};function u(e){if(e)return(e,t,n)=>{console.log(`%cAstralBeam%c ${new Date().toISOString().slice(11,19)} %c${e}%c ${t}`,c,`color:#94a3b8;font-weight:400`,s(l[e]),``,...n===void 0?[]:[n])}}export{n as a,o as c,a as i,r as n,t as o,i as r,e as s,u as t};
|
package/dist/react.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as CORE_OPTION_KEYS, r as createAstralBeamChat } from "./core-Dr2IDA6j.js";
|
|
2
|
+
import { O as DEFAULT_COLOR_SCHEME } from "./api-CaNIR6Af.js";
|
|
2
3
|
import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
3
4
|
import { createPortal } from "react-dom";
|
|
4
5
|
import { defineTool, mountAstralBeamChat } from "@astralbeam/sdk/client";
|
package/dist/server.d.ts
CHANGED
|
@@ -31,6 +31,20 @@ interface CreateAstralBeamTokenOptions<TTenantUser extends TenantUser = TenantUs
|
|
|
31
31
|
readonly tenant: TTenant;
|
|
32
32
|
readonly expiresInSeconds?: number | undefined;
|
|
33
33
|
}
|
|
34
|
+
interface CreateAstralBeamOrganizationTokenOptions {
|
|
35
|
+
readonly apiKey: string;
|
|
36
|
+
/** Host-authenticated email of an existing organization member, never browser-supplied identity. */
|
|
37
|
+
readonly email: string;
|
|
38
|
+
readonly organizationId: string;
|
|
39
|
+
readonly expiresInSeconds?: number | undefined;
|
|
40
|
+
}
|
|
41
|
+
/** Delegates a member's current database permissions. Does not restrict the API-key holder's authority. */
|
|
42
|
+
declare function createAstralBeamOrganizationToken({
|
|
43
|
+
apiKey,
|
|
44
|
+
email,
|
|
45
|
+
organizationId,
|
|
46
|
+
expiresInSeconds
|
|
47
|
+
}: CreateAstralBeamOrganizationTokenOptions): Promise<string>;
|
|
34
48
|
/** Creates the short-lived bearer token returned by an application's server auth endpoint. */
|
|
35
49
|
declare function createAstralBeamToken<TTenantUser extends TenantUser = TenantUser, TTenant extends Tenant = Tenant>({
|
|
36
50
|
apiKey,
|
|
@@ -39,4 +53,4 @@ declare function createAstralBeamToken<TTenantUser extends TenantUser = TenantUs
|
|
|
39
53
|
expiresInSeconds
|
|
40
54
|
}: CreateAstralBeamTokenOptions<TTenantUser, TTenant>): Promise<string>;
|
|
41
55
|
//#endregion
|
|
42
|
-
export { CHAT_AUTH_TOKEN_AUDIENCE, CHAT_AUTH_TOKEN_LIFETIME_SECONDS, CHAT_AUTH_TOKEN_MAX_LIFETIME_SECONDS, CHAT_AUTH_TOKEN_TYPE, CHAT_AUTH_TOKEN_VERSION, CreateAstralBeamTokenOptions, JsonMetadata, JsonValue, Tenant, TenantUser, createAstralBeamToken };
|
|
56
|
+
export { CHAT_AUTH_TOKEN_AUDIENCE, CHAT_AUTH_TOKEN_LIFETIME_SECONDS, CHAT_AUTH_TOKEN_MAX_LIFETIME_SECONDS, CHAT_AUTH_TOKEN_TYPE, CHAT_AUTH_TOKEN_VERSION, CreateAstralBeamOrganizationTokenOptions, CreateAstralBeamTokenOptions, JsonMetadata, JsonValue, Tenant, TenantUser, createAstralBeamOrganizationToken, createAstralBeamToken };
|
package/dist/server.js
CHANGED
|
@@ -645,7 +645,7 @@ const CHAT_AUTH_TOKEN_MAX_LIFETIME_SECONDS = 600;
|
|
|
645
645
|
const CHAT_AUTH_TOKEN_MAX_BYTES = 16384;
|
|
646
646
|
const IDENTITY_MAX_BYTES = 8192;
|
|
647
647
|
const EXTERNAL_ID_MAX_LENGTH = 255;
|
|
648
|
-
const API_KEY_PATTERN = /^key_[0-9a-
|
|
648
|
+
const API_KEY_PATTERN = /^key_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}_[0-9a-f]{8}-[0-9a-f]{4}-7[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}_abo_[A-Za-z]{64}$/;
|
|
649
649
|
const TENANT_FIELDS = [
|
|
650
650
|
"id",
|
|
651
651
|
"name",
|
|
@@ -659,13 +659,13 @@ const TENANT_USER_FIELDS = [
|
|
|
659
659
|
];
|
|
660
660
|
const textEncoder = new TextEncoder();
|
|
661
661
|
function parseApiKey(apiKey) {
|
|
662
|
-
if (!API_KEY_PATTERN.test(apiKey)) throw new Error("apiKey must match key_<
|
|
662
|
+
if (!API_KEY_PATTERN.test(apiKey)) throw new Error("apiKey must match key_<organizationId>_<id>_abo_<secret>");
|
|
663
663
|
const separator = apiKey.lastIndexOf("_abo_");
|
|
664
664
|
const keyId = apiKey.slice(0, separator);
|
|
665
665
|
const keySecret = apiKey.slice(separator + 1);
|
|
666
666
|
return {
|
|
667
667
|
keyId,
|
|
668
|
-
|
|
668
|
+
organizationId: keyId.slice(4, keyId.indexOf("_", 4)),
|
|
669
669
|
keySecret
|
|
670
670
|
};
|
|
671
671
|
}
|
|
@@ -704,10 +704,27 @@ async function signingKey(secret) {
|
|
|
704
704
|
const digest = await crypto.subtle.digest("SHA-256", textEncoder.encode(secret));
|
|
705
705
|
return textEncoder.encode(encode(new Uint8Array(digest)));
|
|
706
706
|
}
|
|
707
|
+
/** Delegates a member's current database permissions. Does not restrict the API-key holder's authority. */
|
|
708
|
+
async function createAstralBeamOrganizationToken({ apiKey, email, organizationId, expiresInSeconds = 300 }) {
|
|
709
|
+
if (typeof email !== "string" || email.length > 320 || email.includes("\0") || !/^[^\s@]+@[^\s@]+$/.test(email)) throw new Error("email must be an email address of at most 320 characters");
|
|
710
|
+
if (!Number.isInteger(expiresInSeconds) || expiresInSeconds < 60 || expiresInSeconds > 600) throw new Error("organization auth tokens must live for 60-600 seconds");
|
|
711
|
+
const { keyId, organizationId: keyOrganizationId, keySecret } = parseApiKey(apiKey);
|
|
712
|
+
if (organizationId !== keyOrganizationId) throw new Error("organizationId must match the API key organization");
|
|
713
|
+
const now = Math.floor(Date.now() / 1e3);
|
|
714
|
+
return await new SignJWT({
|
|
715
|
+
ver: 1,
|
|
716
|
+
email,
|
|
717
|
+
organization_id: organizationId
|
|
718
|
+
}).setProtectedHeader({
|
|
719
|
+
alg: "HS256",
|
|
720
|
+
typ: "astralbeam-organization+jwt",
|
|
721
|
+
kid: keyId
|
|
722
|
+
}).setIssuer(organizationId).setAudience(CHAT_AUTH_TOKEN_AUDIENCE).setIssuedAt(now).setExpirationTime(now + expiresInSeconds).sign(await signingKey(keySecret));
|
|
723
|
+
}
|
|
707
724
|
/** Creates the short-lived bearer token returned by an application's server auth endpoint. */
|
|
708
725
|
async function createAstralBeamToken({ apiKey, user, tenant, expiresInSeconds = 300 }) {
|
|
709
726
|
if (!Number.isInteger(expiresInSeconds) || expiresInSeconds < 60 || expiresInSeconds > 600) throw new Error("chat auth tokens must live for 60-600 seconds");
|
|
710
|
-
const { keyId,
|
|
727
|
+
const { keyId, organizationId, keySecret } = parseApiKey(apiKey);
|
|
711
728
|
const identity = validatedIdentity(user, tenant);
|
|
712
729
|
const now = Math.floor(Date.now() / 1e3);
|
|
713
730
|
const token = await new SignJWT({
|
|
@@ -718,9 +735,9 @@ async function createAstralBeamToken({ apiKey, user, tenant, expiresInSeconds =
|
|
|
718
735
|
alg: "HS256",
|
|
719
736
|
typ: CHAT_AUTH_TOKEN_TYPE,
|
|
720
737
|
kid: keyId
|
|
721
|
-
}).setIssuer(
|
|
738
|
+
}).setIssuer(organizationId).setAudience(CHAT_AUTH_TOKEN_AUDIENCE).setIssuedAt(now).setExpirationTime(now + expiresInSeconds).sign(await signingKey(keySecret));
|
|
722
739
|
if (textEncoder.encode(token).byteLength > CHAT_AUTH_TOKEN_MAX_BYTES) throw new Error(`chat auth tokens must not exceed ${CHAT_AUTH_TOKEN_MAX_BYTES} bytes`);
|
|
723
740
|
return token;
|
|
724
741
|
}
|
|
725
742
|
//#endregion
|
|
726
|
-
export { CHAT_AUTH_TOKEN_AUDIENCE, CHAT_AUTH_TOKEN_LIFETIME_SECONDS, CHAT_AUTH_TOKEN_MAX_LIFETIME_SECONDS, CHAT_AUTH_TOKEN_TYPE, CHAT_AUTH_TOKEN_VERSION, createAstralBeamToken };
|
|
743
|
+
export { CHAT_AUTH_TOKEN_AUDIENCE, CHAT_AUTH_TOKEN_LIFETIME_SECONDS, CHAT_AUTH_TOKEN_MAX_LIFETIME_SECONDS, CHAT_AUTH_TOKEN_TYPE, CHAT_AUTH_TOKEN_VERSION, createAstralBeamOrganizationToken, createAstralBeamToken };
|