lemma-sdk 0.2.37 → 0.2.40

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 (111) hide show
  1. package/README.md +30 -14
  2. package/dist/browser/lemma-client.js +260 -206
  3. package/dist/client.d.ts +2 -2
  4. package/dist/client.js +3 -3
  5. package/dist/index.d.ts +2 -4
  6. package/dist/index.js +1 -2
  7. package/dist/namespaces/conversations.d.ts +0 -5
  8. package/dist/namespaces/conversations.js +0 -15
  9. package/dist/namespaces/pod-members.d.ts +5 -3
  10. package/dist/namespaces/pod-members.js +12 -6
  11. package/dist/namespaces/schedules.d.ts +22 -0
  12. package/dist/namespaces/schedules.js +24 -0
  13. package/dist/namespaces/workflows.d.ts +4 -5
  14. package/dist/namespaces/workflows.js +1 -4
  15. package/dist/openapi_client/index.d.ts +12 -12
  16. package/dist/openapi_client/index.js +5 -3
  17. package/dist/openapi_client/models/AgentModelName.d.ts +1 -1
  18. package/dist/openapi_client/models/AgentModelName.js +1 -1
  19. package/dist/openapi_client/models/CreateScheduleRequest.d.ts +14 -0
  20. package/dist/openapi_client/models/FlowResponse.d.ts +2 -2
  21. package/dist/openapi_client/models/FlowRunEntity.d.ts +5 -4
  22. package/dist/openapi_client/models/FormNodeConfig.d.ts +8 -0
  23. package/dist/openapi_client/models/MessageResponse.d.ts +0 -1
  24. package/dist/openapi_client/models/PodConfigResponse.d.ts +0 -2
  25. package/dist/openapi_client/models/PodMemberDetailResponse.d.ts +2 -0
  26. package/dist/openapi_client/models/PodMemberResponse.d.ts +2 -0
  27. package/dist/openapi_client/models/ScheduleListResponse.d.ts +9 -0
  28. package/dist/openapi_client/models/{TriggerResponse.d.ts → ScheduleResponse.d.ts} +8 -4
  29. package/dist/openapi_client/models/{TriggerType.d.ts → ScheduleType.d.ts} +2 -2
  30. package/dist/openapi_client/models/ScheduleType.js +13 -0
  31. package/dist/openapi_client/models/ScheduledFlowStartInput.d.ts +1 -1
  32. package/dist/openapi_client/models/ScheduledFlowStartOutput.d.ts +1 -1
  33. package/dist/openapi_client/models/SendMessageRequest.d.ts +0 -2
  34. package/dist/openapi_client/models/{UpdateTriggerRequest.d.ts → UpdateScheduleRequest.d.ts} +4 -2
  35. package/dist/openapi_client/models/WorkflowCreateRequest.d.ts +3 -3
  36. package/dist/openapi_client/models/WorkflowMode.d.ts +7 -0
  37. package/dist/openapi_client/models/WorkflowMode.js +12 -0
  38. package/dist/openapi_client/models/WorkflowRunWaitAssignment.d.ts +6 -0
  39. package/dist/openapi_client/models/WorkflowRunWaitAssignmentListResponse.d.ts +6 -0
  40. package/dist/openapi_client/models/WorkflowRunWaitEntity.d.ts +20 -0
  41. package/dist/openapi_client/models/WorkflowRunWaitStatus.d.ts +6 -0
  42. package/dist/openapi_client/models/WorkflowRunWaitStatus.js +11 -0
  43. package/dist/openapi_client/models/WorkflowRunWaitType.d.ts +7 -0
  44. package/dist/openapi_client/models/WorkflowRunWaitType.js +12 -0
  45. package/dist/openapi_client/models/WorkflowUpdateRequest.d.ts +3 -3
  46. package/dist/openapi_client/services/AgentConversationsService.d.ts +4 -14
  47. package/dist/openapi_client/services/AgentConversationsService.js +4 -30
  48. package/dist/openapi_client/services/PodMembersService.d.ts +25 -7
  49. package/dist/openapi_client/services/PodMembersService.js +57 -13
  50. package/dist/openapi_client/services/SchedulesService.d.ts +59 -0
  51. package/dist/openapi_client/services/SchedulesService.js +125 -0
  52. package/dist/openapi_client/services/WebhooksService.d.ts +4 -4
  53. package/dist/openapi_client/services/WebhooksService.js +6 -6
  54. package/dist/openapi_client/services/WorkflowsService.d.ts +12 -33
  55. package/dist/openapi_client/services/WorkflowsService.js +26 -69
  56. package/dist/react/AuthGuard.js +1 -1
  57. package/dist/react/index.d.ts +10 -8
  58. package/dist/react/index.js +5 -4
  59. package/dist/react/useAssistantController.js +0 -2
  60. package/dist/react/useAssistantSession.d.ts +0 -2
  61. package/dist/react/useAssistantSession.js +8 -14
  62. package/dist/react/useCreateSchedule.d.ts +17 -0
  63. package/dist/react/useCreateSchedule.js +45 -0
  64. package/dist/react/useDeleteSchedule.d.ts +19 -0
  65. package/dist/react/useDeleteSchedule.js +49 -0
  66. package/dist/react/usePodAccess.js +1 -1
  67. package/dist/react/useSchedules.d.ts +30 -0
  68. package/dist/react/useSchedules.js +123 -0
  69. package/dist/react/useUpdateSchedule.d.ts +20 -0
  70. package/dist/react/useUpdateSchedule.js +49 -0
  71. package/dist/react/useWorkflowRun.js +1 -1
  72. package/dist/react/useWorkflowRunWaitAssignments.d.ts +26 -0
  73. package/dist/react/useWorkflowRunWaitAssignments.js +102 -0
  74. package/dist/react/useWorkflowStart.js +1 -1
  75. package/dist/run-utils.d.ts +1 -5
  76. package/dist/run-utils.js +0 -10
  77. package/dist/types.d.ts +3 -43
  78. package/package.json +1 -1
  79. package/dist/namespaces/tasks.d.ts +0 -25
  80. package/dist/namespaces/tasks.js +0 -91
  81. package/dist/openapi_client/models/CreateTriggerRequest.d.ts +0 -13
  82. package/dist/openapi_client/models/FlowInstallResponse.d.ts +0 -15
  83. package/dist/openapi_client/models/PodFlowConfigItem.d.ts +0 -7
  84. package/dist/openapi_client/models/TriggerListResponse.d.ts +0 -9
  85. package/dist/openapi_client/models/TriggerType.js +0 -13
  86. package/dist/openapi_client/models/WorkflowInstallListResponse.d.ts +0 -4
  87. package/dist/openapi_client/models/WorkflowInstallMode.d.ts +0 -7
  88. package/dist/openapi_client/models/WorkflowInstallMode.js +0 -12
  89. package/dist/openapi_client/models/WorkflowInstallRequest.d.ts +0 -11
  90. package/dist/openapi_client/models/WorkflowInstallRequest.js +0 -1
  91. package/dist/openapi_client/models/WorkflowTimeInstallConfig.d.ts +0 -19
  92. package/dist/openapi_client/models/WorkflowTimeInstallConfig.js +0 -1
  93. package/dist/openapi_client/services/TriggersService.d.ts +0 -53
  94. package/dist/openapi_client/services/TriggersService.js +0 -109
  95. package/dist/react/useAgentRun.d.ts +0 -38
  96. package/dist/react/useAgentRun.js +0 -149
  97. package/dist/react/useAgentRuns.d.ts +0 -33
  98. package/dist/react/useAgentRuns.js +0 -149
  99. package/dist/react/useAssistantRun.d.ts +0 -27
  100. package/dist/react/useAssistantRun.js +0 -47
  101. package/dist/react/useTaskSession.d.ts +0 -35
  102. package/dist/react/useTaskSession.js +0 -269
  103. package/dist/task-events.d.ts +0 -8
  104. package/dist/task-events.js +0 -115
  105. /package/dist/openapi_client/models/{CreateTriggerRequest.js → CreateScheduleRequest.js} +0 -0
  106. /package/dist/openapi_client/models/{FlowInstallResponse.js → ScheduleListResponse.js} +0 -0
  107. /package/dist/openapi_client/models/{PodFlowConfigItem.js → ScheduleResponse.js} +0 -0
  108. /package/dist/openapi_client/models/{TriggerListResponse.js → UpdateScheduleRequest.js} +0 -0
  109. /package/dist/openapi_client/models/{TriggerResponse.js → WorkflowRunWaitAssignment.js} +0 -0
  110. /package/dist/openapi_client/models/{UpdateTriggerRequest.js → WorkflowRunWaitAssignmentListResponse.js} +0 -0
  111. /package/dist/openapi_client/models/{WorkflowInstallListResponse.js → WorkflowRunWaitEntity.js} +0 -0
