@elqnt/workflow 2.1.3 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/README.md +6 -0
  2. package/SKILL.md +442 -0
  3. package/dist/api/index.d.mts +1 -1
  4. package/dist/api/index.d.ts +1 -1
  5. package/dist/api/index.js +3 -4
  6. package/dist/api/index.js.map +1 -1
  7. package/dist/api/index.mjs +1 -2
  8. package/dist/chunk-3GG6KTGJ.js +998 -0
  9. package/dist/chunk-3GG6KTGJ.js.map +1 -0
  10. package/dist/{chunk-UE4ZBFLG.mjs → chunk-4AUWFGQK.mjs} +1 -3
  11. package/dist/{chunk-UE4ZBFLG.mjs.map → chunk-4AUWFGQK.mjs.map} +1 -1
  12. package/dist/{chunk-H24IF5AA.js → chunk-6DV2LPSN.js} +2 -4
  13. package/dist/chunk-6DV2LPSN.js.map +1 -0
  14. package/dist/chunk-AXXQSYT7.mjs +998 -0
  15. package/dist/chunk-AXXQSYT7.mjs.map +1 -0
  16. package/dist/{chunk-YCEGKVXP.mjs → chunk-IY5JCMLA.mjs} +1 -3
  17. package/dist/{chunk-YCEGKVXP.mjs.map → chunk-IY5JCMLA.mjs.map} +1 -1
  18. package/dist/{chunk-JES2EBNO.js → chunk-YCO5IFZK.js} +2 -4
  19. package/dist/chunk-YCO5IFZK.js.map +1 -0
  20. package/dist/components/index.d.mts +245 -0
  21. package/dist/components/index.d.ts +245 -0
  22. package/dist/components/index.js +10 -0
  23. package/dist/components/index.js.map +1 -0
  24. package/dist/components/index.mjs +10 -0
  25. package/dist/components/index.mjs.map +1 -0
  26. package/dist/hooks/index.d.mts +106 -17
  27. package/dist/hooks/index.d.ts +106 -17
  28. package/dist/hooks/index.js +403 -5
  29. package/dist/hooks/index.js.map +1 -1
  30. package/dist/hooks/index.mjs +404 -6
  31. package/dist/hooks/index.mjs.map +1 -1
  32. package/dist/index.d.mts +6 -247
  33. package/dist/index.d.ts +6 -247
  34. package/dist/index.js +8 -1006
  35. package/dist/index.js.map +1 -1
  36. package/dist/index.mjs +5 -1003
  37. package/dist/index.mjs.map +1 -1
  38. package/dist/models/index.d.mts +1 -1
  39. package/dist/models/index.d.ts +1 -1
  40. package/dist/models/index.js +3 -4
  41. package/dist/models/index.js.map +1 -1
  42. package/dist/models/index.mjs +1 -2
  43. package/dist/{workflow-NznrS9yA.d.ts → workflow-DcJCCEND.d.mts} +1 -1
  44. package/dist/{workflow-NznrS9yA.d.mts → workflow-DcJCCEND.d.ts} +1 -1
  45. package/package.json +12 -6
  46. package/dist/chunk-F5G2ALFS.js +0 -391
  47. package/dist/chunk-F5G2ALFS.js.map +0 -1
  48. package/dist/chunk-H24IF5AA.js.map +0 -1
  49. package/dist/chunk-JES2EBNO.js.map +0 -1
  50. package/dist/chunk-TZA3EPTC.mjs +0 -391
  51. package/dist/chunk-TZA3EPTC.mjs.map +0 -1
