lemma-sdk 0.2.3 → 0.2.5

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.
Files changed (75) hide show
  1. package/README.md +88 -0
  2. package/dist/assistant-events.d.ts +7 -0
  3. package/dist/assistant-events.js +78 -0
  4. package/dist/auth.d.ts +56 -5
  5. package/dist/auth.js +247 -30
  6. package/dist/browser/lemma-client.js +283 -53
  7. package/dist/browser.d.ts +1 -1
  8. package/dist/browser.js +1 -1
  9. package/dist/client.d.ts +4 -1
  10. package/dist/client.js +3 -3
  11. package/dist/index.d.ts +8 -2
  12. package/dist/index.js +4 -1
  13. package/dist/namespaces/desks.d.ts +2 -2
  14. package/dist/namespaces/desks.js +7 -7
  15. package/dist/namespaces/icons.js +4 -1
  16. package/dist/openapi_client/index.d.ts +10 -7
  17. package/dist/openapi_client/models/{AgentNode.d.ts → AgentNode_Input.d.ts} +1 -1
  18. package/dist/openapi_client/models/AgentNode_Output.d.ts +11 -0
  19. package/dist/openapi_client/models/AppDescriptorResponse.d.ts +2 -2
  20. package/dist/openapi_client/models/Body_upload_file_files__resource_type___resource_id__upload_post.d.ts +1 -1
  21. package/dist/openapi_client/models/{Body_file_upload.d.ts → DatastoreFileUploadRequest.d.ts} +2 -2
  22. package/dist/openapi_client/models/{DecisionNode.d.ts → DecisionNode_Input.d.ts} +1 -1
  23. package/dist/openapi_client/models/DecisionNode_Output.d.ts +11 -0
  24. package/dist/openapi_client/models/DeskBundleUploadRequest.d.ts +4 -0
  25. package/dist/openapi_client/models/FlowEntity.d.ts +4 -4
  26. package/dist/openapi_client/models/{FunctionNode.d.ts → FunctionNode_Input.d.ts} +1 -1
  27. package/dist/openapi_client/models/FunctionNode_Output.d.ts +11 -0
  28. package/dist/openapi_client/models/FunctionNode_Output.js +1 -0
  29. package/dist/openapi_client/models/IconUploadRequest.d.ts +3 -0
  30. package/dist/openapi_client/models/IconUploadRequest.js +1 -0
  31. package/dist/openapi_client/models/ValidationError.d.ts +2 -0
  32. package/dist/openapi_client/models/WorkflowGraphUpdateRequest.d.ts +4 -4
  33. package/dist/openapi_client/models/{Body_file_update.d.ts → update.d.ts} +2 -2
  34. package/dist/openapi_client/models/update.js +1 -0
  35. package/dist/openapi_client/services/ApplicationsService.d.ts +2 -2
  36. package/dist/openapi_client/services/ApplicationsService.js +3 -3
  37. package/dist/openapi_client/services/DesksService.d.ts +9 -9
  38. package/dist/openapi_client/services/DesksService.js +8 -8
  39. package/dist/openapi_client/services/FilesService.d.ts +4 -4
  40. package/dist/openapi_client/services/IconsService.d.ts +2 -2
  41. package/dist/openapi_client/services/PublicSdkService.d.ts +1 -1
  42. package/dist/openapi_client/services/PublicSdkService.js +1 -1
  43. package/dist/react/index.d.ts +12 -0
  44. package/dist/react/index.js +6 -0
  45. package/dist/react/useAssistantRun.d.ts +1 -1
  46. package/dist/react/useAssistantRun.js +23 -69
  47. package/dist/react/useAssistantRuntime.d.ts +13 -0
  48. package/dist/react/useAssistantRuntime.js +108 -0
  49. package/dist/react/useAssistantSession.d.ts +61 -0
  50. package/dist/react/useAssistantSession.js +278 -0
  51. package/dist/react/useAuth.d.ts +6 -2
  52. package/dist/react/useAuth.js +1 -1
  53. package/dist/react/useFlowRunHistory.d.ts +19 -0
  54. package/dist/react/useFlowRunHistory.js +77 -0
  55. package/dist/react/useFlowSession.d.ts +39 -0
  56. package/dist/react/useFlowSession.js +195 -0
  57. package/dist/react/useFunctionSession.d.ts +32 -0
  58. package/dist/react/useFunctionSession.js +147 -0
  59. package/dist/react/useTaskSession.d.ts +35 -0
  60. package/dist/react/useTaskSession.js +207 -0
  61. package/dist/run-utils.d.ts +18 -0
  62. package/dist/run-utils.js +62 -0
  63. package/dist/task-events.d.ts +7 -0
  64. package/dist/task-events.js +78 -0
  65. package/dist/types.d.ts +3 -1
  66. package/package.json +1 -1
  67. package/dist/openapi_client/models/Body_icon_upload.d.ts +0 -3
  68. package/dist/openapi_client/models/Body_pod_desk_bundle_upload.d.ts +0 -4
  69. /package/dist/openapi_client/models/{AgentNode.js → AgentNode_Input.js} +0 -0
  70. /package/dist/openapi_client/models/{Body_file_update.js → AgentNode_Output.js} +0 -0
  71. /package/dist/openapi_client/models/{Body_file_upload.js → DatastoreFileUploadRequest.js} +0 -0
  72. /package/dist/openapi_client/models/{Body_icon_upload.js → DecisionNode_Input.js} +0 -0
  73. /package/dist/openapi_client/models/{Body_pod_desk_bundle_upload.js → DecisionNode_Output.js} +0 -0
  74. /package/dist/openapi_client/models/{DecisionNode.js → DeskBundleUploadRequest.js} +0 -0
  75. /package/dist/openapi_client/models/{FunctionNode.js → FunctionNode_Input.js} +0 -0
