lemma-sdk 0.2.45 → 0.2.46

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 (56) hide show
  1. package/dist/assistant-events.js +12 -2
  2. package/dist/browser/lemma-client.js +56 -84
  3. package/dist/client.js +1 -1
  4. package/dist/hey_client/types.gen.d.ts +2 -14
  5. package/dist/namespaces/conversations.d.ts +2 -2
  6. package/dist/namespaces/integrations.d.ts +2 -4
  7. package/dist/namespaces/integrations.js +2 -2
  8. package/dist/namespaces/records.d.ts +3 -9
  9. package/dist/namespaces/records.js +4 -33
  10. package/dist/openapi_client/index.d.ts +3 -5
  11. package/dist/openapi_client/index.js +2 -0
  12. package/dist/openapi_client/models/AgentToolset.d.ts +2 -1
  13. package/dist/openapi_client/models/AgentToolset.js +1 -0
  14. package/dist/openapi_client/models/AppTriggerResponseSchema.d.ts +2 -0
  15. package/dist/openapi_client/models/ApprovalDecisionResponse.d.ts +6 -0
  16. package/dist/openapi_client/models/AuthProvider.d.ts +4 -0
  17. package/dist/openapi_client/models/AuthProvider.js +9 -0
  18. package/dist/openapi_client/models/FlowRunStatus.d.ts +3 -2
  19. package/dist/openapi_client/models/FlowRunStatus.js +3 -2
  20. package/dist/openapi_client/models/MessageKind.d.ts +14 -0
  21. package/dist/openapi_client/models/MessageKind.js +19 -0
  22. package/dist/openapi_client/models/MessageResponse.d.ts +5 -6
  23. package/dist/openapi_client/models/WorkflowRunResponse.d.ts +2 -2
  24. package/dist/openapi_client/services/AgentConversationsService.d.ts +5 -5
  25. package/dist/openapi_client/services/AgentConversationsService.js +3 -3
  26. package/dist/openapi_client/services/ApplicationsService.d.ts +19 -19
  27. package/dist/openapi_client/services/ApplicationsService.js +48 -44
  28. package/dist/openapi_client/services/RecordsService.d.ts +1 -3
  29. package/dist/openapi_client/services/RecordsService.js +1 -5
  30. package/dist/react/assistant-output.d.ts +6 -0
  31. package/dist/react/assistant-output.js +16 -0
  32. package/dist/react/useAssistantController.d.ts +8 -1
  33. package/dist/react/useAssistantController.js +87 -250
  34. package/dist/react/useAssistantRuntime.js +6 -17
  35. package/dist/react/useAssistantSession.d.ts +4 -2
  36. package/dist/react/useAssistantSession.js +6 -7
  37. package/dist/react/useConversationMessages.d.ts +2 -2
  38. package/dist/react/useConversationMessages.js +3 -5
  39. package/dist/react/useRecords.d.ts +1 -1
  40. package/dist/react/useRecords.js +2 -13
  41. package/dist/react/useReferencingRecords.d.ts +4 -6
  42. package/dist/react/useReferencingRecords.js +5 -5
  43. package/dist/react/useReverseRelatedRecords.d.ts +3 -4
  44. package/dist/react/useReverseRelatedRecords.js +5 -5
  45. package/dist/types.d.ts +12 -6
  46. package/package.json +1 -1
  47. package/dist/openapi_client/models/NotificationContent.d.ts +0 -4
  48. package/dist/openapi_client/models/TextContent.d.ts +0 -4
  49. package/dist/openapi_client/models/TextContent.js +0 -1
  50. package/dist/openapi_client/models/ThinkingContent.d.ts +0 -4
  51. package/dist/openapi_client/models/ThinkingContent.js +0 -1
  52. package/dist/openapi_client/models/ToolCallContent.d.ts +0 -6
  53. package/dist/openapi_client/models/ToolCallContent.js +0 -1
  54. package/dist/openapi_client/models/ToolReturnContent.d.ts +0 -6
  55. package/dist/openapi_client/models/ToolReturnContent.js +0 -1
  56. /package/dist/openapi_client/models/{NotificationContent.js → ApprovalDecisionResponse.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { useCallback, useEffect, useMemo, useState } from "react";
2
2
  import { normalizeError, resolvePodClient, stringifyComparable } from "./utils.js";
3
- export function useRecords({ client, podId, tableName, filters, sort, limit = 20, pageToken, offset, sortBy, order, params, enabled = true, autoLoad = true, }) {
3
+ export function useRecords({ client, podId, tableName, filters, sort, limit = 20, pageToken, offset, enabled = true, autoLoad = true, }) {
4
4
  const [records, setRecords] = useState([]);
5
5
  const [total, setTotal] = useState(0);
6
6
  const [nextPageToken, setNextPageToken] = useState(null);
@@ -11,10 +11,8 @@ export function useRecords({ client, podId, tableName, filters, sort, limit = 20
11
11
  const isEnabled = enabled && trimmedTableName.length > 0;
12
12
  const filtersKey = stringifyComparable(filters);
13
13
  const sortKey = stringifyComparable(sort);
14
- const paramsKey = stringifyComparable(params);
15
14
  const stableFilters = useMemo(() => filters, [filtersKey]);
16
15
  const stableSort = useMemo(() => sort, [sortKey]);
17
- const stableParams = useMemo(() => params, [paramsKey]);
18
16
  const refresh = useCallback(async (overrides = {}, signal) => {
19
17
  if (!isEnabled) {
20
18
  setRecords([]);
@@ -34,9 +32,6 @@ export function useRecords({ client, podId, tableName, filters, sort, limit = 20
34
32
  limit: overrides.limit ?? limit,
35
33
  pageToken: overrides.pageToken ?? pageToken,
36
34
  offset: overrides.offset ?? offset,
37
- sortBy: overrides.sortBy ?? sortBy,
38
- order: overrides.order ?? order,
39
- params: overrides.params ?? stableParams,
40
35
  });
41
36
  if (signal?.aborted)
42
37
  return [];
@@ -62,12 +57,9 @@ export function useRecords({ client, podId, tableName, filters, sort, limit = 20
62
57
  isEnabled,
63
58
  limit,
64
59
  offset,
65
- order,
66
60
  pageToken,
67
61
  podId,
68
- sortBy,
69
62
  stableFilters,
70
- stableParams,
71
63
  stableSort,
72
64
  trimmedTableName,
73
65
  ]);
@@ -88,9 +80,6 @@ export function useRecords({ client, podId, tableName, filters, sort, limit = 20
88
80
  limit: overrides.limit ?? limit,
89
81
  pageToken: overrides.pageToken ?? nextPageToken ?? undefined,
90
82
  offset: overrides.offset ?? (nextPageToken ? undefined : (offset ?? 0) + loadedCount),
91
- sortBy: overrides.sortBy ?? sortBy,
92
- order: overrides.order ?? order,
93
- params: overrides.params ?? stableParams,
94
83
  });
95
84
  const moreRecords = (response.items ?? []);
96
85
  setRecords((previous) => [...previous, ...moreRecords]);
@@ -106,7 +95,7 @@ export function useRecords({ client, podId, tableName, filters, sort, limit = 20
106
95
  finally {
107
96
  setIsLoadingMore(false);
108
97
  }
109
- }, [client, isEnabled, isLoading, isLoadingMore, limit, nextPageToken, offset, order, podId, records.length, sortBy, stableFilters, stableParams, stableSort, total, trimmedTableName]);
98
+ }, [client, isEnabled, isLoading, isLoadingMore, limit, nextPageToken, offset, podId, records.length, stableFilters, stableSort, total, trimmedTableName]);
110
99
  useEffect(() => {
111
100
  if (!isEnabled) {
112
101
  setRecords([]);
@@ -1,5 +1,5 @@
1
1
  import type { LemmaClient } from "../client.js";
2
- import type { Table } from "../types.js";
2
+ import type { RecordSort, Table } from "../types.js";
3
3
  /**
4
4
  * React hook for fetching records from a referencing table that point back
5
5
  * to a specific record via a foreign key.
@@ -25,8 +25,7 @@ import type { Table } from "../types.js";
25
25
  * table: "issue_history",
26
26
  * foreignKey: "issue_id",
27
27
  * recordId: selectedIssueId,
28
- * sortBy: "created_at",
29
- * order: "desc",
28
+ * sort: [{ field: "created_at", direction: "desc" }],
30
29
  * });
31
30
  * ```
32
31
  */
@@ -48,8 +47,7 @@ export interface UseReferencingRecordsOptions {
48
47
  fields?: string[];
49
48
  limit?: number;
50
49
  offset?: number;
51
- sortBy?: string;
52
- order?: "asc" | "desc" | string;
50
+ sort?: RecordSort[];
53
51
  enabled?: boolean;
54
52
  autoLoad?: boolean;
55
53
  }
@@ -63,4 +61,4 @@ export interface UseReferencingRecordsResult<TRow extends Record<string, unknown
63
61
  error: Error | null;
64
62
  refresh: () => Promise<TRow[]>;
65
63
  }
66
- export declare function useReferencingRecords<TRow extends Record<string, unknown> = Record<string, unknown>>({ client, podId, table, foreignKey, recordId, fields, limit, offset, sortBy, order, enabled, autoLoad, }: UseReferencingRecordsOptions): UseReferencingRecordsResult<TRow>;
64
+ export declare function useReferencingRecords<TRow extends Record<string, unknown> = Record<string, unknown>>({ client, podId, table, foreignKey, recordId, fields, limit, offset, sort, enabled, autoLoad, }: UseReferencingRecordsOptions): UseReferencingRecordsResult<TRow>;
@@ -25,7 +25,7 @@ function pickDefaultFields(table, foreignKey) {
25
25
  });
26
26
  return next.slice(0, 6);
27
27
  }
28
- export function useReferencingRecords({ client, podId, table, foreignKey, recordId = null, fields, limit = 20, offset, sortBy, order, enabled = true, autoLoad = true, }) {
28
+ export function useReferencingRecords({ client, podId, table, foreignKey, recordId = null, fields, limit = 20, offset, sort, enabled = true, autoLoad = true, }) {
29
29
  const [referencedTable, setReferencedTable] = useState(null);
30
30
  const [columns, setColumns] = useState([]);
31
31
  const [records, setRecords] = useState([]);
@@ -36,7 +36,9 @@ export function useReferencingRecords({ client, podId, table, foreignKey, record
36
36
  const trimmedTable = table.trim();
37
37
  const trimmedRecordId = typeof recordId === "string" ? recordId.trim() : "";
38
38
  const fieldsKey = stringifyComparable(fields);
39
+ const sortKey = stringifyComparable(sort);
39
40
  const stableFields = useMemo(() => fields, [fieldsKey]);
41
+ const stableSort = useMemo(() => sort, [sortKey]);
40
42
  const isEnabled = enabled && trimmedTable.length > 0 && trimmedRecordId.length > 0;
41
43
  const refresh = useCallback(async (signal) => {
42
44
  if (!isEnabled) {
@@ -67,8 +69,7 @@ export function useReferencingRecords({ client, podId, table, foreignKey, record
67
69
  }],
68
70
  limit,
69
71
  offset,
70
- sortBy,
71
- order,
72
+ sort: stableSort,
72
73
  });
73
74
  if (signal?.aborted)
74
75
  return [];
@@ -100,10 +101,9 @@ export function useReferencingRecords({ client, podId, table, foreignKey, record
100
101
  isEnabled,
101
102
  limit,
102
103
  offset,
103
- order,
104
104
  podId,
105
- sortBy,
106
105
  stableFields,
106
+ stableSort,
107
107
  trimmedRecordId,
108
108
  trimmedTable,
109
109
  ]);
@@ -1,5 +1,5 @@
1
1
  import type { LemmaClient } from "../client.js";
2
- import type { Table } from "../types.js";
2
+ import type { RecordSort, Table } from "../types.js";
3
3
  /**
4
4
  * React hook for finding records in *other* tables that reference a given
5
5
  * record. Starts from the parent table, discovers all tables with FK
@@ -45,8 +45,7 @@ export interface UseReverseRelatedRecordsOptions {
45
45
  fields?: string[];
46
46
  limit?: number;
47
47
  offset?: number;
48
- sortBy?: string;
49
- order?: "asc" | "desc" | string;
48
+ sort?: RecordSort[];
50
49
  tablesLimit?: number;
51
50
  enabled?: boolean;
52
51
  autoLoad?: boolean;
@@ -65,4 +64,4 @@ export interface UseReverseRelatedRecordsResult<TRow extends Record<string, unkn
65
64
  error: Error | null;
66
65
  refresh: () => Promise<TRow[]>;
67
66
  }
68
- export declare function useReverseRelatedRecords<TRow extends Record<string, unknown> = Record<string, unknown>>({ client, podId, tableName, recordId, relation, fields, limit, offset, sortBy, order, tablesLimit, enabled, autoLoad, }: UseReverseRelatedRecordsOptions): UseReverseRelatedRecordsResult<TRow>;
67
+ export declare function useReverseRelatedRecords<TRow extends Record<string, unknown> = Record<string, unknown>>({ client, podId, tableName, recordId, relation, fields, limit, offset, sort, tablesLimit, enabled, autoLoad, }: UseReverseRelatedRecordsOptions): UseReverseRelatedRecordsResult<TRow>;
@@ -26,7 +26,7 @@ function pickDefaultFields(table, foreignKey) {
26
26
  });
27
27
  return next.slice(0, 6);
28
28
  }
29
- export function useReverseRelatedRecords({ client, podId, tableName, recordId = null, relation = null, fields, limit = 20, offset, sortBy, order, tablesLimit = 100, enabled = true, autoLoad = true, }) {
29
+ export function useReverseRelatedRecords({ client, podId, tableName, recordId = null, relation = null, fields, limit = 20, offset, sort, tablesLimit = 100, enabled = true, autoLoad = true, }) {
30
30
  const [parentTable, setParentTable] = useState(null);
31
31
  const [relatedTable, setRelatedTable] = useState(null);
32
32
  const [parentRecord, setParentRecord] = useState(null);
@@ -42,8 +42,10 @@ export function useReverseRelatedRecords({ client, podId, tableName, recordId =
42
42
  const trimmedRecordId = typeof recordId === "string" ? recordId.trim() : "";
43
43
  const relationKey = stringifyComparable(relation);
44
44
  const fieldsKey = stringifyComparable(fields);
45
+ const sortKey = stringifyComparable(sort);
45
46
  const stableRelation = useMemo(() => relation, [relationKey]);
46
47
  const stableFields = useMemo(() => fields, [fieldsKey]);
48
+ const stableSort = useMemo(() => sort, [sortKey]);
47
49
  const isEnabled = enabled && trimmedTableName.length > 0 && trimmedRecordId.length > 0;
48
50
  const refresh = useCallback(async (signal) => {
49
51
  if (!isEnabled) {
@@ -130,8 +132,7 @@ export function useReverseRelatedRecords({ client, podId, tableName, recordId =
130
132
  }],
131
133
  limit,
132
134
  offset,
133
- sortBy,
134
- order,
135
+ sort: stableSort,
135
136
  });
136
137
  if (signal?.aborted)
137
138
  return [];
@@ -162,11 +163,10 @@ export function useReverseRelatedRecords({ client, podId, tableName, recordId =
162
163
  isEnabled,
163
164
  limit,
164
165
  offset,
165
- order,
166
166
  podId,
167
- sortBy,
168
167
  stableFields,
169
168
  stableRelation,
169
+ stableSort,
170
170
  tablesLimit,
171
171
  trimmedRecordId,
172
172
  trimmedTableName,
package/dist/types.d.ts CHANGED
@@ -38,9 +38,6 @@ export interface ListRecordsOptions {
38
38
  limit?: number;
39
39
  pageToken?: string;
40
40
  offset?: number;
41
- sortBy?: string;
42
- order?: "asc" | "desc" | string;
43
- params?: Record<string, string | number | boolean | undefined | null>;
44
41
  }
45
42
  export interface RunFunctionOptions {
46
43
  /** Input payload for the function */
@@ -62,17 +59,26 @@ export type Conversation = GeneratedConversationResponse & {
62
59
  model?: ConversationModel | null;
63
60
  status?: string | null;
64
61
  };
62
+ /** Discriminator for the flat message shape (replaces the old nested content union). */
63
+ export type MessageKind = "text" | "thinking" | "notification" | "tool_call" | "tool_return";
65
64
  export interface ConversationMessageResponse {
66
65
  id: string;
67
66
  role: string;
68
- content: unknown;
67
+ kind: MessageKind;
68
+ /** Body for text / thinking / notification messages. */
69
+ text?: string | null;
70
+ /** Set on tool_call / tool_return messages. */
71
+ tool_name?: string | null;
72
+ tool_call_id?: string | null;
73
+ /** Inputs for a tool_call (arbitrary JSON). */
74
+ tool_args?: unknown;
75
+ /** Output for a tool_return (arbitrary JSON). */
76
+ tool_result?: unknown;
69
77
  created_at: string;
70
78
  conversation_id?: string;
71
79
  sequence?: number;
72
80
  agent_run_id?: string | null;
73
81
  metadata?: Record<string, unknown> | null;
74
- tool_call_id?: string | null;
75
- tool_name?: string | null;
76
82
  }
77
83
  export type ConversationMessage = ConversationMessageResponse;
78
84
  export type FunctionRun = FunctionRunResponse;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lemma-sdk",
3
- "version": "0.2.45",
3
+ "version": "0.2.46",
4
4
  "description": "Official TypeScript SDK for Lemma APIs, optimized around pod-scoped workflows",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1,4 +0,0 @@
1
- export type NotificationContent = {
2
- content: string;
3
- type?: string;
4
- };
@@ -1,4 +0,0 @@
1
- export type TextContent = {
2
- content: string;
3
- type?: string;
4
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,4 +0,0 @@
1
- export type ThinkingContent = {
2
- content: string;
3
- type?: string;
4
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- export type ToolCallContent = {
2
- tool_call_id: string;
3
- tool_input?: any;
4
- tool_name: string;
5
- type?: string;
6
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1,6 +0,0 @@
1
- export type ToolReturnContent = {
2
- tool_call_id: string;
3
- tool_name?: (string | null);
4
- tool_output?: any;
5
- type?: string;
6
- };
@@ -1 +0,0 @@
1
- export {};