@ramme-io/kernel 7.3.1 → 8.0.0
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/dist/{AiGateway-Bdcl3v8h.js → AiGateway-U28yN4Mf.js} +409 -358
- package/dist/{bodewellAdapter-BzbeTSIP.js → bodewellAdapter-Cw9brU9k.js} +1 -1
- package/dist/deviceReadings-3Z4nql34.js +16 -0
- package/dist/index-BrFe7_2L.js +1614 -0
- package/dist/index.es.js +4340 -4610
- package/dist/kernel/src/agents/roster.d.ts +11 -3
- package/dist/kernel/src/agents/roster.d.ts.map +1 -1
- package/dist/kernel/src/agents/scope.d.ts +21 -0
- package/dist/kernel/src/agents/scope.d.ts.map +1 -0
- package/dist/kernel/src/agents/scope.test.d.ts +2 -0
- package/dist/kernel/src/agents/scope.test.d.ts.map +1 -0
- package/dist/kernel/src/components/AIChatPanel.d.ts +12 -0
- package/dist/kernel/src/components/AIChatPanel.d.ts.map +1 -1
- package/dist/kernel/src/engine/runtime/data-seeder.d.ts +2 -0
- package/dist/kernel/src/engine/runtime/data-seeder.d.ts.map +1 -1
- package/dist/kernel/src/engine/runtime/useSignal.d.ts +15 -0
- package/dist/kernel/src/engine/runtime/useSignal.d.ts.map +1 -1
- package/dist/kernel/src/engine/runtime/useSignal.test.d.ts +2 -0
- package/dist/kernel/src/engine/runtime/useSignal.test.d.ts.map +1 -0
- package/dist/kernel/src/index.d.ts +1 -4
- package/dist/kernel/src/index.d.ts.map +1 -1
- package/dist/kernel/src/renderers/AppDocumentRenderer.d.ts +57 -5
- package/dist/kernel/src/renderers/AppDocumentRenderer.d.ts.map +1 -1
- package/dist/kernel/src/renderers/AppOrientation.test.d.ts +2 -0
- package/dist/kernel/src/renderers/AppOrientation.test.d.ts.map +1 -0
- package/dist/kernel/src/server.d.ts +3 -0
- package/dist/kernel/src/server.d.ts.map +1 -1
- package/dist/kernel/src/services/ai/AiGatewayService.d.ts.map +1 -1
- package/dist/kernel/src/services/ai/providers/GeminiAdapter.d.ts.map +1 -1
- package/dist/kernel/src/services/ai/providers/OllamaAdapter.d.ts +1 -0
- package/dist/kernel/src/services/ai/providers/OllamaAdapter.d.ts.map +1 -1
- package/dist/kernel/src/services/ai/toolPromptGenerator.d.ts +0 -1
- package/dist/kernel/src/services/ai/toolPromptGenerator.d.ts.map +1 -1
- package/dist/kernel/src/signals/deviceReadings.d.ts +9 -0
- package/dist/kernel/src/signals/deviceReadings.d.ts.map +1 -0
- package/dist/kernel/src/signals/deviceReadings.test.d.ts +2 -0
- package/dist/kernel/src/signals/deviceReadings.test.d.ts.map +1 -0
- package/dist/kernel/src/signals/index.d.ts +1 -0
- package/dist/kernel/src/signals/index.d.ts.map +1 -1
- package/dist/server.es.js +47 -44
- package/dist/signals.es.js +12 -10
- package/package.json +4 -4
- package/dist/index-kBkq1FSR.js +0 -1236
- package/dist/kernel/src/events/mockEventSource.d.ts +0 -28
- package/dist/kernel/src/events/mockEventSource.d.ts.map +0 -1
- package/dist/kernel/src/services/MarketDataService.d.ts +0 -29
- package/dist/kernel/src/services/MarketDataService.d.ts.map +0 -1
- package/dist/kernel/src/services/marketSession.d.ts +0 -33
- package/dist/kernel/src/services/marketSession.d.ts.map +0 -1
- package/dist/kernel/src/services/marketSession.test.d.ts +0 -14
- package/dist/kernel/src/services/marketSession.test.d.ts.map +0 -1
- package/dist/kernel/src/stores/useMarketDataStore.d.ts +0 -50
- package/dist/kernel/src/stores/useMarketDataStore.d.ts.map +0 -1
|
@@ -0,0 +1,1614 @@
|
|
|
1
|
+
import { z as e } from "zod";
|
|
2
|
+
var ee = Object.defineProperty, te = (a, s) => {
|
|
3
|
+
for (var x in s)
|
|
4
|
+
ee(a, x, { get: s[x], enumerable: !0 });
|
|
5
|
+
}, ae = e.object({
|
|
6
|
+
key: e.string(),
|
|
7
|
+
label: e.string(),
|
|
8
|
+
type: e.enum(["text", "number", "currency", "percent", "delta", "date", "boolean", "status", "email", "image", "textarea"]),
|
|
9
|
+
required: e.boolean().optional(),
|
|
10
|
+
description: e.string().optional(),
|
|
11
|
+
defaultValue: e.any().optional()
|
|
12
|
+
}), ne = e.object({
|
|
13
|
+
id: e.string(),
|
|
14
|
+
name: e.string(),
|
|
15
|
+
fields: e.array(ae),
|
|
16
|
+
defaultView: e.enum(["table", "grid", "list"]).optional(),
|
|
17
|
+
features: e.object({
|
|
18
|
+
searchable: e.boolean().optional(),
|
|
19
|
+
creatable: e.boolean().optional(),
|
|
20
|
+
editable: e.boolean().optional(),
|
|
21
|
+
deletable: e.boolean().optional(),
|
|
22
|
+
exportable: e.boolean().optional()
|
|
23
|
+
}).optional()
|
|
24
|
+
}), oe = e.object({
|
|
25
|
+
id: e.string().min(1, "Signal ID is required"),
|
|
26
|
+
label: e.string(),
|
|
27
|
+
description: e.string().optional(),
|
|
28
|
+
kind: e.enum(["sensor", "actuator", "setpoint", "metric", "status", "kpi"]),
|
|
29
|
+
source: e.enum(["mock", "mqtt", "http", "derived", "local"]),
|
|
30
|
+
// Connectivity
|
|
31
|
+
topic: e.string().optional(),
|
|
32
|
+
endpoint: e.string().optional(),
|
|
33
|
+
jsonPath: e.string().optional(),
|
|
34
|
+
refreshRate: e.number().optional().default(1e3),
|
|
35
|
+
// Values
|
|
36
|
+
defaultValue: e.any().optional(),
|
|
37
|
+
unit: e.string().optional(),
|
|
38
|
+
min: e.number().optional(),
|
|
39
|
+
max: e.number().optional()
|
|
40
|
+
}), ie = e.object({
|
|
41
|
+
id: e.string(),
|
|
42
|
+
name: e.string(),
|
|
43
|
+
description: e.string().optional(),
|
|
44
|
+
type: e.string(),
|
|
45
|
+
category: e.string().default("logical"),
|
|
46
|
+
signals: e.array(e.string()),
|
|
47
|
+
ui: e.object({
|
|
48
|
+
icon: e.string().optional(),
|
|
49
|
+
color: e.string().optional(),
|
|
50
|
+
dashboardComponent: e.string().optional()
|
|
51
|
+
}).optional()
|
|
52
|
+
}), re = e.object({
|
|
53
|
+
id: e.string(),
|
|
54
|
+
type: e.enum(["signal_change", "manual_action", "schedule", "webhook"]),
|
|
55
|
+
config: e.record(e.string(), e.any())
|
|
56
|
+
}), se = e.object({
|
|
57
|
+
id: e.string(),
|
|
58
|
+
type: e.enum([
|
|
59
|
+
"update_resource",
|
|
60
|
+
"send_notification",
|
|
61
|
+
"mqtt_publish",
|
|
62
|
+
"api_call",
|
|
63
|
+
"navigate",
|
|
64
|
+
"agent_task"
|
|
65
|
+
]),
|
|
66
|
+
config: e.record(e.string(), e.any())
|
|
67
|
+
}), le = e.object({
|
|
68
|
+
id: e.string(),
|
|
69
|
+
name: e.string(),
|
|
70
|
+
active: e.boolean().default(!0),
|
|
71
|
+
trigger: re,
|
|
72
|
+
actions: e.array(se)
|
|
73
|
+
}), ue = e.object({
|
|
74
|
+
id: e.string(),
|
|
75
|
+
type: e.string(),
|
|
76
|
+
props: e.record(e.string(), e.any()),
|
|
77
|
+
layout: e.object({
|
|
78
|
+
colSpan: e.number().optional(),
|
|
79
|
+
rowSpan: e.number().optional()
|
|
80
|
+
}).optional()
|
|
81
|
+
}), me = e.object({
|
|
82
|
+
id: e.string(),
|
|
83
|
+
title: e.string().optional(),
|
|
84
|
+
description: e.string().optional(),
|
|
85
|
+
layout: e.object({
|
|
86
|
+
columns: e.number().optional(),
|
|
87
|
+
variant: e.enum(["grid", "stack", "split"]).optional()
|
|
88
|
+
}).optional(),
|
|
89
|
+
blocks: e.array(ue)
|
|
90
|
+
}), ce = e.object({
|
|
91
|
+
id: e.string(),
|
|
92
|
+
slug: e.string(),
|
|
93
|
+
title: e.string(),
|
|
94
|
+
description: e.string().optional(),
|
|
95
|
+
icon: e.string().optional(),
|
|
96
|
+
sections: e.array(me)
|
|
97
|
+
}), de = e.enum(["ENVIRONMENT", "SESSION_BYOK", "VAULT"]), pe = e.object({
|
|
98
|
+
strategy: de,
|
|
99
|
+
status: e.enum(["VALID", "KEY_EXPIRED", "BYOK_REQUIRED", "DEGRADED", "UNKNOWN"]).default("UNKNOWN")
|
|
100
|
+
}), vt = e.object({
|
|
101
|
+
meta: e.object({
|
|
102
|
+
name: e.string(),
|
|
103
|
+
version: e.string(),
|
|
104
|
+
description: e.string().optional(),
|
|
105
|
+
author: e.string().optional(),
|
|
106
|
+
createdAt: e.string().optional()
|
|
107
|
+
}),
|
|
108
|
+
config: e.object({
|
|
109
|
+
theme: e.enum(["light", "dark", "system", "corporate", "midnight", "blueprint"]).default("system"),
|
|
110
|
+
layout: e.enum(["dashboard", "explorer", "studio", "focus"]).default("dashboard"),
|
|
111
|
+
mockMode: e.boolean().default(!0),
|
|
112
|
+
brokerUrl: e.string().optional(),
|
|
113
|
+
aiKeyManifest: pe.optional()
|
|
114
|
+
}),
|
|
115
|
+
modules: e.array(e.string()).optional(),
|
|
116
|
+
resources: e.array(ne).optional(),
|
|
117
|
+
domain: e.object({
|
|
118
|
+
signals: e.array(oe),
|
|
119
|
+
entities: e.array(ie),
|
|
120
|
+
workflows: e.array(le).optional()
|
|
121
|
+
}),
|
|
122
|
+
pages: e.array(ce).optional()
|
|
123
|
+
}), yt = e.object({
|
|
124
|
+
timestamp: e.number(),
|
|
125
|
+
soilMoisture: e.number().min(0).max(100),
|
|
126
|
+
ambientLight: e.number().min(0).max(1e5),
|
|
127
|
+
temperature: e.number().min(-40).max(125)
|
|
128
|
+
}), he = e.object({
|
|
129
|
+
id: e.string(),
|
|
130
|
+
source: e.enum(["mqtt", "http", "ws", "mock"]),
|
|
131
|
+
domain: e.string(),
|
|
132
|
+
key: e.string(),
|
|
133
|
+
value: e.union([e.number(), e.string(), e.boolean()]),
|
|
134
|
+
unit: e.string().optional(),
|
|
135
|
+
timestamp: e.number(),
|
|
136
|
+
meta: e.record(e.unknown()).optional()
|
|
137
|
+
});
|
|
138
|
+
e.array(he);
|
|
139
|
+
var wt = {
|
|
140
|
+
AGRICULTURE: "agriculture",
|
|
141
|
+
// Derived — Methodology Engine outputs
|
|
142
|
+
ENVIRONMENT: "environment"
|
|
143
|
+
// A device's surroundings — temperature, humidity, light
|
|
144
|
+
}, xe = e.enum(["telemetry", "market", "system", "logic"]), ge = e.enum(["mqtt", "http", "ws", "mock"]);
|
|
145
|
+
e.object({
|
|
146
|
+
/**
|
|
147
|
+
* Globally unique signal identifier.
|
|
148
|
+
* Convention: '<device-or-entity-id>:<key>'
|
|
149
|
+
* Examples: 'sensor-01:soil_vwc', 'AAPL:price', 'server-01:cpu_pct'
|
|
150
|
+
*/
|
|
151
|
+
id: e.string(),
|
|
152
|
+
/**
|
|
153
|
+
* The semantic category of this signal.
|
|
154
|
+
* Determines which Methodology Engine processes it.
|
|
155
|
+
*/
|
|
156
|
+
kind: xe,
|
|
157
|
+
/**
|
|
158
|
+
* The specific measurement or metric key within its kind.
|
|
159
|
+
* RULE: Keys MUST be abstract and domain-agnostic where possible.
|
|
160
|
+
* Use 'price' not 'stock_price'. Use 'moisture' not 'soil_vwc'.
|
|
161
|
+
* Hardware-specific keys (soil_vwc) MUST be mapped to abstract keys
|
|
162
|
+
* at the adapter layer BEFORE the SignalPacket is created.
|
|
163
|
+
*/
|
|
164
|
+
key: e.string(),
|
|
165
|
+
/**
|
|
166
|
+
* The scalar value. Accepts number, string, or boolean.
|
|
167
|
+
* Structured data MUST be flattened into multiple SignalPackets,
|
|
168
|
+
* one per measurable dimension.
|
|
169
|
+
*/
|
|
170
|
+
value: e.union([e.number(), e.string(), e.boolean()]),
|
|
171
|
+
/**
|
|
172
|
+
* Optional unit of measurement.
|
|
173
|
+
* Examples: 'VWC%', 'USD', 'bpm', 'ms', '°C', 'pct'
|
|
174
|
+
*/
|
|
175
|
+
unit: e.string().optional(),
|
|
176
|
+
/**
|
|
177
|
+
* Unix timestamp in milliseconds (Date.now() format).
|
|
178
|
+
* MUST represent when the measurement was taken, not when it was received.
|
|
179
|
+
*/
|
|
180
|
+
ts: e.number(),
|
|
181
|
+
/**
|
|
182
|
+
* The transport source that produced this signal.
|
|
183
|
+
*/
|
|
184
|
+
source: ge.optional(),
|
|
185
|
+
/**
|
|
186
|
+
* Optional domain namespace for grouping related signals.
|
|
187
|
+
* Examples: 'bodewell', 'finance', 'infrastructure', 'user_behavior'
|
|
188
|
+
*/
|
|
189
|
+
domain: e.string().optional(),
|
|
190
|
+
/**
|
|
191
|
+
* Optional pass-through for source-specific metadata that does NOT
|
|
192
|
+
* belong in the core contract (e.g. device firmware version, exchange name).
|
|
193
|
+
* RULE: If you find yourself reading from meta in UI components, that
|
|
194
|
+
* field should be promoted to the core schema or handled in the adapter.
|
|
195
|
+
*/
|
|
196
|
+
meta: e.record(e.unknown()).optional()
|
|
197
|
+
});
|
|
198
|
+
var be = {};
|
|
199
|
+
te(be, {
|
|
200
|
+
BodewellCommandSchema: () => ve,
|
|
201
|
+
BodewellDeviceID: () => T,
|
|
202
|
+
BodewellTelemetrySchema: () => fe
|
|
203
|
+
});
|
|
204
|
+
var T = e.enum([
|
|
205
|
+
"STK-V1-001",
|
|
206
|
+
"STK-V1-002",
|
|
207
|
+
"STK-V1-003",
|
|
208
|
+
"STK-PRO-001",
|
|
209
|
+
"STK-VIS-001"
|
|
210
|
+
]), fe = e.object({
|
|
211
|
+
device_id: T,
|
|
212
|
+
stick_id: e.string().optional().describe("Firmware alias for device_id"),
|
|
213
|
+
timestamp: e.number().optional().describe("Epoch timestamp from NTP"),
|
|
214
|
+
air_temp: e.number().optional().describe("Celsius"),
|
|
215
|
+
air_humid: e.number().optional().describe("Relative Humidity %"),
|
|
216
|
+
humidity: e.number().optional().describe("Firmware alias for air_humid"),
|
|
217
|
+
air_pressure: e.number().optional().describe("hPa"),
|
|
218
|
+
pressure: e.number().optional().describe("Firmware alias for air_pressure"),
|
|
219
|
+
light_lux: e.number().optional().describe("Lux level"),
|
|
220
|
+
soil_temp_stemma: e.number().optional().describe("Celsius"),
|
|
221
|
+
soil_vwc: e.number().describe("Volumetric Water Content / Raw Capacitance"),
|
|
222
|
+
soil_moisture: e.number().optional().describe("Firmware alias for raw capacitance"),
|
|
223
|
+
soil_moisture_raw: e.number().optional().describe("Unscaled capacitance (300-1100)"),
|
|
224
|
+
fw_version: e.string().max(40).optional().describe("Firmware build the board is running; absent on v4 sketches, which cannot be updated over the air")
|
|
225
|
+
}).passthrough(), ve = e.object({
|
|
226
|
+
stick_id: T,
|
|
227
|
+
// Note: Your API uses stick_id here, not device_id
|
|
228
|
+
type: e.enum(["dry", "wet"]),
|
|
229
|
+
value: e.number()
|
|
230
|
+
}), ye = e.enum([
|
|
231
|
+
"esp32-touch-28",
|
|
232
|
+
// 2.8" 240x320 resistive touch, the workshop board
|
|
233
|
+
"esp32-headless",
|
|
234
|
+
// no display; sensor node
|
|
235
|
+
"simulator"
|
|
236
|
+
// browser-side stand-in, for building without hardware
|
|
237
|
+
]), V = e.enum([
|
|
238
|
+
"weather",
|
|
239
|
+
"clock",
|
|
240
|
+
"aircraft",
|
|
241
|
+
"sensor",
|
|
242
|
+
"blank"
|
|
243
|
+
]), we = e.object({
|
|
244
|
+
/** Postal code is what a person knows; the portal resolves it to coordinates. */
|
|
245
|
+
postalCode: e.string().min(3).max(12),
|
|
246
|
+
latitude: e.number().min(-90).max(90).optional(),
|
|
247
|
+
longitude: e.number().min(-180).max(180).optional(),
|
|
248
|
+
units: e.enum(["imperial", "metric"]).default("imperial"),
|
|
249
|
+
showForecast: e.boolean().default(!0),
|
|
250
|
+
refreshSeconds: e.number().int().min(300).max(86400).default(900)
|
|
251
|
+
}), Ae = e.object({
|
|
252
|
+
/** IANA zone, e.g. "America/New_York". */
|
|
253
|
+
timezone: e.string().default("America/New_York"),
|
|
254
|
+
twentyFourHour: e.boolean().default(!1),
|
|
255
|
+
showSeconds: e.boolean().default(!1),
|
|
256
|
+
showDate: e.boolean().default(!0)
|
|
257
|
+
}), Ee = e.object({
|
|
258
|
+
latitude: e.number().min(-90).max(90),
|
|
259
|
+
longitude: e.number().min(-180).max(180),
|
|
260
|
+
radiusKm: e.number().min(5).max(400).default(80),
|
|
261
|
+
/** Rows the list view can show before the screen runs out. */
|
|
262
|
+
maxRows: e.number().int().min(1).max(12).default(8),
|
|
263
|
+
refreshSeconds: e.number().int().min(10).max(600).default(30)
|
|
264
|
+
}), Se = e.object({
|
|
265
|
+
/** Signal keys to display, in order. Abstract keys per the Signal contract. */
|
|
266
|
+
keys: e.array(e.string()).min(1).max(6),
|
|
267
|
+
refreshSeconds: e.number().int().min(1).max(3600).default(10)
|
|
268
|
+
}), Ce = e.object({
|
|
269
|
+
weather: we.optional(),
|
|
270
|
+
clock: Ae.optional(),
|
|
271
|
+
aircraft: Ee.optional(),
|
|
272
|
+
sensor: Se.optional()
|
|
273
|
+
}), _e = e.object({
|
|
274
|
+
brightness: e.number().int().min(5).max(100).default(80),
|
|
275
|
+
/** Degrees clockwise. The board can sit either way up in a case. */
|
|
276
|
+
rotation: e.union([e.literal(0), e.literal(90), e.literal(180), e.literal(270)]).default(0),
|
|
277
|
+
/** Dim rather than sleep — a desk display that blanks looks broken. */
|
|
278
|
+
dimAfterSeconds: e.number().int().min(0).max(86400).default(0),
|
|
279
|
+
dimBrightness: e.number().int().min(0).max(100).default(15),
|
|
280
|
+
/** Local 24h times, e.g. "22:30". Empty disables night dimming. */
|
|
281
|
+
nightStart: e.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/).optional(),
|
|
282
|
+
nightEnd: e.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/).optional()
|
|
283
|
+
}), E = e.string().regex(
|
|
284
|
+
/^\d{1,3} \d{1,3} \d{1,3}$/,
|
|
285
|
+
'Expected space-separated RGB integers, e.g. "13 110 253"'
|
|
286
|
+
), Be = e.object({
|
|
287
|
+
preset: e.enum(["light", "dark", "corporate", "midnight", "blueprint", "custom"]).default("dark"),
|
|
288
|
+
background: E.optional(),
|
|
289
|
+
foreground: E.optional(),
|
|
290
|
+
accent: E.optional(),
|
|
291
|
+
muted: E.optional(),
|
|
292
|
+
warning: E.optional()
|
|
293
|
+
});
|
|
294
|
+
e.object({
|
|
295
|
+
/** Bumped only on breaking shape changes, so old firmware can refuse safely. */
|
|
296
|
+
schemaVersion: e.literal(1),
|
|
297
|
+
deviceId: e.string().min(1),
|
|
298
|
+
/** Monotonic. Portal increments on write; device echoes what it is running. */
|
|
299
|
+
revision: e.number().int().nonnegative(),
|
|
300
|
+
updatedAt: e.string().datetime().optional(),
|
|
301
|
+
activeApp: V,
|
|
302
|
+
apps: Ce,
|
|
303
|
+
display: _e,
|
|
304
|
+
theme: Be
|
|
305
|
+
});
|
|
306
|
+
var Fe = e.enum([
|
|
307
|
+
"unprovisioned",
|
|
308
|
+
"connecting",
|
|
309
|
+
"online",
|
|
310
|
+
"offline",
|
|
311
|
+
"failed"
|
|
312
|
+
]);
|
|
313
|
+
e.object({
|
|
314
|
+
deviceId: e.string().min(1),
|
|
315
|
+
kind: ye,
|
|
316
|
+
firmwareVersion: e.string(),
|
|
317
|
+
/** Shown on the device's own screen at boot — how the user finds it. */
|
|
318
|
+
ipAddress: e.string().optional(),
|
|
319
|
+
provisioning: Fe,
|
|
320
|
+
/** Revision the device is actually running, not the one it was sent. */
|
|
321
|
+
configRevision: e.number().int().nonnegative(),
|
|
322
|
+
activeApp: V,
|
|
323
|
+
rssi: e.number().int().optional().describe("dBm"),
|
|
324
|
+
uptimeSeconds: e.number().int().nonnegative().optional(),
|
|
325
|
+
freeHeapBytes: e.number().int().nonnegative().optional()
|
|
326
|
+
});
|
|
327
|
+
var ke = e.enum([
|
|
328
|
+
"background",
|
|
329
|
+
"foreground",
|
|
330
|
+
"muted",
|
|
331
|
+
"accent",
|
|
332
|
+
"success",
|
|
333
|
+
"warning",
|
|
334
|
+
"danger"
|
|
335
|
+
]), je = e.string().regex(/^\d{1,3} \d{1,3} \d{1,3}$/, 'RGB must be three space-separated integers, e.g. "13 110 253"'), S = e.union([ke, je]), H = e.enum(["xs", "sm", "base", "lg", "xl", "display"]), C = e.enum(["start", "center", "end"]), Ie = e.discriminatedUnion("kind", [
|
|
336
|
+
e.object({
|
|
337
|
+
kind: e.literal("weather"),
|
|
338
|
+
latitude: e.number().min(-90).max(90),
|
|
339
|
+
longitude: e.number().min(-180).max(180),
|
|
340
|
+
units: e.enum(["imperial", "metric"]).default("imperial"),
|
|
341
|
+
refreshSeconds: e.number().int().min(300).max(86400).default(600)
|
|
342
|
+
}),
|
|
343
|
+
e.object({
|
|
344
|
+
kind: e.literal("clock"),
|
|
345
|
+
/** IANA zone, e.g. "America/New_York". */
|
|
346
|
+
timezone: e.string().default("America/New_York"),
|
|
347
|
+
twentyFourHour: e.boolean().default(!1)
|
|
348
|
+
}),
|
|
349
|
+
e.object({
|
|
350
|
+
kind: e.literal("countdown"),
|
|
351
|
+
/** ISO date or datetime, e.g. "2026-12-25" or "2026-12-25T18:00:00Z". */
|
|
352
|
+
target: e.string().min(4),
|
|
353
|
+
label: e.string().max(24).optional()
|
|
354
|
+
}),
|
|
355
|
+
e.object({
|
|
356
|
+
kind: e.literal("static"),
|
|
357
|
+
values: e.record(e.union([e.string(), e.number(), e.boolean()]))
|
|
358
|
+
}),
|
|
359
|
+
/**
|
|
360
|
+
* Taking turns: a number that counts 0, 1, 2 … up to `count - 1` and starts
|
|
361
|
+
* again, moving on every `minutes`. Its one field is `index`.
|
|
362
|
+
*
|
|
363
|
+
* It exists for the photo frame — each photo hides unless the index is its
|
|
364
|
+
* own — and works for anything that should alternate, like two lines of a
|
|
365
|
+
* sign. Counted from UTC minutes since 1970, so the browser and every board
|
|
366
|
+
* agree on which turn it is without talking to each other, and minutes
|
|
367
|
+
* because a board redraws once a minute and no faster (see loop() in
|
|
368
|
+
* hardware/weather-display/weather-display.ino).
|
|
369
|
+
*/
|
|
370
|
+
e.object({
|
|
371
|
+
kind: e.literal("cycle"),
|
|
372
|
+
count: e.number().int().min(2).max(12),
|
|
373
|
+
minutes: e.number().int().min(1).max(1440).default(5),
|
|
374
|
+
/**
|
|
375
|
+
* A turn shorter than a minute — a slideshow at 5, 15 or 30 seconds. Wins
|
|
376
|
+
* over `minutes` where it is given; `minutes` stays the nearest whole
|
|
377
|
+
* minute, so a board whose firmware predates this still takes turns,
|
|
378
|
+
* once a minute. Counted the same way: seconds since 1970, in turns.
|
|
379
|
+
*/
|
|
380
|
+
seconds: e.number().int().min(5).max(86400).optional()
|
|
381
|
+
}),
|
|
382
|
+
/**
|
|
383
|
+
* The board's own parts: what a sensor plugged into the board it is drawn
|
|
384
|
+
* on is reading right now (docs/superpowers/specs/ramme-lab.md, "The
|
|
385
|
+
* differentiator"). Fields: `temperature`, from a temperature probe, a
|
|
386
|
+
* whole number in `units` like the weather's; and `connected`, whether a
|
|
387
|
+
* probe is plugged in at all. A board with nothing plugged in has no
|
|
388
|
+
* `temperature`, so a binding to it draws the placeholder.
|
|
389
|
+
*
|
|
390
|
+
* The board fills it from the probe (drawApp() in the sketch); a page
|
|
391
|
+
* previewing that board fills it from the readings the board reported
|
|
392
|
+
* (useAppData); the Studio, with no board, shows the placeholder.
|
|
393
|
+
*/
|
|
394
|
+
e.object({
|
|
395
|
+
kind: e.literal("board"),
|
|
396
|
+
units: e.enum(["imperial", "metric"]).default("imperial")
|
|
397
|
+
})
|
|
398
|
+
]), I = e.union([
|
|
399
|
+
e.object({ literal: e.number() }),
|
|
400
|
+
e.object({ source: e.string().min(1), field: e.string().min(1) })
|
|
401
|
+
]), De = e.object({
|
|
402
|
+
compute: e.enum(["add", "subtract", "multiply", "divide"]),
|
|
403
|
+
of: e.tuple([I, I]),
|
|
404
|
+
round: e.boolean().default(!0)
|
|
405
|
+
}), y = e.union([
|
|
406
|
+
e.object({ literal: e.union([e.string(), e.number(), e.boolean()]) }),
|
|
407
|
+
e.object({
|
|
408
|
+
/** Key into the document's `sources` map. */
|
|
409
|
+
source: e.string().min(1),
|
|
410
|
+
/** Field on that source, e.g. "temperature", "high", "condition". */
|
|
411
|
+
field: e.string().min(1)
|
|
412
|
+
}),
|
|
413
|
+
De
|
|
414
|
+
]), _ = e.object({
|
|
415
|
+
value: I,
|
|
416
|
+
op: e.enum(["<", "<=", ">", ">=", "==", "!="]),
|
|
417
|
+
than: e.union([e.number(), e.string(), e.boolean()])
|
|
418
|
+
}), U = e.object({
|
|
419
|
+
when: _,
|
|
420
|
+
color: S.optional(),
|
|
421
|
+
size: H.optional()
|
|
422
|
+
}), B = {
|
|
423
|
+
color: S.optional(),
|
|
424
|
+
/** Drawn only when this is false, or absent. */
|
|
425
|
+
hideWhen: _.optional(),
|
|
426
|
+
/** Conditional style. First match wins. */
|
|
427
|
+
rules: e.array(U).max(4).optional()
|
|
428
|
+
}, Te = e.object({
|
|
429
|
+
type: e.literal("text"),
|
|
430
|
+
value: y,
|
|
431
|
+
size: H.default("base"),
|
|
432
|
+
align: C.default("start"),
|
|
433
|
+
/** Printed after the value, e.g. a degree symbol. Never itself bound. */
|
|
434
|
+
/** Drawn before the value, as `suffix` is after: "H " for "H 68°". */
|
|
435
|
+
prefix: e.string().max(8).optional(),
|
|
436
|
+
suffix: e.string().max(8).optional(),
|
|
437
|
+
...B
|
|
438
|
+
}), Re = e.object({
|
|
439
|
+
type: e.literal("dial"),
|
|
440
|
+
value: y,
|
|
441
|
+
min: e.number(),
|
|
442
|
+
max: e.number(),
|
|
443
|
+
label: e.string().max(24).optional(),
|
|
444
|
+
...B
|
|
445
|
+
}), Oe = e.object({
|
|
446
|
+
type: e.literal("sparkline"),
|
|
447
|
+
/** A source field holding a series rather than a scalar. */
|
|
448
|
+
series: y,
|
|
449
|
+
...B
|
|
450
|
+
}), Me = e.object({
|
|
451
|
+
type: e.literal("bar"),
|
|
452
|
+
value: y,
|
|
453
|
+
min: e.number(),
|
|
454
|
+
max: e.number(),
|
|
455
|
+
...B
|
|
456
|
+
}), Pe = e.object({
|
|
457
|
+
type: e.literal("status"),
|
|
458
|
+
state: y,
|
|
459
|
+
label: e.string().max(24).optional(),
|
|
460
|
+
...B
|
|
461
|
+
}), F = 64, Ne = F / 2, $e = Math.ceil(Ne * F / 3) * 4, ze = e.object({
|
|
462
|
+
type: e.literal("sprite"),
|
|
463
|
+
width: e.number().int().min(1).max(F),
|
|
464
|
+
height: e.number().int().min(1).max(F),
|
|
465
|
+
/**
|
|
466
|
+
* Up to sixteen colours, in the same form every other colour in a document
|
|
467
|
+
* takes: a semantic token, or literal RGB.
|
|
468
|
+
*
|
|
469
|
+
* Both are allowed on purpose. A token re-colours with the theme, which is
|
|
470
|
+
* what an icon wants; literal RGB does not, which is what a drawing wants.
|
|
471
|
+
* A picture of a dog is content, not chrome, and should not turn teal
|
|
472
|
+
* because somebody switched to the corporate theme.
|
|
473
|
+
*/
|
|
474
|
+
palette: e.array(S).min(1).max(16),
|
|
475
|
+
/** base64 of the packed nibbles. */
|
|
476
|
+
pixels: e.string().min(4).max($e),
|
|
477
|
+
align: C.default("start"),
|
|
478
|
+
/** Drawn only when this is false, or absent. */
|
|
479
|
+
hideWhen: _.optional()
|
|
480
|
+
}), D = e.string().regex(/^[0-9a-f]{64}$/, "a lowercase hex SHA-256"), g = { width: 304, height: 224 }, Le = 8, $ = {
|
|
481
|
+
/** "RSPR". */
|
|
482
|
+
magic: [82, 83, 80, 82],
|
|
483
|
+
version: 1,
|
|
484
|
+
/** magic 4, version 1, width u16, height u16, bits per pixel 1, palette count 1. */
|
|
485
|
+
headerBytes: 11,
|
|
486
|
+
/** Only 4 today: two pixels per byte, high nibble first, rows padded to a byte. */
|
|
487
|
+
bitsPerPixel: 4,
|
|
488
|
+
maxColors: 16
|
|
489
|
+
}, At = $.headerBytes + $.maxColors * 2 + Math.ceil(g.width / 2) * g.height, Ve = e.object({
|
|
490
|
+
type: e.literal("image"),
|
|
491
|
+
asset: D,
|
|
492
|
+
/** The file's own pixels, not the drawn size. */
|
|
493
|
+
width: e.number().int().min(1).max(g.width),
|
|
494
|
+
height: e.number().int().min(1).max(g.height),
|
|
495
|
+
scale: e.number().int().min(1).max(Le).default(1),
|
|
496
|
+
/**
|
|
497
|
+
* What kind of file `asset` names: `spr`, the palette file the retro look
|
|
498
|
+
* uses, or `jpeg`, the full-colour rendition (drawn at scale 1). Absent means
|
|
499
|
+
* `spr`, which is every image block written before full colour existed.
|
|
500
|
+
*/
|
|
501
|
+
format: e.enum(["spr", "jpeg"]).default("spr"),
|
|
502
|
+
align: C.default("start"),
|
|
503
|
+
/** Drawn only when this is false, or absent. */
|
|
504
|
+
hideWhen: _.optional()
|
|
505
|
+
}), Et = { sm: 24, md: 48, lg: 72, xl: 96 }, He = e.object({
|
|
506
|
+
type: e.literal("icon"),
|
|
507
|
+
value: y,
|
|
508
|
+
size: e.enum(["sm", "md", "lg", "xl"]).default("md"),
|
|
509
|
+
align: C.default("start"),
|
|
510
|
+
color: S.default("foreground"),
|
|
511
|
+
rules: e.array(U).max(4).optional(),
|
|
512
|
+
/** Drawn only when this is false, or absent. */
|
|
513
|
+
hideWhen: _.optional()
|
|
514
|
+
}), K = e.discriminatedUnion("type", [
|
|
515
|
+
Te,
|
|
516
|
+
Re,
|
|
517
|
+
Oe,
|
|
518
|
+
Me,
|
|
519
|
+
Pe,
|
|
520
|
+
ze,
|
|
521
|
+
Ve,
|
|
522
|
+
He
|
|
523
|
+
]), Ue = e.object({
|
|
524
|
+
type: e.literal("group"),
|
|
525
|
+
direction: e.enum(["row", "stack"]),
|
|
526
|
+
gap: e.number().int().min(0).max(64).default(4),
|
|
527
|
+
align: C.default("start"),
|
|
528
|
+
/**
|
|
529
|
+
* A row whose children take their own width, `gap` apart, placed together
|
|
530
|
+
* at the row's `align` — "68°" with its icon right beside it, "H 68° L 56°"
|
|
531
|
+
* as one line. Without it a row splits into equal cells, which put a short
|
|
532
|
+
* temperature and its icon half a screen apart. Text is as wide as the
|
|
533
|
+
* board draws it (six pixels in eight, per character); bars, dials,
|
|
534
|
+
* sparklines and status lights have no width of their own and share what is
|
|
535
|
+
* left. Ignored by a stack, and by firmware older than 2026-10-17, which
|
|
536
|
+
* falls back to equal cells.
|
|
537
|
+
*/
|
|
538
|
+
pack: e.boolean().optional(),
|
|
539
|
+
children: e.array(K).min(1).max(8)
|
|
540
|
+
}), Ke = e.union([K, Ue]);
|
|
541
|
+
e.enum(["landscape", "portrait"]);
|
|
542
|
+
var St = {
|
|
543
|
+
landscape: { width: 320, height: 240 },
|
|
544
|
+
portrait: { width: 240, height: 320 }
|
|
545
|
+
}, We = e.preprocess(
|
|
546
|
+
(a) => a === "240x320" ? "320x240" : a,
|
|
547
|
+
e.enum(["320x240"])
|
|
548
|
+
), W = e.object({
|
|
549
|
+
/** Bumped only for a breaking change; the device checks it before parsing. */
|
|
550
|
+
schemaVersion: e.literal(1),
|
|
551
|
+
id: e.string().regex(/^[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$/, "lowercase slug"),
|
|
552
|
+
name: e.string().min(1).max(48),
|
|
553
|
+
/** Free text. Never an email or anything else identifying — see the plan. */
|
|
554
|
+
author: e.string().max(32).optional(),
|
|
555
|
+
screen: We.default("320x240"),
|
|
556
|
+
background: S.default("background"),
|
|
557
|
+
/**
|
|
558
|
+
* Where the blocks sit on the screen as a whole: from the top, or in the
|
|
559
|
+
* middle with the space shared above and below. A document taller than the
|
|
560
|
+
* screen starts at the top either way, so centring never pushes the first
|
|
561
|
+
* block off the glass. Older firmware draws from the top.
|
|
562
|
+
*/
|
|
563
|
+
valign: e.enum(["start", "center"]).optional(),
|
|
564
|
+
/**
|
|
565
|
+
* Where the blocks sit across the screen as a whole. `center` makes a column
|
|
566
|
+
* as wide as the widest block and centres that column, so left-aligned lines
|
|
567
|
+
* stay aligned with each other and the group sits in the middle — rather
|
|
568
|
+
* than every line hugging the left edge with the right half empty. Widths
|
|
569
|
+
* are the board's (see `pack`); a block with no width of its own, like an
|
|
570
|
+
* equal-celled row or a bar, fills the screen and leaves nothing to centre.
|
|
571
|
+
* Older firmware draws from the left.
|
|
572
|
+
*/
|
|
573
|
+
halign: e.enum(["start", "center"]).optional(),
|
|
574
|
+
/**
|
|
575
|
+
* The lettering. `inter` (the default) is Inter, anti-aliased, drawn at
|
|
576
|
+
* each text size from its own font — SMOOTH_FONT_ADVANCES in
|
|
577
|
+
* ./deviceFonts.generated.ts are its widths. `pixel` is the board's
|
|
578
|
+
* built-in 5x7 bitmap font scaled up: the retro look, chunky on purpose.
|
|
579
|
+
* `tay` is TAY Dreamboat, the Ramme display face — capitals only, so
|
|
580
|
+
* lowercase is drawn as capitals; best for signs, times and numbers.
|
|
581
|
+
* Firmware older than 2026-10-18 draws everything in pixel, and older than
|
|
582
|
+
* 2026-10-20 draws `tay` as Inter.
|
|
583
|
+
*/
|
|
584
|
+
font: e.enum(["inter", "pixel", "tay"]).optional(),
|
|
585
|
+
/** Named so bindings can refer to them. */
|
|
586
|
+
sources: e.record(Ie).default({}),
|
|
587
|
+
blocks: e.array(Ke).min(1).max(12)
|
|
588
|
+
}).superRefine((a, s) => {
|
|
589
|
+
const x = (c) => Math.ceil(c / 2), w = (c, n) => {
|
|
590
|
+
const t = c;
|
|
591
|
+
if ((t == null ? void 0 : t.type) !== "sprite" || !t.width || !t.height || typeof t.pixels != "string") return;
|
|
592
|
+
const r = x(t.width) * t.height, l = Math.floor(t.pixels.replace(/=+$/, "").length * 3 / 4);
|
|
593
|
+
l !== r && s.addIssue({
|
|
594
|
+
code: e.ZodIssueCode.custom,
|
|
595
|
+
path: [...n, "pixels"],
|
|
596
|
+
message: `${t.width}x${t.height} needs ${r} bytes of pixel data, and this decodes to ${l}. Rows are padded to whole bytes, so the length is ceil(width / 2) * height.`
|
|
597
|
+
});
|
|
598
|
+
}, v = (c, n) => {
|
|
599
|
+
const t = c;
|
|
600
|
+
if ((t == null ? void 0 : t.type) !== "image" || !t.width || !t.height) return;
|
|
601
|
+
const r = t.scale ?? 1;
|
|
602
|
+
if (t.format === "jpeg" && r !== 1) {
|
|
603
|
+
s.addIssue({
|
|
604
|
+
code: e.ZodIssueCode.custom,
|
|
605
|
+
path: [...n, "scale"],
|
|
606
|
+
message: "A jpeg image is drawn at scale 1; make the file the size it should appear."
|
|
607
|
+
});
|
|
608
|
+
return;
|
|
609
|
+
}
|
|
610
|
+
const l = t.width * r, u = t.height * r;
|
|
611
|
+
l <= g.width && u <= g.height || s.addIssue({
|
|
612
|
+
code: e.ZodIssueCode.custom,
|
|
613
|
+
path: [...n, "scale"],
|
|
614
|
+
message: `${t.width}x${t.height} at scale ${r} draws ${l}x${u}, and a board draws at most ${g.width}x${g.height} inside its margin.`
|
|
615
|
+
});
|
|
616
|
+
};
|
|
617
|
+
a.blocks.forEach((c, n) => {
|
|
618
|
+
w(c, ["blocks", n]), v(c, ["blocks", n]);
|
|
619
|
+
const t = c.children;
|
|
620
|
+
Array.isArray(t) && t.forEach((r, l) => {
|
|
621
|
+
w(r, ["blocks", n, "children", l]), v(r, ["blocks", n, "children", l]);
|
|
622
|
+
});
|
|
623
|
+
});
|
|
624
|
+
}), G = e.object({
|
|
625
|
+
x: e.number().min(0).max(1),
|
|
626
|
+
y: e.number().min(0).max(1),
|
|
627
|
+
w: e.number().gt(0).max(1),
|
|
628
|
+
h: e.number().gt(0).max(1),
|
|
629
|
+
mirror: e.boolean().default(!1)
|
|
630
|
+
});
|
|
631
|
+
e.object({
|
|
632
|
+
rendition: e.string().min(4),
|
|
633
|
+
original: e.string().min(4),
|
|
634
|
+
/** The full-colour rendition (FULL_RENDITION), base64 JPEG. Optional for older clients. */
|
|
635
|
+
full: e.string().min(4).optional(),
|
|
636
|
+
crop: G.optional()
|
|
637
|
+
});
|
|
638
|
+
e.object({ full: e.string().min(4) });
|
|
639
|
+
e.object({
|
|
640
|
+
hash: D,
|
|
641
|
+
/** The rendition's own pixels. */
|
|
642
|
+
width: e.number().int().positive(),
|
|
643
|
+
height: e.number().int().positive(),
|
|
644
|
+
renditionBytes: e.number().int().positive(),
|
|
645
|
+
originalWidth: e.number().int().positive(),
|
|
646
|
+
originalHeight: e.number().int().positive(),
|
|
647
|
+
originalBytes: e.number().int().positive(),
|
|
648
|
+
uploadedAt: e.number().int(),
|
|
649
|
+
/** The full-colour rendition, when one has been made. Its own hash names it. */
|
|
650
|
+
full: e.object({ hash: D, bytes: e.number().int().positive() }).optional(),
|
|
651
|
+
crop: G.optional()
|
|
652
|
+
});
|
|
653
|
+
e.enum(["register", "poll", "send"]);
|
|
654
|
+
var Ge = e.enum(["working", "missing", "unsupported", "fault"]), Z = e.string().regex(/^[a-z][a-z0-9-]{0,23}$/), q = e.record(Z, Ge).refine((a) => Object.keys(a).length <= 16, { message: "at most 16 features" });
|
|
655
|
+
e.object({
|
|
656
|
+
/** When the board last said any of this, by the server's clock. */
|
|
657
|
+
reportedAt: e.number().int().nonnegative().optional(),
|
|
658
|
+
/**
|
|
659
|
+
* The firmware build. Today every board sends the literal "doc-1", which is a
|
|
660
|
+
* protocol marker rather than a build id — so this is shown as reported and
|
|
661
|
+
* labelled as not yet a version. The real value lives in the published
|
|
662
|
+
* manifest until firmware carries it.
|
|
663
|
+
*/
|
|
664
|
+
firmwareVersion: e.string().max(40).optional(),
|
|
665
|
+
/** Which board this is. Nothing distinguishes a CYD from a Freenove S3 yet. */
|
|
666
|
+
board: e.string().max(40).optional(),
|
|
667
|
+
/** dBm, negative. -50 is across the room, -85 is a complaint. */
|
|
668
|
+
rssi: e.number().int().min(-127).max(0).optional(),
|
|
669
|
+
/** The board's address on its own network, as the board sees it. */
|
|
670
|
+
ip: e.string().max(45).optional(),
|
|
671
|
+
uptimeSeconds: e.number().int().nonnegative().optional(),
|
|
672
|
+
freeHeapBytes: e.number().int().nonnegative().optional(),
|
|
673
|
+
/**
|
|
674
|
+
* The revision the board is actually showing.
|
|
675
|
+
*
|
|
676
|
+
* Distinct from the revision that was sent, and the difference is the whole
|
|
677
|
+
* value: a send that was never drawn looks identical to a successful one until
|
|
678
|
+
* these two numbers disagree.
|
|
679
|
+
*/
|
|
680
|
+
drewRevision: e.number().int().nonnegative().optional(),
|
|
681
|
+
/** Why it last restarted, if it says. A board power-cycling in a loop is a fault. */
|
|
682
|
+
resetReason: e.string().max(40).optional(),
|
|
683
|
+
/** Its parts and whether each works — see `DeviceFeaturesSchema`. */
|
|
684
|
+
features: q.optional(),
|
|
685
|
+
/** When it last polled — finer-grained than a registration, for liveness only. */
|
|
686
|
+
lastPollAt: e.number().int().nonnegative().optional()
|
|
687
|
+
});
|
|
688
|
+
e.object({
|
|
689
|
+
/** When the board last asked for its app. The freshest signal this system has. */
|
|
690
|
+
lastPollAt: e.number().int().nonnegative(),
|
|
691
|
+
/** The revision it reported drawing at that moment. */
|
|
692
|
+
drewRevision: e.number().int().nonnegative().optional(),
|
|
693
|
+
/**
|
|
694
|
+
* The firmware it is running, sent on every poll by builds that can update
|
|
695
|
+
* remotely — so its presence is also the answer to "can this board be
|
|
696
|
+
* updated from its page?". Registration reports the version too, but only
|
|
697
|
+
* every six hours; after a remote update this is what shows it took.
|
|
698
|
+
*/
|
|
699
|
+
firmware: e.string().max(40).optional(),
|
|
700
|
+
/** Photos its app names, and how many of those it holds in flash. */
|
|
701
|
+
photosWanted: e.number().int().nonnegative().optional(),
|
|
702
|
+
photosHeld: e.number().int().nonnegative().optional(),
|
|
703
|
+
/** What happened to the last firmware update it tried, in a few words. */
|
|
704
|
+
updateResult: e.string().max(80).optional(),
|
|
705
|
+
/**
|
|
706
|
+
* What the battery line reads, in millivolts — S3 boards only, which have a
|
|
707
|
+
* divider on GPIO9; a CYD has no way to measure a battery. Shown raw on the
|
|
708
|
+
* board's page until it has been checked against a real battery, and only
|
|
709
|
+
* then turned into an icon and a percentage on the glass.
|
|
710
|
+
*/
|
|
711
|
+
batteryMv: e.number().int().min(0).max(1e4).optional(),
|
|
712
|
+
/**
|
|
713
|
+
* The quarter turn its screen is set to (Settings → Turn), 0-3 as LovyanGFX
|
|
714
|
+
* counts them: even is upright, odd is sideways, the board's 240x320 panel
|
|
715
|
+
* turned. Its page previews apps the way the board stands (PANEL_SIZE).
|
|
716
|
+
* Absent from a board older than 2026-10-28, which only ever stood sideways.
|
|
717
|
+
*/
|
|
718
|
+
rotation: e.number().int().min(0).max(3).optional()
|
|
719
|
+
});
|
|
720
|
+
var Ze = e.object({
|
|
721
|
+
key: Z,
|
|
722
|
+
value: e.union([e.number().finite(), e.string().max(64), e.boolean()]),
|
|
723
|
+
unit: e.string().max(16).optional(),
|
|
724
|
+
at: e.number().int().nonnegative().optional()
|
|
725
|
+
});
|
|
726
|
+
e.object({
|
|
727
|
+
readings: e.array(Ze).min(1).max(16)
|
|
728
|
+
});
|
|
729
|
+
var p = e.string().regex(/^[0-9A-HJKMNP-TV-Z]{8}$/, "eight characters, no I L O or U"), R = e.string().regex(/^\d{4}$/);
|
|
730
|
+
e.object({
|
|
731
|
+
deviceId: p,
|
|
732
|
+
code: R,
|
|
733
|
+
/** Firmware build, so a support question has an answer. */
|
|
734
|
+
version: e.string().max(40).optional(),
|
|
735
|
+
/** Which board this is, from Boards.h — the two variants need different firmware. */
|
|
736
|
+
board: e.string().max(40).optional(),
|
|
737
|
+
/** dBm, always negative. -50 is across the room; -85 is a complaint. */
|
|
738
|
+
rssi: e.number().int().min(-127).max(0).optional(),
|
|
739
|
+
/** On the owner's own network. Long enough for IPv6, which this does not send yet. */
|
|
740
|
+
ip: e.string().max(45).optional(),
|
|
741
|
+
/** Seconds since boot. Not growing between check-ins means it is restarting. */
|
|
742
|
+
uptime: e.number().int().nonnegative().optional(),
|
|
743
|
+
/** Free heap in bytes. */
|
|
744
|
+
heap: e.number().int().nonnegative().optional(),
|
|
745
|
+
/** The app revision the board has actually drawn. */
|
|
746
|
+
drew: e.number().int().nonnegative().optional(),
|
|
747
|
+
/** Why it last restarted, already mapped to a word by the firmware. */
|
|
748
|
+
reset: e.string().max(40).optional(),
|
|
749
|
+
/**
|
|
750
|
+
* What the board has and whether each part works: "speaker: working",
|
|
751
|
+
* "battery: missing". This describes the device — its own hardware, as its
|
|
752
|
+
* own check screen reports it — and never the room: a state, not a reading.
|
|
753
|
+
* What the microphone heard, a sensor's value, or anything a part could
|
|
754
|
+
* learn about its surroundings does not belong here and is not representable
|
|
755
|
+
* (DeviceFeatureStateSchema is four words). Readings, when they come, travel
|
|
756
|
+
* as Signals and are argued for on their own.
|
|
757
|
+
*/
|
|
758
|
+
features: q.optional()
|
|
759
|
+
});
|
|
760
|
+
e.object({
|
|
761
|
+
deviceId: p,
|
|
762
|
+
code: R
|
|
763
|
+
});
|
|
764
|
+
e.object({
|
|
765
|
+
deviceId: p
|
|
766
|
+
});
|
|
767
|
+
e.object({
|
|
768
|
+
revision: e.number().int().nonnegative(),
|
|
769
|
+
sentAt: e.number().int().nonnegative()
|
|
770
|
+
});
|
|
771
|
+
e.object({
|
|
772
|
+
deviceId: p,
|
|
773
|
+
code: R,
|
|
774
|
+
ownerId: e.string().nullable().default(null),
|
|
775
|
+
version: e.string().max(40).optional(),
|
|
776
|
+
createdAt: e.number().int().nonnegative(),
|
|
777
|
+
lastSeenAt: e.number().int().nonnegative()
|
|
778
|
+
});
|
|
779
|
+
var qe = e.object({
|
|
780
|
+
version: e.string().min(1).max(40),
|
|
781
|
+
url: e.string().url().max(200),
|
|
782
|
+
sha256: e.string().regex(/^[0-9a-f]{64}$/),
|
|
783
|
+
bytes: e.number().int().positive(),
|
|
784
|
+
requestedAt: e.number().int().nonnegative()
|
|
785
|
+
}), Ct = "?", _t = {
|
|
786
|
+
// Accented Latin, CP437 0x80-0xA5 and 0xE1
|
|
787
|
+
Ç: { byte: 128, shows: "Ç" },
|
|
788
|
+
ü: { byte: 129, shows: "ü" },
|
|
789
|
+
é: { byte: 130, shows: "é" },
|
|
790
|
+
â: { byte: 131, shows: "â" },
|
|
791
|
+
ä: { byte: 132, shows: "ä" },
|
|
792
|
+
à: { byte: 133, shows: "à" },
|
|
793
|
+
å: { byte: 134, shows: "å" },
|
|
794
|
+
ç: { byte: 135, shows: "ç" },
|
|
795
|
+
ê: { byte: 136, shows: "ê" },
|
|
796
|
+
ë: { byte: 137, shows: "ë" },
|
|
797
|
+
è: { byte: 138, shows: "è" },
|
|
798
|
+
ï: { byte: 139, shows: "ï" },
|
|
799
|
+
î: { byte: 140, shows: "î" },
|
|
800
|
+
ì: { byte: 141, shows: "ì" },
|
|
801
|
+
Ä: { byte: 142, shows: "Ä" },
|
|
802
|
+
Å: { byte: 143, shows: "Å" },
|
|
803
|
+
É: { byte: 144, shows: "É" },
|
|
804
|
+
æ: { byte: 145, shows: "æ" },
|
|
805
|
+
Æ: { byte: 146, shows: "Æ" },
|
|
806
|
+
ô: { byte: 147, shows: "ô" },
|
|
807
|
+
ö: { byte: 148, shows: "ö" },
|
|
808
|
+
ò: { byte: 149, shows: "ò" },
|
|
809
|
+
û: { byte: 150, shows: "û" },
|
|
810
|
+
ù: { byte: 151, shows: "ù" },
|
|
811
|
+
ÿ: { byte: 152, shows: "ÿ" },
|
|
812
|
+
Ö: { byte: 153, shows: "Ö" },
|
|
813
|
+
Ü: { byte: 154, shows: "Ü" },
|
|
814
|
+
á: { byte: 160, shows: "á" },
|
|
815
|
+
í: { byte: 161, shows: "í" },
|
|
816
|
+
ó: { byte: 162, shows: "ó" },
|
|
817
|
+
ú: { byte: 163, shows: "ú" },
|
|
818
|
+
ñ: { byte: 164, shows: "ñ" },
|
|
819
|
+
Ñ: { byte: 165, shows: "Ñ" },
|
|
820
|
+
ß: { byte: 225, shows: "ß" },
|
|
821
|
+
// Symbols a readout uses
|
|
822
|
+
"¢": { byte: 155, shows: "¢" },
|
|
823
|
+
"£": { byte: 156, shows: "£" },
|
|
824
|
+
"¥": { byte: 157, shows: "¥" },
|
|
825
|
+
ƒ: { byte: 159, shows: "ƒ" },
|
|
826
|
+
ª: { byte: 166, shows: "ª" },
|
|
827
|
+
º: { byte: 167, shows: "º" },
|
|
828
|
+
"¿": { byte: 168, shows: "¿" },
|
|
829
|
+
"¬": { byte: 170, shows: "¬" },
|
|
830
|
+
"½": { byte: 171, shows: "½" },
|
|
831
|
+
"¼": { byte: 172, shows: "¼" },
|
|
832
|
+
"¡": { byte: 173, shows: "¡" },
|
|
833
|
+
"«": { byte: 174, shows: "«" },
|
|
834
|
+
"»": { byte: 175, shows: "»" },
|
|
835
|
+
π: { byte: 227, shows: "π" },
|
|
836
|
+
µ: { byte: 230, shows: "µ" },
|
|
837
|
+
Ω: { byte: 234, shows: "Ω" },
|
|
838
|
+
"∞": { byte: 236, shows: "∞" },
|
|
839
|
+
"±": { byte: 241, shows: "±" },
|
|
840
|
+
"≥": { byte: 242, shows: "≥" },
|
|
841
|
+
"≤": { byte: 243, shows: "≤" },
|
|
842
|
+
"÷": { byte: 246, shows: "÷" },
|
|
843
|
+
"≈": { byte: 247, shows: "≈" },
|
|
844
|
+
"°": { byte: 248, shows: "°" },
|
|
845
|
+
"·": { byte: 250, shows: "·" },
|
|
846
|
+
"√": { byte: 251, shows: "√" },
|
|
847
|
+
"²": { byte: 253, shows: "²" },
|
|
848
|
+
// Punctuation an AI writes without being asked, folded to ASCII
|
|
849
|
+
"‘": { byte: 39, shows: "'" },
|
|
850
|
+
"’": { byte: 39, shows: "'" },
|
|
851
|
+
"“": { byte: 34, shows: '"' },
|
|
852
|
+
"”": { byte: 34, shows: '"' },
|
|
853
|
+
"–": { byte: 45, shows: "-" },
|
|
854
|
+
"—": { byte: 45, shows: "-" },
|
|
855
|
+
"−": { byte: 45, shows: "-" },
|
|
856
|
+
" ": { byte: 32, shows: " " }
|
|
857
|
+
}, Bt = 28, Ft = {
|
|
858
|
+
background: "17 17 17",
|
|
859
|
+
foreground: "238 238 238",
|
|
860
|
+
muted: "153 153 153",
|
|
861
|
+
accent: "23 162 184",
|
|
862
|
+
success: "34 197 94",
|
|
863
|
+
warning: "245 158 11",
|
|
864
|
+
danger: "220 53 69"
|
|
865
|
+
}, kt = 48, jt = 3, It = {
|
|
866
|
+
sun: [
|
|
867
|
+
[32, 24, 32, 26, 30, 29, 29, 30, 26, 32, 22, 32, 19, 30, 18, 29, 16, 26, 16, 22, 18, 19, 19, 18, 22, 16, 26, 16, 29, 18, 30, 19, 32, 22, 32, 24],
|
|
868
|
+
[37, 24, 43, 24],
|
|
869
|
+
[33, 33, 37, 37],
|
|
870
|
+
[24, 37, 24, 43],
|
|
871
|
+
[15, 33, 11, 37],
|
|
872
|
+
[11, 24, 5, 24],
|
|
873
|
+
[15, 15, 11, 11],
|
|
874
|
+
[24, 11, 24, 5],
|
|
875
|
+
[33, 15, 37, 11]
|
|
876
|
+
],
|
|
877
|
+
partly: [
|
|
878
|
+
[17, 23, 15, 23, 13, 22, 11, 20, 10, 18, 10, 14, 11, 12, 13, 10, 15, 9, 19, 9, 21, 10, 23, 12, 24, 14, 24, 16],
|
|
879
|
+
[28, 16, 32, 16],
|
|
880
|
+
[9, 24, 6, 27],
|
|
881
|
+
[6, 16, 2, 16],
|
|
882
|
+
[9, 8, 6, 5],
|
|
883
|
+
[17, 5, 17, 1],
|
|
884
|
+
[25, 8, 28, 5],
|
|
885
|
+
[41, 33, 40, 35, 38, 37, 36, 38, 15, 38, 13, 37, 11, 33, 13, 29, 15, 27, 17, 27, 17, 24, 19, 20, 21, 18, 23, 17, 28, 17, 30, 18, 34, 22, 34, 24, 37, 25, 39, 26, 41, 28, 42, 30, 41, 33]
|
|
886
|
+
],
|
|
887
|
+
cloud: [
|
|
888
|
+
[42, 32, 40, 35, 38, 37, 35, 38, 12, 38, 10, 37, 9, 34, 8, 32, 9, 30, 10, 27, 14, 25, 14, 22, 15, 20, 21, 14, 27, 14, 33, 20, 34, 22, 37, 23, 39, 24, 41, 26, 42, 29, 42, 32]
|
|
889
|
+
],
|
|
890
|
+
fog: [
|
|
891
|
+
[8, 16, 40, 16],
|
|
892
|
+
[12, 24, 36, 24],
|
|
893
|
+
[8, 32, 40, 32]
|
|
894
|
+
],
|
|
895
|
+
rain: [
|
|
896
|
+
[41, 25, 37, 29, 35, 30, 13, 30, 10, 29, 9, 27, 9, 22, 10, 20, 14, 18, 15, 15, 15, 13, 19, 9, 21, 8, 26, 8, 29, 9, 31, 11, 33, 15, 36, 16, 38, 17, 40, 19, 41, 22, 41, 24],
|
|
897
|
+
[15, 36, 12, 43],
|
|
898
|
+
[24, 36, 21, 43],
|
|
899
|
+
[33, 36, 30, 43]
|
|
900
|
+
],
|
|
901
|
+
snow: [
|
|
902
|
+
[41, 25, 37, 29, 35, 30, 13, 30, 10, 29, 9, 27, 9, 22, 10, 20, 14, 18, 15, 15, 15, 13, 19, 9, 21, 8, 26, 8, 29, 9, 31, 11, 33, 15, 36, 16, 38, 17, 40, 19, 41, 22, 41, 24],
|
|
903
|
+
[14, 39, 14, 39],
|
|
904
|
+
[24, 42, 24, 42],
|
|
905
|
+
[34, 39, 34, 39],
|
|
906
|
+
[19, 45, 19, 45],
|
|
907
|
+
[29, 45, 29, 45]
|
|
908
|
+
],
|
|
909
|
+
storm: [
|
|
910
|
+
[41, 25, 37, 29, 35, 30, 13, 30, 10, 29, 9, 27, 9, 22, 10, 20, 14, 18, 15, 15, 15, 13, 19, 9, 21, 8, 26, 8, 29, 9, 31, 11, 33, 15, 36, 16, 38, 17, 40, 19, 41, 22, 41, 24],
|
|
911
|
+
[26, 33, 20, 41, 27, 41, 22, 47]
|
|
912
|
+
]
|
|
913
|
+
}, k = 8, Ye = e.object({
|
|
914
|
+
apps: e.array(W).min(1).max(k),
|
|
915
|
+
/** Which app to show — an index into `apps`. */
|
|
916
|
+
show: e.number().int().min(0).max(k - 1),
|
|
917
|
+
/** Move to the next app every this many minutes; 0 holds still. */
|
|
918
|
+
rotateMinutes: e.number().int().min(0).max(1440).default(0),
|
|
919
|
+
/**
|
|
920
|
+
* When each app was last sent, aligned with `apps`. The server's
|
|
921
|
+
* bookkeeping, not the board's: a send to a full shelf takes off the app
|
|
922
|
+
* sent longest ago, so sending always works. Missing reads as oldest.
|
|
923
|
+
*/
|
|
924
|
+
added: e.array(e.number().int().nonnegative()).max(k).optional()
|
|
925
|
+
});
|
|
926
|
+
e.discriminatedUnion("op", [
|
|
927
|
+
e.object({ op: e.literal("show"), deviceId: p, index: e.number().int().min(0) }),
|
|
928
|
+
e.object({ op: e.literal("remove"), deviceId: p, index: e.number().int().min(0) }),
|
|
929
|
+
e.object({
|
|
930
|
+
op: e.literal("move"),
|
|
931
|
+
deviceId: p,
|
|
932
|
+
from: e.number().int().min(0),
|
|
933
|
+
to: e.number().int().min(0)
|
|
934
|
+
}),
|
|
935
|
+
e.object({ op: e.literal("rotate"), deviceId: p, minutes: e.number().int().min(0).max(1440) }),
|
|
936
|
+
/**
|
|
937
|
+
* Swap the panel's light and dark. Not about apps, but it rides the same
|
|
938
|
+
* route and the same poll: some units of the same board carry a panel wired
|
|
939
|
+
* the other way, so one shows white on black and its twin black on white
|
|
940
|
+
* from identical firmware. It is a fact about one board's glass, so it is a
|
|
941
|
+
* per-board setting rather than a build.
|
|
942
|
+
*/
|
|
943
|
+
e.object({ op: e.literal("screen"), deviceId: p, invert: e.boolean() }),
|
|
944
|
+
/**
|
|
945
|
+
* Remove one entry from the list of apps sent to this board, by the revision
|
|
946
|
+
* it was sent as. The record only: what the board holds is the shelf's
|
|
947
|
+
* business, and `remove` above is how an app comes off it.
|
|
948
|
+
*/
|
|
949
|
+
e.object({ op: e.literal("forget"), deviceId: p, revision: e.number().int().min(1) })
|
|
950
|
+
]);
|
|
951
|
+
var b = e.string().regex(/^\d{1,3} \d{1,3} \d{1,3}$/, 'Must be "R G B", e.g. "13 110 253"').refine((a) => a.split(" ").every((s) => Number(s) <= 255), "Each channel is 0–255"), z = e.object({
|
|
952
|
+
background: b,
|
|
953
|
+
/** Text. */
|
|
954
|
+
foreground: b,
|
|
955
|
+
/** Quieter text: labels, captions, the second line. */
|
|
956
|
+
muted: b,
|
|
957
|
+
/** The brand colour: buttons and links on the site, highlights on a board. */
|
|
958
|
+
accent: b,
|
|
959
|
+
success: b,
|
|
960
|
+
warning: b,
|
|
961
|
+
danger: b
|
|
962
|
+
}), Y = e.enum(["inter", "tay", "pixel"]), Xe = ["0rem", "0.25rem", "0.5rem", "0.75rem", "1rem"];
|
|
963
|
+
e.object({
|
|
964
|
+
name: e.string().trim().min(1).max(40),
|
|
965
|
+
/** The preset it started from, when it started from one. */
|
|
966
|
+
base: e.string().max(40).optional(),
|
|
967
|
+
light: z,
|
|
968
|
+
dark: z,
|
|
969
|
+
lettering: Y,
|
|
970
|
+
radius: e.enum(Xe)
|
|
971
|
+
});
|
|
972
|
+
var Je = e.string().regex(/^[0-9a-f]{42}$/), Qe = e.union([e.literal("auto"), Y]);
|
|
973
|
+
e.object({
|
|
974
|
+
revision: e.number().int().nonnegative(),
|
|
975
|
+
sentAt: e.number().int().nonnegative().optional(),
|
|
976
|
+
document: W.optional(),
|
|
977
|
+
shelf: Ye.optional(),
|
|
978
|
+
update: qe.optional(),
|
|
979
|
+
screen: e.object({ invert: e.boolean() }).optional(),
|
|
980
|
+
palette: Je.optional(),
|
|
981
|
+
font: Qe.optional()
|
|
982
|
+
});
|
|
983
|
+
var Dt = { inter: { family: "Inter", weight: 500, caps: !1 }, tay: { family: "TAY Dreamboat", weight: 400, caps: !0 } }, Tt = { inter: { 10: { 0: 6, 1: 4, 2: 6, 3: 6, 4: 7, 5: 6, 6: 6, 7: 6, 8: 6, 9: 6, " ": 3, "!": 3, '"': 5, "#": 6, $: 6, "%": 10, "&": 7, "'": 3, "(": 4, ")": 4, "*": 5, "+": 7, ",": 3, "-": 5, ".": 3, "/": 4, ":": 3, ";": 3, "<": 7, "=": 7, ">": 7, "?": 5, "@": 10, A: 7, B: 7, C: 7, D: 7, E: 6, F: 6, G: 7, H: 7, I: 3, J: 6, K: 7, L: 6, M: 9, N: 8, O: 8, P: 6, Q: 8, R: 6, S: 6, T: 7, U: 7, V: 7, W: 10, X: 7, Y: 7, Z: 6, "[": 4, "\\": 4, "]": 4, "^": 5, _: 5, "`": 3, a: 6, b: 6, c: 6, d: 6, e: 6, f: 4, g: 6, h: 6, i: 3, j: 3, k: 6, l: 3, m: 9, n: 6, o: 6, p: 6, q: 6, r: 4, s: 5, t: 3, u: 6, v: 6, w: 8, x: 6, y: 6, z: 6, "{": 4, "|": 3, "}": 4, "~": 7, " ": 3, "¡": 3, "¢": 6, "£": 6, "¥": 6, ª: 5, "«": 6, "¬": 7, "°": 5, "±": 7, "²": 4, µ: 6, "·": 3, º: 5, "»": 6, "¼": 8, "½": 9, "¿": 5, Ä: 7, Å: 7, Æ: 10, Ç: 7, É: 6, Ñ: 8, Ö: 8, Ü: 7, ß: 6, à: 6, á: 6, â: 6, ä: 6, å: 6, æ: 9, ç: 6, è: 6, é: 6, ê: 6, ë: 6, ì: 3, í: 3, î: 3, ï: 3, ñ: 6, ò: 6, ó: 6, ô: 6, ö: 6, "÷": 7, ù: 6, ú: 6, û: 6, ü: 6, ÿ: 6, ƒ: 5, Ω: 8, π: 5, "–": 5, "—": 10, "‘": 3, "’": 3, "“": 5, "”": 5, "−": 7, "√": 5, "∞": 7, "≈": 5, "≤": 5, "≥": 5 }, 12: { 0: 8, 1: 5, 2: 7, 3: 8, 4: 8, 5: 7, 6: 8, 7: 7, 8: 8, 9: 8, " ": 3, "!": 4, '"': 6, "#": 8, $: 8, "%": 12, "&": 8, "'": 4, "(": 4, ")": 4, "*": 6, "+": 8, ",": 4, "-": 6, ".": 4, "/": 4, ":": 4, ";": 4, "<": 8, "=": 8, ">": 8, "?": 6, "@": 12, A: 9, B: 8, C: 9, D: 9, E: 7, F: 7, G: 9, H: 9, I: 3, J: 7, K: 8, L: 7, M: 11, N: 9, O: 9, P: 8, Q: 9, R: 8, S: 8, T: 8, U: 9, V: 9, W: 12, X: 8, Y: 8, Z: 8, "[": 4, "\\": 4, "]": 4, "^": 6, _: 6, "`": 4, a: 7, b: 7, c: 7, d: 7, e: 7, f: 5, g: 7, h: 7, i: 3, j: 3, k: 7, l: 3, m: 11, n: 7, o: 7, p: 7, q: 7, r: 5, s: 6, t: 4, u: 7, v: 7, w: 10, x: 7, y: 7, z: 7, "{": 5, "|": 4, "}": 5, "~": 8, " ": 3, "¡": 4, "¢": 7, "£": 7, "¥": 7, ª: 5, "«": 7, "¬": 8, "°": 5, "±": 8, "²": 5, µ: 7, "·": 4, º: 6, "»": 7, "¼": 10, "½": 10, "¿": 6, Ä: 9, Å: 9, Æ: 12, Ç: 9, É: 7, Ñ: 9, Ö: 9, Ü: 9, ß: 8, à: 7, á: 7, â: 7, ä: 7, å: 7, æ: 11, ç: 7, è: 7, é: 7, ê: 7, ë: 7, ì: 3, í: 3, î: 3, ï: 3, ñ: 7, ò: 7, ó: 7, ô: 7, ö: 7, "÷": 8, ù: 7, ú: 7, û: 7, ü: 7, ÿ: 7, ƒ: 6, Ω: 9, π: 7, "–": 6, "—": 12, "‘": 3, "’": 3, "“": 6, "”": 6, "−": 8, "√": 7, "∞": 9, "≈": 7, "≤": 7, "≥": 7 }, 16: { 0: 10, 1: 7, 2: 10, 3: 10, 4: 11, 5: 10, 6: 10, 7: 9, 8: 10, 9: 10, " ": 4, "!": 5, '"': 8, "#": 10, $: 10, "%": 16, "&": 10, "'": 5, "(": 6, ")": 6, "*": 8, "+": 11, ",": 5, "-": 7, ".": 5, "/": 6, ":": 5, ";": 5, "<": 11, "=": 11, ">": 11, "?": 8, "@": 16, A: 11, B: 11, C: 12, D: 12, E: 10, F: 9, G: 12, H: 12, I: 4, J: 9, K: 11, L: 9, M: 15, N: 12, O: 12, P: 10, Q: 12, R: 10, S: 10, T: 10, U: 12, V: 11, W: 16, X: 11, Y: 11, Z: 10, "[": 6, "\\": 6, "]": 6, "^": 8, _: 7, "`": 5, a: 9, b: 10, c: 9, d: 10, e: 9, f: 6, g: 10, h: 10, i: 4, j: 4, k: 9, l: 4, m: 14, n: 10, o: 10, p: 10, q: 10, r: 6, s: 9, t: 5, u: 10, v: 9, w: 13, x: 9, y: 9, z: 9, "{": 7, "|": 6, "}": 7, "~": 11, " ": 4, "¡": 5, "¢": 9, "£": 10, "¥": 9, ª: 7, "«": 10, "¬": 11, "°": 7, "±": 11, "²": 7, µ: 10, "·": 5, º: 8, "»": 10, "¼": 13, "½": 14, "¿": 8, Ä: 11, Å: 11, Æ: 16, Ç: 12, É: 10, Ñ: 12, Ö: 12, Ü: 12, ß: 10, à: 9, á: 9, â: 9, ä: 9, å: 9, æ: 15, ç: 9, è: 9, é: 9, ê: 9, ë: 9, ì: 4, í: 4, î: 4, ï: 4, ñ: 10, ò: 10, ó: 10, ô: 10, ö: 10, "÷": 11, ù: 10, ú: 10, û: 10, ü: 10, ÿ: 9, ƒ: 8, Ω: 12, π: 9, "–": 8, "—": 16, "‘": 4, "’": 4, "“": 8, "”": 8, "−": 11, "√": 9, "∞": 11, "≈": 9, "≤": 9, "≥": 9 }, 20: { 0: 13, 1: 8, 2: 12, 3: 13, 4: 13, 5: 12, 6: 13, 7: 11, 8: 13, 9: 13, " ": 5, "!": 6, '"': 10, "#": 13, $: 13, "%": 20, "&": 13, "'": 6, "(": 7, ")": 7, "*": 10, "+": 13, ",": 6, "-": 9, ".": 6, "/": 7, ":": 6, ";": 6, "<": 13, "=": 13, ">": 13, "?": 11, "@": 20, A: 14, B: 13, C: 15, D: 14, E: 12, F: 12, G: 15, H: 15, I: 5, J: 12, K: 14, L: 11, M: 18, N: 15, O: 15, P: 13, Q: 15, R: 13, S: 13, T: 13, U: 15, V: 14, W: 20, X: 14, Y: 14, Z: 13, "[": 7, "\\": 7, "]": 7, "^": 10, _: 9, "`": 7, a: 11, b: 12, c: 12, d: 12, e: 12, f: 8, g: 12, h: 12, i: 5, j: 5, k: 11, l: 5, m: 18, n: 12, o: 12, p: 12, q: 12, r: 8, s: 11, t: 7, u: 12, v: 11, w: 17, x: 11, y: 12, z: 11, "{": 9, "|": 7, "}": 9, "~": 13, " ": 5, "¡": 6, "¢": 12, "£": 12, "¥": 11, ª: 9, "«": 12, "¬": 13, "°": 9, "±": 13, "²": 9, µ: 12, "·": 6, º: 10, "»": 12, "¼": 16, "½": 17, "¿": 11, Ä: 14, Å: 14, Æ: 20, Ç: 15, É: 12, Ñ: 15, Ö: 15, Ü: 15, ß: 13, à: 11, á: 11, â: 11, ä: 11, å: 11, æ: 18, ç: 12, è: 12, é: 12, ê: 12, ë: 12, ì: 5, í: 5, î: 5, ï: 5, ñ: 12, ò: 12, ó: 12, ô: 12, ö: 12, "÷": 13, ù: 12, ú: 12, û: 12, ü: 12, ÿ: 12, ƒ: 10, Ω: 15, π: 11, "–": 10, "—": 20, "‘": 6, "’": 6, "“": 9, "”": 9, "−": 13, "√": 11, "∞": 14, "≈": 11, "≤": 11, "≥": 11 }, 28: { 0: 18, 1: 12, 2: 17, 3: 18, 4: 18, 5: 17, 6: 18, 7: 16, 8: 18, 9: 18, " ": 7, "!": 9, '"': 14, "#": 18, $: 18, "%": 28, "&": 18, "'": 9, "(": 10, ")": 10, "*": 15, "+": 19, ",": 8, "-": 13, ".": 8, "/": 10, ":": 8, ";": 9, "<": 19, "=": 19, ">": 19, "?": 15, "@": 28, A: 20, B: 18, C: 21, D: 20, E: 17, F: 17, G: 21, H: 21, I: 8, J: 16, K: 19, L: 16, M: 26, N: 21, O: 21, P: 18, Q: 22, R: 18, S: 18, T: 18, U: 21, V: 20, W: 28, X: 20, Y: 19, Z: 18, "[": 10, "\\": 10, "]": 10, "^": 13, _: 13, "`": 9, a: 16, b: 17, c: 16, d: 17, e: 16, f: 11, g: 17, h: 17, i: 7, j: 7, k: 16, l: 7, m: 25, n: 17, o: 17, p: 17, q: 17, r: 11, s: 15, t: 10, u: 17, v: 16, w: 23, x: 16, y: 16, z: 16, "{": 12, "|": 10, "}": 12, "~": 19, " ": 7, "¡": 9, "¢": 16, "£": 17, "¥": 16, ª: 13, "«": 17, "¬": 19, "°": 13, "±": 19, "²": 13, µ: 17, "·": 8, º: 14, "»": 17, "¼": 23, "½": 24, "¿": 15, Ä: 20, Å: 20, Æ: 28, Ç: 21, É: 17, Ñ: 21, Ö: 21, Ü: 21, ß: 18, à: 16, á: 16, â: 16, ä: 16, å: 16, æ: 26, ç: 16, è: 16, é: 16, ê: 16, ë: 16, ì: 7, í: 7, î: 7, ï: 7, ñ: 17, ò: 17, ó: 17, ô: 17, ö: 17, "÷": 19, ù: 17, ú: 17, û: 17, ü: 17, ÿ: 16, ƒ: 14, Ω: 22, π: 15, "–": 14, "—": 28, "‘": 8, "’": 8, "“": 13, "”": 13, "−": 19, "√": 15, "∞": 20, "≈": 15, "≤": 15, "≥": 15 }, 56: { 0: 36, 1: 23, 2: 35, 3: 35, 4: 37, 5: 34, 6: 35, 7: 32, 8: 35, 9: 35, " ": 15, "!": 17, '"': 28, "#": 36, $: 36, "%": 56, "&": 37, "'": 18, "(": 21, ")": 21, "*": 29, "+": 37, ",": 17, "-": 26, ".": 17, "/": 21, ":": 17, ";": 18, "<": 37, "=": 37, ">": 37, "?": 30, "@": 55, A: 40, B: 37, C: 41, D: 40, E: 34, F: 33, G: 42, H: 42, I: 15, J: 32, K: 39, L: 32, M: 51, N: 42, O: 43, P: 36, Q: 43, R: 36, S: 36, T: 37, U: 41, V: 40, W: 56, X: 39, Y: 39, Z: 36, "[": 21, "\\": 21, "]": 21, "^": 27, _: 26, "`": 19, a: 32, b: 35, c: 32, d: 35, e: 33, f: 21, g: 35, h: 34, i: 14, j: 14, k: 31, l: 14, m: 50, n: 34, o: 34, p: 35, q: 35, r: 22, s: 30, t: 19, u: 34, v: 32, w: 46, x: 31, y: 32, z: 31, "{": 25, "|": 19, "}": 25, "~": 37, "°": 26 } }, tay: { 28: { 0: 29, 1: 16, 2: 28, 3: 28, 4: 30, 5: 27, 6: 28, 7: 26, 8: 29, 9: 29, " ": 12, "!": 16, '"': 12, "#": 27, $: 27, "%": 29, "&": 33, "'": 9, "(": 20, ")": 20, "*": 14, "+": 21, ",": 10, "-": 16, ".": 10, "/": 19, ":": 13, ";": 12, "<": 18, "=": 22, ">": 18, "?": 27, "@": 31, A: 28, B: 32, C: 28, D: 30, E: 30, F: 29, G: 29, H: 32, I: 16, J: 27, K: 29, L: 27, M: 36, N: 32, O: 29, P: 30, Q: 30, R: 30, S: 29, T: 31, U: 29, V: 28, W: 40, X: 29, Y: 29, Z: 30, "[": 17, "\\": 19, "]": 17, "^": 13, _: 19, "`": 9, "{": 13, "|": 6, "}": 13, "~": 15, " ": 8, "¡": 15, "¢": 14, "£": 26, "¥": 31, ª: 8, "«": 14, "¬": 16, "°": 14, "±": 15, "²": 8, "·": 7, º: 9, "»": 14, "¼": 21, "½": 21, "¿": 26, Ä: 28, Å: 28, Æ: 25, Ç: 28, É: 30, Ñ: 32, Ö: 29, Ü: 29, "÷": 15, Ω: 22, "–": 14, "—": 28, "‘": 9, "’": 9, "“": 12, "”": 12, "−": 16, "√": 15, "∞": 20, "≈": 15, "≤": 15, "≥": 15 }, 56: { 0: 58, 1: 33, 2: 56, 3: 57, 4: 60, 5: 55, 6: 57, 7: 51, 8: 58, 9: 59, " ": 24, "!": 32, '"': 23, "#": 55, $: 55, "%": 59, "&": 66, "'": 18, "(": 39, ")": 39, "*": 28, "+": 43, ",": 20, "-": 31, ".": 20, "/": 38, ":": 26, ";": 23, "<": 37, "=": 44, ">": 37, "?": 54, "@": 61, A: 56, B: 63, C: 56, D: 60, E: 60, F: 58, G: 58, H: 63, I: 33, J: 55, K: 58, L: 53, M: 72, N: 65, O: 59, P: 60, Q: 59, R: 61, S: 58, T: 62, U: 58, V: 56, W: 79, X: 58, Y: 58, Z: 59, "[": 34, "\\": 38, "]": 34, "^": 26, _: 39, "`": 19, "{": 27, "|": 11, "}": 27, "~": 30, "°": 27 } } };
|
|
984
|
+
e.object({
|
|
985
|
+
deviceId: e.string().min(1, "Device ID is required"),
|
|
986
|
+
timeRange: e.enum(["1h", "24h", "7d"], {
|
|
987
|
+
errorMap: () => ({ message: "Time range must be 1h, 24h, or 7d" })
|
|
988
|
+
}),
|
|
989
|
+
metrics: e.array(
|
|
990
|
+
e.enum(["temperature", "humidity", "vwc", "ec", "ph", "pressure", "co2"])
|
|
991
|
+
).min(1, "At least one metric is required").max(4, "Maximum 4 metrics per graph")
|
|
992
|
+
});
|
|
993
|
+
var j = "gemini-2.5-flash", et = "gemini-2.5-flash", tt = "gemini-2.5-pro", Rt = {
|
|
994
|
+
"google-gemini": "gemini-2.5-flash",
|
|
995
|
+
openai: "gpt-4o-mini",
|
|
996
|
+
anthropic: "claude-haiku-4-5-20251001",
|
|
997
|
+
grok: "grok-2-1212",
|
|
998
|
+
deepseek: "deepseek-chat",
|
|
999
|
+
ollama: "llama3.3"
|
|
1000
|
+
}, Ot = {
|
|
1001
|
+
/** The Strategist: high creativity, exploratory conversation */
|
|
1002
|
+
STRATEGIST: {
|
|
1003
|
+
model: et,
|
|
1004
|
+
provider: "google-gemini",
|
|
1005
|
+
temperature: 0.7
|
|
1006
|
+
},
|
|
1007
|
+
/** The Architect: data schema and resource modeling — precision required */
|
|
1008
|
+
ARCHITECT: {
|
|
1009
|
+
model: j,
|
|
1010
|
+
provider: "google-gemini",
|
|
1011
|
+
temperature: 0.3
|
|
1012
|
+
},
|
|
1013
|
+
/** The Designer: UI layout generation — moderate creativity */
|
|
1014
|
+
DESIGNER: {
|
|
1015
|
+
model: j,
|
|
1016
|
+
provider: "google-gemini",
|
|
1017
|
+
temperature: 0.5
|
|
1018
|
+
},
|
|
1019
|
+
/** The Reviewer/Product Owner: structured plan output — strict adherence.
|
|
1020
|
+
* Uses the Pro tier for superior reasoning on complex structured tasks.
|
|
1021
|
+
*/
|
|
1022
|
+
REVIEWER: {
|
|
1023
|
+
model: tt,
|
|
1024
|
+
provider: "google-gemini",
|
|
1025
|
+
temperature: 0.2
|
|
1026
|
+
},
|
|
1027
|
+
/** The Genesis Engine: one-shot app generation — must be schema-strict */
|
|
1028
|
+
GENESIS: {
|
|
1029
|
+
model: j,
|
|
1030
|
+
provider: "google-gemini",
|
|
1031
|
+
temperature: 0.2
|
|
1032
|
+
}
|
|
1033
|
+
}, Mt = `
|
|
1034
|
+
You write tiny apps for a small desk device whose screen is 320 pixels wide and
|
|
1035
|
+
240 pixels high — landscape.
|
|
1036
|
+
|
|
1037
|
+
Reply with ONE JSON object and nothing else. No markdown fences, no explanation.
|
|
1038
|
+
|
|
1039
|
+
THE SHAPE
|
|
1040
|
+
|
|
1041
|
+
{
|
|
1042
|
+
"schemaVersion": 1,
|
|
1043
|
+
"id": "lowercase-slug",
|
|
1044
|
+
"name": "Short Name",
|
|
1045
|
+
"screen": "320x240",
|
|
1046
|
+
"background": "background",
|
|
1047
|
+
"sources": { },
|
|
1048
|
+
"blocks": [ ]
|
|
1049
|
+
}
|
|
1050
|
+
|
|
1051
|
+
BLOCKS — up to 12, drawn top to bottom. Each is one of:
|
|
1052
|
+
|
|
1053
|
+
{ "type": "text", "value": V, "size": S, "align": A, "color": C, "prefix": "H ", "suffix": "°" }
|
|
1054
|
+
{ "type": "icon", "value": V, "size": "sm"|"md"|"lg"|"xl", "align": A, "color": C }
|
|
1055
|
+
{ "type": "dial", "value": V, "min": 0, "max": 100, "label": "CPU", "color": C }
|
|
1056
|
+
{ "type": "bar", "value": V, "min": 0, "max": 100, "color": C }
|
|
1057
|
+
{ "type": "sparkline", "series": V, "color": C }
|
|
1058
|
+
{ "type": "status", "state": V, "label": "Door", "color": C }
|
|
1059
|
+
{ "type": "sprite", "palette": [C, ...], "grid": "0011
|
|
1060
|
+
0110
|
|
1061
|
+
1100
|
|
1062
|
+
0011", "align": A }
|
|
1063
|
+
{ "type": "group", "direction": "row"|"stack", "gap": 8, "align": A, "pack": true, "children": [ ...leaves... ] }
|
|
1064
|
+
|
|
1065
|
+
A row splits the width into equal cells. Add "pack": true and each child takes
|
|
1066
|
+
only its own width, "gap" apart — a number with its icon right beside it, or
|
|
1067
|
+
"H 68° L 56°" as one line. Put "valign": "center" at the top level of the
|
|
1068
|
+
document to centre the blocks on the screen rather than start at the top, and
|
|
1069
|
+
"font": "pixel" for chunky retro lettering or "font": "tay" for the Ramme
|
|
1070
|
+
display face, all capitals, good for signs and big numbers (the default is a
|
|
1071
|
+
smooth plain face), and
|
|
1072
|
+
"halign": "center" to centre them across it — the lines keep their own
|
|
1073
|
+
alignment inside a column as wide as the widest, and the column is centred.
|
|
1074
|
+
|
|
1075
|
+
AN ICON is the sky drawn in outline: "sun", "partly", "cloud", "fog", "rain",
|
|
1076
|
+
"snow" or "storm". Bind its value to a weather source's "icon" field so it
|
|
1077
|
+
follows the weather — { "source": "forecast", "field": "icon" } — or write one
|
|
1078
|
+
of those names as a literal. Sizes are 24, 48, 72 and 96 pixels square. Prefer
|
|
1079
|
+
it to drawing a weather sprite: it costs nothing and the board draws it crisply.
|
|
1080
|
+
|
|
1081
|
+
DRAWING A SPRITE — you may, and here is the only form that works.
|
|
1082
|
+
|
|
1083
|
+
Write a "grid": one line per row, one hex character per pixel, each character
|
|
1084
|
+
indexing "palette" (so "0" is the first colour, "1" the second, up to "f").
|
|
1085
|
+
Every row must be exactly the same length. Up to 64x64, but 16x16 and 32x32
|
|
1086
|
+
look far better — small palettes and bold shapes read on a 320x240 panel, fine
|
|
1087
|
+
detail does not.
|
|
1088
|
+
|
|
1089
|
+
{ "type": "sprite",
|
|
1090
|
+
"palette": ["background", "255 214 10", "17 17 17"],
|
|
1091
|
+
"grid": "0011110
|
|
1092
|
+
0122210
|
|
1093
|
+
1222221
|
|
1094
|
+
1211121
|
|
1095
|
+
1222221
|
|
1096
|
+
0122210
|
|
1097
|
+
0011110" }
|
|
1098
|
+
|
|
1099
|
+
Put the background colour FIRST so "0" means empty, and use "." as a synonym
|
|
1100
|
+
for "0" if it makes the shape easier to see while you write it.
|
|
1101
|
+
|
|
1102
|
+
Palette entries are the same colours as everywhere else: a semantic token
|
|
1103
|
+
re-colours with the theme, which is what an icon wants, and literal "R G B"
|
|
1104
|
+
does not, which is what a picture wants.
|
|
1105
|
+
|
|
1106
|
+
NEVER write a "pixels" field yourself. That is base64 of packed nibbles, one
|
|
1107
|
+
wrong character shifts every pixel after it, and you cannot check it. Write the
|
|
1108
|
+
grid; it is converted for you. If a document you are editing already has
|
|
1109
|
+
"pixels" and no "grid", leave it exactly as it is.
|
|
1110
|
+
|
|
1111
|
+
PHOTOS — a document you are editing may hold { "type": "image", "asset": "<64 hex
|
|
1112
|
+
characters>", ... }. That is a picture someone uploaded, named by the hash of
|
|
1113
|
+
its file. Keep every image block exactly as it is unless asked to remove it, and
|
|
1114
|
+
never write one yourself: you cannot make the file it names, so any hash you
|
|
1115
|
+
invent draws nothing.
|
|
1116
|
+
|
|
1117
|
+
Count your rows before you answer. A grid whose rows are different lengths is
|
|
1118
|
+
the one mistake that will come back to you.
|
|
1119
|
+
|
|
1120
|
+
A group holds leaves only. Groups do NOT nest inside groups — the device has no
|
|
1121
|
+
layout engine, only computed offsets.
|
|
1122
|
+
|
|
1123
|
+
CONDITIONS — any block may also carry these:
|
|
1124
|
+
|
|
1125
|
+
"hideWhen": { "value": O, "op": "<", "than": 32 }
|
|
1126
|
+
leave it off the screen entirely while that is true
|
|
1127
|
+
|
|
1128
|
+
"rules": [ { "when": { "value": O, "op": "<", "than": 32 }, "color": "accent" },
|
|
1129
|
+
{ "when": { "value": O, "op": ">", "than": 85 }, "color": "danger" } ]
|
|
1130
|
+
style that applies only when something is true. First match wins, so write
|
|
1131
|
+
the narrowest band first. At most four. Each may set "color", "size" or both.
|
|
1132
|
+
|
|
1133
|
+
op is one of "<" "<=" ">" ">=" "==" "!="
|
|
1134
|
+
Only == and != work on words; the rest are for numbers.
|
|
1135
|
+
|
|
1136
|
+
O is an operand: { "literal": 32 } or { "source": "forecast", "field": "temperature" }
|
|
1137
|
+
|
|
1138
|
+
This is how "make it red when it is freezing" is expressed. Use it whenever a
|
|
1139
|
+
request contains "when", "if", "unless", "only", or a colour tied to a value.
|
|
1140
|
+
|
|
1141
|
+
S (size) "xs" | "sm" | "base" | "lg" | "xl" | "display"
|
|
1142
|
+
A (align) "start" | "center" | "end"
|
|
1143
|
+
C (color) "background" | "foreground" | "muted" | "accent" | "success" | "warning" | "danger"
|
|
1144
|
+
or three space-separated RGB numbers, e.g. "220 53 69"
|
|
1145
|
+
|
|
1146
|
+
VALUES — every V is one of:
|
|
1147
|
+
|
|
1148
|
+
{ "literal": "Hello" } text you wrote
|
|
1149
|
+
{ "source": "forecast", "field": "temperature" } read from a source
|
|
1150
|
+
{ "compute": "subtract", "of": [O, O], "round": true } arithmetic
|
|
1151
|
+
|
|
1152
|
+
compute is "add" | "subtract" | "multiply" | "divide", exactly two operands,
|
|
1153
|
+
and it does NOT nest — an operand is a literal or a source field, never
|
|
1154
|
+
another compute. "The difference between the high and the low" is the shape
|
|
1155
|
+
this is for.
|
|
1156
|
+
|
|
1157
|
+
SOURCES — declare what the app reads, then bind to it by name:
|
|
1158
|
+
|
|
1159
|
+
"forecast": { "kind": "weather", "latitude": 39.95, "longitude": -75.17,
|
|
1160
|
+
"units": "imperial", "refreshSeconds": 600 }
|
|
1161
|
+
fields: temperature, condition, icon, high, low
|
|
1162
|
+
"now": { "kind": "clock", "timezone": "America/New_York", "twentyFourHour": false }
|
|
1163
|
+
fields: time, date, weekday, hour (hour is 0-23, for rules about time of day)
|
|
1164
|
+
"until": { "kind": "countdown", "target": "2026-12-25", "label": "Christmas" }
|
|
1165
|
+
fields: days, hours, minutes, seconds, label
|
|
1166
|
+
"fixed": { "kind": "static", "values": { "anything": 1 } }
|
|
1167
|
+
fields: whatever you put in values
|
|
1168
|
+
"turn": { "kind": "cycle", "count": 2, "minutes": 5 }
|
|
1169
|
+
fields: index (0, 1, … count-1, moving on every "minutes", then round again)
|
|
1170
|
+
For things that take turns: give each block "hideWhen": { "value":
|
|
1171
|
+
{ "source": "turn", "field": "index" }, "op": "!=", "than": N } so only
|
|
1172
|
+
block N shows on turn N. The board changes at most once a minute.
|
|
1173
|
+
"probe": { "kind": "board", "units": "imperial" }
|
|
1174
|
+
fields: temperature, connected
|
|
1175
|
+
What a sensor plugged into the board itself is reading: a temperature
|
|
1176
|
+
probe's temperature, a whole number in units, updated about once a
|
|
1177
|
+
second. connected is false when nothing is plugged in, and temperature
|
|
1178
|
+
is then missing (it draws "--"): use hideWhen on connected to show
|
|
1179
|
+
"Plug in the probe" instead. Use this, not weather, for "my sensor",
|
|
1180
|
+
"the probe", "water temperature" and the like.
|
|
1181
|
+
|
|
1182
|
+
RULES
|
|
1183
|
+
|
|
1184
|
+
1. 320x240 is small, and it is wider than it is tall. A "display" size text is
|
|
1185
|
+
about 56 pixels tall — one of those and two or three smaller lines fill the
|
|
1186
|
+
height. Use the width: a "row" group puts two or three things side by side.
|
|
1187
|
+
Prefer fewer, bigger things over a dense dashboard.
|
|
1188
|
+
2. Use semantic colours unless asked for a specific one. They follow the theme.
|
|
1189
|
+
3. There is no scrolling and no text wrapping. Long strings are cut off.
|
|
1190
|
+
4. No tables, no forms, no images, no buttons. The screen shows; it does not
|
|
1191
|
+
take input.
|
|
1192
|
+
5. If the request needs something the vocabulary cannot express, build the
|
|
1193
|
+
closest thing it can and do not invent a component.
|
|
1194
|
+
6. Prefer a rule over a fixed colour whenever the request ties appearance to a
|
|
1195
|
+
value. "Red when cold" is a rule; "red" is not.
|
|
1196
|
+
`.trim(), Pt = "Here is the current app. Change only what is asked:", o = e.string().regex(
|
|
1197
|
+
/^\d{1,3}\s+\d{1,3}\s+\d{1,3}$/,
|
|
1198
|
+
'Must be space-separated RGB integers (e.g. "13 110 253")'
|
|
1199
|
+
), at = e.object({
|
|
1200
|
+
// ── Core Brand ───────────────────────────────────────────────────────────
|
|
1201
|
+
"--app-primary-color": o.optional(),
|
|
1202
|
+
"--app-primary-foreground-color": o.optional(),
|
|
1203
|
+
"--app-secondary-color": o.optional(),
|
|
1204
|
+
"--app-secondary-foreground-color": o.optional(),
|
|
1205
|
+
"--app-accent-color": o.optional(),
|
|
1206
|
+
"--app-accent-foreground-color": o.optional(),
|
|
1207
|
+
// ── Base Surface ─────────────────────────────────────────────────────────
|
|
1208
|
+
"--app-bg-color": o.optional(),
|
|
1209
|
+
"--app-card-bg-color": o.optional(),
|
|
1210
|
+
"--app-text-color": o.optional(),
|
|
1211
|
+
"--app-border-color": o.optional(),
|
|
1212
|
+
"--app-muted-bg": o.optional(),
|
|
1213
|
+
"--app-muted-text": o.optional(),
|
|
1214
|
+
// ── Shape ────────────────────────────────────────────────────────────────
|
|
1215
|
+
"--app-border-radius-sm": e.string().optional(),
|
|
1216
|
+
"--app-border-radius-md": e.string().optional(),
|
|
1217
|
+
"--app-border-radius-lg": e.string().optional(),
|
|
1218
|
+
// ── Form Controls ────────────────────────────────────────────────────────
|
|
1219
|
+
"--app-input-bg-color": o.optional(),
|
|
1220
|
+
"--app-input-text-color": o.optional(),
|
|
1221
|
+
"--app-input-border-color": o.optional(),
|
|
1222
|
+
"--app-input-focus-ring-color": o.optional(),
|
|
1223
|
+
"--app-input-placeholder-color": o.optional(),
|
|
1224
|
+
// ── Chart Palette ────────────────────────────────────────────────────────
|
|
1225
|
+
"--app-chart-1": o.optional(),
|
|
1226
|
+
"--app-chart-2": o.optional(),
|
|
1227
|
+
"--app-chart-3": o.optional(),
|
|
1228
|
+
"--app-chart-4": o.optional(),
|
|
1229
|
+
"--app-chart-5": o.optional()
|
|
1230
|
+
}).strict(), nt = e.object({
|
|
1231
|
+
/** Google Font name for headings (h1–h4, .font-serif). Example: "Playfair Display" */
|
|
1232
|
+
heading: e.string(),
|
|
1233
|
+
/** Google Font name for body text. Example: "Inter" */
|
|
1234
|
+
body: e.string(),
|
|
1235
|
+
/** Optional monospace font. Example: "Roboto Mono" */
|
|
1236
|
+
mono: e.string().optional()
|
|
1237
|
+
});
|
|
1238
|
+
e.object({
|
|
1239
|
+
/** Short descriptive theme name. Example: "Midnight Garden" */
|
|
1240
|
+
name: e.string(),
|
|
1241
|
+
/** One-sentence vibe description. Example: "Dark indigo with golden accents." */
|
|
1242
|
+
description: e.string(),
|
|
1243
|
+
/** Google Font pairing for heading and body text. */
|
|
1244
|
+
fonts: nt.optional(),
|
|
1245
|
+
/**
|
|
1246
|
+
* CSS variable overrides.
|
|
1247
|
+
* Every key must match an --app-* variable name.
|
|
1248
|
+
* All color values must be space-separated RGB integers.
|
|
1249
|
+
*/
|
|
1250
|
+
cssVars: at
|
|
1251
|
+
});
|
|
1252
|
+
e.object({
|
|
1253
|
+
primary: o,
|
|
1254
|
+
neutral: o,
|
|
1255
|
+
success: o,
|
|
1256
|
+
warning: o,
|
|
1257
|
+
destructive: o,
|
|
1258
|
+
radius: e.enum(["none", "sm", "md", "lg", "full"])
|
|
1259
|
+
});
|
|
1260
|
+
var Nt = {
|
|
1261
|
+
primary: "13 110 253",
|
|
1262
|
+
neutral: "24 24 27",
|
|
1263
|
+
success: "34 197 94",
|
|
1264
|
+
warning: "234 179 8",
|
|
1265
|
+
destructive: "239 68 68",
|
|
1266
|
+
radius: "md"
|
|
1267
|
+
}, d = e.number().finite(), i = d.positive(), h = d.nonnegative(), ot = e.object({
|
|
1268
|
+
name: e.string().min(1).default("Bambu Lab X1 Carbon"),
|
|
1269
|
+
/** Walls are whole multiples of this. */
|
|
1270
|
+
nozzle: i.default(0.4),
|
|
1271
|
+
/** Gap for parts that slide together: the case's lip, a lid. */
|
|
1272
|
+
clearance_slip: h.default(0.2),
|
|
1273
|
+
/** Gap for a friction fit. */
|
|
1274
|
+
clearance_press: h.default(0.1)
|
|
1275
|
+
}), it = e.enum(["east", "west", "north", "south", "top", "bottom"]), rt = e.object({
|
|
1276
|
+
/** The tongue's length, from its free end to where it joins the floor. */
|
|
1277
|
+
length: i.default(12),
|
|
1278
|
+
/** Its width. */
|
|
1279
|
+
width: i.default(5),
|
|
1280
|
+
/** The way from the switch to where the tongue joins the floor. */
|
|
1281
|
+
hinge: e.enum(["east", "west", "north", "south"])
|
|
1282
|
+
}), st = e.object({
|
|
1283
|
+
/** usb_c, screen, reset_button, status_led, sd_card… */
|
|
1284
|
+
name: e.string().min(1),
|
|
1285
|
+
edge: it,
|
|
1286
|
+
/** From the centre of that face — see COORDINATES above. */
|
|
1287
|
+
offset_from_center: e.tuple([d, d]).default([0, 0]),
|
|
1288
|
+
/**
|
|
1289
|
+
* A grille is a field of small round holes filling an ellipse of
|
|
1290
|
+
* `cutout_size` — a speaker's — on a top or bottom face only.
|
|
1291
|
+
*/
|
|
1292
|
+
cutout_shape: e.enum(["rect", "rounded_rect", "circle", "grille"]),
|
|
1293
|
+
/** [width, height] of the opening, including room for a plug's boot. A circle uses the first as its diameter. */
|
|
1294
|
+
cutout_size: e.tuple([i, i]),
|
|
1295
|
+
/** How far the part sticks out past the component's edge. */
|
|
1296
|
+
protrusion: h.default(0),
|
|
1297
|
+
/** A wider recess on the outside face, [width, height, depth], for a thick cable boot. */
|
|
1298
|
+
outer_recess: e.tuple([i, i, i]).optional(),
|
|
1299
|
+
/** Press it through the floor instead of opening a hole — see FlexButtonSchema. */
|
|
1300
|
+
flex_button: rt.optional(),
|
|
1301
|
+
/**
|
|
1302
|
+
* A 45° ramp this deep round the opening at the outside face, widening it
|
|
1303
|
+
* by this much a side there. For a screen set back behind a bezel: the
|
|
1304
|
+
* picture's edges stay in view and a fingertip reaches them. Top or bottom
|
|
1305
|
+
* openings only.
|
|
1306
|
+
*/
|
|
1307
|
+
chamfer: h.optional()
|
|
1308
|
+
}), lt = e.object({
|
|
1309
|
+
/** Four holes, this far in from each corner: [east-west, north-south]. */
|
|
1310
|
+
inset_from_corners: e.tuple([i, i]).optional(),
|
|
1311
|
+
/** Or exactly where they are: [east, north] from the footprint centre. */
|
|
1312
|
+
positions: e.array(e.tuple([d, d])).min(1).optional(),
|
|
1313
|
+
thread: e.enum(["M2", "M2.5", "M3"]),
|
|
1314
|
+
/** Heat-set insert outer diameter and depth. split_shell_lip only: tray_bezel's screws cut their own thread. */
|
|
1315
|
+
insert_od: i.optional(),
|
|
1316
|
+
insert_depth: i.optional()
|
|
1317
|
+
}).refine((a) => (a.inset_from_corners ? 1 : 0) + (a.positions ? 1 : 0) == 1, {
|
|
1318
|
+
message: "give either inset_from_corners or positions, not both or neither"
|
|
1319
|
+
}), ut = e.object({
|
|
1320
|
+
relative_to: e.string().min(1),
|
|
1321
|
+
where: e.enum(["below", "above", "east", "west", "north", "south"]),
|
|
1322
|
+
/** Space between the two keep-outs. */
|
|
1323
|
+
gap: h.default(1),
|
|
1324
|
+
/** Moved this far [east, north] from centred on the other, once placed. */
|
|
1325
|
+
offset: e.tuple([d, d]).default([0, 0])
|
|
1326
|
+
}), X = e.object({
|
|
1327
|
+
id: e.string().regex(/^[a-z][a-z0-9_]*$/, "lowercase letters, digits and underscores"),
|
|
1328
|
+
type: e.enum(["pcb", "display", "battery", "speaker", "module"]),
|
|
1329
|
+
/** [east, north, up] — see COORDINATES. */
|
|
1330
|
+
dimensions: e.tuple([i, i, i]),
|
|
1331
|
+
/**
|
|
1332
|
+
* Radius of the footprint's corners: most boards are rounded. The case's
|
|
1333
|
+
* inside corners follow it, so a rounded board gets a rounded tray without
|
|
1334
|
+
* the tray growing wider. Leave it at 0 for a square one, or when unsure —
|
|
1335
|
+
* assuming sharper than the part is safe, rounder is not.
|
|
1336
|
+
*/
|
|
1337
|
+
corner_radius: h.default(0),
|
|
1338
|
+
/** Height of the tallest part on top (headers, capacitors, a connector), kept clear. */
|
|
1339
|
+
clearance_z_top: h.default(0),
|
|
1340
|
+
/** Height of what is underneath (solder joints, a microSD socket), kept clear. */
|
|
1341
|
+
clearance_z_bottom: h.default(0),
|
|
1342
|
+
/** Quarter turns about Z, applied before placement. */
|
|
1343
|
+
rotation: e.union([e.literal(0), e.literal(90), e.literal(180), e.literal(270)]).default(0),
|
|
1344
|
+
placement: ut.optional(),
|
|
1345
|
+
mount_holes: lt.optional(),
|
|
1346
|
+
interfaces: e.array(st).default([]),
|
|
1347
|
+
/** How it is held if it has no screw holes. */
|
|
1348
|
+
retention: e.enum(["none", "cradle_ribs"]).default("none")
|
|
1349
|
+
}), mt = e.object({
|
|
1350
|
+
/** The SVG file, relative to the manifest. Filled paths only; strokes are ignored. */
|
|
1351
|
+
svg: e.string().min(1),
|
|
1352
|
+
face: e.enum(["top", "bottom"]).default("bottom"),
|
|
1353
|
+
/** Height of the mark on the face, along north. Its width follows the SVG's proportions. */
|
|
1354
|
+
height: i,
|
|
1355
|
+
/** How deep it is pressed in. */
|
|
1356
|
+
depth: i.default(0.6),
|
|
1357
|
+
/** From the centre of the case's footprint, [east, north]. */
|
|
1358
|
+
offset: e.tuple([d, d]).default([0, 0]),
|
|
1359
|
+
/**
|
|
1360
|
+
* Cut it right through the face instead, as a stencil — a speaker's grille
|
|
1361
|
+
* in the shape of the mark. Whatever its lines enclose would fall out, so
|
|
1362
|
+
* each enclosed piece is held by bridges across a line: give them here, in
|
|
1363
|
+
* millimetres from the mark's centre as it reads (y up), each turned
|
|
1364
|
+
* `angle` degrees from running east-west. Pieces too small to hold
|
|
1365
|
+
* (STENCIL_SPECK) are cut away; a larger one with no bridge fails the fit
|
|
1366
|
+
* check, by where it is.
|
|
1367
|
+
*/
|
|
1368
|
+
stencil: e.object({
|
|
1369
|
+
bridges: e.array(e.object({ at: e.tuple([d, d]), angle: e.number().default(0), length: i.default(3) })).default([])
|
|
1370
|
+
}).optional()
|
|
1371
|
+
});
|
|
1372
|
+
e.object({
|
|
1373
|
+
project: e.string().regex(/^[a-z0-9][a-z0-9_-]*$/, "lowercase, digits, - and _"),
|
|
1374
|
+
/** How the case goes together — see TWO STYLES above. */
|
|
1375
|
+
enclosure_style: e.enum(["split_shell_lip", "tray_bezel"]).default("split_shell_lip"),
|
|
1376
|
+
wall_thickness: i.default(2.4),
|
|
1377
|
+
/**
|
|
1378
|
+
* Thicker walls on chosen sides, in place of `wall_thickness` there. A
|
|
1379
|
+
* screen whose glass is as wide as its board otherwise gets 2.4mm of frame
|
|
1380
|
+
* along its sides and 11mm at its ends, which looks off balance (the
|
|
1381
|
+
* black ESP32-S3 board's flush case, 2026-10-25). Each is a whole number
|
|
1382
|
+
* of nozzle lines, and no thinner than `wall_thickness`.
|
|
1383
|
+
*/
|
|
1384
|
+
walls: e.object({ east: i, west: i, north: i, south: i }).partial().default({}),
|
|
1385
|
+
/** Radius of the vertical outside corners. */
|
|
1386
|
+
corner_radius: h.default(2),
|
|
1387
|
+
/**
|
|
1388
|
+
* The outside's front and back edges — where the face meets the sides.
|
|
1389
|
+
* `chamfer` bevels them flat at 45°, `round` rounds them; `soften` then
|
|
1390
|
+
* rounds every edge the bevel leaves, so nothing on the outside is sharp.
|
|
1391
|
+
* Without it they are square, and a case reads as a printed box.
|
|
1392
|
+
*/
|
|
1393
|
+
edges: e.object({
|
|
1394
|
+
style: e.enum(["chamfer", "round"]),
|
|
1395
|
+
size: i,
|
|
1396
|
+
soften: h.default(0)
|
|
1397
|
+
}).optional(),
|
|
1398
|
+
printer: ot.default({}),
|
|
1399
|
+
components: e.array(X).min(1),
|
|
1400
|
+
emblem: mt.optional()
|
|
1401
|
+
}).superRefine((a, s) => {
|
|
1402
|
+
const x = a.wall_thickness / a.printer.nozzle;
|
|
1403
|
+
Math.abs(x - Math.round(x)) > 1e-6 && s.addIssue({
|
|
1404
|
+
code: e.ZodIssueCode.custom,
|
|
1405
|
+
path: ["wall_thickness"],
|
|
1406
|
+
message: `${a.wall_thickness}mm is not a whole number of ${a.printer.nozzle}mm lines — try ${(Math.round(x) * a.printer.nozzle).toFixed(2)}`
|
|
1407
|
+
});
|
|
1408
|
+
for (const [n, t] of Object.entries(a.walls)) {
|
|
1409
|
+
if (t === void 0) continue;
|
|
1410
|
+
const r = t / a.printer.nozzle;
|
|
1411
|
+
Math.abs(r - Math.round(r)) > 1e-6 && s.addIssue({
|
|
1412
|
+
code: e.ZodIssueCode.custom,
|
|
1413
|
+
path: ["walls", n],
|
|
1414
|
+
message: `${t}mm is not a whole number of ${a.printer.nozzle}mm lines — try ${(Math.round(r) * a.printer.nozzle).toFixed(2)}`
|
|
1415
|
+
}), t < a.wall_thickness && s.addIssue({
|
|
1416
|
+
code: e.ZodIssueCode.custom,
|
|
1417
|
+
path: ["walls", n],
|
|
1418
|
+
message: `${t}mm is thinner than wall_thickness (${a.wall_thickness}mm): walls only thicken on chosen sides`
|
|
1419
|
+
});
|
|
1420
|
+
}
|
|
1421
|
+
const w = a.components.map((n) => n.id);
|
|
1422
|
+
w.forEach((n, t) => {
|
|
1423
|
+
w.indexOf(n) !== t && s.addIssue({ code: e.ZodIssueCode.custom, path: ["components", t, "id"], message: `"${n}" is used twice` });
|
|
1424
|
+
});
|
|
1425
|
+
const v = a.components.filter((n) => !n.placement);
|
|
1426
|
+
v.length !== 1 && s.addIssue({
|
|
1427
|
+
code: e.ZodIssueCode.custom,
|
|
1428
|
+
path: ["components"],
|
|
1429
|
+
message: `exactly one component must have no placement (the origin); found ${v.length}: ${v.map((n) => n.id).join(", ") || "none"}`
|
|
1430
|
+
});
|
|
1431
|
+
const c = new Map(a.components.map((n) => [n.id, n]));
|
|
1432
|
+
a.components.forEach((n, t) => {
|
|
1433
|
+
if (!n.placement) return;
|
|
1434
|
+
const r = n.placement.relative_to;
|
|
1435
|
+
if (!c.has(r)) {
|
|
1436
|
+
s.addIssue({ code: e.ZodIssueCode.custom, path: ["components", t, "placement", "relative_to"], message: `no component "${r}"` });
|
|
1437
|
+
return;
|
|
1438
|
+
}
|
|
1439
|
+
const l = /* @__PURE__ */ new Set([n.id]);
|
|
1440
|
+
for (let u = c.get(r); u != null && u.placement; u = c.get(u.placement.relative_to)) {
|
|
1441
|
+
if (l.has(u.id)) {
|
|
1442
|
+
s.addIssue({ code: e.ZodIssueCode.custom, path: ["components", t, "placement"], message: `placement loops back to "${u.id}"` });
|
|
1443
|
+
return;
|
|
1444
|
+
}
|
|
1445
|
+
l.add(u.id);
|
|
1446
|
+
}
|
|
1447
|
+
}), a.components.forEach((n, t) => {
|
|
1448
|
+
var M, P, N;
|
|
1449
|
+
a.enclosure_style === "split_shell_lip" && n.mount_holes && (!n.mount_holes.insert_od || !n.mount_holes.insert_depth) && s.addIssue({ code: e.ZodIssueCode.custom, path: ["components", t, "mount_holes"], message: "a split_shell_lip case holds boards on heat-set inserts: give insert_od and insert_depth" }), n.interfaces.forEach((m, A) => {
|
|
1450
|
+
m.chamfer && m.edge !== "top" && m.edge !== "bottom" && s.addIssue({ code: e.ZodIssueCode.custom, path: ["components", t, "interfaces", A, "chamfer"], message: `a chamfer ramps an opening in the bezel or the floor: its edge must be top or bottom, not ${m.edge}` }), m.cutout_shape === "grille" && m.edge !== "top" && m.edge !== "bottom" && s.addIssue({ code: e.ZodIssueCode.custom, path: ["components", t, "interfaces", A, "cutout_shape"], message: `a grille is a field of holes in the bezel or the floor: its edge must be top or bottom, not ${m.edge}` }), m.flex_button && m.edge !== "bottom" && s.addIssue({ code: e.ZodIssueCode.custom, path: ["components", t, "interfaces", A, "flex_button"], message: `a flex button is pressed through the floor: its edge must be bottom, not ${m.edge}` });
|
|
1451
|
+
});
|
|
1452
|
+
const [r, l] = n.dimensions;
|
|
1453
|
+
(P = (M = n.mount_holes) == null ? void 0 : M.positions) == null || P.forEach((m, A) => {
|
|
1454
|
+
(Math.abs(m[0]) > r / 2 || Math.abs(m[1]) > l / 2) && s.addIssue({ code: e.ZodIssueCode.custom, path: ["components", t, "mount_holes", "positions", A], message: `hole at [${m}] is outside the ${r}×${l} footprint` });
|
|
1455
|
+
});
|
|
1456
|
+
const u = (N = n.mount_holes) == null ? void 0 : N.inset_from_corners;
|
|
1457
|
+
u && (u[0] * 2 >= r || u[1] * 2 >= l) && s.addIssue({ code: e.ZodIssueCode.custom, path: ["components", t, "mount_holes", "inset_from_corners"], message: `insets [${u}] meet in the middle of a ${r}×${l} footprint` });
|
|
1458
|
+
});
|
|
1459
|
+
});
|
|
1460
|
+
var ct = e.object({
|
|
1461
|
+
label: e.string().min(1),
|
|
1462
|
+
/** One sentence: what it is for. */
|
|
1463
|
+
description: e.string().optional(),
|
|
1464
|
+
/** Components added to the base manifest's. */
|
|
1465
|
+
components: e.array(X).default([]),
|
|
1466
|
+
/** Top-level manifest fields this choice sets: wall_thickness, emblem… */
|
|
1467
|
+
set: e.record(e.unknown()).default({}),
|
|
1468
|
+
/**
|
|
1469
|
+
* Changes to the base's own components, by id: fields to set, null to
|
|
1470
|
+
* remove one, and `interfaces` by name the same way — a null interface is
|
|
1471
|
+
* removed, an unknown one added. How a flush top lowers the board's
|
|
1472
|
+
* clearance and widens its screen opening to the glass.
|
|
1473
|
+
*/
|
|
1474
|
+
patch: e.record(e.record(e.unknown())).default({})
|
|
1475
|
+
}), dt = e.object({
|
|
1476
|
+
label: e.string().min(1),
|
|
1477
|
+
/** In order; the first is the default. Ids are lowercase words and dashes. */
|
|
1478
|
+
choices: e.array(ct.extend({ id: e.string().regex(/^[a-z0-9][a-z0-9-]*$/) })).min(1)
|
|
1479
|
+
});
|
|
1480
|
+
e.object({
|
|
1481
|
+
/** The base manifest, relative to this file. */
|
|
1482
|
+
manifest: e.string().min(1),
|
|
1483
|
+
/** Option groups, in the order they are offered: base, top… */
|
|
1484
|
+
options: e.record(e.string().regex(/^[a-z][a-z0-9-]*$/), dt)
|
|
1485
|
+
});
|
|
1486
|
+
e.object({
|
|
1487
|
+
id: e.string().default(""),
|
|
1488
|
+
name: e.string(),
|
|
1489
|
+
email: e.string().email(),
|
|
1490
|
+
password: e.string().optional(),
|
|
1491
|
+
role: e.string(),
|
|
1492
|
+
status: e.string().optional(),
|
|
1493
|
+
joinedAt: e.string().optional(),
|
|
1494
|
+
lastActive: e.string().optional(),
|
|
1495
|
+
avatarUrl: e.string().optional()
|
|
1496
|
+
});
|
|
1497
|
+
var f = e.string().regex(/^acct_[0-9a-f]{12}$/, "acct_ and 12 hex digits"), O = e.enum(["member", "admin"]), J = e.enum(["active", "suspended"]), pt = e.object({
|
|
1498
|
+
algo: e.literal("scrypt"),
|
|
1499
|
+
n: e.number().int().positive(),
|
|
1500
|
+
r: e.number().int().positive(),
|
|
1501
|
+
p: e.number().int().positive(),
|
|
1502
|
+
keylen: e.number().int().positive(),
|
|
1503
|
+
salt: e.string().min(16),
|
|
1504
|
+
hash: e.string().min(16)
|
|
1505
|
+
});
|
|
1506
|
+
e.object({
|
|
1507
|
+
accountId: f,
|
|
1508
|
+
/** Lowercased on write, because a login must not depend on how it was typed. */
|
|
1509
|
+
email: e.string().email().max(254),
|
|
1510
|
+
name: e.string().min(1).max(64),
|
|
1511
|
+
role: O,
|
|
1512
|
+
status: J,
|
|
1513
|
+
password: pt,
|
|
1514
|
+
createdAt: e.number().int().nonnegative(),
|
|
1515
|
+
lastLoginAt: e.number().int().nonnegative().nullable().default(null),
|
|
1516
|
+
/** Which admin approved this, or null for the bootstrap account. */
|
|
1517
|
+
invitedBy: f.nullable().default(null)
|
|
1518
|
+
});
|
|
1519
|
+
var L = 40;
|
|
1520
|
+
e.string().transform((a) => a.trim().replace(/\s+/g, " ")).pipe(
|
|
1521
|
+
e.string().min(1, "Give a name.").max(L, `At most ${L} characters.`).refine((a) => !/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u2028-\u202e\u2066-\u2069]/.test(a), "Letters, numbers, spaces and punctuation only.")
|
|
1522
|
+
);
|
|
1523
|
+
e.object({
|
|
1524
|
+
accountId: f,
|
|
1525
|
+
email: e.string().email(),
|
|
1526
|
+
name: e.string(),
|
|
1527
|
+
role: O,
|
|
1528
|
+
status: J
|
|
1529
|
+
});
|
|
1530
|
+
e.object({
|
|
1531
|
+
accountId: f,
|
|
1532
|
+
createdAt: e.number().int().nonnegative(),
|
|
1533
|
+
expiresAt: e.number().int().nonnegative(),
|
|
1534
|
+
lastSeenAt: e.number().int().nonnegative()
|
|
1535
|
+
});
|
|
1536
|
+
e.object({
|
|
1537
|
+
email: e.string().email().max(254),
|
|
1538
|
+
role: O,
|
|
1539
|
+
createdAt: e.number().int().nonnegative(),
|
|
1540
|
+
expiresAt: e.number().int().nonnegative(),
|
|
1541
|
+
invitedBy: f
|
|
1542
|
+
});
|
|
1543
|
+
e.object({
|
|
1544
|
+
email: e.string().email().max(254),
|
|
1545
|
+
name: e.string().min(1).max(64),
|
|
1546
|
+
/** Optional, and never shown publicly. Long enough to be useful, short enough not to be an essay. */
|
|
1547
|
+
reason: e.string().max(500).optional()
|
|
1548
|
+
});
|
|
1549
|
+
var ht = e.enum(["pending", "approved", "denied"]);
|
|
1550
|
+
e.object({
|
|
1551
|
+
requestId: e.string().regex(/^req_[0-9a-f]{12}$/, "req_ and 12 hex digits"),
|
|
1552
|
+
email: e.string().email().max(254),
|
|
1553
|
+
name: e.string().min(1).max(64),
|
|
1554
|
+
reason: e.string().max(500).optional(),
|
|
1555
|
+
status: ht,
|
|
1556
|
+
createdAt: e.number().int().nonnegative(),
|
|
1557
|
+
decidedAt: e.number().int().nonnegative().nullable().default(null),
|
|
1558
|
+
decidedBy: f.nullable().default(null)
|
|
1559
|
+
});
|
|
1560
|
+
var xt = ["boards:read", "boards:send"], Q = e.enum(xt), gt = [7, 30, 90, 365], bt = e.object({
|
|
1561
|
+
/** The first 12 hex digits of the hash: what the owner sees and revokes by. */
|
|
1562
|
+
tokenId: e.string().regex(/^[0-9a-f]{12}$/),
|
|
1563
|
+
accountId: f,
|
|
1564
|
+
/** What the owner called it: "laptop", "Claude Code". */
|
|
1565
|
+
name: e.string().trim().min(1).max(60),
|
|
1566
|
+
scopes: e.array(Q).min(1),
|
|
1567
|
+
createdAt: e.number().int().nonnegative(),
|
|
1568
|
+
expiresAt: e.number().int().nonnegative(),
|
|
1569
|
+
/** Moved forward at most once a day, so using a token is not a write per request. */
|
|
1570
|
+
lastUsedAt: e.number().int().nonnegative().nullable().default(null)
|
|
1571
|
+
});
|
|
1572
|
+
bt.omit({ accountId: !0 });
|
|
1573
|
+
e.object({
|
|
1574
|
+
name: e.string().trim().min(1, "Give it a name.").max(60),
|
|
1575
|
+
scopes: e.array(Q).min(1, "Choose at least one thing it can do."),
|
|
1576
|
+
days: e.union(gt.map((a) => e.literal(a)))
|
|
1577
|
+
});
|
|
1578
|
+
export {
|
|
1579
|
+
Ot as A,
|
|
1580
|
+
ue as B,
|
|
1581
|
+
et as D,
|
|
1582
|
+
ie as E,
|
|
1583
|
+
ae as F,
|
|
1584
|
+
Et as I,
|
|
1585
|
+
me as P,
|
|
1586
|
+
ne as R,
|
|
1587
|
+
wt as S,
|
|
1588
|
+
re as T,
|
|
1589
|
+
le as W,
|
|
1590
|
+
j as a,
|
|
1591
|
+
Mt as b,
|
|
1592
|
+
Pt as c,
|
|
1593
|
+
W as d,
|
|
1594
|
+
he as e,
|
|
1595
|
+
se as f,
|
|
1596
|
+
ce as g,
|
|
1597
|
+
vt as h,
|
|
1598
|
+
Rt as i,
|
|
1599
|
+
$ as j,
|
|
1600
|
+
At as k,
|
|
1601
|
+
F as l,
|
|
1602
|
+
Nt as m,
|
|
1603
|
+
Ft as n,
|
|
1604
|
+
_t as o,
|
|
1605
|
+
Ct as p,
|
|
1606
|
+
Bt as q,
|
|
1607
|
+
Dt as r,
|
|
1608
|
+
St as s,
|
|
1609
|
+
It as t,
|
|
1610
|
+
kt as u,
|
|
1611
|
+
jt as v,
|
|
1612
|
+
Tt as w,
|
|
1613
|
+
yt as x
|
|
1614
|
+
};
|