@fugood/bricks-project 2.24.0-beta.2 → 2.24.0-beta.21

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 (110) hide show
  1. package/compile/action-name-map.ts +14 -0
  2. package/compile/index.ts +377 -129
  3. package/package.json +8 -3
  4. package/skills/bricks-project/rules/architecture-patterns.md +7 -0
  5. package/skills/bricks-project/rules/automations.md +74 -28
  6. package/skills/bricks-project/rules/buttress.md +9 -6
  7. package/tools/deploy.ts +39 -10
  8. package/tools/mcp-server.ts +10 -877
  9. package/tools/mcp-tools/compile.ts +91 -0
  10. package/tools/mcp-tools/huggingface.ts +762 -0
  11. package/tools/mcp-tools/icons.ts +60 -0
  12. package/tools/mcp-tools/lottie.ts +102 -0
  13. package/tools/mcp-tools/media.ts +110 -0
  14. package/tools/postinstall.ts +121 -33
  15. package/tools/preview-main.mjs +12 -8
  16. package/tools/pull.ts +37 -19
  17. package/tsconfig.json +16 -0
  18. package/types/animation.ts +4 -0
  19. package/types/automation.ts +3 -0
  20. package/types/brick-base.ts +1 -1
  21. package/types/bricks/Camera.ts +34 -7
  22. package/types/bricks/Chart.ts +1 -1
  23. package/types/bricks/GenerativeMedia.ts +6 -6
  24. package/types/bricks/Icon.ts +3 -3
  25. package/types/bricks/Image.ts +4 -4
  26. package/types/bricks/Items.ts +7 -7
  27. package/types/bricks/Lottie.ts +4 -4
  28. package/types/bricks/Maps.ts +4 -4
  29. package/types/bricks/QrCode.ts +4 -4
  30. package/types/bricks/Rect.ts +4 -4
  31. package/types/bricks/RichText.ts +3 -3
  32. package/types/bricks/Rive.ts +1 -1
  33. package/types/bricks/Slideshow.ts +4 -4
  34. package/types/bricks/Svg.ts +3 -3
  35. package/types/bricks/Text.ts +4 -4
  36. package/types/bricks/TextInput.ts +11 -7
  37. package/types/bricks/Video.ts +4 -4
  38. package/types/bricks/VideoStreaming.ts +3 -3
  39. package/types/bricks/WebRtcStream.ts +1 -1
  40. package/types/bricks/WebView.ts +4 -4
  41. package/types/canvas.ts +4 -2
  42. package/types/common.ts +9 -4
  43. package/types/data-calc-command.ts +2 -0
  44. package/types/data-calc.ts +1 -0
  45. package/types/data.ts +2 -0
  46. package/types/generators/AlarmClock.ts +5 -5
  47. package/types/generators/Assistant.ts +57 -12
  48. package/types/generators/BleCentral.ts +12 -4
  49. package/types/generators/BlePeripheral.ts +5 -5
  50. package/types/generators/CanvasMap.ts +4 -4
  51. package/types/generators/CastlesPay.ts +3 -3
  52. package/types/generators/DataBank.ts +31 -4
  53. package/types/generators/File.ts +63 -14
  54. package/types/generators/GraphQl.ts +3 -3
  55. package/types/generators/Http.ts +27 -8
  56. package/types/generators/HttpServer.ts +9 -9
  57. package/types/generators/Information.ts +2 -2
  58. package/types/generators/Intent.ts +8 -2
  59. package/types/generators/Iterator.ts +6 -6
  60. package/types/generators/Keyboard.ts +18 -8
  61. package/types/generators/LlmAnthropicCompat.ts +12 -6
  62. package/types/generators/LlmAppleBuiltin.ts +6 -6
  63. package/types/generators/LlmGgml.ts +75 -25
  64. package/types/generators/LlmMlx.ts +210 -0
  65. package/types/generators/LlmOnnx.ts +18 -9
  66. package/types/generators/LlmOpenAiCompat.ts +22 -6
  67. package/types/generators/LlmQualcommAiEngine.ts +32 -8
  68. package/types/generators/Mcp.ts +332 -17
  69. package/types/generators/McpServer.ts +38 -11
  70. package/types/generators/MediaFlow.ts +26 -8
  71. package/types/generators/MqttBroker.ts +10 -4
  72. package/types/generators/MqttClient.ts +11 -5
  73. package/types/generators/Question.ts +6 -6
  74. package/types/generators/RealtimeTranscription.ts +70 -11
  75. package/types/generators/RerankerGgml.ts +23 -9
  76. package/types/generators/SerialPort.ts +6 -6
  77. package/types/generators/SoundPlayer.ts +2 -2
  78. package/types/generators/SoundRecorder.ts +5 -5
  79. package/types/generators/SpeechToTextGgml.ts +34 -14
  80. package/types/generators/SpeechToTextOnnx.ts +8 -8
  81. package/types/generators/SpeechToTextPlatform.ts +4 -4
  82. package/types/generators/SqLite.ts +10 -6
  83. package/types/generators/Step.ts +3 -3
  84. package/types/generators/SttAppleBuiltin.ts +6 -6
  85. package/types/generators/Tcp.ts +5 -5
  86. package/types/generators/TcpServer.ts +7 -7
  87. package/types/generators/TextToSpeechApple.ts +1 -1
  88. package/types/generators/TextToSpeechAppleBuiltin.ts +5 -5
  89. package/types/generators/TextToSpeechGgml.ts +8 -8
  90. package/types/generators/TextToSpeechOnnx.ts +9 -9
  91. package/types/generators/TextToSpeechOpenAiLike.ts +5 -5
  92. package/types/generators/ThermalPrinter.ts +6 -6
  93. package/types/generators/Tick.ts +3 -3
  94. package/types/generators/Udp.ts +9 -4
  95. package/types/generators/VadGgml.ts +39 -10
  96. package/types/generators/VadOnnx.ts +31 -8
  97. package/types/generators/VadTraditional.ts +15 -9
  98. package/types/generators/VectorStore.ts +26 -9
  99. package/types/generators/Watchdog.ts +11 -6
  100. package/types/generators/WebCrawler.ts +5 -5
  101. package/types/generators/WebRtc.ts +17 -11
  102. package/types/generators/WebSocket.ts +5 -5
  103. package/types/generators/index.ts +1 -0
  104. package/types/subspace.ts +1 -0
  105. package/types/system.ts +1 -1
  106. package/utils/calc.ts +12 -8
  107. package/utils/event-props.ts +104 -87
  108. package/utils/id.ts +4 -0
  109. package/api/index.ts +0 -1
  110. package/api/instance.ts +0 -213
