@lunnoa/client 2.0.0 → 2.2.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;
@@ -129,7 +129,10 @@ declare class HttpClient {
129
129
 
130
130
  type ChatMode = 'builder' | 'preview';
131
131
  interface StreamMessageOptions {
132
- /** Agent chat mode; defaults to the server default (`builder`). */
132
+ /**
133
+ * Agent chat mode. Defaults to `preview` (10 model rounds, a normal agent run).
134
+ * `builder` is the agent-editor interview and stops after 4 rounds.
135
+ */
133
136
  chatMode?: ChatMode;
134
137
  /** Optional image attachment forwarded with this turn. */
135
138
  data?: {
@@ -1449,6 +1452,26 @@ interface paths {
1449
1452
  patch?: never;
1450
1453
  trace?: never;
1451
1454
  };
1455
+ "/api/ai-connections": {
1456
+ parameters: {
1457
+ query?: never;
1458
+ header?: never;
1459
+ path?: never;
1460
+ cookie?: never;
1461
+ };
1462
+ /**
1463
+ * List AI connections available to the caller
1464
+ * @description Returns AI provider connections the caller may assign to an agent, each with the catalogue model ids that connection accepts. Use `models[].id` as the agent `model`. `isDefault` marks the connection and model applied when a deploy omits them. App connections (Gmail, HTTP, and similar) are listed separately at `GET /api/connections`. Credentials are never returned. Requires `agents:create`.
1465
+ */
1466
+ get: operations["AiConnectionsController_list"];
1467
+ put?: never;
1468
+ post?: never;
1469
+ delete?: never;
1470
+ options?: never;
1471
+ head?: never;
1472
+ patch?: never;
1473
+ trace?: never;
1474
+ };
1452
1475
  "/api/connections": {
1453
1476
  parameters: {
1454
1477
  query?: never;
@@ -2406,7 +2429,7 @@ interface components {
2406
2429
  description?: string;
2407
2430
  /** @description System instructions / prompt for the agent. */
2408
2431
  instructions: string;
2409
- /** @description Selected model id on the AI provider connection (e.g. `gpt-4o`). */
2432
+ /** @description Catalogue model id enabled on the AI connection. Example: `deepseek-ai/DeepSeek-V4-Pro`. Discover ids with GET /api/ai-connections. */
2410
2433
  model: string;
2411
2434
  /** @description AiProviderConnection UUID. When omitted, platform AI defaults apply. */
2412
2435
  aiConnectionId?: string;
@@ -3543,6 +3566,32 @@ interface components {
3543
3566
  /** Format: date-time */
3544
3567
  updatedAt: string;
3545
3568
  };
3569
+ PublicAiModelResponseDto: {
3570
+ /** @description Catalogue model id passed to agent deploy as `model`. Example: `deepseek-ai/DeepSeek-V4-Pro`. */
3571
+ id: string;
3572
+ /** @description Display name. */
3573
+ name: string;
3574
+ /** @description True when this is the model used if an agent deploy omits `model` on this connection. */
3575
+ isDefault: boolean;
3576
+ /** @description Whether the model can call tools. */
3577
+ supportsTools: boolean;
3578
+ /** @description Whether the model accepts image input. */
3579
+ supportsVision: boolean;
3580
+ /** @description Whether the model exposes a reasoning mode. */
3581
+ supportsReasoning: boolean;
3582
+ };
3583
+ PublicAiConnectionResponseDto: {
3584
+ /** @description AiProviderConnection UUID. Pass as `aiConnectionId` / `defineAiConnection({ id })` when this connection is not the default. */
3585
+ id: string;
3586
+ /** @description Connection display name. Example: `Lunnoa LLMs`. */
3587
+ name: string;
3588
+ /** @description Provider slug. Example: `featherless` or `openai`. */
3589
+ provider: string;
3590
+ /** @description True for the connection used when an agent deploy omits `aiConnectionId`. */
3591
+ isDefault: boolean;
3592
+ /** @description Models this connection accepts. Inactive models are omitted. */
3593
+ models: components["schemas"]["PublicAiModelResponseDto"][];
3594
+ };
3546
3595
  ConnectionWorkspaceDto: {
3547
3596
  /** @description Workspace ID. */
3548
3597
  id: string;
@@ -5477,7 +5526,7 @@ interface operations {
5477
5526
  query?: {
5478
5527
  /** @description Comma-separated inclusion flags. Available: all, internal. Pass internal to include executions of internal workflows, which are excluded by default. */
5479
5528
  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> */
5529
+ /** @description Comma-separated key:value filters. Available: workflowId, source (WORKFLOW|SDK), objectId. Example: filterBy=workflowId:wf_123 or filterBy=objectId:<uuid> */
5481
5530
  filterBy?: string;
5482
5531
  /** @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
5532
  expansion?: string;
@@ -5812,6 +5861,26 @@ interface operations {
5812
5861
  };
5813
5862
  };
5814
5863
  };
5864
+ AiConnectionsController_list: {
5865
+ parameters: {
5866
+ query?: never;
5867
+ header?: never;
5868
+ path?: never;
5869
+ cookie?: never;
5870
+ };
5871
+ requestBody?: never;
5872
+ responses: {
5873
+ /** @description AI connections and the models each one accepts. */
5874
+ 200: {
5875
+ headers: {
5876
+ [name: string]: unknown;
5877
+ };
5878
+ content: {
5879
+ "application/json": components["schemas"]["PublicAiConnectionResponseDto"][];
5880
+ };
5881
+ };
5882
+ };
5883
+ };
5815
5884
  ConnectionsController_findAllForWorkspace: {
5816
5885
  parameters: {
5817
5886
  query?: {
@@ -6597,7 +6666,10 @@ interface AgentDefinition {
6597
6666
  slug: string;
6598
6667
  name?: string;
6599
6668
  description?: string;
6600
- /** Selected model id on the AI provider connection. */
6669
+ /**
6670
+ * Catalogue model id from `ai-connections list` (`models[].id`).
6671
+ * Example on Lunnoa LLMs: `deepseek-ai/DeepSeek-V4-Pro`.
6672
+ */
6601
6673
  model: string;
6602
6674
  instructions: string;
6603
6675
  aiConnection?: AiConnectionDefinition;
@@ -6721,7 +6793,7 @@ interface CurrentUser {
6721
6793
  }
6722
6794
 
6723
6795
  /**
6724
- * Login, refresh, SSO discovery, and session helpers for Pattern B.
6796
+ * Login, refresh, SSO discovery, and session helpers for Lunnoa users.
6725
6797
  *
6726
6798
  * Password login, token exchange, refresh, and SSO provider listing are
6727
6799
  * **public** endpoints (no Bearer). `me()` requires a user JWT.
@@ -6810,6 +6882,36 @@ declare class SsoAuthResource {
6810
6882
  getLoginUrl(providerId: string): string;
6811
6883
  }
6812
6884
 
6885
+ interface AiConnectionModel {
6886
+ /** Catalogue id for `defineAgent({ model })`. */
6887
+ id: string;
6888
+ name: string;
6889
+ isDefault: boolean;
6890
+ supportsTools: boolean;
6891
+ supportsVision: boolean;
6892
+ supportsReasoning: boolean;
6893
+ }
6894
+ interface AiConnection {
6895
+ /** AiProviderConnection UUID for `defineAiConnection({ id })`. */
6896
+ id: string;
6897
+ name: string;
6898
+ /** Provider slug, for example `featherless` or `openai`. */
6899
+ provider: string;
6900
+ /** True when agent deploy uses this connection if `aiConnection` is omitted. */
6901
+ isDefault: boolean;
6902
+ models: AiConnectionModel[];
6903
+ }
6904
+ declare class AiConnectionsResource {
6905
+ private readonly http;
6906
+ constructor(http: HttpClient);
6907
+ /**
6908
+ * Lists AI connections the caller can assign to an agent, with the model
6909
+ * ids each connection accepts. Credentials are never included.
6910
+ * Requires `agents:create` (the same permission as agent deploy).
6911
+ */
6912
+ list(): Promise<AiConnection[]>;
6913
+ }
6914
+
6813
6915
  declare class ConnectionsResource {
6814
6916
  private readonly http;
6815
6917
  constructor(http: HttpClient);
@@ -7379,28 +7481,21 @@ declare class WorkflowsResource {
7379
7481
  /**
7380
7482
  * Typed client for the Lunnoa Automate Public API.
7381
7483
  *
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):
7484
+ * Apps sign people in as Lunnoa users:
7391
7485
  * ```ts
7392
7486
  * import { createBrowserClient } from '@lunnoa/client';
7393
7487
  * const lunnoa = createBrowserClient({ baseUrl: 'https://lunnoa.acme.example' });
7394
7488
  * await lunnoa.auth.login({ email, password });
7395
7489
  * ```
7396
7490
  *
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.
7491
+ * `apiKey` (`lna_...`) is for the CLI and operator scripts (codegen, discovery,
7492
+ * deploy). It is not an app login. Passing one while `window` exists throws:
7493
+ * a leaked key acts as that service account across its whole workspace.
7399
7494
  */
7400
7495
  declare class LunnoaClient {
7401
7496
  /** The underlying HTTP layer, exposed for advanced/escape-hatch requests. */
7402
7497
  readonly http: HttpClient;
7403
- /** Login, refresh, SSO discovery, and session helpers (Pattern B). */
7498
+ /** Login, refresh, SSO discovery, and session helpers for Lunnoa users. */
7404
7499
  readonly auth: AuthResource;
7405
7500
  readonly agents: AgentsResource;
7406
7501
  readonly tasks: TasksResource;
@@ -7427,6 +7522,8 @@ declare class LunnoaClient {
7427
7522
  readonly variables: VariablesResource;
7428
7523
  readonly scorecards: ScorecardsResource;
7429
7524
  readonly connections: ConnectionsResource;
7525
+ /** AI provider connections and the model ids each one accepts. */
7526
+ readonly aiConnections: AiConnectionsResource;
7430
7527
  readonly workflowApps: WorkflowAppsResource;
7431
7528
  readonly discovery: DiscoveryResource;
7432
7529
  constructor(options: LunnoaClientOptions);
@@ -7463,11 +7560,10 @@ declare const API_KEY_PREFIX = "lna_";
7463
7560
  /** Returns true when running inside a browser (or browser-like) environment. */
7464
7561
  declare function isBrowserEnvironment(): boolean;
7465
7562
  /**
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.
7563
+ * API keys are operator credentials (CLI, codegen, deploy). Shipping one to a
7564
+ * browser exposes the whole workspace the key is scoped to, so the SDK refuses.
7468
7565
  *
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).
7566
+ * Apps authenticate end users with a Lunnoa user JWT.
7471
7567
  */
7472
7568
  declare function assertApiKeyAllowedInEnvironment(apiKey: string): void;
7473
7569
 
@@ -7540,7 +7636,7 @@ interface CreateBrowserClientOptions {
7540
7636
  headers?: Record<string, string>;
7541
7637
  }
7542
7638
  /**
7543
- * Pattern B helper: browser (or isomorphic) client with JWT storage,
7639
+ * Browser (or isomorphic) client with JWT storage,
7544
7640
  * `lunnoa.auth.login` / refresh, and optional auto-refresh on 401.
7545
7641
  *
7546
7642
  * Never pass an `lna_` API key here.
@@ -7550,13 +7646,13 @@ interface CreateServerClientOptions {
7550
7646
  /** Base URL of the Lunnoa Automate deployment. */
7551
7647
  baseUrl: string;
7552
7648
  /**
7553
- * Workspace API key (`lna_...`). Preferred for Pattern A backends / BFFs.
7649
+ * Workspace API key (`lna_...`) for operator scripts and the CLI.
7650
+ * Not an app login: people using an app authenticate as Lunnoa users.
7554
7651
  * Mutually exclusive with `accessToken` / `tokenStore`.
7555
7652
  */
7556
7653
  apiKey?: string;
7557
7654
  /**
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.
7655
+ * User JWT (or getter) when the server already holds a signed-in Lunnoa user's token.
7560
7656
  */
7561
7657
  accessToken?: string | (() => string | Promise<string>);
7562
7658
  /** Optional store when the server holds both access and refresh tokens. */
@@ -7566,11 +7662,10 @@ interface CreateServerClientOptions {
7566
7662
  headers?: Record<string, string>;
7567
7663
  }
7568
7664
  /**
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.
7665
+ * Node helper for a Lunnoa user JWT held on the server, or an `lna_` key for
7666
+ * operator scripts. App login uses {@link createBrowserClient}. Throws if
7667
+ * used with an API key in a browser.
7573
7668
  */
7574
7669
  declare function createServerClient(options: CreateServerClientOptions): LunnoaClient;
7575
7670
 
7576
- export { API_KEY_PREFIX, type ActionDefinition, ActionsResource, type AddQueueItemErrorInput, type Agent, AgentChatClient, AgentChatStream, type AgentDefinition, type AgentToolDefinition, AgentsResource, type AiConnectionDefinition, type ApprovalInboxItem, ApprovalsResource, AuthResource, type AuthTokens, type BulkCreateQueueItemsInput, type BulkCreateQueueItemsResult, type ChangeEntityStateInput, type ChangeEntityStateResult, type ChatMode, type Connection, type ConnectionDefinition, ConnectionsResource, type CreateBrowserClientOptions, type CreateEntityInput, type CreateKnowledgeInput, type CreateQueueInput, type CreateQueueItemInput, type CreateServerClientOptions, type CreateTaskInput, type CreateVariableInput, type CurrentUser, DEFINE_KINDS, type DefineKind, type DeletedTask, DiscoveryResource, type EligibleApprover, type EnabledFeatures, EntitiesResource, type Entity, type EntityStateHistoryEntry, type EntityStateTransitions, type EntityType, type EntityTypeDefinition, type EntityTypeReadOptions, EntityTypesResource, type ExecuteWorkflowResult, type Execution, type ExecutionPathStep, type ExecutionProgress, type ExecutionProgressPayload, type ExecutionProgressStep, ExecutionProgressStream, type ExecutionStatus, type ExecutionStreamEvent, type ExecutionStreamEventType, ExecutionTimeoutError, ExecutionsResource, type ExportEntitiesInput, type FetchLike, HttpClient, type ImportEntitiesInput, type ImportEntitiesResult, type ImportTemplate, type Knowledge, type KnowledgeDocument, type KnowledgeDocumentGroup, KnowledgeResource, type ListEntitiesOptions, type ListQueryOptions, type ListQueueItemsByObjectOptions, type ListQueueItemsOptions, type LocalStorageTokenStoreOptions, type LoginRequires2FA, type LoginResult, type LoginSuccess, LunnoaApiError, LunnoaClient, type LunnoaClientOptions, type MessageTaskInput, type OffsetPagination, type PagePagination, type PaginatedEntities, type PendingInput, type PendingInputField, type QueryValue, type Queue, type QueueAllowedObjectType, type QueueItem, type QueueItemCreated, type QueueItemErrorEntry, type QueueItemFull, type QueueItemList, type QueueItemObjectSummary, type QueueItemStats, type QueueItemStatus, QueueItemsResource, type QueueStats, QueuesResource, type RecordMeasureValueInput, type RequestOptions, type RunActionInput, type RunActionOptions, type RunActionResult, RunsResource, type SaveUploadedTextInput, type Scorecard, type ScorecardMeasure, type ScorecardMeasureStatus, type ScorecardMeasureValue, type ScorecardObjective, type ScorecardSummary, ScorecardsResource, type SseEvent, SsoAuthResource, type SsoProviderSummary, type SsoProvidersResponse, type StartRunInput, type StartRunInputDto, type StartRunOptions, type StartRunStep, type StopStreamOptions, type StreamMessageOptions, type Table, TablesResource, type Task, type TaskListItem, TasksResource, type TokenStore, type UpdateEntityInput, type UpdateKnowledgeInput, type UpdateQueueInput, type UpdateQueueItemInput, type UpdateTaskInput, type UpdateVariableInput, type UpsertAgentBySlugInput, type UpsertAgentBySlugInputDto, type UpsertAgentToolInput, type UpsertEntityTypeBySlugInput, type UpsertTableBySlugInput, type UpsertWorkflowBySlugInput, type UpsertWorkflowBySlugInputDto, type UpsertWorkflowStepInput, type Variable, VariablesResource, type WaitUntilFinishedOptions, type WatchProgressOptions, type Workflow, type WorkflowApp, WorkflowAppsResource, type WorkflowDefinition, type WorkflowStepDefinition, WorkflowsResource, assertApiKeyAllowedInEnvironment, type components, createBrowserClient, createLocalStorageTokenStore, createMemoryTokenStore, createServerClient, defineAction, defineAgent, defineAiConnection, defineConnection, defineEntityType, defineWorkflow, entityTypeDefinitionToUpsert, isBrowserEnvironment, isLoginRequires2FA, iterateOffset, iteratePages, type operations, parseSseEvents, parseSseStream, type paths, resolveActionAppId, resolveActionId };
7671
+ export { API_KEY_PREFIX, type ActionDefinition, ActionsResource, type AddQueueItemErrorInput, type Agent, AgentChatClient, AgentChatStream, type AgentDefinition, type AgentToolDefinition, AgentsResource, type AiConnection, type AiConnectionDefinition, type AiConnectionModel, AiConnectionsResource, type ApprovalInboxItem, ApprovalsResource, AuthResource, type AuthTokens, type BulkCreateQueueItemsInput, type BulkCreateQueueItemsResult, type ChangeEntityStateInput, type ChangeEntityStateResult, type ChatMode, type Connection, type ConnectionDefinition, ConnectionsResource, type CreateBrowserClientOptions, type CreateEntityInput, type CreateKnowledgeInput, type CreateQueueInput, type CreateQueueItemInput, type CreateServerClientOptions, type CreateTaskInput, type CreateVariableInput, type CurrentUser, DEFINE_KINDS, type DefineKind, type DeletedTask, DiscoveryResource, type EligibleApprover, type EnabledFeatures, EntitiesResource, type Entity, type EntityStateHistoryEntry, type EntityStateTransitions, type EntityType, type EntityTypeDefinition, type EntityTypeReadOptions, EntityTypesResource, type ExecuteWorkflowResult, type Execution, type ExecutionPathStep, type ExecutionProgress, type ExecutionProgressPayload, type ExecutionProgressStep, ExecutionProgressStream, type ExecutionStatus, type ExecutionStreamEvent, type ExecutionStreamEventType, ExecutionTimeoutError, ExecutionsResource, type ExportEntitiesInput, type FetchLike, HttpClient, type ImportEntitiesInput, type ImportEntitiesResult, type ImportTemplate, type Knowledge, type KnowledgeDocument, type KnowledgeDocumentGroup, KnowledgeResource, type ListEntitiesOptions, type ListQueryOptions, type ListQueueItemsByObjectOptions, type ListQueueItemsOptions, type LocalStorageTokenStoreOptions, type LoginRequires2FA, type LoginResult, type LoginSuccess, LunnoaApiError, LunnoaClient, type LunnoaClientOptions, type MessageTaskInput, type OffsetPagination, type PagePagination, type PaginatedEntities, type PendingInput, type PendingInputField, type QueryValue, type Queue, type QueueAllowedObjectType, type QueueItem, type QueueItemCreated, type QueueItemErrorEntry, type QueueItemFull, type QueueItemList, type QueueItemObjectSummary, type QueueItemStats, type QueueItemStatus, QueueItemsResource, type QueueStats, QueuesResource, type RecordMeasureValueInput, type RequestOptions, type RunActionInput, type RunActionOptions, type RunActionResult, RunsResource, type SaveUploadedTextInput, type Scorecard, type ScorecardMeasure, type ScorecardMeasureStatus, type ScorecardMeasureValue, type ScorecardObjective, type ScorecardSummary, ScorecardsResource, type SseEvent, SsoAuthResource, type SsoProviderSummary, type SsoProvidersResponse, type StartRunInput, type StartRunInputDto, type StartRunOptions, type StartRunStep, type StopStreamOptions, type StreamMessageOptions, type Table, TablesResource, type Task, type TaskListItem, TasksResource, type TokenStore, type UpdateEntityInput, type UpdateKnowledgeInput, type UpdateQueueInput, type UpdateQueueItemInput, type UpdateTaskInput, type UpdateVariableInput, type UpsertAgentBySlugInput, type UpsertAgentBySlugInputDto, type UpsertAgentToolInput, type UpsertEntityTypeBySlugInput, type UpsertTableBySlugInput, type UpsertWorkflowBySlugInput, type UpsertWorkflowBySlugInputDto, type UpsertWorkflowStepInput, type Variable, VariablesResource, type WaitUntilFinishedOptions, type WatchProgressOptions, type Workflow, type WorkflowApp, WorkflowAppsResource, type WorkflowDefinition, type WorkflowStepDefinition, WorkflowsResource, assertApiKeyAllowedInEnvironment, type components, createBrowserClient, createLocalStorageTokenStore, createMemoryTokenStore, createServerClient, defineAction, defineAgent, defineAiConnection, defineConnection, defineEntityType, defineWorkflow, entityTypeDefinitionToUpsert, isBrowserEnvironment, isLoginRequires2FA, iterateOffset, iteratePages, type operations, parseSseEvents, parseSseStream, type paths, resolveActionAppId, resolveActionId };
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;
@@ -129,7 +129,10 @@ declare class HttpClient {
129
129
 
130
130
  type ChatMode = 'builder' | 'preview';
131
131
  interface StreamMessageOptions {
132
- /** Agent chat mode; defaults to the server default (`builder`). */
132
+ /**
133
+ * Agent chat mode. Defaults to `preview` (10 model rounds, a normal agent run).
134
+ * `builder` is the agent-editor interview and stops after 4 rounds.
135
+ */
133
136
  chatMode?: ChatMode;
134
137
  /** Optional image attachment forwarded with this turn. */
135
138
  data?: {
@@ -1449,6 +1452,26 @@ interface paths {
1449
1452
  patch?: never;
1450
1453
  trace?: never;
1451
1454
  };
1455
+ "/api/ai-connections": {
1456
+ parameters: {
1457
+ query?: never;
1458
+ header?: never;
1459
+ path?: never;
1460
+ cookie?: never;
1461
+ };
1462
+ /**
1463
+ * List AI connections available to the caller
1464
+ * @description Returns AI provider connections the caller may assign to an agent, each with the catalogue model ids that connection accepts. Use `models[].id` as the agent `model`. `isDefault` marks the connection and model applied when a deploy omits them. App connections (Gmail, HTTP, and similar) are listed separately at `GET /api/connections`. Credentials are never returned. Requires `agents:create`.
1465
+ */
1466
+ get: operations["AiConnectionsController_list"];
1467
+ put?: never;
1468
+ post?: never;
1469
+ delete?: never;
1470
+ options?: never;
1471
+ head?: never;
1472
+ patch?: never;
1473
+ trace?: never;
1474
+ };
1452
1475
  "/api/connections": {
1453
1476
  parameters: {
1454
1477
  query?: never;
@@ -2406,7 +2429,7 @@ interface components {
2406
2429
  description?: string;
2407
2430
  /** @description System instructions / prompt for the agent. */
2408
2431
  instructions: string;
2409
- /** @description Selected model id on the AI provider connection (e.g. `gpt-4o`). */
2432
+ /** @description Catalogue model id enabled on the AI connection. Example: `deepseek-ai/DeepSeek-V4-Pro`. Discover ids with GET /api/ai-connections. */
2410
2433
  model: string;
2411
2434
  /** @description AiProviderConnection UUID. When omitted, platform AI defaults apply. */
2412
2435
  aiConnectionId?: string;
@@ -3543,6 +3566,32 @@ interface components {
3543
3566
  /** Format: date-time */
3544
3567
  updatedAt: string;
3545
3568
  };
3569
+ PublicAiModelResponseDto: {
3570
+ /** @description Catalogue model id passed to agent deploy as `model`. Example: `deepseek-ai/DeepSeek-V4-Pro`. */
3571
+ id: string;
3572
+ /** @description Display name. */
3573
+ name: string;
3574
+ /** @description True when this is the model used if an agent deploy omits `model` on this connection. */
3575
+ isDefault: boolean;
3576
+ /** @description Whether the model can call tools. */
3577
+ supportsTools: boolean;
3578
+ /** @description Whether the model accepts image input. */
3579
+ supportsVision: boolean;
3580
+ /** @description Whether the model exposes a reasoning mode. */
3581
+ supportsReasoning: boolean;
3582
+ };
3583
+ PublicAiConnectionResponseDto: {
3584
+ /** @description AiProviderConnection UUID. Pass as `aiConnectionId` / `defineAiConnection({ id })` when this connection is not the default. */
3585
+ id: string;
3586
+ /** @description Connection display name. Example: `Lunnoa LLMs`. */
3587
+ name: string;
3588
+ /** @description Provider slug. Example: `featherless` or `openai`. */
3589
+ provider: string;
3590
+ /** @description True for the connection used when an agent deploy omits `aiConnectionId`. */
3591
+ isDefault: boolean;
3592
+ /** @description Models this connection accepts. Inactive models are omitted. */
3593
+ models: components["schemas"]["PublicAiModelResponseDto"][];
3594
+ };
3546
3595
  ConnectionWorkspaceDto: {
3547
3596
  /** @description Workspace ID. */
3548
3597
  id: string;
@@ -5477,7 +5526,7 @@ interface operations {
5477
5526
  query?: {
5478
5527
  /** @description Comma-separated inclusion flags. Available: all, internal. Pass internal to include executions of internal workflows, which are excluded by default. */
5479
5528
  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> */
5529
+ /** @description Comma-separated key:value filters. Available: workflowId, source (WORKFLOW|SDK), objectId. Example: filterBy=workflowId:wf_123 or filterBy=objectId:<uuid> */
5481
5530
  filterBy?: string;
5482
5531
  /** @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
5532
  expansion?: string;
@@ -5812,6 +5861,26 @@ interface operations {
5812
5861
  };
5813
5862
  };
5814
5863
  };
5864
+ AiConnectionsController_list: {
5865
+ parameters: {
5866
+ query?: never;
5867
+ header?: never;
5868
+ path?: never;
5869
+ cookie?: never;
5870
+ };
5871
+ requestBody?: never;
5872
+ responses: {
5873
+ /** @description AI connections and the models each one accepts. */
5874
+ 200: {
5875
+ headers: {
5876
+ [name: string]: unknown;
5877
+ };
5878
+ content: {
5879
+ "application/json": components["schemas"]["PublicAiConnectionResponseDto"][];
5880
+ };
5881
+ };
5882
+ };
5883
+ };
5815
5884
  ConnectionsController_findAllForWorkspace: {
5816
5885
  parameters: {
5817
5886
  query?: {
@@ -6597,7 +6666,10 @@ interface AgentDefinition {
6597
6666
  slug: string;
6598
6667
  name?: string;
6599
6668
  description?: string;
6600
- /** Selected model id on the AI provider connection. */
6669
+ /**
6670
+ * Catalogue model id from `ai-connections list` (`models[].id`).
6671
+ * Example on Lunnoa LLMs: `deepseek-ai/DeepSeek-V4-Pro`.
6672
+ */
6601
6673
  model: string;
6602
6674
  instructions: string;
6603
6675
  aiConnection?: AiConnectionDefinition;
@@ -6721,7 +6793,7 @@ interface CurrentUser {
6721
6793
  }
6722
6794
 
6723
6795
  /**
6724
- * Login, refresh, SSO discovery, and session helpers for Pattern B.
6796
+ * Login, refresh, SSO discovery, and session helpers for Lunnoa users.
6725
6797
  *
6726
6798
  * Password login, token exchange, refresh, and SSO provider listing are
6727
6799
  * **public** endpoints (no Bearer). `me()` requires a user JWT.
@@ -6810,6 +6882,36 @@ declare class SsoAuthResource {
6810
6882
  getLoginUrl(providerId: string): string;
6811
6883
  }
6812
6884
 
6885
+ interface AiConnectionModel {
6886
+ /** Catalogue id for `defineAgent({ model })`. */
6887
+ id: string;
6888
+ name: string;
6889
+ isDefault: boolean;
6890
+ supportsTools: boolean;
6891
+ supportsVision: boolean;
6892
+ supportsReasoning: boolean;
6893
+ }
6894
+ interface AiConnection {
6895
+ /** AiProviderConnection UUID for `defineAiConnection({ id })`. */
6896
+ id: string;
6897
+ name: string;
6898
+ /** Provider slug, for example `featherless` or `openai`. */
6899
+ provider: string;
6900
+ /** True when agent deploy uses this connection if `aiConnection` is omitted. */
6901
+ isDefault: boolean;
6902
+ models: AiConnectionModel[];
6903
+ }
6904
+ declare class AiConnectionsResource {
6905
+ private readonly http;
6906
+ constructor(http: HttpClient);
6907
+ /**
6908
+ * Lists AI connections the caller can assign to an agent, with the model
6909
+ * ids each connection accepts. Credentials are never included.
6910
+ * Requires `agents:create` (the same permission as agent deploy).
6911
+ */
6912
+ list(): Promise<AiConnection[]>;
6913
+ }
6914
+
6813
6915
  declare class ConnectionsResource {
6814
6916
  private readonly http;
6815
6917
  constructor(http: HttpClient);
@@ -7379,28 +7481,21 @@ declare class WorkflowsResource {
7379
7481
  /**
7380
7482
  * Typed client for the Lunnoa Automate Public API.
7381
7483
  *
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):
7484
+ * Apps sign people in as Lunnoa users:
7391
7485
  * ```ts
7392
7486
  * import { createBrowserClient } from '@lunnoa/client';
7393
7487
  * const lunnoa = createBrowserClient({ baseUrl: 'https://lunnoa.acme.example' });
7394
7488
  * await lunnoa.auth.login({ email, password });
7395
7489
  * ```
7396
7490
  *
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.
7491
+ * `apiKey` (`lna_...`) is for the CLI and operator scripts (codegen, discovery,
7492
+ * deploy). It is not an app login. Passing one while `window` exists throws:
7493
+ * a leaked key acts as that service account across its whole workspace.
7399
7494
  */
7400
7495
  declare class LunnoaClient {
7401
7496
  /** The underlying HTTP layer, exposed for advanced/escape-hatch requests. */
7402
7497
  readonly http: HttpClient;
7403
- /** Login, refresh, SSO discovery, and session helpers (Pattern B). */
7498
+ /** Login, refresh, SSO discovery, and session helpers for Lunnoa users. */
7404
7499
  readonly auth: AuthResource;
7405
7500
  readonly agents: AgentsResource;
7406
7501
  readonly tasks: TasksResource;
@@ -7427,6 +7522,8 @@ declare class LunnoaClient {
7427
7522
  readonly variables: VariablesResource;
7428
7523
  readonly scorecards: ScorecardsResource;
7429
7524
  readonly connections: ConnectionsResource;
7525
+ /** AI provider connections and the model ids each one accepts. */
7526
+ readonly aiConnections: AiConnectionsResource;
7430
7527
  readonly workflowApps: WorkflowAppsResource;
7431
7528
  readonly discovery: DiscoveryResource;
7432
7529
  constructor(options: LunnoaClientOptions);
@@ -7463,11 +7560,10 @@ declare const API_KEY_PREFIX = "lna_";
7463
7560
  /** Returns true when running inside a browser (or browser-like) environment. */
7464
7561
  declare function isBrowserEnvironment(): boolean;
7465
7562
  /**
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.
7563
+ * API keys are operator credentials (CLI, codegen, deploy). Shipping one to a
7564
+ * browser exposes the whole workspace the key is scoped to, so the SDK refuses.
7468
7565
  *
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).
7566
+ * Apps authenticate end users with a Lunnoa user JWT.
7471
7567
  */
7472
7568
  declare function assertApiKeyAllowedInEnvironment(apiKey: string): void;
7473
7569
 
@@ -7540,7 +7636,7 @@ interface CreateBrowserClientOptions {
7540
7636
  headers?: Record<string, string>;
7541
7637
  }
7542
7638
  /**
7543
- * Pattern B helper: browser (or isomorphic) client with JWT storage,
7639
+ * Browser (or isomorphic) client with JWT storage,
7544
7640
  * `lunnoa.auth.login` / refresh, and optional auto-refresh on 401.
7545
7641
  *
7546
7642
  * Never pass an `lna_` API key here.
@@ -7550,13 +7646,13 @@ interface CreateServerClientOptions {
7550
7646
  /** Base URL of the Lunnoa Automate deployment. */
7551
7647
  baseUrl: string;
7552
7648
  /**
7553
- * Workspace API key (`lna_...`). Preferred for Pattern A backends / BFFs.
7649
+ * Workspace API key (`lna_...`) for operator scripts and the CLI.
7650
+ * Not an app login: people using an app authenticate as Lunnoa users.
7554
7651
  * Mutually exclusive with `accessToken` / `tokenStore`.
7555
7652
  */
7556
7653
  apiKey?: string;
7557
7654
  /**
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.
7655
+ * User JWT (or getter) when the server already holds a signed-in Lunnoa user's token.
7560
7656
  */
7561
7657
  accessToken?: string | (() => string | Promise<string>);
7562
7658
  /** Optional store when the server holds both access and refresh tokens. */
@@ -7566,11 +7662,10 @@ interface CreateServerClientOptions {
7566
7662
  headers?: Record<string, string>;
7567
7663
  }
7568
7664
  /**
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.
7665
+ * Node helper for a Lunnoa user JWT held on the server, or an `lna_` key for
7666
+ * operator scripts. App login uses {@link createBrowserClient}. Throws if
7667
+ * used with an API key in a browser.
7573
7668
  */
7574
7669
  declare function createServerClient(options: CreateServerClientOptions): LunnoaClient;
7575
7670
 
7576
- export { API_KEY_PREFIX, type ActionDefinition, ActionsResource, type AddQueueItemErrorInput, type Agent, AgentChatClient, AgentChatStream, type AgentDefinition, type AgentToolDefinition, AgentsResource, type AiConnectionDefinition, type ApprovalInboxItem, ApprovalsResource, AuthResource, type AuthTokens, type BulkCreateQueueItemsInput, type BulkCreateQueueItemsResult, type ChangeEntityStateInput, type ChangeEntityStateResult, type ChatMode, type Connection, type ConnectionDefinition, ConnectionsResource, type CreateBrowserClientOptions, type CreateEntityInput, type CreateKnowledgeInput, type CreateQueueInput, type CreateQueueItemInput, type CreateServerClientOptions, type CreateTaskInput, type CreateVariableInput, type CurrentUser, DEFINE_KINDS, type DefineKind, type DeletedTask, DiscoveryResource, type EligibleApprover, type EnabledFeatures, EntitiesResource, type Entity, type EntityStateHistoryEntry, type EntityStateTransitions, type EntityType, type EntityTypeDefinition, type EntityTypeReadOptions, EntityTypesResource, type ExecuteWorkflowResult, type Execution, type ExecutionPathStep, type ExecutionProgress, type ExecutionProgressPayload, type ExecutionProgressStep, ExecutionProgressStream, type ExecutionStatus, type ExecutionStreamEvent, type ExecutionStreamEventType, ExecutionTimeoutError, ExecutionsResource, type ExportEntitiesInput, type FetchLike, HttpClient, type ImportEntitiesInput, type ImportEntitiesResult, type ImportTemplate, type Knowledge, type KnowledgeDocument, type KnowledgeDocumentGroup, KnowledgeResource, type ListEntitiesOptions, type ListQueryOptions, type ListQueueItemsByObjectOptions, type ListQueueItemsOptions, type LocalStorageTokenStoreOptions, type LoginRequires2FA, type LoginResult, type LoginSuccess, LunnoaApiError, LunnoaClient, type LunnoaClientOptions, type MessageTaskInput, type OffsetPagination, type PagePagination, type PaginatedEntities, type PendingInput, type PendingInputField, type QueryValue, type Queue, type QueueAllowedObjectType, type QueueItem, type QueueItemCreated, type QueueItemErrorEntry, type QueueItemFull, type QueueItemList, type QueueItemObjectSummary, type QueueItemStats, type QueueItemStatus, QueueItemsResource, type QueueStats, QueuesResource, type RecordMeasureValueInput, type RequestOptions, type RunActionInput, type RunActionOptions, type RunActionResult, RunsResource, type SaveUploadedTextInput, type Scorecard, type ScorecardMeasure, type ScorecardMeasureStatus, type ScorecardMeasureValue, type ScorecardObjective, type ScorecardSummary, ScorecardsResource, type SseEvent, SsoAuthResource, type SsoProviderSummary, type SsoProvidersResponse, type StartRunInput, type StartRunInputDto, type StartRunOptions, type StartRunStep, type StopStreamOptions, type StreamMessageOptions, type Table, TablesResource, type Task, type TaskListItem, TasksResource, type TokenStore, type UpdateEntityInput, type UpdateKnowledgeInput, type UpdateQueueInput, type UpdateQueueItemInput, type UpdateTaskInput, type UpdateVariableInput, type UpsertAgentBySlugInput, type UpsertAgentBySlugInputDto, type UpsertAgentToolInput, type UpsertEntityTypeBySlugInput, type UpsertTableBySlugInput, type UpsertWorkflowBySlugInput, type UpsertWorkflowBySlugInputDto, type UpsertWorkflowStepInput, type Variable, VariablesResource, type WaitUntilFinishedOptions, type WatchProgressOptions, type Workflow, type WorkflowApp, WorkflowAppsResource, type WorkflowDefinition, type WorkflowStepDefinition, WorkflowsResource, assertApiKeyAllowedInEnvironment, type components, createBrowserClient, createLocalStorageTokenStore, createMemoryTokenStore, createServerClient, defineAction, defineAgent, defineAiConnection, defineConnection, defineEntityType, defineWorkflow, entityTypeDefinitionToUpsert, isBrowserEnvironment, isLoginRequires2FA, iterateOffset, iteratePages, type operations, parseSseEvents, parseSseStream, type paths, resolveActionAppId, resolveActionId };
7671
+ export { API_KEY_PREFIX, type ActionDefinition, ActionsResource, type AddQueueItemErrorInput, type Agent, AgentChatClient, AgentChatStream, type AgentDefinition, type AgentToolDefinition, AgentsResource, type AiConnection, type AiConnectionDefinition, type AiConnectionModel, AiConnectionsResource, type ApprovalInboxItem, ApprovalsResource, AuthResource, type AuthTokens, type BulkCreateQueueItemsInput, type BulkCreateQueueItemsResult, type ChangeEntityStateInput, type ChangeEntityStateResult, type ChatMode, type Connection, type ConnectionDefinition, ConnectionsResource, type CreateBrowserClientOptions, type CreateEntityInput, type CreateKnowledgeInput, type CreateQueueInput, type CreateQueueItemInput, type CreateServerClientOptions, type CreateTaskInput, type CreateVariableInput, type CurrentUser, DEFINE_KINDS, type DefineKind, type DeletedTask, DiscoveryResource, type EligibleApprover, type EnabledFeatures, EntitiesResource, type Entity, type EntityStateHistoryEntry, type EntityStateTransitions, type EntityType, type EntityTypeDefinition, type EntityTypeReadOptions, EntityTypesResource, type ExecuteWorkflowResult, type Execution, type ExecutionPathStep, type ExecutionProgress, type ExecutionProgressPayload, type ExecutionProgressStep, ExecutionProgressStream, type ExecutionStatus, type ExecutionStreamEvent, type ExecutionStreamEventType, ExecutionTimeoutError, ExecutionsResource, type ExportEntitiesInput, type FetchLike, HttpClient, type ImportEntitiesInput, type ImportEntitiesResult, type ImportTemplate, type Knowledge, type KnowledgeDocument, type KnowledgeDocumentGroup, KnowledgeResource, type ListEntitiesOptions, type ListQueryOptions, type ListQueueItemsByObjectOptions, type ListQueueItemsOptions, type LocalStorageTokenStoreOptions, type LoginRequires2FA, type LoginResult, type LoginSuccess, LunnoaApiError, LunnoaClient, type LunnoaClientOptions, type MessageTaskInput, type OffsetPagination, type PagePagination, type PaginatedEntities, type PendingInput, type PendingInputField, type QueryValue, type Queue, type QueueAllowedObjectType, type QueueItem, type QueueItemCreated, type QueueItemErrorEntry, type QueueItemFull, type QueueItemList, type QueueItemObjectSummary, type QueueItemStats, type QueueItemStatus, QueueItemsResource, type QueueStats, QueuesResource, type RecordMeasureValueInput, type RequestOptions, type RunActionInput, type RunActionOptions, type RunActionResult, RunsResource, type SaveUploadedTextInput, type Scorecard, type ScorecardMeasure, type ScorecardMeasureStatus, type ScorecardMeasureValue, type ScorecardObjective, type ScorecardSummary, ScorecardsResource, type SseEvent, SsoAuthResource, type SsoProviderSummary, type SsoProvidersResponse, type StartRunInput, type StartRunInputDto, type StartRunOptions, type StartRunStep, type StopStreamOptions, type StreamMessageOptions, type Table, TablesResource, type Task, type TaskListItem, TasksResource, type TokenStore, type UpdateEntityInput, type UpdateKnowledgeInput, type UpdateQueueInput, type UpdateQueueItemInput, type UpdateTaskInput, type UpdateVariableInput, type UpsertAgentBySlugInput, type UpsertAgentBySlugInputDto, type UpsertAgentToolInput, type UpsertEntityTypeBySlugInput, type UpsertTableBySlugInput, type UpsertWorkflowBySlugInput, type UpsertWorkflowBySlugInputDto, type UpsertWorkflowStepInput, type Variable, VariablesResource, type WaitUntilFinishedOptions, type WatchProgressOptions, type Workflow, type WorkflowApp, WorkflowAppsResource, type WorkflowDefinition, type WorkflowStepDefinition, WorkflowsResource, assertApiKeyAllowedInEnvironment, type components, createBrowserClient, createLocalStorageTokenStore, createMemoryTokenStore, createServerClient, defineAction, defineAgent, defineAiConnection, defineConnection, defineEntityType, defineWorkflow, entityTypeDefinitionToUpsert, isBrowserEnvironment, isLoginRequires2FA, iterateOffset, iteratePages, type operations, parseSseEvents, parseSseStream, type paths, resolveActionAppId, resolveActionId };