@fugood/bricks-project 2.23.4 → 2.23.5-1

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 (90) hide show
  1. package/compile/action-name-map.ts +14 -0
  2. package/compile/index.ts +29 -0
  3. package/package.json +2 -2
  4. package/skills/bricks-project/rules/architecture-patterns.md +7 -0
  5. package/skills/bricks-project/rules/buttress.md +9 -6
  6. package/tools/mcp-tools/huggingface.ts +113 -3
  7. package/tools/postinstall.ts +113 -28
  8. package/types/animation.ts +4 -0
  9. package/types/automation.ts +3 -0
  10. package/types/bricks/Camera.ts +33 -6
  11. package/types/bricks/GenerativeMedia.ts +5 -5
  12. package/types/bricks/Icon.ts +2 -2
  13. package/types/bricks/Image.ts +3 -3
  14. package/types/bricks/Items.ts +6 -6
  15. package/types/bricks/Lottie.ts +3 -3
  16. package/types/bricks/Maps.ts +3 -3
  17. package/types/bricks/QrCode.ts +3 -3
  18. package/types/bricks/Rect.ts +3 -3
  19. package/types/bricks/RichText.ts +2 -2
  20. package/types/bricks/Slideshow.ts +1 -1
  21. package/types/bricks/Svg.ts +2 -2
  22. package/types/bricks/Text.ts +3 -3
  23. package/types/bricks/TextInput.ts +10 -6
  24. package/types/bricks/Video.ts +3 -3
  25. package/types/bricks/VideoStreaming.ts +2 -2
  26. package/types/bricks/WebView.ts +3 -3
  27. package/types/canvas.ts +2 -0
  28. package/types/common.ts +5 -0
  29. package/types/data-calc-command.ts +2 -0
  30. package/types/data-calc.ts +1 -0
  31. package/types/data.ts +2 -0
  32. package/types/generators/AlarmClock.ts +4 -4
  33. package/types/generators/Assistant.ts +53 -8
  34. package/types/generators/BleCentral.ts +11 -3
  35. package/types/generators/BlePeripheral.ts +3 -3
  36. package/types/generators/CanvasMap.ts +3 -3
  37. package/types/generators/CastlesPay.ts +2 -2
  38. package/types/generators/DataBank.ts +29 -2
  39. package/types/generators/File.ts +62 -13
  40. package/types/generators/GraphQl.ts +2 -2
  41. package/types/generators/Http.ts +25 -6
  42. package/types/generators/HttpServer.ts +4 -4
  43. package/types/generators/Information.ts +1 -1
  44. package/types/generators/Intent.ts +7 -1
  45. package/types/generators/Iterator.ts +5 -5
  46. package/types/generators/Keyboard.ts +15 -5
  47. package/types/generators/LlmAnthropicCompat.ts +9 -3
  48. package/types/generators/LlmAppleBuiltin.ts +4 -4
  49. package/types/generators/LlmGgml.ts +63 -13
  50. package/types/generators/LlmMlx.ts +210 -0
  51. package/types/generators/LlmOnnx.ts +13 -4
  52. package/types/generators/LlmOpenAiCompat.ts +19 -3
  53. package/types/generators/LlmQualcommAiEngine.ts +29 -5
  54. package/types/generators/Mcp.ts +331 -16
  55. package/types/generators/McpServer.ts +34 -7
  56. package/types/generators/MediaFlow.ts +24 -6
  57. package/types/generators/MqttBroker.ts +9 -3
  58. package/types/generators/MqttClient.ts +10 -4
  59. package/types/generators/Question.ts +4 -4
  60. package/types/generators/RealtimeTranscription.ts +81 -10
  61. package/types/generators/RerankerGgml.ts +19 -5
  62. package/types/generators/SerialPort.ts +5 -5
  63. package/types/generators/SoundPlayer.ts +1 -1
  64. package/types/generators/SoundRecorder.ts +16 -5
  65. package/types/generators/SpeechToTextGgml.ts +27 -7
  66. package/types/generators/SpeechToTextOnnx.ts +3 -3
  67. package/types/generators/SpeechToTextPlatform.ts +3 -3
  68. package/types/generators/SqLite.ts +9 -5
  69. package/types/generators/Step.ts +2 -2
  70. package/types/generators/SttAppleBuiltin.ts +4 -4
  71. package/types/generators/Tcp.ts +3 -3
  72. package/types/generators/TcpServer.ts +5 -5
  73. package/types/generators/TextToSpeechAppleBuiltin.ts +3 -3
  74. package/types/generators/TextToSpeechGgml.ts +3 -3
  75. package/types/generators/TextToSpeechOnnx.ts +3 -3
  76. package/types/generators/TextToSpeechOpenAiLike.ts +3 -3
  77. package/types/generators/ThermalPrinter.ts +4 -4
  78. package/types/generators/Tick.ts +2 -2
  79. package/types/generators/Udp.ts +8 -3
  80. package/types/generators/VadGgml.ts +34 -5
  81. package/types/generators/VadOnnx.ts +27 -4
  82. package/types/generators/VadTraditional.ts +13 -7
  83. package/types/generators/VectorStore.ts +22 -5
  84. package/types/generators/Watchdog.ts +10 -5
  85. package/types/generators/WebCrawler.ts +3 -3
  86. package/types/generators/WebRtc.ts +14 -8
  87. package/types/generators/WebSocket.ts +4 -4
  88. package/types/generators/index.ts +1 -0
  89. package/types/subspace.ts +1 -0
  90. package/utils/event-props.ts +104 -87
