@fugood/bricks-project 2.24.0-beta.3 → 2.24.0-beta.30

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 (112) hide show
  1. package/compile/action-name-map.ts +36 -0
  2. package/compile/index.ts +400 -146
  3. package/compile/util.ts +2 -0
  4. package/package.json +8 -3
  5. package/skills/bricks-project/rules/architecture-patterns.md +7 -0
  6. package/skills/bricks-project/rules/automations.md +74 -28
  7. package/skills/bricks-project/rules/buttress.md +9 -6
  8. package/tools/deploy.ts +66 -12
  9. package/tools/mcp-server.ts +10 -877
  10. package/tools/mcp-tools/compile.ts +91 -0
  11. package/tools/mcp-tools/huggingface.ts +762 -0
  12. package/tools/mcp-tools/icons.ts +60 -0
  13. package/tools/mcp-tools/lottie.ts +102 -0
  14. package/tools/mcp-tools/media.ts +110 -0
  15. package/tools/postinstall.ts +121 -33
  16. package/tools/preview-main.mjs +12 -8
  17. package/tools/pull.ts +37 -19
  18. package/tsconfig.json +16 -0
  19. package/types/animation.ts +4 -0
  20. package/types/automation.ts +3 -0
  21. package/types/brick-base.ts +1 -1
  22. package/types/bricks/Camera.ts +34 -7
  23. package/types/bricks/Chart.ts +1 -1
  24. package/types/bricks/GenerativeMedia.ts +6 -6
  25. package/types/bricks/Icon.ts +3 -3
  26. package/types/bricks/Image.ts +4 -4
  27. package/types/bricks/Items.ts +7 -7
  28. package/types/bricks/Lottie.ts +4 -4
  29. package/types/bricks/Maps.ts +4 -4
  30. package/types/bricks/QrCode.ts +4 -4
  31. package/types/bricks/Rect.ts +4 -4
  32. package/types/bricks/RichText.ts +3 -3
  33. package/types/bricks/Rive.ts +1 -1
  34. package/types/bricks/Slideshow.ts +4 -4
  35. package/types/bricks/Svg.ts +3 -3
  36. package/types/bricks/Text.ts +4 -4
  37. package/types/bricks/TextInput.ts +11 -7
  38. package/types/bricks/Video.ts +4 -4
  39. package/types/bricks/VideoStreaming.ts +3 -3
  40. package/types/bricks/WebRtcStream.ts +1 -1
  41. package/types/bricks/WebView.ts +4 -4
  42. package/types/canvas.ts +4 -2
  43. package/types/common.ts +9 -4
  44. package/types/data-calc-command.ts +2 -0
  45. package/types/data-calc.ts +1 -0
  46. package/types/data.ts +2 -0
  47. package/types/generators/AlarmClock.ts +5 -5
  48. package/types/generators/Assistant.ts +57 -12
  49. package/types/generators/BleCentral.ts +12 -4
  50. package/types/generators/BlePeripheral.ts +5 -5
  51. package/types/generators/CanvasMap.ts +4 -4
  52. package/types/generators/CastlesPay.ts +3 -3
  53. package/types/generators/DataBank.ts +31 -4
  54. package/types/generators/File.ts +63 -14
  55. package/types/generators/GraphQl.ts +3 -3
  56. package/types/generators/Http.ts +27 -8
  57. package/types/generators/HttpServer.ts +9 -9
  58. package/types/generators/Information.ts +2 -2
  59. package/types/generators/Intent.ts +8 -2
  60. package/types/generators/Iterator.ts +6 -6
  61. package/types/generators/Keyboard.ts +18 -8
  62. package/types/generators/LlmAnthropicCompat.ts +12 -6
  63. package/types/generators/LlmAppleBuiltin.ts +6 -6
  64. package/types/generators/LlmGgml.ts +101 -25
  65. package/types/generators/LlmMediaTekNeuroPilot.ts +225 -0
  66. package/types/generators/LlmMlx.ts +210 -0
  67. package/types/generators/LlmOnnx.ts +18 -9
  68. package/types/generators/LlmOpenAiCompat.ts +22 -6
  69. package/types/generators/LlmQualcommAiEngine.ts +32 -8
  70. package/types/generators/Mcp.ts +332 -17
  71. package/types/generators/McpServer.ts +38 -11
  72. package/types/generators/MediaFlow.ts +26 -8
  73. package/types/generators/MqttBroker.ts +10 -4
  74. package/types/generators/MqttClient.ts +11 -5
  75. package/types/generators/Question.ts +6 -6
  76. package/types/generators/RealtimeTranscription.ts +82 -11
  77. package/types/generators/RerankerGgml.ts +23 -9
  78. package/types/generators/SerialPort.ts +6 -6
  79. package/types/generators/SoundPlayer.ts +2 -2
  80. package/types/generators/SoundRecorder.ts +17 -6
  81. package/types/generators/SpeechToTextGgml.ts +34 -14
  82. package/types/generators/SpeechToTextOnnx.ts +8 -8
  83. package/types/generators/SpeechToTextPlatform.ts +4 -4
  84. package/types/generators/SqLite.ts +10 -6
  85. package/types/generators/Step.ts +3 -3
  86. package/types/generators/SttAppleBuiltin.ts +6 -6
  87. package/types/generators/Tcp.ts +5 -5
  88. package/types/generators/TcpServer.ts +7 -7
  89. package/types/generators/TextToSpeechApple.ts +1 -1
  90. package/types/generators/TextToSpeechAppleBuiltin.ts +5 -5
  91. package/types/generators/TextToSpeechGgml.ts +8 -8
  92. package/types/generators/TextToSpeechOnnx.ts +9 -9
  93. package/types/generators/TextToSpeechOpenAiLike.ts +5 -5
  94. package/types/generators/ThermalPrinter.ts +6 -6
  95. package/types/generators/Tick.ts +3 -3
  96. package/types/generators/Udp.ts +9 -4
  97. package/types/generators/VadGgml.ts +39 -10
  98. package/types/generators/VadOnnx.ts +31 -8
  99. package/types/generators/VadTraditional.ts +15 -9
  100. package/types/generators/VectorStore.ts +26 -9
  101. package/types/generators/Watchdog.ts +11 -6
  102. package/types/generators/WebCrawler.ts +5 -5
  103. package/types/generators/WebRtc.ts +17 -11
  104. package/types/generators/WebSocket.ts +5 -5
  105. package/types/generators/index.ts +2 -0
  106. package/types/subspace.ts +3 -0
  107. package/types/system.ts +1 -1
  108. package/utils/calc.ts +12 -8
  109. package/utils/event-props.ts +124 -87
  110. package/utils/id.ts +4 -0
  111. package/api/index.ts +0 -1
  112. package/api/instance.ts +0 -213
