@lunnoa/client 2.1.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunnoa/client",
3
- "version": "2.1.0",
3
+ "version": "2.2.0",
4
4
  "description": "TypeScript SDK for building applications on top of Lunnoa Automate — typed client for the Public API (agents, workflows, executions, entities, knowledge, queues), SSE agent chat streaming, and deployment-specific codegen",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -58,11 +58,15 @@ Run these before inventing resources or shipping UI code:
58
58
  3. **Discover before inventing** — prefer the CLI (JSON for agents), then
59
59
  the SDK: `npx @lunnoa/client tools list --json --for-agent`,
60
60
  `tools get <actionId> --json`, `apps list`, `connections list`,
61
+ `ai-connections list --json`,
61
62
  `agents|workflows|entity-types|tables list`, `tables get <slugOrId>`,
62
63
  `features`.
63
64
  SDK equivalents: `workflowApps.list()`, `agents.list`, `workflows.list`,
64
- `entityTypes.list`, `tables.list`, `discovery.enabledFeatures()`.
65
- Do not invent catalogue action ids.
65
+ `entityTypes.list`, `tables.list`, `aiConnections.list()`,
66
+ `discovery.enabledFeatures()`.
67
+ Do not invent catalogue action ids or model ids. `connections list` is
68
+ app connections (Gmail, HTTP). `ai-connections list` is the model
69
+ provider connection and the `models[].id` values `defineAgent` accepts.
66
70
  4. **Run vs deploy** — Ad-hoc: `actions.run` / `runs.start` /
67
71
  `workflows.execute`. Durable shared automation: CLI
68
72
  `npx @lunnoa/client workflows|agents deploy`. Upsert is by slug
