lemma-sdk 0.2.30 → 0.2.32

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.
Files changed (74) hide show
  1. package/README.md +213 -51
  2. package/dist/react/index.d.ts +23 -1
  3. package/dist/react/index.js +11 -0
  4. package/dist/react/useAgentInputSchema.d.ts +19 -0
  5. package/dist/react/useAgentInputSchema.js +73 -0
  6. package/dist/react/useAgentRun.js +18 -20
  7. package/dist/react/useAgentRuns.d.ts +33 -0
  8. package/dist/react/useAgentRuns.js +149 -0
  9. package/dist/react/useAssistantRun.js +10 -9
  10. package/dist/react/useAssistantSession.js +21 -25
  11. package/dist/react/useBulkRecords.js +9 -16
  12. package/dist/react/useConversation.js +24 -8
  13. package/dist/react/useConversations.d.ts +4 -0
  14. package/dist/react/useConversations.js +49 -3
  15. package/dist/react/useCreateRecord.d.ts +33 -3
  16. package/dist/react/useCreateRecord.js +20 -17
  17. package/dist/react/useCurrentUser.d.ts +14 -0
  18. package/dist/react/useCurrentUser.js +68 -0
  19. package/dist/react/useDeleteRecord.js +9 -16
  20. package/dist/react/useFlowRunHistory.js +1 -5
  21. package/dist/react/useFlowSession.js +41 -33
  22. package/dist/react/useForeignKeyOptions.d.ts +18 -0
  23. package/dist/react/useForeignKeyOptions.js +26 -15
  24. package/dist/react/useFunctionRun.d.ts +36 -0
  25. package/dist/react/useFunctionRun.js +30 -0
  26. package/dist/react/useFunctionRuns.d.ts +33 -0
  27. package/dist/react/useFunctionRuns.js +149 -0
  28. package/dist/react/useFunctionSession.js +37 -29
  29. package/dist/react/useJoinedRecords.d.ts +57 -2
  30. package/dist/react/useJoinedRecords.js +77 -27
  31. package/dist/react/useMembers.d.ts +4 -0
  32. package/dist/react/useMembers.js +55 -16
  33. package/dist/react/useOrganizationMembers.d.ts +26 -0
  34. package/dist/react/useOrganizationMembers.js +113 -0
  35. package/dist/react/usePodAccess.d.ts +22 -0
  36. package/dist/react/usePodAccess.js +128 -0
  37. package/dist/react/useRecord.d.ts +16 -0
  38. package/dist/react/useRecord.js +24 -13
  39. package/dist/react/useRecordForm.d.ts +42 -3
  40. package/dist/react/useRecordForm.js +44 -24
  41. package/dist/react/useRecords.d.ts +2 -0
  42. package/dist/react/useRecords.js +62 -22
  43. package/dist/react/useReferencingRecords.d.ts +66 -0
  44. package/dist/react/useReferencingRecords.js +159 -0
  45. package/dist/react/useRelatedRecords.d.ts +17 -0
  46. package/dist/react/useRelatedRecords.js +28 -21
  47. package/dist/react/useReverseRelatedRecords.d.ts +21 -0
  48. package/dist/react/useReverseRelatedRecords.js +30 -21
  49. package/dist/react/useSchemaForm.js +1 -13
  50. package/dist/react/useTable.js +24 -13
  51. package/dist/react/useTables.d.ts +4 -0
  52. package/dist/react/useTables.js +57 -15
  53. package/dist/react/useTaskSession.js +11 -22
  54. package/dist/react/useUpdateRecord.d.ts +34 -3
  55. package/dist/react/useUpdateRecord.js +21 -17
  56. package/dist/react/useWorkflowResume.d.ts +18 -0
  57. package/dist/react/useWorkflowResume.js +45 -0
  58. package/dist/react/useWorkflowRun.d.ts +21 -0
  59. package/dist/react/useWorkflowRun.js +49 -0
  60. package/dist/react/useWorkflowRuns.d.ts +33 -0
  61. package/dist/react/useWorkflowRuns.js +149 -0
  62. package/dist/react/useWorkflowStart.js +20 -27
  63. package/dist/react/utils.d.ts +5 -0
  64. package/dist/react/utils.js +25 -0
  65. package/dist/types.d.ts +1 -0
  66. package/package.json +2 -4
  67. package/dist/react/components/AssistantChrome.d.ts +0 -86
  68. package/dist/react/components/AssistantChrome.js +0 -48
  69. package/dist/react/components/AssistantEmbedded.d.ts +0 -10
  70. package/dist/react/components/AssistantEmbedded.js +0 -15
  71. package/dist/react/components/AssistantExperience.d.ts +0 -96
  72. package/dist/react/components/AssistantExperience.js +0 -1294
  73. package/dist/react/components/assistant-types.d.ts +0 -80
  74. package/dist/react/components/assistant-types.js +0 -1