@@ -0,0 +1,210 @@
1
+ /* Auto generated by build script */
2
+ import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
3
+ import type { Data, DataLink } from '../data'
4
+ import type {
5
+ Brick,
6
+ Generator,
7
+ EventAction,
8
+ ActionWithDataParams,
9
+ ActionWithParams,
10
+ Action,
11
+ EventProperty,
12
+ } from '../common'
13
+
14
+ /* Load model */
15
+ export type GeneratorMlxLLMActionLoadModel = ActionWithParams & {
16
+ __actionName: 'GENERATOR_MLX_LLM_LOAD_MODEL'
17
+ params?: Array<
18
+ | {
19
+ input: 'modelId'
20
+ value?: string | DataLink | EventProperty
21
+ mapping?: string
22
+ }
23
+ | {
24
+ input: 'vlm'
25
+ value?: boolean | DataLink | EventProperty
26
+ mapping?: string
27
+ }
28
+ >
29
+ }
30
+
31
+ /* Run text completion */
32
+ export type GeneratorMlxLLMActionCompletion = ActionWithParams & {
33
+ __actionName: 'GENERATOR_MLX_LLM_COMPLETION'
34
+ params?: Array<
35
+ | {
36
+ input: 'messages'
37
+ value?: Array<any> | DataLink | EventProperty
38
+ mapping?: string
39
+ }
40
+ | {
41
+ input: 'tools'
42
+ value?: Array<any> | DataLink | EventProperty
43
+ mapping?: string
44
+ }
45
+ | {
46
+ input: 'maxTokens'
47
+ value?: number | DataLink | EventProperty
48
+ mapping?: string
49
+ }
50
+ | {
51
+ input: 'temperature'
52
+ value?: number | DataLink | EventProperty
53
+ mapping?: string
54
+ }
55
+ | {
56
+ input: 'topP'
57
+ value?: number | DataLink | EventProperty
58
+ mapping?: string
59
+ }
60
+ | {
61
+ input: 'repetitionPenalty'
62
+ value?: number | DataLink | EventProperty
63
+ mapping?: string
64
+ }
65
+ >
66
+ }
67
+
68
+ /* Stop text completion */
69
+ export type GeneratorMlxLLMActionStopCompletion = Action & {
70
+ __actionName: 'GENERATOR_MLX_LLM_STOP_COMPLETION'
71
+ }
72
+
73
+ /* Release model context */
74
+ export type GeneratorMlxLLMActionReleaseContext = Action & {
75
+ __actionName: 'GENERATOR_MLX_LLM_RELEASE_CONTEXT'
76
+ }
77
+
78
+ interface GeneratorMlxLLMDef {
79
+ /*
80
+ Default property:
81
+ {
82
+ "init": false,
83
+ "modelId": "mlx-community/Qwen3-4B-4bit",
84
+ "vlm": false,
85
+ "completionMessages": [
86
+ {
87
+ "role": "system",
88
+ "content": "You are a helpful assistant."
89
+ },
90
+ {
91
+ "role": "user",
92
+ "content": "Hello"
93
+ }
94
+ ],
95
+ "completionMaxTokens": 1024,
96
+ "completionTemperature": 0.6,
97
+ "completionTopP": 1,
98
+ "completionRepetitionContextSize": 20
99
+ }
100
+ */
101
+ property?: {
102
+ /* Initialize model on generator init */
103
+ init?: boolean | DataLink
104
+ /* HuggingFace model ID or local path to model directory
105
+ e.g. "mlx-community/Qwen3-4B-4bit" */
106
+ modelId?: string | DataLink
107
+ /* Enable Vision Language Model (VLM) mode */
108
+ vlm?: boolean | DataLink
109
+ /* Chat messages (if first message has role 'system', it will be used as system prompt) */
110
+ completionMessages?:
111
+ | Array<
112
+ | DataLink
113
+ | {
114
+ role?: string | DataLink
115
+ content?: string | DataLink
116
+ }
117
+ >
118
+ | DataLink
119
+ /* Maximum tokens to generate */
120
+ completionMaxTokens?: number | DataLink
121
+ /* Temperature (0.0 to 2.0) */
122
+ completionTemperature?: number | DataLink
123
+ /* Top P sampling */
124
+ completionTopP?: number | DataLink
125
+ /* Repetition penalty factor */
126
+ completionRepetitionPenalty?: number | DataLink
127
+ /* Number of tokens to consider for repetition penalty */
128
+ completionRepetitionContextSize?: number | DataLink
129
+ /* Maximum KV cache size (context window). Uses rotating cache to limit memory.
130
+ Smaller values (e.g. 512) use less memory but lower quality.
131
+ Larger values (e.g. 4096) use more memory but better quality.
132
+ Leave empty for unlimited (model default). */
133
+ contextSize?: number | DataLink
134
+ /* Enable thinking mode (model-dependent, e.g. Qwen3).
135
+ When enabled, passes enable_thinking=true to the chat template.
136
+ The model may output reasoning in &lt;think&gt; tags which will be extracted as reasoning_content. */
137
+ completionEnableThinking?: boolean | DataLink
138
+ /* Additional keyword arguments for chat template (object) */
139
+ completionChatTemplateKwargs?: {} | DataLink
140
+ /* Tools for chat mode using OpenAI-compatible function calling format
141
+ Format: Array of objects with {type, function: {name, description, parameters}} structure
142
+ See: https://platform.openai.com/docs/guides/function-calling */
143
+ completionTools?: Array<{} | DataLink> | DataLink
144
+ /* Buttress connection settings for remote inference */
145
+ buttressConnectionSettings?:
146
+ | DataLink
147
+ | {
148
+ enabled?: boolean | DataLink
149
+ url?: string | DataLink
150
+ fallbackType?: 'use-local' | 'no-op' | DataLink
151
+ strategy?: 'prefer-local' | 'prefer-buttress' | 'prefer-best' | DataLink
152
+ }
153
+ }
154
+ events?: {
155
+ /* Event triggered when context state changes */
156
+ onContextStateChange?: Array<EventAction>
157
+ /* Error event */
158
+ onError?: Array<EventAction>
159
+ /* Completion streaming event (emitted for each token) */
160
+ onCompletion?: Array<EventAction>
161
+ /* Completion finished event */
162
+ onCompletionFinished?: Array<EventAction>
163
+ }
164
+ outlets?: {
165
+ /* Context state */
166
+ contextState?: () => Data<string>
167
+ /* Model load progress (0-1) */
168
+ loadProgress?: () => Data<number>
169
+ /* Whether the model is evaluating */
170
+ isEvaluating?: () => Data<boolean>
171
+ /* Completion result */
172
+ completionResult?: () => Data<string>
173
+ /* Last token */
174
+ completionLastToken?: () => Data<string>
175
+ }
176
+ }
177
+
178
+ /* On-device LLM inference using Apple MLX framework on iOS/tvOS
179
+
180
+ ## Features
181
+ - Powered by MLX (Apple's ML framework optimized for Apple Silicon)
182
+ - Download models directly from HuggingFace Hub
183
+ - Streaming token generation
184
+ - Supports LLM and VLM (Vision Language Models)
185
+ - Requires iOS 17+ or tvOS 17+ */
186
+ export type GeneratorMlxLLM = Generator &
187
+ GeneratorMlxLLMDef & {
188
+ templateKey: 'GENERATOR_MLX_LLM'
189
+ switches?: Array<
190
+ SwitchDef &
191
+ GeneratorMlxLLMDef & {
192
+ conds?: Array<{
193
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
194
+ cond:
195
+ | SwitchCondInnerStateCurrentCanvas
196
+ | SwitchCondData
197
+ | {
198
+ __typename: 'SwitchCondInnerStateOutlet'
199
+ outlet:
200
+ | 'contextState'
201
+ | 'loadProgress'
202
+ | 'isEvaluating'
203
+ | 'completionResult'
204
+ | 'completionLastToken'
205
+ value: any
206
+ }
207
+ }>
208
+ }
209
+ >
210
+ }
@@ -110,7 +110,7 @@ Default property:
110
110
  audios?: Array<string | DataLink> | DataLink
