lemma-sdk 0.2.0 → 0.2.1
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 +108 -36
- package/dist/browser/lemma-client.js +244 -518
- package/dist/client.d.ts +2 -0
- package/dist/client.js +6 -3
- package/dist/http.d.ts +18 -5
- package/dist/http.js +77 -22
- package/dist/index.d.ts +4 -1
- package/dist/index.js +1 -0
- package/dist/namespaces/assistants.d.ts +55 -15
- package/dist/namespaces/assistants.js +108 -19
- package/dist/namespaces/resources.d.ts +16 -0
- package/dist/namespaces/resources.js +32 -0
- package/dist/namespaces/tasks.d.ts +15 -9
- package/dist/namespaces/tasks.js +43 -11
- package/dist/react/index.d.ts +4 -0
- package/dist/react/index.js +2 -0
- package/dist/react/useAgentRun.d.ts +17 -0
- package/dist/react/useAgentRun.js +66 -0
- package/dist/react/useAssistantRun.d.ts +18 -0
- package/dist/react/useAssistantRun.js +82 -0
- package/dist/streams.d.ts +10 -0
- package/dist/streams.js +68 -0
- package/dist/types.d.ts +27 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
|
-
# Lemma TypeScript SDK
|
|
1
|
+
# Lemma TypeScript SDK (`lemma-sdk`)
|
|
2
2
|
|
|
3
|
-
Official TypeScript SDK for Lemma pod-scoped
|
|
4
|
-
|
|
5
|
-
- High-level `LemmaClient` namespaces for common workflows
|
|
6
|
-
- React helpers (`lemma-sdk/react`) for auth-gated apps
|
|
7
|
-
- Re-exported generated OpenAPI services and model types
|
|
8
|
-
- Browser standalone bundle (`dist/browser/lemma-client.js`)
|
|
3
|
+
Official TypeScript SDK for Lemma APIs with pod-scoped namespaces, auth helpers, streaming support, and reusable React hooks.
|
|
9
4
|
|
|
10
5
|
## Install
|
|
11
6
|
|
|
@@ -19,48 +14,129 @@ If you want to import as `lemma`, use npm aliasing:
|
|
|
19
14
|
npm i lemma@npm:lemma-sdk
|
|
20
15
|
```
|
|
21
16
|
|
|
22
|
-
## Quick
|
|
17
|
+
## Quick Start
|
|
23
18
|
|
|
24
19
|
```ts
|
|
25
20
|
import { LemmaClient } from "lemma-sdk";
|
|
26
21
|
|
|
27
22
|
const client = new LemmaClient({
|
|
28
|
-
apiUrl: "
|
|
29
|
-
authUrl: "
|
|
23
|
+
apiUrl: "https://api-next.asur.work",
|
|
24
|
+
authUrl: "https://auth.asur.work/auth",
|
|
30
25
|
podId: "<pod-id>",
|
|
31
26
|
});
|
|
32
27
|
|
|
33
28
|
await client.initialize();
|
|
34
|
-
|
|
29
|
+
|
|
30
|
+
const datastores = await client.datastores.list();
|
|
31
|
+
const assistants = await client.assistants.list({ limit: 20 });
|
|
32
|
+
const supportAssistant = await client.assistants.get("support_assistant");
|
|
35
33
|
```
|
|
36
34
|
|
|
37
|
-
##
|
|
35
|
+
## Core Concepts
|
|
38
36
|
|
|
39
|
-
|
|
37
|
+
- `LemmaClient`: entrypoint with auth + API transport.
|
|
38
|
+
- Namespace APIs (`client.agents`, `client.tasks`, `client.conversations`, etc.) for typed operations.
|
|
39
|
+
- `client.request(method, path, options)` escape hatch for endpoints not yet modeled.
|
|
40
|
+
- `client.resources` for generic file resource APIs (`conversation`, `assistant`, `task`, etc.).
|
|
41
|
+
- Ergonomic type aliases exported at top level: `Agent`, `Assistant`, `Conversation`, `Task`, `TaskMessage`, `CreateAgentInput`, `CreateAssistantInput`, etc.
|
|
40
42
|
|
|
41
|
-
|
|
42
|
-
- `docs/index.mdx`
|
|
43
|
-
- `docs/quickstart.mdx`
|
|
44
|
-
- `docs/configuration.mdx`
|
|
45
|
-
- `docs/authentication.mdx`
|
|
46
|
-
- `docs/namespaces.mdx`
|
|
47
|
-
- `docs/react.mdx`
|
|
48
|
-
- `docs/browser-bundle.mdx`
|
|
49
|
-
- `docs/generated-api.mdx`
|
|
50
|
-
- `docs/publishing.mdx`
|
|
43
|
+
## Assistants + Agent Runs
|
|
51
44
|
|
|
52
|
-
|
|
45
|
+
### Assistant names (resource key)
|
|
53
46
|
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
Assistant CRUD is name-based:
|
|
48
|
+
|
|
49
|
+
```ts
|
|
50
|
+
await client.assistants.get("support_assistant");
|
|
51
|
+
await client.assistants.update("support_assistant", { description: "Handles support triage" });
|
|
52
|
+
await client.assistants.delete("old_assistant");
|
|
56
53
|
```
|
|
57
54
|
|
|
58
|
-
|
|
55
|
+
### Conversation scoping by assistant name
|
|
59
56
|
|
|
60
|
-
```
|
|
61
|
-
|
|
57
|
+
```ts
|
|
58
|
+
const conversations = await client.conversations.list({
|
|
59
|
+
assistantName: "support_assistant",
|
|
60
|
+
limit: 20,
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
const conversation = await client.conversations.createForAssistant("support_assistant", {
|
|
64
|
+
title: "Ticket triage",
|
|
65
|
+
});
|
|
62
66
|
```
|
|
63
67
|
|
|
68
|
+
### Conversations with SSE streaming
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
const stream = await client.conversations.sendMessageStream(conversationId, {
|
|
72
|
+
content: "Find open support tickets from yesterday",
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
for await (const event of readSSE(stream)) {
|
|
76
|
+
const payload = parseSSEJson(event);
|
|
77
|
+
if (!payload) continue;
|
|
78
|
+
console.log(payload);
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### Task runs with SSE streaming
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
const task = await client.tasks.create({
|
|
86
|
+
agentId: "triage-agent",
|
|
87
|
+
input: { ticketId: "TCK-1042" },
|
|
88
|
+
runtimeAccountIds: ["acc_123"],
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const stream = await client.tasks.stream(task.id);
|
|
92
|
+
for await (const event of readSSE(stream)) {
|
|
93
|
+
const payload = parseSSEJson(event);
|
|
94
|
+
if (!payload) continue;
|
|
95
|
+
console.log(payload);
|
|
96
|
+
}
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## React Helpers
|
|
100
|
+
|
|
101
|
+
Import from `lemma-sdk/react`:
|
|
102
|
+
|
|
103
|
+
- `useAuth(client)`
|
|
104
|
+
- `AuthGuard`
|
|
105
|
+
- `useAgentRunStream(...)`
|
|
106
|
+
- `useAssistantRun(...)`
|
|
107
|
+
|
|
108
|
+
Example:
|
|
109
|
+
|
|
110
|
+
```tsx
|
|
111
|
+
import { useAssistantRun } from "lemma-sdk/react";
|
|
112
|
+
|
|
113
|
+
const { sendMessage, stop, isStreaming } = useAssistantRun({
|
|
114
|
+
client,
|
|
115
|
+
podId,
|
|
116
|
+
conversationId,
|
|
117
|
+
onEvent: (event, payload) => {
|
|
118
|
+
console.log(event.event, payload);
|
|
119
|
+
},
|
|
120
|
+
});
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## File Resources
|
|
124
|
+
|
|
125
|
+
```ts
|
|
126
|
+
await client.resources.upload("conversation", conversationId, file);
|
|
127
|
+
const files = await client.resources.list("conversation", conversationId);
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
## Migration Tips
|
|
131
|
+
|
|
132
|
+
When migrating from direct `fetch`/custom API clients:
|
|
133
|
+
|
|
134
|
+
1. Replace auth/session bootstrapping with `LemmaClient`.
|
|
135
|
+
2. Move pod-scoped calls into namespaces (`tasks`, `assistants`, `conversations`, etc.).
|
|
136
|
+
3. Keep rare/unmodeled endpoints on `client.request(...)` temporarily.
|
|
137
|
+
4. Replace SSE parsing code with `readSSE` + `parseSSEJson`.
|
|
138
|
+
5. Gradually lift app-specific run/chat logic into reusable hooks in `lemma-sdk/react`.
|
|
139
|
+
|
|
64
140
|
## Development
|
|
65
141
|
|
|
66
142
|
### Regenerate OpenAPI client
|
|
@@ -81,20 +157,16 @@ Output:
|
|
|
81
157
|
- `dist/browser/lemma-client.js` standalone browser bundle
|
|
82
158
|
- `public/lemma-client.js` committed copy for static serving
|
|
83
159
|
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
As of March 26, 2026, npm package name `lemma` is already taken. This repo is configured to publish as `lemma-sdk`.
|
|
87
|
-
|
|
88
|
-
Release check:
|
|
160
|
+
### Release check
|
|
89
161
|
|
|
90
162
|
```bash
|
|
91
163
|
npm run release:check
|
|
92
164
|
```
|
|
93
165
|
|
|
94
|
-
Publish
|
|
166
|
+
### Publish
|
|
95
167
|
|
|
96
168
|
```bash
|
|
97
169
|
npm publish
|
|
98
170
|
```
|
|
99
171
|
|
|
100
|
-
`lemma
|
|
172
|
+
As of March 26, 2026, npm package name `lemma` is already taken. This package publishes as `lemma-sdk`.
|