@lunnoa/client 2.0.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -2,7 +2,7 @@ import { UIMessage, UIMessageChunk } from 'ai';
2
2
  export { UIMessage, UIMessageChunk } from 'ai';
3
3
 
4
4
  /**
5
- * Pluggable storage for Pattern B JWTs.
5
+ * Pluggable storage for Lunnoa user JWTs.
6
6
  * The SDK never uses httpOnly cookies: Automate auth is bearer JWT based.
7
7
  */
8
8
  interface TokenStore {
@@ -46,20 +46,20 @@ interface LunnoaClientOptions {
46
46
  */
47
47
  baseUrl: string;
48
48
  /**
49
- * Server-side machine credential (`lna_...`). Never usable in browsers —
50
- * the constructor throws if one is supplied while `window` exists.
49
+ * Machine credential (`lna_...`) for the CLI and operator scripts, not for app login.
50
+ * Never usable in browsers: the constructor throws if one is supplied while `window` exists.
51
51
  */
52
52
  apiKey?: string;
53
53
  /**
54
54
  * User JWT obtained from login / SSO. The supported credential for browser
55
55
  * applications. May be a function so refreshed tokens are picked up per request.
56
56
  *
57
- * Prefer {@link tokenStore} for Pattern B so login/refresh can persist tokens
57
+ * Prefer {@link tokenStore} so login/refresh can persist tokens
58
58
  * and optionally auto-refresh on 401.
59
59
  */
60
60
  accessToken?: string | (() => string | Promise<string>);
61
61
  /**
62
- * Optional JWT store for Pattern B. When set, authenticated requests read
62
+ * Optional JWT store for a signed-in Lunnoa user. When set, authenticated requests read
63
63
  * the access token from the store. Login / refresh helpers write back into it.
64
64
  */
65
65
  tokenStore?: TokenStore;
@@ -5477,7 +5477,7 @@ interface operations {
5477
5477
  query?: {
5478
5478
  /** @description Comma-separated inclusion flags. Available: all, internal. Pass internal to include executions of internal workflows, which are excluded by default. */
5479
5479
  includeType?: string;
5480
- /** @description Comma-separated key:value filters. Available: projectId, workflowId, source (WORKFLOW|SDK), objectId. Example: filterBy=workflowId:wf_123 or filterBy=objectId:<uuid> */
5480
+ /** @description Comma-separated key:value filters. Available: workflowId, source (WORKFLOW|SDK), objectId. Example: filterBy=workflowId:wf_123 or filterBy=objectId:<uuid> */
5481
5481
  filterBy?: string;
5482
5482
  /** @description Comma-separated fields to expand. Available: createdAt, updatedAt, startedAt, stoppedAt, executionNumber, nodes, edges, status, statusMessage, continueExecutionAt, workflow, project, workspace, output, orientation, executionVariables, source, name. The executionPath expansion is only honoured on GET /executions/{executionId}. Example: expansion=status,startedAt,workflow,source */
5483
5483
  expansion?: string;
@@ -6721,7 +6721,7 @@ interface CurrentUser {
6721
6721
  }
6722
6722
 
6723
6723
  /**
6724
- * Login, refresh, SSO discovery, and session helpers for Pattern B.
6724
+ * Login, refresh, SSO discovery, and session helpers for Lunnoa users.
6725
6725
  *
6726
6726
  * Password login, token exchange, refresh, and SSO provider listing are
6727
6727
  * **public** endpoints (no Bearer). `me()` requires a user JWT.
@@ -7379,28 +7379,21 @@ declare class WorkflowsResource {
7379
7379
  /**
7380
7380
  * Typed client for the Lunnoa Automate Public API.
7381
7381
  *
7382
- * Server-side (Pattern A — the backend holds the key):
7383
- * ```ts
7384
- * const lunnoa = new LunnoaClient({
7385
- * baseUrl: 'https://lunnoa.acme.example',
7386
- * apiKey: process.env.LUNNOA_API_KEY, // lna_...
7387
- * });
7388
- * ```
7389
- *
7390
- * Browser (Pattern B — the end user is a Lunnoa user):
7382
+ * Apps sign people in as Lunnoa users:
7391
7383
  * ```ts
7392
7384
  * import { createBrowserClient } from '@lunnoa/client';
7393
7385
  * const lunnoa = createBrowserClient({ baseUrl: 'https://lunnoa.acme.example' });
7394
7386
  * await lunnoa.auth.login({ email, password });
7395
7387
  * ```
7396
7388
  *
7397
- * Passing an `lna_` API key in a browser throws immediately: API keys are
7398
- * workspace-wide server credentials and must never ship to browsers.
7389
+ * `apiKey` (`lna_...`) is for the CLI and operator scripts (codegen, discovery,
7390
+ * deploy). It is not an app login. Passing one while `window` exists throws:
7391
+ * a leaked key acts as that service account across its whole workspace.
7399
7392
  */
7400
7393
  declare class LunnoaClient {
7401
7394
  /** The underlying HTTP layer, exposed for advanced/escape-hatch requests. */
7402
7395
  readonly http: HttpClient;
7403
- /** Login, refresh, SSO discovery, and session helpers (Pattern B). */
7396
+ /** Login, refresh, SSO discovery, and session helpers for Lunnoa users. */
7404
7397
  readonly auth: AuthResource;
7405
7398
  readonly agents: AgentsResource;
7406
7399
  readonly tasks: TasksResource;
@@ -7463,11 +7456,10 @@ declare const API_KEY_PREFIX = "lna_";
7463
7456
  /** Returns true when running inside a browser (or browser-like) environment. */
7464
7457
  declare function isBrowserEnvironment(): boolean;
7465
7458
  /**
7466
- * API keys are server-to-server credentials. Shipping one to a browser exposes
7467
- * the whole workspace the key is scoped to, so the SDK refuses outright.
7459
+ * API keys are operator credentials (CLI, codegen, deploy). Shipping one to a
7460
+ * browser exposes the whole workspace the key is scoped to, so the SDK refuses.
7468
7461
  *
7469
- * Browser apps must authenticate end users with a Lunnoa user JWT (Pattern B)
7470
- * or proxy through their own backend which holds the key (Pattern A / BFF).
7462
+ * Apps authenticate end users with a Lunnoa user JWT.
7471
7463
  */
7472
7464
  declare function assertApiKeyAllowedInEnvironment(apiKey: string): void;
7473
7465
 
@@ -7540,7 +7532,7 @@ interface CreateBrowserClientOptions {
7540
7532
  headers?: Record<string, string>;
7541
7533
  }
7542
7534
  /**
7543
- * Pattern B helper: browser (or isomorphic) client with JWT storage,
7535
+ * Browser (or isomorphic) client with JWT storage,
7544
7536
  * `lunnoa.auth.login` / refresh, and optional auto-refresh on 401.
7545
7537
  *
7546
7538
  * Never pass an `lna_` API key here.
@@ -7550,13 +7542,13 @@ interface CreateServerClientOptions {
7550
7542
  /** Base URL of the Lunnoa Automate deployment. */
7551
7543
  baseUrl: string;
7552
7544
  /**
7553
- * Workspace API key (`lna_...`). Preferred for Pattern A backends / BFFs.
7545
+ * Workspace API key (`lna_...`) for operator scripts and the CLI.
7546
+ * Not an app login: people using an app authenticate as Lunnoa users.
7554
7547
  * Mutually exclusive with `accessToken` / `tokenStore`.
7555
7548
  */
7556
7549
  apiKey?: string;
7557
7550
  /**
7558
- * User JWT (or getter) when the server acts on behalf of a logged-in user.
7559
- * Prefer this over embedding tokens in the browser when you own the session.
7551
+ * User JWT (or getter) when the server already holds a signed-in Lunnoa user's token.
7560
7552
  */
7561
7553
  accessToken?: string | (() => string | Promise<string>);
7562
7554
  /** Optional store when the server holds both access and refresh tokens. */
@@ -7566,10 +7558,9 @@ interface CreateServerClientOptions {
7566
7558
  headers?: Record<string, string>;
7567
7559
  }
7568
7560
  /**
7569
- * Pattern A (or server-side Pattern B) helper for Node / BFF / route handlers.
7570
- *
7571
- * Provide `apiKey` for a service account, or `accessToken` / `tokenStore` for a
7572
- * user JWT held on the server. Throws if used with an API key in a browser.
7561
+ * Node helper for a Lunnoa user JWT held on the server, or an `lna_` key for
7562
+ * operator scripts. App login uses {@link createBrowserClient}. Throws if
7563
+ * used with an API key in a browser.
7573
7564
  */
7574
7565
  declare function createServerClient(options: CreateServerClientOptions): LunnoaClient;
7575
7566
 
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { UIMessage, UIMessageChunk } from 'ai';
2
2
  export { UIMessage, UIMessageChunk } from 'ai';
3
3
 
4
4
  /**
5
- * Pluggable storage for Pattern B JWTs.
5
+ * Pluggable storage for Lunnoa user JWTs.
6
6
  * The SDK never uses httpOnly cookies: Automate auth is bearer JWT based.
7
7
  */
8
8
  interface TokenStore {
@@ -46,20 +46,20 @@ interface LunnoaClientOptions {
46
46
  */
47
47
  baseUrl: string;
48
48
  /**
49
- * Server-side machine credential (`lna_...`). Never usable in browsers —
50
- * the constructor throws if one is supplied while `window` exists.
49
+ * Machine credential (`lna_...`) for the CLI and operator scripts, not for app login.
50
+ * Never usable in browsers: the constructor throws if one is supplied while `window` exists.
51
51
  */
52
52
  apiKey?: string;
53
53
  /**
54
54
  * User JWT obtained from login / SSO. The supported credential for browser
55
55
  * applications. May be a function so refreshed tokens are picked up per request.
56
56
  *
57
- * Prefer {@link tokenStore} for Pattern B so login/refresh can persist tokens
57
+ * Prefer {@link tokenStore} so login/refresh can persist tokens
58
58
  * and optionally auto-refresh on 401.
59
59
  */
60
60
  accessToken?: string | (() => string | Promise<string>);
61
61
  /**
62
- * Optional JWT store for Pattern B. When set, authenticated requests read
62
+ * Optional JWT store for a signed-in Lunnoa user. When set, authenticated requests read
63
63
  * the access token from the store. Login / refresh helpers write back into it.
64
64
  */
65
65
  tokenStore?: TokenStore;
@@ -5477,7 +5477,7 @@ interface operations {
5477
5477
  query?: {
5478
5478
  /** @description Comma-separated inclusion flags. Available: all, internal. Pass internal to include executions of internal workflows, which are excluded by default. */
5479
5479
  includeType?: string;
5480
- /** @description Comma-separated key:value filters. Available: projectId, workflowId, source (WORKFLOW|SDK), objectId. Example: filterBy=workflowId:wf_123 or filterBy=objectId:<uuid> */
5480
+ /** @description Comma-separated key:value filters. Available: workflowId, source (WORKFLOW|SDK), objectId. Example: filterBy=workflowId:wf_123 or filterBy=objectId:<uuid> */
5481
5481
  filterBy?: string;
5482
5482
  /** @description Comma-separated fields to expand. Available: createdAt, updatedAt, startedAt, stoppedAt, executionNumber, nodes, edges, status, statusMessage, continueExecutionAt, workflow, project, workspace, output, orientation, executionVariables, source, name. The executionPath expansion is only honoured on GET /executions/{executionId}. Example: expansion=status,startedAt,workflow,source */
5483
5483
  expansion?: string;
@@ -6721,7 +6721,7 @@ interface CurrentUser {
6721
6721
  }
6722
6722
 
6723
6723
  /**
6724
- * Login, refresh, SSO discovery, and session helpers for Pattern B.
6724
+ * Login, refresh, SSO discovery, and session helpers for Lunnoa users.
6725
6725
  *
6726
6726
  * Password login, token exchange, refresh, and SSO provider listing are
6727
6727
  * **public** endpoints (no Bearer). `me()` requires a user JWT.
@@ -7379,28 +7379,21 @@ declare class WorkflowsResource {
7379
7379
  /**
7380
7380
  * Typed client for the Lunnoa Automate Public API.
7381
7381
  *
7382
- * Server-side (Pattern A — the backend holds the key):
7383
- * ```ts
7384
- * const lunnoa = new LunnoaClient({
7385
- * baseUrl: 'https://lunnoa.acme.example',
7386
- * apiKey: process.env.LUNNOA_API_KEY, // lna_...
7387
- * });
7388
- * ```
7389
- *
7390
- * Browser (Pattern B — the end user is a Lunnoa user):
7382
+ * Apps sign people in as Lunnoa users:
7391
7383
  * ```ts
7392
7384
  * import { createBrowserClient } from '@lunnoa/client';
7393
7385
  * const lunnoa = createBrowserClient({ baseUrl: 'https://lunnoa.acme.example' });
7394
7386
  * await lunnoa.auth.login({ email, password });
7395
7387
  * ```
7396
7388
  *
7397
- * Passing an `lna_` API key in a browser throws immediately: API keys are
7398
- * workspace-wide server credentials and must never ship to browsers.
7389
+ * `apiKey` (`lna_...`) is for the CLI and operator scripts (codegen, discovery,
7390
+ * deploy). It is not an app login. Passing one while `window` exists throws:
7391
+ * a leaked key acts as that service account across its whole workspace.
7399
7392
  */
7400
7393
  declare class LunnoaClient {
7401
7394
  /** The underlying HTTP layer, exposed for advanced/escape-hatch requests. */
7402
7395
  readonly http: HttpClient;
7403
- /** Login, refresh, SSO discovery, and session helpers (Pattern B). */
7396
+ /** Login, refresh, SSO discovery, and session helpers for Lunnoa users. */
7404
7397
  readonly auth: AuthResource;
7405
7398
  readonly agents: AgentsResource;
7406
7399
  readonly tasks: TasksResource;
@@ -7463,11 +7456,10 @@ declare const API_KEY_PREFIX = "lna_";
7463
7456
  /** Returns true when running inside a browser (or browser-like) environment. */
7464
7457
  declare function isBrowserEnvironment(): boolean;
7465
7458
  /**
7466
- * API keys are server-to-server credentials. Shipping one to a browser exposes
7467
- * the whole workspace the key is scoped to, so the SDK refuses outright.
7459
+ * API keys are operator credentials (CLI, codegen, deploy). Shipping one to a
7460
+ * browser exposes the whole workspace the key is scoped to, so the SDK refuses.
7468
7461
  *
7469
- * Browser apps must authenticate end users with a Lunnoa user JWT (Pattern B)
7470
- * or proxy through their own backend which holds the key (Pattern A / BFF).
7462
+ * Apps authenticate end users with a Lunnoa user JWT.
7471
7463
  */
7472
7464
  declare function assertApiKeyAllowedInEnvironment(apiKey: string): void;
7473
7465
 
@@ -7540,7 +7532,7 @@ interface CreateBrowserClientOptions {
7540
7532
  headers?: Record<string, string>;
7541
7533
  }
7542
7534
  /**
7543
- * Pattern B helper: browser (or isomorphic) client with JWT storage,
7535
+ * Browser (or isomorphic) client with JWT storage,
7544
7536
  * `lunnoa.auth.login` / refresh, and optional auto-refresh on 401.
7545
7537
  *
7546
7538
  * Never pass an `lna_` API key here.
@@ -7550,13 +7542,13 @@ interface CreateServerClientOptions {
7550
7542
  /** Base URL of the Lunnoa Automate deployment. */
7551
7543
  baseUrl: string;
7552
7544
  /**
7553
- * Workspace API key (`lna_...`). Preferred for Pattern A backends / BFFs.
7545
+ * Workspace API key (`lna_...`) for operator scripts and the CLI.
7546
+ * Not an app login: people using an app authenticate as Lunnoa users.
7554
7547
  * Mutually exclusive with `accessToken` / `tokenStore`.
7555
7548
  */
7556
7549
  apiKey?: string;
7557
7550
  /**
7558
- * User JWT (or getter) when the server acts on behalf of a logged-in user.
7559
- * Prefer this over embedding tokens in the browser when you own the session.
7551
+ * User JWT (or getter) when the server already holds a signed-in Lunnoa user's token.
7560
7552
  */
7561
7553
  accessToken?: string | (() => string | Promise<string>);
7562
7554
  /** Optional store when the server holds both access and refresh tokens. */
@@ -7566,10 +7558,9 @@ interface CreateServerClientOptions {
7566
7558
  headers?: Record<string, string>;
7567
7559
  }
7568
7560
  /**
7569
- * Pattern A (or server-side Pattern B) helper for Node / BFF / route handlers.
7570
- *
7571
- * Provide `apiKey` for a service account, or `accessToken` / `tokenStore` for a
7572
- * user JWT held on the server. Throws if used with an API key in a browser.
7561
+ * Node helper for a Lunnoa user JWT held on the server, or an `lna_` key for
7562
+ * operator scripts. App login uses {@link createBrowserClient}. Throws if
7563
+ * used with an API key in a browser.
7573
7564
  */
7574
7565
  declare function createServerClient(options: CreateServerClientOptions): LunnoaClient;
7575
7566
 
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ function isBrowserEnvironment() {
6
6
  function assertApiKeyAllowedInEnvironment(apiKey) {
7
7
  if (isBrowserEnvironment()) {
8
8
  throw new Error(
9
- "Refusing to use a Lunnoa API key (lna_...) in a browser environment. API keys are server-side credentials: anyone opening dev tools could read the key and act as the service account across its whole workspace. Either call the Lunnoa API from your own backend which holds the key (backend-for-frontend pattern), or authenticate the end user with a Lunnoa user JWT and pass it as `accessToken`."
9
+ "Refusing to use a Lunnoa API key (lna_...) in a browser environment. API keys are for the CLI and operator scripts, not for app login. Anyone opening dev tools could read the key and act as the service account across its whole workspace. Sign the end user in with lunnoa.auth.login and pass their JWT as `accessToken`."
10
10
  );
11
11
  }
12
12
  if (!apiKey.startsWith(API_KEY_PREFIX)) {
@@ -88,7 +88,7 @@ var HttpClient = class {
88
88
  }
89
89
  if (!options.apiKey && !options.accessToken && !options.tokenStore) {
90
90
  throw new Error(
91
- "LunnoaClient requires an apiKey (server-side), an accessToken (user JWT), or a tokenStore (Pattern B)."
91
+ "LunnoaClient requires an accessToken or tokenStore (Lunnoa user JWT), or an apiKey for operator scripts."
92
92
  );
93
93
  }
94
94
  if (options.apiKey) {
@@ -2090,7 +2090,7 @@ var WorkflowsResource = class {
2090
2090
  var LunnoaClient = class {
2091
2091
  /** The underlying HTTP layer, exposed for advanced/escape-hatch requests. */
2092
2092
  http;
2093
- /** Login, refresh, SSO discovery, and session helpers (Pattern B). */
2093
+ /** Login, refresh, SSO discovery, and session helpers for Lunnoa users. */
2094
2094
  auth;
2095
2095
  agents;
2096
2096
  tasks;