package/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Lemma TypeScript SDK
2
2
 
3
- `lemma-sdk` is the headless TypeScript SDK for Lemma. Use `lemma-sdk/react` for hooks and auth primitives, and use the Lemma shadcn registry for stock UI blocks.
3
+ `lemma-sdk` is the headless TypeScript SDK for Lemma. Use `lemma-sdk` for the core client, `lemma-sdk/react` for hooks and auth primitives, and the Lemma shadcn registry for stock UI blocks.
4
+
5
+ `AuthGuard` intentionally stays in `lemma-sdk/react`. Stock assistant, table, workflow, agent, member, and function UI lives in the registry.
4
6
 
5
7
  ## Install
6
8
 
@@ -26,15 +28,34 @@ That adds this namespace to your app's `components.json`:
26
28
 
27
29
  If your app does not have `components.json` yet, run `npx shadcn@latest init` first or after the command above.
28
30
 
29
- ## React Hooks
31
+ ## Core Client
32
+
33
+ ```ts
34
+ import { LemmaClient } from "lemma-sdk";
35
+
36
+ const client = new LemmaClient({
37
+ podId: "<pod-id>",
38
+ });
39
+
40
+ await client.initialize();
41
+
42
+ const tables = await client.tables.list();
43
+ const records = await client.records.list("tickets");
44
+ ```
45
+
46
+ Pod-scoped namespaces include `tables`, `records`, `assistants`, `agents`, `tasks`, `workflows`, `functions`, `files`, `desks`, `integrations`, `resources`, and `datastore`.
47
+
48
+ Org and user surfaces include `users`, `organizations`, `pods`, `podMembers`, `podJoinRequests`, and `podSurfaces`.
49
+
50
+ ## React Package
30
51
 
31
- Install React if your app needs it:
52
+ Install React if your app needs hooks:
32
53
 
33
54
  ```bash
34
55
  npm install react react-dom
35
56
  ```
36
57
 
37
- `lemma-sdk/react` is intentionally headless-first. It includes hooks plus `AuthGuard`, but not stock assistant or records UI.
58
+ `lemma-sdk/react` is headless-first. It exports hooks plus `AuthGuard`; it does not export stock UI components or CSS.
38
59
 
39
60
  ```tsx
40
61
  import {
@@ -42,105 +63,233 @@ import {
42
63
  useAgentRun,
43
64
  useConversationMessages,
44
65
  useConversations,
45
- useForeignKeyOptions,
46
- useMembers,
47
- useRecordForm,
48
- useRecordSchema,
49
66
  useRecords,
50
67
  useSchemaForm,
51
- useTables,
52
68
  useWorkflowStart,
53
69
  } from "lemma-sdk/react";
54
70
  ```
55
71
 
56
- Typical hook groups:
72
+ ### Hook Matrix
57
73
 
58
- - data tables: `useTables`, `useTable`, `useRecords`, `useRecord`, `useRelatedRecords`, `useReverseRelatedRecords`
59
- - record mutations and forms: `useCreateRecord`, `useUpdateRecord`, `useDeleteRecord`, `useBulkRecords`, `useRecordSchema`, `useRecordForm`, `useSchemaForm`
60
- - assistant and runs: `useConversation`, `useConversations`, `useConversationMessages`, `useAssistantController`, `useAssistantRun`, `useAgentRun`, `useWorkflowStart`
61
- - org and auth: `AuthGuard`, `useMembers`
74
+ | Area | Hooks | Stability | Use when |
75
+ | --- | --- | --- | --- |
76
+ | Auth | `AuthGuard`, `useAuth`, `useCurrentUser`, `usePodAccess` | Stable | Gate an app, read signed-in user state, or request pod access. |
77
+ | Tables | `useTables`, `useTable`, `useRecords`, `useRecord`, `useJoinedRecords`, `useRelatedRecords`, `useReverseRelatedRecords`, `useReferencingRecords` | Stable | Build custom table browsers, details views, related-record views, and relational reads. |
78
+ | Record mutations | `useCreateRecord`, `useUpdateRecord`, `useDeleteRecord`, `useBulkRecords` | Stable | Create, update, delete, or bulk-delete rows from headless UI. Function-backed mutations via `createVia`/`updateVia` options. |
79
+ | Record forms | `useRecordSchema`, `useRecordForm`, `useForeignKeyOptions`, `useSchemaForm` | Stable | Render schema-driven forms, enum fields, and foreign-key selectors. `useRecordForm` supports `submitVia: "function"`, `visibleFields`, `hiddenFields`. |
80
+ | Assistant | `useConversations`, `useConversation`, `useConversationMessages`, `useAssistantRun`, `useAssistantSession`, `useAssistantRuntime`, `useAssistantController` | Stable except controller/runtime | Build custom chat, conversation lists, streaming output, and final-output views. |
81
+ | Agents | `useAgentRun`, `useAgentRuns`, `useAgentInputSchema`, `useTaskSession` | Stable except raw session | Start agent tasks, submit follow-up input, read task history, and inspect input/output schemas. |
82
+ | Workflows | `useWorkflowStart`, `useWorkflowRun`, `useWorkflowRuns`, `useWorkflowResume` | Stable | Start, poll, resume, cancel, retry, and inspect workflow runs. |
83
+ | Workflow compatibility | `useFlowSession`, `useFlowRunHistory` | Deprecated naming | Kept for existing callers; prefer workflow-named hooks for new code. |
84
+ | Functions | `useFunctionRun`, `useFunctionRuns`, `useFunctionSession` | Stable except raw session | Run functions, poll function runs, and list function history. |
85
+ | Members and org | `useMembers`, `useOrganizationMembers` | Stable | Read pod and organization member lists. `useMembers` is intentionally read-only. |
62
86
 
