lemma-sdk 0.2.19 → 0.2.21
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 +71 -33
- package/dist/auth.d.ts +42 -1
- package/dist/auth.js +43 -0
- package/dist/browser/lemma-client.js +49 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/namespaces/assistants.d.ts +2 -0
- package/dist/namespaces/assistants.js +3 -0
- package/dist/openapi_client/index.d.ts +3 -0
- package/dist/openapi_client/index.js +1 -0
- package/dist/openapi_client/models/AvailableModelInfo.d.ts +8 -0
- package/dist/openapi_client/models/AvailableModelInfo.js +1 -0
- package/dist/openapi_client/models/AvailableModels.d.ts +3 -4
- package/dist/openapi_client/models/AvailableModels.js +2 -3
- package/dist/openapi_client/models/AvailableModelsListResponse.d.ts +7 -0
- package/dist/openapi_client/models/AvailableModelsListResponse.js +1 -0
- package/dist/openapi_client/models/BulkCreateRecordsRequest.d.ts +4 -0
- package/dist/openapi_client/models/CreateFunctionRequest.d.ts +2 -0
- package/dist/openapi_client/models/FunctionResponse.d.ts +2 -0
- package/dist/openapi_client/models/FunctionRunResponse.d.ts +4 -0
- package/dist/openapi_client/models/FunctionType.d.ts +7 -0
- package/dist/openapi_client/models/FunctionType.js +12 -0
- package/dist/openapi_client/models/UpdateFunctionRequest.d.ts +2 -0
- package/dist/openapi_client/services/ConversationsService.d.ts +8 -0
- package/dist/openapi_client/services/ConversationsService.js +12 -0
- package/dist/react/components/AssistantChrome.js +13 -23
- package/dist/react/components/AssistantExperience.d.ts +12 -4
- package/dist/react/components/AssistantExperience.js +40 -40
- package/dist/react/components/assistant-types.d.ts +7 -0
- package/dist/react/index.d.ts +3 -3
- package/dist/react/index.js +1 -1
- package/dist/react/styles.css +1246 -5
- package/dist/react/useAssistantController.d.ts +2 -1
- package/dist/react/useAssistantController.js +34 -1
- package/dist/react/useAssistantRuntime.js +25 -4
- package/dist/react/useAssistantSession.js +14 -5
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -108,7 +108,12 @@ const assistantPayload: CreateAssistantInput = {
|
|
|
108
108
|
## Auth Helpers
|
|
109
109
|
|
|
110
110
|
```ts
|
|
111
|
-
import {
|
|
111
|
+
import {
|
|
112
|
+
LemmaClient,
|
|
113
|
+
buildAuthUrl,
|
|
114
|
+
buildFederatedLogoutUrl,
|
|
115
|
+
resolveSafeRedirectUri,
|
|
116
|
+
} from "lemma-sdk";
|
|
112
117
|
|
|
113
118
|
const client = new LemmaClient({
|
|
114
119
|
apiUrl: "https://api-next.asur.work",
|
|
@@ -131,6 +136,14 @@ await client.auth.signOut();
|
|
|
131
136
|
const token = await client.auth.getAccessToken();
|
|
132
137
|
const refreshed = await client.auth.refreshAccessToken();
|
|
133
138
|
client.auth.redirectToAuth({ mode: "signup", redirectUri: safeRedirect });
|
|
139
|
+
|
|
140
|
+
// Build upstream logout URL (server/client)
|
|
141
|
+
const federatedLogoutUrl = buildFederatedLogoutUrl(client.authUrl, {
|
|
142
|
+
redirectUri: safeRedirect,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
// Browser: sign out locally, then clear upstream SSO and return to app
|
|
146
|
+
await client.auth.redirectToFederatedLogout({ redirectUri: safeRedirect });
|
|
134
147
|
```
|
|
135
148
|
|
|
136
149
|
### Browser Testing With Injected Token
|
|
@@ -179,37 +192,7 @@ Import the bundled stylesheet once anywhere in your app:
|
|
|
179
192
|
import "lemma-sdk/react/styles.css";
|
|
180
193
|
```
|
|
181
194
|
|
|
182
|
-
The stylesheet includes the SDK theme tokens and semantic assistant
|
|
183
|
-
|
|
184
|
-
#### Important for Tailwind apps
|
|
185
|
-
|
|
186
|
-
If your app uses Tailwind and installs `lemma-sdk` from npm, Tailwind must scan the SDK package too. Otherwise the assistant can look half-styled: native file inputs may appear, layouts can collapse, spacing disappears, and buttons/header chrome look wrong.
|
|
187
|
-
|
|
188
|
-
For Tailwind v3, add the SDK package to `content`:
|
|
189
|
-
|
|
190
|
-
```js
|
|
191
|
-
// tailwind.config.js
|
|
192
|
-
export default {
|
|
193
|
-
content: [
|
|
194
|
-
"./index.html",
|
|
195
|
-
"./src/**/*.{js,ts,jsx,tsx}",
|
|
196
|
-
"./node_modules/lemma-sdk/dist/react/**/*.{js,mjs}",
|
|
197
|
-
],
|
|
198
|
-
}
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
If you are developing against a local checkout of the SDK source instead of the published npm package, scan the source files too:
|
|
202
|
-
|
|
203
|
-
```js
|
|
204
|
-
// tailwind.config.js
|
|
205
|
-
export default {
|
|
206
|
-
content: [
|
|
207
|
-
"./index.html",
|
|
208
|
-
"./src/**/*.{js,ts,jsx,tsx}",
|
|
209
|
-
"../lemma-typescript/src/react/**/*.{ts,tsx}",
|
|
210
|
-
],
|
|
211
|
-
}
|
|
212
|
-
```
|
|
195
|
+
The stylesheet includes the SDK theme tokens and the complete semantic assistant UI. The assistant components do not depend on the host app's Tailwind version or Tailwind content scanning.
|
|
213
196
|
|
|
214
197
|
If you alias the package to local SDK source in Vite, make sure the alias points at the React source and stylesheet:
|
|
215
198
|
|
|
@@ -233,7 +216,6 @@ Quick checklist for developers:
|
|
|
233
216
|
- import `lemma-sdk/react/styles.css` once
|
|
234
217
|
- give the assistant container a real height
|
|
235
218
|
- if the assistant is inside flex/grid, add `min-height: 0` on the relevant parent
|
|
236
|
-
- if you use Tailwind, scan the SDK package or SDK source
|
|
237
219
|
- if you use `AssistantEmbedded`, pass `theme` directly there
|
|
238
220
|
- if you use `AssistantExperienceView`, wrap it in `AssistantThemeScope`
|
|
239
221
|
|
|
@@ -244,11 +226,22 @@ The assistant UI renders markdown by default:
|
|
|
244
226
|
- links open safely in a new tab by default
|
|
245
227
|
- lists, tables, blockquotes, inline code, and fenced code blocks are styled out of the box
|
|
246
228
|
|
|
229
|
+
#### Recommended path
|
|
230
|
+
|
|
231
|
+
For most apps, start with `AssistantEmbedded`.
|
|
232
|
+
|
|
233
|
+
- use `AssistantEmbedded` when you want the SDK to handle the controller lifecycle and render the ready-made assistant UI
|
|
234
|
+
- use `AssistantExperienceView` when you still want the SDK's default assistant UI, but you need to own the controller lifecycle yourself
|
|
235
|
+
- use `useAssistantController` plus primitives only when you are intentionally building a custom shell or custom layout
|
|
236
|
+
|
|
237
|
+
If you are unsure, use `AssistantEmbedded` first. It is the path we recommend and the one we expect most SDK consumers to ship.
|
|
238
|
+
|
|
247
239
|
#### Choose an integration level
|
|
248
240
|
|
|
249
241
|
##### 1. `AssistantEmbedded` for the fastest setup
|
|
250
242
|
|
|
251
243
|
Use `AssistantEmbedded` when you want a ready-made assistant surface with the SDK defaults.
|
|
244
|
+
This is the recommended integration for most users.
|
|
252
245
|
|
|
253
246
|
```tsx
|
|
254
247
|
import "lemma-sdk/react/styles.css";
|
|
@@ -264,7 +257,14 @@ function SupportAssistant() {
|
|
|
264
257
|
title="Support Assistant"
|
|
265
258
|
subtitle="Ask questions about this pod."
|
|
266
259
|
placeholder="Message Support Assistant"
|
|
260
|
+
emptyStateSuggestions={[
|
|
261
|
+
{ text: "Summarize this conversation", icon: "✦" },
|
|
262
|
+
{ text: "Help me draft a response", icon: "✎" },
|
|
263
|
+
{ text: "List the next steps", icon: "→" },
|
|
264
|
+
]}
|
|
267
265
|
showConversationList
|
|
266
|
+
showModelPicker={false}
|
|
267
|
+
radius="lg"
|
|
268
268
|
theme="auto"
|
|
269
269
|
/>
|
|
270
270
|
</div>
|
|
@@ -275,13 +275,18 @@ function SupportAssistant() {
|
|
|
275
275
|
Important notes:
|
|
276
276
|
|
|
277
277
|
- `theme` accepts `"auto" | "light" | "dark"`
|
|
278
|
+
- `radius` lets you pick the built-in rounding scale from `"none"` through `"xl"`
|
|
279
|
+
- `showModelPicker={false}` hides the built-in model chooser when you do not want model controls visible
|
|
278
280
|
- `theme="auto"` follows the host app when it uses common selectors like `.dark`, `[data-theme="dark"]`, `[data-mode="dark"]`, and also falls back to `prefers-color-scheme`
|
|
279
281
|
- the parent container must have a real height; if it lives inside flex/grid, `min-height: 0` is usually needed too
|
|
280
282
|
- attachments are queued into the composer and sent with the next message by default
|
|
283
|
+
- `emptyStateSuggestions` lets you replace the built-in prompt chips shown before the first message
|
|
284
|
+
- prefer this component unless you specifically need to own controller state or replace the built-in layout
|
|
281
285
|
|
|
282
286
|
##### 2. `AssistantExperienceView` for the default UI with your own controller
|
|
283
287
|
|
|
284
288
|
Use `AssistantExperienceView` when you want the built-in assistant layout, but you need to own the controller lifecycle yourself.
|
|
289
|
+
This is the second-best default when `AssistantEmbedded` is too opinionated for your integration.
|
|
285
290
|
|
|
286
291
|
```tsx
|
|
287
292
|
import "lemma-sdk/react/styles.css";
|
|
@@ -305,6 +310,11 @@ function ControlledAssistant() {
|
|
|
305
310
|
title="Support Assistant"
|
|
306
311
|
subtitle="Direct use of the default assistant experience."
|
|
307
312
|
placeholder="Message Support Assistant"
|
|
313
|
+
emptyStateSuggestions={[
|
|
314
|
+
{ text: "Summarize the current context" },
|
|
315
|
+
{ text: "Help me write a reply" },
|
|
316
|
+
{ text: "What should I do next?" },
|
|
317
|
+
]}
|
|
308
318
|
showConversationList
|
|
309
319
|
chromeStyle="subtle"
|
|
310
320
|
statusPlacement="inline"
|
|
@@ -319,13 +329,19 @@ Useful props on `AssistantExperienceView`:
|
|
|
319
329
|
- `showConversationList`: show the built-in conversation sidebar
|
|
320
330
|
- `chromeStyle`: `"elevated" | "subtle" | "flat"`
|
|
321
331
|
- `statusPlacement`: `"inline" | "composer" | "none"`
|
|
332
|
+
- `radius`: `"none" | "sm" | "md" | "lg" | "xl"`
|
|
333
|
+
- `showModelPicker`: show or hide the built-in model selector
|
|
334
|
+
- `showNewConversationButton`: show or hide the built-in reset/new-conversation button
|
|
335
|
+
- `emptyStateSuggestions`: replace the built-in generic prompt suggestions used by the default empty state
|
|
322
336
|
- `renderMessageContent`: override markdown rendering for custom message content
|
|
323
337
|
- `renderToolInvocation`: replace the default tool activity renderer
|
|
324
338
|
- `renderPresentedFile` and `renderPendingFile`: customize attachment rendering
|
|
339
|
+
- prefer this over building from primitives if you still want the SDK's default assistant experience
|
|
325
340
|
|
|
326
341
|
##### 3. `useAssistantController` + primitives for a custom shell
|
|
327
342
|
|
|
328
343
|
Use the primitives when you want full control over layout and app chrome.
|
|
344
|
+
This is the advanced path and should be the exception, not the starting point.
|
|
329
345
|
|
|
330
346
|
```tsx
|
|
331
347
|
import "lemma-sdk/react/styles.css";
|
|
@@ -335,6 +351,7 @@ import {
|
|
|
335
351
|
AssistantMessageViewport,
|
|
336
352
|
AssistantShellLayout,
|
|
337
353
|
AssistantThemeScope,
|
|
354
|
+
EmptyState,
|
|
338
355
|
MessageGroup,
|
|
339
356
|
PlanSummaryStrip,
|
|
340
357
|
ThinkingIndicator,
|
|
@@ -369,6 +386,19 @@ function CustomAssistantShell() {
|
|
|
369
386
|
{activeToolBanner ? <div>{activeToolBanner.summary}</div> : null}
|
|
370
387
|
|
|
371
388
|
<AssistantMessageViewport>
|
|
389
|
+
{assistant.messages.length === 0 ? (
|
|
390
|
+
<EmptyState
|
|
391
|
+
suggestions={[
|
|
392
|
+
{ text: "Summarize this for me" },
|
|
393
|
+
{ text: "Help me draft a reply" },
|
|
394
|
+
{ text: "Brainstorm next steps" },
|
|
395
|
+
]}
|
|
396
|
+
onSendMessage={(text) => {
|
|
397
|
+
void assistant.sendMessage(text);
|
|
398
|
+
}}
|
|
399
|
+
/>
|
|
400
|
+
) : null}
|
|
401
|
+
|
|
372
402
|
{rows.map((row, index) => (
|
|
373
403
|
<MessageGroup
|
|
374
404
|
key={row.id}
|
|
@@ -411,6 +441,14 @@ Useful primitives exported from `lemma-sdk/react`:
|
|
|
411
441
|
- `PlanSummaryStrip`
|
|
412
442
|
- `ThinkingIndicator`
|
|
413
443
|
|
|
444
|
+
Guidance:
|
|
445
|
+
|
|
446
|
+
- prefer `AssistantEmbedded` over this path when the SDK layout is acceptable
|
|
447
|
+
- prefer `AssistantExperienceView` over this path when you only need controller ownership, theming control, or a few render overrides
|
|
448
|
+
- reach for primitives only when you are replacing the layout itself or deeply integrating the assistant into app-specific chrome
|
|
449
|
+
|
|
450
|
+
Default empty-state suggestions are intentionally generic so they work across support, internal tools, content, and general assistant use cases. Override them with `emptyStateSuggestions` when you want task-specific prompts.
|
|
451
|
+
|
|
414
452
|
#### Theming
|
|
415
453
|
|
|
416
454
|
Use `AssistantThemeScope` around custom assistant layouts:
|
package/dist/auth.d.ts
CHANGED
|
@@ -28,6 +28,7 @@ export interface AuthState {
|
|
|
28
28
|
}
|
|
29
29
|
export type AuthListener = (state: AuthState) => void;
|
|
30
30
|
export type AuthRedirectMode = "login" | "signup";
|
|
31
|
+
type AuthQueryParams = Record<string, string | number | boolean | Array<string | number | boolean> | null | undefined>;
|
|
31
32
|
export interface BuildAuthUrlOptions {
|
|
32
33
|
/** Optional auth path segment relative to authUrl pathname, e.g. "callback" -> /auth/callback. */
|
|
33
34
|
path?: string;
|
|
@@ -36,7 +37,35 @@ export interface BuildAuthUrlOptions {
|
|
|
36
37
|
/** Redirect URI passed to auth service. */
|
|
37
38
|
redirectUri?: string;
|
|
38
39
|
/** Additional query parameters appended to auth URL. */
|
|
39
|
-
params?:
|
|
40
|
+
params?: AuthQueryParams;
|
|
41
|
+
}
|
|
42
|
+
export interface BuildFederatedLogoutUrlOptions {
|
|
43
|
+
/**
|
|
44
|
+
* Optional auth path segment for logout, relative to authUrl pathname.
|
|
45
|
+
* Defaults to "logout" (for example: https://auth.example.com/auth/logout).
|
|
46
|
+
*/
|
|
47
|
+
path?: string;
|
|
48
|
+
/**
|
|
49
|
+
* Post-logout redirect URI passed to the auth service.
|
|
50
|
+
*/
|
|
51
|
+
redirectUri?: string;
|
|
52
|
+
/**
|
|
53
|
+
* Query parameter name used for redirect URI. Defaults to "redirect_uri".
|
|
54
|
+
*/
|
|
55
|
+
redirectParam?: string;
|
|
56
|
+
/** Additional query parameters appended to logout URL. */
|
|
57
|
+
params?: AuthQueryParams;
|
|
58
|
+
}
|
|
59
|
+
export interface RedirectToFederatedLogoutOptions extends Omit<BuildFederatedLogoutUrlOptions, "redirectUri"> {
|
|
60
|
+
/**
|
|
61
|
+
* Post-logout redirect URI. Defaults to current location.
|
|
62
|
+
*/
|
|
63
|
+
redirectUri?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Whether to clear the local session before redirecting upstream.
|
|
66
|
+
* Defaults to true.
|
|
67
|
+
*/
|
|
68
|
+
localSignOut?: boolean;
|
|
40
69
|
}
|
|
41
70
|
export interface ResolveSafeRedirectUriOptions {
|
|
42
71
|
/** Origin for resolving relative paths. */
|
|
@@ -50,6 +79,7 @@ export declare function setTestingToken(token: string): void;
|
|
|
50
79
|
export declare function getTestingToken(): string | null;
|
|
51
80
|
export declare function clearTestingToken(): void;
|
|
52
81
|
export declare function buildAuthUrl(authUrl: string, options?: BuildAuthUrlOptions): string;
|
|
82
|
+
export declare function buildFederatedLogoutUrl(authUrl: string, options?: BuildFederatedLogoutUrlOptions): string;
|
|
53
83
|
export declare function resolveSafeRedirectUri(rawValue: string | null | undefined, options: ResolveSafeRedirectUriOptions): string;
|
|
54
84
|
export declare class AuthManager {
|
|
55
85
|
private readonly apiUrl;
|
|
@@ -112,6 +142,10 @@ export declare class AuthManager {
|
|
|
112
142
|
* Build auth URL for login/signup/custom auth sub-path.
|
|
113
143
|
*/
|
|
114
144
|
getAuthUrl(options?: BuildAuthUrlOptions): string;
|
|
145
|
+
/**
|
|
146
|
+
* Build upstream/federated logout URL.
|
|
147
|
+
*/
|
|
148
|
+
getFederatedLogoutUrl(options?: BuildFederatedLogoutUrlOptions): string;
|
|
115
149
|
/**
|
|
116
150
|
* Redirect to the auth service, passing the current URL as redirect_uri.
|
|
117
151
|
* After the user authenticates, the auth service should redirect back to
|
|
@@ -120,4 +154,11 @@ export declare class AuthManager {
|
|
|
120
154
|
redirectToAuth(options?: Omit<BuildAuthUrlOptions, "redirectUri"> & {
|
|
121
155
|
redirectUri?: string;
|
|
122
156
|
}): void;
|
|
157
|
+
/**
|
|
158
|
+
* Optional full logout flow:
|
|
159
|
+
* 1. clear local SDK/session cookies
|
|
160
|
+
* 2. redirect to auth service logout endpoint to terminate upstream SSO
|
|
161
|
+
*/
|
|
162
|
+
redirectToFederatedLogout(options?: RedirectToFederatedLogoutOptions): Promise<void>;
|
|
123
163
|
}
|
|
164
|
+
export {};
|
package/dist/auth.js
CHANGED
|
@@ -121,6 +121,26 @@ export function buildAuthUrl(authUrl, options = {}) {
|
|
|
121
121
|
}
|
|
122
122
|
return url.toString();
|
|
123
123
|
}
|
|
124
|
+
export function buildFederatedLogoutUrl(authUrl, options = {}) {
|
|
125
|
+
const url = new URL(authUrl);
|
|
126
|
+
url.pathname = resolveAuthPath(url.pathname, options.path ?? "logout");
|
|
127
|
+
for (const [key, value] of Object.entries(options.params ?? {})) {
|
|
128
|
+
if (value === null || value === undefined)
|
|
129
|
+
continue;
|
|
130
|
+
if (Array.isArray(value)) {
|
|
131
|
+
url.searchParams.delete(key);
|
|
132
|
+
for (const item of value) {
|
|
133
|
+
url.searchParams.append(key, String(item));
|
|
134
|
+
}
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
url.searchParams.set(key, String(value));
|
|
138
|
+
}
|
|
139
|
+
if (options.redirectUri && options.redirectUri.trim()) {
|
|
140
|
+
url.searchParams.set(options.redirectParam ?? "redirect_uri", options.redirectUri);
|
|
141
|
+
}
|
|
142
|
+
return url.toString();
|
|
143
|
+
}
|
|
124
144
|
export function resolveSafeRedirectUri(rawValue, options) {
|
|
125
145
|
const siteOrigin = normalizeOrigin(options.siteOrigin);
|
|
126
146
|
const blockedPaths = options.blockedPaths ?? DEFAULT_BLOCKED_REDIRECT_PATHS;
|
|
@@ -368,6 +388,12 @@ export class AuthManager {
|
|
|
368
388
|
getAuthUrl(options = {}) {
|
|
369
389
|
return buildAuthUrl(this.authUrl, options);
|
|
370
390
|
}
|
|
391
|
+
/**
|
|
392
|
+
* Build upstream/federated logout URL.
|
|
393
|
+
*/
|
|
394
|
+
getFederatedLogoutUrl(options = {}) {
|
|
395
|
+
return buildFederatedLogoutUrl(this.authUrl, options);
|
|
396
|
+
}
|
|
371
397
|
/**
|
|
372
398
|
* Redirect to the auth service, passing the current URL as redirect_uri.
|
|
373
399
|
* After the user authenticates, the auth service should redirect back to
|
|
@@ -380,4 +406,21 @@ export class AuthManager {
|
|
|
380
406
|
const redirectUri = options.redirectUri ?? window.location.href;
|
|
381
407
|
window.location.href = this.getAuthUrl({ ...options, redirectUri });
|
|
382
408
|
}
|
|
409
|
+
/**
|
|
410
|
+
* Optional full logout flow:
|
|
411
|
+
* 1. clear local SDK/session cookies
|
|
412
|
+
* 2. redirect to auth service logout endpoint to terminate upstream SSO
|
|
413
|
+
*/
|
|
414
|
+
async redirectToFederatedLogout(options = {}) {
|
|
415
|
+
this.assertBrowserContext();
|
|
416
|
+
const redirectUri = options.redirectUri ?? window.location.href;
|
|
417
|
+
const localSignOut = options.localSignOut ?? true;
|
|
418
|
+
if (localSignOut) {
|
|
419
|
+
await this.signOut();
|
|
420
|
+
}
|
|
421
|
+
window.location.href = this.getFederatedLogoutUrl({
|
|
422
|
+
...options,
|
|
423
|
+
redirectUri,
|
|
424
|
+
});
|
|
425
|
+
}
|
|
383
426
|
}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"./browser.js": function (module, exports, require) {
|
|
4
4
|
"use strict";
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.ApiError = exports.setTestingToken = exports.resolveSafeRedirectUri = exports.getTestingToken = exports.clearTestingToken = exports.buildAuthUrl = exports.AuthManager = exports.LemmaClient = void 0;
|
|
6
|
+
exports.ApiError = exports.setTestingToken = exports.resolveSafeRedirectUri = exports.getTestingToken = exports.clearTestingToken = exports.buildFederatedLogoutUrl = exports.buildAuthUrl = exports.AuthManager = exports.LemmaClient = void 0;
|
|
7
7
|
/**
|
|
8
8
|
* Browser bundle entry point.
|
|
9
9
|
* Exposes LemmaClient as globalThis.LemmaClient.LemmaClient
|
|
@@ -19,6 +19,7 @@ Object.defineProperty(exports, "LemmaClient", { enumerable: true, get: function
|
|
|
19
19
|
var auth_js_1 = require("./auth.js");
|
|
20
20
|
Object.defineProperty(exports, "AuthManager", { enumerable: true, get: function () { return auth_js_1.AuthManager; } });
|
|
21
21
|
Object.defineProperty(exports, "buildAuthUrl", { enumerable: true, get: function () { return auth_js_1.buildAuthUrl; } });
|
|
22
|
+
Object.defineProperty(exports, "buildFederatedLogoutUrl", { enumerable: true, get: function () { return auth_js_1.buildFederatedLogoutUrl; } });
|
|
22
23
|
Object.defineProperty(exports, "clearTestingToken", { enumerable: true, get: function () { return auth_js_1.clearTestingToken; } });
|
|
23
24
|
Object.defineProperty(exports, "getTestingToken", { enumerable: true, get: function () { return auth_js_1.getTestingToken; } });
|
|
24
25
|
Object.defineProperty(exports, "resolveSafeRedirectUri", { enumerable: true, get: function () { return auth_js_1.resolveSafeRedirectUri; } });
|
|
@@ -198,6 +199,7 @@ exports.setTestingToken = setTestingToken;
|
|
|
198
199
|
exports.getTestingToken = getTestingToken;
|
|
199
200
|
exports.clearTestingToken = clearTestingToken;
|
|
200
201
|
exports.buildAuthUrl = buildAuthUrl;
|
|
202
|
+
exports.buildFederatedLogoutUrl = buildFederatedLogoutUrl;
|
|
201
203
|
exports.resolveSafeRedirectUri = resolveSafeRedirectUri;
|
|
202
204
|
const session_1 = require("supertokens-web-js/recipe/session");
|
|
203
205
|
const supertokens_js_1 = require("./supertokens.js");
|
|
@@ -305,6 +307,26 @@ function buildAuthUrl(authUrl, options = {}) {
|
|
|
305
307
|
}
|
|
306
308
|
return url.toString();
|
|
307
309
|
}
|
|
310
|
+
function buildFederatedLogoutUrl(authUrl, options = {}) {
|
|
311
|
+
const url = new URL(authUrl);
|
|
312
|
+
url.pathname = resolveAuthPath(url.pathname, options.path ?? "logout");
|
|
313
|
+
for (const [key, value] of Object.entries(options.params ?? {})) {
|
|
314
|
+
if (value === null || value === undefined)
|
|
315
|
+
continue;
|
|
316
|
+
if (Array.isArray(value)) {
|
|
317
|
+
url.searchParams.delete(key);
|
|
318
|
+
for (const item of value) {
|
|
319
|
+
url.searchParams.append(key, String(item));
|
|
320
|
+
}
|
|
321
|
+
continue;
|
|
322
|
+
}
|
|
323
|
+
url.searchParams.set(key, String(value));
|
|
324
|
+
}
|
|
325
|
+
if (options.redirectUri && options.redirectUri.trim()) {
|
|
326
|
+
url.searchParams.set(options.redirectParam ?? "redirect_uri", options.redirectUri);
|
|
327
|
+
}
|
|
328
|
+
return url.toString();
|
|
329
|
+
}
|
|
308
330
|
function resolveSafeRedirectUri(rawValue, options) {
|
|
309
331
|
const siteOrigin = normalizeOrigin(options.siteOrigin);
|
|
310
332
|
const blockedPaths = options.blockedPaths ?? DEFAULT_BLOCKED_REDIRECT_PATHS;
|
|
@@ -549,6 +571,12 @@ class AuthManager {
|
|
|
549
571
|
getAuthUrl(options = {}) {
|
|
550
572
|
return buildAuthUrl(this.authUrl, options);
|
|
551
573
|
}
|
|
574
|
+
/**
|
|
575
|
+
* Build upstream/federated logout URL.
|
|
576
|
+
*/
|
|
577
|
+
getFederatedLogoutUrl(options = {}) {
|
|
578
|
+
return buildFederatedLogoutUrl(this.authUrl, options);
|
|
579
|
+
}
|
|
552
580
|
/**
|
|
553
581
|
* Redirect to the auth service, passing the current URL as redirect_uri.
|
|
554
582
|
* After the user authenticates, the auth service should redirect back to
|
|
@@ -561,6 +589,23 @@ class AuthManager {
|
|
|
561
589
|
const redirectUri = options.redirectUri ?? window.location.href;
|
|
562
590
|
window.location.href = this.getAuthUrl({ ...options, redirectUri });
|
|
563
591
|
}
|
|
592
|
+
/**
|
|
593
|
+
* Optional full logout flow:
|
|
594
|
+
* 1. clear local SDK/session cookies
|
|
595
|
+
* 2. redirect to auth service logout endpoint to terminate upstream SSO
|
|
596
|
+
*/
|
|
597
|
+
async redirectToFederatedLogout(options = {}) {
|
|
598
|
+
this.assertBrowserContext();
|
|
599
|
+
const redirectUri = options.redirectUri ?? window.location.href;
|
|
600
|
+
const localSignOut = options.localSignOut ?? true;
|
|
601
|
+
if (localSignOut) {
|
|
602
|
+
await this.signOut();
|
|
603
|
+
}
|
|
604
|
+
window.location.href = this.getFederatedLogoutUrl({
|
|
605
|
+
...options,
|
|
606
|
+
redirectUri,
|
|
607
|
+
});
|
|
608
|
+
}
|
|
564
609
|
}
|
|
565
610
|
exports.AuthManager = AuthManager;
|
|
566
611
|
|
|
@@ -1538,6 +1583,9 @@ class ConversationsNamespace {
|
|
|
1538
1583
|
listByAssistant(assistantId, options = {}) {
|
|
1539
1584
|
return this.list({ ...options, assistant_id: assistantId });
|
|
1540
1585
|
}
|
|
1586
|
+
listModels() {
|
|
1587
|
+
return this.http.request("GET", "/models");
|
|
1588
|
+
}
|
|
1541
1589
|
create(payload) {
|
|
1542
1590
|
return this.http.request("POST", "/conversations", {
|
|
1543
1591
|
body: {
|
package/dist/browser.d.ts
CHANGED
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
* </script>
|
|
10
10
|
*/
|
|
11
11
|
export { LemmaClient } from "./client.js";
|
|
12
|
-
export { AuthManager, buildAuthUrl, clearTestingToken, getTestingToken, resolveSafeRedirectUri, setTestingToken, } from "./auth.js";
|
|
12
|
+
export { AuthManager, buildAuthUrl, buildFederatedLogoutUrl, clearTestingToken, getTestingToken, resolveSafeRedirectUri, setTestingToken, } from "./auth.js";
|
|
13
13
|
export { ApiError } from "./http.js";
|
package/dist/browser.js
CHANGED
|
@@ -9,5 +9,5 @@
|
|
|
9
9
|
* </script>
|
|
10
10
|
*/
|
|
11
11
|
export { LemmaClient } from "./client.js";
|
|
12
|
-
export { AuthManager, buildAuthUrl, clearTestingToken, getTestingToken, resolveSafeRedirectUri, setTestingToken, } from "./auth.js";
|
|
12
|
+
export { AuthManager, buildAuthUrl, buildFederatedLogoutUrl, clearTestingToken, getTestingToken, resolveSafeRedirectUri, setTestingToken, } from "./auth.js";
|
|
13
13
|
export { ApiError } from "./http.js";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { LemmaClient } from "./client.js";
|
|
2
2
|
export type { LemmaConfig } from "./client.js";
|
|
3
|
-
export { AuthManager, buildAuthUrl, clearTestingToken, getTestingToken, resolveSafeRedirectUri, setTestingToken, } from "./auth.js";
|
|
4
|
-
export type { AuthState, AuthListener, AuthStatus, UserInfo, AuthRedirectMode, BuildAuthUrlOptions, ResolveSafeRedirectUriOptions, } from "./auth.js";
|
|
3
|
+
export { AuthManager, buildAuthUrl, buildFederatedLogoutUrl, clearTestingToken, getTestingToken, resolveSafeRedirectUri, setTestingToken, } from "./auth.js";
|
|
4
|
+
export type { AuthState, AuthListener, AuthStatus, UserInfo, AuthRedirectMode, BuildAuthUrlOptions, BuildFederatedLogoutUrlOptions, RedirectToFederatedLogoutOptions, ResolveSafeRedirectUriOptions, } from "./auth.js";
|
|
5
5
|
export { ApiError } from "./http.js";
|
|
6
6
|
export * from "./types.js";
|
|
7
7
|
export { readSSE, parseSSEJson } from "./streams.js";
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { LemmaClient } from "./client.js";
|
|
2
|
-
export { AuthManager, buildAuthUrl, clearTestingToken, getTestingToken, resolveSafeRedirectUri, setTestingToken, } from "./auth.js";
|
|
2
|
+
export { AuthManager, buildAuthUrl, buildFederatedLogoutUrl, clearTestingToken, getTestingToken, resolveSafeRedirectUri, setTestingToken, } from "./auth.js";
|
|
3
3
|
export { ApiError } from "./http.js";
|
|
4
4
|
export * from "./types.js";
|
|
5
5
|
export { readSSE, parseSSEJson } from "./streams.js";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { HttpClient } from "../http.js";
|
|
2
|
+
import type { AvailableModelsListResponse } from "../openapi_client/models/AvailableModelsListResponse.js";
|
|
2
3
|
import type { AssistantListResponse } from "../openapi_client/models/AssistantListResponse.js";
|
|
3
4
|
import type { AssistantResponse } from "../openapi_client/models/AssistantResponse.js";
|
|
4
5
|
import type { ConversationListResponse } from "../openapi_client/models/ConversationListResponse.js";
|
|
@@ -41,6 +42,7 @@ export declare class ConversationsNamespace {
|
|
|
41
42
|
limit?: number;
|
|
42
43
|
page_token?: string;
|
|
43
44
|
}): Promise<ConversationListResponse>;
|
|
45
|
+
listModels(): Promise<AvailableModelsListResponse>;
|
|
44
46
|
create(payload: CreateConversationRequest): Promise<ConversationResponse>;
|
|
45
47
|
createForAssistant(assistantId: string, payload?: Omit<CreateConversationRequest, "assistant_id">): Promise<ConversationResponse>;
|
|
46
48
|
get(conversationId: string, options?: {
|
|
@@ -67,6 +67,9 @@ export class ConversationsNamespace {
|
|
|
67
67
|
listByAssistant(assistantId, options = {}) {
|
|
68
68
|
return this.list({ ...options, assistant_id: assistantId });
|
|
69
69
|
}
|
|
70
|
+
listModels() {
|
|
71
|
+
return this.http.request("GET", "/models");
|
|
72
|
+
}
|
|
70
73
|
create(payload) {
|
|
71
74
|
return this.http.request("POST", "/conversations", {
|
|
72
75
|
body: {
|
|
@@ -26,7 +26,9 @@ export type { AssistantListResponse } from './models/AssistantListResponse.js';
|
|
|
26
26
|
export type { AssistantResponse } from './models/AssistantResponse.js';
|
|
27
27
|
export type { AssistantSurfaceListResponse } from './models/AssistantSurfaceListResponse.js';
|
|
28
28
|
export type { AssistantSurfaceResponse } from './models/AssistantSurfaceResponse.js';
|
|
29
|
+
export type { AvailableModelInfo } from './models/AvailableModelInfo.js';
|
|
29
30
|
export { AvailableModels } from './models/AvailableModels.js';
|
|
31
|
+
export type { AvailableModelsListResponse } from './models/AvailableModelsListResponse.js';
|
|
30
32
|
export { BillingInterval } from './models/BillingInterval.js';
|
|
31
33
|
export type { Body_upload_file_files__resource_type___resource_id__upload_post } from './models/Body_upload_file_files__resource_type___resource_id__upload_post.js';
|
|
32
34
|
export type { BulkCreateRecordsRequest } from './models/BulkCreateRecordsRequest.js';
|
|
@@ -103,6 +105,7 @@ export type { FunctionRunListResponse } from './models/FunctionRunListResponse.j
|
|
|
103
105
|
export type { FunctionRunResponse } from './models/FunctionRunResponse.js';
|
|
104
106
|
export { FunctionRunStatus } from './models/FunctionRunStatus.js';
|
|
105
107
|
export { FunctionStatus } from './models/FunctionStatus.js';
|
|
108
|
+
export { FunctionType } from './models/FunctionType.js';
|
|
106
109
|
export type { HTTPValidationError } from './models/HTTPValidationError.js';
|
|
107
110
|
export type { IconUploadRequest } from './models/IconUploadRequest.js';
|
|
108
111
|
export type { IconUploadResponse } from './models/IconUploadResponse.js';
|
|
@@ -18,6 +18,7 @@ export { FlowRunStatus } from './models/FlowRunStatus.js';
|
|
|
18
18
|
export { FlowStartType } from './models/FlowStartType.js';
|
|
19
19
|
export { FunctionRunStatus } from './models/FunctionRunStatus.js';
|
|
20
20
|
export { FunctionStatus } from './models/FunctionStatus.js';
|
|
21
|
+
export { FunctionType } from './models/FunctionType.js';
|
|
21
22
|
export { OrganizationInvitationStatus } from './models/OrganizationInvitationStatus.js';
|
|
22
23
|
export { OrganizationRole } from './models/OrganizationRole.js';
|
|
23
24
|
export { PodAppMode } from './models/PodAppMode.js';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,8 +4,7 @@ export declare enum AvailableModels {
|
|
|
4
4
|
GEMINI_FLASH_LITE = "GEMINI_FLASH_LITE",
|
|
5
5
|
KIMI_K2 = "KIMI_K2",
|
|
6
6
|
GPT_OSS = "GPT_OSS",
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
GLM_5 = "GLM_5"
|
|
7
|
+
DEEPSEEK_V32 = "DEEPSEEK_V32",
|
|
8
|
+
GLM_5 = "GLM_5",
|
|
9
|
+
QWEN3_6 = "QWEN3_6"
|
|
11
10
|
}
|
|
@@ -9,8 +9,7 @@ export var AvailableModels;
|
|
|
9
9
|
AvailableModels["GEMINI_FLASH_LITE"] = "GEMINI_FLASH_LITE";
|
|
10
10
|
AvailableModels["KIMI_K2"] = "KIMI_K2";
|
|
11
11
|
AvailableModels["GPT_OSS"] = "GPT_OSS";
|
|
12
|
-
AvailableModels["
|
|
13
|
-
AvailableModels["CLAUDE_SONNET_4"] = "CLAUDE_SONNET_4";
|
|
14
|
-
AvailableModels["QWEN3_235B"] = "QWEN3_235B";
|
|
12
|
+
AvailableModels["DEEPSEEK_V32"] = "DEEPSEEK_V32";
|
|
15
13
|
AvailableModels["GLM_5"] = "GLM_5";
|
|
14
|
+
AvailableModels["QWEN3_6"] = "QWEN3_6";
|
|
16
15
|
})(AvailableModels || (AvailableModels = {}));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ApplicationAccessConfig } from './ApplicationAccessConfig.js';
|
|
2
|
+
import type { FunctionType } from './FunctionType.js';
|
|
2
3
|
import type { TableAccessEntry } from './TableAccessEntry.js';
|
|
3
4
|
/**
|
|
4
5
|
* Request to create a function.
|
|
@@ -15,4 +16,5 @@ export type CreateFunctionRequest = {
|
|
|
15
16
|
input_schema?: Record<string, any>;
|
|
16
17
|
name: string;
|
|
17
18
|
output_schema?: Record<string, any>;
|
|
19
|
+
type?: FunctionType;
|
|
18
20
|
};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ApplicationAccessConfig } from './ApplicationAccessConfig.js';
|
|
2
2
|
import type { FunctionStatus } from './FunctionStatus.js';
|
|
3
|
+
import type { FunctionType } from './FunctionType.js';
|
|
3
4
|
import type { TableAccessEntry } from './TableAccessEntry.js';
|
|
4
5
|
/**
|
|
5
6
|
* Function response.
|
|
@@ -21,6 +22,7 @@ export type FunctionResponse = {
|
|
|
21
22
|
output_schema: Record<string, any>;
|
|
22
23
|
pod_id: string;
|
|
23
24
|
status: FunctionStatus;
|
|
25
|
+
type: FunctionType;
|
|
24
26
|
updated_at: any;
|
|
25
27
|
user_id: string;
|
|
26
28
|
};
|
|
@@ -9,9 +9,13 @@ export type FunctionRunResponse = {
|
|
|
9
9
|
function_id: string;
|
|
10
10
|
id: string;
|
|
11
11
|
input_data?: (Record<string, any> | null);
|
|
12
|
+
job_id?: (string | null);
|
|
12
13
|
logs?: (string | null);
|
|
13
14
|
output_data?: (Record<string, any> | null);
|
|
14
15
|
started_at: any;
|
|
15
16
|
status: FunctionRunStatus;
|
|
17
|
+
user_email?: (string | null);
|
|
16
18
|
user_id: string;
|
|
19
|
+
workspace_process_id?: (string | null);
|
|
20
|
+
workspace_session_id?: (string | null);
|
|
17
21
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/* generated using openapi-typescript-codegen -- do not edit */
|
|
2
|
+
/* istanbul ignore file */
|
|
3
|
+
/* tslint:disable */
|
|
4
|
+
/* eslint-disable */
|
|
5
|
+
/**
|
|
6
|
+
* Execution mode for a function.
|
|
7
|
+
*/
|
|
8
|
+
export var FunctionType;
|
|
9
|
+
(function (FunctionType) {
|
|
10
|
+
FunctionType["API"] = "API";
|
|
11
|
+
FunctionType["JOB"] = "JOB";
|
|
12
|
+
})(FunctionType || (FunctionType = {}));
|