@lunnoa/client 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -40
- package/dist/cli.js +6 -6
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -31
- package/dist/index.d.ts +22 -31
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/react.cjs +3 -3
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +15 -22
- package/dist/react.d.ts +15 -22
- package/dist/react.js +3 -3
- package/dist/react.js.map +1 -1
- package/package.json +1 -1
- package/skills/lunnoa-client/SKILL.md +32 -32
- package/skills/lunnoa-solution-design/SKILL.md +9 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lunnoa/client",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.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",
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
name: lunnoa-client
|
|
3
3
|
description: >-
|
|
4
4
|
Builds custom frontends and backends on top of a Lunnoa Automate deployment
|
|
5
|
-
using the @lunnoa/client TypeScript SDK.
|
|
6
|
-
(
|
|
7
|
-
|
|
8
|
-
browser
|
|
5
|
+
using the @lunnoa/client TypeScript SDK. App login is always a Lunnoa user
|
|
6
|
+
(createBrowserClient + lunnoa.auth.login / refresh / SSO). lna_ API keys are
|
|
7
|
+
for the CLI only (discovery, codegen, deploy), never for the app session and
|
|
8
|
+
never in a browser. Covers discovery of the deployment's agents, workflows, and entity
|
|
9
9
|
types, running the deployment codegen first for typed accessors, querying
|
|
10
10
|
and creating entities, triggering workflows and polling executions,
|
|
11
11
|
resuming NEEDS_INPUT executions from custom forms, streaming agent chat
|
|
@@ -49,9 +49,10 @@ Human docs (detail): Lunnoa Docs → Develop → TypeScript client SDK.
|
|
|
49
49
|
|
|
50
50
|
Run these before inventing resources or shipping UI code:
|
|
51
51
|
|
|
52
|
-
1. **Auth** —
|
|
53
|
-
|
|
54
|
-
browser (SDK throws when `window` exists).
|
|
52
|
+
1. **Auth** — Lunnoa user JWT via `createBrowserClient` + `lunnoa.auth.login`
|
|
53
|
+
(or SSO). **Never** call Lunnoa as the app's users with an `lna_` key, and
|
|
54
|
+
**never** put `lna_` in the browser (SDK throws when `window` exists).
|
|
55
|
+
`lna_` keys are for CLI discovery, codegen, and deploy only.
|
|
55
56
|
2. **Codegen** — When building typed UIs, run
|
|
56
57
|
`npx @lunnoa/client codegen` against the deployment first.
|
|
57
58
|
3. **Discover before inventing** — prefer the CLI (JSON for agents), then
|
|
@@ -70,36 +71,33 @@ Run these before inventing resources or shipping UI code:
|
|
|
70
71
|
|
|
71
72
|
---
|
|
72
73
|
|
|
73
|
-
## 1. Auth:
|
|
74
|
+
## 1. Auth: Lunnoa users only
|
|
74
75
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
76
|
+
Every person who uses the app is a Lunnoa user. If they are not in the
|
|
77
|
+
workspace yet, they are provisioned there first (invite, SSO, or SCIM). The
|
|
78
|
+
app does not keep its own user directory and does not call Lunnoa with an
|
|
79
|
+
`lna_` key on their behalf.
|
|
80
|
+
|
|
81
|
+
| Caller | Credential |
|
|
82
|
+
|---|---|
|
|
83
|
+
| **Person using the app** | `createBrowserClient({ baseUrl })` + `lunnoa.auth.login` (password, 2FA, or SSO). Permissions, agent shares, and task history are that user's. |
|
|
84
|
+
| **CLI (codegen, discovery, deploy)** | `lna_` API key in `.env` / `--api-key`. Not the app session. |
|
|
79
85
|
|
|
80
86
|
Hard rules:
|
|
81
87
|
|
|
82
88
|
- **NEVER put an `lna_` key in browser code, env vars bundled into the client,
|
|
83
89
|
or anything shipped to the browser.** The SDK throws if an `lna_` key is
|
|
84
90
|
used while `window` exists. A leaked key exposes the whole workspace.
|
|
85
|
-
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
-
|
|
89
|
-
|
|
90
|
-
- Keys are minted by a SuperAdmin in **Adminspace → API keys** (workspace +
|
|
91
|
+
- **NEVER build a backend-for-frontend that holds an `lna_` key so the app
|
|
92
|
+
can have its own users.** Next.js route handlers and server actions count
|
|
93
|
+
as the app: they must forward the signed-in user's JWT, not a service key.
|
|
94
|
+
- The deployment must allow the app's origin via `CORS_ALLOWED_ORIGINS`.
|
|
95
|
+
- CLI keys are minted by a SuperAdmin in **Adminspace → API keys** (workspace +
|
|
91
96
|
RBAC role + optional expiry; secret shown once). Recommend a minimal custom
|
|
92
97
|
role (e.g. `entities:read`, `entities:create`, `agents:use`), not Admin.
|
|
93
98
|
|
|
94
99
|
```typescript
|
|
95
|
-
//
|
|
96
|
-
import { createServerClient } from '@lunnoa/client';
|
|
97
|
-
const lunnoa = createServerClient({
|
|
98
|
-
baseUrl: process.env.LUNNOA_URL!,
|
|
99
|
-
apiKey: process.env.LUNNOA_API_KEY!,
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
// Pattern B (browser) — login + localStorage token store + auto-refresh on 401
|
|
100
|
+
// App session — login + localStorage token store + auto-refresh on 401
|
|
103
101
|
import { createBrowserClient, isLoginRequires2FA } from '@lunnoa/client';
|
|
104
102
|
const lunnoa = createBrowserClient({ baseUrl });
|
|
105
103
|
const result = await lunnoa.auth.login({ email, password });
|
|
@@ -150,7 +148,7 @@ const { data, setPage } = useEntityList({ objectTypeSlug: 'invoice' });
|
|
|
150
148
|
|
|
151
149
|
Peer: `react` ≥ 18 for `/react`. `@ai-sdk/react` ships with the SDK (no extra install).
|
|
152
150
|
Errors are `LunnoaApiError` with `.status`, `.body`, `.isUnauthorized`,
|
|
153
|
-
`.isForbidden`, `.isRateLimited`. A 403 means the
|
|
151
|
+
`.isForbidden`, `.isRateLimited`. A 403 means the user's role or the
|
|
154
152
|
deployment's licence edition does not cover the endpoint.
|
|
155
153
|
|
|
156
154
|
---
|
|
@@ -169,8 +167,9 @@ npx @lunnoa/client codegen --url <deployment-url> --api-key <lna_key> --out ./sr
|
|
|
169
167
|
This emits `src/lunnoa/lunnoa.generated.ts` with `createDeploymentClient`:
|
|
170
168
|
|
|
171
169
|
```typescript
|
|
170
|
+
import { createBrowserClient } from '@lunnoa/client';
|
|
172
171
|
import { createDeploymentClient } from './lunnoa/lunnoa.generated';
|
|
173
|
-
const lunnoa = createDeploymentClient(
|
|
172
|
+
const lunnoa = createDeploymentClient(createBrowserClient({ baseUrl }));
|
|
174
173
|
|
|
175
174
|
await lunnoa.entities.invoice.list({ state: 'pending' }); // typed attributes + states
|
|
176
175
|
await lunnoa.workflows.processInvoice.execute({ invoiceId }); // typed trigger inputs
|
|
@@ -500,7 +499,7 @@ const { items: work } = await lunnoa.queueItems.listByObject(ticket.id);
|
|
|
500
499
|
`lunnoa.approvals` mirrors Automate **Approvals** (`/approvals`). It uses the
|
|
501
500
|
workspace API (`/api/approvals/...`), not Public API v1. The inbox is filtered
|
|
502
501
|
to requests where the **current user** is eligible and has not decided yet.
|
|
503
|
-
|
|
502
|
+
The caller is the signed-in Lunnoa user. Role needs `approvals:read` / `approvals:decide`.
|
|
504
503
|
|
|
505
504
|
```typescript
|
|
506
505
|
const { items } = await lunnoa.approvals.inbox(); // pending + partially_approved
|
|
@@ -531,9 +530,10 @@ with emails (capped; not Azure object IDs).
|
|
|
531
530
|
|
|
532
531
|
## 10. Ship checklist (after the mandatory checklist)
|
|
533
532
|
|
|
534
|
-
1. Confirm base URL
|
|
535
|
-
|
|
536
|
-
|
|
533
|
+
1. Confirm the base URL. Sign people in with `createBrowserClient` and
|
|
534
|
+
`lunnoa.auth.login` (not an `lna_` key, and not raw localStorage getters
|
|
535
|
+
unless you already hold that user's JWT). Allow the origin in
|
|
536
|
+
`CORS_ALLOWED_ORIGINS`.
|
|
537
537
|
2. Run `npx @lunnoa/client codegen` against the deployment; commit the output.
|
|
538
538
|
3. Call `discovery.enabledFeatures()` and hide unsupported areas.
|
|
539
539
|
4. Build forms/tables from `attributeSchema` / `customInputConfig` (or the generated types).
|
|
@@ -42,10 +42,11 @@ interrogation.
|
|
|
42
42
|
|
|
43
43
|
### Actors
|
|
44
44
|
|
|
45
|
-
- Who uses the custom UI
|
|
46
|
-
|
|
47
|
-
-
|
|
48
|
-
|
|
45
|
+
- Who uses the custom UI? They sign in as Lunnoa users. If they are not in
|
|
46
|
+
the workspace yet, they are provisioned there first (invite, SSO, or SCIM).
|
|
47
|
+
- The app does not keep its own login and does not call Lunnoa with an `lna_`
|
|
48
|
+
key on their behalf. `lna_` keys are for the CLI only. Never put one in a
|
|
49
|
+
browser.
|
|
49
50
|
|
|
50
51
|
### Data and knowledge
|
|
51
52
|
|
|
@@ -70,10 +71,10 @@ interrogation.
|
|
|
70
71
|
|
|
71
72
|
### Auth for any custom UI
|
|
72
73
|
|
|
73
|
-
| End users |
|
|
74
|
+
| End users | Auth |
|
|
74
75
|
|---|---|
|
|
75
|
-
|
|
|
76
|
-
|
|
|
76
|
+
| People using the app | Lunnoa user JWT: `createBrowserClient` + `lunnoa.auth.login` (or SSO). Provision missing people with invite, SSO, or SCIM first. |
|
|
77
|
+
| Coding agent / CLI | `LUNNOA_API_KEY` for discovery, codegen, and deploy. Not the app session. |
|
|
77
78
|
| Anonymous embed chat (no full login) | Out of scope for v1 client path; scoped embed tokens are a later platform bet |
|
|
78
79
|
|
|
79
80
|
---
|
|
@@ -192,7 +193,7 @@ continue in a coding turn with that skill loaded.
|
|
|
192
193
|
**You ask:** Who chats (customers or staff)? Data source (entities vs ERP
|
|
193
194
|
action)? Need approvals? Existing HTTP/CRM connections?
|
|
194
195
|
|
|
195
|
-
**You conclude (example):**
|
|
196
|
+
**You conclude (example):** Customers are Lunnoa users (SCIM or invite) and sign in with a browser JWT; Agent `order-status` with tools
|
|
196
197
|
`defineAction` for ERP lookup (after `tools list` / `tools get`) + optional
|
|
197
198
|
workflow for staff notifications; UI = chat only; no agent schedule.
|
|
198
199
|
|