63
- Minimal example:
87
+ ### Common Hook Shapes
88
+
89
+ For business-facing examples and a decision guide mapping "I want to..." to the right hook, see [docs/hooks-guide.md](docs/hooks-guide.md).
90
+
91
+ List hooks generally expose:
92
+
93
+ - `items` named for the resource, such as `records`, `runs`, or `members`
94
+ - `isLoading`
95
+ - `error`
96
+ - `nextPageToken`
97
+ - `refresh(...)`
98
+ - `loadMore(...)` where pagination is useful
99
+
100
+ Run hooks generally expose:
101
+
102
+ - `run` or `task`
103
+ - `status`
104
+ - `isPolling`, `isStreaming`, or `isRunning`
105
+ - `output`
106
+ - `finalOutput`
107
+ - `start(...)`
108
+ - `refresh(...)`
109
+ - follow-up helpers such as `resume(...)`, `submitInput(...)`, `cancel(...)`, or `retry(...)`
110
+
111
+ ### Headless Examples
112
+
113
+ Records:
64
114
 
65
115
  ```tsx
66
116
  import { LemmaClient } from "lemma-sdk";
67
- import { AuthGuard, useConversations, useConversationMessages } from "lemma-sdk/react";
117
+ import { useRecords } from "lemma-sdk/react";
68
118
 
69
119
  const client = new LemmaClient({ podId: "<pod-id>" });
70
120
 
71
- function SupportThread() {
121
+ function TicketList() {
122
+ const tickets = useRecords({
123
+ client,
124
+ tableName: "tickets",
125
+ limit: 25,
126
+ sortBy: "created_at",
127
+ order: "desc",
128
+ });
129
+
130
+ if (tickets.error) return <p>{tickets.error.message}</p>;
131
+
132
+ return (
133
+ <ul>
134
+ {tickets.records.map((ticket) => (
135
+ <li key={String(ticket.id)}>{String(ticket.title ?? ticket.id)}</li>
136
+ ))}
137
+ </ul>
138
+ );
139
+ }
140
+ ```
141
+
142
+ Assistant final output:
143
+
144
+ ```tsx
145
+ import { useConversationMessages, useConversations } from "lemma-sdk/react";
146
+
147
+ function SupportThread({ client }: { client: LemmaClient }) {
72
148
  const conversations = useConversations({
73
149
  client,
74
- podId: "<pod-id>",
75
150
  assistantName: "support_assistant",
76
151
  });
77
152
 
78
- const thread = useConversationMessages({
153
+ const messages = useConversationMessages({
79
154
  client,
80
- podId: "<pod-id>",
81
155
  conversationId: conversations.effectiveSelectedConversationId,
156
+ autoResume: true,
157
+ });
158
+
159
+ return <pre>{messages.finalOutputText || messages.outputText || "No output yet."}</pre>;
160
+ }
161
+ ```
162
+
163
+ Agent run:
164
+
165
+ ```tsx
166
+ import { useAgentRun } from "lemma-sdk/react";
167
+
168
+ function AgentButton({ client }: { client: LemmaClient }) {
169
+ const agent = useAgentRun({
170
+ client,
171
+ agentName: "triage_agent",
82
172
  });
83
173
 
84
- return <pre>{thread.finalOutputText ?? "No assistant output yet."}</pre>;
174
+ return (
175
+ <button
176
+ disabled={agent.isStreaming}
177
+ onClick={() => {
178
+ void agent.start({ ticket_id: "ticket_123" });
179
+ }}
180
+ >
181
+ {agent.status ?? "Run agent"}
182
+ </button>
183
+ );
85
184
  }
185
+ ```
186
+
187
+ Workflow run:
188
+
189
+ ```tsx
190
+ import { useWorkflowRun } from "lemma-sdk/react";
191
+
192
+ function WorkflowButton({ client }: { client: LemmaClient }) {
193
+ const workflow = useWorkflowRun({
194
+ client,
195
+ workflowName: "approve_ticket",
196
+ });
86
197
 
87
- export function App() {
88
198
  return (
89
- <AuthGuard client={client}>
90
- <SupportThread />
91
- </AuthGuard>
199
+ <button
200
+ disabled={workflow.isPolling}
201
+ onClick={() => {
202
+ void workflow.start({ ticket_id: "ticket_123" });
203
+ }}
204
+ >
205
+ {workflow.status ?? "Start workflow"}
206
+ </button>
92
207
  );
93
208
  }
94
209
  ```