111
111
  /* Tool call parser */
112
112
  toolCallParser?: 'llama3_json' | 'mistral' | 'hermes' | 'internlm' | 'phi4' | DataLink
113
- /* Tools for chat mode using OpenAI-compatible function calling format
113
+ /* Tools for chat mode using OpenAI-compatible function calling format
114
114
  Format: Array of objects with {type, function: {name, description, parameters}} structure
115
115
  See: https://platform.openai.com/docs/guides/function-calling */
116
116
  tools?: Array<{} | DataLink> | DataLink
@@ -132,12 +132,12 @@ Default property:
132
132
  numBeams?: number | DataLink
133
133
  /* Do sampling */
134
134
  doSample?: boolean | DataLink
135
- /* Executor candidates, descending order of priority
135
+ /* Executor candidates, descending order of priority
136
136
  Default will be xnnpack, wasm, cpu */
137
137
  executors?:
138
138
  | Array<'qnn' | 'dml' | 'nnapi' | 'xnnpack' | 'coreml' | 'cpu' | 'wasm' | 'webgpu' | DataLink>
139
139
  | DataLink
140
- /* Execution mode
140
+ /* Execution mode
141
141
  Usually when the model has many branches, setting this option to `parallel` will give you better performance. */
142
142
  executionMode?: 'sequential' | 'parallel' | DataLink
