@fugood/bricks-ctor 2.24.2 → 2.24.3
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/index.ts +193 -13
- package/package.json +2 -2
- package/skills/bricks-ctor/rules/animation.md +3 -2
- package/skills/bricks-ctor/rules/buttress.md +97 -8
- package/tools/preview-main.mjs +18 -5
- package/tools/update-config.ts +110 -0
- package/types/animation.ts +16 -5
- package/types/bricks/Image.ts +12 -0
- package/types/data.ts +1 -1
- package/types/generators/LlmGgml.ts +1 -0
- package/types/generators/LlmMlx.ts +1 -0
- package/types/generators/SpeechToTextGgml.ts +1 -0
- package/types/subspace.ts +1 -1
- package/utils/data.ts +1 -1
package/compile/index.ts
CHANGED
|
@@ -301,6 +301,162 @@ const animationTypeMap = {
|
|
|
301
301
|
AnimationTimingConfig: 'timing',
|
|
302
302
|
AnimationSpringConfig: 'spring',
|
|
303
303
|
AnimationDecayConfig: 'decay',
|
|
304
|
+
} as const
|
|
305
|
+
|
|
306
|
+
type CompiledAnimationType = (typeof animationTypeMap)[keyof typeof animationTypeMap]
|
|
307
|
+
type WarningMetadata = Record<string, unknown>
|
|
308
|
+
|
|
309
|
+
const animationProperties = new Set([
|
|
310
|
+
'transform.translateX',
|
|
311
|
+
'transform.translateY',
|
|
312
|
+
'transform.scale',
|
|
313
|
+
'transform.scaleX',
|
|
314
|
+
'transform.scaleY',
|
|
315
|
+
'transform.rotate',
|
|
316
|
+
'transform.rotateX',
|
|
317
|
+
'transform.rotateY',
|
|
318
|
+
'opacity',
|
|
319
|
+
])
|
|
320
|
+
|
|
321
|
+
const animationComposeTypes = new Set(['parallel', 'sequence'])
|
|
322
|
+
const springConfigFamilies = [
|
|
323
|
+
['stiffness', 'damping', 'mass'],
|
|
324
|
+
['tension', 'friction'],
|
|
325
|
+
['bounciness', 'speed'],
|
|
326
|
+
]
|
|
327
|
+
const springConfigFamilyKeys = new Set(springConfigFamilies.flat())
|
|
328
|
+
|
|
329
|
+
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
330
|
+
Boolean(value) && typeof value === 'object' && !Array.isArray(value)
|
|
331
|
+
|
|
332
|
+
const hasDefinedConfigValue = (config: Record<string, unknown>, key: string) =>
|
|
333
|
+
config[key] !== undefined
|
|
334
|
+
|
|
335
|
+
const assertConfigValue = (
|
|
336
|
+
config: Record<string, unknown>,
|
|
337
|
+
key: string,
|
|
338
|
+
errorReference: string,
|
|
339
|
+
) => {
|
|
340
|
+
if (!hasDefinedConfigValue(config, key)) {
|
|
341
|
+
throw new Error(`Invalid animation config ${errorReference}: missing "${key}"`)
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
const assertAnimationProperty = (property: unknown, errorReference: string) => {
|
|
346
|
+
if (typeof property !== 'string' || !animationProperties.has(property)) {
|
|
347
|
+
throw new Error(
|
|
348
|
+
`Invalid animation property${errorReference ? ` ${errorReference}` : ''}: ${String(
|
|
349
|
+
property,
|
|
350
|
+
)}`,
|
|
351
|
+
)
|
|
352
|
+
}
|
|
353
|
+
return property
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
const getAnimationType = (config: unknown, errorReference: string): CompiledAnimationType => {
|
|
357
|
+
if (!isRecord(config)) {
|
|
358
|
+
throw new Error(`Invalid animation config ${errorReference}: config must be an object`)
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
const animationType = animationTypeMap[config.__type as keyof typeof animationTypeMap]
|
|
362
|
+
if (!animationType) {
|
|
363
|
+
throw new Error(`Invalid animation config type ${errorReference}: ${String(config.__type)}`)
|
|
364
|
+
}
|
|
365
|
+
return animationType
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
const assertAnimationComposeType = (composeType: unknown, errorReference: string) => {
|
|
369
|
+
if (typeof composeType !== 'string' || !animationComposeTypes.has(composeType)) {
|
|
370
|
+
throw new Error(`Invalid animation compose type ${errorReference}: ${String(composeType)}`)
|
|
371
|
+
}
|
|
372
|
+
return composeType
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
const pickDefinedConfigValues = (config: Record<string, unknown>, keys: string[]) =>
|
|
376
|
+
keys.reduce((acc, key) => {
|
|
377
|
+
if (hasDefinedConfigValue(config, key)) acc[key] = config[key]
|
|
378
|
+
return acc
|
|
379
|
+
}, {})
|
|
380
|
+
|
|
381
|
+
const getDefinedConfigKeys = (config: Record<string, unknown>, keys: string[]) =>
|
|
382
|
+
keys.filter((key) => hasDefinedConfigValue(config, key))
|
|
383
|
+
|
|
384
|
+
const formatWarningMetadata = (metadata: WarningMetadata = {}) =>
|
|
385
|
+
Object.entries(metadata)
|
|
386
|
+
.filter(([, value]) => value !== undefined && value !== null && value !== '')
|
|
387
|
+
.map(([key, value]) => `${key}: ${String(value)}`)
|
|
388
|
+
.join(', ')
|
|
389
|
+
|
|
390
|
+
const formatWarningReference = (metadata?: WarningMetadata) => {
|
|
391
|
+
const metadataText = formatWarningMetadata(metadata)
|
|
392
|
+
return metadataText ? ` [${metadataText}]` : ''
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
const normalizeSpringConfig = (
|
|
396
|
+
config: Record<string, unknown>,
|
|
397
|
+
errorReference: string,
|
|
398
|
+
warningMetadata?: WarningMetadata,
|
|
399
|
+
): Record<string, unknown> => {
|
|
400
|
+
assertConfigValue(config, 'toValue', errorReference)
|
|
401
|
+
|
|
402
|
+
const usedFamilies = springConfigFamilies.filter((keys) =>
|
|
403
|
+
keys.some((key) => hasDefinedConfigValue(config, key)),
|
|
404
|
+
)
|
|
405
|
+
if (usedFamilies.length <= 1) return config
|
|
406
|
+
|
|
407
|
+
const configWithoutSpringFamily = Object.entries(config).reduce((acc, [key, value]) => {
|
|
408
|
+
if (!springConfigFamilyKeys.has(key)) acc[key] = value
|
|
409
|
+
return acc
|
|
410
|
+
}, {})
|
|
411
|
+
|
|
412
|
+
// Match runtime normalization: physical spring values are most explicit,
|
|
413
|
+
// otherwise preserve BRICKS' historical tension/friction controls.
|
|
414
|
+
const resolvedFamily =
|
|
415
|
+
usedFamilies.find((keys) => keys.includes('stiffness')) ||
|
|
416
|
+
usedFamilies.find((keys) => keys.includes('tension')) ||
|
|
417
|
+
usedFamilies[0]
|
|
418
|
+
const resolvedFamilyKeys = getDefinedConfigKeys(config, resolvedFamily)
|
|
419
|
+
const droppedFamilyKeys = usedFamilies
|
|
420
|
+
.filter((keys) => keys !== resolvedFamily)
|
|
421
|
+
.flatMap((keys) => getDefinedConfigKeys(config, keys))
|
|
422
|
+
|
|
423
|
+
console.warn(
|
|
424
|
+
`[Warning] Resolved animation spring config${formatWarningReference(
|
|
425
|
+
warningMetadata,
|
|
426
|
+
)}: using ${resolvedFamilyKeys.join('/')}, dropping ${droppedFamilyKeys.join('/')}`,
|
|
427
|
+
)
|
|
428
|
+
|
|
429
|
+
return {
|
|
430
|
+
...configWithoutSpringFamily,
|
|
431
|
+
...pickDefinedConfigValues(config, resolvedFamily),
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
const compileAnimationConfig = (
|
|
436
|
+
animationType: CompiledAnimationType,
|
|
437
|
+
config: unknown,
|
|
438
|
+
errorReference: string,
|
|
439
|
+
warningMetadata?: WarningMetadata,
|
|
440
|
+
) => {
|
|
441
|
+
if (!isRecord(config)) {
|
|
442
|
+
throw new Error(`Invalid animation config ${errorReference}: config must be an object`)
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const compiledConfig = compileProperty(omit(config, '__type'), errorReference)
|
|
446
|
+
|
|
447
|
+
if (!isRecord(compiledConfig)) {
|
|
448
|
+
throw new Error(`Invalid animation config ${errorReference}: config must compile to an object`)
|
|
449
|
+
}
|
|
450
|
+
|
|
451
|
+
if (animationType === 'timing') {
|
|
452
|
+
assertConfigValue(compiledConfig, 'toValue', errorReference)
|
|
453
|
+
} else if (animationType === 'spring') {
|
|
454
|
+
return normalizeSpringConfig(compiledConfig, errorReference, warningMetadata)
|
|
455
|
+
} else if (animationType === 'decay') {
|
|
456
|
+
assertConfigValue(compiledConfig, 'velocity', errorReference)
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
return compiledConfig
|
|
304
460
|
}
|
|
305
461
|
|
|
306
462
|
const compileFrame = (frame: Canvas['items'][number]['frame']) => ({
|
|
@@ -629,39 +785,63 @@ export const compile = async (app: Application) => {
|
|
|
629
785
|
`(animation index: ${animationIndex}, subspace: ${subspaceId})`,
|
|
630
786
|
)
|
|
631
787
|
|
|
632
|
-
|
|
788
|
+
const animationTypename = animation.__typename
|
|
789
|
+
if (animationTypename === 'Animation') {
|
|
633
790
|
const animationDef = animation as AnimationDef
|
|
791
|
+
const animationErrorReference = `(animation: ${animationId}, subspace ${subspaceId})`
|
|
792
|
+
const animationWarningMetadata = {
|
|
793
|
+
animationIndex,
|
|
794
|
+
animationTitle: animationDef.title,
|
|
795
|
+
animationAlias: animationDef.alias,
|
|
796
|
+
animationProperty: animationDef.property,
|
|
797
|
+
subspaceIndex,
|
|
798
|
+
subspaceTitle: subspace.title,
|
|
799
|
+
}
|
|
800
|
+
const animationType = getAnimationType(animationDef.config, animationErrorReference)
|
|
634
801
|
map[animationId] = {
|
|
635
802
|
alias: animationDef.alias,
|
|
636
803
|
title: animationDef.title,
|
|
637
804
|
description: animationDef.description,
|
|
638
805
|
hide_short_ref: animationDef.hideShortRef,
|
|
639
806
|
animationRunType: animationDef.runType,
|
|
640
|
-
property: animationDef.property,
|
|
641
|
-
type:
|
|
642
|
-
config:
|
|
643
|
-
|
|
644
|
-
|
|
807
|
+
property: assertAnimationProperty(animationDef.property, animationErrorReference),
|
|
808
|
+
type: animationType,
|
|
809
|
+
config: compileAnimationConfig(
|
|
810
|
+
animationType,
|
|
811
|
+
animationDef.config,
|
|
812
|
+
animationErrorReference,
|
|
813
|
+
animationWarningMetadata,
|
|
645
814
|
),
|
|
646
815
|
}
|
|
647
|
-
} else if (
|
|
816
|
+
} else if (animationTypename === 'AnimationCompose') {
|
|
648
817
|
const animationDef = animation as AnimationComposeDef
|
|
818
|
+
const animationErrorReference = `(animation: ${animationId}, subspace ${subspaceId})`
|
|
649
819
|
map[animationId] = {
|
|
650
820
|
alias: animationDef.alias,
|
|
651
821
|
title: animationDef.title,
|
|
652
822
|
description: animationDef.description,
|
|
653
823
|
hide_short_ref: animationDef.hideShortRef,
|
|
654
824
|
animationRunType: animationDef.runType,
|
|
655
|
-
compose_type:
|
|
825
|
+
compose_type: assertAnimationComposeType(
|
|
826
|
+
animationDef.composeType,
|
|
827
|
+
animationErrorReference,
|
|
828
|
+
),
|
|
656
829
|
item_list: animationDef.items.map((item, index) => {
|
|
657
830
|
const innerAnimation = item()
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
)
|
|
662
|
-
|
|
831
|
+
const innerAnimationId = assertEntryId(
|
|
832
|
+
innerAnimation?.id,
|
|
833
|
+
'ANIMATION',
|
|
834
|
+
`(animation item index: ${index}, animation: ${animationId}, subspace ${subspaceId})`,
|
|
835
|
+
)
|
|
836
|
+
return { animation_id: innerAnimationId }
|
|
663
837
|
}),
|
|
664
838
|
}
|
|
839
|
+
} else {
|
|
840
|
+
throw new Error(
|
|
841
|
+
`Invalid animation typename (animation: ${animationId}, subspace ${subspaceId}): ${String(
|
|
842
|
+
animationTypename,
|
|
843
|
+
)}`,
|
|
844
|
+
)
|
|
665
845
|
}
|
|
666
846
|
return map
|
|
667
847
|
}, {}),
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fugood/bricks-ctor",
|
|
3
|
-
"version": "2.24.
|
|
3
|
+
"version": "2.24.3",
|
|
4
4
|
"main": "index.ts",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"typecheck": "tsc --noEmit",
|
|
7
7
|
"build": "bun scripts/build.js"
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@fugood/bricks-cli": "^2.24.
|
|
10
|
+
"@fugood/bricks-cli": "^2.24.3",
|
|
11
11
|
"@huggingface/gguf": "^0.3.2",
|
|
12
12
|
"@iarna/toml": "^3.0.0",
|
|
13
13
|
"@modelcontextprotocol/sdk": "^1.15.0",
|
|
@@ -41,12 +41,13 @@ const bounce: AnimationDef = {
|
|
|
41
41
|
toValue: 1,
|
|
42
42
|
friction: 7,
|
|
43
43
|
tension: 40,
|
|
44
|
-
speed: 12,
|
|
45
|
-
bounciness: 8,
|
|
46
44
|
},
|
|
47
45
|
}
|
|
48
46
|
```
|
|
49
47
|
|
|
48
|
+
Use one spring parameter family per config: `tension/friction`, `speed/bounciness`, or
|
|
49
|
+
`stiffness/damping/mass`.
|
|
50
|
+
|
|
50
51
|
### Decay Animation
|
|
51
52
|
Velocity-based deceleration animation.
|
|
52
53
|
|
|
@@ -20,16 +20,26 @@ When mobile devices or embedded systems lack hardware for local AI inference (LL
|
|
|
20
20
|
|
|
21
21
|
## Client Configuration
|
|
22
22
|
|
|
23
|
-
In generator properties, configure
|
|
23
|
+
In generator properties, configure `buttressConnectionSettings`:
|
|
24
24
|
|
|
25
25
|
| Setting | Description |
|
|
26
26
|
|---------|-------------|
|
|
27
|
-
| `
|
|
28
|
-
| `
|
|
29
|
-
| `
|
|
30
|
-
| `
|
|
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) |
|
|
31
32
|
|
|
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
|
|
33
43
|
|
|
34
44
|
| Strategy | Description |
|
|
35
45
|
|----------|-------------|
|
|
@@ -37,7 +47,11 @@ In generator properties, configure Buttress settings:
|
|
|
37
47
|
| `prefer-buttress` | Use Buttress if available, fallback to local |
|
|
38
48
|
| `prefer-best` | Auto-select based on capability comparison |
|
|
39
49
|
|
|
40
|
-
## Generator Configuration
|
|
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.
|
|
41
55
|
|
|
42
56
|
```typescript
|
|
43
57
|
import { makeId } from 'bricks-ctor'
|
|
@@ -53,7 +67,7 @@ const llmGenerator: GeneratorLLM = {
|
|
|
53
67
|
contextSize: 8192,
|
|
54
68
|
buttressConnectionSettings: {
|
|
55
69
|
enabled: true,
|
|
56
|
-
|
|
70
|
+
autoDiscoverType: 'auto',
|
|
57
71
|
fallbackType: 'use-local',
|
|
58
72
|
strategy: 'prefer-best',
|
|
59
73
|
},
|
|
@@ -63,6 +77,44 @@ const llmGenerator: GeneratorLLM = {
|
|
|
63
77
|
}
|
|
64
78
|
```
|
|
65
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
|
+
|
|
66
118
|
## Server Setup
|
|
67
119
|
|
|
68
120
|
### Requirements
|
|
@@ -98,6 +150,43 @@ bricks-buttress --config ./config.toml
|
|
|
98
150
|
|----------|-------------|
|
|
99
151
|
| `HF_TOKEN` | Hugging Face token for model downloads |
|
|
100
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.
|
|
101
190
|
|
|
102
191
|
## Server Configuration (TOML)
|
|
103
192
|
|
package/tools/preview-main.mjs
CHANGED
|
@@ -6,6 +6,12 @@ import { createServer } from 'http'
|
|
|
6
6
|
import { parseArgs } from 'util'
|
|
7
7
|
import * as TOON from '@toon-format/toon'
|
|
8
8
|
|
|
9
|
+
for (const stream of [process.stdout, process.stderr]) {
|
|
10
|
+
stream.on('error', (err) => {
|
|
11
|
+
if (err.code !== 'EPIPE') throw err
|
|
12
|
+
})
|
|
13
|
+
}
|
|
14
|
+
|
|
9
15
|
const { values } = parseArgs({
|
|
10
16
|
args: process.argv,
|
|
11
17
|
options: {
|
|
@@ -224,16 +230,23 @@ app.on('ready', () => {
|
|
|
224
230
|
)
|
|
225
231
|
if (takeScreenshotConfig) {
|
|
226
232
|
const { delay, width, height, path } = takeScreenshotConfig
|
|
227
|
-
setTimeout(() => {
|
|
233
|
+
setTimeout(async () => {
|
|
234
|
+
let screenshotFailed = false
|
|
228
235
|
console.log('Taking screenshot')
|
|
229
|
-
|
|
236
|
+
try {
|
|
237
|
+
const image = await mainWindow.webContents.capturePage()
|
|
230
238
|
console.log('Writing screenshot to', path)
|
|
231
|
-
writeFile(path, image.resize({ width, height }).toJPEG(75))
|
|
239
|
+
await writeFile(path, image.resize({ width, height }).toJPEG(75))
|
|
240
|
+
} catch (err) {
|
|
241
|
+
screenshotFailed = true
|
|
242
|
+
console.error('Screenshot capture/write failed', err)
|
|
243
|
+
} finally {
|
|
232
244
|
if (noKeepOpen) {
|
|
233
245
|
console.log('Closing app')
|
|
234
|
-
app.
|
|
246
|
+
if (screenshotFailed) app.exit(1)
|
|
247
|
+
else app.quit()
|
|
235
248
|
}
|
|
236
|
-
}
|
|
249
|
+
}
|
|
237
250
|
}, delay)
|
|
238
251
|
}
|
|
239
252
|
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import { readFile, writeFile } from 'node:fs/promises'
|
|
2
|
+
import { parseArgs } from 'util'
|
|
3
|
+
import { sh } from './_shell'
|
|
4
|
+
import { buildCommitArgs } from './_git-author'
|
|
5
|
+
|
|
6
|
+
const cwd = process.cwd()
|
|
7
|
+
|
|
8
|
+
const readJson = async (p: string) => JSON.parse(await readFile(p, 'utf8'))
|
|
9
|
+
|
|
10
|
+
const {
|
|
11
|
+
values: { 'auto-commit': autoCommit, 'no-check': noCheck, 'no-validate': noValidate, yes, help },
|
|
12
|
+
} = parseArgs({
|
|
13
|
+
args: process.argv.slice(2),
|
|
14
|
+
options: {
|
|
15
|
+
'auto-commit': { type: 'boolean' },
|
|
16
|
+
'no-check': { type: 'boolean' },
|
|
17
|
+
'no-validate': { type: 'boolean' },
|
|
18
|
+
yes: { type: 'boolean', short: 'y' },
|
|
19
|
+
help: { type: 'boolean', short: 'h' },
|
|
20
|
+
},
|
|
21
|
+
allowPositionals: true,
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
if (help) {
|
|
25
|
+
console.log(`Push compiled config to BRICKS without creating a release.
|
|
26
|
+
|
|
27
|
+
Options:
|
|
28
|
+
--auto-commit Auto-commit unstaged changes before pushing
|
|
29
|
+
--no-check Skip the conflict guard (don't pass --last-commit-id)
|
|
30
|
+
--no-validate Skip server-side config schema validation
|
|
31
|
+
-y, --yes Skip all prompts
|
|
32
|
+
-h, --help Show this help message`)
|
|
33
|
+
process.exit(0)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// Detect git repo (mirrors deploy.ts)
|
|
37
|
+
const { exitCode } = await sh`cd ${cwd} && git status`.quiet().nothrow()
|
|
38
|
+
const isGitRepo = exitCode === 0
|
|
39
|
+
|
|
40
|
+
if (!isGitRepo && !yes) {
|
|
41
|
+
const confirmContinue = prompt('No git repository found, continue? (y/n)')
|
|
42
|
+
if (confirmContinue !== 'y') throw new Error('Update cancelled')
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Read application.json + compiled config
|
|
46
|
+
const app = await readJson(`${cwd}/application.json`)
|
|
47
|
+
const config = await readJson(`${cwd}/.bricks/build/application-config.json`)
|
|
48
|
+
|
|
49
|
+
// Handle unstaged changes the same way deploy.ts does.
|
|
50
|
+
let commitId = ''
|
|
51
|
+
let parentCommitId = ''
|
|
52
|
+
if (isGitRepo) {
|
|
53
|
+
const unstagedChanges = await sh`cd ${cwd} && git diff --name-only --diff-filter=ACMR`.text()
|
|
54
|
+
if (unstagedChanges) {
|
|
55
|
+
if (autoCommit) {
|
|
56
|
+
// Capture the pre-commit HEAD so we can use it as the conflict-check
|
|
57
|
+
// baseline (the server should still hold it from the prior deploy).
|
|
58
|
+
parentCommitId = (await sh`cd ${cwd} && git rev-parse HEAD`.nothrow().text()).trim()
|
|
59
|
+
await sh`cd ${cwd} && git add -A`
|
|
60
|
+
const commitArgs = await buildCommitArgs(cwd, ['chore: update bricks config'])
|
|
61
|
+
await sh`cd ${cwd} && git ${commitArgs}`
|
|
62
|
+
} else {
|
|
63
|
+
throw new Error('Unstaged changes found, please commit or stash your changes before updating')
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
commitId = (await sh`cd ${cwd} && git rev-parse HEAD`.text()).trim()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// Auto-derive --last-commit-id for the server-side conflict guard.
|
|
70
|
+
// - parent of the auto-commit (server still holds it from the prior deploy)
|
|
71
|
+
// - current HEAD (clean tree — server should be at the same commit too)
|
|
72
|
+
let lastCommitId: string | undefined
|
|
73
|
+
if (!noCheck) {
|
|
74
|
+
if (parentCommitId) lastCommitId = parentCommitId
|
|
75
|
+
else if (commitId) lastCommitId = commitId
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
if (!yes) {
|
|
79
|
+
const confirm = prompt('Are you sure you want to push the new config? (y/n)')
|
|
80
|
+
if (confirm !== 'y') throw new Error('Update cancelled')
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const isModule = app.type === 'module'
|
|
84
|
+
const command = isModule ? 'module' : 'app'
|
|
85
|
+
|
|
86
|
+
const updateConfig = {
|
|
87
|
+
...config,
|
|
88
|
+
bricks_project_last_commit_id: commitId || undefined,
|
|
89
|
+
}
|
|
90
|
+
const configPath = `${cwd}/.bricks/build/update-config.json`
|
|
91
|
+
await writeFile(configPath, JSON.stringify(updateConfig))
|
|
92
|
+
|
|
93
|
+
const args = ['bricks', command, 'update', app.id, '-f', configPath, '--json']
|
|
94
|
+
if (noValidate) args.push('--no-validate')
|
|
95
|
+
if (lastCommitId) args.push('--last-commit-id', lastCommitId)
|
|
96
|
+
|
|
97
|
+
const result = await sh`${args}`.quiet().nothrow()
|
|
98
|
+
|
|
99
|
+
if (result.exitCode !== 0) {
|
|
100
|
+
const output = result.stderr.toString() || result.stdout.toString()
|
|
101
|
+
try {
|
|
102
|
+
const json = JSON.parse(output)
|
|
103
|
+
throw new Error(json.error?.message || json.error || 'Update failed')
|
|
104
|
+
} catch {
|
|
105
|
+
throw new Error(output || 'Update failed')
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const output = JSON.parse(result.stdout.toString())
|
|
110
|
+
console.log(`${isModule ? 'Module' : 'App'} config updated: ${output.target?.name || app.name}`)
|
package/types/animation.ts
CHANGED
|
@@ -44,10 +44,21 @@ export interface AnimationTimingConfig {
|
|
|
44
44
|
export interface AnimationSpringConfig {
|
|
45
45
|
__type: 'AnimationSpringConfig'
|
|
46
46
|
toValue: number // BRICKS Grid unit
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
// Use one spring parameter family: tension/friction, speed/bounciness,
|
|
48
|
+
// or stiffness/damping/mass.
|
|
49
|
+
friction?: number
|
|
50
|
+
tension?: number
|
|
51
|
+
speed?: number
|
|
52
|
+
bounciness?: number
|
|
53
|
+
stiffness?: number
|
|
54
|
+
damping?: number
|
|
55
|
+
mass?: number
|
|
56
|
+
velocity?: number
|
|
57
|
+
delay?: number
|
|
58
|
+
isInteraction?: boolean
|
|
59
|
+
overshootClamping?: boolean
|
|
60
|
+
restDisplacementThreshold?: number
|
|
61
|
+
restSpeedThreshold?: number
|
|
51
62
|
}
|
|
52
63
|
|
|
53
64
|
export interface AnimationDecayConfig {
|
|
@@ -62,7 +73,7 @@ export interface AnimationDef {
|
|
|
62
73
|
__typename: 'Animation'
|
|
63
74
|
id: string
|
|
64
75
|
alias?: string
|
|
65
|
-
title
|
|
76
|
+
title?: string
|
|
66
77
|
description?: string
|
|
67
78
|
hideShortRef?: boolean
|
|
68
79
|
runType?: 'once' | 'loop'
|
package/types/bricks/Image.ts
CHANGED
|
@@ -25,6 +25,10 @@ Default property:
|
|
|
25
25
|
"templateType": "${}",
|
|
26
26
|
"fadeDuration": 0,
|
|
27
27
|
"blurBackgroundRadius": 8,
|
|
28
|
+
"imageFilterEnabled": false,
|
|
29
|
+
"imageFilterBlur": 0,
|
|
30
|
+
"imageFilterBlurMode": "clamp",
|
|
31
|
+
"imageFilterColorMatrix": [],
|
|
28
32
|
"loadSystemIos": "auto",
|
|
29
33
|
"loadSystemAndroid": "auto"
|
|
30
34
|
}
|
|
@@ -50,6 +54,14 @@ Default property:
|
|
|
50
54
|
enableBlurBackground?: boolean | DataLink
|
|
51
55
|
/* The blur radius of the blur filter added to the image background */
|
|
52
56
|
blurBackgroundRadius?: number | DataLink
|
|
57
|
+
/* Enable Skia image filters. When disabled, Image uses the normal platform image renderer. */
|
|
58
|
+
imageFilterEnabled?: boolean | DataLink
|
|
59
|
+
/* Blur amount for the Skia image filter. */
|
|
60
|
+
imageFilterBlur?: number | DataLink
|
|
61
|
+
/* Tile mode for the Skia blur image filter. */
|
|
62
|
+
imageFilterBlurMode?: 'clamp' | 'decal' | 'repeat' | 'mirror' | DataLink
|
|
63
|
+
/* Optional 4x5 color matrix for the Skia image filter. Provide 20 numbers. */
|
|
64
|
+
imageFilterColorMatrix?: Array<number | DataLink> | DataLink
|
|
53
65
|
/* [iOS] The use priority of image loading system (Auto: sdwebimage, fallback to default if failed) */
|
|
54
66
|
loadSystemIos?: 'auto' | 'sdwebimage' | 'default' | DataLink
|
|
55
67
|
/* [Android] The use priority of image loading system (Auto: glide, fallback to fresco if failed) */
|
package/types/data.ts
CHANGED
|
@@ -713,6 +713,7 @@ Default property:
|
|
|
713
713
|
| {
|
|
714
714
|
enabled?: boolean | DataLink
|
|
715
715
|
url?: string | DataLink
|
|
716
|
+
autoDiscoverType?: 'manual' | 'auto' | DataLink
|
|
716
717
|
fallbackType?: 'use-local' | 'no-op' | DataLink
|
|
717
718
|
strategy?: 'prefer-local' | 'prefer-buttress' | 'prefer-best' | DataLink
|
|
718
719
|
}
|
|
@@ -158,6 +158,7 @@ Default property:
|
|
|
158
158
|
| {
|
|
159
159
|
enabled?: boolean | DataLink
|
|
160
160
|
url?: string | DataLink
|
|
161
|
+
autoDiscoverType?: 'manual' | 'auto' | DataLink
|
|
161
162
|
fallbackType?: 'use-local' | 'no-op' | DataLink
|
|
162
163
|
strategy?: 'prefer-local' | 'prefer-buttress' | 'prefer-best' | DataLink
|
|
163
164
|
}
|
|
@@ -323,6 +323,7 @@ Default property:
|
|
|
323
323
|
| {
|
|
324
324
|
enabled?: boolean | DataLink
|
|
325
325
|
url?: string | DataLink
|
|
326
|
+
autoDiscoverType?: 'manual' | 'auto' | DataLink
|
|
326
327
|
fallbackType?: 'use-local' | 'no-op' | DataLink
|
|
327
328
|
strategy?: 'prefer-local' | 'prefer-buttress' | 'prefer-best' | DataLink
|
|
328
329
|
}
|
package/types/subspace.ts
CHANGED