@fugood/bricks-project 2.24.0-beta.4 → 2.24.0-beta.41

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 (126) hide show
  1. package/compile/action-name-map.ts +38 -0
  2. package/compile/index.ts +429 -160
  3. package/compile/util.ts +2 -0
  4. package/package.json +7 -3
  5. package/package.json.bak +27 -0
  6. package/skills/{bricks-project → bricks-ctor}/SKILL.md +2 -2
  7. package/skills/{bricks-project → bricks-ctor}/rules/animation.md +1 -1
  8. package/skills/{bricks-project → bricks-ctor}/rules/architecture-patterns.md +7 -0
  9. package/skills/bricks-ctor/rules/automations.md +221 -0
  10. package/skills/{bricks-project → bricks-ctor}/rules/buttress.md +10 -7
  11. package/skills/{bricks-project → bricks-ctor}/rules/data-calculation.md +1 -1
  12. package/skills/{bricks-project → bricks-ctor}/rules/local-sync.md +2 -2
  13. package/skills/{bricks-project → bricks-ctor}/rules/media-flow.md +3 -3
  14. package/skills/{bricks-project → bricks-ctor}/rules/remote-data-bank.md +6 -6
  15. package/skills/{bricks-project → bricks-ctor}/rules/standby-transition.md +1 -1
  16. package/skills/bricks-design/LICENSE.txt +180 -0
  17. package/skills/bricks-design/SKILL.md +66 -0
  18. package/tools/deploy.ts +66 -12
  19. package/tools/icons/fa6pro-meta.json +3669 -26125
  20. package/tools/mcp-server.ts +11 -878
  21. package/tools/mcp-tools/compile.ts +91 -0
  22. package/tools/mcp-tools/huggingface.ts +762 -0
  23. package/tools/mcp-tools/icons.ts +70 -0
  24. package/tools/mcp-tools/lottie.ts +102 -0
  25. package/tools/mcp-tools/media.ts +110 -0
  26. package/tools/postinstall.ts +137 -40
  27. package/tools/preview-main.mjs +146 -9
  28. package/tools/preview.ts +30 -2
  29. package/tools/pull.ts +37 -19
  30. package/tsconfig.json +16 -0
  31. package/types/animation.ts +4 -0
  32. package/types/automation.ts +4 -1
  33. package/types/brick-base.ts +1 -1
  34. package/types/bricks/Camera.ts +48 -13
  35. package/types/bricks/Chart.ts +10 -4
  36. package/types/bricks/GenerativeMedia.ts +30 -14
  37. package/types/bricks/Icon.ts +9 -5
  38. package/types/bricks/Image.ts +10 -6
  39. package/types/bricks/Items.ts +29 -15
  40. package/types/bricks/Lottie.ts +15 -7
  41. package/types/bricks/Maps.ts +16 -8
  42. package/types/bricks/QrCode.ts +9 -5
  43. package/types/bricks/Rect.ts +45 -6
  44. package/types/bricks/RichText.ts +9 -5
  45. package/types/bricks/Rive.ts +21 -11
  46. package/types/bricks/Slideshow.ts +20 -10
  47. package/types/bricks/Svg.ts +8 -4
  48. package/types/bricks/Text.ts +9 -5
  49. package/types/bricks/TextInput.ts +23 -13
  50. package/types/bricks/Video.ts +11 -7
  51. package/types/bricks/VideoStreaming.ts +8 -4
  52. package/types/bricks/WebRtcStream.ts +7 -3
  53. package/types/bricks/WebView.ts +12 -8
  54. package/types/canvas.ts +4 -2
  55. package/types/common.ts +19 -12
  56. package/types/data-calc-command.ts +2 -0
  57. package/types/data-calc.ts +1 -0
  58. package/types/data.ts +2 -0
  59. package/types/generators/AlarmClock.ts +17 -11
  60. package/types/generators/Assistant.ts +69 -18
  61. package/types/generators/BleCentral.ts +31 -11
  62. package/types/generators/BlePeripheral.ts +11 -7
  63. package/types/generators/CanvasMap.ts +10 -6
  64. package/types/generators/CastlesPay.ts +15 -7
  65. package/types/generators/DataBank.ts +44 -9
  66. package/types/generators/File.ts +109 -30
  67. package/types/generators/GraphQl.ts +12 -6
  68. package/types/generators/Http.ts +33 -10
  69. package/types/generators/HttpServer.ts +23 -15
  70. package/types/generators/Information.ts +9 -5
  71. package/types/generators/Intent.ts +15 -5
  72. package/types/generators/Iterator.ts +15 -11
  73. package/types/generators/Keyboard.ts +27 -13
  74. package/types/generators/LlmAnthropicCompat.ts +33 -11
  75. package/types/generators/LlmAppleBuiltin.ts +25 -10
  76. package/types/generators/LlmGgml.ts +140 -31
  77. package/types/generators/LlmMediaTekNeuroPilot.ts +235 -0
  78. package/types/generators/LlmMlx.ts +227 -0
  79. package/types/generators/LlmOnnx.ts +34 -14
  80. package/types/generators/LlmOpenAiCompat.ts +47 -11
  81. package/types/generators/LlmQualcommAiEngine.ts +45 -13
  82. package/types/generators/Mcp.ts +375 -34
  83. package/types/generators/McpServer.ts +58 -19
  84. package/types/generators/MediaFlow.ts +38 -12
  85. package/types/generators/MqttBroker.ts +29 -11
  86. package/types/generators/MqttClient.ts +19 -9
  87. package/types/generators/Question.ts +13 -9
  88. package/types/generators/RealtimeTranscription.ts +108 -19
  89. package/types/generators/RerankerGgml.ts +43 -12
  90. package/types/generators/SerialPort.ts +18 -10
  91. package/types/generators/SoundPlayer.ts +10 -4
  92. package/types/generators/SoundRecorder.ts +24 -9
  93. package/types/generators/SpeechToTextGgml.ts +52 -18
  94. package/types/generators/SpeechToTextOnnx.ts +18 -11
  95. package/types/generators/SpeechToTextPlatform.ts +15 -7
  96. package/types/generators/SqLite.ts +20 -10
  97. package/types/generators/Step.ts +9 -5
  98. package/types/generators/SttAppleBuiltin.ts +22 -9
  99. package/types/generators/Tcp.ts +13 -9
  100. package/types/generators/TcpServer.ts +20 -14
  101. package/types/generators/TextToSpeechAppleBuiltin.ts +21 -8
  102. package/types/generators/TextToSpeechGgml.ts +29 -11
  103. package/types/generators/TextToSpeechOnnx.ts +19 -12
  104. package/types/generators/TextToSpeechOpenAiLike.ts +14 -8
  105. package/types/generators/ThermalPrinter.ts +13 -9
  106. package/types/generators/Tick.ts +11 -7
  107. package/types/generators/Udp.ts +17 -8
  108. package/types/generators/VadGgml.ts +51 -14
  109. package/types/generators/VadOnnx.ts +42 -12
  110. package/types/generators/VadTraditional.ts +28 -13
  111. package/types/generators/VectorStore.ts +33 -12
  112. package/types/generators/Watchdog.ts +19 -10
  113. package/types/generators/WebCrawler.ts +11 -7
  114. package/types/generators/WebRtc.ts +30 -16
  115. package/types/generators/WebSocket.ts +11 -7
  116. package/types/generators/index.ts +2 -0
  117. package/types/subspace.ts +3 -0
  118. package/types/system.ts +1 -1
  119. package/utils/calc.ts +12 -8
  120. package/utils/event-props.ts +833 -1022
  121. package/utils/id.ts +4 -0
  122. package/api/index.ts +0 -1
  123. package/api/instance.ts +0 -213
  124. package/skills/bricks-project/rules/automations.md +0 -175
  125. package/types/generators/TextToSpeechApple.ts +0 -113
  126. package/types/generators/TtsAppleBuiltin.ts +0 -105