@@ -364,7 +368,8 @@ export const ping = defineWorkflow({
364
368
 
365
369
  export const triage = defineAgent({
366
370
  slug: 'support-triage',
367
- model: 'gpt-4o',
371
+ // models[].id from `npx @lunnoa/client ai-connections list --json`
372
+ model: 'deepseek-ai/DeepSeek-V4-Pro',
368
373
  instructions: 'Triage mail. Be concise.',
369
374
  tools: [defineAction({ id: 'http_action_send-request' })],
370
375
  });
@@ -384,11 +389,20 @@ npx @lunnoa/client tools list --json --for-agent
384
389
  npx @lunnoa/client tools search email --json --for-agent
385
390
  npx @lunnoa/client tools get http_action_send-request --json
386
391
  npx @lunnoa/client connections list --app gmail --json
392
+ npx @lunnoa/client ai-connections list --json
387
393
  ```
388
394
 
389
395
  `tools get` returns `inputConfig` / `inputFields` and a `defineAction` sketch.
390
396
  `tools list` is compact; use `get` for the schema. `--json` is for coding agents.
391
397
 
398
+ `ai-connections list` returns the AI connections this key can assign to an
399
+ agent. Set `defineAgent({ model })` to a `models[].id` from that JSON
400
+ (on Lunnoa LLMs that is a catalogue id such as
401
+ `deepseek-ai/DeepSeek-V4-Pro`). Omit `aiConnection` to
402
+ use the connection with `isDefault: true`. Pass
403
+ `defineAiConnection({ id })` only for a different connection. SDK:
404
+ `lunnoa.aiConnections.list()`.
405
+
392
406
  Deploy to Automate UI (upsert by slug inside the workspace on the API key; prefer CLI):
393
407
 
394
408
  ```bash
@@ -442,6 +456,8 @@ for await (const chunk of stream) {
442
456
  }
443
457
  ```
444
458
 
459
+ A turn from an app runs in **preview**: 10 model rounds, so the agent can call tools a few times and still send a final reply. The SDK sends `chatMode: 'preview'` for you. Do not pass `chatMode: 'builder'` from an app. That is the agent-editor interview: 4 rounds, and it stops a tool-using agent halfway. The workflow then fails with "Agent did not generate a response" even when a tool already saved the data. A workflow Message Agent step uses the same preview budget. For a job that chains many tool calls (read every record, then write a result), turn on **Long-horizon mode** on that agent in Lunnoa. That raises the budget to 50 rounds. `defineAgent` cannot set the switch, and a later deploy leaves it as you set it.
460
+
445
461
  - **React apps:** prefer `useAgentChat` from `@lunnoa/client/react`, which wraps AI SDK `useChat` + `DefaultChatTransport`
446
462
  pointed at
447
463
  `${baseUrl}/api/agents/${agentId}/tasks/${taskId}/stream-message` with an
@@ -538,7 +554,7 @@ with emails (capped; not Azure object IDs).
538
554
  3. Call `discovery.enabledFeatures()` and hide unsupported areas.
539
555
  4. Build forms/tables from `attributeSchema` / `customInputConfig` (or the generated types).
540
556
  5. Render workflow progress from `executionPath`; handle `NEEDS_INPUT` with `submitInput`.
541
- 6. For single-action calls, use `actions.run`; for linear multi-step, use `runs.start` / `defineWorkflow`. Deploy with `npx @lunnoa/client workflows|agents deploy`. Discover catalogue via `npx @lunnoa/client tools list|get|search` (or `workflowApps.list()`).
557
+ 6. For single-action calls, use `actions.run`; for linear multi-step, use `runs.start` / `defineWorkflow`. Deploy with `npx @lunnoa/client workflows|agents deploy`. Discover catalogue via `npx @lunnoa/client tools list|get|search` (or `workflowApps.list()`). Discover agent models via `npx @lunnoa/client ai-connections list --json` (or `aiConnections.list()`).
542
558
  7. For Request Approval nodes, use `approvals.inbox` / `approvals.decide` (or `executions.submitApproval`).
543
559
  8. Chat: stream via SSE, handle resume (reconnects) and stop, load history from the task.
544
560
  9. Handle `LunnoaApiError`: 401 → re-auth; 403 → hide the capability; 429 → back off.
@@ -106,18 +106,28 @@ interrogation.
106
106
  1. **Agents have no schedules or event triggers.** If something must run on a
107
107
  cron or webhook, use a **Workflow** that messages the agent (or runs
108
108
  actions). Do not invent an agent trigger.
109
- 2. **Connections stay on Lunnoa.** Definitions only reference connection ids
109
+ 2. **A tool-using agent gets 10 model rounds per turn** from an app or a
110
+ Message Agent step. That covers a handful of tool calls plus a final reply.
111
+ If the job chains many calls (read every record, then write), the brief must
112
+ say to turn on **Long-horizon mode** for that agent in Lunnoa (50 rounds).
113
+ Do not plan around `chatMode: 'builder'`; that is the editor interview and
114
+ stops after 4 rounds.
115
+ 3. **Connections stay on Lunnoa.** Definitions only reference connection ids
110
116
  (or omit for sole/default resolution). Never ask the partner to put OAuth
111
117
  secrets in their app.
112
- 3. **Do not invent catalogue actions.** Discover with
118
+ 4. **Do not invent catalogue actions or model ids.** Discover actions with
113
119
  `npx @lunnoa/client tools list|get|search --json` (or `workflowApps.list()`
114
- / codegen). Client `defineAction` binds existing catalogue actions; toolkit
115
- `createAction` is a different product (in-platform apps).
116
- 4. **Durable vs ephemeral:** experiments → `runs.start`; shared production
120
+ / codegen). Discover models with
121
+ `npx @lunnoa/client ai-connections list --json` and use a returned
122
+ `models[].id` (Lunnoa LLMs uses catalogue ids such as
123
+ `deepseek-ai/DeepSeek-V4-Pro`). Client `defineAction` binds existing
124
+ catalogue actions; toolkit `createAction` is a different product
125
+ (in-platform apps).
126
+ 5. **Durable vs ephemeral:** experiments → `runs.start`; shared production
117
127
  automation → CLI `workflows deploy` / `agents deploy` by slug.
118
- 5. **UI is headless.** `@lunnoa/client` has no design system. Optional React
128
+ 6. **UI is headless.** `@lunnoa/client` has no design system. Optional React
119
129
  hooks in `@lunnoa/client/react`. Partners bring their own UI.
120
- 6. **Reuse before create.** Before proposing any new entity type, table,
130
+ 7. **Reuse before create.** Before proposing any new entity type, table,
121
131
  workflow, or agent, run `npx @lunnoa/client entity-types list --json`,
122
132
  `tables list --json`, `workflows list --json`, and `agents list --json`.
123
133
  The build brief must state explicitly what is **reused** vs **created**.
@@ -125,11 +135,13 @@ interrogation.
125
135
  ### Common anti-patterns to reject
126
136
 
127
137
  - Putting an agent on a schedule without a workflow wrapper
138
+ - Expecting an agent to loop tools indefinitely, or sending `chatMode: 'builder'` from an app (4 rounds, editor only)
128
139
  - Building a fake multi-step “batch” as many unrelated `actions.run` calls
129
140
  when the user wanted one Execution (use `runs.start` / workflow)
130
141
  - Shipping `lna_` to the browser “just for the demo”
131
142
  - Using `@lunnoa/toolkit` to build a customer portal
132
143
  - Designing a local LangChain loop instead of Lunnoa-hosted agents
144
+ - Hardcoding `model: 'gpt-4o'` without reading `ai-connections list`
133
145
 
134
146
  ---
135
147
 
@@ -150,6 +162,7 @@ can execute. Use this shape:
150
162
 
151
163
  ### Discovery (run first)
152
164
  - [ ] `npx @lunnoa/client tools list --json --for-agent` then `tools get <id>`
165
+ - [ ] `npx @lunnoa/client ai-connections list --json` before choosing an agent model
153
166
  - [ ] agents / workflows / entity-types / tables list — reuse before create
154
167
  - [ ] codegen — if building typed entity/workflow accessors
155
168