@@ -0,0 +1,245 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
2
+ import { JSONSchema } from '@elqnt/types';
3
+
4
+ interface DynamicSchemaFormUIComponents {
5
+ Input: React.ComponentType<{
6
+ type?: string;
7
+ value: any;
8
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
9
+ disabled?: boolean;
10
+ className?: string;
11
+ placeholder?: string;
12
+ min?: number;
13
+ max?: number;
14
+ step?: string | number;
15
+ }>;
16
+ Label: React.ComponentType<{
17
+ htmlFor?: string;
18
+ className?: string;
19
+ children: React.ReactNode;
20
+ }>;
21
+ Textarea: React.ComponentType<{
22
+ value: any;
23
+ onChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;
24
+ disabled?: boolean;
25
+ rows?: number;
26
+ className?: string;
27
+ placeholder?: string;
28
+ }>;
29
+ Checkbox: React.ComponentType<{
30
+ id?: string;
31
+ checked: boolean;
32
+ onCheckedChange: (checked: boolean) => void;
33
+ disabled?: boolean;
34
+ }>;
35
+ Select: React.ComponentType<{
36
+ value: string;
37
+ onValueChange: (value: string) => void;
38
+ disabled?: boolean;
39
+ children: React.ReactNode;
40
+ }>;
41
+ SelectTrigger: React.ComponentType<{
42
+ className?: string;
43
+ children: React.ReactNode;
44
+ }>;
45
+ SelectValue: React.ComponentType<{
46
+ placeholder?: string;
47
+ }>;
48
+ SelectContent: React.ComponentType<{
49
+ children: React.ReactNode;
50
+ }>;
51
+ SelectItem: React.ComponentType<{
52
+ value: string;
53
+ className?: string;
54
+ children: React.ReactNode;
55
+ }>;
56
+ Button: React.ComponentType<{
57
+ type?: "button" | "submit" | "reset";
58
+ variant?: string;
59
+ size?: string;
60
+ className?: string;
61
+ onClick?: () => void;
62
+ disabled?: boolean;
63
+ children: React.ReactNode;
64
+ }>;
65
+ Card: React.ComponentType<{
66
+ className?: string;
67
+ children: React.ReactNode;
68
+ }>;
69
+ PlusIcon: React.ComponentType<{
70
+ className?: string;
71
+ }>;
72
+ TrashIcon: React.ComponentType<{
73
+ className?: string;
74
+ }>;
75
+ ChevronDownIcon: React.ComponentType<{
76
+ className?: string;
77
+ }>;
78
+ ChevronRightIcon: React.ComponentType<{
79
+ className?: string;
80
+ }>;
81
+ VariableIcon?: React.ComponentType<{
82
+ className?: string;
83
+ }>;
84
+ CheckIcon?: React.ComponentType<{
85
+ className?: string;
86
+ }>;
87
+ EditIcon?: React.ComponentType<{
88
+ className?: string;
89
+ }>;
90
+ Popover?: React.ComponentType<{
91
+ open?: boolean;
92
+ onOpenChange?: (open: boolean) => void;
93
+ children: React.ReactNode;
94
+ }>;
95
+ PopoverTrigger?: React.ComponentType<{
96
+ asChild?: boolean;
97
+ children: React.ReactNode;
98
+ }>;
99
+ PopoverContent?: React.ComponentType<{
100
+ className?: string;
101
+ align?: "start" | "center" | "end";
102
+ children: React.ReactNode;
103
+ }>;
104
+ Dialog?: React.ComponentType<{
105
+ open?: boolean;
106
+ onOpenChange?: (open: boolean) => void;
107
+ children: React.ReactNode;
108
+ }>;
109
+ DialogContent?: React.ComponentType<{
110
+ className?: string;
111
+ children: React.ReactNode;
112
+ }>;
113
+ DialogHeader?: React.ComponentType<{
114
+ className?: string;
115
+ children: React.ReactNode;
116
+ }>;
117
+ DialogTitle?: React.ComponentType<{
118
+ className?: string;
119
+ children: React.ReactNode;
120
+ }>;
121
+ DialogFooter?: React.ComponentType<{
122
+ className?: string;
123
+ children: React.ReactNode;
124
+ }>;
125
+ ScrollArea?: React.ComponentType<{
126
+ className?: string;
127
+ children: React.ReactNode;
128
+ }>;
129
+ MarkdownEditor?: React.ComponentType<{
130
+ content: string;
131
+ onChange: (markdown: string) => void;
132
+ placeholder?: string;
133
+ className?: string;
134
+ readOnly?: boolean;
135
+ minHeight?: string;
136
+ variables?: Array<{
137
+ name: string;
138
+ path: string;
139
+ title?: string;
140
+ }>;
141
+ }>;
142
+ cn: (...classes: (string | undefined | null | false)[]) => string;
143
+ }
144
+ /**
145
+ * Variable definition for workflow variables
146
+ */
147
+ interface WorkflowVariable {
148
+ name: string;
149
+ type: string;
150
+ title?: string;
151
+ path: string;
152
+ }
153
+ interface DynamicSchemaFormProps {
154
+ schema: JSONSchema;
155
+ value: any;
156
+ onChange: (value: any) => void;
157
+ disabled?: boolean;
158
+ path?: string[];
159
+ components: DynamicSchemaFormUIComponents;
160
+ /** Workflow variables available for selection */
161
+ variables?: WorkflowVariable[];
162
+ /** Whether to show variable picker buttons */
163
+ showVariablePicker?: boolean;
164
+ }
165
+ declare function DynamicSchemaForm({ schema, value, onChange, disabled, path, components, variables, showVariablePicker, }: DynamicSchemaFormProps): react_jsx_runtime.JSX.Element;
166
+
167
+ interface SchemaBuilderUIComponents {
168
+ Input: React.ComponentType<{
169
+ value: any;
170
+ onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
171
+ disabled?: boolean;
172
+ className?: string;
173
+ placeholder?: string;
174
+ }>;
175
+ Label: React.ComponentType<{
176
+ htmlFor?: string;
177
+ className?: string;
178
+ children: React.ReactNode;
179
+ }>;
180
+ Checkbox: React.ComponentType<{
181
+ id?: string;
182
+ checked: boolean;
183
+ onCheckedChange: (checked: boolean) => void;
184
+ disabled?: boolean;
185
+ }>;
186
+ Select: React.ComponentType<{
187
+ value: string;
188
+ onValueChange: (value: string) => void;
189
+ disabled?: boolean;
190
+ children: React.ReactNode;
191
+ }>;
192
+ SelectTrigger: React.ComponentType<{
193
+ className?: string;
194
+ children: React.ReactNode;
195
+ }>;
196
+ SelectValue: React.ComponentType<{
197
+ placeholder?: string;
198
+ }>;
199
+ SelectContent: React.ComponentType<{
200
+ children: React.ReactNode;
201
+ }>;
202
+ SelectItem: React.ComponentType<{
203
+ value: string;
204
+ className?: string;
205
+ children: React.ReactNode;
206
+ }>;
207
+ Button: React.ComponentType<{
208
+ type?: "button" | "submit" | "reset";
209
+ variant?: string;
210
+ size?: string;
211
+ className?: string;
212
+ onClick?: () => void;
213
+ disabled?: boolean;
214
+ children: React.ReactNode;
215
+ }>;
216
+ Card: React.ComponentType<{
217
+ className?: string;
218
+ children: React.ReactNode;
219
+ }>;
220
+ PlusIcon: React.ComponentType<{
221
+ className?: string;
222
+ }>;
223
+ TrashIcon: React.ComponentType<{
224
+ className?: string;
225
+ }>;
226
+ GripVerticalIcon: React.ComponentType<{
227
+ className?: string;
228
+ }>;
229
+ ChevronDownIcon: React.ComponentType<{
230
+ className?: string;
231
+ }>;
232
+ ChevronRightIcon: React.ComponentType<{
233
+ className?: string;
234
+ }>;
235
+ cn: (...classes: (string | undefined | null | false)[]) => string;
236
+ }
237
+ interface SchemaBuilderProps {
238
+ schema: JSONSchema;
239
+ onChange: (schema: JSONSchema) => void;
240
+ disabled?: boolean;
241
+ components: SchemaBuilderUIComponents;
242
+ }
243
+ declare function SchemaBuilder({ schema, onChange, disabled, components, }: SchemaBuilderProps): react_jsx_runtime.JSX.Element;
244
+
245
+ export { DynamicSchemaForm, type DynamicSchemaFormProps, type DynamicSchemaFormUIComponents, SchemaBuilder, type SchemaBuilderProps, type SchemaBuilderUIComponents, type WorkflowVariable };
@@ -0,0 +1,10 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
2
+
3
+
4
+
5
+ var _chunk3GG6KTGJjs = require('../chunk-3GG6KTGJ.js');
6
+
7
+
8
+
9
+ exports.DynamicSchemaForm = _chunk3GG6KTGJjs.DynamicSchemaForm; exports.SchemaBuilder = _chunk3GG6KTGJjs.SchemaBuilder;
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/home/runner/work/eloquent/eloquent/packages/@elqnt/workflow/dist/components/index.js"],"names":[],"mappings":"AAAA,qFAAY;AACZ;AACE;AACA;AACF,uDAA6B;AAC7B;AACE;AACA;AACF,uHAAC","file":"/home/runner/work/eloquent/eloquent/packages/@elqnt/workflow/dist/components/index.js"}
@@ -0,0 +1,10 @@
1
+ "use client";
2
+ import {
3
+ DynamicSchemaForm,
4
+ SchemaBuilder
5
+ } from "../chunk-AXXQSYT7.mjs";
6
+ export {
7
+ DynamicSchemaForm,
8
+ SchemaBuilder
9
+ };
10
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1,9 +1,33 @@
1
1
  import { ApiClientOptions } from '@elqnt/api-client';