@@ -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.AuthManager = exports.LemmaClient = void 0;
6
+ exports.ApiError = exports.setTestingToken = exports.resolveSafeRedirectUri = exports.getTestingToken = exports.clearTestingToken = exports.buildAuthUrl = exports.AuthManager = exports.LemmaClient = void 0;
7
7
  /**
8
8
  * Browser bundle entry point.
9
9
  * Exposes LemmaClient as globalThis.LemmaClient.LemmaClient
@@ -18,6 +18,11 @@ var client_js_1 = require("./client.js");
18
18
  Object.defineProperty(exports, "LemmaClient", { enumerable: true, get: function () { return client_js_1.LemmaClient; } });
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
+ Object.defineProperty(exports, "buildAuthUrl", { enumerable: true, get: function () { return auth_js_1.buildAuthUrl; } });
22
+ Object.defineProperty(exports, "clearTestingToken", { enumerable: true, get: function () { return auth_js_1.clearTestingToken; } });
23
+ Object.defineProperty(exports, "getTestingToken", { enumerable: true, get: function () { return auth_js_1.getTestingToken; } });
24
+ Object.defineProperty(exports, "resolveSafeRedirectUri", { enumerable: true, get: function () { return auth_js_1.resolveSafeRedirectUri; } });
25
+ Object.defineProperty(exports, "setTestingToken", { enumerable: true, get: function () { return auth_js_1.setTestingToken; } });
21
26
  var http_js_1 = require("./http.js");
22
27
  Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return http_js_1.ApiError; } });
23
28
 
@@ -50,11 +55,11 @@ const tasks_js_1 = require("./namespaces/tasks.js");
50
55
  const users_js_1 = require("./namespaces/users.js");
51
56
  const workflows_js_1 = require("./namespaces/workflows.js");
52
57
  class LemmaClient {
53
- constructor(overrides = {}) {
58
+ constructor(overrides = {}, internalOptions = {}) {
54
59
  this._config = (0, config_js_1.resolveConfig)(overrides);
55
60
  this._currentPodId = this._config.podId;
56
61
  this._podId = this._config.podId;
57
- this.auth = new auth_js_1.AuthManager(this._config.apiUrl, this._config.authUrl);
62
+ this.auth = internalOptions.authManager ?? new auth_js_1.AuthManager(this._config.apiUrl, this._config.authUrl);
58
63
  this._http = new http_js_1.HttpClient(this._config.apiUrl, this.auth);
59
64
  this._generated = new generated_js_1.GeneratedClientAdapter(this._config.apiUrl, this.auth);
60
65
  const podIdFn = () => {
@@ -89,7 +94,7 @@ class LemmaClient {
89
94
  }
90
95
  /** Return a new client scoped to a specific pod, sharing auth state. */
91
96
  withPod(podId) {
92
- return new LemmaClient({ ...this._config, podId });
97
+ return new LemmaClient({ ...this._config, podId }, { authManager: this.auth });
93
98
  }
