@lunnoa/client 1.4.0 → 2.0.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": "1.4.0",
3
+ "version": "2.0.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",
@@ -39,22 +39,18 @@
39
39
  "release": "semantic-release"
40
40
  },
41
41
  "dependencies": {
42
+ "@ai-sdk/react": "^3.0.230",
42
43
  "ai": "^6.0.199"
43
44
  },
44
45
  "peerDependencies": {
45
- "@ai-sdk/react": "^3.0.0 || ^4.0.0",
46
46
  "react": "^18.0.0 || ^19.0.0"
47
47
  },
48
48
  "peerDependenciesMeta": {
49
49
  "react": {
50
50
  "optional": true
51
- },
52
- "@ai-sdk/react": {
53
- "optional": true
54
51
  }
55
52
  },
56
53
  "devDependencies": {
57
- "@ai-sdk/react": "^3.0.230",
58
54
  "@semantic-release/changelog": "^6.0.3",
59
55
  "@semantic-release/git": "^10.0.1",
60
56
  "@semantic-release/github": "^12.0.0",
@@ -57,13 +57,15 @@ Run these before inventing resources or shipping UI code:
57
57
  3. **Discover before inventing** — prefer the CLI (JSON for agents), then
58
58
  the SDK: `npx @lunnoa/client tools list --json --for-agent`,
59
59
  `tools get <actionId> --json`, `apps list`, `connections list`,
60
- `agents|workflows|entity-types|projects list`, `features`.
60
+ `agents|workflows|entity-types|tables list`, `tables get <slugOrId>`,
61
+ `features`.
61
62
  SDK equivalents: `workflowApps.list()`, `agents.list`, `workflows.list`,
62
- `entityTypes.list`, `discovery.enabledFeatures()`.
63
+ `entityTypes.list`, `tables.list`, `discovery.enabledFeatures()`.
63
64
  Do not invent catalogue action ids.
64
65
  4. **Run vs deploy** — Ad-hoc: `actions.run` / `runs.start` /
65
66
  `workflows.execute`. Durable shared automation: CLI
66
- `npx @lunnoa/client workflows|agents deploy` (upsert by slug).
67
+ `npx @lunnoa/client workflows|agents deploy`. Upsert is by slug
68
+ inside the workspace on the API key. URL and API key are enough.
67
69
  5. **Toolkit boundary** — Client `defineAction` ≠ toolkit `createAction`.
68
70
 
69
71
  ---
@@ -141,12 +143,12 @@ const { user, status, login, logout, verify2faLogin } = useLunnoaAuth();
141
143
  const lunnoa = useLunnoaClient(); // same client for entities / actions / chat
142
144
  const { progress } = useExecutionProgress(executionId);
143
145
  const { waiting, pendingInput, submitInput } = useNeedsInput(progress);
144
- const { messages, send, stop, taskId } = useAgentChat(agentId); // peer: @ai-sdk/react
146
+ const { messages, send, stop, taskId } = useAgentChat(agentId);
145
147
  const { items, decide } = useApprovalsInbox({ pollIntervalMs: 15_000 });
146
148
  const { data, setPage } = useEntityList({ objectTypeSlug: 'invoice' });
147
149
  ```
148
150
 
149
- Peers: `react` ≥ 18 for `/react`; `@ai-sdk/react` only for `useAgentChat`.
151
+ Peer: `react` ≥ 18 for `/react`. `@ai-sdk/react` ships with the SDK (no extra install).
150
152
  Errors are `LunnoaApiError` with `.status`, `.body`, `.isUnauthorized`,
151
153
  `.isForbidden`, `.isRateLimited`. A 403 means the key's role or the
152
154
  deployment's licence edition does not cover the endpoint.
@@ -193,8 +195,20 @@ const workflows = await lunnoa.workflows.list({ expansion: ['description', 'isAc
193
195
  const entityTypes = await lunnoa.entityTypes.list({
194
196
  expansion: ['attributeSchema', 'stateSchema'],
195
197
  });
198
+
199
+ // Tables: small reference / lookup data (list omits rows; get includes them)
200
+ const tables = await lunnoa.tables.list();
201
+ const costCentres = await lunnoa.tables.getBySlug('cost_centres'); // or tables.get(id)
202
+ await lunnoa.tables.upsertBySlug({
203
+ slug: 'cost_centres',
204
+ columns: [{ key: 'code' }, { key: 'owner' }],
205
+ rows: [{ code: 'CC-100', owner: 'Finance' }],
206
+ }); // managedByCode defaults to true; omitted columns/rows are kept
196
207
  ```
197
208
 
209
+ - Use a **Table** for slowly changing reference data under ~10k rows; anything
210
+ that grows per transaction (invoice, ticket, case) is an **entity**.
211
+
198
212
  - `attributeSchema.sections[].fields[]` defines each entity field: `id`
199
213
  (attribute key), `label`, `type` (`text`, `number`, `currency`, `date`,
200
214
  `dropdown` with `config.options`, `boolean`, ...), `required`. Build forms
@@ -306,7 +320,6 @@ const result = await lunnoa.actions.run({
306
320
  appId: 'http',
307
321
  actionId: 'http_action_send-request',
308
322
  // connectionId: '<Connection.id UUID>', // required if needsConnection + multiple
309
- // projectId: '<project UUID>', // required if multiple projects
310
323
  input: { method: 'GET', url: 'https://example.com' },
311
324
  name: 'Ping example',
312
325
  });
@@ -377,11 +390,11 @@ npx @lunnoa/client connections list --app gmail --json
377
390
  `tools get` returns `inputConfig` / `inputFields` and a `defineAction` sketch.
378
391
  `tools list` is compact; use `get` for the schema. `--json` is for coding agents.
379
392
 
380
- Deploy to Automate UI (upsert by slug; prefer CLI):
393
+ Deploy to Automate UI (upsert by slug inside the workspace on the API key; prefer CLI):
381
394
 
382
395
  ```bash
383
- npx @lunnoa/client workflows deploy ./ping.ts --url … --api-key … --project-id …
384
- npx @lunnoa/client agents deploy ./triage.ts --url … --api-key … --project-id …
396
+ npx @lunnoa/client workflows deploy ./ping.ts --url … --api-key …
397
+ npx @lunnoa/client agents deploy ./triage.ts --url … --api-key …
385
398
  ```
386
399
 
387
400
  `defineAction` binds catalogue actions only. Toolkit `createAction` is a
@@ -430,8 +443,7 @@ for await (const chunk of stream) {
430
443
  }
431
444
  ```
432
445
 
433
- - **React apps:** prefer `useAgentChat` from `@lunnoa/client/react` (optional
434
- peer `@ai-sdk/react`), which wraps AI SDK `useChat` + `DefaultChatTransport`
446
+ - **React apps:** prefer `useAgentChat` from `@lunnoa/client/react`, which wraps AI SDK `useChat` + `DefaultChatTransport`
435
447
  pointed at
436
448
  `${baseUrl}/api/agents/${agentId}/tasks/${taskId}/stream-message` with an
437
449
  `Authorization` header. You can also wire `useChat` yourself. Use
@@ -4,7 +4,7 @@ description: >-
4
4
  Acts as a Lunnoa business analyst / solution designer for vibecoders and
5
5
  partners. Interviews the human about triggers, actors, data, HITL, and
6
6
  integrations; maps intent to Lunnoa primitives (actions, workflows, agents,
7
- entities, approvals, queues); produces a short build brief; then hands off
7
+ entities, tables, approvals, queues); produces a short build brief; then hands off
8
8
  to the lunnoa-client skill for implementation. Use when requirements are
9
9
  unclear, the user asks what to build on Lunnoa, how to design a workflow or
10
10
  agent, whether to use an agent vs workflow, or before writing @lunnoa/client
@@ -50,6 +50,7 @@ interrogation.
50
50
  ### Data and knowledge
51
51
 
52
52
  - Structured business records (invoice, order, ticket) → **Entities**
53
+ - Small reference / lookup data (cost centres, price list) → **Tables**
53
54
  - Free-form conversation / reasoning → **Agent** chat
54
55
  - Documents / notebooks the model should search → **Knowledge**
55
56
  - Transient run output only → Executions / Tasks
@@ -86,9 +87,19 @@ interrogation.
86
87
  | Reusable automation + triggers | Saved **Workflow** (UI or CLI deploy) | Schedules/webhooks live on workflows |
87
88
  | Reasoning + tools + conversation | **Agent** | Tools = workflows, actions, knowledge |
88
89
  | Structured CRUD / portals | **Entities** + schemas | Codegen for typed accessors |
90
+ | Reference / lookup data | **Tables** | `tables.upsertBySlug`; workflows use the Tables Lookup action |
89
91
  | Human review inbox | **Approvals** | |
90
92
  | Assigned human work items | **Queues** | |
91
93
 
94
+ ### Objects (entities) vs Tables
95
+
96
+ - **Object (entity)** = a business record with identity and lifecycle
97
+ (invoice, ticket, case): states and state history, linked to
98
+ executions / agents / queues, has a business key, grows with transactions.
99
+ - **Table** = small, slowly changing reference data (cost-centre mapping,
100
+ price list, country codes), under ~10k rows (rows live in one JSON blob).
101
+ - Anything that grows per transaction is an **Object**, never a Table.
102
+
92
103
  ### Hard product rules (enforce these)
93
104
 
94
105
  1. **Agents have no schedules or event triggers.** If something must run on a
@@ -105,6 +116,10 @@ interrogation.
105
116
  automation → CLI `workflows deploy` / `agents deploy` by slug.
106
117
  5. **UI is headless.** `@lunnoa/client` has no design system. Optional React
107
118
  hooks in `@lunnoa/client/react`. Partners bring their own UI.
119
+ 6. **Reuse before create.** Before proposing any new entity type, table,
120
+ workflow, or agent, run `npx @lunnoa/client entity-types list --json`,
121
+ `tables list --json`, `workflows list --json`, and `agents list --json`.
122
+ The build brief must state explicitly what is **reused** vs **created**.
108
123
 
109
124
  ### Common anti-patterns to reject
110
125
 
@@ -130,19 +145,20 @@ can execute. Use this shape:
130
145
 
131
146
  ### Auth
132
147
  - Pattern: A (server API key) | B (browser JWT)
133
- - Notes: <CORS, BFF, project id, env vars>
148
+ - Notes: <CORS, BFF, env vars LUNNOA_URL and LUNNOA_API_KEY>
134
149
 
135
150
  ### Discovery (run first)
136
151
  - [ ] `npx @lunnoa/client tools list --json --for-agent` then `tools get <id>`
137
- - [ ] agents / workflows / entity-types / projects list — reuse before create
152
+ - [ ] agents / workflows / entity-types / tables list — reuse before create
138
153
  - [ ] codegen — if building typed entity/workflow accessors
139
154
 
140
- ### Resources
141
- | Kind | Slug / id | Create or reuse | Notes |
155
+ ### Resources (every row says REUSED or CREATED)
156
+ | Kind | Slug / id | Reused / created | Notes |
142
157
  |---|---|---|---|
143
158
  | Workflow | … | … | steps / trigger |
144
159
  | Agent | … | … | model, tools |
145
160
  | Entity type | … | … | if portal CRUD |
161
+ | Table | … | … | reference / lookup data |
146
162
  | Knowledge | … | … | if RAG |
147
163
 
148
164
  ### Runtime paths