@lunnoa/client 2.1.0 → 2.3.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.ts CHANGED
@@ -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?: {
@@ -712,7 +715,7 @@ interface paths {
712
715
  put?: never;
713
716
  /**
714
717
  * Upsert a workflow by slug from a linear step list
715
- * @description Creates or updates a workflow identified by workspace-scoped `slug`. Builds a minimal valid graph (manual trigger → linear catalogue-action steps). Marks `managedByCode` by default. Prefer the CLI (`npx @lunnoa/client workflows deploy`) over calling this from application code.
718
+ * @description Creates or updates a workflow identified by workspace-scoped `slug`. Builds a minimal valid graph (one catalogue trigger, Manually Run when omitted, then linear catalogue-action steps). Marks `managedByCode` by default. Prefer the CLI (`npx @lunnoa/client workflows deploy`) over calling this from application code.
716
719
  */
717
720
  post: operations["WorkflowsController_upsertBySlug"];
718
721
  delete?: never;
@@ -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;
@@ -2291,6 +2314,41 @@ interface components {
2291
2314
  /** @description Step description. */
2292
2315
  description?: string;
2293
2316
  };
2317
+ UpsertWorkflowTriggerInputFieldDto: {
2318
+ /** @description Field id. Callers pass this key to workflows.execute. */
2319
+ id: string;
2320
+ /** @description Label shown on the Manually Run form. */
2321
+ label?: string;
2322
+ description?: string;
2323
+ /** @description text, number, date, or select. Defaults to text. */
2324
+ inputType?: string;
2325
+ /** @description true, or { missingMessage, missingStatus }. */
2326
+ required?: boolean | {
2327
+ [key: string]: unknown;
2328
+ };
2329
+ /** @description Used when the caller omits the field. */
2330
+ defaultValue?: unknown;
2331
+ selectOptions?: {
2332
+ [key: string]: unknown;
2333
+ }[];
2334
+ };
2335
+ UpsertWorkflowTriggerDto: {
2336
+ /** @description Catalogue trigger id, for example flow-control_trigger_manual. */
2337
+ triggerId: string;
2338
+ /** @description Workflow app id. Inferred from triggerId when it contains _trigger_. */
2339
+ appId?: string;
2340
+ /** @description Connection instance UUID for this trigger. */
2341
+ connectionId?: string;
2342
+ /** @description Trigger config fields from the catalogue inputConfig. */
2343
+ input?: {
2344
+ [key: string]: unknown;
2345
+ };
2346
+ /** @description Manual-trigger fields. Stored on the trigger as customInputConfig. */
2347
+ inputs?: components["schemas"]["UpsertWorkflowTriggerInputFieldDto"][];
2348
+ /** @description Display name for the trigger node. */
2349
+ name?: string;
2350
+ description?: string;
2351
+ };
2294
2352
  UpsertWorkflowBySlugDto: {
2295
2353
  /**
2296
2354
  * @description Stable workspace-scoped slug (lowercase, digits, hyphens). Used as the upsert key.
@@ -2302,6 +2360,8 @@ interface components {
2302
2360
  description?: string;
2303
2361
  /** @description Whether the workflow is active. */
2304
2362
  isActive?: boolean;
2363
+ /** @description Catalogue trigger. Omit for a Manually Run trigger with no input fields. */
2364
+ trigger?: components["schemas"]["UpsertWorkflowTriggerDto"];
2305
2365
  /** @description Linear catalogue-action steps (v1; no branches). */
2306
2366
  steps: components["schemas"]["UpsertWorkflowStepDto"][];
2307
2367
  /** @description Marks the row as managed by code (CLI / SDK). Defaults to true on this endpoint. */
@@ -2406,7 +2466,7 @@ interface components {
2406
2466
  description?: string;
2407
2467
  /** @description System instructions / prompt for the agent. */
2408
2468
  instructions: string;
2409
- /** @description Selected model id on the AI provider connection (e.g. `gpt-4o`). */
2469
+ /** @description Catalogue model id enabled on the AI connection. Example: `deepseek-ai/DeepSeek-V4-Pro`. Discover ids with GET /api/ai-connections. */
2410
2470
  model: string;
2411
2471
  /** @description AiProviderConnection UUID. When omitted, platform AI defaults apply. */
2412
2472
  aiConnectionId?: string;
@@ -3543,6 +3603,32 @@ interface components {
3543
3603
  /** Format: date-time */
3544
3604
  updatedAt: string;
3545
3605
  };
3606
+ PublicAiModelResponseDto: {
3607
+ /** @description Catalogue model id passed to agent deploy as `model`. Example: `deepseek-ai/DeepSeek-V4-Pro`. */
3608
+ id: string;
3609
+ /** @description Display name. */
3610
+ name: string;
3611
+ /** @description True when this is the model used if an agent deploy omits `model` on this connection. */
3612
+ isDefault: boolean;
3613
+ /** @description Whether the model can call tools. */
3614
+ supportsTools: boolean;
3615
+ /** @description Whether the model accepts image input. */
3616
+ supportsVision: boolean;
3617
+ /** @description Whether the model exposes a reasoning mode. */
3618
+ supportsReasoning: boolean;
3619
+ };
3620
+ PublicAiConnectionResponseDto: {
3621
+ /** @description AiProviderConnection UUID. Pass as `aiConnectionId` / `defineAiConnection({ id })` when this connection is not the default. */
3622
+ id: string;
3623
+ /** @description Connection display name. Example: `Lunnoa LLMs`. */
3624
+ name: string;
3625
+ /** @description Provider slug. Example: `featherless` or `openai`. */
3626
+ provider: string;
3627
+ /** @description True for the connection used when an agent deploy omits `aiConnectionId`. */
3628
+ isDefault: boolean;
3629
+ /** @description Models this connection accepts. Inactive models are omitted. */
3630
+ models: components["schemas"]["PublicAiModelResponseDto"][];
3631
+ };
3546
3632
  ConnectionWorkspaceDto: {
3547
3633
  /** @description Workspace ID. */
3548
3634
  id: string;
@@ -5812,6 +5898,26 @@ interface operations {
5812
5898
  };
5813
5899
  };
5814
5900
  };
5901
+ AiConnectionsController_list: {
5902
+ parameters: {
5903
+ query?: never;
5904
+ header?: never;
5905
+ path?: never;
5906
+ cookie?: never;
5907
+ };
5908
+ requestBody?: never;
5909
+ responses: {
5910
+ /** @description AI connections and the models each one accepts. */
5911
+ 200: {
5912
+ headers: {
5913
+ [name: string]: unknown;
5914
+ };
5915
+ content: {
5916
+ "application/json": components["schemas"]["PublicAiConnectionResponseDto"][];
5917
+ };
5918
+ };
5919
+ };
5920
+ };
5815
5921
  ConnectionsController_findAllForWorkspace: {
5816
5922
  parameters: {
5817
5923
  query?: {
@@ -6536,6 +6642,7 @@ declare const DEFINE_KINDS: {
6536
6642
  readonly connection: "connection";
6537
6643
  readonly aiConnection: "aiConnection";
6538
6644
  readonly action: "action";
6645
+ readonly trigger: "trigger";
6539
6646
  readonly workflow: "workflow";
6540
6647
  readonly agent: "agent";
6541
6648
  readonly entityType: "entityType";
@@ -6571,6 +6678,43 @@ interface ActionDefinition {
6571
6678
  name?: string;
6572
6679
  description?: string;
6573
6680
  }
6681
+ /** One field on a Manually Run trigger. Stored as `customInputConfig`. */
6682
+ interface TriggerInputFieldDefinition {
6683
+ /** Field id. Callers pass this key to `workflows.execute`. */
6684
+ id: string;
6685
+ label?: string;
6686
+ description?: string;
6687
+ /** `text`, `number`, `date`, or `select`. Defaults to `text` on deploy. */
6688
+ inputType?: string;
6689
+ required?: boolean | {
6690
+ missingMessage?: string;
6691
+ missingStatus?: string;
6692
+ };
6693
+ defaultValue?: unknown;
6694
+ selectOptions?: Array<{
6695
+ label?: string;
6696
+ value?: string;
6697
+ }>;
6698
+ }
6699
+ /** Ref to a catalogue trigger. Credentials stay on the connection, when one is set. */
6700
+ interface TriggerDefinition {
6701
+ kind: typeof DEFINE_KINDS.trigger;
6702
+ /**
6703
+ * Catalogue trigger id, e.g. `flow-control_trigger_manual`.
6704
+ * Discover with `apps get <appId> --json` (`triggers[].triggerId`).
6705
+ */
6706
+ id: string;
6707
+ /** Workflow app id. Inferred from `id` when it matches `{app}_trigger_…`. */
6708
+ appId?: string;
6709
+ /** Optional Connection ref. Omit to let the platform resolve. */
6710
+ connection?: ConnectionDefinition;
6711
+ /** Catalogue trigger config (webhook method, schedule, app trigger fields). */
6712
+ input?: Record<string, unknown>;
6713
+ /** Manual-trigger fields. Stored as `customInputConfig`. */
6714
+ inputs?: TriggerInputFieldDefinition[];
6715
+ name?: string;
6716
+ description?: string;
6717
+ }
6574
6718
  interface WorkflowStepDefinition {
6575
6719
  /** Action definition (or inline action-shaped object). */
6576
6720
  use: ActionDefinition;
@@ -6585,6 +6729,11 @@ interface WorkflowDefinition {
6585
6729
  name?: string;
6586
6730
  description?: string;
6587
6731
  isActive?: boolean;
6732
+ /**
6733
+ * Catalogue trigger. Omit for Manually Run with no input fields.
6734
+ * `runs.start` ignores this and runs the steps only.
6735
+ */
6736
+ trigger?: TriggerDefinition;
6588
6737
  /** Linear steps (v1; no branches). */
6589
6738
  steps: WorkflowStepDefinition[];
6590
6739
  }
@@ -6597,7 +6746,10 @@ interface AgentDefinition {
6597
6746
  slug: string;
6598
6747
  name?: string;
6599
6748
  description?: string;
6600
- /** Selected model id on the AI provider connection. */
6749
+ /**
6750
+ * Catalogue model id from `ai-connections list` (`models[].id`).
6751
+ * Example on Lunnoa LLMs: `deepseek-ai/DeepSeek-V4-Pro`.
6752
+ */
6601
6753
  model: string;
6602
6754
  instructions: string;
6603
6755
  aiConnection?: AiConnectionDefinition;
@@ -6609,6 +6761,7 @@ interface AgentDefinition {
6609
6761
  declare function defineConnection(config?: Omit<ConnectionDefinition, 'kind'>): ConnectionDefinition;
6610
6762
  declare function defineAiConnection(config?: Omit<AiConnectionDefinition, 'kind'>): AiConnectionDefinition;
6611
6763
  declare function defineAction(config: Omit<ActionDefinition, 'kind'>): ActionDefinition;
6764
+ declare function defineTrigger(config: Omit<TriggerDefinition, 'kind'>): TriggerDefinition;
6612
6765
  declare function defineWorkflow(config: Omit<WorkflowDefinition, 'kind'>): WorkflowDefinition;
6613
6766
  declare function defineAgent(config: Omit<AgentDefinition, 'kind'>): AgentDefinition;
6614
6767
  interface EntityTypeDefinition {
@@ -6633,6 +6786,9 @@ interface EntityTypeDefinition {
6633
6786
  declare function defineEntityType(config: Omit<EntityTypeDefinition, 'kind'>): EntityTypeDefinition;
6634
6787
  /** Infer appId from catalogue action ids like `http_action_send-request`. */
6635
6788
  declare function resolveActionAppId(action: ActionDefinition): string;
6789
+ /** Infer appId from catalogue trigger ids like `flow-control_trigger_manual`. */
6790
+ declare function resolveTriggerAppId(trigger: TriggerDefinition): string;
6791
+ declare function resolveTriggerId(trigger: TriggerDefinition): string;
6636
6792
  declare function resolveActionId(action: ActionDefinition): string;
6637
6793
 
6638
6794
  interface UpsertAgentToolInput {
@@ -6810,6 +6966,36 @@ declare class SsoAuthResource {
6810
6966
  getLoginUrl(providerId: string): string;
6811
6967
  }
6812
6968
 
6969
+ interface AiConnectionModel {
6970
+ /** Catalogue id for `defineAgent({ model })`. */
6971
+ id: string;
6972
+ name: string;
6973
+ isDefault: boolean;
6974
+ supportsTools: boolean;
6975
+ supportsVision: boolean;
6976
+ supportsReasoning: boolean;
6977
+ }
6978
+ interface AiConnection {
6979
+ /** AiProviderConnection UUID for `defineAiConnection({ id })`. */
6980
+ id: string;
6981
+ name: string;
6982
+ /** Provider slug, for example `featherless` or `openai`. */
6983
+ provider: string;
6984
+ /** True when agent deploy uses this connection if `aiConnection` is omitted. */
6985
+ isDefault: boolean;
6986
+ models: AiConnectionModel[];
6987
+ }
6988
+ declare class AiConnectionsResource {
6989
+ private readonly http;
6990
+ constructor(http: HttpClient);
6991
+ /**
6992
+ * Lists AI connections the caller can assign to an agent, with the model
6993
+ * ids each connection accepts. Credentials are never included.
6994
+ * Requires `agents:create` (the same permission as agent deploy).
6995
+ */
6996
+ list(): Promise<AiConnection[]>;
6997
+ }
6998
+
6813
6999
  declare class ConnectionsResource {
6814
7000
  private readonly http;
6815
7001
  constructor(http: HttpClient);
@@ -7333,11 +7519,24 @@ interface UpsertWorkflowStepInput {
7333
7519
  name?: string;
7334
7520
  description?: string;
7335
7521
  }
7522
+ interface UpsertWorkflowTriggerInput {
7523
+ triggerId: string;
7524
+ appId?: string;
7525
+ connectionId?: string;
7526
+ /** Catalogue trigger config. */
7527
+ input?: Record<string, unknown>;
7528
+ /** Manual-trigger fields. Stored as `customInputConfig`. */
7529
+ inputs?: TriggerDefinition['inputs'];
7530
+ name?: string;
7531
+ description?: string;
7532
+ }
7336
7533
  interface UpsertWorkflowBySlugInput {
7337
7534
  slug: string;
7338
7535
  name?: string;
7339
7536
  description?: string;
7340
7537
  isActive?: boolean;
7538
+ /** Omit for Manually Run with no input fields. */
7539
+ trigger?: UpsertWorkflowTriggerInput;
7341
7540
  steps: UpsertWorkflowStepInput[];
7342
7541
  managedByCode?: boolean;
7343
7542
  }
@@ -7420,6 +7619,8 @@ declare class LunnoaClient {
7420
7619
  readonly variables: VariablesResource;
7421
7620
  readonly scorecards: ScorecardsResource;
7422
7621
  readonly connections: ConnectionsResource;
7622
+ /** AI provider connections and the model ids each one accepts. */
7623
+ readonly aiConnections: AiConnectionsResource;
7423
7624
  readonly workflowApps: WorkflowAppsResource;
7424
7625
  readonly discovery: DiscoveryResource;
7425
7626
  constructor(options: LunnoaClientOptions);
@@ -7564,4 +7765,4 @@ interface CreateServerClientOptions {
7564
7765
  */
7565
7766
  declare function createServerClient(options: CreateServerClientOptions): LunnoaClient;
7566
7767
 
7567
- 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 };
7768
+ 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 TriggerDefinition, type TriggerInputFieldDefinition, 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 UpsertWorkflowTriggerInput, 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, defineTrigger, defineWorkflow, entityTypeDefinitionToUpsert, isBrowserEnvironment, isLoginRequires2FA, iterateOffset, iteratePages, type operations, parseSseEvents, parseSseStream, type paths, resolveActionAppId, resolveActionId, resolveTriggerAppId, resolveTriggerId };
package/dist/index.js CHANGED
@@ -466,7 +466,7 @@ var AgentChatClient = class {
466
466
  function messageTaskBody(message, options = {}) {
467
467
  return {
468
468
  messages: [message],
469
- ...options.chatMode ? { chatMode: options.chatMode } : {},
469
+ chatMode: options.chatMode ?? "preview",
470
470
  ...options.data ? { data: options.data } : {},
471
471
  ...options.piiResolution ? { piiResolution: options.piiResolution } : {}
472
472
  };
@@ -535,6 +535,7 @@ var DEFINE_KINDS = {
535
535
  connection: "connection",
536
536
  aiConnection: "aiConnection",
537
537
  action: "action",
538
+ trigger: "trigger",
538
539
  workflow: "workflow",
539
540
  agent: "agent",
540
541
  entityType: "entityType"
@@ -551,6 +552,25 @@ function defineAction(config) {
551
552
  }
552
553
  return { kind: DEFINE_KINDS.action, ...config };
553
554
  }
555
+ function assertTriggerConfig(config) {
556
+ if (!config.id?.trim()) {
557
+ throw new Error("defineTrigger requires id (catalogue trigger id)");
558
+ }
559
+ for (const field of config.inputs ?? []) {
560
+ if (!field?.id?.trim()) {
561
+ throw new Error("defineTrigger inputs require id");
562
+ }
563
+ }
564
+ if (config.inputs?.length && config.id.trim() !== "flow-control_trigger_manual") {
565
+ throw new Error(
566
+ "defineTrigger inputs are only valid on flow-control_trigger_manual"
567
+ );
568
+ }
569
+ }
570
+ function defineTrigger(config) {
571
+ assertTriggerConfig(config);
572
+ return { kind: DEFINE_KINDS.trigger, ...config };
573
+ }
554
574
  function defineWorkflow(config) {
555
575
  if (!config.slug?.trim()) {
556
576
  throw new Error("defineWorkflow requires slug");
@@ -558,6 +578,9 @@ function defineWorkflow(config) {
558
578
  if (!config.steps?.length) {
559
579
  throw new Error("defineWorkflow requires at least one step");
560
580
  }
581
+ if (config.trigger) {
582
+ assertTriggerConfig(config.trigger);
583
+ }
561
584
  return { kind: DEFINE_KINDS.workflow, ...config };
562
585
  }
563
586
  function defineAgent(config) {
@@ -603,6 +626,40 @@ function resolveActionAppId(action) {
603
626
  `Cannot infer appId for action "${id}". Pass appId explicitly.`
604
627
  );
605
628
  }
629
+ function resolveTriggerAppId(trigger) {
630
+ if (trigger.appId?.trim()) {
631
+ return trigger.appId.trim();
632
+ }
633
+ const id = trigger.id.trim();
634
+ const marker = "_trigger_";
635
+ const markerIndex = id.indexOf(marker);
636
+ if (markerIndex > 0) {
637
+ return id.slice(0, markerIndex);
638
+ }
639
+ const dot = id.indexOf(".");
640
+ if (dot > 0) {
641
+ return id.slice(0, dot);
642
+ }
643
+ throw new Error(
644
+ `Cannot infer appId for trigger "${id}". Pass appId explicitly.`
645
+ );
646
+ }
647
+ function resolveTriggerId(trigger) {
648
+ const id = trigger.id.trim();
649
+ const appId = trigger.appId?.trim();
650
+ if (appId && id.startsWith(`${appId}.`)) {
651
+ return id.slice(appId.length + 1);
652
+ }
653
+ const marker = "_trigger_";
654
+ if (id.includes(marker)) {
655
+ return id;
656
+ }
657
+ const dot = id.indexOf(".");
658
+ if (dot > 0) {
659
+ return id.slice(dot + 1);
660
+ }
661
+ return id;
662
+ }
606
663
  function resolveActionId(action) {
607
664
  const id = action.id.trim();
608
665
  const appId = action.appId?.trim();
@@ -892,6 +949,22 @@ var SsoAuthResource = class {
892
949
  }
893
950
  };
894
951
 
952
+ // src/resources/ai-connections.ts
953
+ var AiConnectionsResource = class {
954
+ constructor(http) {
955
+ this.http = http;
956
+ }
957
+ http;
958
+ /**
959
+ * Lists AI connections the caller can assign to an agent, with the model
960
+ * ids each connection accepts. Credentials are never included.
961
+ * Requires `agents:create` (the same permission as agent deploy).
962
+ */
963
+ list() {
964
+ return this.http.get("/api/ai-connections");
965
+ }
966
+ };
967
+
895
968
  // src/resources/connections.ts
896
969
  var ConnectionsResource = class {
897
970
  constructor(http) {
@@ -2001,6 +2074,17 @@ var WorkflowAppsResource = class {
2001
2074
  };
2002
2075
 
2003
2076
  // src/resources/workflows.ts
2077
+ function triggerToUpsertInput(trigger) {
2078
+ return {
2079
+ triggerId: resolveTriggerId(trigger),
2080
+ appId: resolveTriggerAppId(trigger),
2081
+ ...trigger.connection?.id ? { connectionId: trigger.connection.id } : {},
2082
+ ...trigger.input ? { input: trigger.input } : {},
2083
+ ...trigger.inputs?.length ? { inputs: trigger.inputs } : {},
2084
+ ...trigger.name ? { name: trigger.name } : {},
2085
+ ...trigger.description ? { description: trigger.description } : {}
2086
+ };
2087
+ }
2004
2088
  function stepToUpsertInput(step) {
2005
2089
  const use = step.use;
2006
2090
  return {
@@ -2021,6 +2105,7 @@ function workflowDefinitionToUpsert(def) {
2021
2105
  name: def.name,
2022
2106
  description: def.description,
2023
2107
  isActive: def.isActive,
2108
+ ...def.trigger ? { trigger: triggerToUpsertInput(def.trigger) } : {},
2024
2109
  managedByCode: true,
2025
2110
  steps: def.steps.map(stepToUpsertInput)
2026
2111
  };
@@ -2117,6 +2202,8 @@ var LunnoaClient = class {
2117
2202
  variables;
2118
2203
  scorecards;
2119
2204
  connections;
2205
+ /** AI provider connections and the model ids each one accepts. */
2206
+ aiConnections;
2120
2207
  workflowApps;
2121
2208
  discovery;
2122
2209
  constructor(options) {
@@ -2140,6 +2227,7 @@ var LunnoaClient = class {
2140
2227
  this.variables = new VariablesResource(this.http);
2141
2228
  this.scorecards = new ScorecardsResource(this.http);
2142
2229
  this.connections = new ConnectionsResource(this.http);
2230
+ this.aiConnections = new AiConnectionsResource(this.http);
2143
2231
  this.discovery = new DiscoveryResource(this.http);
2144
2232
  }
2145
2233
  };
@@ -2216,6 +2304,6 @@ function createServerClient(options) {
2216
2304
  });
2217
2305
  }
2218
2306
 
2219
- export { API_KEY_PREFIX, ActionsResource, AgentChatClient, AgentChatStream, AgentsResource, ApprovalsResource, AuthResource, ConnectionsResource, DEFINE_KINDS, DiscoveryResource, EntitiesResource, EntityTypesResource, ExecutionProgressStream, ExecutionTimeoutError, ExecutionsResource, HttpClient, KnowledgeResource, LunnoaApiError, LunnoaClient, QueueItemsResource, QueuesResource, RunsResource, ScorecardsResource, SsoAuthResource, TablesResource, TasksResource, VariablesResource, WorkflowAppsResource, WorkflowsResource, assertApiKeyAllowedInEnvironment, createBrowserClient, createLocalStorageTokenStore, createMemoryTokenStore, createServerClient, defineAction, defineAgent, defineAiConnection, defineConnection, defineEntityType, defineWorkflow, entityTypeDefinitionToUpsert, isBrowserEnvironment, isLoginRequires2FA, iterateOffset, iteratePages, parseSseEvents, parseSseStream, resolveActionAppId, resolveActionId };
2307
+ export { API_KEY_PREFIX, ActionsResource, AgentChatClient, AgentChatStream, AgentsResource, AiConnectionsResource, ApprovalsResource, AuthResource, ConnectionsResource, DEFINE_KINDS, DiscoveryResource, EntitiesResource, EntityTypesResource, ExecutionProgressStream, ExecutionTimeoutError, ExecutionsResource, HttpClient, KnowledgeResource, LunnoaApiError, LunnoaClient, QueueItemsResource, QueuesResource, RunsResource, ScorecardsResource, SsoAuthResource, TablesResource, TasksResource, VariablesResource, WorkflowAppsResource, WorkflowsResource, assertApiKeyAllowedInEnvironment, createBrowserClient, createLocalStorageTokenStore, createMemoryTokenStore, createServerClient, defineAction, defineAgent, defineAiConnection, defineConnection, defineEntityType, defineTrigger, defineWorkflow, entityTypeDefinitionToUpsert, isBrowserEnvironment, isLoginRequires2FA, iterateOffset, iteratePages, parseSseEvents, parseSseStream, resolveActionAppId, resolveActionId, resolveTriggerAppId, resolveTriggerId };
2220
2308
  //# sourceMappingURL=index.js.map
2221
2309
  //# sourceMappingURL=index.js.map