94
99
  get podId() {
95
100
  return this._currentPodId;
@@ -177,11 +182,10 @@ function resolveConfig(overrides = {}) {
177
182
  * for agent/dev testing.
178
183
  *
179
184
  * Auth resolution order on init:
180
- * 1. ?lemma_token=<token> query param (stored in memory for session)
181
- * 2. localStorage.getItem("lemma_token")
182
- * 3. Session cookie (credentials: "include") — production path
185
+ * 1. localStorage.getItem("lemma_token")
186
+ * 2. Session cookie (credentials: "include") — production path
183
187
  *
184
- * If a token is found in (1) or (2), all requests use Authorization: Bearer <token>.
188
+ * If a token is found in (1), all requests use Authorization: Bearer <token>.
185
189
  * Otherwise requests rely on cookies, and the server must set the session cookie
186
190
  * after the user authenticates at the auth service. In cookie mode we initialise
187
191
  * the SuperTokens browser SDK so fetch/XHR automatically handles anti-CSRF and
@@ -192,41 +196,136 @@ function resolveConfig(overrides = {}) {
192
196
  */
193
197
  Object.defineProperty(exports, "__esModule", { value: true });
194
198
  exports.AuthManager = void 0;
199
+ exports.setTestingToken = setTestingToken;
200
+ exports.getTestingToken = getTestingToken;
201
+ exports.clearTestingToken = clearTestingToken;
202
+ exports.buildAuthUrl = buildAuthUrl;
203
+ exports.resolveSafeRedirectUri = resolveSafeRedirectUri;
204
+ const session_1 = require("supertokens-web-js/recipe/session");
195
205
  const supertokens_js_1 = require("./supertokens.js");
206
+ const DEFAULT_BLOCKED_REDIRECT_PATHS = ["/login", "/signup", "/auth"];
196
207
  const LOCALSTORAGE_TOKEN_KEY = "lemma_token";
197
- const QUERY_PARAM_TOKEN_KEY = "lemma_token";
198
- function detectInjectedToken() {
208
+ function readStorageToken() {
199
209
  if (typeof window === "undefined")
200
210
  return null;
201
- // 1. Query param — highest priority, persist to sessionStorage for this session
202
211
  try {
203
- const params = new URLSearchParams(window.location.search);
204
- const qpToken = params.get(QUERY_PARAM_TOKEN_KEY);
205
- if (qpToken) {
206
- try {
207
- sessionStorage.setItem(LOCALSTORAGE_TOKEN_KEY, qpToken);
208
- }
209
- catch { /* ignore */ }
210
- return qpToken;
211
- }
212
+ return localStorage.getItem(LOCALSTORAGE_TOKEN_KEY);
213
+ }
214
+ catch {
215
+ return null;
212
216
  }
213
- catch { /* ignore */ }
214
- // 2. sessionStorage — survives HMR and same-tab navigation
217
+ }
218
+ function writeStorageToken(token) {
219
+ if (typeof window === "undefined")
220
+ return;
215
221
  try {
216
- const stored = sessionStorage.getItem(LOCALSTORAGE_TOKEN_KEY);
217
- if (stored)
218
- return stored;
222
+ localStorage.setItem(LOCALSTORAGE_TOKEN_KEY, token);
219
223
  }
220
- catch { /* ignore */ }
221
- // 3. localStorage — set manually by dev/agent for persistent testing
224
+ catch {
225
+ // ignore storage errors
226
+ }
227
+ }
228
+ function removeStorageToken() {
229
+ if (typeof window === "undefined")
230
+ return;
222
231
  try {
223
- const stored = localStorage.getItem(LOCALSTORAGE_TOKEN_KEY);
224
- if (stored)
225
- return stored;
232
+ localStorage.removeItem(LOCALSTORAGE_TOKEN_KEY);
233
+ }
234
+ catch {
235
+ // ignore storage errors
226
236
  }
227
- catch { /* ignore */ }
237
+ }
238
+ function setTestingToken(token) {
239
+ writeStorageToken(token);
240
+ }
241
+ function getTestingToken() {
242
+ return readStorageToken();
243
+ }
244
+ function clearTestingToken() {
245
+ removeStorageToken();
246
+ }
247
+ function detectInjectedToken() {
248
+ if (typeof window === "undefined")
249
+ return null;
250
+ // 1. localStorage — the only supported browser testing path
251
+ const localToken = readStorageToken();
252
+ if (localToken)
253
+ return localToken;
228
254
  return null;
229
255
  }
256
+ function normalizePath(path) {
257
+ const trimmed = path.trim();
258
+ if (!trimmed)
259
+ return "/";
260
+ if (trimmed === "/")
261
+ return "/";
262
+ const withLeadingSlash = trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
263
+ return withLeadingSlash.endsWith("/") ? withLeadingSlash.slice(0, -1) : withLeadingSlash;
264
+ }
265
+ function resolveAuthPath(basePath, path) {
266
+ const normalizedBase = normalizePath(basePath);
267
+ if (!path || !path.trim()) {
268
+ return normalizedBase;
269
+ }
270
+ const segment = path.trim().replace(/^\/+/, "");
271
+ if (!segment) {
272
+ return normalizedBase;
273
+ }
274
+ return `${normalizedBase}/${segment}`.replace(/\/{2,}/g, "/");
275
+ }
276
+ function isBlockedLocalPath(pathname, blockedPaths) {
277
+ const normalizedPathname = normalizePath(pathname);
278
+ return blockedPaths.some((rawBlockedPath) => {
279
+ const blockedPath = normalizePath(rawBlockedPath);
280
+ return normalizedPathname === blockedPath || normalizedPathname.startsWith(`${blockedPath}/`);
281
+ });
282
+ }
283
+ function normalizeOrigin(rawOrigin) {
284
+ const parsed = new URL(rawOrigin);
285
+ return parsed.origin;
286
+ }
287
+ function buildAuthUrl(authUrl, options = {}) {
288
+ const url = new URL(authUrl);
289
+ url.pathname = resolveAuthPath(url.pathname, options.path);
290
+ for (const [key, value] of Object.entries(options.params ?? {})) {
291
+ if (value === null || value === undefined)
292
+ continue;
293
+ if (Array.isArray(value)) {
294
+ url.searchParams.delete(key);
295
+ for (const item of value) {
296
+ url.searchParams.append(key, String(item));
297
+ }
298
+ continue;
299
+ }
300
+ url.searchParams.set(key, String(value));
301
+ }
302
+ if (options.mode === "signup") {
303
+ url.searchParams.set("show", "signup");
304
+ }
305
+ if (options.redirectUri && options.redirectUri.trim()) {
306
+ url.searchParams.set("redirect_uri", options.redirectUri);
307
+ }
308
+ return url.toString();
309
+ }
310
+ function resolveSafeRedirectUri(rawValue, options) {
311
+ const siteOrigin = normalizeOrigin(options.siteOrigin);
312
+ const blockedPaths = options.blockedPaths ?? DEFAULT_BLOCKED_REDIRECT_PATHS;
313
+ const fallbackTarget = options.fallback ?? "/";
314
+ const fallback = new URL(fallbackTarget, siteOrigin).toString();
315
+ if (!rawValue || !rawValue.trim()) {
316
+ return fallback;
317
+ }
318
+ try {
319
+ const parsed = new URL(rawValue, siteOrigin);
320
+ if (parsed.origin === siteOrigin && isBlockedLocalPath(parsed.pathname, blockedPaths)) {
321
+ return fallback;
322
+ }
323
+ return parsed.toString();
324
+ }
325
+ catch {
326
+ return fallback;
327
+ }
328
+ }
230
329
  class AuthManager {
231
330
  constructor(apiUrl, authUrl) {
232
331
  this.state = { status: "loading", user: null };
@@ -266,6 +365,96 @@ class AuthManager {
266
365
  this.state = state;
267
366
  this.notify();
268
367
  }
368
+ assertBrowserContext() {
369
+ if (typeof window === "undefined") {
370
+ throw new Error("This auth method is only available in browser environments.");
371
+ }
372
+ }
373
+ getCookie(name) {
374
+ if (typeof document === "undefined")
375
+ return undefined;
376
+ const escaped = name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
377
+ const match = document.cookie.match(new RegExp(`(?:^|; )${escaped}=([^;]*)`));
378
+ return match ? decodeURIComponent(match[1]) : undefined;
379
+ }
380
+ clearInjectedToken() {
381
+ this.injectedToken = null;
382
+ clearTestingToken();
383
+ }
384
+ async rawSignOutViaBackend() {
385
+ const antiCsrf = this.getCookie("sAntiCsrf");
386
+ const headers = {
387
+ Accept: "application/json",
388
+ "Content-Type": "application/json",
389
+ rid: "anti-csrf",
390
+ "fdi-version": "4.2",
391
+ "st-auth-mode": "cookie",
392
+ };
393
+ if (antiCsrf) {
394
+ headers["anti-csrf"] = antiCsrf;
395
+ }
396
+ const separator = this.apiUrl.includes("?") ? "&" : "?";
397
+ const signOutUrl = `${this.apiUrl.replace(/\/$/, "")}/st/auth/signout${separator}superTokensDoNotDoInterception=true`;
398
+ await fetch(signOutUrl, {
399
+ method: "POST",
400
+ credentials: "include",
401
+ headers,
402
+ });
403
+ }
404
+ /**
405
+ * Check whether a cookie-backed session is active without mutating auth state.
406
+ */
407
+ async isAuthenticatedViaCookie() {
408
+ if (this.injectedToken) {
409
+ return this.isAuthenticated();
410
+ }
411
+ try {
412
+ const response = await fetch(`${this.apiUrl}/users/me`, {
413
+ method: "GET",
414
+ credentials: "include",
415
+ headers: { Accept: "application/json" },
416
+ });
417
+ return response.status !== 401;
418
+ }
419
+ catch {
420
+ return false;
421
+ }
422
+ }
423
+ /**
424
+ * Return a browser access token from the session layer.
425
+ * Throws if no token is available.
426
+ */
427
+ async getAccessToken() {
428
+ if (this.injectedToken) {
429
+ return this.injectedToken;
430
+ }
431
+ this.assertBrowserContext();
432
+ (0, supertokens_js_1.ensureCookieSessionSupport)(this.apiUrl, () => this.markUnauthenticated());
433
+ const token = await session_1.default.getAccessToken();
434
+ if (!token) {
435
+ throw new Error("Token unavailable");
436
+ }
437
+ return token;
438
+ }
439
+ /**
440
+ * Force a refresh-token flow and return the new access token.
441
+ */
442
+ async refreshAccessToken() {
443
+ if (this.injectedToken) {
444
+ return this.injectedToken;
445
+ }
446
+ this.assertBrowserContext();
447
+ (0, supertokens_js_1.ensureCookieSessionSupport)(this.apiUrl, () => this.markUnauthenticated());
448
+ const refreshed = await session_1.default.attemptRefreshingSession();
449
+ if (!refreshed) {
450
+ throw new Error("Session refresh failed");
451
+ }
452
+ const token = await session_1.default.getAccessToken();
453
+ if (!token) {
454
+ throw new Error("Token unavailable");
455
+ }
456
+ return token;
457
+ }
269
458
  /**
270
459
  * Build request headers for an API call.
271
460
  * Uses Bearer token if one was injected, otherwise omits Authorization
@@ -324,17 +513,55 @@ class AuthManager {
324
513
  markUnauthenticated() {
325
514
  this.setState({ status: "unauthenticated", user: null });
326
515
  }
516
+ /**
517
+ * Sign out the current user session.
518
+ * Returns true when the session is no longer active.
519
+ */
520
+ async signOut() {
521
+ if (this.injectedToken) {
522
+ this.clearInjectedToken();
523
+ this.markUnauthenticated();
524
+ return true;
525
+ }
526
+ this.assertBrowserContext();
527
+ (0, supertokens_js_1.ensureCookieSessionSupport)(this.apiUrl, () => this.markUnauthenticated());
528
+ try {
529
+ await session_1.default.signOut();
530
+ }
531
+ catch {
532
+ // continue with raw fallback
533
+ }
534
+ if (await this.isAuthenticatedViaCookie()) {
535
+ try {
536
+ await this.rawSignOutViaBackend();
537
+ }
538
+ catch {
539
+ // best effort fallback only
540
+ }
541
+ }
542
+ const isAuthenticated = await this.isAuthenticatedViaCookie();
543
+ if (!isAuthenticated) {
544
+ this.markUnauthenticated();
545
+ }
546
+ return !isAuthenticated;
547
+ }
548
+ /**
549
+ * Build auth URL for login/signup/custom auth sub-path.
550
+ */
551
+ getAuthUrl(options = {}) {
552
+ return buildAuthUrl(this.authUrl, options);
553
+ }
327
554
  /**
328
555
  * Redirect to the auth service, passing the current URL as redirect_uri.
329
556
  * After the user authenticates, the auth service should redirect back to
330
557
  * the original URL and set the session cookie.
331
558
  */
332
- redirectToAuth() {
559
+ redirectToAuth(options = {}) {
333
560
  if (typeof window === "undefined") {
334
561
  return;
335
562
  }
336
- const redirectUri = encodeURIComponent(window.location.href);
337
- window.location.href = `${this.authUrl}?redirect_uri=${redirectUri}`;
563
+ const redirectUri = options.redirectUri ?? window.location.href;
564
+ window.location.href = this.getAuthUrl({ ...options, redirectUri });
338
565
  }
339
566
  }
340
567
  exports.AuthManager = AuthManager;
@@ -1575,29 +1802,29 @@ class DesksNamespace {
1575
1802
  this.http = http;
1576
1803
  this.podId = podId;
1577
1804
  this.html = {
1578
- get: (name) => this.client.request(() => DesksService_js_1.DesksService.podDeskHtmlGet(this.podId(), name)),
1805
+ get: (name) => this.client.request(() => DesksService_js_1.DesksService.deskHtmlGet(this.podId(), name)),
1579
1806
  };
1580
1807
  this.bundle = {
1581
- upload: (name, payload) => this.client.request(() => DesksService_js_1.DesksService.podDeskBundleUpload(this.podId(), name, payload)),
1808
+ upload: (name, payload) => this.client.request(() => DesksService_js_1.DesksService.deskBundleUpload(this.podId(), name, payload)),
1582
1809
  };
1583
1810
  this.source = {
1584
1811
  download: (name) => this.http.requestBytes("GET", `/pods/${this.podId()}/desks/${name}/source/archive`),
1585
1812
  };
1586
1813
  }
1587
1814
  list(options = {}) {
1588
- return this.client.request(() => DesksService_js_1.DesksService.podDeskList(this.podId(), options.limit ?? 100, options.pageToken));
1815
+ return this.client.request(() => DesksService_js_1.DesksService.deskList(this.podId(), options.limit ?? 100, options.pageToken));
1589
1816
  }
1590
1817
  create(payload) {
1591
- return this.client.request(() => DesksService_js_1.DesksService.podDeskCreate(this.podId(), payload));
1818
+ return this.client.request(() => DesksService_js_1.DesksService.deskCreate(this.podId(), payload));
1592
1819
  }
1593
1820
  get(name) {
1594
- return this.client.request(() => DesksService_js_1.DesksService.podDeskGet(this.podId(), name));
1821
+ return this.client.request(() => DesksService_js_1.DesksService.deskGet(this.podId(), name));
1595
1822
  }
1596
1823
  update(name, payload) {
1597
- return this.client.request(() => DesksService_js_1.DesksService.podDeskUpdate(this.podId(), name, payload));
1824
+ return this.client.request(() => DesksService_js_1.DesksService.deskUpdate(this.podId(), name, payload));
1598
1825
  }
1599
1826
  delete(name) {
1600
- return this.client.request(() => DesksService_js_1.DesksService.podDeskDelete(this.podId(), name));
1827
+ return this.client.request(() => DesksService_js_1.DesksService.deskDelete(this.podId(), name));
1601
1828
  }
1602
1829
  }
1603
1830
  exports.DesksNamespace = DesksNamespace;
@@ -1617,7 +1844,7 @@ class DesksService {
1617
1844
  * @returns DeskResponse Successful Response
1618
1845
  * @throws ApiError
1619
1846
  */
1620
- static podDeskCreate(podId, requestBody) {
1847
+ static deskCreate(podId, requestBody) {
1621
1848
  return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
1622
1849
  method: 'POST',
1623
1850
  url: '/pods/{pod_id}/desks',
@@ -1639,7 +1866,7 @@ class DesksService {
1639
1866
  * @returns DeskListResponse Successful Response
1640
1867
  * @throws ApiError
1641
1868
  */
1642
- static podDeskList(podId, limit = 100, pageToken) {
1869
+ static deskList(podId, limit = 100, pageToken) {
1643
1870
  return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
1644
1871
  method: 'GET',
1645
1872
  url: '/pods/{pod_id}/desks',
@@ -1662,7 +1889,7 @@ class DesksService {
1662
1889
  * @returns DeskResponse Successful Response
1663
1890
  * @throws ApiError
1664
1891
  */
1665
- static podDeskGet(podId, deskName) {
1892
+ static deskGet(podId, deskName) {
1666
1893
  return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
1667
1894
  method: 'GET',
1668
1895
  url: '/pods/{pod_id}/desks/{desk_name}',
@@ -1683,7 +1910,7 @@ class DesksService {
1683
1910
  * @returns DeskResponse Successful Response
1684
1911
  * @throws ApiError
1685
1912
  */
1686
- static podDeskUpdate(podId, deskName, requestBody) {
1913
+ static deskUpdate(podId, deskName, requestBody) {
1687
1914
  return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
1688
1915
  method: 'PATCH',
1689
1916
  url: '/pods/{pod_id}/desks/{desk_name}',
@@ -1705,7 +1932,7 @@ class DesksService {
1705
1932
  * @returns DeskMessageResponse Successful Response
1706
1933
  * @throws ApiError
1707
1934
  */
1708
- static podDeskDelete(podId, deskName) {
1935
+ static deskDelete(podId, deskName) {
1709
1936
  return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
1710
1937
  method: 'DELETE',
1711
1938
  url: '/pods/{pod_id}/desks/{desk_name}',
@@ -1726,7 +1953,7 @@ class DesksService {
1726
1953
  * @returns DeskBundleUploadResponse Successful Response
1727
1954
  * @throws ApiError
1728
1955
  */
1729
- static podDeskBundleUpload(podId, deskName, formData) {
1956
+ static deskBundleUpload(podId, deskName, formData) {
1730
1957
  return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
1731
1958
  method: 'POST',
1732
1959
  url: '/pods/{pod_id}/desks/{desk_name}/bundle',
@@ -1748,7 +1975,7 @@ class DesksService {
1748
1975
  * @returns any Successful Response
1749
1976
  * @throws ApiError
1750
1977
  */
1751
- static podDeskHtmlGet(podId, deskName) {
1978
+ static deskHtmlGet(podId, deskName) {
1752
1979
  return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
1753
1980
  method: 'GET',
1754
1981
  url: '/pods/{pod_id}/desks/{desk_name}/html',
@@ -1768,7 +1995,7 @@ class DesksService {
1768
1995
  * @returns any Successful Response
1769
1996
  * @throws ApiError
1770
1997
  */
1771
- static podDeskSourceArchiveGet(podId, deskName) {
1998
+ static deskSourceArchiveGet(podId, deskName) {
1772
1999
  return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
1773
2000
  method: 'GET',
1774
2001
  url: '/pods/{pod_id}/desks/{desk_name}/source/archive',
@@ -2409,7 +2636,10 @@ class IconsNamespace {
2409
2636
  this.client = client;
2410
2637
  }
2411
2638
  upload(file) {
2412
- return this.client.request(() => IconsService_js_1.IconsService.iconUpload({ file }));
2639
+ const payload = {
2640
+ file: file,
2641
+ };
2642
+ return this.client.request(() => IconsService_js_1.IconsService.iconUpload(payload));
2413
2643
  }
2414
2644
  getPublic(iconPath) {
2415
2645
  return this.client.request(() => IconsService_js_1.IconsService.iconPublicGet(iconPath));
@@ -2621,13 +2851,13 @@ class ApplicationsService {
2621
2851
  /**
2622
2852
  * List Application Operations
2623
2853
  * @param applicationId
2624
- * @param search
2854
+ * @param query
2625
2855
  * @param limit
2626
2856
  * @param pageToken
2627
2857
  * @returns OperationListResponse Successful Response
2628
2858
  * @throws ApiError
2629
2859
  */
2630
- static applicationOperationList(applicationId, search, limit = 100, pageToken) {
2860
+ static applicationOperationList(applicationId, query, limit = 100, pageToken) {
2631
2861
  return (0, request_js_1.request)(OpenAPI_js_1.OpenAPI, {
2632
2862
  method: 'GET',
2633
2863
  url: '/integrations/applications/{application_id}/operations',
@@ -2635,7 +2865,7 @@ class ApplicationsService {
2635
2865
  'application_id': applicationId,
2636
2866
  },
2637
2867
  query: {
2638
- 'search': search,
2868
+ 'query': query,
2639
2869
  'limit': limit,
2640
2870
  'page_token': pageToken,
2641
2871
  },
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 } from "./auth.js";
12
+ export { AuthManager, buildAuthUrl, 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 } from "./auth.js";
12
+ export { AuthManager, buildAuthUrl, clearTestingToken, getTestingToken, resolveSafeRedirectUri, setTestingToken, } from "./auth.js";
13
13
  export { ApiError } from "./http.js";
package/dist/client.d.ts CHANGED
@@ -21,6 +21,9 @@ import { WorkflowsNamespace } from "./namespaces/workflows.js";
21
21
  export type { LemmaConfig };
22
22
  export { AuthManager };
23
23
  export type { AuthState, AuthListener };
24
+ interface LemmaClientInternalOptions {
25
+ authManager?: AuthManager;
26
+ }
24
27
  export declare class LemmaClient {
25
28
  private readonly _config;
26
29
  private readonly _podId;
@@ -48,7 +51,7 @@ export declare class LemmaClient {
48
51
  readonly podMembers: PodMembersNamespace;
49
52
  readonly organizations: OrganizationsNamespace;
50
53
  readonly podSurfaces: PodSurfacesNamespace;
51
- constructor(overrides?: Partial<LemmaConfig>);
54
+ constructor(overrides?: Partial<LemmaConfig>, internalOptions?: LemmaClientInternalOptions);
52
55
  /** Change the active pod ID for subsequent calls. */
53
56
  setPodId(podId: string): void;
54
57
  /** Return a new client scoped to a specific pod, sharing auth state. */
package/dist/client.js CHANGED
@@ -49,11 +49,11 @@ export class LemmaClient {
49
49
  podMembers;
50
50
  organizations;
51
51
  podSurfaces;
52
- constructor(overrides = {}) {
52
+ constructor(overrides = {}, internalOptions = {}) {
53
53
  this._config = resolveConfig(overrides);
54
54
  this._currentPodId = this._config.podId;
55
55
  this._podId = this._config.podId;
56
- this.auth = new AuthManager(this._config.apiUrl, this._config.authUrl);
56
+ this.auth = internalOptions.authManager ?? new AuthManager(this._config.apiUrl, this._config.authUrl);
57
57
  this._http = new HttpClient(this._config.apiUrl, this.auth);
58
58
  this._generated = new GeneratedClientAdapter(this._config.apiUrl, this.auth);
59
59
  const podIdFn = () => {
@@ -88,7 +88,7 @@ export class LemmaClient {
88
88
  }
89
89
  /** Return a new client scoped to a specific pod, sharing auth state. */
90
90
  withPod(podId) {
91
- return new LemmaClient({ ...this._config, podId });
91
+ return new LemmaClient({ ...this._config, podId }, { authManager: this.auth });
92
92
  }
93
93
  get podId() {
94
94
  return this._currentPodId;
package/dist/index.d.ts CHANGED
@@ -1,11 +1,17 @@
1
1
  export { LemmaClient } from "./client.js";
2
2
  export type { LemmaConfig } from "./client.js";
3
- export { AuthManager } from "./auth.js";
4
- export type { AuthState, AuthListener, AuthStatus, UserInfo } from "./auth.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";
5
5
  export { ApiError } from "./http.js";
6
6
  export * from "./types.js";
7
7
  export { readSSE, parseSSEJson } from "./streams.js";
8
8
  export type { SseRawEvent } from "./streams.js";
9
+ export { normalizeRunStatus, isTerminalTaskStatus, isTerminalFunctionStatus, isTerminalFlowStatus, sleep, nextBackoffDelay, } from "./run-utils.js";
10
+ export type { AnyRunStatus } from "./run-utils.js";
11
+ export { parseTaskStreamEvent, upsertTaskMessage } from "./task-events.js";
12
+ export type { ParsedTaskStreamEvent } from "./task-events.js";
13
+ export { parseAssistantStreamEvent, upsertConversationMessage } from "./assistant-events.js";
14
+ export type { ParsedAssistantStreamEvent } from "./assistant-events.js";
9
15
  export type { AgentsNamespace } from "./namespaces/agents.js";
10
16
  export type { AssistantsNamespace, ConversationsNamespace } from "./namespaces/assistants.js";
11
17
  export type { DatastoresNamespace } from "./namespaces/datastores.js";
package/dist/index.js CHANGED
@@ -1,5 +1,8 @@
1
1
  export { LemmaClient } from "./client.js";
2
- export { AuthManager } from "./auth.js";
2
+ export { AuthManager, buildAuthUrl, 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";
6
+ export { normalizeRunStatus, isTerminalTaskStatus, isTerminalFunctionStatus, isTerminalFlowStatus, sleep, nextBackoffDelay, } from "./run-utils.js";
7
+ export { parseTaskStreamEvent, upsertTaskMessage } from "./task-events.js";
8
+ export { parseAssistantStreamEvent, upsertConversationMessage } from "./assistant-events.js";
@@ -1,7 +1,7 @@
1
1
  import type { GeneratedClientAdapter } from "../generated.js";
2
2
  import type { HttpClient } from "../http.js";
3
- import type { Body_pod_desk_bundle_upload } from "../openapi_client/models/Body_pod_desk_bundle_upload.js";
4
3
  import type { CreateDeskRequest } from "../openapi_client/models/CreateDeskRequest.js";
4
+ import type { DeskBundleUploadRequest } from "../openapi_client/models/DeskBundleUploadRequest.js";
5
5
  import type { UpdateDeskRequest } from "../openapi_client/models/UpdateDeskRequest.js";
6
6
  export declare class DesksNamespace {
7
7
  private readonly client;
@@ -20,7 +20,7 @@ export declare class DesksNamespace {
20
20
  get: (name: string) => Promise<string>;
21
21
  };
22
22
  readonly bundle: {
23
- upload: (name: string, payload: Body_pod_desk_bundle_upload) => Promise<import("../types.js").DeskBundleUploadResponse>;
23
+ upload: (name: string, payload: DeskBundleUploadRequest) => Promise<import("../types.js").DeskBundleUploadResponse>;
24
24
  };
25
25
  readonly source: {
26
26
  download: (name: string) => Promise<Blob>;
@@ -9,25 +9,25 @@ export class DesksNamespace {
9
9
  this.podId = podId;
10
10
  }
11
11
  list(options = {}) {
12
- return this.client.request(() => DesksService.podDeskList(this.podId(), options.limit ?? 100, options.pageToken));
12
+ return this.client.request(() => DesksService.deskList(this.podId(), options.limit ?? 100, options.pageToken));
13
13
  }
14
14
  create(payload) {
15
- return this.client.request(() => DesksService.podDeskCreate(this.podId(), payload));
15
+ return this.client.request(() => DesksService.deskCreate(this.podId(), payload));
16
16
  }
17
17
  get(name) {
18
- return this.client.request(() => DesksService.podDeskGet(this.podId(), name));
18
+ return this.client.request(() => DesksService.deskGet(this.podId(), name));
19
19
  }
20
20
  update(name, payload) {
21
- return this.client.request(() => DesksService.podDeskUpdate(this.podId(), name, payload));
21
+ return this.client.request(() => DesksService.deskUpdate(this.podId(), name, payload));
22
22
  }
23
23
  delete(name) {
24
- return this.client.request(() => DesksService.podDeskDelete(this.podId(), name));
24
+ return this.client.request(() => DesksService.deskDelete(this.podId(), name));
25
25
  }
26
26
  html = {
27
- get: (name) => this.client.request(() => DesksService.podDeskHtmlGet(this.podId(), name)),
27
+ get: (name) => this.client.request(() => DesksService.deskHtmlGet(this.podId(), name)),
28
28
  };
29
29
  bundle = {
30
- upload: (name, payload) => this.client.request(() => DesksService.podDeskBundleUpload(this.podId(), name, payload)),
30
+ upload: (name, payload) => this.client.request(() => DesksService.deskBundleUpload(this.podId(), name, payload)),
31
31
  };
32
32
  source = {
33
33
  download: (name) => this.http.requestBytes("GET", `/pods/${this.podId()}/desks/${name}/source/archive`),
@@ -5,7 +5,10 @@ export class IconsNamespace {
5
5
  this.client = client;
6
6
  }
7
7
  upload(file) {
8
- return this.client.request(() => IconsService.iconUpload({ file }));
8
+ const payload = {
9
+ file: file,
10
+ };
11
+ return this.client.request(() => IconsService.iconUpload(payload));
9
12
  }
10
13
  getPublic(iconPath) {
11
14
  return this.client.request(() => IconsService.iconPublicGet(iconPath));