2
- import { W as WorkflowInstance, a as WorkflowDefinition } from '../workflow-NznrS9yA.mjs';
2
+ import { W as WorkflowDefinition, d as WorkflowInstance } from '../workflow-DcJCCEND.mjs';
3
3
  import { WorkflowTemplate } from '../api/index.mjs';
4
+ export { UseAsyncOptions, UseAsyncReturn, useApiAsync, useAsync } from '@elqnt/api-client/hooks';
4
5
  import '@elqnt/types';
5
6
 
6
7
  type UseWorkflowsOptions = ApiClientOptions;
8
+ /**
9
+ * The exact, stable return surface of `useWorkflows`.
10
+ *
11
+ * This is the agent/consumer **contract**: the only methods that exist on the
12
+ * workflow-definitions hook. Every method is imperative and DOES NOT throw — on
13
+ * failure it resolves to the documented default and sets `error`. See `SKILL.md`.
14
+ */
15
+ interface UseWorkflowsReturn {
16
+ /** True while any method is in flight. */
17
+ loading: boolean;
18
+ /** Latest method error, else null. */
19
+ error: string | null;
20
+ /** GET /api/v1/workflows — default `[]` on error. */
21
+ listWorkflows: () => Promise<WorkflowDefinition[]>;
22
+ /** GET /api/v1/workflows/{id} — default `null`. */
23
+ getWorkflow: (workflowId: string) => Promise<WorkflowDefinition | null>;
24
+ /** POST /api/v1/workflows — created definition, or `null` on error. */
25
+ createWorkflow: (workflow: Partial<WorkflowDefinition>) => Promise<WorkflowDefinition | null>;
26
+ /** PUT /api/v1/workflows/{id} — updated definition, or `null` on error. */
27
+ updateWorkflow: (workflowId: string, workflow: Partial<WorkflowDefinition>) => Promise<WorkflowDefinition | null>;
28
+ /** DELETE /api/v1/workflows/{id} — `true`/`false`. */
29
+ deleteWorkflow: (workflowId: string) => Promise<boolean>;
30
+ }
7
31
  /**
8
32
  * Hook for workflow definition CRUD operations
9
33
  *
@@ -17,47 +41,112 @@ type UseWorkflowsOptions = ApiClientOptions;
17
41
  * const workflows = await listWorkflows();
18
42
  * ```
19
43
  */