95
210
 
96
211
  ## Shadcn Registry
97
212
 
98
- Lemma UI now lives in the registry, not in `lemma-sdk/react`.
213
+ Lemma UI lives in the registry, not in `lemma-sdk/react`.
99
214
 
100
215
  After running `npx lemma-sdk init-shadcn`, install blocks like:
101
216
 
102
217
  ```bash
103
218
  npx shadcn@latest add @lemma/lemma-records-page
104
- npx shadcn@latest add @lemma/lemma-assistant-embedded
105
- npx shadcn@latest add @lemma/lemma-workflow-start-form
219
+ npx shadcn@latest add @lemma/lemma-agent-runner-page
220
+ npx shadcn@latest add @lemma/lemma-workflow-launcher-page
221
+ npx shadcn@latest add @lemma/lemma-function-runner-page
106
222
  ```
107
223
 
108
- Current registry items include:
224
+ Current registry items:
109
225
 
110
- - `lemma-assistant-experience`
111
- - `lemma-assistant-embedded`
112
- - `lemma-schema-form`
113
- - `lemma-records-page`
114
- - `lemma-record-form`
115
- - `lemma-records-table`
116
- - `lemma-related-records-table`
117
- - `lemma-reverse-related-records-table`
118
- - `lemma-workflow-start-form`
226
+ | Area | Items |
227
+ | --- | --- |
228
+ | Assistant | `lemma-assistant-experience`, `lemma-assistant-embedded` |
229
+ | Schema | `lemma-schema-form` |
230
+ | Tables | `lemma-table-picker`, `lemma-record-picker`, `lemma-record-filters-bar`, `lemma-records-table`, `lemma-record-details-card`, `lemma-record-form`, `lemma-related-records-table`, `lemma-reverse-related-records-table`, `lemma-bulk-actions-bar`, `lemma-records-page` |
231
+ | Agents | `lemma-agent-run-panel`, `lemma-agent-output-card`, `lemma-agent-messages`, `lemma-agent-runner-page` |
232
+ | Workflows | `lemma-workflow-start-form`, `lemma-workflow-history`, `lemma-workflow-run-status`, `lemma-workflow-run-details`, `lemma-workflow-launcher-page` |
233
+ | Members and access | `lemma-members-table`, `lemma-member-picker`, `lemma-org-member-picker`, `lemma-pod-access-card` |
234
+ | Functions | `lemma-function-run-panel`, `lemma-function-run-history`, `lemma-function-runner-page` |
119
235
 
120
236
  The registry is currently served from jsDelivr against this public repo:
121
237
 
122
238
  - registry root: `https://cdn.jsdelivr.net/gh/gappyai/lemma-typescript@main/public/r/registry.json`
123
239
  - item shape: `https://cdn.jsdelivr.net/gh/gappyai/lemma-typescript@main/public/r/{name}.json`
124
240
 
125
- For more stable installs, prefer pinning the registry URL to a tag or commit SHA instead of `@main`.
241
+ For more stable installs, pin the registry URL to a tag or commit SHA instead of `@main`.
126
242
 
127
- ## Core Client
243
+ ### Records Workspace Customization
128
244
 
129
- ```ts
130
- import { LemmaClient } from "lemma-sdk";
245
+ The records blocks are meant to be configured with props before you reach for a fork.
131
246
 
132
- const client = new LemmaClient({
133
- podId: "<pod-id>",
134
- });
247
+ `lemma-records-page` supports:
135
248
 
136
- await client.initialize();
249
+ - capability toggles such as `allowCreate`, `allowEdit`, `allowSelection`, `allowBulkDelete`, `allowSearch`, `allowFilters`, `allowSorting`, `allowPageSizeSelect`, and `allowColumnVisibility`
250
+ - layout toggles such as `showTablePicker`, `showRecordPicker`, and `showRecordDetails`
251
+ - column control through `columns`, `hiddenColumnNames`, `defaultHiddenColumnNames`, and `onHiddenColumnNamesChange`
252
+ - non-`id` primary keys through `recordIdField` or `getRecordId`
253
+ - record-form overrides through `recordFormHiddenFields`, `recordFormFieldOrder`, `recordFormFieldLabels`, `recordFormFieldDescriptions`, `createFormTitle`, `editFormTitle`, `createSubmitLabel`, and `editSubmitLabel`
137
254
 
138
- const tables = await client.tables.list();
139
- const records = await client.records.list("tickets");
140
- ```
255
+ `lemma-records-table` supports richer column definitions:
256
+
257
+ - `label`, `description`, `type`, `width`, `minWidth`, `align`
258
+ - `searchable`, `hideable`, `hidden`
259
+ - `renderCell(...)` for custom cell output
260
+ - per-row buttons through `rowActions`
141
261
 
