@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.
@@ -0,0 +1,653 @@
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.reference === void 0 || typeof body.reference === "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
+ const response = await apiResponse(path, options);
49
+ if (response.status === 204) return void 0;
50
+ return await response.json();
51
+ }
52
+ function astralBeamJwtFetch(path, options) {
53
+ return astralBeamApiFetch(path, options);
54
+ }
55
+ function astralBeamResourceFetch(path, options) {
56
+ return apiResponse(path, options);
57
+ }
58
+ function astralBeamChatFetch(path, options) {
59
+ return apiResponse(path, options);
60
+ }
61
+ function astralBeamFileFetch(path, options = {}) {
62
+ return apiResponse(path, options);
63
+ }
64
+ //#endregion
65
+ //#region src/api/generated/api.ts
66
+ /**
67
+ * Generated by Orval. Do not edit by hand.
68
+ */
69
+ const ResolveChatToolResultInputEncodedResultsItemOutcome = {
70
+ succeeded: "succeeded",
71
+ failed: "failed",
72
+ skipped: "skipped",
73
+ unknown: "unknown"
74
+ };
75
+ const ChatParticipantEncodedRole = {
76
+ viewer: "viewer",
77
+ member: "member",
78
+ manager: "manager"
79
+ };
80
+ const SetChatParticipantInputEncodedRole = {
81
+ viewer: "viewer",
82
+ member: "member",
83
+ manager: "manager"
84
+ };
85
+ const ChatHistoryPageEncodedMessagesItemRole = {
86
+ user: "user",
87
+ assistant: "assistant",
88
+ tool: "tool"
89
+ };
90
+ const ChatHistoryPageEncodedMessagesItemState = {
91
+ draft: "draft",
92
+ complete: "complete",
93
+ interrupted: "interrupted"
94
+ };
95
+ const ChatHistoryPageEncodedThreadRole = {
96
+ viewer: "viewer",
97
+ member: "member",
98
+ manager: "manager"
99
+ };
100
+ const ChatHistoryPageEncodedPendingInteractionsItemExecutionLocation = {
101
+ server_api: "server_api",
102
+ sandbox: "sandbox",
103
+ browser: "browser"
104
+ };
105
+ const ChatThreadEncodedRole = {
106
+ viewer: "viewer",
107
+ member: "member",
108
+ manager: "manager"
109
+ };
110
+ const ChatMessageEncodedRole = {
111
+ user: "user",
112
+ assistant: "assistant",
113
+ tool: "tool"
114
+ };
115
+ const ChatMessageEncodedState = {
116
+ draft: "draft",
117
+ complete: "complete",
118
+ interrupted: "interrupted"
119
+ };
120
+ const ListUsersForTenantFilterAdmin = {
121
+ true: "true",
122
+ false: "false"
123
+ };
124
+ const getListTenantsUrl = (params) => {
125
+ const normalizedParams = new URLSearchParams();
126
+ Object.entries(params || {}).forEach(([key, value]) => {
127
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
128
+ });
129
+ const stringifiedParams = normalizedParams.toString();
130
+ return stringifiedParams.length > 0 ? `/api/v1/tenants?${stringifiedParams}` : `/api/v1/tenants`;
131
+ };
132
+ /**
133
+ * 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.
134
+ * @summary List Tenants
135
+ */
136
+ const listTenants = (params, options) => {
137
+ return astralBeamApiFetch(getListTenantsUrl(params), {
138
+ ...options,
139
+ method: "GET"
140
+ });
141
+ };
142
+ const getCreateTenantUrl = () => {
143
+ return `/api/v1/tenants`;
144
+ };
145
+ /**
146
+ * 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.
147
+ * @summary Create a Tenant
148
+ */
149
+ const createTenant = (createTenantInput, options) => {
150
+ const getHeaders = (h) => {
151
+ if (!h) return {};
152
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
153
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
154
+ const headers = {};
155
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
156
+ return headers;
157
+ };
158
+ return astralBeamApiFetch(getCreateTenantUrl(), {
159
+ ...options,
160
+ method: "POST",
161
+ headers: {
162
+ "Content-Type": "application/json",
163
+ ...getHeaders(options?.headers)
164
+ },
165
+ body: JSON.stringify(createTenantInput)
166
+ });
167
+ };
168
+ const getGetTenantUrl = (id) => {
169
+ return `/api/v1/tenants/${encodeURIComponent(String(id))}`;
170
+ };
171
+ /**
172
+ * Get a Tenant by internal UUID, not external_id.
173
+ * @summary Get a Tenant
174
+ */
175
+ const getTenant = (id, options) => {
176
+ return astralBeamApiFetch(getGetTenantUrl(id), {
177
+ ...options,
178
+ method: "GET"
179
+ });
180
+ };
181
+ const getUpdateTenantUrl = (id) => {
182
+ return `/api/v1/tenants/${encodeURIComponent(String(id))}`;
183
+ };
184
+ /**
185
+ * 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.
186
+ * @summary Update a Tenant
187
+ */
188
+ const updateTenant = (id, updateTenantInput, options) => {
189
+ const getHeaders = (h) => {
190
+ if (!h) return {};
191
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
192
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
193
+ const headers = {};
194
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
195
+ return headers;
196
+ };
197
+ return astralBeamApiFetch(getUpdateTenantUrl(id), {
198
+ ...options,
199
+ method: "PATCH",
200
+ headers: {
201
+ "Content-Type": "application/json",
202
+ ...getHeaders(options?.headers)
203
+ },
204
+ body: JSON.stringify(updateTenantInput)
205
+ });
206
+ };
207
+ const getListUsersForTenantUrl = (tenantId, params) => {
208
+ const normalizedParams = new URLSearchParams();
209
+ Object.entries(params || {}).forEach(([key, value]) => {
210
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
211
+ });
212
+ const stringifiedParams = normalizedParams.toString();
213
+ return stringifiedParams.length > 0 ? `/api/v1/tenants/${encodeURIComponent(String(tenantId))}/tenant_users?${stringifiedParams}` : `/api/v1/tenants/${encodeURIComponent(String(tenantId))}/tenant_users`;
214
+ };
215
+ /**
216
+ * 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.
217
+ * @summary List TenantUsers
218
+ */
219
+ const listUsersForTenant = (tenantId, params, options) => {
220
+ return astralBeamApiFetch(getListUsersForTenantUrl(tenantId, params), {
221
+ ...options,
222
+ method: "GET"
223
+ });
224
+ };
225
+ const getCreateTenantUserUrl = (tenantId) => {
226
+ return `/api/v1/tenants/${encodeURIComponent(String(tenantId))}/tenant_users`;
227
+ };
228
+ /**
229
+ * 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.
230
+ * @summary Create a TenantUser
231
+ */
232
+ const createTenantUser = (tenantId, createTenantUserInput, options) => {
233
+ const getHeaders = (h) => {
234
+ if (!h) return {};
235
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
236
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
237
+ const headers = {};
238
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
239
+ return headers;
240
+ };
241
+ return astralBeamApiFetch(getCreateTenantUserUrl(tenantId), {
242
+ ...options,
243
+ method: "POST",
244
+ headers: {
245
+ "Content-Type": "application/json",
246
+ ...getHeaders(options?.headers)
247
+ },
248
+ body: JSON.stringify(createTenantUserInput)
249
+ });
250
+ };
251
+ const getGetTenantUserUrl = (tenantId, id) => {
252
+ return `/api/v1/tenants/${encodeURIComponent(String(tenantId))}/tenant_users/${encodeURIComponent(String(id))}`;
253
+ };
254
+ /**
255
+ * Get a TenantUser by the internal tenant_id and id pair within the authorized scope. No identity upsert.
256
+ * @summary Get a TenantUser
257
+ */
258
+ const getTenantUser = (tenantId, id, options) => {
259
+ return astralBeamApiFetch(getGetTenantUserUrl(tenantId, id), {
260
+ ...options,
261
+ method: "GET"
262
+ });
263
+ };
264
+ const getUpdateTenantUserUrl = (tenantId, id) => {
265
+ return `/api/v1/tenants/${encodeURIComponent(String(tenantId))}/tenant_users/${encodeURIComponent(String(id))}`;
266
+ };
267
+ /**
268
+ * 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.
269
+ * @summary Update a TenantUser
270
+ */
271
+ const updateTenantUser = (tenantId, id, updateTenantUserInput, options) => {
272
+ const getHeaders = (h) => {
273
+ if (!h) return {};
274
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
275
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
276
+ const headers = {};
277
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
278
+ return headers;
279
+ };
280
+ return astralBeamApiFetch(getUpdateTenantUserUrl(tenantId, id), {
281
+ ...options,
282
+ method: "PATCH",
283
+ headers: {
284
+ "Content-Type": "application/json",
285
+ ...getHeaders(options?.headers)
286
+ },
287
+ body: JSON.stringify(updateTenantUserInput)
288
+ });
289
+ };
290
+ const getGetOrganizationUrl = () => {
291
+ return `/api/v1/organization`;
292
+ };
293
+ /**
294
+ * 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.
295
+ * @summary Get the current Organization
296
+ */
297
+ const getOrganization = (options) => {
298
+ return astralBeamApiFetch(getGetOrganizationUrl(), {
299
+ ...options,
300
+ method: "GET"
301
+ });
302
+ };
303
+ const getListThreadsUrl = (params) => {
304
+ const normalizedParams = new URLSearchParams();
305
+ Object.entries(params || {}).forEach(([key, value]) => {
306
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
307
+ });
308
+ const stringifiedParams = normalizedParams.toString();
309
+ return stringifiedParams.length > 0 ? `/api/v1/threads?${stringifiedParams}` : `/api/v1/threads`;
310
+ };
311
+ /**
312
+ * List nonempty conversations by activity, Tenant ID and thread ID descending. q searches titles as a case-insensitive literal substring. filter[tenant_id] narrows the verified scope. Keep filters unchanged when reusing cursors. This is a live listing, not a snapshot.
313
+ * @summary List conversations for administration
314
+ */
315
+ const listThreads = (params, options) => {
316
+ return astralBeamApiFetch(getListThreadsUrl(params), {
317
+ ...options,
318
+ method: "GET"
319
+ });
320
+ };
321
+ const getListThreadMessagesUrl = (tenantId, id, params) => {
322
+ const normalizedParams = new URLSearchParams();
323
+ Object.entries(params || {}).forEach(([key, value]) => {
324
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
325
+ });
326
+ const stringifiedParams = normalizedParams.toString();
327
+ return stringifiedParams.length > 0 ? `/api/v1/tenants/${encodeURIComponent(String(tenantId))}/threads/${encodeURIComponent(String(id))}/messages?${stringifiedParams}` : `/api/v1/tenants/${encodeURIComponent(String(tenantId))}/threads/${encodeURIComponent(String(id))}/messages`;
328
+ };
329
+ /**
330
+ * @summary Read conversation history for administration
331
+ */
332
+ const listThreadMessages = (tenantId, id, params, options) => {
333
+ return astralBeamApiFetch(getListThreadMessagesUrl(tenantId, id, params), {
334
+ ...options,
335
+ method: "GET"
336
+ });
337
+ };
338
+ const getGetThreadAttachmentUrl = (tenantId, id, messageId, partId) => {
339
+ return `/api/v1/tenants/${encodeURIComponent(String(tenantId))}/threads/${encodeURIComponent(String(id))}/messages/${encodeURIComponent(String(messageId))}/attachments/${encodeURIComponent(String(partId))}`;
340
+ };
341
+ /**
342
+ * @summary Download a saved conversation upload for administration
343
+ */
344
+ const getThreadAttachment = (tenantId, id, messageId, partId, options) => {
345
+ return astralBeamResourceFetch(getGetThreadAttachmentUrl(tenantId, id, messageId, partId), {
346
+ ...options,
347
+ method: "GET"
348
+ });
349
+ };
350
+ const getRunChatUrl = () => {
351
+ return `/api/v1/chat`;
352
+ };
353
+ /**
354
+ * Save one new user message and stream an AG-UI agent run for a conversation participant using a synchronized tenant user JWT. An optional Idempotency-Key retains acceptance for 24 hours. An identical retry returns an application/json admission receipt without generation. Changed input under the same key returns 400 and simultaneous use returns 409. HTTP failures before streaming use AstralBeamApiError. Once streaming starts, failures use RUN_ERROR events. Submit tool results to the conversation's tool-results endpoint. Disconnecting cancels the foreground run and preserves saved history. Limited to 20 new turns per minute per organization, tenant, and user.
355
+ * @summary Run chat
356
+ */
357
+ const runChat = (chatRunInput, options) => {
358
+ const getHeaders = (h) => {
359
+ if (!h) return {};
360
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
361
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
362
+ const headers = {};
363
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
364
+ return headers;
365
+ };
366
+ return astralBeamChatFetch(getRunChatUrl(), {
367
+ ...options,
368
+ method: "POST",
369
+ headers: {
370
+ "Content-Type": "application/json",
371
+ ...getHeaders(options?.headers)
372
+ },
373
+ body: JSON.stringify(chatRunInput)
374
+ });
375
+ };
376
+ const getGetChatConfigUrl = (params) => {
377
+ const normalizedParams = new URLSearchParams();
378
+ Object.entries(params || {}).forEach(([key, value]) => {
379
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
380
+ });
381
+ const stringifiedParams = normalizedParams.toString();
382
+ return stringifiedParams.length > 0 ? `/api/v1/chat/config?${stringifiedParams}` : `/api/v1/chat/config`;
383
+ };
384
+ /**
385
+ * 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.
386
+ * @summary Get chat capabilities
387
+ */
388
+ const getChatConfig = (params, options) => {
389
+ return astralBeamJwtFetch(getGetChatConfigUrl(params), {
390
+ ...options,
391
+ method: "GET"
392
+ });
393
+ };
394
+ const getGetChatFileUrl = (params) => {
395
+ const normalizedParams = new URLSearchParams();
396
+ Object.entries(params || {}).forEach(([key, value]) => {
397
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
398
+ });
399
+ const stringifiedParams = normalizedParams.toString();
400
+ return stringifiedParams.length > 0 ? `/api/v1/chat/files?${stringifiedParams}` : `/api/v1/chat/files`;
401
+ };
402
+ /**
403
+ * 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.
404
+ * @summary Download a chat artifact
405
+ */
406
+ const getChatFile = (params, options) => {
407
+ return astralBeamFileFetch(getGetChatFileUrl(params), {
408
+ ...options,
409
+ method: "GET"
410
+ });
411
+ };
412
+ const getCreateChatThreadUrl = () => {
413
+ return `/api/v1/chat/threads`;
414
+ };
415
+ /**
416
+ * @summary Create a saved conversation
417
+ */
418
+ const createChatThread = (createChatThreadInputEncoded, options) => {
419
+ const getHeaders = (h) => {
420
+ if (!h) return {};
421
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
422
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
423
+ const headers = {};
424
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
425
+ return headers;
426
+ };
427
+ return astralBeamJwtFetch(getCreateChatThreadUrl(), {
428
+ ...options,
429
+ method: "POST",
430
+ headers: {
431
+ "Content-Type": "application/json",
432
+ ...getHeaders(options?.headers)
433
+ },
434
+ body: JSON.stringify(createChatThreadInputEncoded)
435
+ });
436
+ };
437
+ const getListChatThreadsUrl = (params) => {
438
+ const normalizedParams = new URLSearchParams();
439
+ Object.entries(params || {}).forEach(([key, value]) => {
440
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
441
+ });
442
+ const stringifiedParams = normalizedParams.toString();
443
+ return stringifiedParams.length > 0 ? `/api/v1/chat/threads?${stringifiedParams}` : `/api/v1/chat/threads`;
444
+ };
445
+ /**
446
+ * @summary List your conversations
447
+ */
448
+ const listChatThreads = (params, options) => {
449
+ return astralBeamJwtFetch(getListChatThreadsUrl(params), {
450
+ ...options,
451
+ method: "GET"
452
+ });
453
+ };
454
+ const getGetChatThreadUrl = (id) => {
455
+ return `/api/v1/chat/threads/${encodeURIComponent(String(id))}`;
456
+ };
457
+ /**
458
+ * @summary Get a saved conversation
459
+ */
460
+ const getChatThread = (id, options) => {
461
+ return astralBeamJwtFetch(getGetChatThreadUrl(id), {
462
+ ...options,
463
+ method: "GET"
464
+ });
465
+ };
466
+ const getUpdateChatThreadUrl = (id) => {
467
+ return `/api/v1/chat/threads/${encodeURIComponent(String(id))}`;
468
+ };
469
+ /**
470
+ * @summary Rename a conversation
471
+ */
472
+ const updateChatThread = (id, updateChatThreadInputEncoded, options) => {
473
+ const getHeaders = (h) => {
474
+ if (!h) return {};
475
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
476
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
477
+ const headers = {};
478
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
479
+ return headers;
480
+ };
481
+ return astralBeamJwtFetch(getUpdateChatThreadUrl(id), {
482
+ ...options,
483
+ method: "PATCH",
484
+ headers: {
485
+ "Content-Type": "application/json",
486
+ ...getHeaders(options?.headers)
487
+ },
488
+ body: JSON.stringify(updateChatThreadInputEncoded)
489
+ });
490
+ };
491
+ const getDeleteChatThreadUrl = (id, params) => {
492
+ const normalizedParams = new URLSearchParams();
493
+ Object.entries(params || {}).forEach(([key, value]) => {
494
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
495
+ });
496
+ const stringifiedParams = normalizedParams.toString();
497
+ return stringifiedParams.length > 0 ? `/api/v1/chat/threads/${encodeURIComponent(String(id))}?${stringifiedParams}` : `/api/v1/chat/threads/${encodeURIComponent(String(id))}`;
498
+ };
499
+ /**
500
+ * @summary Delete a conversation
501
+ */
502
+ const deleteChatThread = (id, params, options) => {
503
+ return astralBeamJwtFetch(getDeleteChatThreadUrl(id, params), {
504
+ ...options,
505
+ method: "DELETE"
506
+ });
507
+ };
508
+ const getListChatMessagesUrl = (id, params) => {
509
+ const normalizedParams = new URLSearchParams();
510
+ Object.entries(params || {}).forEach(([key, value]) => {
511
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
512
+ });
513
+ const stringifiedParams = normalizedParams.toString();
514
+ return stringifiedParams.length > 0 ? `/api/v1/chat/threads/${encodeURIComponent(String(id))}/messages?${stringifiedParams}` : `/api/v1/chat/threads/${encodeURIComponent(String(id))}/messages`;
515
+ };
516
+ /**
517
+ * @summary Read conversation history
518
+ */
519
+ const listChatMessages = (id, params, options) => {
520
+ return astralBeamJwtFetch(getListChatMessagesUrl(id, params), {
521
+ ...options,
522
+ method: "GET"
523
+ });
524
+ };
525
+ const getListChatParticipantsUrl = (id, params) => {
526
+ const normalizedParams = new URLSearchParams();
527
+ Object.entries(params || {}).forEach(([key, value]) => {
528
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
529
+ });
530
+ const stringifiedParams = normalizedParams.toString();
531
+ return stringifiedParams.length > 0 ? `/api/v1/chat/threads/${encodeURIComponent(String(id))}/participants?${stringifiedParams}` : `/api/v1/chat/threads/${encodeURIComponent(String(id))}/participants`;
532
+ };
533
+ /**
534
+ * @summary List conversation participants
535
+ */
536
+ const listChatParticipants = (id, params, options) => {
537
+ return astralBeamJwtFetch(getListChatParticipantsUrl(id, params), {
538
+ ...options,
539
+ method: "GET"
540
+ });
541
+ };
542
+ const getSearchChatTenantUsersUrl = (id, params) => {
543
+ const normalizedParams = new URLSearchParams();
544
+ Object.entries(params || {}).forEach(([key, value]) => {
545
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
546
+ });
547
+ const stringifiedParams = normalizedParams.toString();
548
+ return stringifiedParams.length > 0 ? `/api/v1/chat/threads/${encodeURIComponent(String(id))}/tenant-users?${stringifiedParams}` : `/api/v1/chat/threads/${encodeURIComponent(String(id))}/tenant-users`;
549
+ };
550
+ /**
551
+ * Requires a conversation manager. Searches names and external IDs within the conversation's Tenant. Returns only identity and display fields, without user metadata or administrative flags.
552
+ * @summary Search same-Tenant users for sharing
553
+ */
554
+ const searchChatTenantUsers = (id, params, options) => {
555
+ return astralBeamJwtFetch(getSearchChatTenantUsersUrl(id, params), {
556
+ ...options,
557
+ method: "GET"
558
+ });
559
+ };
560
+ const getSetChatParticipantUrl = (id, tenantUserId) => {
561
+ return `/api/v1/chat/threads/${encodeURIComponent(String(id))}/participants/${encodeURIComponent(String(tenantUserId))}`;
562
+ };
563
+ /**
564
+ * @summary Add a participant or change their role
565
+ */
566
+ const setChatParticipant = (id, tenantUserId, setChatParticipantInputEncoded, options) => {
567
+ const getHeaders = (h) => {
568
+ if (!h) return {};
569
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
570
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
571
+ const headers = {};
572
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
573
+ return headers;
574
+ };
575
+ return astralBeamJwtFetch(getSetChatParticipantUrl(id, tenantUserId), {
576
+ ...options,
577
+ method: "PUT",
578
+ headers: {
579
+ "Content-Type": "application/json",
580
+ ...getHeaders(options?.headers)
581
+ },
582
+ body: JSON.stringify(setChatParticipantInputEncoded)
583
+ });
584
+ };
585
+ const getRemoveChatParticipantUrl = (id, tenantUserId, params) => {
586
+ const normalizedParams = new URLSearchParams();
587
+ Object.entries(params || {}).forEach(([key, value]) => {
588
+ if (value !== void 0) normalizedParams.append(key, value === null ? "null" : String(value));
589
+ });
590
+ const stringifiedParams = normalizedParams.toString();
591
+ return stringifiedParams.length > 0 ? `/api/v1/chat/threads/${encodeURIComponent(String(id))}/participants/${encodeURIComponent(String(tenantUserId))}?${stringifiedParams}` : `/api/v1/chat/threads/${encodeURIComponent(String(id))}/participants/${encodeURIComponent(String(tenantUserId))}`;
592
+ };
593
+ /**
594
+ * @summary Remove a conversation participant
595
+ */
596
+ const removeChatParticipant = (id, tenantUserId, params, options) => {
597
+ return astralBeamJwtFetch(getRemoveChatParticipantUrl(id, tenantUserId, params), {
598
+ ...options,
599
+ method: "DELETE"
600
+ });
601
+ };
602
+ const getResolveChatToolResultUrl = (id) => {
603
+ return `/api/v1/chat/threads/${encodeURIComponent(String(id))}/tool-results`;
604
+ };
605
+ /**
606
+ * @summary Submit a pending tool result
607
+ */
608
+ const resolveChatToolResult = (id, resolveChatToolResultInputEncoded, options) => {
609
+ const getHeaders = (h) => {
610
+ if (!h) return {};
611
+ if (h instanceof Headers) return Object.fromEntries(h.entries());
612
+ if (Symbol.iterator in h) return Object.fromEntries(Array.from(h, (entry) => Array.from(entry)));
613
+ const headers = {};
614
+ for (const [name, value] of Object.entries(h)) if (value !== void 0) headers[name] = value;
615
+ return headers;
616
+ };
617
+ return astralBeamChatFetch(getResolveChatToolResultUrl(id), {
618
+ ...options,
619
+ method: "POST",
620
+ headers: {
621
+ "Content-Type": "application/json",
622
+ ...getHeaders(options?.headers)
623
+ },
624
+ body: JSON.stringify(resolveChatToolResultInputEncoded)
625
+ });
626
+ };
627
+ const getGetChatAttachmentUrl = (id, messageId, partId) => {
628
+ return `/api/v1/chat/threads/${encodeURIComponent(String(id))}/messages/${encodeURIComponent(String(messageId))}/attachments/${encodeURIComponent(String(partId))}`;
629
+ };
630
+ /**
631
+ * @summary Download a saved attachment
632
+ */
633
+ const getChatAttachment = (id, messageId, partId, options) => {
634
+ return astralBeamChatFetch(getGetChatAttachmentUrl(id, messageId, partId), {
635
+ ...options,
636
+ method: "GET"
637
+ });
638
+ };
639
+ const getGetCurrentUserUrl = () => {
640
+ return `/api/v1/me`;
641
+ };
642
+ /**
643
+ * 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.
644
+ * @summary Get the current user
645
+ */
646
+ const getCurrentUser = (options) => {
647
+ return astralBeamJwtFetch(getGetCurrentUserUrl(), {
648
+ ...options,
649
+ method: "POST"
650
+ });
651
+ };
652
+ //#endregion
653
+ export { listChatMessages as $, getGetOrganizationUrl as A, getListUsersForTenantUrl as B, getCurrentUser as C, getGetChatFileUrl as D, getGetChatConfigUrl as E, getListChatParticipantsUrl as F, getSearchChatTenantUsersUrl as G, getRemoveChatParticipantUrl as H, getListChatThreadsUrl as I, getTenantUser as J, getSetChatParticipantUrl as K, getListTenantsUrl as L, getGetTenantUserUrl as M, getGetThreadAttachmentUrl as N, getGetChatThreadUrl as O, getListChatMessagesUrl as P, getUpdateTenantUserUrl as Q, getListThreadMessagesUrl as R, getCreateTenantUserUrl as S, getGetChatAttachmentUrl as T, getResolveChatToolResultUrl as U, getOrganization as V, getRunChatUrl as W, getUpdateChatThreadUrl as X, getThreadAttachment as Y, getUpdateTenantUrl as Z, getChatConfig as _, DEFAULT_API_URL as _t, ChatMessageEncodedRole as a, listUsersForTenant as at, getCreateChatThreadUrl as b, ChatThreadEncodedRole as c, runChat as ct, SetChatParticipantInputEncodedRole as d, updateChatThread as dt, listChatParticipants as et, createChatThread as f, updateTenant as ft, getChatAttachment as g, resolveApiUrl as gt, deleteChatThread as h, isAstralBeamApiError as ht, ChatHistoryPageEncodedThreadRole as i, listThreads as it, getGetTenantUrl as j, getGetCurrentUserUrl as k, ListUsersForTenantFilterAdmin as l, searchChatTenantUsers as lt, createTenantUser as m, astralBeamChatFetch as mt, ChatHistoryPageEncodedMessagesItemState as n, listTenants as nt, ChatMessageEncodedState as o, removeChatParticipant as ot, createTenant as p, updateTenantUser as pt, getTenant as q, ChatHistoryPageEncodedPendingInteractionsItemExecutionLocation as r, listThreadMessages as rt, ChatParticipantEncodedRole as s, resolveChatToolResult as st, ChatHistoryPageEncodedMessagesItemRole as t, listChatThreads as tt, ResolveChatToolResultInputEncodedResultsItemOutcome as u, setChatParticipant as ut, getChatFile as v, DEFAULT_CHAT_AUTH_TOKEN_URL as vt, getDeleteChatThreadUrl as w, getCreateTenantUrl as x, getChatThread as y, DEFAULT_COLOR_SCHEME as yt, getListThreadsUrl as z };
package/dist/api.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as updateTenant, A as createTenantUser, B as getGetTenantUrl, C as TenantUserRecordEncoded, D as UpdateTenantUserInput, E as UpdateTenantInputMetadata, F as getCurrentUser, G as getRunChatUrl, H as getListTenantsUrl, I as getGetChatConfigUrl, J as getUpdateTenantUrl, K as getTenant, L as getGetChatFileUrl, M as getChatFile, N as getCreateTenantUrl, O as UpdateTenantUserInputMetadata, P as getCreateTenantUserUrl, Q as runChat, R as getGetCurrentUserUrl, S as TenantUserPage, T as UpdateTenantInput, U as getListUsersForTenantUrl, V as getGetTenantUserUrl, W as getOrganization, X as listTenants, Y as getUpdateTenantUserUrl, Z as listUsersForTenant, _ as ListUsersForTenantParams, a as ChatRunInput, at as FileOptions, b as TenantRecordEncoded, c as CreateTenantInput, d as CreateTenantUserInputMetadata, et as updateTenantUser, f as CurrentUser, g as ListUsersForTenantFilterAdmin, h as ListTenantsParams, i as ChatConfigurationCapabilities, it as AstralBeamApiError, j as getChatConfig, k as createTenant, l as CreateTenantInputMetadata, m as GetChatFileParams, n as AstralBeamApiErrorIssuesItem, nt as ApiOptions, o as ChatRunInputData, ot as JwtOptions, p as GetChatConfigParams, q as getTenantUser, r as ChatConfiguration, rt as ApiRequestOptions, s as ChatRunInputForwardedProps, st as isAstralBeamApiError, t as AstralBeamApiError$1, tt as ApiKeyOptions, u as CreateTenantUserInput, v as Organization, w as TenantUserRecordEncodedMetadata, x as TenantRecordEncodedMetadata, y as TenantPage, z as getGetOrganizationUrl } from "./api-DUe8JSVU.js";
2
- export { type ApiKeyOptions, type ApiOptions, type ApiRequestOptions, AstralBeamApiError, type AstralBeamApiError$1 as AstralBeamApiErrorBody, AstralBeamApiErrorIssuesItem, ChatConfiguration, ChatConfigurationCapabilities, ChatRunInput, ChatRunInputData, ChatRunInputForwardedProps, CreateTenantInput, CreateTenantInputMetadata, CreateTenantUserInput, CreateTenantUserInputMetadata, CurrentUser, type FileOptions, GetChatConfigParams, GetChatFileParams, type JwtOptions, ListTenantsParams, ListUsersForTenantFilterAdmin, ListUsersForTenantParams, Organization, TenantPage, TenantRecordEncoded, TenantRecordEncodedMetadata, TenantUserPage, TenantUserRecordEncoded, TenantUserRecordEncodedMetadata, UpdateTenantInput, UpdateTenantInputMetadata, UpdateTenantUserInput, UpdateTenantUserInputMetadata, createTenant, createTenantUser, getChatConfig, getChatFile, getCreateTenantUrl, getCreateTenantUserUrl, getCurrentUser, getGetChatConfigUrl, getGetChatFileUrl, getGetCurrentUserUrl, getGetOrganizationUrl, getGetTenantUrl, getGetTenantUserUrl, getListTenantsUrl, getListUsersForTenantUrl, getOrganization, getRunChatUrl, getTenant, getTenantUser, getUpdateTenantUrl, getUpdateTenantUserUrl, isAstralBeamApiError, listTenants, listUsersForTenant, runChat, updateTenant, updateTenantUser };
1
+ import { $ as ResolveChatToolResultInputEncoded, $t as getThreadAttachment, A as CreateChatThreadInputEncoded, At as getGetChatConfigUrl, B as DirectoryThreadPage, Bt as getListChatThreadsUrl, C as ChatRunInputForwardedProps, Cn as JwtOptions, Ct as getChatThread, D as ChatThreadEncoded, Dt as getCurrentUser, E as ChatTenantUserPage, Et as getCreateTenantUserUrl, F as CurrentUser, Ft as getGetTenantUrl, G as ListChatThreadsParams, Gt as getOrganization, H as GetChatFileParams, Ht as getListThreadMessagesUrl, I as DeleteChatThreadParams, It as getGetTenantUserUrl, J as ListThreadsParams, Jt as getRunChatUrl, K as ListTenantsParams, Kt as getRemoveChatParticipantUrl, L as DirectoryThreadEncoded, Lt as getGetThreadAttachmentUrl, M as CreateTenantInputMetadata, Mt as getGetChatThreadUrl, N as CreateTenantUserInput, Nt as getGetCurrentUserUrl, O as ChatThreadEncodedRole, Ot as getDeleteChatThreadUrl, P as CreateTenantUserInputMetadata, Pt as getGetOrganizationUrl, Q as RemoveChatParticipantParams, Qt as getTenantUser, R as DirectoryThreadEncodedParticipantsItem, Rt as getListChatMessagesUrl, S as ChatRunInputData, Sn as FileOptions, St as getChatFile, T as ChatTenantUserEncoded, Tt as getCreateTenantUrl, U as ListChatMessagesParams, Ut as getListThreadsUrl, V as GetChatConfigParams, Vt as getListTenantsUrl, W as ListChatParticipantsParams, Wt as getListUsersForTenantUrl, X as ListUsersForTenantParams, Xt as getSetChatParticipantUrl, Y as ListUsersForTenantFilterAdmin, Yt as getSearchChatTenantUsersUrl, Z as Organization, Zt as getTenant, _ as ChatMessageEncodedState, _n as updateTenantUser, _t as createTenant, a as ChatHistoryPageEncoded, an as listChatThreads, at as TenantPage, b as ChatParticipantPage, bn as ApiRequestOptions, bt as getChatAttachment, c as ChatHistoryPageEncodedMessagesItemRole, cn as listThreads, ct as TenantUserPage, d as ChatHistoryPageEncodedPendingInteractionsItemExecutionLocation, dn as resolveChatToolResult, dt as UpdateChatThreadInputEncoded, en as getUpdateChatThreadUrl, et as ResolveChatToolResultInputEncodedResultsItem, f as ChatHistoryPageEncodedThread, fn as runChat, ft as UpdateTenantInput, g as ChatMessageEncodedRole, gn as updateTenant, gt as createChatThread, h as ChatMessageEncodedPartsItem, hn as updateChatThread, ht as UpdateTenantUserInputMetadata, i as ChatConfigurationCapabilities, in as listChatParticipants, it as SetChatParticipantInputEncodedRole, j as CreateTenantInput, jt as getGetChatFileUrl, k as ChatThreadPage, kt as getGetChatAttachmentUrl, l as ChatHistoryPageEncodedMessagesItemState, ln as listUsersForTenant, lt as TenantUserRecordEncoded, m as ChatMessageEncoded, mn as setChatParticipant, mt as UpdateTenantUserInput, n as AstralBeamApiErrorIssuesItem, nn as getUpdateTenantUserUrl, nt as SearchChatTenantUsersParams, o as ChatHistoryPageEncodedMessagesItem, on as listTenants, ot as TenantRecordEncoded, p as ChatHistoryPageEncodedThreadRole, pn as searchChatTenantUsers, pt as UpdateTenantInputMetadata, q as ListThreadMessagesParams, qt as getResolveChatToolResultUrl, r as ChatConfiguration, rn as listChatMessages, rt as SetChatParticipantInputEncoded, s as ChatHistoryPageEncodedMessagesItemPartsItem, sn as listThreadMessages, st as TenantRecordEncodedMetadata, t as AstralBeamApiError$1, tn as getUpdateTenantUrl, tt as ResolveChatToolResultInputEncodedResultsItemOutcome, u as ChatHistoryPageEncodedPendingInteractionsItem, un as removeChatParticipant, ut as TenantUserRecordEncodedMetadata, v as ChatParticipantEncoded, vn as ApiKeyOptions, vt as createTenantUser, w as ChatSubmissionReceiptEncoded, wn as isAstralBeamApiError, wt as getCreateChatThreadUrl, x as ChatRunInput, xn as AstralBeamApiError, xt as getChatConfig, y as ChatParticipantEncodedRole, yn as ApiOptions, yt as deleteChatThread, z as DirectoryThreadHistoryPage, zt as getListChatParticipantsUrl } from "./index-CH3RVjha.js";
2
+ export { type ApiKeyOptions, type ApiOptions, type ApiRequestOptions, AstralBeamApiError, type AstralBeamApiError$1 as AstralBeamApiErrorBody, AstralBeamApiErrorIssuesItem, ChatConfiguration, ChatConfigurationCapabilities, ChatHistoryPageEncoded, ChatHistoryPageEncodedMessagesItem, ChatHistoryPageEncodedMessagesItemPartsItem, ChatHistoryPageEncodedMessagesItemRole, ChatHistoryPageEncodedMessagesItemState, ChatHistoryPageEncodedPendingInteractionsItem, ChatHistoryPageEncodedPendingInteractionsItemExecutionLocation, ChatHistoryPageEncodedThread, ChatHistoryPageEncodedThreadRole, ChatMessageEncoded, ChatMessageEncodedPartsItem, ChatMessageEncodedRole, ChatMessageEncodedState, ChatParticipantEncoded, ChatParticipantEncodedRole, ChatParticipantPage, ChatRunInput, ChatRunInputData, ChatRunInputForwardedProps, ChatSubmissionReceiptEncoded, ChatTenantUserEncoded, ChatTenantUserPage, ChatThreadEncoded, ChatThreadEncodedRole, ChatThreadPage, CreateChatThreadInputEncoded, CreateTenantInput, CreateTenantInputMetadata, CreateTenantUserInput, CreateTenantUserInputMetadata, CurrentUser, DeleteChatThreadParams, DirectoryThreadEncoded, DirectoryThreadEncodedParticipantsItem, DirectoryThreadHistoryPage, DirectoryThreadPage, type FileOptions, GetChatConfigParams, GetChatFileParams, type JwtOptions, ListChatMessagesParams, ListChatParticipantsParams, ListChatThreadsParams, ListTenantsParams, ListThreadMessagesParams, ListThreadsParams, ListUsersForTenantFilterAdmin, ListUsersForTenantParams, Organization, RemoveChatParticipantParams, ResolveChatToolResultInputEncoded, ResolveChatToolResultInputEncodedResultsItem, ResolveChatToolResultInputEncodedResultsItemOutcome, SearchChatTenantUsersParams, SetChatParticipantInputEncoded, SetChatParticipantInputEncodedRole, TenantPage, TenantRecordEncoded, TenantRecordEncodedMetadata, TenantUserPage, TenantUserRecordEncoded, TenantUserRecordEncodedMetadata, UpdateChatThreadInputEncoded, UpdateTenantInput, UpdateTenantInputMetadata, UpdateTenantUserInput, UpdateTenantUserInputMetadata, createChatThread, createTenant, createTenantUser, deleteChatThread, getChatAttachment, getChatConfig, getChatFile, getChatThread, getCreateChatThreadUrl, getCreateTenantUrl, getCreateTenantUserUrl, getCurrentUser, getDeleteChatThreadUrl, getGetChatAttachmentUrl, getGetChatConfigUrl, getGetChatFileUrl, getGetChatThreadUrl, getGetCurrentUserUrl, getGetOrganizationUrl, getGetTenantUrl, getGetTenantUserUrl, getGetThreadAttachmentUrl, getListChatMessagesUrl, getListChatParticipantsUrl, getListChatThreadsUrl, getListTenantsUrl, getListThreadMessagesUrl, getListThreadsUrl, getListUsersForTenantUrl, getOrganization, getRemoveChatParticipantUrl, getResolveChatToolResultUrl, getRunChatUrl, getSearchChatTenantUsersUrl, getSetChatParticipantUrl, getTenant, getTenantUser, getThreadAttachment, getUpdateChatThreadUrl, getUpdateTenantUrl, getUpdateTenantUserUrl, isAstralBeamApiError, listChatMessages, listChatParticipants, listChatThreads, listTenants, listThreadMessages, listThreads, listUsersForTenant, removeChatParticipant, resolveChatToolResult, runChat, searchChatTenantUsers, setChatParticipant, updateChatThread, updateTenant, updateTenantUser };