20
- declare function useWorkflows(options: UseWorkflowsOptions): {
21
- loading: boolean;
22
- error: string | null;
23
- listWorkflows: () => Promise<WorkflowDefinition[]>;
24
- getWorkflow: (workflowId: string) => Promise<WorkflowDefinition | null>;
25
- createWorkflow: (workflow: Partial<WorkflowDefinition>) => Promise<WorkflowDefinition | null>;
26
- updateWorkflow: (workflowId: string, workflow: Partial<WorkflowDefinition>) => Promise<WorkflowDefinition | null>;
27
- deleteWorkflow: (workflowId: string) => Promise<boolean>;
28
- };
44
+ declare function useWorkflows(options: UseWorkflowsOptions): UseWorkflowsReturn;
45
+
46
+ type UseWorkflowInstancesOptions = ApiClientOptions;
29
47
  /**
30
- * Hook for workflow instance operations
48
+ * The exact, stable return surface of `useWorkflowInstances`.
49
+ *
50
+ * This is the agent/consumer **contract**: the only methods that exist on the
51
+ * workflow-instances hook. Every method is imperative and DOES NOT throw — on
52
+ * failure it resolves to the documented default and sets `error`. See `SKILL.md`.
31
53
  */
32
- declare function useWorkflowInstances(options: UseWorkflowsOptions): {
54
+ interface UseWorkflowInstancesReturn {
55
+ /** True while any method is in flight. */
33
56
  loading: boolean;
57
+ /** Latest method error, else null. */
34
58
  error: string | null;
59
+ /** GET /api/v1/workflows/{definitionId}/instances(?userId=&status=) — default `[]`. */
35
60
  listInstances: (definitionId: string, filters?: {
36
61
  userId?: string;
37
62
  status?: string;
38
63
  }) => Promise<WorkflowInstance[]>;
64
+ /** GET /api/v1/workflows/instances/{id} — default `null`. */
39
65
  getInstance: (instanceId: string) => Promise<WorkflowInstance | null>;
66
+ /** POST /api/v1/workflows/{definitionId}/instances — new instance, or `null`. */
40
67
  createInstance: (definitionId: string, data?: {
41
68
  variables?: Record<string, unknown>;
42
69
  autoExecute?: boolean;
43
70
  }) => Promise<WorkflowInstance | null>;
71
+ /** PUT /api/v1/workflows/instances/{id}/status — updated instance, or `null`. */
44
72
  updateStatus: (instanceId: string, status: string) => Promise<WorkflowInstance | null>;
73
+ /** POST .../instances/{id}/nodes/{nodeId}/execute — node output, or `null`. */
45
74
  executeNode: (instanceId: string, nodeId: string, input: Record<string, unknown>) => Promise<Record<string, unknown> | null>;
75
+ /** POST .../instances/{id}/nodes/{nodeId}/resume — updated instance, or `null`. */
46
76
  resumeNode: (instanceId: string, nodeId: string, result: Record<string, unknown>) => Promise<WorkflowInstance | null>;
77
+ /** POST .../instances/{id}/nodes/{nodeId}/retry — updated instance, or `null`. */
47
78
  retryNode: (instanceId: string, nodeId: string) => Promise<WorkflowInstance | null>;
48
- };
79
+ }
49
80
  /**
50
- * Hook for workflow template operations
81
+ * Hook for workflow instance operations
82
+ *
83
+ * @example
84
+ * ```tsx
85
+ * const { listInstances, getInstance, createInstance } = useWorkflowInstances({
86
+ * baseUrl: apiGatewayUrl,
87
+ * orgId: selectedOrgId,
88
+ * });
89
+ *
90
+ * const instances = await listInstances(definitionId);
91
+ * ```
92
+ */
93
+ declare function useWorkflowInstances(options: UseWorkflowInstancesOptions): UseWorkflowInstancesReturn;
94
+
95
+ type UseWorkflowTemplatesOptions = ApiClientOptions;
96
+ /**
97
+ * The exact, stable return surface of `useWorkflowTemplates`.
98
+ *
99
+ * This is the agent/consumer **contract**: the only methods that exist on the
100
+ * workflow-templates hook. Every method is imperative and DOES NOT throw — on
101
+ * failure it resolves to the documented default and sets `error`. See `SKILL.md`.
51
102
  */