@@ -289,31 +289,80 @@ Default property:
289
289
  }
290
290
  outlets?: {
291
291
  /* File init error result will be stored in Data */
292
- initError?: () => Data
292
+ initError?: () => Data<string>
293
293
  /* File read stats result will be stored in Data */
294
- readStats?: () => Data
294
+ readStats?: () => Data<{
295
+ path?: string
296
+ size?: number
297
+ isDirectory?: boolean
298
+ mtime?: string
299
+ ctime?: string
300
+ mode?: number
301
+ originalFilepath?: string
302
+ [key: string]: any
303
+ }>
295
304
  /* File read content result will be stored in Data */
296
- readContent?: () => Data
305
+ readContent?: () => Data<any>
297
306
  /* File read details result will be stored in Data */
298
- readDetails?: () => Data
307
+ readDetails?: () => Data<{
308
+ path?: string
309
+ content?: any
310
+ size?: number
311
+ exists?: boolean
312
+ [key: string]: any
313
+ }>
299
314
  /* File read error result will be stored in Data */
300
- readError?: () => Data
315
+ readError?: () => Data<string>
301
316
  /* File append content result will be stored in Data */
302
- appendDetails?: () => Data
317
+ appendDetails?: () => Data<{
318
+ path?: string
319
+ appended?: boolean
320
+ contentLength?: number
321
+ [key: string]: any
322
+ }>
303
323
  /* File append error result will be stored in Data */
304
- appendError?: () => Data
324
+ appendError?: () => Data<string>
305
325
  /* File write details result will be stored in Data */
306
- writeDetails?: () => Data
326
+ writeDetails?: () => Data<{
327
+ path?: string
328
+ written?: boolean
329
+ contentLength?: number
330
+ [key: string]: any
331
+ }>
307
332
  /* File write error result will be stored in Data */
308
- writeError?: () => Data
333
+ writeError?: () => Data<string>
309
334
  /* File upload progress result will be stored in Data */
310
- uploadProgress?: () => Data
335
+ uploadProgress?: () => Data<{
336
+ id?: string
337
+ path?: string
338
+ uri?: string
339
+ hash?: string
340
+ hashType?: string
341
+ headers?: { [key: string]: any }
342
+ fields?: { [key: string]: any }
343
+ method?: string
344
+ progress?: number
345
+ isLastUpdated?: boolean
346
+ [key: string]: any
347
+ }>
311
348
  /* File upload complete result will be stored in Data */
312
- uploadResult?: () => Data
349
+ uploadResult?: () => Data<any>
313
350
  /* File download progress result will be stored in Data */
314
- downloadProgress?: () => Data
351
+ downloadProgress?: () => Data<{
352
+ id?: string
353
+ path?: string
354
+ uri?: string
355
+ hash?: string
356
+ hashType?: string
357
+ headers?: { [key: string]: any }
358
+ fields?: { [key: string]: any }
359
+ method?: string
360
+ progress?: number
361
+ isLastUpdated?: boolean
362
+ [key: string]: any
363
+ }>
315
364
  /* File download complete result will be stored in Data */
316
- downloadResult?: () => Data
365
+ downloadResult?: () => Data<any>
317
366
  }
318
367
  }
319
368
 
@@ -97,9 +97,9 @@ Default property:
97
97
  }
98
98
  outlets?: {
99
99
  /* Response for GraphQL request, it will save to Data */
100
- response?: () => Data
100
+ response?: () => Data<{ [key: string]: any }>
101
101
  /* Server response error of GraphQL request, it will save to Data */
102
- error?: () => Data
102
+ error?: () => Data<string>
103
103
  }
104
104
  }
105
105
 
@@ -156,17 +156,36 @@ Default property:
156
156
  events?: {}
