@mantir/headless-view 0.1.10 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -8
- package/dist/index.d.mts +8 -5
- package/dist/index.d.ts +8 -5
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +6 -6
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,14 +76,14 @@ function CustomExecutor({ workflow }) {
|
|
|
76
76
|
|
|
77
77
|
## Props / Hook Options
|
|
78
78
|
|
|
79
|
-
-
|
|
80
|
-
-
|
|
81
|
-
-
|
|
82
|
-
-
|
|
83
|
-
-
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
-
|
|
79
|
+
- **apiEndpoint**: `(string)` The URL to post workflow execution requests to.
|
|
80
|
+
- **workflow**: `(Workflow, optional)` The JSON workflow definition. When provided with `initialInput`, enables auto-start.
|
|
81
|
+
- **initialInput**: `(string, optional)` If provided, the workflow will automatically start on mount using this value.
|
|
82
|
+
- **onResult**: `(callback, optional)` Called when the workflow produces a final JSON result.
|
|
83
|
+
- **onDone**: `(callback, optional)` Called when the execution stream finishes completely.
|
|
84
|
+
- **onMessage**: `(callback, optional)` Called for every message/trace event.
|
|
85
|
+
- **onInterrupt**: `(callback, optional)` Called when the workflow requires user input.
|
|
86
|
+
- **onError**: `(callback, optional)` Called if a network or execution error occurs.
|
|
87
87
|
|
|
88
88
|
## Configuration for Tailwind CSS Projects
|
|
89
89
|
|
|
@@ -111,3 +111,30 @@ module.exports = {
|
|
|
111
111
|
|
|
112
112
|
- `react` >= 18
|
|
113
113
|
- `react-dom` >= 18
|
|
114
|
+
|
|
115
|
+
## API Reference
|
|
116
|
+
|
|
117
|
+
### `useWorkflowExecution` Hook
|
|
118
|
+
|
|
119
|
+
Returns an object with:
|
|
120
|
+
|
|
121
|
+
- **messages**: `Message[]` - Array of all messages from the workflow execution
|
|
122
|
+
- **isRunning**: `boolean` - Whether the workflow is currently executing
|
|
123
|
+
- **error**: `Error | null` - Any error that occurred during execution
|
|
124
|
+
- **pendingInterrupt**: `any | null` - Details of any pending user input request
|
|
125
|
+
- **currentThreadId**: `string | undefined` - The current execution thread ID
|
|
126
|
+
- **execute**: `(workflow: Workflow, input: string) => Promise<void>` - Programmatically start a workflow
|
|
127
|
+
- **restart**: `(workflow: Workflow, input: string) => Promise<void>` - Restart the workflow from the beginning
|
|
128
|
+
- **resume**: `(workflow: Workflow, value: any) => Promise<void>` - Resume after an interrupt
|
|
129
|
+
- **runExecution**: Internal execution function (advanced use only)
|
|
130
|
+
|
|
131
|
+
### Message Type
|
|
132
|
+
|
|
133
|
+
```typescript
|
|
134
|
+
interface Message {
|
|
135
|
+
id: string;
|
|
136
|
+
role: "user" | "assistant" | "system" | "trace";
|
|
137
|
+
content: string;
|
|
138
|
+
meta?: any;
|
|
139
|
+
}
|
|
140
|
+
```
|
package/dist/index.d.mts
CHANGED
|
@@ -153,9 +153,12 @@ interface HeadlessExecutorProps {
|
|
|
153
153
|
workflow: Workflow;
|
|
154
154
|
apiEndpoint?: string;
|
|
155
155
|
className?: string;
|
|
156
|
+
initialInput?: string;
|
|
156
157
|
onResult?: (result: any) => void;
|
|
157
158
|
onDone?: () => void;
|
|
158
|
-
|
|
159
|
+
onMessage?: (message: any) => void;
|
|
160
|
+
onInterrupt?: (interrupt: any) => void;
|
|
161
|
+
onError?: (error: Error) => void;
|
|
159
162
|
}
|
|
160
163
|
declare const HeadlessExecutor: React.FC<HeadlessExecutorProps>;
|
|
161
164
|
|
|
@@ -184,23 +187,23 @@ interface Message {
|
|
|
184
187
|
}
|
|
185
188
|
interface UseWorkflowExecutionOptions {
|
|
186
189
|
apiEndpoint: string;
|
|
190
|
+
workflow?: Workflow;
|
|
191
|
+
initialInput?: string;
|
|
187
192
|
onMessage?: (message: Message) => void;
|
|
188
193
|
onInterrupt?: (payload: any) => void;
|
|
189
194
|
onError?: (error: Error) => void;
|
|
190
195
|
onDone?: () => void;
|
|
191
196
|
onResult?: (result: any) => void;
|
|
192
|
-
initialInput?: string;
|
|
193
|
-
workflow?: Workflow;
|
|
194
197
|
}
|
|
195
|
-
declare function useWorkflowExecution({ apiEndpoint, onMessage, onInterrupt, onError, onDone, onResult
|
|
198
|
+
declare function useWorkflowExecution({ apiEndpoint, workflow, initialInput, onMessage, onInterrupt, onError, onDone, onResult }: UseWorkflowExecutionOptions): {
|
|
196
199
|
messages: Message[];
|
|
197
200
|
isRunning: boolean;
|
|
198
201
|
error: Error | null;
|
|
199
202
|
currentThreadId: string | undefined;
|
|
200
203
|
pendingInterrupt: any;
|
|
204
|
+
execute: (workflow: Workflow, userInput: string) => Promise<void>;
|
|
201
205
|
runExecution: (workflow: Workflow, userInput: string, existingThreadId?: string, resumeValue?: any) => Promise<void>;
|
|
202
206
|
restart: (workflow: Workflow, userInput: string) => Promise<void>;
|
|
203
|
-
execute: (workflow: Workflow, userInput: string) => Promise<void>;
|
|
204
207
|
resume: (workflow: Workflow, resumeValue: any) => Promise<void>;
|
|
205
208
|
};
|
|
206
209
|
|
package/dist/index.d.ts
CHANGED
|
@@ -153,9 +153,12 @@ interface HeadlessExecutorProps {
|
|
|
153
153
|
workflow: Workflow;
|
|
154
154
|
apiEndpoint?: string;
|
|
155
155
|
className?: string;
|
|
156
|
+
initialInput?: string;
|
|
156
157
|
onResult?: (result: any) => void;
|
|
157
158
|
onDone?: () => void;
|
|
158
|
-
|
|
159
|
+
onMessage?: (message: any) => void;
|
|
160
|
+
onInterrupt?: (interrupt: any) => void;
|
|
161
|
+
onError?: (error: Error) => void;
|
|
159
162
|
}
|
|
160
163
|
declare const HeadlessExecutor: React.FC<HeadlessExecutorProps>;
|
|
161
164
|
|
|
@@ -184,23 +187,23 @@ interface Message {
|
|
|
184
187
|
}
|
|
185
188
|
interface UseWorkflowExecutionOptions {
|
|
186
189
|
apiEndpoint: string;
|
|
190
|
+
workflow?: Workflow;
|
|
191
|
+
initialInput?: string;
|
|
187
192
|
onMessage?: (message: Message) => void;
|
|
188
193
|
onInterrupt?: (payload: any) => void;
|
|
189
194
|
onError?: (error: Error) => void;
|
|
190
195
|
onDone?: () => void;
|
|
191
196
|
onResult?: (result: any) => void;
|
|
192
|
-
initialInput?: string;
|
|
193
|
-
workflow?: Workflow;
|
|
194
197
|
}
|
|
195
|
-
declare function useWorkflowExecution({ apiEndpoint, onMessage, onInterrupt, onError, onDone, onResult
|
|
198
|
+
declare function useWorkflowExecution({ apiEndpoint, workflow, initialInput, onMessage, onInterrupt, onError, onDone, onResult }: UseWorkflowExecutionOptions): {
|
|
196
199
|
messages: Message[];
|
|
197
200
|
isRunning: boolean;
|
|
198
201
|
error: Error | null;
|
|
199
202
|
currentThreadId: string | undefined;
|
|
200
203
|
pendingInterrupt: any;
|
|
204
|
+
execute: (workflow: Workflow, userInput: string) => Promise<void>;
|
|
201
205
|
runExecution: (workflow: Workflow, userInput: string, existingThreadId?: string, resumeValue?: any) => Promise<void>;
|
|
202
206
|
restart: (workflow: Workflow, userInput: string) => Promise<void>;
|
|
203
|
-
execute: (workflow: Workflow, userInput: string) => Promise<void>;
|
|
204
207
|
resume: (workflow: Workflow, resumeValue: any) => Promise<void>;
|
|
205
208
|
};
|
|
206
209
|
|