52
- declare function useWorkflowTemplates(options: UseWorkflowsOptions): {
103
+ interface UseWorkflowTemplatesReturn {
104
+ /** True while any method is in flight. */
53
105
  loading: boolean;
106
+ /** Latest method error, else null. */
54
107
  error: string | null;
108
+ /** GET /api/v1/workflows/templates(?category=) — default `[]` on error. */
55
109
  listTemplates: (category?: string) => Promise<WorkflowTemplate[]>;
110
+ /** GET /api/v1/workflows/templates/{id} — default `null`. */
56
111
  getTemplate: (templateId: string) => Promise<WorkflowTemplate | null>;
112
+ /** POST /api/v1/workflows/templates/{id}/instantiate — new definition, or `null`. */
57
113
  instantiateTemplate: (templateId: string, params: {
58
114
  variables: Record<string, unknown>;
59
115
  title?: string;
60
116
  }) => Promise<WorkflowDefinition | null>;
61
- };
117
+ }
118
+ /**
119
+ * Hook for workflow template operations
120
+ *
121
+ * @example
122
+ * ```tsx
123
+ * const { listTemplates, getTemplate, instantiateTemplate } = useWorkflowTemplates({
124
+ * baseUrl: apiGatewayUrl,
125
+ * orgId: selectedOrgId,
126
+ * });
127
+ *
128
+ * const templates = await listTemplates();
129
+ * ```
130
+ */
131
+ declare function useWorkflowTemplates(options: UseWorkflowTemplatesOptions): UseWorkflowTemplatesReturn;
132
+
133
+ /**
134
+ * Keep a mutable ref synchronized with the latest value
135
+ *
136
+ * @example
137
+ * ```tsx
138
+ * function useWorkflows(options: ApiClientOptions) {
139
+ * const optionsRef = useOptionsRef(options);
140
+ *
141
+ * const listWorkflows = useCallback(async () => {
142
+ * // Always uses latest options
143
+ * return listWorkflowsApi(optionsRef.current);
144
+ * }, []); // No dependency on options - callback never changes
145
+ *
146
+ * return { listWorkflows };
147
+ * }
148
+ * ```
149
+ */
150
+ declare function useOptionsRef<T>(options: T): React.MutableRefObject<T>;
62
151
 