@@ -1,6 +1,31 @@
1
1
  import { OpenAPI } from '../core/OpenAPI.js';
2
2
  import { request as __request } from '../core/request.js';
3
3
  export class WorkflowsService {
4
+ /**
5
+ * List Workflow Runs Waiting For Current User
6
+ * List active human form waits assigned to the current pod member.
7
+ * @param podId
8
+ * @param limit
9
+ * @param pageToken
10
+ * @returns WorkflowRunWaitAssignmentListResponse Successful Response
11
+ * @throws ApiError
12
+ */
13
+ static workflowRunWaitingAssignedToMe(podId, limit = 100, pageToken) {
14
+ return __request(OpenAPI, {
15
+ method: 'GET',
16
+ url: '/pods/{pod_id}/workflow-runs/waiting/assigned-to-me',
17
+ path: {
18
+ 'pod_id': podId,
19
+ },
20
+ query: {
21
+ 'limit': limit,
22
+ 'page_token': pageToken,
23
+ },
24
+ errors: {
25
+ 422: `Validation Error`,
26
+ },
27
+ });
28
+ }
4
29
  /**
5
30
  * Get Workflow Run
6
31
  * Get current state, context, and step history of a workflow run.
@@ -185,7 +210,7 @@ export class WorkflowsService {
185
210
  }
186
211
  /**
187
212
  * Update Workflow Metadata
188
- * Update workflow-level metadata such as description/install mode. Workflow names are immutable after creation. Use `workflow.graph.update` for nodes and edges.
213
+ * Update workflow-level metadata such as description and schedule mode. Workflow names are immutable after creation. Use `workflow.graph.update` for nodes and edges.
189
214
  * @param podId
190
215
  * @param workflowName
191
216
  * @param requestBody
@@ -231,74 +256,6 @@ export class WorkflowsService {
231
256
  },
232
257
  });
233
258
  }
234
- /**
235
- * Install Workflow
236
- * Install a workflow for runtime execution. Provide `account_id` when the workflow needs an integration account binding, and provide `schedule` when installing a scheduled workflow.
237
- * @param podId
238
- * @param workflowName
239
- * @param requestBody
240
- * @returns FlowInstallResponse Successful Response
241
- * @throws ApiError
242
- */
243
- static workflowInstallCreate(podId, workflowName, requestBody) {
244
- return __request(OpenAPI, {
245
- method: 'POST',
246
- url: '/pods/{pod_id}/workflows/{workflow_name}/install',
247
- path: {
248
- 'pod_id': podId,
249
- 'workflow_name': workflowName,
250
- },
251
- body: requestBody,
252
- mediaType: 'application/json',
253
- errors: {
254
- 422: `Validation Error`,
255
- },
256
- });
257
- }
258
- /**
259
- * List Workflow Installs
260
- * List workflow installations visible to the current user. `GLOBAL` workflows return the pod-level install; `USER` workflows return the current user's install.
261
- * @param podId
262
- * @param workflowName
263
- * @returns WorkflowInstallListResponse Successful Response
264
- * @throws ApiError
265
- */
266
- static workflowInstallList(podId, workflowName) {
267
- return __request(OpenAPI, {
268
- method: 'GET',
269
- url: '/pods/{pod_id}/workflows/{workflow_name}/installs',
270
- path: {
271
- 'pod_id': podId,
272
- 'workflow_name': workflowName,
273
- },
274
- errors: {
275
- 422: `Validation Error`,
276
- },
277
- });
278
- }
279
- /**
280
- * Uninstall Workflow
281
- * Remove a previously created workflow installation binding.
282
- * @param podId
283
- * @param workflowName
284
- * @param installId
285
- * @returns void
286
- * @throws ApiError
287
- */
288
- static workflowInstallDelete(podId, workflowName, installId) {
289
- return __request(OpenAPI, {
290
- method: 'DELETE',
291
- url: '/pods/{pod_id}/workflows/{workflow_name}/installs/{install_id}',
292
- path: {
293
- 'pod_id': podId,
294
- 'workflow_name': workflowName,
295
- 'install_id': installId,
296
- },
297
- errors: {
298
- 422: `Validation Error`,
299
- },
300
- });
301
- }
302
259
  /**
303
260
  * Start Workflow
304
261
  * Start a new workflow run. For event/scheduled/datastore starts, the request body is treated as initial trigger payload and merged into execution context.
@@ -98,7 +98,7 @@ export function AuthGuard({ client, children, loadingFallback = null, unauthenti
98
98
  setMembershipError(null);
99
99
  try {
100
100
  const currentUser = await client.users.current();
101
- await client.podMembers.get(client.podId, currentUser.id);
101
+ await client.podMembers.lookupByUserId(client.podId, currentUser.id);
102
102
  setMembershipState("member");
103
103
  setJoinRequest(null);
104
104
  return;
@@ -2,18 +2,12 @@ export { AuthGuard } from "./AuthGuard.js";
2
2
  export type { AuthGuardProps } from "./AuthGuard.js";
3
3
  export { useAuth } from "./useAuth.js";
4
4
  export type { UseAuthResult } from "./useAuth.js";
5
- export { useAssistantRun } from "./useAssistantRun.js";
6
- export type { UseAssistantRunOptions, UseAssistantRunResult } from "./useAssistantRun.js";
7
5
  export { useConversations } from "./useConversations.js";
8
6
  export type { UseConversationsOptions, UseConversationsResult } from "./useConversations.js";
9
7
  export { useConversation } from "./useConversation.js";
10
8
  export type { UseConversationOptions, UseConversationResult } from "./useConversation.js";
11
9
  export { useConversationMessages } from "./useConversationMessages.js";
12
10
  export type { UseConversationMessagesOptions, UseConversationMessagesResult, } from "./useConversationMessages.js";
13
- export { useAgentRun } from "./useAgentRun.js";
14
- export type { UseAgentRunOptions, UseAgentRunResult } from "./useAgentRun.js";
15
- export { useAgentRuns } from "./useAgentRuns.js";
16
- export type { UseAgentRunsOptions, UseAgentRunsResult } from "./useAgentRuns.js";
17
11
  export { useAgentInputSchema } from "./useAgentInputSchema.js";
18
12
  export type { UseAgentInputSchemaOptions, UseAgentInputSchemaResult, } from "./useAgentInputSchema.js";
19
13
  export { useAssistantSession } from "./useAssistantSession.js";
@@ -92,14 +86,20 @@ export { useSchemaForm } from "./useSchemaForm.js";
92
86
  export type { UseSchemaFormOptions, UseSchemaFormResult } from "./useSchemaForm.js";
93
87
  export { useAssistantController } from "./useAssistantController.js";
94
88
  export type { AssistantAction, AssistantConversationScope, AssistantMessagePart, AssistantRenderableMessage, AssistantToolInvocation, UseAssistantControllerOptions, UseAssistantControllerResult, } from "./useAssistantController.js";
95
- export { useTaskSession } from "./useTaskSession.js";
96
- export type { CreateTaskInput, UseTaskSessionOptions, UseTaskSessionResult, } from "./useTaskSession.js";
97
89
  export { useFunctionSession } from "./useFunctionSession.js";
98
90
  export type { UseFunctionSessionOptions, UseFunctionSessionResult, } from "./useFunctionSession.js";
99
91
  export { useFunctionRun } from "./useFunctionRun.js";
100
92
  export type { UseFunctionRunOptions, UseFunctionRunResult } from "./useFunctionRun.js";
101
93
  export { useFunctionRuns } from "./useFunctionRuns.js";
102
94
  export type { UseFunctionRunsOptions, UseFunctionRunsResult } from "./useFunctionRuns.js";
95
+ export { useSchedules } from "./useSchedules.js";
96
+ export type { UseSchedulesOptions, UseSchedulesResult } from "./useSchedules.js";
97
+ export { useCreateSchedule } from "./useCreateSchedule.js";
98
+ export type { UseCreateScheduleOptions, UseCreateScheduleResult } from "./useCreateSchedule.js";
99
+ export { useUpdateSchedule } from "./useUpdateSchedule.js";
100
+ export type { UseUpdateScheduleOptions, UseUpdateScheduleResult } from "./useUpdateSchedule.js";
101
+ export { useDeleteSchedule } from "./useDeleteSchedule.js";
102
+ export type { UseDeleteScheduleOptions, UseDeleteScheduleResult } from "./useDeleteSchedule.js";
103
103
  export { useFlowSession } from "./useFlowSession.js";
104
104
  export type { UseFlowSessionOptions, UseFlowSessionResult, } from "./useFlowSession.js";
105
105
  export { useWorkflowStart } from "./useWorkflowStart.js";
@@ -108,6 +108,8 @@ export { useWorkflowRun } from "./useWorkflowRun.js";
108
108
  export type { UseWorkflowRunOptions, UseWorkflowRunResult } from "./useWorkflowRun.js";
109
109
  export { useWorkflowRuns } from "./useWorkflowRuns.js";
110
110
  export type { UseWorkflowRunsOptions, UseWorkflowRunsResult } from "./useWorkflowRuns.js";
111
+ export { useWorkflowRunWaitAssignments } from "./useWorkflowRunWaitAssignments.js";
112
+ export type { UseWorkflowRunWaitAssignmentsOptions, UseWorkflowRunWaitAssignmentsResult, } from "./useWorkflowRunWaitAssignments.js";
111
113
  export { useWorkflowResume } from "./useWorkflowResume.js";
112
114
  export type { UseWorkflowResumeOptions, UseWorkflowResumeResult, } from "./useWorkflowResume.js";
113
115
  export { useFlowRunHistory } from "./useFlowRunHistory.js";
@@ -1,11 +1,8 @@
1
1
  export { AuthGuard } from "./AuthGuard.js";
2
2
  export { useAuth } from "./useAuth.js";
3
- export { useAssistantRun } from "./useAssistantRun.js";
4
3
  export { useConversations } from "./useConversations.js";
5
4
  export { useConversation } from "./useConversation.js";
6
5
  export { useConversationMessages } from "./useConversationMessages.js";
7
- export { useAgentRun } from "./useAgentRun.js";
8
- export { useAgentRuns } from "./useAgentRuns.js";
9
6
  export { useAgentInputSchema } from "./useAgentInputSchema.js";
10
7
  export { useAssistantSession } from "./useAssistantSession.js";
11
8
  export { useAssistantRuntime } from "./useAssistantRuntime.js";
@@ -45,13 +42,17 @@ export { useRecordSchema } from "./useRecordSchema.js";
45
42
  export { useRecordForm } from "./useRecordForm.js";
46
43
  export { useSchemaForm } from "./useSchemaForm.js";
47
44
  export { useAssistantController } from "./useAssistantController.js";
48
- export { useTaskSession } from "./useTaskSession.js";
49
45
  export { useFunctionSession } from "./useFunctionSession.js";
50
46
  export { useFunctionRun } from "./useFunctionRun.js";
51
47
  export { useFunctionRuns } from "./useFunctionRuns.js";
48
+ export { useSchedules } from "./useSchedules.js";
49
+ export { useCreateSchedule } from "./useCreateSchedule.js";
50
+ export { useUpdateSchedule } from "./useUpdateSchedule.js";
51
+ export { useDeleteSchedule } from "./useDeleteSchedule.js";
52
52
  export { useFlowSession } from "./useFlowSession.js";
53
53
  export { useWorkflowStart } from "./useWorkflowStart.js";
54
54
  export { useWorkflowRun } from "./useWorkflowRun.js";
55
55
  export { useWorkflowRuns } from "./useWorkflowRuns.js";
56
+ export { useWorkflowRunWaitAssignments } from "./useWorkflowRunWaitAssignments.js";
56
57
  export { useWorkflowResume } from "./useWorkflowResume.js";
57
58
  export { useFlowRunHistory } from "./useFlowRunHistory.js";
@@ -1057,7 +1057,6 @@ export function useAssistantController({ client, podId, agentName, assistantName
1057
1057
  touchConversation(finalConversationId, { status: "running" });
1058
1058
  await sessionSendMessage(messageContent, {
1059
1059
  conversationId: finalConversationId,
1060
- createIfMissing: false,
1061
1060
  });
1062
1061
  touchConversation(finalConversationId, { updated_at: new Date().toISOString() });
1063
1062
  }
@@ -1102,7 +1101,6 @@ export function useAssistantController({ client, podId, agentName, assistantName
1102
1101
  setIsStreaming(true);
1103
1102
  await sessionSendMessage(fileMessage, {
1104
1103
  conversationId: activeId,
1105
- createIfMissing: false,
1106
1104
  });
1107
1105
  await loadConversationMessages(activeId);
1108
1106
  touchConversation(activeId, { updated_at: new Date().toISOString() });
@@ -54,8 +54,6 @@ export interface CreateConversationInput {
54
54
  }
55
55
  export interface SendAssistantMessageOptions {
56
56
  conversationId?: string | null;
57
- createIfMissing?: boolean;
58
- createConversation?: CreateConversationInput;
59
57
  syncOnTurnEnd?: boolean;
60
58
  }
61
59
  export interface ResumeAssistantOptions {
@@ -342,7 +342,7 @@ export function useAssistantSession(options) {
342
342
  }
343
343
  catch (streamError) {
344
344
  if (!(streamError instanceof Error && streamError.name === "AbortError")) {
345
- const normalized = normalizeError(streamError, "Failed to stream agent run.");
345
+ const normalized = normalizeError(streamError, "Failed to stream conversation.");
346
346
  setError(normalized);
347
347
  onErrorRef.current?.(streamError);
348
348
  }
@@ -362,7 +362,7 @@ export function useAssistantSession(options) {
362
362
  setConversationStatus,
363
363
  syncOnTurnEnd,
364
364
  ]);
365
- const ensureConversation = useCallback(async (overrideConversationId, options) => {
365
+ const ensureConversation = useCallback(async (overrideConversationId) => {
366
366
  const existingId = overrideConversationId ?? conversationId;
367
367
  if (existingId) {
368
368
  // Avoid a network roundtrip on every send when we already have this conversation in state.
@@ -374,23 +374,17 @@ export function useAssistantSession(options) {
374
374
  return existing;
375
375
  throw new Error("Failed to resolve existing conversation.");
376
376
  }
377
- if (options?.createIfMissing !== true) {
378
- throw new Error("conversationId is required.");
379
- }
380
- return createConversation({
381
- ...(options.createConversation ?? {}),
382
- setActive: true,
383
- });
384
- }, [conversation, conversationId, createConversation, refreshConversation]);
377
+ throw new Error("conversationId is required. Create a conversation before sending a message.");
378
+ }, [conversation, conversationId, refreshConversation]);
385
379
  const sendMessage = useCallback(async (content, input = {}) => {
386
380
  setError(null);
387
381
  try {
388
- const resolvedConversation = await ensureConversation(input.conversationId, input);
382
+ const resolvedConversation = await ensureConversation(input.conversationId);
389
383
  const resolvedConversationId = requireConversationId(resolvedConversation.id);
390
384
  cancel();
391
385
  const controller = new AbortController();
392
386
  abortRef.current = controller;
393
- const scope = normalizeScope(client, defaultScope, input.createConversation);
387
+ const scope = normalizeScope(client, defaultScope);
394
388
  const scopedClient = applyPodScope(client, scope.podId);
395
389
  const stream = await scopedClient.conversations.sendMessageStream(resolvedConversationId, { content }, {
396
390
  pod_id: scope.podId ?? undefined,
@@ -438,7 +432,7 @@ export function useAssistantSession(options) {
438
432
  });
439
433
  }
440
434
  catch (resumeError) {
441
- const normalized = normalizeError(resumeError, "Failed to resume agent run.");
435
+ const normalized = normalizeError(resumeError, "Failed to resume conversation.");
442
436
  setError(normalized);
443
437
  onErrorRef.current?.(resumeError);
444
438
  throw normalized;
@@ -491,7 +485,7 @@ export function useAssistantSession(options) {
491
485
  clearStreamingText();
492
486
  }
493
487
  catch (stopError) {
494
- const normalized = normalizeError(stopError, "Failed to stop agent run.");
488
+ const normalized = normalizeError(stopError, "Failed to stop conversation.");
495
489
  setError(normalized);
496
490
  onErrorRef.current?.(stopError);
497
491
  throw normalized;
@@ -0,0 +1,17 @@
1
+ import type { LemmaClient } from "../client.js";
2
+ import type { CreateScheduleRequest, Schedule } from "../types.js";
3
+ export interface UseCreateScheduleOptions {
4
+ client: LemmaClient;
5
+ podId?: string;
6
+ enabled?: boolean;
7
+ onSuccess?: (schedule: Schedule) => void;
8
+ onError?: (error: unknown) => void;
9
+ }
10
+ export interface UseCreateScheduleResult {
11
+ schedule: Schedule | null;
12
+ isSubmitting: boolean;
13
+ error: Error | null;
14
+ create: (payload: CreateScheduleRequest) => Promise<Schedule | null>;
15
+ reset: () => void;
16
+ }
17
+ export declare function useCreateSchedule({ client, podId, enabled, onSuccess, onError, }: UseCreateScheduleOptions): UseCreateScheduleResult;
@@ -0,0 +1,45 @@
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
+ import { normalizeError, resolvePodClient } from "./utils.js";
3
+ export function useCreateSchedule({ client, podId, enabled = true, onSuccess, onError, }) {
4
+ const [schedule, setSchedule] = useState(null);
5
+ const [isSubmitting, setIsSubmitting] = useState(false);
6
+ const [error, setError] = useState(null);
7
+ const onSuccessRef = useRef(onSuccess);
8
+ const onErrorRef = useRef(onError);
9
+ useEffect(() => { onSuccessRef.current = onSuccess; }, [onSuccess]);
10
+ useEffect(() => { onErrorRef.current = onError; }, [onError]);
11
+ const create = useCallback(async (payload) => {
12
+ if (!enabled)
13
+ return null;
14
+ setIsSubmitting(true);
15
+ setError(null);
16
+ try {
17
+ const scopedClient = resolvePodClient(client, podId);
18
+ const nextSchedule = await scopedClient.schedules.create(payload);
19
+ setSchedule(nextSchedule);
20
+ onSuccessRef.current?.(nextSchedule);
21
+ return nextSchedule;
22
+ }
23
+ catch (mutationError) {
24
+ const normalized = normalizeError(mutationError, "Failed to create schedule.");
25
+ setError(normalized);
26
+ onErrorRef.current?.(mutationError);
27
+ return null;
28
+ }
29
+ finally {
30
+ setIsSubmitting(false);
31
+ }
32
+ }, [client, enabled, podId]);
33
+ const reset = useCallback(() => {
34
+ setSchedule(null);
35
+ setError(null);
36
+ setIsSubmitting(false);
37
+ }, []);
38
+ return useMemo(() => ({
39
+ schedule,
40
+ isSubmitting,
41
+ error,
42
+ create,
43
+ reset,
44
+ }), [create, error, isSubmitting, reset, schedule]);
45
+ }
@@ -0,0 +1,19 @@
1
+ import type { LemmaClient } from "../client.js";
2
+ export interface UseDeleteScheduleOptions {
3
+ client: LemmaClient;
4
+ podId?: string;
5
+ scheduleId?: string | null;
6
+ enabled?: boolean;
7
+ onSuccess?: (scheduleId: string) => void;
8
+ onError?: (error: unknown) => void;
9
+ }
10
+ export interface UseDeleteScheduleResult {
11
+ deletedScheduleId: string | null;
12
+ isSubmitting: boolean;
13
+ error: Error | null;
14
+ remove: (overrides?: {
15
+ scheduleId?: string | null;
16
+ }) => Promise<boolean>;
17
+ reset: () => void;
18
+ }
19
+ export declare function useDeleteSchedule({ client, podId, scheduleId, enabled, onSuccess, onError, }: UseDeleteScheduleOptions): UseDeleteScheduleResult;
@@ -0,0 +1,49 @@
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
+ import { normalizeError, resolvePodClient } from "./utils.js";
3
+ export function useDeleteSchedule({ client, podId, scheduleId = null, enabled = true, onSuccess, onError, }) {
4
+ const [deletedScheduleId, setDeletedScheduleId] = useState(null);
5
+ const [isSubmitting, setIsSubmitting] = useState(false);
6
+ const [error, setError] = useState(null);
7
+ const onSuccessRef = useRef(onSuccess);
8
+ const onErrorRef = useRef(onError);
9
+ useEffect(() => { onSuccessRef.current = onSuccess; }, [onSuccess]);
10
+ useEffect(() => { onErrorRef.current = onError; }, [onError]);
11
+ const trimmedScheduleId = typeof scheduleId === "string" ? scheduleId.trim() : "";
12
+ const remove = useCallback(async (overrides = {}) => {
13
+ const nextScheduleId = typeof overrides.scheduleId === "string"
14
+ ? overrides.scheduleId.trim()
15
+ : trimmedScheduleId;
16
+ if (!enabled || nextScheduleId.length === 0)
17
+ return false;
18
+ setIsSubmitting(true);
19
+ setError(null);
20
+ try {
21
+ const scopedClient = resolvePodClient(client, podId);
22
+ await scopedClient.schedules.delete(nextScheduleId);
23
+ setDeletedScheduleId(nextScheduleId);
24
+ onSuccessRef.current?.(nextScheduleId);
25
+ return true;
26
+ }
27
+ catch (mutationError) {
28
+ const normalized = normalizeError(mutationError, "Failed to delete schedule.");
29
+ setError(normalized);
30
+ onErrorRef.current?.(mutationError);
31
+ return false;
32
+ }
33
+ finally {
34
+ setIsSubmitting(false);
35
+ }
36
+ }, [client, enabled, podId, trimmedScheduleId]);
37
+ const reset = useCallback(() => {
38
+ setDeletedScheduleId(null);
39
+ setError(null);
40
+ setIsSubmitting(false);
41
+ }, []);
42
+ return useMemo(() => ({
43
+ deletedScheduleId,
44
+ isSubmitting,
45
+ error,
46
+ remove,
47
+ reset,
48
+ }), [deletedScheduleId, error, isSubmitting, remove, reset]);
49
+ }
@@ -30,7 +30,7 @@ export function usePodAccess({ client, podId, enabled = true, autoLoad = true, }
30
30
  const currentUser = await client.users.current();
31
31
  setUser(currentUser);
32
32
  try {
33
- const nextMember = await client.podMembers.get(resolvedPodId, currentUser.id);
33
+ const nextMember = await client.podMembers.lookupByUserId(resolvedPodId, currentUser.id);
34
34
  setMember(nextMember);
35
35
  setJoinRequest(null);
36
36
  setStatus("member");
@@ -0,0 +1,30 @@
1
+ import type { LemmaClient } from "../client.js";
2
+ import type { Schedule, ScheduleType } from "../types.js";
3
+ export interface UseSchedulesOptions {
4
+ client: LemmaClient;
5
+ podId?: string;
6
+ enabled?: boolean;
7
+ autoLoad?: boolean;
8
+ scheduleType?: ScheduleType | null;
9
+ isActive?: boolean | null;
10
+ agentName?: string | null;
11
+ workflowName?: string | null;
12
+ limit?: number;
13
+ pageToken?: string | null;
14
+ }
15
+ export interface UseSchedulesResult {
16
+ schedules: Schedule[];
17
+ total: number;
18
+ nextPageToken: string | null;
19
+ isLoading: boolean;
20
+ isLoadingMore: boolean;
21
+ error: Error | null;
22
+ refresh: (overrides?: {
23
+ limit?: number;
24
+ pageToken?: string | null;
25
+ }) => Promise<Schedule[]>;
26
+ loadMore: (overrides?: {
27
+ limit?: number;
28
+ }) => Promise<Schedule[]>;
29
+ }
30
+ export declare function useSchedules({ client, podId, enabled, autoLoad, scheduleType, isActive, agentName, workflowName, limit, pageToken, }: UseSchedulesOptions): UseSchedulesResult;
@@ -0,0 +1,123 @@
1
+ import { useCallback, useEffect, useMemo, useState } from "react";
2
+ import { normalizeError, resolvePodClient } from "./utils.js";
3
+ export function useSchedules({ client, podId, enabled = true, autoLoad = true, scheduleType = null, isActive = null, agentName = null, workflowName = null, limit = 100, pageToken = null, }) {
4
+ const [schedules, setSchedules] = useState([]);
5
+ const [total, setTotal] = useState(0);
6
+ const [nextPageToken, setNextPageToken] = useState(null);
7
+ const [isLoading, setIsLoading] = useState(false);
8
+ const [isLoadingMore, setIsLoadingMore] = useState(false);
9
+ const [error, setError] = useState(null);
10
+ const refresh = useCallback(async (overrides = {}, signal) => {
11
+ if (!enabled) {
12
+ setSchedules([]);
13
+ setTotal(0);
14
+ setNextPageToken(null);
15
+ setError(null);
16
+ setIsLoading(false);
17
+ return [];
18
+ }
19
+ setIsLoading(true);
20
+ setError(null);
21
+ try {
22
+ const scopedClient = resolvePodClient(client, podId);
23
+ const response = await scopedClient.schedules.list({
24
+ scheduleType,
25
+ isActive,
26
+ agentName,
27
+ workflowName,
28
+ limit: overrides.limit ?? limit,
29
+ pageToken: overrides.pageToken ?? pageToken,
30
+ });
31
+ if (signal?.aborted)
32
+ return [];
33
+ const nextSchedules = response.items ?? [];
34
+ setSchedules(nextSchedules);
35
+ setTotal(response.total ?? nextSchedules.length);
36
+ setNextPageToken(response.next_page_token ?? null);
37
+ return nextSchedules;
38
+ }
39
+ catch (refreshError) {
40
+ if (signal?.aborted)
41
+ return [];
42
+ const normalized = normalizeError(refreshError, "Failed to load schedules.");
43
+ setError(normalized);
44
+ return [];
45
+ }
46
+ finally {
47
+ if (!signal?.aborted)
48
+ setIsLoading(false);
49
+ }
50
+ }, [agentName, client, enabled, isActive, limit, pageToken, podId, scheduleType, workflowName]);
51
+ const loadMore = useCallback(async (overrides = {}) => {
52
+ if (!enabled || !nextPageToken || isLoading || isLoadingMore) {
53
+ return [];
54
+ }
55
+ setIsLoadingMore(true);
56
+ setError(null);
57
+ try {
58
+ const scopedClient = resolvePodClient(client, podId);
59
+ const response = await scopedClient.schedules.list({
60
+ scheduleType,
61
+ isActive,
62
+ agentName,
63
+ workflowName,
64
+ limit: overrides.limit ?? limit,
65
+ pageToken: nextPageToken,
66
+ });
67
+ const moreSchedules = response.items ?? [];
68
+ setSchedules((previous) => [...previous, ...moreSchedules]);
69
+ setTotal(response.total ?? schedules.length + moreSchedules.length);
70
+ setNextPageToken(response.next_page_token ?? null);
71
+ return moreSchedules;
72
+ }
73
+ catch (loadError) {
74
+ const normalized = normalizeError(loadError, "Failed to load more schedules.");
75
+ setError(normalized);
76
+ return [];
77
+ }
78
+ finally {
79
+ setIsLoadingMore(false);
80
+ }
81
+ }, [
82
+ agentName,
83
+ client,
84
+ enabled,
85
+ isActive,
86
+ isLoading,
87
+ isLoadingMore,
88
+ limit,
89
+ nextPageToken,
90
+ podId,
91
+ scheduleType,
92
+ schedules.length,
93
+ workflowName,
94
+ ]);
95
+ useEffect(() => {
96
+ if (!enabled) {
97
+ setSchedules([]);
98
+ setTotal(0);
99
+ setNextPageToken(null);
100
+ setError(null);
101
+ setIsLoading(false);
102
+ setIsLoadingMore(false);
103
+ return;
104
+ }
105
+ if (!autoLoad)
106
+ return;
107
+ const controller = new AbortController();
108
+ void refresh({}, controller.signal);
109
+ return () => {
110
+ controller.abort();
111
+ };
112
+ }, [autoLoad, enabled, refresh]);
113
+ return useMemo(() => ({
114
+ schedules,
115
+ total,
116
+ nextPageToken,
117
+ isLoading,
118
+ isLoadingMore,
119
+ error,
120
+ refresh,
121
+ loadMore,
122
+ }), [error, isLoading, isLoadingMore, loadMore, nextPageToken, refresh, schedules, total]);
123
+ }
@@ -0,0 +1,20 @@
1
+ import type { LemmaClient } from "../client.js";
2
+ import type { Schedule, UpdateScheduleRequest } from "../types.js";
3
+ export interface UseUpdateScheduleOptions {
4
+ client: LemmaClient;
5
+ podId?: string;
6
+ scheduleId?: string | null;
7
+ enabled?: boolean;
8
+ onSuccess?: (schedule: Schedule) => void;
9
+ onError?: (error: unknown) => void;
10
+ }
11
+ export interface UseUpdateScheduleResult {
12
+ schedule: Schedule | null;
13
+ isSubmitting: boolean;
14
+ error: Error | null;
15
+ update: (payload: UpdateScheduleRequest, overrides?: {
16
+ scheduleId?: string | null;
17
+ }) => Promise<Schedule | null>;
18
+ reset: () => void;
19
+ }
20
+ export declare function useUpdateSchedule({ client, podId, scheduleId, enabled, onSuccess, onError, }: UseUpdateScheduleOptions): UseUpdateScheduleResult;
@@ -0,0 +1,49 @@
1
+ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
2
+ import { normalizeError, resolvePodClient } from "./utils.js";
3
+ export function useUpdateSchedule({ client, podId, scheduleId = null, enabled = true, onSuccess, onError, }) {
4
+ const [schedule, setSchedule] = useState(null);
5
+ const [isSubmitting, setIsSubmitting] = useState(false);
6
+ const [error, setError] = useState(null);
7
+ const onSuccessRef = useRef(onSuccess);
8
+ const onErrorRef = useRef(onError);
9
+ useEffect(() => { onSuccessRef.current = onSuccess; }, [onSuccess]);
10
+ useEffect(() => { onErrorRef.current = onError; }, [onError]);
11
+ const trimmedScheduleId = typeof scheduleId === "string" ? scheduleId.trim() : "";
12
+ const update = useCallback(async (payload, overrides = {}) => {
13
+ const nextScheduleId = typeof overrides.scheduleId === "string"
14
+ ? overrides.scheduleId.trim()
15
+ : trimmedScheduleId;
16
+ if (!enabled || nextScheduleId.length === 0)
17
+ return null;
18
+ setIsSubmitting(true);
19
+ setError(null);
20
+ try {
21
+ const scopedClient = resolvePodClient(client, podId);
22
+ const nextSchedule = await scopedClient.schedules.update(nextScheduleId, payload);
23
+ setSchedule(nextSchedule);
24
+ onSuccessRef.current?.(nextSchedule);
25
+ return nextSchedule;
26
+ }
27
+ catch (mutationError) {
28
+ const normalized = normalizeError(mutationError, "Failed to update schedule.");
29
+ setError(normalized);
30
+ onErrorRef.current?.(mutationError);
31
+ return null;
32
+ }
33
+ finally {
34
+ setIsSubmitting(false);
35
+ }
36
+ }, [client, enabled, podId, trimmedScheduleId]);
37
+ const reset = useCallback(() => {
38
+ setSchedule(null);
39
+ setError(null);
40
+ setIsSubmitting(false);
41
+ }, []);
42
+ return useMemo(() => ({
43
+ schedule,
44
+ isSubmitting,
45
+ error,
46
+ update,
47
+ reset,
48
+ }), [error, isSubmitting, reset, schedule, update]);
49
+ }