142
- Pod-scoped namespaces include `tables`, `records`, `assistants`, `agents`, `workflows`, `functions`, `files`, and `resources`.
143
- Org and user surfaces include `users`, `organizations`, `pods`, `podMembers`, and `podJoinRequests`.
262
+ ```tsx
263
+ import { LemmaRecordsPage } from "@/components/lemma/lemma-records-page";
264
+ import type { LemmaRecordsTableColumn } from "@/components/lemma/lemma-records-table";
265
+
266
+ const columns: LemmaRecordsTableColumn[] = [
267
+ { name: "item_id", label: "Item ID", hideable: false, width: 180 },
268
+ { name: "group_id", label: "Group", width: 160 },
269
+ { name: "name", label: "Name", minWidth: 320, searchable: true },
270
+ {
271
+ name: "sellable",
272
+ label: "Sellable",
273
+ type: "boolean",
274
+ width: 120,
275
+ align: "center",
276
+ renderCell: ({ value }) => (value ? "Yes" : "No"),
277
+ },
278
+ ];
279
+
280
+ <LemmaRecordsPage
281
+ allowColumnVisibility
282
+ allowCreate
283
+ allowEdit
284
+ columns={columns}
285
+ createButtonLabel="New SKU"
286
+ defaultHiddenColumnNames={["group_id"]}
287
+ editSubmitLabel="Save SKU"
288
+ recordFormFieldLabels={{ item_id: "Item ID" }}
289
+ recordIdField="item_id"
290
+ tableName="catalog_items"
291
+ />;
292
+ ```
144
293
 
145
294
  ## Auth
146
295
 
@@ -156,6 +305,19 @@ Useful helpers:
156
305
 
157
306
  When `client.podId` is set and the signed-in user is not a pod member, `AuthGuard` can render the request-access flow and create or show pod join requests.
158
307
 
308
+ `usePodAccess` exposes the same membership/request-access state as a hook for custom UI.
309
+
310
+ ## Migration Notes
311
+
312
+ From `0.2.30` onward:
313
+
314
+ - `lemma-sdk/react` should be treated as hooks plus auth primitives.
315
+ - `AuthGuard` remains in `lemma-sdk/react`.
316
+ - Stock UI should be installed from the shadcn registry.
317
+ - Assistant UI source and CSS are no longer part of the React SDK internals.
318
+ - `react-markdown` and `remark-gfm` are registry-block dependencies for assistant UI, not core SDK dependencies.
319
+ - New workflow code should prefer `useWorkflowRun`, `useWorkflowRuns`, and `useWorkflowResume` over the older `flow`-named hooks.
320
+
159
321
  ## Local Development
160
322
 
161
323
  From the root of this repository:
@@ -12,12 +12,22 @@ export { useConversationMessages } from "./useConversationMessages.js";
12
12
  export type { UseConversationMessagesOptions, UseConversationMessagesResult, } from "./useConversationMessages.js";
13
13
  export { useAgentRun } from "./useAgentRun.js";
14
14
  export type { UseAgentRunOptions, UseAgentRunResult } from "./useAgentRun.js";
15
+ export { useAgentRuns } from "./useAgentRuns.js";
16
+ export type { UseAgentRunsOptions, UseAgentRunsResult } from "./useAgentRuns.js";
17
+ export { useAgentInputSchema } from "./useAgentInputSchema.js";
18
+ export type { UseAgentInputSchemaOptions, UseAgentInputSchemaResult, } from "./useAgentInputSchema.js";
15
19
  export { useAssistantSession } from "./useAssistantSession.js";
16
20
  export type { CreateConversationInput, SendAssistantMessageOptions, UseAssistantSessionOptions, UseAssistantSessionResult, } from "./useAssistantSession.js";
17
21
  export { useAssistantRuntime } from "./useAssistantRuntime.js";
18
22
  export type { UseAssistantRuntimeOptions, UseAssistantRuntimeResult, } from "./useAssistantRuntime.js";
19
23
  export { useMembers } from "./useMembers.js";
20
24
  export type { UseMembersOptions, UseMembersResult } from "./useMembers.js";