63
- export { type UseWorkflowsOptions, useWorkflowInstances, useWorkflowTemplates, useWorkflows };
152
+ export { type UseWorkflowInstancesOptions, type UseWorkflowInstancesReturn, type UseWorkflowTemplatesOptions, type UseWorkflowTemplatesReturn, type UseWorkflowsOptions, type UseWorkflowsReturn, useOptionsRef, useWorkflowInstances, useWorkflowTemplates, useWorkflows };
@@ -1,9 +1,33 @@
1
1
  import { ApiClientOptions } from '@elqnt/api-client';
2
- import { W as WorkflowInstance, a as WorkflowDefinition } from '../workflow-NznrS9yA.js';
2
+ import { W as WorkflowDefinition, d as WorkflowInstance } from '../workflow-DcJCCEND.js';
3
3
  import { WorkflowTemplate } from '../api/index.js';
4
+ export { UseAsyncOptions, UseAsyncReturn, useApiAsync, useAsync } from '@elqnt/api-client/hooks';
4
5
  import '@elqnt/types';
5
6
 
6
7
  type UseWorkflowsOptions = ApiClientOptions;
8
+ /**
9
+ * The exact, stable return surface of `useWorkflows`.
10
+ *
11
+ * This is the agent/consumer **contract**: the only methods that exist on the
12
+ * workflow-definitions hook. Every method is imperative and DOES NOT throw — on
13
+ * failure it resolves to the documented default and sets `error`. See `SKILL.md`.
14
+ */
15
+ interface UseWorkflowsReturn {
16
+ /** True while any method is in flight. */
17
+ loading: boolean;
18
+ /** Latest method error, else null. */
19
+ error: string | null;
20
+ /** GET /api/v1/workflows — default `[]` on error. */
21
+ listWorkflows: () => Promise<WorkflowDefinition[]>;
22
+ /** GET /api/v1/workflows/{id} — default `null`. */
23
+ getWorkflow: (workflowId: string) => Promise<WorkflowDefinition | null>;
24
+ /** POST /api/v1/workflows — created definition, or `null` on error. */
25
+ createWorkflow: (workflow: Partial<WorkflowDefinition>) => Promise<WorkflowDefinition | null>;
26
+ /** PUT /api/v1/workflows/{id} — updated definition, or `null` on error. */
27
+ updateWorkflow: (workflowId: string, workflow: Partial<WorkflowDefinition>) => Promise<WorkflowDefinition | null>;
28
+ /** DELETE /api/v1/workflows/{id} — `true`/`false`. */
29
+ deleteWorkflow: (workflowId: string) => Promise<boolean>;
30
+ }
7
31
  /**
8
32
  * Hook for workflow definition CRUD operations
9
33
  *
@@ -17,47 +41,112 @@ type UseWorkflowsOptions = ApiClientOptions;
17
41
  * const workflows = await listWorkflows();
18
42
  * ```
19
43
  */