@@ -1,4 +1,17 @@
1
- /* Auto generated by build script */
1
+ /* Auto generated by build script
2
+ *
3
+ * Local Large Language Model (LLM) inference based on GGML and [llama.cpp](https://github.com/ggerganov/llama.cpp)
4
+ *
5
+ * ## Notice
6
+ * - The device RAM must be larger than 8GB
7
+ * - iOS: Recommended use M1+ / A17+ chip device. Supported GPU acceleration by Metal.
8
+ * - macOS: Recommended use M1+ chip device. Supported GPU acceleration by Metal.
9
+ * - Android: Recommended use Android 13+ system.
10
+ * - Supported GPU acceleration by OpenCL, currently only for Qualcomm Adreno 700+ GPUs, other GPUs are not supported.
11
+ * - Supported Hexagon NPU for Qualcomm Snapdragon 8 Gen 1+ GPUs.
12
+ * - Linux / Windows [@nextline - Supported GPU acceleration, you can choose `vulkan` or `cuda` backend in Accel Variant property
13
+ * - Supported Hexagon NPU for Qualcomm Dragonwing IQ9 series+ (Linux)
14
+ */
2
15
  import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
3
16
  import type { Data, DataLink } from '../data'
4
17
  import type {
@@ -10,6 +23,7 @@ import type {
10
23
  Action,
11
24
  EventProperty,
12
25
  } from '../common'
26
+ import type { TemplateEventPropsMap } from '../../utils/event-props'
13
27
 
14
28
  /* Load the model */
15
29
  export type GeneratorLLMActionLoadModel = Action & {
@@ -97,6 +111,16 @@ export type GeneratorLLMActionProcessPrompt = ActionWithParams & {
97
111
  value?: boolean | DataLink | EventProperty
98
112
  mapping?: string
99
113
  }
114
+ | {
115
+ input: 'thinkingBudgetTokens'
116
+ value?: number | DataLink | EventProperty
117
+ mapping?: string
118
+ }
119
+ | {
120
+ input: 'thinkingBudgetMessage'
121
+ value?: string | DataLink | EventProperty
122
+ mapping?: string
123
+ }
100
124
  | {
101
125
  input: 'prompt'
102
126
  value?: string | DataLink | EventProperty
@@ -137,6 +161,11 @@ export type GeneratorLLMActionProcessPrompt = ActionWithParams & {
137
161
  value?: string | DataLink | EventProperty
138
162
  mapping?: string
139
163
  }
164
+ | {
165
+ input: 'forcePureContent'
166
+ value?: boolean | DataLink | EventProperty
167
+ mapping?: string
168
+ }
140
169
  >
141
170
  }
142
171
 
@@ -179,6 +208,16 @@ export type GeneratorLLMActionCompletion = ActionWithParams & {
179
208
  value?: boolean | DataLink | EventProperty
180
209
  mapping?: string
181
210
  }
211
+ | {
212
+ input: 'thinkingBudgetTokens'
213
+ value?: number | DataLink | EventProperty
214
+ mapping?: string
215
+ }
216
+ | {
217
+ input: 'thinkingBudgetMessage'
218
+ value?: string | DataLink | EventProperty
219
+ mapping?: string
220
+ }
182
221
  | {
183
222
  input: 'useReasoningFormat'
184
223
  value?: string | DataLink | EventProperty
@@ -224,6 +263,11 @@ export type GeneratorLLMActionCompletion = ActionWithParams & {
224
263
  value?: string | DataLink | EventProperty
225
264
  mapping?: string
226
265
  }
266
+ | {
267
+ input: 'forcePureContent'
268
+ value?: boolean | DataLink | EventProperty
269
+ mapping?: string
270
+ }
227
271
  | {
228
272
  input: 'grammar'
229
273
  value?: string | DataLink | EventProperty
@@ -432,6 +476,7 @@ Default property:
432
476
  "completionEnableThinking": true,
433
477
  "completionAddGenerationPrompt": true,
434
478
  "completionChatTemplateKwargs": {},
479
+ "completionForcePureContent": false,
435
480
  "completionUseReasoningFormat": "auto",
436
481
  "completionStopWords": [],
437
482
  "completionPredict": 400,
@@ -459,10 +504,10 @@ Default property:
459
504
  }
460
505
  */
461
506
  property?: {
462
- /* Initialize the Llama context on generator initialization
507
+ /* Initialize the Llama context on generator initialization
463
508
  Please note that it will take some RAM depending on the model size */
464
509
  init?: boolean | DataLink
465
- /* The URL or path of model
510
+ /* The URL or path of model
466
511
  We used GGUF format model, please refer to https://github.com/ggerganov/llama.cpp/tree/master#description */
467
512
  modelUrl?: string | DataLink
468
513
  /* Hash type of model */
@@ -477,10 +522,10 @@ Default property:
477
522
  mmprojHashType?: 'md5' | 'sha256' | 'sha1' | DataLink
478
523
  /* Hash of mmproj file (PREVIEW FEATURE) */
479
524
  mmprojHash?: string | DataLink
480
- /* Minimum tokens for image encoding in multimodal (PREVIEW FEATURE)
525
+ /* Minimum tokens for image encoding in multimodal (PREVIEW FEATURE)
481
526
  Useful for dynamic resolution models (e.g. Qwen-VL). Default: -1 (auto) */
482
527
  imageMinTokens?: number | DataLink
483
- /* Maximum tokens for image encoding in multimodal (PREVIEW FEATURE)
528
+ /* Maximum tokens for image encoding in multimodal (PREVIEW FEATURE)
484
529
  Limit tokens for dynamic resolution models to balance speed vs. detail. Default: -1 (auto) */
485
530
  imageMaxTokens?: number | DataLink
486
531
  /* Chat Template (Jinja format) to override the default template from model */
@@ -493,13 +538,13 @@ Default property:
493
538
  uBatchSize?: number | DataLink
494
539
  /* Number of threads */
495
540
  maxThreads?: number | DataLink
496
- /* Accelerator variant (Only for desktop)
541
+ /* Accelerator variant (Only for desktop)
497
542
  `default` - CPU / Metal (macOS)
498
543
  `vulkan` - Use Vulkan
499
544
  `cuda` - Use CUDA
500
545
  `snapdragon` - Use OpenCL/Hexagon of Qualcomm Snapdragon */
501
546
  accelVariant?: 'default' | 'vulkan' | 'cuda' | 'snapdragon' | DataLink
502
- /* Devices. For example:
547
+ /* Devices. For example:
503
548
 
504
549
  Metal or CPU for iOS/tvOS/MacOS
505
550
  OpenCL or CPU for Android
@@ -514,6 +559,8 @@ Default property:
514
559
  useMlock?: boolean | DataLink
515
560
  /* Use mmap */
516
561
  useMmap?: boolean | DataLink
562
+ /* Disable extra buffer types for weight repacking. Reduces memory usage at the cost of slower prompt processing. */
563
+ noExtraBuffs?: boolean | DataLink
517
564
  /* Use Flash Attention for inference (Recommended with GPU enabled) */
518
565
  useFlashAttn?: 'auto' | 'on' | 'off' | DataLink
519
566
  /* KV cache data type for the K (Default: f16) */
@@ -534,7 +581,7 @@ Default property:
534
581
  transformScriptCode?: string | DataLink
535
582
  /* Variables used in Transform Script (object) */
536
583
  transformScriptVariables?: {} | DataLink
537
- /* Session save mode
584
+ /* Session save mode
538
585
  `none` - No session saving
539
586
  `prompt` - Save session when prompt processed
540
587
  `completion` - Save session when completion finished
@@ -546,7 +593,7 @@ Default property:
546
593
  sessionRemain?: number | DataLink
547
594
  /* TODO:loran_gqarms_norm_epsrope_freq_baserope_freq_scale */
548
595
  completionMode?: 'auto' | 'chat' | 'text' | DataLink
549
- /* Tools for chat mode using OpenAI-compatible function calling format
596
+ /* Tools for chat mode using OpenAI-compatible function calling format
550
597
  Format: Array of objects with {type, function: {name, description, parameters}} structure
551
598
  See: https://platform.openai.com/docs/guides/function-calling */
552
599
  completionTools?: Array<{} | DataLink> | DataLink
@@ -566,7 +613,7 @@ Default property:
566
613
  | DataLink
567
614
  /* Prompt (text mode) */
568
615
  completionPrompt?: string | DataLink
569
- /* Media paths to be used in the prompt template (PREVIEW FEATURE)
616
+ /* Media paths to be used in the prompt template (PREVIEW FEATURE)
570
617
  In prompt, use `<__media__>` for position of media content */
571
618
  completionPromptMediaPaths?: Array<string | DataLink> | DataLink
572
619
  /* Data to be used in the prompt template (e.g. `Hello ${name}`). Supports nested data, such as `Hello ${user.name}`. */
@@ -588,13 +635,19 @@ Default property:
588
635
  }
589
636
  /* Enable thinking */
590
637
  completionEnableThinking?: boolean | DataLink
638
+ /* Maximum tokens allowed inside the model's thinking block before forcing it closed. Only applies when chat formatting exposes thinking tags. */
639
+ completionThinkingBudgetTokens?: number | DataLink
640
+ /* Message injected before the thinking end tag when the thinking budget is exhausted. */
641
+ completionThinkingBudgetMessage?: string | DataLink
591
642
  /* Add generation prompt */
592
643
  completionAddGenerationPrompt?: boolean | DataLink
593
644
  /* Now (for fill current date in chat template if supported) */
594
645
  completionNow?: string | DataLink
595
646
  /* Additional keyword arguments for chat template (object) */
596
647
  completionChatTemplateKwargs?: {} | DataLink
597
- /* Use reasoning format for enhanced response structure
648
+ /* Force pure content (accept any model that has a chat_template without requiring template validation) */
649
+ completionForcePureContent?: boolean | DataLink
650
+ /* Use reasoning format for enhanced response structure
598
651
  `auto` - Auto-determine the reasoning format of the model
599
652
  `none` - Disable reasoning format */
600
653
  completionUseReasoningFormat?: 'auto' | 'none' | DataLink
@@ -666,47 +719,103 @@ Default property:
666
719
  }
667
720
  events?: {
668
721
  /* Event triggered when context state changes */
669
- onContextStateChange?: Array<EventAction>
722
+ onContextStateChange?: Array<
723
+ EventAction<string & keyof TemplateEventPropsMap['Llm']['onContextStateChange']>
724
+ >
670
725
  /* Event triggered when error occurs */
671
- onError?: Array<EventAction>
726
+ onError?: Array<EventAction<string & keyof TemplateEventPropsMap['Llm']['onError']>>
672
727
  /* Event triggered when completion */
673
- onCompletion?: Array<EventAction>
728
+ onCompletion?: Array<EventAction<string & keyof TemplateEventPropsMap['Llm']['onCompletion']>>
674
729
  /* Event triggered when completion finished */
675
- onCompletionFinished?: Array<EventAction>
730
+ onCompletionFinished?: Array<
731
+ EventAction<string & keyof TemplateEventPropsMap['Llm']['onCompletionFinished']>
732
+ >
676
733
  /* Event triggered on get function call request */
677
- onCompletionFunctionCall?: Array<EventAction>
734
+ onCompletionFunctionCall?: Array<
735
+ EventAction<string & keyof TemplateEventPropsMap['Llm']['onCompletionFunctionCall']>
736
+ >
678
737
  }
679
738
  outlets?: {
680
739
  /* Context state */
681
- contextState?: () => Data
740
+ contextState?: () => Data<string>
682
741
  /* Context load progress (0-100) */
683
- contextLoadProgress?: () => Data
742
+ contextLoadProgress?: () => Data<number>
684
743
  /* Context details */
685
- contextDetails?: () => Data
744
+ contextDetails?: () => Data<{
745
+ state?: string
746
+ contextId?: string
747
+ gpu?: string
748
+ reasonNoGPU?: string
749
+ model?: { [key: string]: any }
750
+ isMultimodalEnabled?: boolean
751
+ [key: string]: any
752
+ }>
686
753
  /* Session details */
687
- sessions?: () => Data
754
+ sessions?: () => Data<{
755
+ last_session_id?: string
756
+ sessions?: Array<{
757
+ id?: string
758
+ type?: string
759
+ prompt?: string
760
+ sessionKey?: string
761
+ model_instance_id?: string
762
+ tokens_evaluated?: number
763
+ t?: number
764
+ [key: string]: any
765
+ }>
766
+ last_custom_session_id?: string
767
+ custom_sessions?: Array<{
768
+ id?: string
769
+ type?: string
770
+ prompt?: string
771
+ sessionKey?: string
772
+ model_instance_id?: string
773
+ tokens_evaluated?: number
774
+ t?: number
775
+ [key: string]: any
776
+ }>
777
+ [key: string]: any
778
+ }>
688
779
  /* Is evaluating */
689
- isEvaluating?: () => Data
780
+ isEvaluating?: () => Data<boolean>
690
781
  /* Tokenize result */
691
- tokenizeResult?: () => Data
782
+ tokenizeResult?: () => Data<Array<number>>
692
783
  /* Detokenize result */
693
- detokenizeResult?: () => Data
784
+ detokenizeResult?: () => Data<string>
694
785
  /* Last formatted prompt (messages or prompt) */
695
- completionLastFormattedPrompt?: () => Data
786
+ completionLastFormattedPrompt?: () => Data<string>
696
787
  /* Last completion token */
697
- completionLastToken?: () => Data
788
+ completionLastToken?: () => Data<string>
698
789
  /* Completion result */
699
- completionResult?: () => Data
790
+ completionResult?: () => Data<string>
700
791
  /* Reasoning content from model responses */
701
- completionReasoningContent?: () => Data
792
+ completionReasoningContent?: () => Data<string>
702
793
  /* Full context (Prompt + Completion) */
703
- completionFullContext?: () => Data
794
+ completionFullContext?: () => Data<string>
704
795
  /* Inference result details */
705
- completionResultDetails?: () => Data
796
+ completionResultDetails?: () => Data<{
797
+ prompt?: string
798
+ full_context?: string
799
+ text?: string
800
+ content?: string
801
+ reasoning_content?: string
802
+ token?: string
803
+ tool_calls?: Array<{
804
+ id?: string
805
+ type?: string
806
+ function?: {
807
+ name?: string
808
+ arguments?: string
809
+ [key: string]: any
810
+ }
811
+ [key: string]: any
812
+ }>
813
+ [key: string]: any
814
+ }>
706
815
  }
707
816
  }
708
817
 
709
- /* Local Large Language Model (LLM) inference based on GGML and [llama.cpp](https://github.com/ggerganov/llama.cpp)
818
+ /* Local Large Language Model (LLM) inference based on GGML and [llama.cpp](https://github.com/ggerganov/llama.cpp)
710
819
 
711
820
  ## Notice
712
821
  - The device RAM must be larger than 8GB
@@ -720,7 +829,7 @@ Default property:
720
829
  export type GeneratorLLM = Generator &
721
830
  GeneratorLLMDef & {
722
831
  templateKey: 'GENERATOR_LLM'
723
- switches: Array<
832
+ switches?: Array<
724
833
  SwitchDef &
725
834
  GeneratorLLMDef & {
726
835
  conds?: Array<{
@@ -0,0 +1,235 @@
1
+ /* Auto generated by build script
2
+ *
3
+ * On-device LLM inference using MediaTek NeuroPilot native SDK integration on Android
4
+ */
5
+ import type { SwitchCondInnerStateCurrentCanvas, SwitchCondData, SwitchDef } from '../switch'
6
+ import type { Data, DataLink } from '../data'
7
+ import type {
8
+ Brick,
9
+ Generator,
10
+ EventAction,
11
+ ActionWithDataParams,
12
+ ActionWithParams,
13
+ Action,
14
+ EventProperty,
15
+ } from '../common'
16
+ import type { TemplateEventPropsMap } from '../../utils/event-props'
17
+
18
+ /* Load or validate the NeuroPilot model context */
19
+ export type GeneratorNeuropilotLlmActionLoadModel = ActionWithParams & {
20
+ __actionName: 'GENERATOR_NEUROPILOT_LLM_LOAD_MODEL'
21
+ params?: Array<
22
+ | {
23
+ input: 'runnerPath'
24
+ value?: string | DataLink | EventProperty
25
+ mapping?: string
26
+ }
27
+ | {
28
+ input: 'configPath'
29
+ value?: string | DataLink | EventProperty
30
+ mapping?: string
31
+ }
32
+ | {
33
+ input: 'workingDirectory'
34
+ value?: string | DataLink | EventProperty
35
+ mapping?: string
36
+ }
37
+ | {
38
+ input: 'libraryPaths'
39
+ value?: Array<any> | DataLink | EventProperty
40
+ mapping?: string
41
+ }
42
+ | {
43
+ input: 'daemonHost'
44
+ value?: string | DataLink | EventProperty
45
+ mapping?: string
46
+ }
47
+ | {
48
+ input: 'daemonPort'
49
+ value?: number | DataLink | EventProperty
50
+ mapping?: string
51
+ }
52
+ | {
53
+ input: 'daemonSocketName'
54
+ value?: string | DataLink | EventProperty
55
+ mapping?: string
56
+ }
57
+ | {
58
+ input: 'daemonSocketNamespace'
59
+ value?: string | DataLink | EventProperty
60
+ mapping?: string
61
+ }
62
+ >
63
+ }
64
+
65
+ /* Run text generation with the current NeuroPilot context */
66
+ export type GeneratorNeuropilotLlmActionGenerate = ActionWithParams & {
67
+ __actionName: 'GENERATOR_NEUROPILOT_LLM_GENERATE'
68
+ params?: Array<
69
+ | {
70
+ input: 'prompt'
71
+ value?: string | DataLink | EventProperty
72
+ mapping?: string
73
+ }
74
+ | {
75
+ input: 'messages'
76
+ value?: Array<any> | DataLink | EventProperty
77
+ mapping?: string
78
+ }
79
+ | {
80
+ input: 'maxNewTokens'
81
+ value?: number | DataLink | EventProperty
82
+ mapping?: string
83
+ }
84
+ | {
85
+ input: 'preformatter'
86
+ value?: string | DataLink | EventProperty
87
+ mapping?: string
88
+ }
89
+ >
90
+ }
91
+
92
+ /* Abort an in-flight NeuroPilot generation request */
93
+ export type GeneratorNeuropilotLlmActionAbortGeneration = Action & {
94
+ __actionName: 'GENERATOR_NEUROPILOT_LLM_ABORT_GENERATION'
95
+ }
96
+
97
+ /* Release the current NeuroPilot context */
98
+ export type GeneratorNeuropilotLlmActionReleaseContext = Action & {
99
+ __actionName: 'GENERATOR_NEUROPILOT_LLM_RELEASE_CONTEXT'
100
+ }
101
+
102
+ interface GeneratorNeuropilotLlmDef {
103
+ /*
104
+ Default property:
105
+ {
106
+ "runnerPath": "/data/local/tmp/llm_sdk/main",
107
+ "configPath": "/data/local/tmp/llm_sdk/config_gemma2_2b_instruct.yaml",
108
+ "workingDirectory": "/data/local/tmp/llm_sdk",
109
+ "libraryPaths": [
110
+ "/vendor/lib64",
111
+ "/system_ext/lib64",
112
+ "/vendor/lib",
113
+ "/system_ext/lib"
114
+ ],
115
+ "runtimeMode": "auto",
116
+ "preformatter": "GemmaNoInput",
117
+ "maxNewTokens": 128
118
+ }
119
+ */
120
+ property?: {
121
+ /* Preloadable NeuroPilot model bundle preset */
122
+ modelBundle?:
123
+ | 'Gemma 2 2B Instruct'
124
+ | 'Gemma 2 2B Instruct (Tailpatched)'
125
+ | 'Gemma 2 2B Instruct (Tailpatched MDLA53)'
126
+ | 'Qwen 2.5 0.5B Instruct'
127
+ | 'Qwen 2.5 1.5B Instruct'
128
+ | 'Llama 3 8B Instruct'
129
+ | DataLink
130
+ /* Override base URL for NeuroPilot model bundle downloads */
131
+ modelBaseUrl?: string | DataLink
132
+ /* Validate runner/config paths on generator initialization */
133
+ init?: boolean | DataLink
134
+ /* Runner binary path on device */
135
+ runnerPath?: string | DataLink
136
+ /* YAML config path on device */
137
+ configPath?: string | DataLink
138
+ /* Working directory for the runner process */
139
+ workingDirectory?: string | DataLink
140
+ /* Extra library search paths for the runner process */
141
+ libraryPaths?: Array<string | DataLink> | DataLink
142
+ /* Daemon host for a preloaded NeuroPilot service */
143
+ daemonHost?: string | DataLink
144
+ /* Daemon TCP port for a preloaded NeuroPilot service */
145
+ daemonPort?: number | DataLink
146
+ /* Android local socket name for a privileged NeuroPilot service */
147
+ daemonSocketName?: string | DataLink
148
+ /* Android local socket namespace used by the privileged NeuroPilot service */
149
+ daemonSocketNamespace?: 'abstract' | 'reserved' | 'filesystem' | DataLink
150
+ /* Runtime selection strategy for MediaTek execution */
151
+ runtimeMode?: 'auto' | 'daemon' | 'root-runner' | 'native' | DataLink
152
+ /* Prompt preformatter used by the vendor runner */
153
+ preformatter?:
154
+ | 'AlpacaNoInput'
155
+ | 'OneShotConversation'
156
+ | 'VicunaNoInput'
157
+ | 'QwenNoInput'
158
+ | 'Qwen3NoInput'
159
+ | 'Qwen3NoInputNoThink'
160
+ | 'Llama3NoInput'
161
+ | 'Phi3NoInput'
162
+ | 'MinicpmNoInput'
163
+ | 'MinicpmNoInputZh'
164
+ | 'InternLM2'
165
+ | 'GemmaNoInput'
166
+ | DataLink
167
+ /* Prompt to run */
168
+ prompt?: string | DataLink
169
+ /* Chat messages to flatten into a prompt */
170
+ messages?: Array<DataLink | {}> | DataLink
171
+ /* Maximum tokens requested from the runner */
172
+ maxNewTokens?: number | DataLink
173
+ }
174
+ events?: {
175
+ /* Event triggered when the NeuroPilot context state changes */
176
+ onContextStateChange?: Array<
177
+ EventAction<string & keyof TemplateEventPropsMap['NeuropilotLlm']['onContextStateChange']>
178
+ >
179
+ /* Event triggered when a completion token or partial result is emitted */
180
+ onCompletion?: Array<
181
+ EventAction<string & keyof TemplateEventPropsMap['NeuropilotLlm']['onCompletion']>
182
+ >
183
+ /* Event triggered when generation finishes */
184
+ onCompletionFinished?: Array<
185
+ EventAction<string & keyof TemplateEventPropsMap['NeuropilotLlm']['onCompletionFinished']>
186
+ >
187
+ /* Event triggered when a NeuroPilot error occurs */
188
+ onError?: Array<EventAction<string & keyof TemplateEventPropsMap['NeuropilotLlm']['onError']>>
189
+ }
190
+ outlets?: {
191
+ /* Current NeuroPilot context state */
192
+ contextState?: () => Data<string>
193
+ /* Final generated result text */
194
+ result?: () => Data<string>
195
+ /* Full context returned by the runner */
196
+ fullContext?: () => Data<string>
197
+ /* Last emitted token or chunk */
198
+ lastToken?: () => Data<string>
199
+ /* Raw output captured from the NeuroPilot runner */
200
+ rawOutput?: () => Data<string>
201
+ /* Prompt-phase performance in tokens per second */
202
+ promptTokensPerSec?: () => Data<string>
203
+ /* Generation-phase performance in tokens per second */
204
+ generationTokensPerSec?: () => Data<string>
205
+ }
206
+ }
207
+
208
+ /* On-device LLM inference using MediaTek NeuroPilot native SDK integration on Android */
209
+ export type GeneratorNeuropilotLlm = Generator &
210
+ GeneratorNeuropilotLlmDef & {
211
+ templateKey: 'GENERATOR_NEUROPILOT_LLM'
212
+ switches?: Array<
213
+ SwitchDef &
214
+ GeneratorNeuropilotLlmDef & {
215
+ conds?: Array<{
216
+ method: '==' | '!=' | '>' | '<' | '>=' | '<='
217
+ cond:
218
+ | SwitchCondInnerStateCurrentCanvas
219
+ | SwitchCondData
220
+ | {
221
+ __typename: 'SwitchCondInnerStateOutlet'
222
+ outlet:
223
+ | 'contextState'
224
+ | 'result'
225
+ | 'fullContext'
226
+ | 'lastToken'
227
+ | 'rawOutput'
228
+ | 'promptTokensPerSec'
229
+ | 'generationTokensPerSec'
230
+ value: any
231
+ }
232
+ }>
233
+ }
234
+ >
235
+ }