143
143
  /* QNN backend */
@@ -159,22 +159,31 @@ Default property:
159
159
  }
160
160
  outlets?: {
161
161
  /* Context state */
162
- contextState?: () => Data
162
+ contextState?: () => Data<string>
163
163
  /* Generated output */
164
- generated?: () => Data
164
+ generated?: () => Data<string>
165
165
  /* Full result of generation */
166
- fullResult?: () => Data
166
+ fullResult?: () => Data<string>
167
167
  /* Last function call */
168
- lastFunctionCall?: () => Data
168
+ lastFunctionCall?: () => Data<{
169
+ id?: string
170
+ type?: string
171
+ function?: {
172
+ name?: string
173
+ arguments?: string
174
+ [key: string]: any
175
+ }
176
+ [key: string]: any
177
+ }>
169
178
  }
170
179
  }
171
180
 
172
- /* Local LLM inference based on [transformers.js](https://huggingface.co/docs/transformers.js)
181
+ /* Local LLM inference based on [transformers.js](https://huggingface.co/docs/transformers.js)
173
182
  You can use any converted model on HuggingFace. */
174
183
  export type GeneratorOnnxLLM = Generator &
175
184
  GeneratorOnnxLLMDef & {
176
185
  templateKey: 'GENERATOR_ONNX_LLM'
177
- switches: Array<
186
+ switches?: Array<
178
187
  SwitchDef &
179
188
  GeneratorOnnxLLMDef & {
180
189
  conds?: Array<{
@@ -122,7 +122,7 @@ Default property:
122
122
  }
123
123
  >
124
124
  | DataLink
125
- /* Tools for chat mode following OpenAI function calling format
125
+ /* Tools for chat mode following OpenAI function calling format
126
126
  Format: Array of objects with {type, function: {name, description, parameters}} structure
127
127
  See: https://platform.openai.com/docs/guides/function-calling */
128
128
  completionTools?: Array<{} | DataLink> | DataLink
@@ -167,15 +167,31 @@ Default property:
167
167
  }
168
168
  outlets?: {
169
169
  /* Evaluating outlet */
170
- isEvaluating?: () => Data
170
+ isEvaluating?: () => Data<boolean>
171
171
  /* Completion result outlet */
172
- completionResult?: () => Data
172
+ completionResult?: () => Data<string>
173
173
  /* Completion details outlet */
174
- completionDetails?: () => Data
174
+ completionDetails?: () => Data<{
175
+ text?: string
176
+ content?: string
177
+ finish_reason?: string
178
+ usage?: { [key: string]: any }
179
+ tool_calls?: Array<{
180
+ id?: string
181
+ type?: string
182
+ function?: {
183
+ name?: string
184
+ arguments?: string
185
+ [key: string]: any
186
+ }
187
+ [key: string]: any
188
+ }>
189
+ [key: string]: any
190
+ }>
175
191
  }
176
192
  }