25
+ export { useOrganizationMembers } from "./useOrganizationMembers.js";
26
+ export type { UseOrganizationMembersOptions, UseOrganizationMembersResult, } from "./useOrganizationMembers.js";
27
+ export { useCurrentUser } from "./useCurrentUser.js";
28
+ export type { UseCurrentUserOptions, UseCurrentUserResult } from "./useCurrentUser.js";
29
+ export { usePodAccess } from "./usePodAccess.js";
30
+ export type { PodAccessStatus, UsePodAccessOptions, UsePodAccessResult, } from "./usePodAccess.js";
21
31
  export { useTables } from "./useTables.js";
22
32
  export type { UseTablesOptions, UseTablesResult } from "./useTables.js";
23
33
  export { useTable } from "./useTable.js";
@@ -35,11 +45,13 @@ export type { UseDeleteRecordOptions, UseDeleteRecordResult } from "./useDeleteR
35
45
  export { useBulkRecords } from "./useBulkRecords.js";
36
46
  export type { UseBulkRecordsOptions, UseBulkRecordsResult } from "./useBulkRecords.js";
37
47
  export { useJoinedRecords } from "./useJoinedRecords.js";
38
- export type { UseJoinedRecordsOptions, UseJoinedRecordsResult } from "./useJoinedRecords.js";
48
+ export type { JoinedRecordsShorthandJoin, UseJoinedRecordsOptions, UseJoinedRecordsResult, } from "./useJoinedRecords.js";
39
49
  export { useRelatedRecords } from "./useRelatedRecords.js";
40
50
  export type { RelatedRecordsColumn, RelatedRecordsInclude, RelatedRecordsResolvedInclude, UseRelatedRecordsOptions, UseRelatedRecordsResult, } from "./useRelatedRecords.js";
41
51
  export { useReverseRelatedRecords } from "./useReverseRelatedRecords.js";
42
52
  export type { ReverseRelatedRecordsColumn, ReverseRelatedRelation, ReverseRelationSelector, UseReverseRelatedRecordsOptions, UseReverseRelatedRecordsResult, } from "./useReverseRelatedRecords.js";
53
+ export { useReferencingRecords } from "./useReferencingRecords.js";
54
+ export type { ReferencingRecordsColumn, UseReferencingRecordsOptions, UseReferencingRecordsResult, } from "./useReferencingRecords.js";
43
55
  export { useForeignKeyOptions } from "./useForeignKeyOptions.js";
44
56
  export type { ForeignKeyOption, UseForeignKeyOptionsOptions, UseForeignKeyOptionsResult, } from "./useForeignKeyOptions.js";
45
57
  export { useRecordSchema } from "./useRecordSchema.js";
@@ -54,9 +66,19 @@ export { useTaskSession } from "./useTaskSession.js";
54
66
  export type { CreateTaskInput, UseTaskSessionOptions, UseTaskSessionResult, } from "./useTaskSession.js";
55
67
  export { useFunctionSession } from "./useFunctionSession.js";
56
68
  export type { UseFunctionSessionOptions, UseFunctionSessionResult, } from "./useFunctionSession.js";
69
+ export { useFunctionRun } from "./useFunctionRun.js";
70
+ export type { UseFunctionRunOptions, UseFunctionRunResult } from "./useFunctionRun.js";
71
+ export { useFunctionRuns } from "./useFunctionRuns.js";
72
+ export type { UseFunctionRunsOptions, UseFunctionRunsResult } from "./useFunctionRuns.js";
57
73
  export { useFlowSession } from "./useFlowSession.js";
58
74
  export type { UseFlowSessionOptions, UseFlowSessionResult, } from "./useFlowSession.js";
59
75
  export { useWorkflowStart } from "./useWorkflowStart.js";
60
76
  export type { UseWorkflowStartOptions, UseWorkflowStartResult, } from "./useWorkflowStart.js";
77
+ export { useWorkflowRun } from "./useWorkflowRun.js";
78
+ export type { UseWorkflowRunOptions, UseWorkflowRunResult } from "./useWorkflowRun.js";
79
+ export { useWorkflowRuns } from "./useWorkflowRuns.js";
80
+ export type { UseWorkflowRunsOptions, UseWorkflowRunsResult } from "./useWorkflowRuns.js";
81
+ export { useWorkflowResume } from "./useWorkflowResume.js";
82
+ export type { UseWorkflowResumeOptions, UseWorkflowResumeResult, } from "./useWorkflowResume.js";
61
83
  export { useFlowRunHistory } from "./useFlowRunHistory.js";
62
84
  export type { UseFlowRunHistoryOptions, UseFlowRunHistoryResult, } from "./useFlowRunHistory.js";
@@ -5,9 +5,14 @@ export { useConversations } from "./useConversations.js";
5
5
  export { useConversation } from "./useConversation.js";
6
6
  export { useConversationMessages } from "./useConversationMessages.js";
7
7
  export { useAgentRun } from "./useAgentRun.js";
8
+ export { useAgentRuns } from "./useAgentRuns.js";
9
+ export { useAgentInputSchema } from "./useAgentInputSchema.js";
8
10
  export { useAssistantSession } from "./useAssistantSession.js";