20
- declare function useWorkflows(options: UseWorkflowsOptions): {
21
- loading: boolean;
22
- error: string | null;
23
- listWorkflows: () => Promise<WorkflowDefinition[]>;
24
- getWorkflow: (workflowId: string) => Promise<WorkflowDefinition | null>;
25
- createWorkflow: (workflow: Partial<WorkflowDefinition>) => Promise<WorkflowDefinition | null>;
26
- updateWorkflow: (workflowId: string, workflow: Partial<WorkflowDefinition>) => Promise<WorkflowDefinition | null>;
27
- deleteWorkflow: (workflowId: string) => Promise<boolean>;
28
- };
44
+ declare function useWorkflows(options: UseWorkflowsOptions): UseWorkflowsReturn;
45
+
46
+ type UseWorkflowInstancesOptions = ApiClientOptions;
29
47
  /**
30
- * Hook for workflow instance operations
48
+ * The exact, stable return surface of `useWorkflowInstances`.
49
+ *
50
+ * This is the agent/consumer **contract**: the only methods that exist on the
51
+ * workflow-instances hook. Every method is imperative and DOES NOT throw — on
52
+ * failure it resolves to the documented default and sets `error`. See `SKILL.md`.
31
53
  */
32
- declare function useWorkflowInstances(options: UseWorkflowsOptions): {
54
+ interface UseWorkflowInstancesReturn {
55
+ /** True while any method is in flight. */
33
56
  loading: boolean;
57
+ /** Latest method error, else null. */
34
58
  error: string | null;
59
+ /** GET /api/v1/workflows/{definitionId}/instances(?userId=&status=) — default `[]`. */
35
60
  listInstances: (definitionId: string, filters?: {
36
61
  userId?: string;
37
62
  status?: string;
38
63
  }) => Promise<WorkflowInstance[]>;
64
+ /** GET /api/v1/workflows/instances/{id} — default `null`. */
39
65
  getInstance: (instanceId: string) => Promise<WorkflowInstance | null>;
66
+ /** POST /api/v1/workflows/{definitionId}/instances — new instance, or `null`. */
40
67
  createInstance: (definitionId: string, data?: {
41
68
  variables?: Record<string, unknown>;
42
69
  autoExecute?: boolean;
43
70
  }) => Promise<WorkflowInstance | null>;
71
+ /** PUT /api/v1/workflows/instances/{id}/status — updated instance, or `null`. */
44
72
  updateStatus: (instanceId: string, status: string) => Promise<WorkflowInstance | null>;
73
+ /** POST .../instances/{id}/nodes/{nodeId}/execute — node output, or `null`. */
45
74
  executeNode: (instanceId: string, nodeId: string, input: Record<string, unknown>) => Promise<Record<string, unknown> | null>;
75
+ /** POST .../instances/{id}/nodes/{nodeId}/resume — updated instance, or `null`. */
46
76
  resumeNode: (instanceId: string, nodeId: string, result: Record<string, unknown>) => Promise<WorkflowInstance | null>;
77
+ /** POST .../instances/{id}/nodes/{nodeId}/retry — updated instance, or `null`. */
47
78
  retryNode: (instanceId: string, nodeId: string) => Promise<WorkflowInstance | null>;
48
- };
79
+ }
49
80
  /**
50
- * Hook for workflow template operations
81
+ * Hook for workflow instance operations
82
+ *
83
+ * @example
84
+ * ```tsx
85
+ * const { listInstances, getInstance, createInstance } = useWorkflowInstances({
86
+ * baseUrl: apiGatewayUrl,
87
+ * orgId: selectedOrgId,
88
+ * });
89
+ *
90
+ * const instances = await listInstances(definitionId);
91
+ * ```
92
+ */
93
+ declare function useWorkflowInstances(options: UseWorkflowInstancesOptions): UseWorkflowInstancesReturn;
94
+
95
+ type UseWorkflowTemplatesOptions = ApiClientOptions;
96
+ /**
97
+ * The exact, stable return surface of `useWorkflowTemplates`.
98
+ *
99
+ * This is the agent/consumer **contract**: the only methods that exist on the
100
+ * workflow-templates hook. Every method is imperative and DOES NOT throw — on
101
+ * failure it resolves to the documented default and sets `error`. See `SKILL.md`.
51
102
  */