157
157
  outlets?: {
158
158
  /* Response for HTTP request */
159
- response?: () => Data
159
+ response?: () => Data<string | { [key: string]: any }>
160
160
  /* Response details for HTTP request */
161
- responseDetails?: () => Data
161
+ responseDetails?: () => Data<{
162
+ ok?: boolean
163
+ redirected?: boolean
164
+ type?: string
165
+ status?: number
166
+ statusText?: string
167
+ headers?: { [key: string]: any }
168
+ body?: any
169
+ event?: string
170
+ id?: string
171
+ data?: any
172
+ [key: string]: any
173
+ }>
162
174
  /* All received data from event stream */
163
- eventLog?: () => Data
175
+ eventLog?: () => Data<Array<any>>
164
176
  /* All received event details from event stream */
165
- eventLogDetails?: () => Data
177
+ eventLogDetails?: () => Data<
178
+ Array<{
179
+ event?: string
180
+ id?: string
181
+ data?: any
182
+ [key: string]: any
183
+ }>
184
+ >
166
185
  /* EventSource state */
167
- sseState?: () => Data
186
+ sseState?: () => Data<string>
168
187
  /* Server response error of HTTP request */
169
- error?: () => Data
188
+ error?: () => Data<string>
170
189
  }
171
190
  }
172
191
 
@@ -135,13 +135,13 @@ Default property:
135
135
  }
136
136
  outlets?: {
137
137
  /* Server is listening */
138
- isListening?: () => Data
138
+ isListening?: () => Data<boolean>
139
139
  /* Query of request */
140
- requestQuery?: () => Data
140
+ requestQuery?: () => Data<{ [key: string]: any }>
141
141
  /* Body of request */
142
- requestBody?: () => Data
142
+ requestBody?: () => Data<any>
143
143
  /* Remote address of request */
144
- clientAddress?: () => Data
144
+ clientAddress?: () => Data<string>
145
145
  }
146
146
  }
147
147
 
@@ -72,7 +72,7 @@ Default property:
72
72
  }
73
73
  outlets?: {
74
74
  /* Error message */
75
- errorMessage?: () => Data
75
+ errorMessage?: () => Data<string>
76
76
  }
77
77
  }
78
78
 
@@ -131,7 +131,13 @@ Default property:
131
131
  }
132
132
  outlets?: {
133
133
  /* Last intent result */
134
- result?: () => Data
134
+ result?: () => Data<{
135
+ action?: string
136
+ data?: string
137
+ type?: string
138
+ extras?: { [key: string]: any }
139
+ [key: string]: any
140
+ }>
135
141
  }
136
142
  }
137
143
 
@@ -69,15 +69,15 @@ Default property:
69
69
  }
70
70
  outlets?: {
71
71
  /* Elements that have been iterated (including current one) */
72
- iteratedArray?: () => Data
72
+ iteratedArray?: () => Data<Array<any>>
73
73
  /* Elements that will be iterated but have not been iterated yet */
74
- upcomingArray?: () => Data
74
+ upcomingArray?: () => Data<Array<any>>
75
75
  /* Current iteration element */
76
- value?: () => Data
76
+ value?: () => Data<any>
77
77
  /* Key of the current iteration element (for number: same as value, for array/string: index, for object: string key) */
78
- key?: () => Data
78
+ key?: () => Data<any>
79
79
  /* Current iteration count (if data is 6 and step is 2, this will return: 1,2,3 in sequence) */
80
- index?: () => Data
80
+ index?: () => Data<number>
81
81
  }
82
82
  }
83
83
 
@@ -51,15 +51,25 @@ Default property:
51
51
  }
52
52
  outlets?: {
53
53
  /* Last key code pressed */
54
- lastKeyDown?: () => Data
54
+ lastKeyDown?: () => Data<string | number>
55
55
  /* Modifier key information on last key press */
56
- lastKeyDownFlags?: () => Data
56
+ lastKeyDownFlags?: () => Data<{ [key: string]: any }>
57
57
  /* Last key code released */
58
- lastKeyUp?: () => Data
58
+ lastKeyUp?: () => Data<string | number>
59
59
  /* Modifier key information on last key release */
60
- lastKeyUpFlags?: () => Data
60
+ lastKeyUpFlags?: () => Data<{ [key: string]: any }>
61
61
  /* Last batch event */
62
- lastBatchEvents?: () => Data
62
+ lastBatchEvents?: () => Data<
63
+ Array<{
64
+ event?: string
65
+ key?: any
66
+ keyNoMapping?: any
67
+ keyCode?: any
68
+ keyCodeNoMapping?: any
69
+ flags?: { [key: string]: any }
70
+ [key: string]: any
71
+ }>
72
+ >
63
73
  }
64
74
  }
65
75
 
@@ -153,11 +153,17 @@ Default property:
153
153
  }