177
193
 
178
- /* LLM inference using OpenAI-compatible API endpoints
194
+ /* LLM inference using OpenAI-compatible API endpoints
179
195
 
180
196
  ## Features
181
197
  - Compatible with OpenAI API format
@@ -189,7 +205,7 @@ Default property:
189
205
  export type GeneratorOpenAILLM = Generator &
190
206
  GeneratorOpenAILLMDef & {
191
207
  templateKey: 'GENERATOR_OPENAI_LLM'
192
- switches: Array<
208
+ switches?: Array<
193
209
  SwitchDef &
194
210
  GeneratorOpenAILLMDef & {
195
211
  conds?: Array<{
@@ -108,7 +108,7 @@ Default property:
108
108
  | DataLink
109
109
  /* SOC model */
110
110
  socModel?: 'X Elite' | 'X Plus' | '8 Elite' | '8 Gen 3' | 'QCS8550' | DataLink
111
- /* Custom model base URL
111
+ /* Custom model base URL
112
112
  The model should be bundled, for details see https://github.com/mybigday/node-qnn-llm?tab=readme-ov-file#bundled-file */
113
113
  customModelUrl?: string | DataLink
114
114
  /* Custom model MD5 */
@@ -142,7 +142,7 @@ Default property:
142
142
  stopWords?: Array<string | DataLink> | DataLink
143
143
  /* Tool call parser */
144
144
  toolCallParser?: 'llama3_json' | 'mistral' | 'hermes' | 'internlm' | 'phi4' | DataLink
145
- /* Tools for chat mode using OpenAI-compatible function calling format
145
+ /* Tools for chat mode using OpenAI-compatible function calling format
146
146
  Format: Array of objects with {type, function: {name, description, parameters}} structure
147
147
  See: https://platform.openai.com/docs/guides/function-calling */
148
148
  tools?: Array<{} | DataLink> | DataLink
@@ -175,15 +175,39 @@ Default property:
175
175
  }
176
176
  outlets?: {
177
177
  /* Context state */
178
- contextState?: () => Data
178
+ contextState?: () => Data<string>
179
179
  /* Generation result */
180
- result?: () => Data
180
+ result?: () => Data<string>
181
181
  /* Full context (Prompt + Generation Result) */
182
- fullContext?: () => Data
182
+ fullContext?: () => Data<string>
183
183
  /* Last function call details */
184
- lastFunctionCall?: () => Data
184
+ lastFunctionCall?: () => Data<{
185
+ id?: string
186
+ type?: string
187
+ function?: {
188
+ name?: string
189
+ arguments?: string
190
+ [key: string]: any
191
+ }
192
+ [key: string]: any
193
+ }>
185
194
  /* Completion details */
186
- completionDetails?: () => Data
195
+ completionDetails?: () => Data<{
196
+ text?: string
197
+ content?: string
198
+ reasoning_content?: string
199
+ tool_calls?: Array<{
200
+ id?: string
201
+ type?: string
202
+ function?: {
203
+ name?: string
204
+ arguments?: string
205
+ [key: string]: any
206
+ }
207
+ [key: string]: any
208
+ }>
209
+ [key: string]: any
210
+ }>
187
211
  }
188
212
  }
189
213
 
@@ -191,7 +215,7 @@ Default property:
191
215
  export type GeneratorQnnLlm = Generator &
192
216
  GeneratorQnnLlmDef & {
193
217
  templateKey: 'GENERATOR_QNN_LLM'
194
- switches: Array<
218
+ switches?: Array<
195
219
  SwitchDef &
196
220
  GeneratorQnnLlmDef & {
197
221
  conds?: Array<{