@fugood/bricks-project 2.25.0-beta.4 → 2.25.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.
- package/compile/action-name-map.ts +64 -0
- package/compile/index.ts +208 -19
- package/package.json +4 -3
- package/package.json.bak +4 -3
- package/skills/bricks-ctor/SKILL.md +21 -17
- package/skills/bricks-ctor/{rules → references}/animation.md +3 -2
- package/skills/bricks-ctor/{rules → references}/architecture-patterns.md +12 -0
- package/skills/bricks-ctor/{rules → references}/automations.md +11 -0
- package/skills/bricks-ctor/references/buttress.md +245 -0
- package/skills/bricks-ctor/references/data-calculation.md +239 -0
- package/skills/bricks-ctor/references/simulator.md +131 -0
- package/skills/bricks-ctor/references/verification-toolchain.md +179 -0
- package/skills/bricks-design/SKILL.md +160 -45
- package/skills/bricks-design/references/architecture-truths.md +132 -0
- package/skills/bricks-design/references/avoiding-complexity.md +91 -0
- package/skills/bricks-design/references/design-critique.md +195 -0
- package/skills/bricks-design/references/design-languages.md +265 -0
- package/skills/bricks-design/references/performance.md +116 -0
- package/skills/bricks-design/references/presentation-and-slideshow.md +137 -0
- package/skills/bricks-design/references/translating-inputs.md +152 -0
- package/skills/bricks-design/references/variations-and-tweaks.md +124 -0
- package/skills/bricks-design/references/when-the-brief-is-branded.md +284 -0
- package/skills/bricks-design/references/when-the-brief-is-vague.md +85 -0
- package/skills/bricks-design/references/workflow.md +134 -0
- package/skills/bricks-ux/SKILL.md +120 -0
- package/skills/bricks-ux/references/accessibility.md +162 -0
- package/skills/bricks-ux/references/flow-states.md +175 -0
- package/skills/bricks-ux/references/interaction-archetypes.md +189 -0
- package/skills/bricks-ux/references/monitoring-screens.md +153 -0
- package/skills/bricks-ux/references/pressable-composition.md +126 -0
- package/skills/bricks-ux/references/user-journey.md +168 -0
- package/skills/bricks-ux/references/ux-critique.md +256 -0
- package/tools/_git-author.ts +10 -2
- package/tools/_last-pushed-commit.ts +28 -0
- package/tools/_shell.ts +8 -1
- package/tools/deploy.ts +15 -0
- package/tools/mcp-tools/compile.ts +19 -9
- package/tools/mcp-tools/media.ts +4 -1
- package/tools/pull.ts +91 -16
- package/tools/push-config.ts +118 -0
- package/tools/{preview-main.mjs → simulator-main.mjs} +207 -12
- package/tools/simulator-preload.cjs +16 -0
- package/tools/{preview.ts → simulator.ts} +4 -4
- package/types/{animation.ts → animation.d.ts} +24 -8
- package/types/{automation.ts → automation.d.ts} +16 -20
- package/types/{brick-base.ts → brick-base.d.ts} +1 -1
- package/types/bricks/{Camera.ts → Camera.d.ts} +8 -8
- package/types/bricks/{Chart.ts → Chart.d.ts} +4 -4
- package/types/bricks/{GenerativeMedia.ts → GenerativeMedia.d.ts} +15 -15
- package/types/bricks/{Icon.ts → Icon.d.ts} +7 -7
- package/types/bricks/{Image.ts → Image.d.ts} +21 -9
- package/types/bricks/{Items.ts → Items.d.ts} +7 -7
- package/types/bricks/{Lottie.ts → Lottie.d.ts} +10 -10
- package/types/bricks/{Maps.ts → Maps.d.ts} +11 -11
- package/types/bricks/{QrCode.ts → QrCode.d.ts} +7 -7
- package/types/bricks/{Rect.ts → Rect.d.ts} +7 -7
- package/types/bricks/{RichText.ts → RichText.d.ts} +12 -9
- package/types/bricks/{Rive.ts → Rive.d.ts} +9 -9
- package/types/bricks/Scene3D.d.ts +676 -0
- package/types/bricks/{Sketch.ts → Sketch.d.ts} +6 -6
- package/types/bricks/{Slideshow.ts → Slideshow.d.ts} +7 -7
- package/types/bricks/{Svg.ts → Svg.d.ts} +7 -7
- package/types/bricks/{Text.ts → Text.d.ts} +9 -9
- package/types/bricks/{TextInput.ts → TextInput.d.ts} +10 -10
- package/types/bricks/{Video.ts → Video.d.ts} +12 -12
- package/types/bricks/{VideoStreaming.ts → VideoStreaming.d.ts} +10 -10
- package/types/bricks/{WebRtcStream.ts → WebRtcStream.d.ts} +1 -1
- package/types/bricks/{WebView.ts → WebView.d.ts} +4 -4
- package/types/bricks/{index.ts → index.d.ts} +1 -0
- package/types/{common.ts → common.d.ts} +3 -6
- package/types/data-calc-command/base.d.ts +57 -0
- package/types/data-calc-command/collection.d.ts +418 -0
- package/types/data-calc-command/color.d.ts +432 -0
- package/types/data-calc-command/constant.d.ts +50 -0
- package/types/data-calc-command/datetime.d.ts +147 -0
- package/types/data-calc-command/file.d.ts +129 -0
- package/types/data-calc-command/index.d.ts +13 -0
- package/types/data-calc-command/iteratee.d.ts +23 -0
- package/types/data-calc-command/logictype.d.ts +190 -0
- package/types/data-calc-command/math.d.ts +275 -0
- package/types/data-calc-command/object.d.ts +119 -0
- package/types/data-calc-command/sandbox.d.ts +66 -0
- package/types/data-calc-command/string.d.ts +407 -0
- package/types/{data-calc.ts → data-calc.d.ts} +1 -0
- package/types/{data.ts → data.d.ts} +4 -2
- package/types/generators/{Assistant.ts → Assistant.d.ts} +19 -0
- package/types/generators/{LlmGgml.ts → LlmGgml.d.ts} +43 -1
- package/types/generators/{LlmMlx.ts → LlmMlx.d.ts} +1 -0
- package/types/generators/{RerankerGgml.ts → RerankerGgml.d.ts} +5 -1
- package/types/generators/{SoundRecorder.ts → SoundRecorder.d.ts} +10 -1
- package/types/generators/{SpeechToTextGgml.ts → SpeechToTextGgml.d.ts} +6 -1
- package/types/generators/{SttAppleBuiltin.ts → SttAppleBuiltin.d.ts} +27 -4
- package/types/generators/{ThermalPrinter.ts → ThermalPrinter.d.ts} +9 -7
- package/types/generators/{VadGgml.ts → VadGgml.d.ts} +12 -2
- package/types/{subspace.ts → subspace.d.ts} +1 -1
- package/utils/data.ts +2 -2
- package/utils/event-props.ts +17 -0
- package/utils/id.ts +78 -27
- package/skills/bricks-ctor/rules/buttress.md +0 -156
- package/skills/bricks-ctor/rules/data-calculation.md +0 -209
- package/skills/bricks-design/LICENSE.txt +0 -180
- package/types/data-calc-command.ts +0 -7005
- /package/skills/bricks-ctor/{rules → references}/local-sync.md +0 -0
- /package/skills/bricks-ctor/{rules → references}/media-flow.md +0 -0
- /package/skills/bricks-ctor/{rules → references}/remote-data-bank.md +0 -0
- /package/skills/bricks-ctor/{rules → references}/standby-transition.md +0 -0
- /package/types/{canvas.ts → canvas.d.ts} +0 -0
- /package/types/{data-calc-script.ts → data-calc-script.d.ts} +0 -0
- /package/types/generators/{AlarmClock.ts → AlarmClock.d.ts} +0 -0
- /package/types/generators/{BleCentral.ts → BleCentral.d.ts} +0 -0
- /package/types/generators/{BlePeripheral.ts → BlePeripheral.d.ts} +0 -0
- /package/types/generators/{CanvasMap.ts → CanvasMap.d.ts} +0 -0
- /package/types/generators/{CastlesPay.ts → CastlesPay.d.ts} +0 -0
- /package/types/generators/{DataBank.ts → DataBank.d.ts} +0 -0
- /package/types/generators/{File.ts → File.d.ts} +0 -0
- /package/types/generators/{GraphQl.ts → GraphQl.d.ts} +0 -0
- /package/types/generators/{Http.ts → Http.d.ts} +0 -0
- /package/types/generators/{HttpServer.ts → HttpServer.d.ts} +0 -0
- /package/types/generators/{Information.ts → Information.d.ts} +0 -0
- /package/types/generators/{Intent.ts → Intent.d.ts} +0 -0
- /package/types/generators/{Iterator.ts → Iterator.d.ts} +0 -0
- /package/types/generators/{Keyboard.ts → Keyboard.d.ts} +0 -0
- /package/types/generators/{LlmAnthropicCompat.ts → LlmAnthropicCompat.d.ts} +0 -0
- /package/types/generators/{LlmAppleBuiltin.ts → LlmAppleBuiltin.d.ts} +0 -0
- /package/types/generators/{LlmMediaTekNeuroPilot.ts → LlmMediaTekNeuroPilot.d.ts} +0 -0
- /package/types/generators/{LlmOnnx.ts → LlmOnnx.d.ts} +0 -0
- /package/types/generators/{LlmOpenAiCompat.ts → LlmOpenAiCompat.d.ts} +0 -0
- /package/types/generators/{LlmQualcommAiEngine.ts → LlmQualcommAiEngine.d.ts} +0 -0
- /package/types/generators/{Mcp.ts → Mcp.d.ts} +0 -0
- /package/types/generators/{McpServer.ts → McpServer.d.ts} +0 -0
- /package/types/generators/{MediaFlow.ts → MediaFlow.d.ts} +0 -0
- /package/types/generators/{MqttBroker.ts → MqttBroker.d.ts} +0 -0
- /package/types/generators/{MqttClient.ts → MqttClient.d.ts} +0 -0
- /package/types/generators/{Question.ts → Question.d.ts} +0 -0
- /package/types/generators/{RealtimeTranscription.ts → RealtimeTranscription.d.ts} +0 -0
- /package/types/generators/{SerialPort.ts → SerialPort.d.ts} +0 -0
- /package/types/generators/{SoundPlayer.ts → SoundPlayer.d.ts} +0 -0
- /package/types/generators/{SpeechToTextOnnx.ts → SpeechToTextOnnx.d.ts} +0 -0
- /package/types/generators/{SpeechToTextPlatform.ts → SpeechToTextPlatform.d.ts} +0 -0
- /package/types/generators/{SqLite.ts → SqLite.d.ts} +0 -0
- /package/types/generators/{Step.ts → Step.d.ts} +0 -0
- /package/types/generators/{Tcp.ts → Tcp.d.ts} +0 -0
- /package/types/generators/{TcpServer.ts → TcpServer.d.ts} +0 -0
- /package/types/generators/{TextToSpeechAppleBuiltin.ts → TextToSpeechAppleBuiltin.d.ts} +0 -0
- /package/types/generators/{TextToSpeechGgml.ts → TextToSpeechGgml.d.ts} +0 -0
- /package/types/generators/{TextToSpeechOnnx.ts → TextToSpeechOnnx.d.ts} +0 -0
- /package/types/generators/{TextToSpeechOpenAiLike.ts → TextToSpeechOpenAiLike.d.ts} +0 -0
- /package/types/generators/{Tick.ts → Tick.d.ts} +0 -0
- /package/types/generators/{Udp.ts → Udp.d.ts} +0 -0
- /package/types/generators/{VadOnnx.ts → VadOnnx.d.ts} +0 -0
- /package/types/generators/{VadTraditional.ts → VadTraditional.d.ts} +0 -0
- /package/types/generators/{VectorStore.ts → VectorStore.d.ts} +0 -0
- /package/types/generators/{Watchdog.ts → Watchdog.d.ts} +0 -0
- /package/types/generators/{WebCrawler.ts → WebCrawler.d.ts} +0 -0
- /package/types/generators/{WebRtc.ts → WebRtc.d.ts} +0 -0
- /package/types/generators/{WebSocket.ts → WebSocket.d.ts} +0 -0
- /package/types/generators/{index.ts → index.d.ts} +0 -0
- /package/types/{index.ts → index.d.ts} +0 -0
- /package/types/{switch.ts → switch.d.ts} +0 -0
- /package/types/{system.ts → system.d.ts} +0 -0
|
@@ -0,0 +1,245 @@
|
|
|
1
|
+
# Buttress (Remote Inference)
|
|
2
|
+
|
|
3
|
+
Backend system for offloading compute-intensive AI generator tasks from BRICKS devices to more powerful machines.
|
|
4
|
+
|
|
5
|
+
## Purpose
|
|
6
|
+
|
|
7
|
+
When mobile devices or embedded systems lack hardware for local AI inference (LLM, speech-to-text), Buttress transparently delegates work to a server with appropriate resources (GPU).
|
|
8
|
+
|
|
9
|
+
## How It Works
|
|
10
|
+
|
|
11
|
+
1. **Capability Exchange**: Client and server share hardware capabilities
|
|
12
|
+
2. **Strategy Selection**: System decides local vs. remote execution
|
|
13
|
+
3. **Transparent Offloading**: Generator operates same way, execution happens remotely
|
|
14
|
+
|
|
15
|
+
## Supported Generators
|
|
16
|
+
|
|
17
|
+
- LLM (GGML) (LlmMlx.ts) - Local Large Language Model inference with GGML
|
|
18
|
+
- LLM (MLX) (LlmGgml.ts) - Local Large Language Model inference with MLX
|
|
19
|
+
- Speech-to-Text (GGML) (SpeechToTextGgml.ts) - Local Speech-to-Text inference with GGML
|
|
20
|
+
|
|
21
|
+
## Client Configuration
|
|
22
|
+
|
|
23
|
+
In generator properties, configure `buttressConnectionSettings`:
|
|
24
|
+
|
|
25
|
+
| Setting | Description |
|
|
26
|
+
|---------|-------------|
|
|
27
|
+
| `enabled` | Toggle Buttress offloading |
|
|
28
|
+
| `autoDiscoverType` | `auto` (LAN auto-discovery, recommended) or `manual` (typed URL) |
|
|
29
|
+
| `url` | Server URL (`manual` mode only — leave empty for `auto`) |
|
|
30
|
+
| `fallbackType` | If Buttress is unreachable: `use-local` runs locally, `no-op` blocks the load |
|
|
31
|
+
| `strategy` | Execution preference (see below) |
|
|
32
|
+
|
|
33
|
+
The launcher provides the access token automatically — there is **no user-facing access-token setting**. In `auto` mode the launcher discovers servers bound to the device's workspace and uses its workspace-scoped JWT; in `manual` mode it sends the same JWT only when the typed URL belongs to a server bound to the same workspace (verified against the server's `/buttress/info`).
|
|
34
|
+
|
|
35
|
+
### `autoDiscoverType` options
|
|
36
|
+
|
|
37
|
+
| Mode | When to use | What the device does |
|
|
38
|
+
|------|-------------|----------------------|
|
|
39
|
+
| `auto` | LAN deployment with a workspace-bound buttress-server | Listens for UDP announcements and picks the strongest server bound to its workspace; reconnects automatically when the workspace flips |
|
|
40
|
+
| `manual` | Internet-reachable server, mixed networks, or a public/unbound server | Connects to the typed `url` directly; sends a token only when the server is bound to the same workspace |
|
|
41
|
+
|
|
42
|
+
### Strategy options
|
|
43
|
+
|
|
44
|
+
| Strategy | Description |
|
|
45
|
+
|----------|-------------|
|
|
46
|
+
| `prefer-local` | Use local if capable, fallback to Buttress |
|
|
47
|
+
| `prefer-buttress` | Use Buttress if available, fallback to local |
|
|
48
|
+
| `prefer-best` | Auto-select based on capability comparison |
|
|
49
|
+
|
|
50
|
+
## Generator Configuration Examples
|
|
51
|
+
|
|
52
|
+
### Auto-discovery (recommended)
|
|
53
|
+
|
|
54
|
+
Workspace-bound launcher + workspace-bound buttress-server on the same LAN. No URL needed — discovery picks the highest-scoring server that runs the requested backend.
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { makeId } from 'bricks-ctor'
|
|
58
|
+
|
|
59
|
+
const llmGenerator: GeneratorLLM = {
|
|
60
|
+
__typename: 'Generator',
|
|
61
|
+
templateKey: 'GENERATOR_LLM',
|
|
62
|
+
id: makeId('generator'),
|
|
63
|
+
title: 'Chat LLM',
|
|
64
|
+
description: '',
|
|
65
|
+
property: {
|
|
66
|
+
modelUrl: 'https://huggingface.co/ggml-org/gemma-3-12b-it-qat-GGUF/resolve/main/gemma-3-12b-it-qat-q4_0.gguf',
|
|
67
|
+
contextSize: 8192,
|
|
68
|
+
buttressConnectionSettings: {
|
|
69
|
+
enabled: true,
|
|
70
|
+
autoDiscoverType: 'auto',
|
|
71
|
+
fallbackType: 'use-local',
|
|
72
|
+
strategy: 'prefer-best',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
events: {},
|
|
76
|
+
switches: [],
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Manual URL
|
|
81
|
+
|
|
82
|
+
Use when the server isn't on the launcher's broadcast domain (cross-subnet, internet, behind a reverse proxy) or you want to point at a specific public/unbound server.
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
buttressConnectionSettings: {
|
|
86
|
+
enabled: true,
|
|
87
|
+
autoDiscoverType: 'manual',
|
|
88
|
+
url: 'http://192.168.1.100:2080',
|
|
89
|
+
fallbackType: 'use-local',
|
|
90
|
+
strategy: 'prefer-best',
|
|
91
|
+
}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
> ⚠️ With `fallbackType: 'no-op'` the generator refuses to load locally if Buttress is unreachable. Use `'use-local'` whenever the device can also run the model standalone.
|
|
95
|
+
|
|
96
|
+
## Integrating a discovered buttress-server
|
|
97
|
+
|
|
98
|
+
The ctor-desktop "Local Devices" panel (and the `bricks buttress scan` CLI) can hand you a server's identity, workspace, and announced generator caps. When the user asks to integrate one:
|
|
99
|
+
|
|
100
|
+
1. **Confirm workspace match.** The discovery message says whether the server's workspace matches this project's. If it doesn't, do NOT add the integration — instruct the user to run `bricks buttress unbind && bricks buttress bind` from this workspace's owner CLI on the server host. The launcher won't trust a cross-workspace server.
|
|
101
|
+
|
|
102
|
+
2. **Map announced types to generator templates.** For each `generators[].type` in the announce, target the matching templateKey (create the generator if absent):
|
|
103
|
+
|
|
104
|
+
| Announced type | templateKey | Default model |
|
|
105
|
+
|----------------|------------------------------|---------------|
|
|
106
|
+
| `ggml-llm` | `GENERATOR_LLM` | `ggml-org/gemma-3-12b-it-qat-GGUF` (≥20 GB usable) or `ggml-org/gpt-oss-20b-GGUF` (~12 GB usable) |
|
|
107
|
+
| `mlx-llm` | `GENERATOR_MLX_LLM` | `mlx-community/Qwen3-4B-4bit` (or a larger 4-bit quant if `usableBytes` allows) |
|
|
108
|
+
| `ggml-stt` | `GENERATOR_SPEECH_INFERENCE` | `BricksDisplay/whisper-ggml` (filename `ggml-small-q8_0.bin`) |
|
|
109
|
+
|
|
110
|
+
Pick a model that fits the announced `usableBytes`. Set `contextSize` to match.
|
|
111
|
+
|
|
112
|
+
3. **Use the canonical auto-discovery config** from "Auto-discovery (recommended)" above. Don't switch to manual mode just because the server is on the LAN — auto mode picks the workspace-bound server automatically and rebinds when the device's workspace flips.
|
|
113
|
+
|
|
114
|
+
### Real-device caveat
|
|
115
|
+
|
|
116
|
+
Buttress LAN auto-discovery uses native UDP via `react-native-jsi-udp`. The iOS Simulator silently fails to bind UDP, so auto mode is a no-op there. With `fallbackType: 'use-local'` the generator falls back to local inference in the simulator — dev/test stays functional. **Validate the buttress path itself only when deploying to a real Foundation device; don't gate the build on simulator validation.**
|
|
117
|
+
|
|
118
|
+
## Server Setup
|
|
119
|
+
|
|
120
|
+
### Requirements
|
|
121
|
+
- [Bun](https://bun.sh) v1.3+
|
|
122
|
+
- GPU recommended for LLM/STT
|
|
123
|
+
|
|
124
|
+
### Installation
|
|
125
|
+
|
|
126
|
+
```bash
|
|
127
|
+
bun add -g @fugood/buttress-server
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Start Server
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
bricks-buttress
|
|
134
|
+
# or with config
|
|
135
|
+
bricks-buttress --config ./config.toml
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### CLI Options
|
|
139
|
+
|
|
140
|
+
| Option | Description |
|
|
141
|
+
|--------|-------------|
|
|
142
|
+
| `-p, --port` | Port (default: 2080) |
|
|
143
|
+
| `-c, --config` | TOML config file path |
|
|
144
|
+
| `-v, --version` | Show version |
|
|
145
|
+
| `-h, --help` | Show help |
|
|
146
|
+
|
|
147
|
+
### Environment Variables
|
|
148
|
+
|
|
149
|
+
| Variable | Description |
|
|
150
|
+
|----------|-------------|
|
|
151
|
+
| `HF_TOKEN` | Hugging Face token for model downloads |
|
|
152
|
+
| `ENABLE_OPENAI_COMPAT_ENDPOINT` | Set to `1` for OpenAI-compatible API |
|
|
153
|
+
| `BRICKS_BUTTRESS_STATE_DIR` | Override the workspace state directory (default `~/.bricks-cli/buttress`) |
|
|
154
|
+
|
|
155
|
+
## Bind the Server to a Workspace
|
|
156
|
+
|
|
157
|
+
To use `autoDiscoverType: 'auto'` — and to require workspace-scoped JWT auth — pair the buttress-server with a BRICKS workspace using the `bricks buttress` CLI commands. An unbound server stays in legacy public mode and accepts any LAN client.
|
|
158
|
+
|
|
159
|
+
### One-time bind
|
|
160
|
+
|
|
161
|
+
```bash
|
|
162
|
+
# Log into the cloud bricks-server with the workspace owner's account
|
|
163
|
+
bricks auth login
|
|
164
|
+
|
|
165
|
+
# Pair the buttress-server running on this machine with the active workspace
|
|
166
|
+
bricks buttress bind
|
|
167
|
+
|
|
168
|
+
# Restart bricks-buttress so it picks up the new state.json
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
`bricks buttress bind` writes `~/.bricks-cli/buttress/state.json` containing the workspace id, the issuer's Ed25519 public key, and a stable `serverId` (defaults to `buttress-<machineId>`). Override location with `--state-dir` or `$BRICKS_BUTTRESS_STATE_DIR`. For headless setups, use `bricks buttress bind --print` to emit state.json to stdout.
|
|
172
|
+
|
|
173
|
+
### Verify and manage
|
|
174
|
+
|
|
175
|
+
```bash
|
|
176
|
+
# Show local binding + workspace-side bound list
|
|
177
|
+
bricks buttress status
|
|
178
|
+
|
|
179
|
+
# Discover buttress-servers on the LAN (with version, auth state, generator caps)
|
|
180
|
+
bricks buttress scan
|
|
181
|
+
|
|
182
|
+
# Issue a long-lived workspace access token (CI / ctor agents that already hold a workspace token)
|
|
183
|
+
bricks buttress issue-token --ttl 86400
|
|
184
|
+
|
|
185
|
+
# Detach this server from the workspace
|
|
186
|
+
bricks buttress unbind
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
After binding, launchers in the same workspace will auto-discover this server; manual-mode generators will only send their access token if the server's reported workspace matches their own.
|
|
190
|
+
|
|
191
|
+
## Server Configuration (TOML)
|
|
192
|
+
|
|
193
|
+
```toml
|
|
194
|
+
[server]
|
|
195
|
+
port = 2080
|
|
196
|
+
|
|
197
|
+
[runtime]
|
|
198
|
+
cache_dir = "./.buttress-cache"
|
|
199
|
+
n_threads = 6
|
|
200
|
+
flash_attn_type = "on"
|
|
201
|
+
cache_type_k = "q8_0"
|
|
202
|
+
cache_type_v = "q8_0"
|
|
203
|
+
|
|
204
|
+
# LLM Generator
|
|
205
|
+
[[generators]]
|
|
206
|
+
type = "ggml-llm"
|
|
207
|
+
[generators.backend]
|
|
208
|
+
variant_preference = ["cuda", "vulkan", "default"]
|
|
209
|
+
gpu_memory_fraction = 0.95
|
|
210
|
+
[generators.model]
|
|
211
|
+
repo_id = "ggml-org/gemma-3-12b-it-qat-GGUF"
|
|
212
|
+
download = true
|
|
213
|
+
n_ctx = 8192
|
|
214
|
+
|
|
215
|
+
# STT Generator
|
|
216
|
+
[[generators]]
|
|
217
|
+
type = "ggml-stt"
|
|
218
|
+
[generators.backend]
|
|
219
|
+
variant_preference = ["cuda", "vulkan", "default"]
|
|
220
|
+
[generators.model]
|
|
221
|
+
repo_id = "BricksDisplay/whisper-ggml"
|
|
222
|
+
filename = "ggml-small-q8_0.bin"
|
|
223
|
+
download = true
|
|
224
|
+
use_gpu = true
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
## Use Cases
|
|
228
|
+
|
|
229
|
+
### Resource-Constrained Devices
|
|
230
|
+
Digital signage with basic hardware offloads LLM to powerful server.
|
|
231
|
+
|
|
232
|
+
### Shared GPU Resources
|
|
233
|
+
Multiple devices share single GPU server for inference.
|
|
234
|
+
|
|
235
|
+
### Development Testing
|
|
236
|
+
Test AI features on lightweight dev machines by connecting to beefy server.
|
|
237
|
+
|
|
238
|
+
## Best Practices
|
|
239
|
+
|
|
240
|
+
1. **Network reliability**: Ensure stable LAN connection to Buttress server
|
|
241
|
+
2. **Fallback strategy**: Configure appropriate fallback for critical features
|
|
242
|
+
3. **Server monitoring**: Monitor Buttress server resource usage
|
|
243
|
+
4. **Model consistency**: Ensure client and server use compatible models
|
|
244
|
+
5. **Security**: Run Buttress on private network, not public internet
|
|
245
|
+
6. **Latency awareness**: Account for network latency in UX design
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
# Data Calculation (JS Sandbox)
|
|
2
|
+
|
|
3
|
+
Transform and compute Data Bank values using JavaScript scripts. Calcs are for **pure data transformation only** — see [Architecture Patterns](architecture-patterns.md) for the pattern selection guide.
|
|
4
|
+
|
|
5
|
+
| If you need to... | Use instead |
|
|
6
|
+
|---|---|
|
|
7
|
+
| Call an LLM / AI model | Generator (Assistant, LLM, HTTP) |
|
|
8
|
+
| Sequence multiple actions | Event Action Chain |
|
|
9
|
+
| Set a data value directly | PROPERTY_BANK system action |
|
|
10
|
+
| Compute a simple expression | PROPERTY_BANK_EXPRESSION |
|
|
11
|
+
| Transform/format/parse data | Data Calculation (correct use) |
|
|
12
|
+
|
|
13
|
+
## Authoring Contract
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { makeId } from 'bricks-ctor'
|
|
17
|
+
import { readFile } from 'node:fs/promises'
|
|
18
|
+
|
|
19
|
+
const calculation: DataCalculationScript = {
|
|
20
|
+
__typename: 'DataCalculationScript',
|
|
21
|
+
id: makeId('property_bank_calc'),
|
|
22
|
+
title: 'Format Price',
|
|
23
|
+
description: 'Formats price with currency symbol',
|
|
24
|
+
note: '',
|
|
25
|
+
triggerMode: 'auto', // 'auto' (default) | 'manual'
|
|
26
|
+
enableAsync: false,
|
|
27
|
+
// Inline code for short scripts...
|
|
28
|
+
code: `
|
|
29
|
+
const price = inputs.price || 0
|
|
30
|
+
const currency = inputs.currency || 'USD'
|
|
31
|
+
return new Intl.NumberFormat('en-US', {
|
|
32
|
+
style: 'currency',
|
|
33
|
+
currency,
|
|
34
|
+
}).format(price)
|
|
35
|
+
`,
|
|
36
|
+
// ...or load from a file (preferred for longer scripts):
|
|
37
|
+
// code: await readFile(new URL('./format-price.sandbox.js', import.meta.url), 'utf8'),
|
|
38
|
+
inputs: [
|
|
39
|
+
{ key: 'price', data: () => priceData, trigger: true },
|
|
40
|
+
{ key: 'currency', data: () => currencyData, trigger: false },
|
|
41
|
+
],
|
|
42
|
+
output: () => formattedPriceData,
|
|
43
|
+
outputs: [], // Additional named outputs (see Multiple Outputs)
|
|
44
|
+
error: null, // or () => errorData for error handling
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Field Rules (defaults and constraints)
|
|
49
|
+
|
|
50
|
+
- `trigger` **defaults to `false` when omitted** — always set it explicitly. A calc whose inputs are all non-trigger never auto-runs.
|
|
51
|
+
- `triggerMode` defaults to `'auto'` when omitted.
|
|
52
|
+
- `output` receives the **whole return value**. `outputs` entries extract fields by key from a returned object — `key` is a lodash-get path, so deep paths like `'user.name'` work. `output`, `outputs`, and `error` can be combined.
|
|
53
|
+
- `error` receives the error **message string** when the script throws. Both extraction steps run on every execution: a success overwrites the error Data, a failure overwrites the output Data(s) — don't expect stale values to persist.
|
|
54
|
+
- **Auto mode rejects the same Data in both `inputs` and `output`/`outputs`/`error`** — compile fails with `Not allow duplicate set property id between inputs / outputs / output / error`. Manual mode allows the overlap (self-referential updates, see Recipes).
|
|
55
|
+
- `.sandbox.js` files use an `export function main() { ... }` wrapper — compile unwraps it. Raw statements also work, but the wrapper keeps linters happy since script bodies use top-level `return`.
|
|
56
|
+
|
|
57
|
+
## Trigger Modes
|
|
58
|
+
|
|
59
|
+
| Mode | Description |
|
|
60
|
+
|------|-------------|
|
|
61
|
+
| `auto` | Run on every write to a `trigger: true` input (even if the value is unchanged) |
|
|
62
|
+
| `manual` | Never auto-runs; only via `PROPERTY_BANK_COMMAND` action. Allows the same Data as both input and output |
|
|
63
|
+
|
|
64
|
+
Use `manual` to prevent circular dependencies, for explicit control, or when an output must feed back into an input.
|
|
65
|
+
|
|
66
|
+
## Triggering via PROPERTY_BANK_COMMAND
|
|
67
|
+
|
|
68
|
+
`input` references a Data that is an input of the target calc — the system runs the calc(s) that data feeds into. It does NOT reference the DataCalculation itself.
|
|
69
|
+
|
|
70
|
+
- **Manual calc**: ANY input works — `trigger` flags are ignored for manual-mode calcs.
|
|
71
|
+
- **Auto calc**: only `trigger: true` inputs work; commanding a `trigger: false` input is a silent no-op.
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
const triggerCalc: EventAction = {
|
|
75
|
+
handler: 'system',
|
|
76
|
+
action: {
|
|
77
|
+
__actionName: 'PROPERTY_BANK_COMMAND',
|
|
78
|
+
parent: 'System',
|
|
79
|
+
dataParams: [
|
|
80
|
+
{ input: () => priceData }, // Reference to an input Data of the calc
|
|
81
|
+
],
|
|
82
|
+
},
|
|
83
|
+
}
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
- When the same chain **writes a calc input first** (e.g. `PROPERTY_BANK` setting `dLastButton`) then issues `PROPERTY_BANK_COMMAND`, set `waitAsync: true` on the write so the calc reads the new value rather than the pre-chain snapshot. See [Event Action Chains](architecture-patterns.md#event-action-chains-priority-2).
|
|
87
|
+
- When a **later action reads the calc's outputs**, set `waitAsync: true` on the `PROPERTY_BANK_COMMAND` action itself — it awaits the full calc chain including output writes.
|
|
88
|
+
- A dataParam's `value` acts as an execution gate: `{ input: () => d, value: false }` skips that trigger (combine with `mapping` for conditional runs).
|
|
89
|
+
|
|
90
|
+
## Script Sandbox
|
|
91
|
+
|
|
92
|
+
Scripts run in `use strict` mode as a function body — top-level `return` returns the calc result. No `fetch`, `XMLHttpRequest`, or `require` in any mode: I/O belongs to Generators.
|
|
93
|
+
|
|
94
|
+
### Built-in Globals
|
|
95
|
+
|
|
96
|
+
| Global | Description |
|
|
97
|
+
|--------|-------------|
|
|
98
|
+
| `inputs` | Object with input values (keyed by input `key`) |
|
|
99
|
+
| `console` | `{ log, error, warn, info }` — output is only visible in DevTools debug sessions; production is a no-op |
|
|
100
|
+
| `Platform` | `{ OS, isTV, isPad, isVision, isElectron }` |
|
|
101
|
+
| `TextEncoder`, `TextDecoder` | Text encoding/decoding |
|
|
102
|
+
| `Buffer` | Node.js Buffer (without `allocUnsafe`/`allocUnsafeSlow`) |
|
|
103
|
+
| `btoa`, `atob` | Base64 encoding/decoding |
|
|
104
|
+
|
|
105
|
+
### Async Mode
|
|
106
|
+
|
|
107
|
+
Sync mode (default) has **no `Promise`, timers, or `await`**. Enable `enableAsync: true` to unlock:
|
|
108
|
+
|
|
109
|
+
- `Promise`, `setTimeout`, `setInterval`, `setImmediate`, `clearTimeout`, `clearInterval`, `clearImmediate`, `requestAnimationFrame`
|
|
110
|
+
- Full lodash (sync mode omits `debounce`, `delay`, `defer`)
|
|
111
|
+
- `await` at the top level of the script
|
|
112
|
+
|
|
113
|
+
```typescript
|
|
114
|
+
code: `
|
|
115
|
+
const result = await new Promise((resolve) => {
|
|
116
|
+
setTimeout(() => resolve(inputs.value * 2), 100)
|
|
117
|
+
})
|
|
118
|
+
return result
|
|
119
|
+
`,
|
|
120
|
+
enableAsync: true,
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
### Runtime Environment
|
|
124
|
+
|
|
125
|
+
| Platform | Engine |
|
|
126
|
+
|----------|--------|
|
|
127
|
+
| Android | Hermes engine sandbox |
|
|
128
|
+
| iOS | JavaScriptCore sandbox |
|
|
129
|
+
| Electron desktop | Web Worker (V8) |
|
|
130
|
+
| Web preview / Simulator | Web Worker (V8) |
|
|
131
|
+
|
|
132
|
+
Simulator (Path 1) runs scripts on V8 while devices run Hermes/JSC — engine-sensitive code (date parsing, Intl, regex features) can pass in the Simulator and fail on device.
|
|
133
|
+
|
|
134
|
+
### Available Libraries
|
|
135
|
+
|
|
136
|
+
All exposed as globals. No network/file-download capability in any of them.
|
|
137
|
+
|
|
138
|
+
| Global | Library | Notes |
|
|
139
|
+
|--------|---------|-------|
|
|
140
|
+
| `_`, `lodash` | lodash | Sync mode omits `debounce`/`delay`/`defer` |
|
|
141
|
+
| `voca` | voca | String manipulation |
|
|
142
|
+
| `invariant` | invariant | Assertions |
|
|
143
|
+
| `json5` | json5 | JSON5 parsing |
|
|
144
|
+
| `qs` | qs | Query string parsing |
|
|
145
|
+
| `url` | node-url | URL parsing |
|
|
146
|
+
| `bytes` | bytes | Byte parsing/formatting |
|
|
147
|
+
| `ms` | ms | Millisecond conversion |
|
|
148
|
+
| `base45` | base45 | Base45 encoding |
|
|
149
|
+
| `iconv` | iconv-lite | Character encoding |
|
|
150
|
+
| `math`, `mathjs` | mathjs | Math library |
|
|
151
|
+
| `chroma` | chroma-js | Color manipulation |
|
|
152
|
+
| `moment` | moment | Date/time; auto parseFormat for string args |
|
|
153
|
+
| `nanoid` | nanoid | Unique ID generation |
|
|
154
|
+
| `md5` | md5 | MD5 hashing |
|
|
155
|
+
| `crypto` | crypto-browserify | Crypto functions |
|
|
156
|
+
| `kjurJWS` | jsrsasign | JWT/JWS signing (`KJUR.jws.JWS`) |
|
|
157
|
+
| `coseVerify` | cose-js | COSE verification (sync) |
|
|
158
|
+
| `fflate` | fflate | `{ zlibSync, unzlibSync, gzipSync, gunzipSync, compressSync, decompressSync, strFromU8 }` |
|
|
159
|
+
| `cbor` | cbor | `{ encode, decode, decodeFirstSync, decodeAllSync, addSemanticType }` |
|
|
160
|
+
| `fs` | (in-repo fs-compat) | File system; no download/upload methods |
|
|
161
|
+
| `parseDocument` | officeparser (in-repo fork) | Office document parsing (async) |
|
|
162
|
+
| `TurndownService` | turndown | HTML to Markdown |
|
|
163
|
+
| `OpenCC` | opencc-js | Chinese conversion `{ Converter, ConverterFactory, CustomConverter, Locale }` |
|
|
164
|
+
| `TOON` | @toon-format/toon | TOON format parsing |
|
|
165
|
+
|
|
166
|
+
## Recipes
|
|
167
|
+
|
|
168
|
+
### Multiple Outputs
|
|
169
|
+
|
|
170
|
+
Return an object; each `outputs` entry extracts its `key`:
|
|
171
|
+
|
|
172
|
+
```typescript
|
|
173
|
+
outputs: [
|
|
174
|
+
{ key: 'total', data: () => totalData },
|
|
175
|
+
{ key: 'tax', data: () => taxData },
|
|
176
|
+
{ key: 'subtotal', data: () => subtotalData },
|
|
177
|
+
],
|
|
178
|
+
output: null,
|
|
179
|
+
error: null,
|
|
180
|
+
code: `
|
|
181
|
+
const subtotal = inputs.price * inputs.quantity
|
|
182
|
+
const tax = subtotal * 0.1
|
|
183
|
+
const total = subtotal + tax
|
|
184
|
+
return { total, tax, subtotal }
|
|
185
|
+
`,
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
### Manual Self-Referential Update
|
|
189
|
+
|
|
190
|
+
When an update is too complex for `PROPERTY_BANK_EXPRESSION` and must read its own previous value — manual mode allows the same Data as input and output:
|
|
191
|
+
|
|
192
|
+
```typescript
|
|
193
|
+
const appendHistory: DataCalculationScript = {
|
|
194
|
+
__typename: 'DataCalculationScript',
|
|
195
|
+
id: makeId('property_bank_calc'),
|
|
196
|
+
title: 'Append History Entry',
|
|
197
|
+
triggerMode: 'manual',
|
|
198
|
+
enableAsync: false,
|
|
199
|
+
code: `
|
|
200
|
+
const history = Array.isArray(inputs.history) ? inputs.history : []
|
|
201
|
+
return [...history, { entry: inputs.entry, at: moment().toISOString() }].slice(-50)
|
|
202
|
+
`,
|
|
203
|
+
inputs: [
|
|
204
|
+
{ key: 'history', data: () => historyData, trigger: true },
|
|
205
|
+
{ key: 'entry', data: () => entryData, trigger: true },
|
|
206
|
+
],
|
|
207
|
+
output: () => historyData, // same Data as input — manual mode only
|
|
208
|
+
outputs: [],
|
|
209
|
+
error: null,
|
|
210
|
+
}
|
|
211
|
+
// Run it from an event chain: PROPERTY_BANK writes entryData (waitAsync: true),
|
|
212
|
+
// then PROPERTY_BANK_COMMAND with input: () => entryData.
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Failure Modes
|
|
216
|
+
|
|
217
|
+
| Symptom | Cause | Fix |
|
|
218
|
+
|---------|-------|-----|
|
|
219
|
+
| Calc never auto-runs | `trigger` omitted on inputs (defaults to `false`) | Set `trigger: true` explicitly |
|
|
220
|
+
| `PROPERTY_BANK_COMMAND` does nothing | Auto calc + `trigger: false` input, or `input` doesn't reference an input Data of the calc | Command a `trigger: true` input (auto) or any input (manual) |
|
|
221
|
+
| Compile error `Not allow duplicate set property id...` | Auto mode with same Data as input and output | Use `triggerMode: 'manual'`, or split into separate Data |
|
|
222
|
+
| Calc reads stale value written earlier in the same chain | Missing `waitAsync: true` on the preceding write | Set `waitAsync: true` on the write action |
|
|
223
|
+
| Works in Simulator, fails on device | V8 vs Hermes/JSC engine difference | Verify on device (Path 2); avoid engine-sensitive parsing |
|
|
224
|
+
| `console.log` shows nothing | Console only emits during DevTools debug sessions | Attach DevTools, or write debug values to an output Data |
|
|
225
|
+
| `Promise`/`setTimeout` undefined, or `Async mode is required` error | `enableAsync: false` | Set `enableAsync: true` |
|
|
226
|
+
|
|
227
|
+
## Best Practices
|
|
228
|
+
|
|
229
|
+
1. **Avoid circular deps**: Set non-triggering inputs (`trigger: false`) or use `manual` mode
|
|
230
|
+
2. **Error handling**: Always set `error` output for scripts that might fail
|
|
231
|
+
3. **Keep scripts pure**: Avoid side effects, return computed values
|
|
232
|
+
4. **Debounce rapid updates**: Use `manual` mode + timer for high-frequency inputs (auto calcs re-run on every write, even unchanged)
|
|
233
|
+
|
|
234
|
+
## Anti-Patterns (AVOID)
|
|
235
|
+
|
|
236
|
+
See [Architecture Patterns](architecture-patterns.md) for the full pattern selection guide.
|
|
237
|
+
|
|
238
|
+
### Using Data Calc as an orchestrator
|
|
239
|
+
Scripts that manage state machines, control UI flow, or coordinate multi-step processes belong in Event Action Chains. Symptoms: if/else on "what happens next", mirror `dFooResult` outputs that copy back to `dFoo` via `valueChange`, or a `dLastInput` field set-then-cleared to force an auto calc. See the "user-driven state machine" recipe in [Architecture Patterns](architecture-patterns.md).
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
# Simulator
|
|
2
|
+
|
|
3
|
+
What the Simulator can and can't faithfully reproduce — so a passing Simulator run means what you think it means. This is the fidelity companion to Path 1 in [Verification Toolchain](verification-toolchain.md); read that for how to *drive* the Simulator (compile, screenshot, Automations).
|
|
4
|
+
|
|
5
|
+
## What it is
|
|
6
|
+
|
|
7
|
+
- The default Path 1 target: it renders your compiled project on your computer, with no device required.
|
|
8
|
+
- It runs in Chromium/Electron — a browser-class runtime, not the device runtime. Two consequences to design verification around: it has a browser's capabilities and limits (below), and its JavaScript engine differs from the device's (iOS runs JSC, Android runs Hermes), so engine-specific behavior won't surface here.
|
|
9
|
+
|
|
10
|
+
A Simulator screenshot proves **layout, navigation, Standby Transitions, Data wiring, and generator/Automation wiring**. It does *not* prove anything that depends on real hardware, real models, or capabilities the preview runtime lacks.
|
|
11
|
+
|
|
12
|
+
## Automation screenshots
|
|
13
|
+
|
|
14
|
+
`match_screenshot` stores Simulator automation artifacts at the project level:
|
|
15
|
+
|
|
16
|
+
```text
|
|
17
|
+
.bricks/automation_screenshots/
|
|
18
|
+
last/
|
|
19
|
+
failed/
|
|
20
|
+
diff/
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
There is no application-id subdirectory; in CTOR the project is the application. Generated project `.gitignore` files exclude this directory.
|
|
24
|
+
|
|
25
|
+
When a `match_screenshot` baseline is missing or updated, the baseline goes under `last/`. When a screenshot mismatch occurs, the current capture goes under `failed/` and the pixel diff goes under `diff/`. File names follow `<screenshotName>+local+<timestamp>.png`.
|
|
26
|
+
|
|
27
|
+
In CTOR Desktop, `simulator_invoke` reports any automation screenshot files created or changed by the invocation in an `Automation screenshots:` section. It still separately reports the ordinary preview capture at `.bricks/simulator-screenshot.jpg`.
|
|
28
|
+
|
|
29
|
+
## What the Simulator can't reproduce
|
|
30
|
+
|
|
31
|
+
Because it runs in a browser-class preview rather than on device hardware, the Simulator cannot exercise these — a green run says nothing about them. Verify on a real device (Path 2):
|
|
32
|
+
|
|
33
|
+
| Area | In the Simulator |
|
|
34
|
+
|------|------------------|
|
|
35
|
+
| BLE (Central / Peripheral), Video Streaming | Not available |
|
|
36
|
+
| Raw network sockets — UDP, TCP, TCP Server, MQTT Broker | Not available (also why Buttress LAN discovery is a no-op — see [Buttress](buttress.md)) |
|
|
37
|
+
| Android Intent | Not available (Android-only) |
|
|
38
|
+
| On-device database **persistence** (SQLite / Vector Store) | Not available — both run in-memory in the Simulator (see caveats below), so data never survives a reload |
|
|
39
|
+
| GGML Text-to-Speech | No vocoder in the preview — use an ONNX TTS model to hear speech |
|
|
40
|
+
|
|
41
|
+
These work, but with browser caveats:
|
|
42
|
+
|
|
43
|
+
| Area | Caveat |
|
|
44
|
+
|------|--------|
|
|
45
|
+
| Serial Port | Works via WebSerial — requires browser support and a user gesture |
|
|
46
|
+
| WebView / WebCrawler | Subject to browser CORS — a load/fetch that works on device may be blocked |
|
|
47
|
+
| On-device AI (LLM / STT / VAD / Vector Store / Reranker) | Runs **single-threaded** — far slower than the device, not representative of real latency. Also subject to the model fallbacks below |
|
|
48
|
+
| On-device database (SQLite — `GENERATOR_SQLITE`) | Runs for real on the in-memory WASM `sqlite-vec` build — `execute` / `query` / `transaction` / batch all work. `storageType: file` is transparently treated as in-memory, so nothing persists across reloads (see above) |
|
|
49
|
+
| Scene3D / Maps / Sketch / WebRTC | Supported |
|
|
50
|
+
|
|
51
|
+
Feature availability also varies across the device platforms themselves (iOS / tvOS / Android / the desktop OSes). When a deployment targets a specific platform's capability, confirm it on that platform.
|
|
52
|
+
|
|
53
|
+
## Network security
|
|
54
|
+
|
|
55
|
+
The Simulator blocks insecure connections from `applicationPreview` by default: `http://` and `ws://` requests fail, while `https://` and `wss://` are allowed. The Simulator internally allows its own preview host when running the development preview.
|
|
56
|
+
|
|
57
|
+
Generated projects include this project-level setting:
|
|
58
|
+
|
|
59
|
+
```json
|
|
60
|
+
{
|
|
61
|
+
"allowedInsecureHosts": []
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Add explicit entries only when you deliberately need to test an insecure endpoint in the Simulator. A bare `host:port` allows both `http://` and `ws://` for that host:
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"allowedInsecureHosts": ["localhost:8080"]
|
|
70
|
+
}
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Use a URL form when only one insecure protocol should be allowed:
|
|
74
|
+
|
|
75
|
+
```json
|
|
76
|
+
{
|
|
77
|
+
"allowedInsecureHosts": ["http://localhost:8080"]
|
|
78
|
+
}
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
In that example, `http://localhost:8080` is allowed and `ws://localhost:8080` remains blocked.
|
|
82
|
+
|
|
83
|
+
Prefer HTTPS/WSS for anything that is not local development.
|
|
84
|
+
|
|
85
|
+
## Feature fallbacks — what the Simulator fakes
|
|
86
|
+
|
|
87
|
+
So that camera and AI features are usable without device permissions, multi-gigabyte downloads, API keys, or a remote inference backend, the Simulator **transparently substitutes a lightweight stand-in** for a few bricks/generators. The config you author is untouched — only the Simulator's runtime behavior differs. **A fallback render proves wiring and layout, not the real feature.**
|
|
88
|
+
|
|
89
|
+
| Brick / Generator | In the Simulator | Does NOT prove |
|
|
90
|
+
|-------------------|------------------|----------------|
|
|
91
|
+
| Camera (`BRICK_CAMERA`) | A 3D mock canvas, no camera permission prompt. `takePicture` snapshots the canvas; recording produces a placeholder clip | Real camera feed, focus, recording, permission flow |
|
|
92
|
+
| Thermal Printer (`GENERATOR_THERMAL_PRINTER`) | A simulated printer — `init` / `checkStatus` / `scan` fake per-driver status and discovered devices (ESC/POS, Star, TSC, Castles); `print` renders an approximate on-screen receipt. A bottom-left bubble shows live status with a fault toggle to exercise error wiring. Print results can be exported as PNG via `bricks-cli` (see below) | Real device connection, actual paper output, exact native driver status codes |
|
|
93
|
+
| LLM (`GENERATOR_LLM`) | Swapped to a tiny local stand-in model | Output quality / latency of your real model |
|
|
94
|
+
| Reranker — GGML (`GENERATOR_RERANKER`) | Swapped to a small local multilingual reranker model | Ranking quality / latency of your real model |
|
|
95
|
+
| Speech-to-Text — GGML (`GENERATOR_SPEECH_INFERENCE`) | Swapped to a tiny local model | Accuracy / latency of your real model |
|
|
96
|
+
| Speech-to-Text — ONNX (`GENERATOR_ONNX_STT`) | Swapped to a tiny whisper model | Accuracy / latency of your real model |
|
|
97
|
+
| Text-to-Speech — ONNX (`GENERATOR_TTS`) | Swapped to a tiny VITS model (no vocoder or speaker embedding) | Voice / quality / latency of your real model |
|
|
98
|
+
| Vector Store (`GENERATOR_VECTOR_STORE`) | Runs with a tiny local embedding model — an OpenAI-source config works **without a key** | Real embeddings / dimensions / recall (and no persistence — see above) |
|
|
99
|
+
| Buttress (all generators) | **Disabled** — there is no remote inference backend in the Simulator | The Buttress offload path — see [Buttress](buttress.md) |
|
|
100
|
+
| MLX LLM (`GENERATOR_MLX_LLM`) | Runs as authored, except Buttress is disabled | The MLX / Buttress path |
|
|
101
|
+
|
|
102
|
+
These swaps make the AI generators runnable in the Simulator for wiring checks — validate real models, quality, and latency on a device (Path 2).
|
|
103
|
+
|
|
104
|
+
### Inspecting simulated thermal printer print results
|
|
105
|
+
|
|
106
|
+
With the Simulator running (CDP at `localhost:19852`, see [Verification Toolchain](verification-toolchain.md)), `bricks-cli` can read the simulated printers and export a print result as a PNG image — no need to open the bubble popover or screenshot the whole window:
|
|
107
|
+
|
|
108
|
+
```bash
|
|
109
|
+
# Printers + print history (newest first; shows the --index value per result)
|
|
110
|
+
bricks devtools simulator thermal-printer list -p 19852
|
|
111
|
+
bricks devtools simulator thermal-printer list -p 19852 -j --commands # full print payloads as JSON
|
|
112
|
+
|
|
113
|
+
# Render one print result to PNG (defaults: the only printer, --index 0 = latest)
|
|
114
|
+
bricks devtools simulator thermal-printer print-result -p 19852 -o receipt.png
|
|
115
|
+
bricks devtools simulator thermal-printer print-result -p 19852 --index 1 --scale 2 -o older.png
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
The PNG is the same approximate receipt the on-screen preview shows (rendered from the print payload). It proves the payload wiring — content, ordering, alignment, barcode/QR/image presence — not pixel-exact native raster output. Print history is in-memory (up to 10 per printer) and clears on preview reload.
|
|
119
|
+
|
|
120
|
+
### Running the real implementation instead
|
|
121
|
+
|
|
122
|
+
Each substituted brick/generator can be switched back to its real implementation per item: open the **gear (Simulator settings)** in the editor's preview toolbar, uncheck the item, and **Apply**. Apply persists the choice and reloads the preview so it takes effect (a plain refresh won't). Use this to, e.g., point a Vector Store at a real API key in the preview. The browser limits above still apply, and **Buttress stays disabled regardless** — there's no backend for it here.
|
|
123
|
+
|
|
124
|
+
The Thermal Printer is the exception: it has no real web implementation to switch to (the native drivers can't run in a browser), so it is **always simulated** and is not in the gear list.
|
|
125
|
+
|
|
126
|
+
## Enough vs. escalate
|
|
127
|
+
|
|
128
|
+
- **Simulator is enough for:** layout, navigation, Standby Transitions, Data wiring, Automation / state-machine happy paths, and confirming a generator fires and handles its events.
|
|
129
|
+
- **Escalate to a real device for:** anything in the "can't reproduce" tables, real camera / peripherals / payment / identity, real model quality & latency, multi-device Local Sync, on-device persistence, the Buttress offload path, and engine-specific behavior.
|
|
130
|
+
|
|
131
|
+
The full Path 1/2/3 decision rule lives in [Verification Toolchain](verification-toolchain.md).
|