154
154
  outlets?: {
155
155
  /* Evaluating outlet */
156
- isEvaluating?: () => Data
156
+ isEvaluating?: () => Data<boolean>
157
157
  /* Completion result outlet */
158
- completionResult?: () => Data
158
+ completionResult?: () => Data<string>
159
159
  /* Completion details outlet */
160
- completionDetails?: () => Data
160
+ completionDetails?: () => Data<{
161
+ model?: string
162
+ stop_reason?: string
163
+ usage?: { [key: string]: any }
164
+ content?: Array<any>
165
+ [key: string]: any
166
+ }>
161
167
  }
162
168
  }
163
169
 
@@ -100,13 +100,13 @@ Default property:
100
100
  }
101
101
  outlets?: {
102
102
  /* Context state outlet */
103
- contextState?: () => Data
103
+ contextState?: () => Data<string>
104
104
  /* Evaluating outlet */
105
- isEvaluating?: () => Data
105
+ isEvaluating?: () => Data<boolean>
106
106
  /* Completion result outlet */
107
- completionResult?: () => Data
107
+ completionResult?: () => Data<string>
108
108
  /* Last token outlet */
109
- completionLastToken?: () => Data
109
+ completionLastToken?: () => Data<string>
110
110
  }
111
111
  }
112
112
 
@@ -678,31 +678,81 @@ Default property:
678
678
  }
679
679
  outlets?: {
680
680
  /* Context state */
681
- contextState?: () => Data
681
+ contextState?: () => Data<string>
682
682
  /* Context load progress (0-100) */
683
- contextLoadProgress?: () => Data
683
+ contextLoadProgress?: () => Data<number>
684
684
  /* Context details */
685
- contextDetails?: () => Data
685
+ contextDetails?: () => Data<{
686
+ state?: string
687
+ contextId?: string
688
+ gpu?: string
689
+ reasonNoGPU?: string
690
+ model?: { [key: string]: any }
691
+ isMultimodalEnabled?: boolean
692
+ [key: string]: any
693
+ }>
686
694
  /* Session details */
687
- sessions?: () => Data
695
+ sessions?: () => Data<{
696
+ last_session_id?: string
697
+ sessions?: Array<{
698
+ id?: string
699
+ type?: string
700
+ prompt?: string
701
+ sessionKey?: string
702
+ model_instance_id?: string
703
+ tokens_evaluated?: number
704
+ t?: number
705
+ [key: string]: any
706
+ }>
707
+ last_custom_session_id?: string
708
+ custom_sessions?: Array<{
709
+ id?: string
710
+ type?: string
711
+ prompt?: string
712
+ sessionKey?: string
713
+ model_instance_id?: string
714
+ tokens_evaluated?: number
715
+ t?: number
716
+ [key: string]: any
717
+ }>
718
+ [key: string]: any
719
+ }>
688
720
  /* Is evaluating */
689
- isEvaluating?: () => Data
721
+ isEvaluating?: () => Data<boolean>
690
722
  /* Tokenize result */
691
- tokenizeResult?: () => Data
723
+ tokenizeResult?: () => Data<Array<number>>
692
724
  /* Detokenize result */
693
- detokenizeResult?: () => Data
725
+ detokenizeResult?: () => Data<string>
694
726
  /* Last formatted prompt (messages or prompt) */
695
- completionLastFormattedPrompt?: () => Data
727
+ completionLastFormattedPrompt?: () => Data<string>
696
728
  /* Last completion token */
697
- completionLastToken?: () => Data
729
+ completionLastToken?: () => Data<string>
698
730
  /* Completion result */
699
- completionResult?: () => Data
731
+ completionResult?: () => Data<string>
700
732
  /* Reasoning content from model responses */
701
- completionReasoningContent?: () => Data
733
+ completionReasoningContent?: () => Data<string>
702
734
  /* Full context (Prompt + Completion) */
703
- completionFullContext?: () => Data
735
+ completionFullContext?: () => Data<string>
704
736
  /* Inference result details */
705
- completionResultDetails?: () => Data
737
+ completionResultDetails?: () => Data<{
738
+ prompt?: string
739
+ full_context?: string
740
+ text?: string
741
+ content?: string
742
+ reasoning_content?: string
743
+ token?: string
744
+ tool_calls?: Array<{
745
+ id?: string
746
+ type?: string
747
+ function?: {
748
+ name?: string
749
+ arguments?: string
750
+ [key: string]: any
751
+ }
752
+ [key: string]: any
753
+ }>
754
+ [key: string]: any
755
+ }>
706
756
  }
707
757
  }
708
758
 
@@ -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
+ }
@@ -159,13 +159,22 @@ 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
 
@@ -167,11 +167,27 @@ 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