9
11
  export { useAssistantRuntime } from "./useAssistantRuntime.js";
10
12
  export { useMembers } from "./useMembers.js";
13
+ export { useOrganizationMembers } from "./useOrganizationMembers.js";
14
+ export { useCurrentUser } from "./useCurrentUser.js";
15
+ export { usePodAccess } from "./usePodAccess.js";
11
16
  export { useTables } from "./useTables.js";
12
17
  export { useTable } from "./useTable.js";
13
18
  export { useRecords } from "./useRecords.js";
@@ -19,6 +24,7 @@ export { useBulkRecords } from "./useBulkRecords.js";
19
24
  export { useJoinedRecords } from "./useJoinedRecords.js";
20
25
  export { useRelatedRecords } from "./useRelatedRecords.js";
21
26
  export { useReverseRelatedRecords } from "./useReverseRelatedRecords.js";
27
+ export { useReferencingRecords } from "./useReferencingRecords.js";
22
28
  export { useForeignKeyOptions } from "./useForeignKeyOptions.js";
23
29
  export { useRecordSchema } from "./useRecordSchema.js";
24
30
  export { useRecordForm } from "./useRecordForm.js";
@@ -26,6 +32,11 @@ export { useSchemaForm } from "./useSchemaForm.js";
26
32
  export { useAssistantController } from "./useAssistantController.js";
27
33
  export { useTaskSession } from "./useTaskSession.js";
28
34
  export { useFunctionSession } from "./useFunctionSession.js";
35
+ export { useFunctionRun } from "./useFunctionRun.js";
36
+ export { useFunctionRuns } from "./useFunctionRuns.js";
29
37
  export { useFlowSession } from "./useFlowSession.js";
30
38
  export { useWorkflowStart } from "./useWorkflowStart.js";
39
+ export { useWorkflowRun } from "./useWorkflowRun.js";
40
+ export { useWorkflowRuns } from "./useWorkflowRuns.js";
41
+ export { useWorkflowResume } from "./useWorkflowResume.js";
31
42
  export { useFlowRunHistory } from "./useFlowRunHistory.js";
@@ -0,0 +1,19 @@
1
+ import type { LemmaClient } from "../client.js";
2
+ import type { JsonSchemaLike } from "../schema-form.js";
3
+ import type { Agent } from "../types.js";
4
+ export interface UseAgentInputSchemaOptions {
5
+ client: LemmaClient;
6
+ podId?: string;
7
+ agentName: string;
8
+ enabled?: boolean;
9
+ autoLoad?: boolean;
10
+ }
11
+ export interface UseAgentInputSchemaResult {
12
+ agent: Agent | null;
13
+ inputSchema: JsonSchemaLike | null;
14
+ outputSchema: JsonSchemaLike | null;
15
+ isLoading: boolean;
16
+ error: Error | null;
17
+ refresh: () => Promise<Agent | null>;
18
+ }
19
+ export declare function useAgentInputSchema({ client, podId, agentName, enabled, autoLoad, }: UseAgentInputSchemaOptions): UseAgentInputSchemaResult;
@@ -0,0 +1,73 @@
1
+ import { useCallback, useEffect, useMemo, useState } from "react";
2
+ import { normalizeError, resolvePodClient } from "./utils.js";
3
+ export function useAgentInputSchema({ client, podId, agentName, enabled = true, autoLoad = true, }) {
4
+ const [agent, setAgent] = useState(null);
5
+ const [isLoading, setIsLoading] = useState(false);
6
+ const [error, setError] = useState(null);
7
+ const trimmedAgentName = agentName.trim();
8
+ const isEnabled = enabled && trimmedAgentName.length > 0;
9
+ const refresh = useCallback(async (signal) => {
10
+ if (!isEnabled) {
11
+ setAgent(null);
12
+ setError(null);
13
+ setIsLoading(false);
14
+ return null;
15
+ }
16
+ setIsLoading(true);
17
+ setError(null);
18
+ try {
19
+ const scopedClient = resolvePodClient(client, podId);
20
+ const nextAgent = await scopedClient.agents.get(trimmedAgentName);
21
+ if (signal?.aborted)
22
+ return null;
23
+ setAgent(nextAgent);
24
+ return nextAgent;
25
+ }
26
+ catch (refreshError) {
27
+ if (signal?.aborted)
28
+ return null;
29
+ const normalized = normalizeError(refreshError, "Failed to load agent schema.");
30
+ setError(normalized);
31
+ setAgent(null);
32
+ return null;
33
+ }
34
+ finally {
35
+ if (!signal?.aborted)
36
+ setIsLoading(false);
37
+ }
38
+ }, [client, isEnabled, podId, trimmedAgentName]);
39
+ useEffect(() => {
40
+ if (!isEnabled) {
41
+ setAgent(null);
42
+ setError(null);
43
+ setIsLoading(false);
44
+ return;
45
+ }
46
+ if (!autoLoad)
47
+ return;
48
+ const controller = new AbortController();
49
+ let cancelled = false;
50
+ (async () => {
51
+ try {
52
+ await refresh(controller.signal);
53
+ }
54
+ catch {
55
+ if (!cancelled) {
56
+ setError(normalizeError(new Error("Failed to load agent schema."), "Failed to load agent schema."));
57
+ }
58
+ }
59
+ })();
60
+ return () => {
61
+ cancelled = true;
62
+ controller.abort();
63
+ };
64
+ }, [autoLoad, isEnabled, refresh]);
65
+ return useMemo(() => ({
66
+ agent,
67
+ inputSchema: (agent?.input_schema ?? null),
68
+ outputSchema: (agent?.output_schema ?? null),
69
+ isLoading,
70
+ error,
71
+ refresh,
72
+ }), [agent, error, isLoading, refresh]);
73
+ }
@@ -1,5 +1,6 @@
1
- import { useCallback } from "react";
1
+ import { useCallback, useMemo } from "react";
2
2
  import { isTerminalTaskStatus, normalizeRunStatus } from "../run-utils.js";