@@ -0,0 +1,91 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js'
2
+ import { z } from 'zod'
3
+ import { $ } from 'bun'
4
+
5
+ export function register(server: McpServer, projectDir: string) {
6
+ const { dirname } = import.meta
7
+
8
+ server.tool('compile', {}, async () => {
9
+ let log = ''
10
+ try {
11
+ log += 'Type checking & Compiling...'
12
+ log += await $`bun compile`.cwd(projectDir).text()
13
+ } catch (err) {
14
+ log += `${err.stdout.toString()}\n${err.stderr.toString()}`
15
+ }
16
+ return {
17
+ content: [{ type: 'text', text: log }],
18
+ }
19
+ })
20
+
21
+ server.tool(
22
+ 'preview',
23
+ {
24
+ delay: z
25
+ .number()
26
+ .describe('Delay in milliseconds before taking screenshot')
27
+ .optional()
28
+ .default(3000),
29
+ width: z.number().describe('Width of the screenshot').optional().default(600),
30
+ height: z.number().optional().default(480),
31
+ responseImage: z
32
+ .boolean()
33
+ .describe(
34
+ 'Whether to response image content (base64 encoded jpeg). If false, only saved path will be responded as text.',
35
+ )
36
+ .optional()
37
+ .default(false),
38
+ testId: z.string().describe('Automation test ID to trigger').optional(),
39
+ testTitleLike: z
40
+ .string()
41
+ .describe('Find automation test by partial title match (case-insensitive)')
42
+ .optional(),
43
+ } as any,
44
+ async ({ delay, width, height, responseImage, testId, testTitleLike }: any) => {
45
+ let log = ''
46
+ let error = false
47
+ try {
48
+ const toolsDir = `${dirname}/..`
49
+ const args = [
50
+ '--no-keep-open',
51
+ '--take-screenshot',
52
+ JSON.stringify({
53
+ delay,
54
+ width,
55
+ height,
56
+ path: `${toolsDir}/screenshot.jpg`,
57
+ closeAfter: true,
58
+ headless: true,
59
+ }),
60
+ ]
61
+ if (testId) args.push('--test-id', testId)
62
+ if (testTitleLike) args.push('--test-title-like', testTitleLike)
63
+ log = await $`bunx --bun electron ${toolsDir}/preview-main.mjs ${args}`
64
+ .cwd(projectDir)
65
+ .text()
66
+ } catch (err) {
67
+ log = `${err.stdout.toString()}\n${err.stderr.toString()}`
68
+ error = true
69
+ }
70
+ let screenshotBase64: string | null = null
71
+ if (!error && responseImage) {
72
+ const toolsDir = `${dirname}/..`
73
+ const screenshot = await Bun.file(`${toolsDir}/screenshot.jpg`).arrayBuffer()
74
+ screenshotBase64 = Buffer.from(screenshot).toString('base64')
75
+ }
76
+ const content: Array<
77
+ { type: 'text'; text: string } | { type: 'image'; data: string; mimeType: string }
78
+ > = [{ type: 'text', text: log }]
79
+ if (screenshotBase64) {
80
+ content.push({
81
+ type: 'image',
82
+ data: screenshotBase64,
83
+ mimeType: 'image/jpeg',
84
+ })
85
+ }
86
+ return {
87
+ content,
88
+ }
89
+ },
90
+ )
91
+ }