@fugood/bricks-project 2.22.0-beta.8 → 2.22.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.
- package/compile/action-name-map.ts +112 -1
- package/compile/index.ts +10 -1
- package/package.json +3 -3
- package/tools/postinstall.ts +16 -9
- package/types/animation.ts +2 -1
- package/types/brick-base.ts +79 -0
- package/types/bricks/3DViewer.ts +200 -0
- package/types/bricks/Camera.ts +195 -0
- package/types/bricks/Chart.ts +362 -0
- package/types/bricks/GenerativeMedia.ts +240 -0
- package/types/bricks/Icon.ts +93 -0
- package/types/bricks/Image.ts +104 -0
- package/types/bricks/Items.ts +461 -0
- package/types/bricks/Lottie.ts +159 -0
- package/types/bricks/QrCode.ts +112 -0
- package/types/bricks/Rect.ts +110 -0
- package/types/bricks/RichText.ts +123 -0
- package/types/bricks/Rive.ts +209 -0
- package/types/bricks/Slideshow.ts +155 -0
- package/types/bricks/Svg.ts +94 -0
- package/types/bricks/Text.ts +143 -0
- package/types/bricks/TextInput.ts +231 -0
- package/types/bricks/Video.ts +170 -0
- package/types/bricks/VideoStreaming.ts +107 -0
- package/types/bricks/WebRtcStream.ts +60 -0
- package/types/bricks/WebView.ts +157 -0
- package/types/bricks/index.ts +20 -0
- package/types/common.ts +8 -3
- package/types/data.ts +6 -0
- package/types/generators/AlarmClock.ts +102 -0
- package/types/generators/Assistant.ts +546 -0
- package/types/generators/BleCentral.ts +225 -0
- package/types/generators/BlePeripheral.ts +202 -0
- package/types/generators/CanvasMap.ts +57 -0
- package/types/generators/CastlesPay.ts +77 -0
- package/types/generators/DataBank.ts +123 -0
- package/types/generators/File.ts +351 -0
- package/types/generators/GraphQl.ts +124 -0
- package/types/generators/Http.ts +117 -0
- package/types/generators/HttpServer.ts +164 -0
- package/types/generators/Information.ts +97 -0
- package/types/generators/Intent.ts +107 -0
- package/types/generators/Iterator.ts +95 -0
- package/types/generators/Keyboard.ts +85 -0
- package/types/generators/LlmAnthropicCompat.ts +188 -0
- package/types/generators/LlmGgml.ts +719 -0
- package/types/generators/LlmOnnx.ts +184 -0
- package/types/generators/LlmOpenAiCompat.ts +206 -0
- package/types/generators/LlmQualcommAiEngine.ts +213 -0
- package/types/generators/Mcp.ts +294 -0
- package/types/generators/McpServer.ts +248 -0
- package/types/generators/MediaFlow.ts +142 -0
- package/types/generators/MqttBroker.ts +121 -0
- package/types/generators/MqttClient.ts +129 -0
- package/types/generators/Question.ts +395 -0
- package/types/generators/RealtimeTranscription.ts +180 -0
- package/types/generators/RerankerGgml.ts +153 -0
- package/types/generators/SerialPort.ts +141 -0
- package/types/generators/SoundPlayer.ts +86 -0
- package/types/generators/SoundRecorder.ts +113 -0
- package/types/generators/SpeechToTextGgml.ts +462 -0
- package/types/generators/SpeechToTextOnnx.ts +227 -0
- package/types/generators/SpeechToTextPlatform.ts +75 -0
- package/types/generators/SqLite.ts +118 -0
- package/types/generators/Step.ts +101 -0
- package/types/generators/TapToPayOnIPhone.ts +175 -0
- package/types/generators/Tcp.ts +120 -0
- package/types/generators/TcpServer.ts +137 -0
- package/types/generators/TextToSpeechGgml.ts +182 -0
- package/types/generators/TextToSpeechOnnx.ts +169 -0
- package/types/generators/TextToSpeechOpenAiLike.ts +113 -0
- package/types/generators/ThermalPrinter.ts +185 -0
- package/types/generators/Tick.ts +75 -0
- package/types/generators/Udp.ts +109 -0
- package/types/generators/VadGgml.ts +211 -0
- package/types/generators/VectorStore.ts +223 -0
- package/types/generators/Watchdog.ts +96 -0
- package/types/generators/WebCrawler.ts +97 -0
- package/types/generators/WebRtc.ts +165 -0
- package/types/generators/WebSocket.ts +142 -0
- package/types/generators/index.ts +51 -0
- package/types/system.ts +64 -0
- package/utils/data.ts +45 -0
- package/utils/event-props.ts +89 -0
- package/types/bricks.ts +0 -3168
- package/types/generators.ts +0 -7580
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
2
|
+
import type { Data, DataLink } from '../data'
|
|
3
|
+
import type {
|
|
4
|
+
Generator,
|
|
5
|
+
EventAction,
|
|
6
|
+
ActionWithDataParams,
|
|
7
|
+
ActionWithParams,
|
|
8
|
+
Action,
|
|
9
|
+
EventProperty,
|
|
10
|
+
} from '../common'
|
|
11
|
+
|
|
12
|
+
/* Connect to MCP server */
|
|
13
|
+
export type GeneratorMCPActionConnect = Action & {
|
|
14
|
+
__actionName: 'GENERATOR_MCP_CONNECT'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* Disconnect from MCP server */
|
|
18
|
+
export type GeneratorMCPActionDisconnect = Action & {
|
|
19
|
+
__actionName: 'GENERATOR_MCP_DISCONNECT'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* List resources */
|
|
23
|
+
export type GeneratorMCPActionListResources = ActionWithParams & {
|
|
24
|
+
__actionName: 'GENERATOR_MCP_LIST_RESOURCES'
|
|
25
|
+
params?: Array<{
|
|
26
|
+
input: 'requestId'
|
|
27
|
+
value?: string | DataLink | EventProperty
|
|
28
|
+
mapping?: string
|
|
29
|
+
}>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/* List resource templates */
|
|
33
|
+
export type GeneratorMCPActionListResourceTemplates = ActionWithParams & {
|
|
34
|
+
__actionName: 'GENERATOR_MCP_LIST_RESOURCE_TEMPLATES'
|
|
35
|
+
params?: Array<{
|
|
36
|
+
input: 'requestId'
|
|
37
|
+
value?: string | DataLink | EventProperty
|
|
38
|
+
mapping?: string
|
|
39
|
+
}>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/* Read resource */
|
|
43
|
+
export type GeneratorMCPActionReadResource = ActionWithParams & {
|
|
44
|
+
__actionName: 'GENERATOR_MCP_READ_RESOURCE'
|
|
45
|
+
params?: Array<
|
|
46
|
+
| {
|
|
47
|
+
input: 'requestId'
|
|
48
|
+
value?: string | DataLink | EventProperty
|
|
49
|
+
mapping?: string
|
|
50
|
+
}
|
|
51
|
+
| {
|
|
52
|
+
input: 'uri'
|
|
53
|
+
value?: string | DataLink | EventProperty
|
|
54
|
+
mapping?: string
|
|
55
|
+
}
|
|
56
|
+
| {
|
|
57
|
+
input: 'variables'
|
|
58
|
+
value?: {} | DataLink | EventProperty
|
|
59
|
+
mapping?: string
|
|
60
|
+
}
|
|
61
|
+
>
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/* List tools */
|
|
65
|
+
export type GeneratorMCPActionListTools = ActionWithParams & {
|
|
66
|
+
__actionName: 'GENERATOR_MCP_LIST_TOOLS'
|
|
67
|
+
params?: Array<{
|
|
68
|
+
input: 'requestId'
|
|
69
|
+
value?: string | DataLink | EventProperty
|
|
70
|
+
mapping?: string
|
|
71
|
+
}>
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* Call tool */
|
|
75
|
+
export type GeneratorMCPActionCallTool = ActionWithParams & {
|
|
76
|
+
__actionName: 'GENERATOR_MCP_CALL_TOOL'
|
|
77
|
+
params?: Array<
|
|
78
|
+
| {
|
|
79
|
+
input: 'requestId'
|
|
80
|
+
value?: string | DataLink | EventProperty
|
|
81
|
+
mapping?: string
|
|
82
|
+
}
|
|
83
|
+
| {
|
|
84
|
+
input: 'name'
|
|
85
|
+
value?: string | DataLink | EventProperty
|
|
86
|
+
mapping?: string
|
|
87
|
+
}
|
|
88
|
+
| {
|
|
89
|
+
input: 'variables'
|
|
90
|
+
value?: {} | DataLink | EventProperty
|
|
91
|
+
mapping?: string
|
|
92
|
+
}
|
|
93
|
+
>
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/* List prompts */
|
|
97
|
+
export type GeneratorMCPActionListPrompts = ActionWithParams & {
|
|
98
|
+
__actionName: 'GENERATOR_MCP_LIST_PROMPTS'
|
|
99
|
+
params?: Array<{
|
|
100
|
+
input: 'requestId'
|
|
101
|
+
value?: string | DataLink | EventProperty
|
|
102
|
+
mapping?: string
|
|
103
|
+
}>
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/* Request prompt */
|
|
107
|
+
export type GeneratorMCPActionGetPrompt = ActionWithParams & {
|
|
108
|
+
__actionName: 'GENERATOR_MCP_GET_PROMPT'
|
|
109
|
+
params?: Array<
|
|
110
|
+
| {
|
|
111
|
+
input: 'requestId'
|
|
112
|
+
value?: string | DataLink | EventProperty
|
|
113
|
+
mapping?: string
|
|
114
|
+
}
|
|
115
|
+
| {
|
|
116
|
+
input: 'name'
|
|
117
|
+
value?: string | DataLink | EventProperty
|
|
118
|
+
mapping?: string
|
|
119
|
+
}
|
|
120
|
+
| {
|
|
121
|
+
input: 'variables'
|
|
122
|
+
value?: {} | DataLink | EventProperty
|
|
123
|
+
mapping?: string
|
|
124
|
+
}
|
|
125
|
+
>
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
interface GeneratorMCPDef {
|
|
129
|
+
/*
|
|
130
|
+
Default property:
|
|
131
|
+
{
|
|
132
|
+
"init": false,
|
|
133
|
+
"type": "streamable-http",
|
|
134
|
+
"url": "",
|
|
135
|
+
"autoReconnect": true,
|
|
136
|
+
"maxReconnectAttempts": 10,
|
|
137
|
+
"reconnectInterval": 1000,
|
|
138
|
+
"generatorId": "",
|
|
139
|
+
"generatorKey": "",
|
|
140
|
+
"name": "bricks-foundation-mcp-client-default",
|
|
141
|
+
"version": "1.0.0",
|
|
142
|
+
"ignoreResourceInList": [],
|
|
143
|
+
"ignoreToolInList": [],
|
|
144
|
+
"ignorePromptInList": [],
|
|
145
|
+
"requestTimeout": 60000
|
|
146
|
+
}
|
|
147
|
+
*/
|
|
148
|
+
property?: {
|
|
149
|
+
/* Application-scoped generator key, key cannot be the same with other application-scoped generators */
|
|
150
|
+
globalGeneratorKey?: string | DataLink
|
|
151
|
+
/* Initialize the MCP client on start */
|
|
152
|
+
init?: boolean | DataLink
|
|
153
|
+
/* Type of the MCP connection, e.g. sse or direct-link (generator) */
|
|
154
|
+
type?: 'streamable-http' | 'sse' | 'direct-link' | DataLink
|
|
155
|
+
/* URL of the MCP server, e.g. http://localhost:19853/sse */
|
|
156
|
+
url?: string | DataLink
|
|
157
|
+
/* Whether to automatically reconnect to the MCP server */
|
|
158
|
+
autoReconnect?: boolean | DataLink
|
|
159
|
+
/* Maximum number of reconnection attempts */
|
|
160
|
+
maxReconnectAttempts?: number | DataLink
|
|
161
|
+
/* Reconnection interval in milliseconds */
|
|
162
|
+
reconnectInterval?: number | DataLink
|
|
163
|
+
/* SSE connection headers */
|
|
164
|
+
sseHeaders?: {} | DataLink
|
|
165
|
+
/* Send request headers */
|
|
166
|
+
sendHeaders?: {} | DataLink
|
|
167
|
+
/* Bearer token for authentication */
|
|
168
|
+
bearerToken?: string | DataLink
|
|
169
|
+
/* Generator MCP Server ID for direct link */
|
|
170
|
+
generatorId?: string | DataLink
|
|
171
|
+
/* Application-scoped key of Generator MCP Server for direct link (If ID is not provided) */
|
|
172
|
+
generatorKey?: string | DataLink
|
|
173
|
+
/* Name of the MCP client */
|
|
174
|
+
name?: string | DataLink
|
|
175
|
+
/* Version of the MCP client */
|
|
176
|
+
version?: string | DataLink
|
|
177
|
+
/* Ignore resources in list response */
|
|
178
|
+
ignoreResourceInList?: Array<string | DataLink> | DataLink
|
|
179
|
+
/* Ignore tools in list response */
|
|
180
|
+
ignoreToolInList?: Array<string | DataLink> | DataLink
|
|
181
|
+
/* Ignore prompts in list response */
|
|
182
|
+
ignorePromptInList?: Array<string | DataLink> | DataLink
|
|
183
|
+
/* Request timeout in milliseconds */
|
|
184
|
+
requestTimeout?: number | DataLink
|
|
185
|
+
}
|
|
186
|
+
events?: {
|
|
187
|
+
/* On connected */
|
|
188
|
+
onConnected?: Array<EventAction>
|
|
189
|
+
/* On connection error */
|
|
190
|
+
onConnectionError?: Array<EventAction>
|
|
191
|
+
/* On disconnected */
|
|
192
|
+
onDisconnected?: Array<EventAction>
|
|
193
|
+
/* On list resources */
|
|
194
|
+
onListResources?: Array<EventAction>
|
|
195
|
+
/* On list resources error */
|
|
196
|
+
onListResourcesError?: Array<EventAction>
|
|
197
|
+
/* On list resource templates */
|
|
198
|
+
onListResourceTemplates?: Array<EventAction>
|
|
199
|
+
/* On list resource templates error */
|
|
200
|
+
onListResourceTemplatesError?: Array<EventAction>
|
|
201
|
+
/* On read resource */
|
|
202
|
+
onReadResource?: Array<EventAction>
|
|
203
|
+
/* On read resource error */
|
|
204
|
+
onReadResourceError?: Array<EventAction>
|
|
205
|
+
/* On list tools */
|
|
206
|
+
onListTools?: Array<EventAction>
|
|
207
|
+
/* On list tools error */
|
|
208
|
+
onListToolsError?: Array<EventAction>
|
|
209
|
+
/* On call tool */
|
|
210
|
+
onCallTool?: Array<EventAction>
|
|
211
|
+
/* On call tool error */
|
|
212
|
+
onCallToolError?: Array<EventAction>
|
|
213
|
+
/* On list prompts */
|
|
214
|
+
onListPrompts?: Array<EventAction>
|
|
215
|
+
/* On list prompts error */
|
|
216
|
+
onListPromptsError?: Array<EventAction>
|
|
217
|
+
/* On get prompt */
|
|
218
|
+
onGetPrompt?: Array<EventAction>
|
|
219
|
+
/* On get prompt error */
|
|
220
|
+
onGetPromptError?: Array<EventAction>
|
|
221
|
+
}
|
|
222
|
+
outlets?: {
|
|
223
|
+
/* Connection state */
|
|
224
|
+
connectionState?: () => Data
|
|
225
|
+
/* List resources response */
|
|
226
|
+
listResourcesResponse?: () => Data
|
|
227
|
+
/* List resources error */
|
|
228
|
+
listResourcesError?: () => Data
|
|
229
|
+
/* List resource templates response */
|
|
230
|
+
listResourceTemplatesResponse?: () => Data
|
|
231
|
+
/* List resource templates error */
|
|
232
|
+
listResourceTemplatesError?: () => Data
|
|
233
|
+
/* Read resource response */
|
|
234
|
+
readResourceResponse?: () => Data
|
|
235
|
+
/* Read resource error */
|
|
236
|
+
readResourceError?: () => Data
|
|
237
|
+
/* List tools response */
|
|
238
|
+
listToolsResponse?: () => Data
|
|
239
|
+
/* List tools error */
|
|
240
|
+
listToolsError?: () => Data
|
|
241
|
+
/* Call tool response */
|
|
242
|
+
callToolResponse?: () => Data
|
|
243
|
+
/* Call tool error */
|
|
244
|
+
callToolError?: () => Data
|
|
245
|
+
/* List prompts response */
|
|
246
|
+
listPromptsResponse?: () => Data
|
|
247
|
+
/* List prompts error */
|
|
248
|
+
listPromptsError?: () => Data
|
|
249
|
+
/* Get prompt response */
|
|
250
|
+
getPromptResponse?: () => Data
|
|
251
|
+
/* Request prompt error */
|
|
252
|
+
getPromptError?: () => Data
|
|
253
|
+
/* Last error */
|
|
254
|
+
lastError?: () => Data
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/* Model Context Protocol (MCP) Client, support SSE and Generator MCPServer direct link */
|
|
259
|
+
export type GeneratorMCP = Generator &
|
|
260
|
+
GeneratorMCPDef & {
|
|
261
|
+
templateKey: 'GENERATOR_MCP'
|
|
262
|
+
switches: Array<
|
|
263
|
+
SwitchDef &
|
|
264
|
+
GeneratorMCPDef & {
|
|
265
|
+
conds?: Array<{
|
|
266
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
267
|
+
cond:
|
|
268
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
269
|
+
| SwitchCondData
|
|
270
|
+
| {
|
|
271
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
272
|
+
outlet:
|
|
273
|
+
| 'connectionState'
|
|
274
|
+
| 'listResourcesResponse'
|
|
275
|
+
| 'listResourcesError'
|
|
276
|
+
| 'listResourceTemplatesResponse'
|
|
277
|
+
| 'listResourceTemplatesError'
|
|
278
|
+
| 'readResourceResponse'
|
|
279
|
+
| 'readResourceError'
|
|
280
|
+
| 'listToolsResponse'
|
|
281
|
+
| 'listToolsError'
|
|
282
|
+
| 'callToolResponse'
|
|
283
|
+
| 'callToolError'
|
|
284
|
+
| 'listPromptsResponse'
|
|
285
|
+
| 'listPromptsError'
|
|
286
|
+
| 'getPromptResponse'
|
|
287
|
+
| 'getPromptError'
|
|
288
|
+
| 'lastError'
|
|
289
|
+
value: any
|
|
290
|
+
}
|
|
291
|
+
}>
|
|
292
|
+
}
|
|
293
|
+
>
|
|
294
|
+
}
|
|
@@ -0,0 +1,248 @@
|
|
|
1
|
+
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
2
|
+
import type { Data, DataLink } from '../data'
|
|
3
|
+
import type {
|
|
4
|
+
Generator,
|
|
5
|
+
EventAction,
|
|
6
|
+
ActionWithDataParams,
|
|
7
|
+
ActionWithParams,
|
|
8
|
+
Action,
|
|
9
|
+
EventProperty,
|
|
10
|
+
} from '../common'
|
|
11
|
+
|
|
12
|
+
/* Refresh tools and resources, used for case if tools or resources are changed. Note that the current connections will be closed. */
|
|
13
|
+
export type GeneratorMCPServerActionRefreshResources = Action & {
|
|
14
|
+
__actionName: 'GENERATOR_MCP_SERVER_REFRESH_RESOURCES'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
interface GeneratorMCPServerDef {
|
|
18
|
+
/*
|
|
19
|
+
Default property:
|
|
20
|
+
{
|
|
21
|
+
"enabled": true,
|
|
22
|
+
"listening": true,
|
|
23
|
+
"authType": "none",
|
|
24
|
+
"name": "bricks-foundation-mcp-server-default",
|
|
25
|
+
"version": "1.0.0",
|
|
26
|
+
"resources": [],
|
|
27
|
+
"tools": [],
|
|
28
|
+
"prompts": []
|
|
29
|
+
}
|
|
30
|
+
*/
|
|
31
|
+
property?: {
|
|
32
|
+
/* Enable MCP server. If enabled and Listening is false, the generator can still provide application-scoped resources. */
|
|
33
|
+
enabled?: boolean | DataLink
|
|
34
|
+
/* Application-scoped generator key, key cannot be the same with other application-scoped generators */
|
|
35
|
+
globalGeneratorKey?: string | DataLink
|
|
36
|
+
/* Start MCP server */
|
|
37
|
+
listening?: boolean | DataLink
|
|
38
|
+
/* HTTP server port */
|
|
39
|
+
port?: number | DataLink
|
|
40
|
+
/* Authorization type of HTTP request */
|
|
41
|
+
authType?: 'none' | 'bearer' | DataLink
|
|
42
|
+
/* Token of bearer auth */
|
|
43
|
+
bearerToken?: string | DataLink
|
|
44
|
+
/* Name of the MCP server */
|
|
45
|
+
name?: string | DataLink
|
|
46
|
+
/* Version of the MCP server */
|
|
47
|
+
version?: string | DataLink
|
|
48
|
+
/* Resources
|
|
49
|
+
Type:
|
|
50
|
+
`static`: Return static data
|
|
51
|
+
`detect-data-change`: Watch data target change to return data,
|
|
52
|
+
please update data with ({ id: string, content: string | object }),
|
|
53
|
+
and ensure the id is same with request id
|
|
54
|
+
`script`: Run a JavaScript code to return data
|
|
55
|
+
- Script can define members to call generator functions
|
|
56
|
+
- Script support async/await */
|
|
57
|
+
resources?:
|
|
58
|
+
| Array<
|
|
59
|
+
| DataLink
|
|
60
|
+
| {
|
|
61
|
+
enabled?: boolean | DataLink
|
|
62
|
+
name?: string | DataLink
|
|
63
|
+
description?: string | DataLink
|
|
64
|
+
uriOrTemplate?: string | DataLink
|
|
65
|
+
type?: 'static' | 'detect-data-change' | 'script' | DataLink
|
|
66
|
+
staticData?: any
|
|
67
|
+
dataChangeConfig?:
|
|
68
|
+
| DataLink
|
|
69
|
+
| {
|
|
70
|
+
target?: string | DataLink
|
|
71
|
+
timeout?: number | DataLink
|
|
72
|
+
additionalParams?: {} | DataLink
|
|
73
|
+
}
|
|
74
|
+
scriptConfig?:
|
|
75
|
+
| DataLink
|
|
76
|
+
| {
|
|
77
|
+
code?: string | DataLink
|
|
78
|
+
timeout?: number | DataLink
|
|
79
|
+
members?:
|
|
80
|
+
| Array<
|
|
81
|
+
| DataLink
|
|
82
|
+
| {
|
|
83
|
+
handler?: string | DataLink
|
|
84
|
+
varName?: string | DataLink
|
|
85
|
+
}
|
|
86
|
+
>
|
|
87
|
+
| DataLink
|
|
88
|
+
additionalParams?: {} | DataLink
|
|
89
|
+
}
|
|
90
|
+
responseType?: 'text' | 'object' | DataLink
|
|
91
|
+
}
|
|
92
|
+
>
|
|
93
|
+
| DataLink
|
|
94
|
+
/* Tools
|
|
95
|
+
Type:
|
|
96
|
+
`static`: Return static data
|
|
97
|
+
`detect-data-change`: Watch data target change to return data,
|
|
98
|
+
please update data with ({ id: string, content: string | object }),
|
|
99
|
+
and ensure the id is same with request id.
|
|
100
|
+
`script`: Run a JavaScript code to return data
|
|
101
|
+
- Script can define members to call generator functions
|
|
102
|
+
- Script support async/await */
|
|
103
|
+
tools?:
|
|
104
|
+
| Array<
|
|
105
|
+
| DataLink
|
|
106
|
+
| {
|
|
107
|
+
enabled?: boolean | DataLink
|
|
108
|
+
name?: string | DataLink
|
|
109
|
+
description?: string | DataLink
|
|
110
|
+
params?: {} | DataLink
|
|
111
|
+
type?: 'static' | 'detect-data-change' | 'script' | DataLink
|
|
112
|
+
staticData?: any
|
|
113
|
+
dataChangeConfig?:
|
|
114
|
+
| DataLink
|
|
115
|
+
| {
|
|
116
|
+
target?: string | DataLink
|
|
117
|
+
timeout?: number | DataLink
|
|
118
|
+
additionalParams?: {} | DataLink
|
|
119
|
+
}
|
|
120
|
+
scriptConfig?:
|
|
121
|
+
| DataLink
|
|
122
|
+
| {
|
|
123
|
+
code?: string | DataLink
|
|
124
|
+
timeout?: number | DataLink
|
|
125
|
+
members?:
|
|
126
|
+
| Array<
|
|
127
|
+
| DataLink
|
|
128
|
+
| {
|
|
129
|
+
handler?: string | DataLink
|
|
130
|
+
varName?: string | DataLink
|
|
131
|
+
}
|
|
132
|
+
>
|
|
133
|
+
| DataLink
|
|
134
|
+
additionalParams?: {} | DataLink
|
|
135
|
+
}
|
|
136
|
+
responseType?: 'text' | 'object' | DataLink
|
|
137
|
+
}
|
|
138
|
+
>
|
|
139
|
+
| DataLink
|
|
140
|
+
/* Prompts
|
|
141
|
+
Type:
|
|
142
|
+
`static`: Return static data
|
|
143
|
+
`detect-data-change`: Watch data target change to return data,
|
|
144
|
+
please update data with ({ id: string, content: string | object }),
|
|
145
|
+
and ensure the id is same with request id
|
|
146
|
+
`script`: Run a JavaScript code to return data
|
|
147
|
+
- Script can define members to call generator functions
|
|
148
|
+
- Script support async/await */
|
|
149
|
+
prompts?:
|
|
150
|
+
| Array<
|
|
151
|
+
| DataLink
|
|
152
|
+
| {
|
|
153
|
+
enabled?: boolean | DataLink
|
|
154
|
+
name?: string | DataLink
|
|
155
|
+
description?: string | DataLink
|
|
156
|
+
arguments?: {} | DataLink
|
|
157
|
+
type?: 'static' | 'detect-data-change' | 'script' | DataLink
|
|
158
|
+
staticData?: any
|
|
159
|
+
dataChangeConfig?:
|
|
160
|
+
| DataLink
|
|
161
|
+
| {
|
|
162
|
+
target?: string | DataLink
|
|
163
|
+
timeout?: number | DataLink
|
|
164
|
+
additionalParams?: {} | DataLink
|
|
165
|
+
}
|
|
166
|
+
scriptConfig?:
|
|
167
|
+
| DataLink
|
|
168
|
+
| {
|
|
169
|
+
code?: string | DataLink
|
|
170
|
+
timeout?: number | DataLink
|
|
171
|
+
members?:
|
|
172
|
+
| Array<
|
|
173
|
+
| DataLink
|
|
174
|
+
| {
|
|
175
|
+
handler?: string | DataLink
|
|
176
|
+
varName?: string | DataLink
|
|
177
|
+
}
|
|
178
|
+
>
|
|
179
|
+
| DataLink
|
|
180
|
+
additionalParams?: {} | DataLink
|
|
181
|
+
}
|
|
182
|
+
responseType?: 'text' | 'object' | DataLink
|
|
183
|
+
}
|
|
184
|
+
>
|
|
185
|
+
| DataLink
|
|
186
|
+
}
|
|
187
|
+
events?: {
|
|
188
|
+
/* Listening of HTTP server */
|
|
189
|
+
onListening?: Array<EventAction>
|
|
190
|
+
/* Error of HTTP server */
|
|
191
|
+
onError?: Array<EventAction>
|
|
192
|
+
/* Client error of HTTP server */
|
|
193
|
+
onClientError?: Array<EventAction>
|
|
194
|
+
/* Client close of HTTP server */
|
|
195
|
+
onClientClose?: Array<EventAction>
|
|
196
|
+
/* On request resource (Request: { name: string, uri: string, params: object }) */
|
|
197
|
+
onRequestResource?: Array<EventAction>
|
|
198
|
+
/* On call tool (Request: { name: string, params: object }) */
|
|
199
|
+
onCallTool?: Array<EventAction>
|
|
200
|
+
/* On get prompt (Request: { name: string, arguments: object }) */
|
|
201
|
+
onGetPrompt?: Array<EventAction>
|
|
202
|
+
}
|
|
203
|
+
outlets?: {
|
|
204
|
+
/* Whether the HTTP server is listening */
|
|
205
|
+
isListening?: () => Data
|
|
206
|
+
/* Last error of HTTP server */
|
|
207
|
+
lastError?: () => Data
|
|
208
|
+
/* MCP server endpoint URL */
|
|
209
|
+
endpoint?: () => Data
|
|
210
|
+
/* Connected remotes (Session ID) */
|
|
211
|
+
connectedRemotes?: () => Data
|
|
212
|
+
/* Last resource request ({ name: string, uri: string, params: object }) */
|
|
213
|
+
lastResourceRequest?: () => Data
|
|
214
|
+
/* Last tool call ({ name: string, params: object }) */
|
|
215
|
+
lastToolCall?: () => Data
|
|
216
|
+
/* Last prompt get ({ name: string, arguments: object }) */
|
|
217
|
+
lastPromptGet?: () => Data
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
/* Model Context Protocol (MCP) Server (https://docs.anthropic.com/en/docs/agents-and-tools/mcp) */
|
|
222
|
+
export type GeneratorMCPServer = Generator &
|
|
223
|
+
GeneratorMCPServerDef & {
|
|
224
|
+
templateKey: 'GENERATOR_MCP_SERVER'
|
|
225
|
+
switches: Array<
|
|
226
|
+
SwitchDef &
|
|
227
|
+
GeneratorMCPServerDef & {
|
|
228
|
+
conds?: Array<{
|
|
229
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
230
|
+
cond:
|
|
231
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
232
|
+
| SwitchCondData
|
|
233
|
+
| {
|
|
234
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
235
|
+
outlet:
|
|
236
|
+
| 'isListening'
|
|
237
|
+
| 'lastError'
|
|
238
|
+
| 'endpoint'
|
|
239
|
+
| 'connectedRemotes'
|
|
240
|
+
| 'lastResourceRequest'
|
|
241
|
+
| 'lastToolCall'
|
|
242
|
+
| 'lastPromptGet'
|
|
243
|
+
value: any
|
|
244
|
+
}
|
|
245
|
+
}>
|
|
246
|
+
}
|
|
247
|
+
>
|
|
248
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
|
|
2
|
+
import type { Data, DataLink } from '../data'
|
|
3
|
+
import type {
|
|
4
|
+
Generator,
|
|
5
|
+
EventAction,
|
|
6
|
+
ActionWithDataParams,
|
|
7
|
+
ActionWithParams,
|
|
8
|
+
Action,
|
|
9
|
+
EventProperty,
|
|
10
|
+
} from '../common'
|
|
11
|
+
|
|
12
|
+
/* Start fetcn Media box file list */
|
|
13
|
+
export type GeneratorMediaFlowActionFetch = Action & {
|
|
14
|
+
__actionName: 'GENERATOR_MEDIA_FLOW_FETCH'
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/* Reset cache */
|
|
18
|
+
export type GeneratorMediaFlowActionResetCache = Action & {
|
|
19
|
+
__actionName: 'GENERATOR_MEDIA_FLOW_RESET_CACHE'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Abort current fetch request of media list */
|
|
23
|
+
export type GeneratorMediaFlowActionAbortFetch = Action & {
|
|
24
|
+
__actionName: 'GENERATOR_MEDIA_FLOW_ABORT_FETCH'
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
interface GeneratorMediaFlowDef {
|
|
28
|
+
/*
|
|
29
|
+
Default property:
|
|
30
|
+
{
|
|
31
|
+
"includeTypes": [
|
|
32
|
+
"IMAGE",
|
|
33
|
+
"VIDEO",
|
|
34
|
+
"AUDIO",
|
|
35
|
+
"FILE"
|
|
36
|
+
],
|
|
37
|
+
"fetchPolicy": "cache-first",
|
|
38
|
+
"subscribeBoxChange": false,
|
|
39
|
+
"saveToStorageDownloadMode": "sequence",
|
|
40
|
+
"loadSizeLimit": "",
|
|
41
|
+
"allowLoadSizeLimitExceed": true,
|
|
42
|
+
"source": "original",
|
|
43
|
+
"sourceVersionAlternatives": []
|
|
44
|
+
}
|
|
45
|
+
*/
|
|
46
|
+
property?: {
|
|
47
|
+
/* The box id of Media Flow */
|
|
48
|
+
boxId?: string | DataLink
|
|
49
|
+
/* Authorize accessToken, use `passcode` if `accessToken` is empty */
|
|
50
|
+
accessToken?: string | DataLink
|
|
51
|
+
/* Authorize passcode */
|
|
52
|
+
passcode?: string | DataLink
|
|
53
|
+
/* Include File Types */
|
|
54
|
+
includeTypes?: Array<'IMAGE' | 'VIDEO' | 'AUDIO' | 'FILE' | DataLink> | DataLink
|
|
55
|
+
/* Determine the cache behavior
|
|
56
|
+
|
|
57
|
+
cache-first: Cache first if existing, then fetch from network
|
|
58
|
+
network-and-cache: Fetch from network, then save cache
|
|
59
|
+
network-only: Fetch from network only */
|
|
60
|
+
fetchPolicy?: 'cache-first' | 'network-and-cache' | 'network-only' | DataLink
|
|
61
|
+
/* Subscribe box change to refresh file list (file deleted / new file uploaded) */
|
|
62
|
+
subscribeBoxChange?: boolean | DataLink
|
|
63
|
+
/* Save files into local file storage */
|
|
64
|
+
saveToStorage?: boolean | DataLink
|
|
65
|
+
/* Concurrent download files or sequence for saveToStorage */
|
|
66
|
+
saveToStorageDownloadMode?: 'sequence' | 'concurrent' | DataLink
|
|
67
|
+
/* Limit the load size (* GB, * MB, * KB) */
|
|
68
|
+
loadSizeLimit?: string | DataLink
|
|
69
|
+
/* Allow Load size limit exceed, just call event */
|
|
70
|
+
allowLoadSizeLimitExceed?: boolean | DataLink
|
|
71
|
+
/* Select download source */
|
|
72
|
+
source?:
|
|
73
|
+
| 'original'
|
|
74
|
+
| 'auto'
|
|
75
|
+
| 'converted'
|
|
76
|
+
| 'video-thumbnail-original'
|
|
77
|
+
| 'use-source-versions'
|
|
78
|
+
| DataLink
|
|
79
|
+
/* Select download source with image version (use width, e.g. [250, 360]) */
|
|
80
|
+
sourceVersionAlternatives?: Array<number | DataLink> | DataLink
|
|
81
|
+
/* Allowlist patterns to filter media files (supports regex or plain text) */
|
|
82
|
+
allowlist?: Array<string | DataLink> | DataLink
|
|
83
|
+
/* Blocklist patterns to filter media files (supports regex or plain text) */
|
|
84
|
+
blocklist?: Array<string | DataLink> | DataLink
|
|
85
|
+
}
|
|
86
|
+
events?: {
|
|
87
|
+
/* Event of media box fetch error */
|
|
88
|
+
fetchError?: Array<EventAction>
|
|
89
|
+
/* Event of subscribe box change connected (If set `Subscribe Box Change`) */
|
|
90
|
+
subscribeBoxConnect?: Array<EventAction>
|
|
91
|
+
/* Event of subscribe box change error (If set `Subscribe Box Change`) */
|
|
92
|
+
subscribeBoxError?: Array<EventAction>
|
|
93
|
+
/* Event of subscribe box change connection error (If set `Subscribe Box Change`) */
|
|
94
|
+
subscribeBoxConnectError?: Array<EventAction>
|
|
95
|
+
/* Event of file sync completed for used `saveToStorage` */
|
|
96
|
+
saveStorageCompleted?: Array<EventAction>
|
|
97
|
+
/* Event when file list size exceed of Load size limit */
|
|
98
|
+
fileSizeExceed?: Array<EventAction>
|
|
99
|
+
}
|
|
100
|
+
outlets?: {
|
|
101
|
+
/* File sync status */
|
|
102
|
+
downloadStatus?: () => Data
|
|
103
|
+
/* File sync progress */
|
|
104
|
+
downloadProgress?: () => Data
|
|
105
|
+
/* File sync download errors */
|
|
106
|
+
downloadErrors?: () => Data
|
|
107
|
+
/* Media box info */
|
|
108
|
+
box?: () => Data
|
|
109
|
+
/* Save Media Flow fetch result [ { "url": "https://d1kk0369g9vrck.cloudfront.net/box/5b431e29efd40c01e8b2019c/photo5b431e37efd40c01e8b201d1" "extension": "", // enum("jpg", "png", "mp4") "id": "5b431e37efd40c01e8b201d1", "md5": "6134ab412351651324" // md5 came from media resource api } ] */
|
|
110
|
+
result?: () => Data
|
|
111
|
+
/* File sync result [ { "url": "/storage/emulated/0/Download/SyncFolder/Asset/1.png", "mediaType": "photo" // enum("photo", "video"), used to distingiush "id": "", } ] */
|
|
112
|
+
downloadFileUrls?: () => Data
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* Fetch box's file list from Media Flow */
|
|
117
|
+
export type GeneratorMediaFlow = Generator &
|
|
118
|
+
GeneratorMediaFlowDef & {
|
|
119
|
+
templateKey: 'GENERATOR_MEDIA_FLOW'
|
|
120
|
+
switches: Array<
|
|
121
|
+
SwitchDef &
|
|
122
|
+
GeneratorMediaFlowDef & {
|
|
123
|
+
conds?: Array<{
|
|
124
|
+
method: '==' | '!=' | '>' | '<' | '>=' | '<='
|
|
125
|
+
cond:
|
|
126
|
+
| SwitchCondInnerStateCurrentCanvas
|
|
127
|
+
| SwitchCondData
|
|
128
|
+
| {
|
|
129
|
+
__typename: 'SwitchCondInnerStateOutlet'
|
|
130
|
+
outlet:
|
|
131
|
+
| 'downloadStatus'
|
|
132
|
+
| 'downloadProgress'
|
|
133
|
+
| 'downloadErrors'
|
|
134
|
+
| 'box'
|
|
135
|
+
| 'result'
|
|
136
|
+
| 'downloadFileUrls'
|
|
137
|
+
value: any
|
|
138
|
+
}
|
|
139
|
+
}>
|
|
140
|
+
}
|
|
141
|
+
>
|
|
142
|
+
}
|