52
- declare function useWorkflowTemplates(options: UseWorkflowsOptions): {
103
+ interface UseWorkflowTemplatesReturn {
104
+ /** True while any method is in flight. */
53
105
  loading: boolean;
106
+ /** Latest method error, else null. */
54
107
  error: string | null;
108
+ /** GET /api/v1/workflows/templates(?category=) — default `[]` on error. */
55
109
  listTemplates: (category?: string) => Promise<WorkflowTemplate[]>;
110
+ /** GET /api/v1/workflows/templates/{id} — default `null`. */
56
111
  getTemplate: (templateId: string) => Promise<WorkflowTemplate | null>;
112
+ /** POST /api/v1/workflows/templates/{id}/instantiate — new definition, or `null`. */
57
113
  instantiateTemplate: (templateId: string, params: {
58
114
  variables: Record<string, unknown>;
59
115
  title?: string;
60
116
  }) => Promise<WorkflowDefinition | null>;
61
- };
117
+ }
118
+ /**
119
+ * Hook for workflow template operations
120
+ *
121
+ * @example
122
+ * ```tsx
123
+ * const { listTemplates, getTemplate, instantiateTemplate } = useWorkflowTemplates({
124
+ * baseUrl: apiGatewayUrl,
125
+ * orgId: selectedOrgId,
126
+ * });
127
+ *
128
+ * const templates = await listTemplates();
129
+ * ```
130
+ */
131
+ declare function useWorkflowTemplates(options: UseWorkflowTemplatesOptions): UseWorkflowTemplatesReturn;
132
+
133
+ /**
134
+ * Keep a mutable ref synchronized with the latest value
135
+ *
136
+ * @example
137
+ * ```tsx
138
+ * function useWorkflows(options: ApiClientOptions) {
139
+ * const optionsRef = useOptionsRef(options);
140
+ *
141
+ * const listWorkflows = useCallback(async () => {
142
+ * // Always uses latest options
143
+ * return listWorkflowsApi(optionsRef.current);
144
+ * }, []); // No dependency on options - callback never changes
145
+ *
146
+ * return { listWorkflows };
147
+ * }
148
+ * ```
149
+ */
150
+ declare function useOptionsRef<T>(options: T): React.MutableRefObject<T>;
62
151
 
63
- export { type UseWorkflowsOptions, useWorkflowInstances, useWorkflowTemplates, useWorkflows };
152
+ export { type UseWorkflowInstancesOptions, type UseWorkflowInstancesReturn, type UseWorkflowTemplatesOptions, type UseWorkflowTemplatesReturn, type UseWorkflowsOptions, type UseWorkflowsReturn, useOptionsRef, useWorkflowInstances, useWorkflowTemplates, useWorkflows };