@stateflowx/runtime 0.1.6 → 0.1.7
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 +105 -14
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,38 +8,105 @@ StateFlowX Runtime is a lightweight orchestration runtime for building operation
|
|
|
8
8
|
- Runtime composition
|
|
9
9
|
- Pluggable provider architecture
|
|
10
10
|
- Transport abstraction
|
|
11
|
+
- Dynamic workflow registration
|
|
11
12
|
- Service orchestration foundation
|
|
12
13
|
- Realtime execution flow
|
|
13
14
|
- NestJS-based runtime infrastructure
|
|
14
15
|
|
|
16
|
+
---
|
|
17
|
+
|
|
15
18
|
## Installation
|
|
16
19
|
|
|
17
20
|
```bash
|
|
18
21
|
npm install @stateflowx/runtime
|
|
19
22
|
```
|
|
20
23
|
|
|
21
|
-
|
|
24
|
+
---
|
|
22
25
|
|
|
23
|
-
|
|
24
|
-
import { createRuntime } from '@stateflowx/runtime';
|
|
26
|
+
## Runtime Host Example
|
|
25
27
|
|
|
26
|
-
|
|
27
|
-
providers: [
|
|
28
|
-
gemini({
|
|
29
|
-
priority: 1,
|
|
30
|
-
}),
|
|
31
|
-
],
|
|
32
|
-
});
|
|
28
|
+
Minimal external runtime host example:
|
|
33
29
|
|
|
34
|
-
|
|
30
|
+
:contentReference[oaicite:0]{index=0}
|
|
35
31
|
|
|
36
|
-
|
|
32
|
+
This demonstrates:
|
|
33
|
+
|
|
34
|
+
- external npm package consumption
|
|
35
|
+
- WebSocket runtime hosting
|
|
36
|
+
- JSON-RPC transport
|
|
37
|
+
- dynamic runtime initialization
|
|
38
|
+
- Gemini provider integration
|
|
39
|
+
- remote workflow execution
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Demo Client Application
|
|
37
44
|
|
|
38
45
|
Example Angular client implementation:
|
|
39
46
|
|
|
40
|
-
https://github.com/bws9000/stateflowx-client-demo
|
|
47
|
+
<https://github.com/bws9000/stateflowx-client-demo>
|
|
48
|
+
|
|
49
|
+
## Demo Host Application
|
|
41
50
|
|
|
42
|
-
|
|
51
|
+
<https://github.com/bws9000/stateflowx-runtime-host-example>
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Basic Runtime Host Example
|
|
56
|
+
|
|
57
|
+
```ts
|
|
58
|
+
import 'dotenv/config';
|
|
59
|
+
|
|
60
|
+
import { WebSocketServer } from 'ws';
|
|
61
|
+
|
|
62
|
+
import {
|
|
63
|
+
createRuntime,
|
|
64
|
+
RuntimeInitializeApp,
|
|
65
|
+
GeminiProvider,
|
|
66
|
+
} from '@stateflowx/runtime';
|
|
67
|
+
|
|
68
|
+
const wss = new WebSocketServer({
|
|
69
|
+
port: 3000,
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
wss.on('connection', (socket) => {
|
|
73
|
+
const runtime = createRuntime(
|
|
74
|
+
{
|
|
75
|
+
send(data) {
|
|
76
|
+
socket.send(data);
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
apps: [
|
|
81
|
+
new RuntimeInitializeApp(),
|
|
82
|
+
],
|
|
83
|
+
|
|
84
|
+
providers: [
|
|
85
|
+
{
|
|
86
|
+
name: 'default',
|
|
87
|
+
provider: new GeminiProvider(),
|
|
88
|
+
},
|
|
89
|
+
],
|
|
90
|
+
|
|
91
|
+
services: [],
|
|
92
|
+
}
|
|
93
|
+
);
|
|
94
|
+
|
|
95
|
+
socket.on('message', async (message) => {
|
|
96
|
+
const payload = JSON.parse(message.toString());
|
|
97
|
+
|
|
98
|
+
await runtime.receiveAndSend(payload);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
console.log(
|
|
103
|
+
'StateFlowX runtime listening on ws://localhost:3000'
|
|
104
|
+
);
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
---
|
|
108
|
+
|
|
109
|
+
## Example Client Runtime Configuration
|
|
43
110
|
|
|
44
111
|
```ts
|
|
45
112
|
const config = defineConfig({
|
|
@@ -79,6 +146,30 @@ const config = defineConfig({
|
|
|
79
146
|
});
|
|
80
147
|
```
|
|
81
148
|
|
|
149
|
+
---
|
|
150
|
+
|
|
151
|
+
## Architecture
|
|
152
|
+
|
|
153
|
+
```text
|
|
154
|
+
Angular Client
|
|
155
|
+
->
|
|
156
|
+
WebSocket
|
|
157
|
+
->
|
|
158
|
+
JSON-RPC Runtime
|
|
159
|
+
->
|
|
160
|
+
Dynamic Runtime Initialization
|
|
161
|
+
->
|
|
162
|
+
Workflow Registration
|
|
163
|
+
->
|
|
164
|
+
HTTP Services
|
|
165
|
+
->
|
|
166
|
+
AI Providers
|
|
167
|
+
->
|
|
168
|
+
Structured Response
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
82
173
|
## Current Status
|
|
83
174
|
|
|
84
175
|
StateFlowX Runtime is currently experimental and under active development.
|
package/package.json
CHANGED