3
+ import { resolvePodClient } from "./utils.js";
3
4
  import { useTaskSession, } from "./useTaskSession.js";
4
5
  function resolveAgentName(base, override) {
5
6
  const resolved = override ?? base;
@@ -8,11 +9,6 @@ function resolveAgentName(base, override) {
8
9
  }
9
10
  return resolved;
10
11
  }
11
- function resolvePodClient(client, podId) {
12
- if (!podId || podId === client.podId)
13
- return client;
14
- return client.withPod(podId);
15
- }
16
12
  export function useAgentRun({ client, podId, agentName, taskId = null, autoConnect = true, autoConnectOnStart = true, onEvent, onStatus, onMessage, onError, }) {
17
13
  const session = useTaskSession({
18
14
  client,
@@ -41,18 +37,20 @@ export function useAgentRun({ client, podId, agentName, taskId = null, autoConne
41
37
  await session.loadMessages(resolvedTaskId);
42
38
  return session.refreshTask(resolvedTaskId);
43
39
  }, [client, podId, session]);
44
- const normalizedStatus = normalizeRunStatus(session.status);
45
- const isFinished = isTerminalTaskStatus(normalizedStatus);
46
- const isWaitingForInput = normalizedStatus === "WAITING";
47
- const output = session.task?.output_data ?? null;
48
- const finalOutput = isFinished ? output : null;
49
- return {
50
- ...session,
51
- output,
52
- finalOutput,
53
- isWaitingForInput,
54
- isFinished,
55
- start,
56
- submitInput,
57
- };
40
+ return useMemo(() => {
41
+ const normalizedStatus = normalizeRunStatus(session.status);
42
+ const isFinished = isTerminalTaskStatus(normalizedStatus);
43
+ const isWaitingForInput = normalizedStatus === "WAITING";
44
+ const output = session.task?.output_data ?? null;
45
+ const finalOutput = isFinished ? output : null;
46
+ return {
47
+ ...session,
48
+ output,
49
+ finalOutput,
50
+ isWaitingForInput,
51
+ isFinished,
52
+ start,
53
+ submitInput,
54
+ };
55
+ }, [session, start, submitInput]);
58
56
  }
@@ -0,0 +1,33 @@
1
+ import type { LemmaClient } from "../client.js";
2
+ import type { Task } from "../types.js";
3
+ export interface UseAgentRunsOptions {
4
+ client: LemmaClient;
5
+ podId?: string;
6
+ agentName?: string;
7
+ enabled?: boolean;
8
+ autoLoad?: boolean;
9
+ limit?: number;
10
+ pageToken?: string;
11
+ initialTaskId?: string | null;
12
+ }
13
+ export interface UseAgentRunsResult {
14
+ runs: Task[];
15
+ total: number;
16
+ nextPageToken: string | null;
17
+ selectedTaskId: string | null;
18
+ effectiveSelectedTaskId: string | null;
19
+ selectedRun: Task | null;
20
+ isLoading: boolean;
21
+ isLoadingMore: boolean;
22
+ error: Error | null;
23
+ selectRun: (taskId: string | null) => void;
24
+ clearSelection: () => void;
25
+ refresh: (overrides?: {
26
+ limit?: number;
27
+ pageToken?: string;
28
+ }) => Promise<Task[]>;
29
+ loadMore: (overrides?: {
30
+ limit?: number;
31
+ }) => Promise<Task[]>;
32
+ }
33
+ export declare function useAgentRuns({ client, podId, agentName, enabled, autoLoad, limit, pageToken, initialTaskId, }: UseAgentRunsOptions): UseAgentRunsResult;