@ramme-io/shared 3.1.1 → 3.2.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/README.md +2 -2
- package/dist/index.cjs +1330 -81
- package/dist/index.d.cts +18449 -24
- package/dist/index.d.ts +18449 -24
- package/dist/index.js +1210 -81
- package/package.json +7 -5
package/dist/index.cjs
CHANGED
|
@@ -20,38 +20,152 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
ACCESS_REQUEST_TTL_SECONDS: () => ACCESS_REQUEST_TTL_SECONDS,
|
|
24
|
+
ACCOUNT_TTL_SECONDS: () => ACCOUNT_TTL_SECONDS,
|
|
23
25
|
AIKeyManifestSchema: () => AIKeyManifestSchema,
|
|
24
26
|
AIThemeSchema: () => AIThemeSchema,
|
|
25
27
|
AI_ROSTER: () => AI_ROSTER,
|
|
26
28
|
AI_TOOLS: () => AI_TOOLS,
|
|
29
|
+
APP_DOCUMENT_EDIT_PREFIX: () => APP_DOCUMENT_EDIT_PREFIX,
|
|
30
|
+
APP_DOCUMENT_SYSTEM_PROMPT: () => APP_DOCUMENT_SYSTEM_PROMPT,
|
|
31
|
+
ASSISTANT_MODEL: () => ASSISTANT_MODEL,
|
|
32
|
+
ASSISTANT_PROVIDER: () => ASSISTANT_PROVIDER,
|
|
33
|
+
AccessRequestRecordSchema: () => AccessRequestRecordSchema,
|
|
34
|
+
AccessRequestSchema: () => AccessRequestSchema,
|
|
35
|
+
AccessRequestStatusSchema: () => AccessRequestStatusSchema,
|
|
36
|
+
AccountIdSchema: () => AccountIdSchema,
|
|
37
|
+
AccountRecordSchema: () => AccountRecordSchema,
|
|
38
|
+
AccountRoleSchema: () => AccountRoleSchema,
|
|
39
|
+
AccountStatusSchema: () => AccountStatusSchema,
|
|
27
40
|
ActionSchema: () => ActionSchema,
|
|
41
|
+
AircraftAppConfigSchema: () => AircraftAppConfigSchema,
|
|
42
|
+
AppAlignSchema: () => AppAlignSchema,
|
|
43
|
+
AppBarSchema: () => AppBarSchema,
|
|
44
|
+
AppBindingSchema: () => AppBindingSchema,
|
|
45
|
+
AppBlockSchema: () => AppBlockSchema,
|
|
46
|
+
AppColorSchema: () => AppColorSchema,
|
|
47
|
+
AppColorTokenSchema: () => AppColorTokenSchema,
|
|
48
|
+
AppComputeSchema: () => AppComputeSchema,
|
|
49
|
+
AppConditionSchema: () => AppConditionSchema,
|
|
50
|
+
AppDialSchema: () => AppDialSchema,
|
|
51
|
+
AppDocumentSchema: () => AppDocumentSchema,
|
|
52
|
+
AppGroupSchema: () => AppGroupSchema,
|
|
53
|
+
AppImageSchema: () => AppImageSchema,
|
|
54
|
+
AppLeafSchema: () => AppLeafSchema,
|
|
55
|
+
AppOperandSchema: () => AppOperandSchema,
|
|
56
|
+
AppRgbSchema: () => AppRgbSchema,
|
|
57
|
+
AppScreenSizeSchema: () => AppScreenSizeSchema,
|
|
28
58
|
AppSignalSchema: () => AppSignalSchema,
|
|
59
|
+
AppSourceSchema: () => AppSourceSchema,
|
|
60
|
+
AppSparklineSchema: () => AppSparklineSchema,
|
|
29
61
|
AppSpecificationSchema: () => AppSpecificationSchema,
|
|
62
|
+
AppSpriteSchema: () => AppSpriteSchema,
|
|
63
|
+
AppStatusSchema: () => AppStatusSchema,
|
|
64
|
+
AppStyleRuleSchema: () => AppStyleRuleSchema,
|
|
65
|
+
AppTextSchema: () => AppTextSchema,
|
|
66
|
+
AppTextSizeSchema: () => AppTextSizeSchema,
|
|
67
|
+
AssetHashSchema: () => AssetHashSchema,
|
|
30
68
|
AuthStrategySchema: () => AuthStrategySchema,
|
|
31
69
|
BlockSchema: () => BlockSchema,
|
|
32
70
|
Bodewell: () => schema_exports,
|
|
71
|
+
CLAIMED_DEVICE_TTL_SECONDS: () => CLAIMED_DEVICE_TTL_SECONDS,
|
|
72
|
+
ClockAppConfigSchema: () => ClockAppConfigSchema,
|
|
33
73
|
CounterpartyNodeSchema: () => CounterpartyNodeSchema,
|
|
74
|
+
CounterpartyResolutionSchema: () => CounterpartyResolutionSchema,
|
|
34
75
|
CounterpartyTypeSchema: () => CounterpartyTypeSchema,
|
|
35
76
|
DEFAULT_CHAT_MODEL: () => DEFAULT_CHAT_MODEL,
|
|
77
|
+
DEFAULT_DEVICE_CONFIG: () => DEFAULT_DEVICE_CONFIG,
|
|
78
|
+
DEFAULT_HORIZON_QUARTERS: () => DEFAULT_HORIZON_QUARTERS,
|
|
36
79
|
DEFAULT_PRO_MODEL: () => DEFAULT_PRO_MODEL,
|
|
37
80
|
DEFAULT_SCHEMA_MODEL: () => DEFAULT_SCHEMA_MODEL,
|
|
38
81
|
DEFAULT_THEME_TOKENS: () => DEFAULT_THEME_TOKENS,
|
|
82
|
+
DEVICE_AP_SSID_PREFIX: () => DEVICE_AP_SSID_PREFIX,
|
|
83
|
+
DEVICE_ENDPOINTS: () => DEVICE_ENDPOINTS,
|
|
84
|
+
DEVICE_FRESH_MS: () => DEVICE_FRESH_MS,
|
|
85
|
+
DEVICE_GLYPHS: () => DEVICE_GLYPHS,
|
|
86
|
+
DEVICE_LABEL_MAX: () => DEVICE_LABEL_MAX,
|
|
87
|
+
DEVICE_PALETTE: () => DEVICE_PALETTE,
|
|
88
|
+
DEVICE_STALE_MS: () => DEVICE_STALE_MS,
|
|
89
|
+
DEVICE_TIMEZONES: () => DEVICE_TIMEZONES,
|
|
90
|
+
DEVICE_TIMEZONE_FALLBACK: () => DEVICE_TIMEZONE_FALLBACK,
|
|
91
|
+
DEVICE_TTL_SECONDS: () => DEVICE_TTL_SECONDS,
|
|
92
|
+
DEVICE_UNKNOWN_GLYPH: () => DEVICE_UNKNOWN_GLYPH,
|
|
93
|
+
DEVICE_VITALS_FIELDS: () => DEVICE_VITALS_FIELDS,
|
|
94
|
+
DailyPricePointSchema: () => DailyPricePointSchema,
|
|
95
|
+
DeliveredAppSchema: () => DeliveredAppSchema,
|
|
96
|
+
DeviceAppIdSchema: () => DeviceAppIdSchema,
|
|
97
|
+
DeviceAppsSchema: () => DeviceAppsSchema,
|
|
98
|
+
DeviceConfigSchema: () => DeviceConfigSchema,
|
|
99
|
+
DeviceDisplayConfigSchema: () => DeviceDisplayConfigSchema,
|
|
100
|
+
DeviceIdSchema: () => DeviceIdSchema,
|
|
101
|
+
DeviceKindSchema: () => DeviceKindSchema,
|
|
102
|
+
DeviceRecordSchema: () => DeviceRecordSchema,
|
|
103
|
+
DeviceRegistrationSchema: () => DeviceRegistrationSchema,
|
|
104
|
+
DeviceSeenSchema: () => DeviceSeenSchema,
|
|
105
|
+
DeviceStatusSchema: () => DeviceStatusSchema,
|
|
106
|
+
DeviceThemeSchema: () => DeviceThemeSchema,
|
|
107
|
+
DeviceVitalsSchema: () => DeviceVitalsSchema,
|
|
39
108
|
DivergenceMetricSchema: () => DivergenceMetricSchema,
|
|
109
|
+
EVENT_KIND_LABELS: () => EVENT_KIND_LABELS,
|
|
110
|
+
EXCLUDED_SOURCES: () => EXCLUDED_SOURCES,
|
|
111
|
+
EntityEventDensityBucketSchema: () => EntityEventDensityBucketSchema,
|
|
112
|
+
EntityEventDensitySchema: () => EntityEventDensitySchema,
|
|
113
|
+
EntityEventFacetSchema: () => EntityEventFacetSchema,
|
|
114
|
+
EntityEventFacetsSchema: () => EntityEventFacetsSchema,
|
|
115
|
+
EntityEventKindSchema: () => EntityEventKindSchema,
|
|
116
|
+
EntityEventSchema: () => EntityEventSchema,
|
|
117
|
+
EntityPriceSeriesSchema: () => EntityPriceSeriesSchema,
|
|
40
118
|
EntitySchema: () => EntitySchema,
|
|
119
|
+
EventBucketSizeSchema: () => EventBucketSizeSchema,
|
|
120
|
+
EventSourceSchema: () => EventSourceSchema,
|
|
41
121
|
FieldSchema: () => FieldSchema,
|
|
42
122
|
FloraTelemetrySchema: () => FloraTelemetrySchema,
|
|
43
123
|
GENESIS_LIBRARY_CONTEXT: () => GENESIS_LIBRARY_CONTEXT,
|
|
44
124
|
GENESIS_VALID_COMPONENTS: () => GENESIS_VALID_COMPONENTS,
|
|
125
|
+
IMAGE_MAX_DRAWN: () => IMAGE_MAX_DRAWN,
|
|
126
|
+
IMAGE_MAX_SCALE: () => IMAGE_MAX_SCALE,
|
|
127
|
+
IMPACT_FLAG_THRESHOLD: () => IMPACT_FLAG_THRESHOLD,
|
|
128
|
+
INVITE_TTL_SECONDS: () => INVITE_TTL_SECONDS,
|
|
129
|
+
ImpactScaleSchema: () => ImpactScaleSchema,
|
|
130
|
+
InviteRecordSchema: () => InviteRecordSchema,
|
|
131
|
+
MAX_PASSWORD_LENGTH: () => MAX_PASSWORD_LENGTH,
|
|
132
|
+
MIN_PASSWORD_LENGTH: () => MIN_PASSWORD_LENGTH,
|
|
45
133
|
NonPublicEntitySchema: () => NonPublicEntitySchema,
|
|
134
|
+
ORIGINAL_MAX_BYTES: () => ORIGINAL_MAX_BYTES,
|
|
135
|
+
ORIGINAL_MAX_SIDE: () => ORIGINAL_MAX_SIDE,
|
|
136
|
+
OwnedSendRequestSchema: () => OwnedSendRequestSchema,
|
|
137
|
+
PHOTOS_PER_ACCOUNT: () => PHOTOS_PER_ACCOUNT,
|
|
138
|
+
PHOTO_UPLOADS_PER_HOUR: () => PHOTO_UPLOADS_PER_HOUR,
|
|
139
|
+
PROVIDER_DEFAULT_MODEL: () => PROVIDER_DEFAULT_MODEL,
|
|
46
140
|
PageSchema: () => PageSchema,
|
|
47
141
|
PageSectionSchema: () => PageSectionSchema,
|
|
142
|
+
PaginatedEntityEventsSchema: () => PaginatedEntityEventsSchema,
|
|
143
|
+
PairCodeSchema: () => PairCodeSchema,
|
|
144
|
+
PhotoSummarySchema: () => PhotoSummarySchema,
|
|
145
|
+
PhotoUploadSchema: () => PhotoUploadSchema,
|
|
146
|
+
ProvisioningStateSchema: () => ProvisioningStateSchema,
|
|
147
|
+
PublicAccountSchema: () => PublicAccountSchema,
|
|
148
|
+
RETRO_RENDITION: () => RETRO_RENDITION,
|
|
48
149
|
RelationshipEdgeSchema: () => RelationshipEdgeSchema,
|
|
49
150
|
RelationshipEdgeTypeSchema: () => RelationshipEdgeTypeSchema,
|
|
50
151
|
ResourceSchema: () => ResourceSchema,
|
|
152
|
+
SCRYPT_PARAMS: () => SCRYPT_PARAMS,
|
|
153
|
+
SENTIMENT_NEUTRAL: () => SENTIMENT_NEUTRAL,
|
|
154
|
+
SESSION_COOKIE_NAME: () => SESSION_COOKIE_NAME,
|
|
155
|
+
SESSION_TTL_SECONDS: () => SESSION_TTL_SECONDS,
|
|
51
156
|
SIGNAL_DOMAINS: () => SIGNAL_DOMAINS,
|
|
52
157
|
SIGNAL_KINDS: () => SIGNAL_KINDS,
|
|
53
158
|
SIGNAL_KIND_LABELS: () => SIGNAL_KIND_LABELS,
|
|
54
159
|
SIGNAL_SOURCES: () => SIGNAL_SOURCES,
|
|
160
|
+
SPRITE_MAX_BASE64: () => SPRITE_MAX_BASE64,
|
|
161
|
+
SPRITE_MAX_ROW_BYTES: () => SPRITE_MAX_ROW_BYTES,
|
|
162
|
+
SPRITE_MAX_SIDE: () => SPRITE_MAX_SIDE,
|
|
163
|
+
SPR_FORMAT: () => SPR_FORMAT,
|
|
164
|
+
SPR_MAX_BYTES: () => SPR_MAX_BYTES,
|
|
165
|
+
ScryptHashSchema: () => ScryptHashSchema,
|
|
166
|
+
SendRequestSchema: () => SendRequestSchema,
|
|
167
|
+
SensorAppConfigSchema: () => SensorAppConfigSchema,
|
|
168
|
+
SessionRecordSchema: () => SessionRecordSchema,
|
|
55
169
|
SignalArraySchema: () => SignalArraySchema,
|
|
56
170
|
SignalKindSchema: () => SignalKindSchema,
|
|
57
171
|
SignalPacketSchema: () => SignalPacketSchema,
|
|
@@ -63,11 +177,17 @@ __export(index_exports, {
|
|
|
63
177
|
ThemeFontsSchema: () => ThemeFontsSchema,
|
|
64
178
|
ThemeOverridesSchema: () => ThemeOverridesSchema,
|
|
65
179
|
ThemeTokensSchema: () => ThemeTokensSchema,
|
|
180
|
+
TimestampPrecisionSchema: () => TimestampPrecisionSchema,
|
|
66
181
|
TriggerSchema: () => TriggerSchema,
|
|
67
182
|
UserSchema: () => UserSchema,
|
|
183
|
+
VitalSourceSchema: () => VitalSourceSchema,
|
|
184
|
+
WeatherAppConfigSchema: () => WeatherAppConfigSchema,
|
|
68
185
|
WorkflowSchema: () => WorkflowSchema,
|
|
186
|
+
architectureReferenceParameters: () => architectureReferenceParameters,
|
|
69
187
|
companyNewsParameters: () => companyNewsParameters,
|
|
70
188
|
companyProfileParameters: () => companyProfileParameters,
|
|
189
|
+
counterpartyGraphParameters: () => counterpartyGraphParameters,
|
|
190
|
+
divergenceMetricsParameters: () => divergenceMetricsParameters,
|
|
71
191
|
liveQuoteParameters: () => liveQuoteParameters,
|
|
72
192
|
stockChartParameters: () => stockChartParameters,
|
|
73
193
|
telemetryGraphParameters: () => telemetryGraphParameters
|
|
@@ -334,7 +454,8 @@ var BodewellTelemetrySchema = import_zod4.z.object({
|
|
|
334
454
|
soil_temp_stemma: import_zod4.z.number().optional().describe("Celsius"),
|
|
335
455
|
soil_vwc: import_zod4.z.number().describe("Volumetric Water Content / Raw Capacitance"),
|
|
336
456
|
soil_moisture: import_zod4.z.number().optional().describe("Firmware alias for raw capacitance"),
|
|
337
|
-
soil_moisture_raw: import_zod4.z.number().optional().describe("Unscaled capacitance (300-1100)")
|
|
457
|
+
soil_moisture_raw: import_zod4.z.number().optional().describe("Unscaled capacitance (300-1100)"),
|
|
458
|
+
fw_version: import_zod4.z.string().max(40).optional().describe("Firmware build the board is running; absent on v4 sketches, which cannot be updated over the air")
|
|
338
459
|
}).passthrough();
|
|
339
460
|
var BodewellCommandSchema = import_zod4.z.object({
|
|
340
461
|
stick_id: BodewellDeviceID,
|
|
@@ -343,28 +464,669 @@ var BodewellCommandSchema = import_zod4.z.object({
|
|
|
343
464
|
value: import_zod4.z.number()
|
|
344
465
|
});
|
|
345
466
|
|
|
346
|
-
// src/
|
|
467
|
+
// src/device/schema.ts
|
|
347
468
|
var import_zod5 = require("zod");
|
|
348
|
-
var
|
|
349
|
-
|
|
350
|
-
|
|
469
|
+
var DeviceKindSchema = import_zod5.z.enum([
|
|
470
|
+
"esp32-touch-28",
|
|
471
|
+
// 2.8" 240x320 resistive touch, the workshop board
|
|
472
|
+
"esp32-headless",
|
|
473
|
+
// no display; sensor node
|
|
474
|
+
"simulator"
|
|
475
|
+
// browser-side stand-in, for building without hardware
|
|
476
|
+
]);
|
|
477
|
+
var DeviceAppIdSchema = import_zod5.z.enum([
|
|
478
|
+
"weather",
|
|
479
|
+
"clock",
|
|
480
|
+
"aircraft",
|
|
481
|
+
"sensor",
|
|
482
|
+
"blank"
|
|
483
|
+
]);
|
|
484
|
+
var WeatherAppConfigSchema = import_zod5.z.object({
|
|
485
|
+
/** Postal code is what a person knows; the portal resolves it to coordinates. */
|
|
486
|
+
postalCode: import_zod5.z.string().min(3).max(12),
|
|
487
|
+
latitude: import_zod5.z.number().min(-90).max(90).optional(),
|
|
488
|
+
longitude: import_zod5.z.number().min(-180).max(180).optional(),
|
|
489
|
+
units: import_zod5.z.enum(["imperial", "metric"]).default("imperial"),
|
|
490
|
+
showForecast: import_zod5.z.boolean().default(true),
|
|
491
|
+
refreshSeconds: import_zod5.z.number().int().min(300).max(86400).default(900)
|
|
492
|
+
});
|
|
493
|
+
var ClockAppConfigSchema = import_zod5.z.object({
|
|
494
|
+
/** IANA zone, e.g. "America/New_York". */
|
|
495
|
+
timezone: import_zod5.z.string().default("America/New_York"),
|
|
496
|
+
twentyFourHour: import_zod5.z.boolean().default(false),
|
|
497
|
+
showSeconds: import_zod5.z.boolean().default(false),
|
|
498
|
+
showDate: import_zod5.z.boolean().default(true)
|
|
499
|
+
});
|
|
500
|
+
var AircraftAppConfigSchema = import_zod5.z.object({
|
|
501
|
+
latitude: import_zod5.z.number().min(-90).max(90),
|
|
502
|
+
longitude: import_zod5.z.number().min(-180).max(180),
|
|
503
|
+
radiusKm: import_zod5.z.number().min(5).max(400).default(80),
|
|
504
|
+
/** Rows the list view can show before the screen runs out. */
|
|
505
|
+
maxRows: import_zod5.z.number().int().min(1).max(12).default(8),
|
|
506
|
+
refreshSeconds: import_zod5.z.number().int().min(10).max(600).default(30)
|
|
507
|
+
});
|
|
508
|
+
var SensorAppConfigSchema = import_zod5.z.object({
|
|
509
|
+
/** Signal keys to display, in order. Abstract keys per the Signal contract. */
|
|
510
|
+
keys: import_zod5.z.array(import_zod5.z.string()).min(1).max(6),
|
|
511
|
+
refreshSeconds: import_zod5.z.number().int().min(1).max(3600).default(10)
|
|
512
|
+
});
|
|
513
|
+
var DeviceAppsSchema = import_zod5.z.object({
|
|
514
|
+
weather: WeatherAppConfigSchema.optional(),
|
|
515
|
+
clock: ClockAppConfigSchema.optional(),
|
|
516
|
+
aircraft: AircraftAppConfigSchema.optional(),
|
|
517
|
+
sensor: SensorAppConfigSchema.optional()
|
|
518
|
+
});
|
|
519
|
+
var DeviceDisplayConfigSchema = import_zod5.z.object({
|
|
520
|
+
brightness: import_zod5.z.number().int().min(5).max(100).default(80),
|
|
521
|
+
/** Degrees clockwise. The board can sit either way up in a case. */
|
|
522
|
+
rotation: import_zod5.z.union([import_zod5.z.literal(0), import_zod5.z.literal(90), import_zod5.z.literal(180), import_zod5.z.literal(270)]).default(0),
|
|
523
|
+
/** Dim rather than sleep — a desk display that blanks looks broken. */
|
|
524
|
+
dimAfterSeconds: import_zod5.z.number().int().min(0).max(86400).default(0),
|
|
525
|
+
dimBrightness: import_zod5.z.number().int().min(0).max(100).default(15),
|
|
526
|
+
/** Local 24h times, e.g. "22:30". Empty disables night dimming. */
|
|
527
|
+
nightStart: import_zod5.z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/).optional(),
|
|
528
|
+
nightEnd: import_zod5.z.string().regex(/^([01]\d|2[0-3]):[0-5]\d$/).optional()
|
|
529
|
+
});
|
|
530
|
+
var RgbTripletSchema = import_zod5.z.string().regex(
|
|
531
|
+
/^\d{1,3} \d{1,3} \d{1,3}$/,
|
|
532
|
+
'Expected space-separated RGB integers, e.g. "13 110 253"'
|
|
533
|
+
);
|
|
534
|
+
var DeviceThemeSchema = import_zod5.z.object({
|
|
535
|
+
preset: import_zod5.z.enum(["light", "dark", "corporate", "midnight", "blueprint", "custom"]).default("dark"),
|
|
536
|
+
background: RgbTripletSchema.optional(),
|
|
537
|
+
foreground: RgbTripletSchema.optional(),
|
|
538
|
+
accent: RgbTripletSchema.optional(),
|
|
539
|
+
muted: RgbTripletSchema.optional(),
|
|
540
|
+
warning: RgbTripletSchema.optional()
|
|
541
|
+
});
|
|
542
|
+
var DeviceConfigSchema = import_zod5.z.object({
|
|
543
|
+
/** Bumped only on breaking shape changes, so old firmware can refuse safely. */
|
|
544
|
+
schemaVersion: import_zod5.z.literal(1),
|
|
545
|
+
deviceId: import_zod5.z.string().min(1),
|
|
546
|
+
/** Monotonic. Portal increments on write; device echoes what it is running. */
|
|
547
|
+
revision: import_zod5.z.number().int().nonnegative(),
|
|
548
|
+
updatedAt: import_zod5.z.string().datetime().optional(),
|
|
549
|
+
activeApp: DeviceAppIdSchema,
|
|
550
|
+
apps: DeviceAppsSchema,
|
|
551
|
+
display: DeviceDisplayConfigSchema,
|
|
552
|
+
theme: DeviceThemeSchema
|
|
553
|
+
});
|
|
554
|
+
var ProvisioningStateSchema = import_zod5.z.enum([
|
|
555
|
+
"unprovisioned",
|
|
556
|
+
"connecting",
|
|
557
|
+
"online",
|
|
558
|
+
"offline",
|
|
559
|
+
"failed"
|
|
560
|
+
]);
|
|
561
|
+
var DeviceStatusSchema = import_zod5.z.object({
|
|
562
|
+
deviceId: import_zod5.z.string().min(1),
|
|
563
|
+
kind: DeviceKindSchema,
|
|
564
|
+
firmwareVersion: import_zod5.z.string(),
|
|
565
|
+
/** Shown on the device's own screen at boot — how the user finds it. */
|
|
566
|
+
ipAddress: import_zod5.z.string().optional(),
|
|
567
|
+
provisioning: ProvisioningStateSchema,
|
|
568
|
+
/** Revision the device is actually running, not the one it was sent. */
|
|
569
|
+
configRevision: import_zod5.z.number().int().nonnegative(),
|
|
570
|
+
activeApp: DeviceAppIdSchema,
|
|
571
|
+
rssi: import_zod5.z.number().int().optional().describe("dBm"),
|
|
572
|
+
uptimeSeconds: import_zod5.z.number().int().nonnegative().optional(),
|
|
573
|
+
freeHeapBytes: import_zod5.z.number().int().nonnegative().optional()
|
|
574
|
+
});
|
|
575
|
+
var DEVICE_ENDPOINTS = {
|
|
576
|
+
/** GET → DeviceStatus */
|
|
577
|
+
status: "/api/status",
|
|
578
|
+
/** GET → DeviceConfig · POST DeviceConfig → applied + persisted */
|
|
579
|
+
config: "/api/config",
|
|
580
|
+
/** POST → clears stored credentials and returns to AP mode */
|
|
581
|
+
forget: "/api/forget"
|
|
582
|
+
};
|
|
583
|
+
var DEVICE_AP_SSID_PREFIX = "ramme-setup-";
|
|
584
|
+
var DEFAULT_DEVICE_CONFIG = {
|
|
585
|
+
schemaVersion: 1,
|
|
586
|
+
revision: 0,
|
|
587
|
+
activeApp: "clock",
|
|
588
|
+
apps: {},
|
|
589
|
+
display: {
|
|
590
|
+
brightness: 80,
|
|
591
|
+
rotation: 0,
|
|
592
|
+
dimAfterSeconds: 0,
|
|
593
|
+
dimBrightness: 15
|
|
594
|
+
},
|
|
595
|
+
theme: { preset: "dark" }
|
|
596
|
+
};
|
|
597
|
+
|
|
598
|
+
// src/apps/schema.ts
|
|
599
|
+
var import_zod6 = require("zod");
|
|
600
|
+
var AppColorTokenSchema = import_zod6.z.enum([
|
|
601
|
+
"background",
|
|
602
|
+
"foreground",
|
|
603
|
+
"muted",
|
|
604
|
+
"accent",
|
|
605
|
+
"success",
|
|
606
|
+
"warning",
|
|
607
|
+
"danger"
|
|
608
|
+
]);
|
|
609
|
+
var AppRgbSchema = import_zod6.z.string().regex(/^\d{1,3} \d{1,3} \d{1,3}$/, 'RGB must be three space-separated integers, e.g. "13 110 253"');
|
|
610
|
+
var AppColorSchema = import_zod6.z.union([AppColorTokenSchema, AppRgbSchema]);
|
|
611
|
+
var AppTextSizeSchema = import_zod6.z.enum(["xs", "sm", "base", "lg", "xl", "display"]);
|
|
612
|
+
var AppAlignSchema = import_zod6.z.enum(["start", "center", "end"]);
|
|
613
|
+
var AppSourceSchema = import_zod6.z.discriminatedUnion("kind", [
|
|
614
|
+
import_zod6.z.object({
|
|
615
|
+
kind: import_zod6.z.literal("weather"),
|
|
616
|
+
latitude: import_zod6.z.number().min(-90).max(90),
|
|
617
|
+
longitude: import_zod6.z.number().min(-180).max(180),
|
|
618
|
+
units: import_zod6.z.enum(["imperial", "metric"]).default("imperial"),
|
|
619
|
+
refreshSeconds: import_zod6.z.number().int().min(300).max(86400).default(600)
|
|
620
|
+
}),
|
|
621
|
+
import_zod6.z.object({
|
|
622
|
+
kind: import_zod6.z.literal("clock"),
|
|
623
|
+
/** IANA zone, e.g. "America/New_York". */
|
|
624
|
+
timezone: import_zod6.z.string().default("America/New_York"),
|
|
625
|
+
twentyFourHour: import_zod6.z.boolean().default(false)
|
|
626
|
+
}),
|
|
627
|
+
import_zod6.z.object({
|
|
628
|
+
kind: import_zod6.z.literal("countdown"),
|
|
629
|
+
/** ISO date or datetime, e.g. "2026-12-25" or "2026-12-25T18:00:00Z". */
|
|
630
|
+
target: import_zod6.z.string().min(4),
|
|
631
|
+
label: import_zod6.z.string().max(24).optional()
|
|
632
|
+
}),
|
|
633
|
+
import_zod6.z.object({
|
|
634
|
+
kind: import_zod6.z.literal("static"),
|
|
635
|
+
values: import_zod6.z.record(import_zod6.z.union([import_zod6.z.string(), import_zod6.z.number(), import_zod6.z.boolean()]))
|
|
636
|
+
})
|
|
637
|
+
]);
|
|
638
|
+
var AppOperandSchema = import_zod6.z.union([
|
|
639
|
+
import_zod6.z.object({ literal: import_zod6.z.number() }),
|
|
640
|
+
import_zod6.z.object({ source: import_zod6.z.string().min(1), field: import_zod6.z.string().min(1) })
|
|
641
|
+
]);
|
|
642
|
+
var AppComputeSchema = import_zod6.z.object({
|
|
643
|
+
compute: import_zod6.z.enum(["add", "subtract", "multiply", "divide"]),
|
|
644
|
+
of: import_zod6.z.tuple([AppOperandSchema, AppOperandSchema]),
|
|
645
|
+
round: import_zod6.z.boolean().default(true)
|
|
646
|
+
});
|
|
647
|
+
var AppBindingSchema = import_zod6.z.union([
|
|
648
|
+
import_zod6.z.object({ literal: import_zod6.z.union([import_zod6.z.string(), import_zod6.z.number(), import_zod6.z.boolean()]) }),
|
|
649
|
+
import_zod6.z.object({
|
|
650
|
+
/** Key into the document's `sources` map. */
|
|
651
|
+
source: import_zod6.z.string().min(1),
|
|
652
|
+
/** Field on that source, e.g. "temperature", "high", "condition". */
|
|
653
|
+
field: import_zod6.z.string().min(1)
|
|
654
|
+
}),
|
|
655
|
+
AppComputeSchema
|
|
656
|
+
]);
|
|
657
|
+
var AppConditionSchema = import_zod6.z.object({
|
|
658
|
+
value: AppOperandSchema,
|
|
659
|
+
op: import_zod6.z.enum(["<", "<=", ">", ">=", "==", "!="]),
|
|
660
|
+
than: import_zod6.z.union([import_zod6.z.number(), import_zod6.z.string(), import_zod6.z.boolean()])
|
|
661
|
+
});
|
|
662
|
+
var AppStyleRuleSchema = import_zod6.z.object({
|
|
663
|
+
when: AppConditionSchema,
|
|
664
|
+
color: AppColorSchema.optional(),
|
|
665
|
+
size: AppTextSizeSchema.optional()
|
|
666
|
+
});
|
|
667
|
+
var leafBase = {
|
|
668
|
+
color: AppColorSchema.optional(),
|
|
669
|
+
/** Drawn only when this is false, or absent. */
|
|
670
|
+
hideWhen: AppConditionSchema.optional(),
|
|
671
|
+
/** Conditional style. First match wins. */
|
|
672
|
+
rules: import_zod6.z.array(AppStyleRuleSchema).max(4).optional()
|
|
673
|
+
};
|
|
674
|
+
var AppTextSchema = import_zod6.z.object({
|
|
675
|
+
type: import_zod6.z.literal("text"),
|
|
676
|
+
value: AppBindingSchema,
|
|
677
|
+
size: AppTextSizeSchema.default("base"),
|
|
678
|
+
align: AppAlignSchema.default("start"),
|
|
679
|
+
/** Printed after the value, e.g. a degree symbol. Never itself bound. */
|
|
680
|
+
suffix: import_zod6.z.string().max(8).optional(),
|
|
681
|
+
...leafBase
|
|
682
|
+
});
|
|
683
|
+
var AppDialSchema = import_zod6.z.object({
|
|
684
|
+
type: import_zod6.z.literal("dial"),
|
|
685
|
+
value: AppBindingSchema,
|
|
686
|
+
min: import_zod6.z.number(),
|
|
687
|
+
max: import_zod6.z.number(),
|
|
688
|
+
label: import_zod6.z.string().max(24).optional(),
|
|
689
|
+
...leafBase
|
|
690
|
+
});
|
|
691
|
+
var AppSparklineSchema = import_zod6.z.object({
|
|
692
|
+
type: import_zod6.z.literal("sparkline"),
|
|
693
|
+
/** A source field holding a series rather than a scalar. */
|
|
694
|
+
series: AppBindingSchema,
|
|
695
|
+
...leafBase
|
|
696
|
+
});
|
|
697
|
+
var AppBarSchema = import_zod6.z.object({
|
|
698
|
+
type: import_zod6.z.literal("bar"),
|
|
699
|
+
value: AppBindingSchema,
|
|
700
|
+
min: import_zod6.z.number(),
|
|
701
|
+
max: import_zod6.z.number(),
|
|
702
|
+
...leafBase
|
|
703
|
+
});
|
|
704
|
+
var AppStatusSchema = import_zod6.z.object({
|
|
705
|
+
type: import_zod6.z.literal("status"),
|
|
706
|
+
state: AppBindingSchema,
|
|
707
|
+
label: import_zod6.z.string().max(24).optional(),
|
|
708
|
+
...leafBase
|
|
709
|
+
});
|
|
710
|
+
var SPRITE_MAX_SIDE = 64;
|
|
711
|
+
var SPRITE_MAX_ROW_BYTES = SPRITE_MAX_SIDE / 2;
|
|
712
|
+
var SPRITE_MAX_BASE64 = Math.ceil(SPRITE_MAX_ROW_BYTES * SPRITE_MAX_SIDE / 3) * 4;
|
|
713
|
+
var AppSpriteSchema = import_zod6.z.object({
|
|
714
|
+
type: import_zod6.z.literal("sprite"),
|
|
715
|
+
width: import_zod6.z.number().int().min(1).max(SPRITE_MAX_SIDE),
|
|
716
|
+
height: import_zod6.z.number().int().min(1).max(SPRITE_MAX_SIDE),
|
|
717
|
+
/**
|
|
718
|
+
* Up to sixteen colours, in the same form every other colour in a document
|
|
719
|
+
* takes: a semantic token, or literal RGB.
|
|
720
|
+
*
|
|
721
|
+
* Both are allowed on purpose. A token re-colours with the theme, which is
|
|
722
|
+
* what an icon wants; literal RGB does not, which is what a drawing wants.
|
|
723
|
+
* A picture of a dog is content, not chrome, and should not turn teal
|
|
724
|
+
* because somebody switched to the corporate theme.
|
|
725
|
+
*/
|
|
726
|
+
palette: import_zod6.z.array(AppColorSchema).min(1).max(16),
|
|
727
|
+
/** base64 of the packed nibbles. */
|
|
728
|
+
pixels: import_zod6.z.string().min(4).max(SPRITE_MAX_BASE64),
|
|
729
|
+
align: AppAlignSchema.default("start"),
|
|
730
|
+
/** Drawn only when this is false, or absent. */
|
|
731
|
+
hideWhen: AppConditionSchema.optional()
|
|
732
|
+
});
|
|
733
|
+
var AssetHashSchema = import_zod6.z.string().regex(/^[0-9a-f]{64}$/, "a lowercase hex SHA-256");
|
|
734
|
+
var IMAGE_MAX_DRAWN = { width: 304, height: 224 };
|
|
735
|
+
var IMAGE_MAX_SCALE = 8;
|
|
736
|
+
var RETRO_RENDITION = { width: 76, height: 56, scale: 4, colors: 16 };
|
|
737
|
+
var SPR_FORMAT = {
|
|
738
|
+
/** "RSPR". */
|
|
739
|
+
magic: [82, 83, 80, 82],
|
|
740
|
+
version: 1,
|
|
741
|
+
/** magic 4, version 1, width u16, height u16, bits per pixel 1, palette count 1. */
|
|
742
|
+
headerBytes: 11,
|
|
743
|
+
/** Only 4 today: two pixels per byte, high nibble first, rows padded to a byte. */
|
|
744
|
+
bitsPerPixel: 4,
|
|
745
|
+
maxColors: 16
|
|
746
|
+
};
|
|
747
|
+
var SPR_MAX_BYTES = SPR_FORMAT.headerBytes + SPR_FORMAT.maxColors * 2 + Math.ceil(IMAGE_MAX_DRAWN.width / 2) * IMAGE_MAX_DRAWN.height;
|
|
748
|
+
var AppImageSchema = import_zod6.z.object({
|
|
749
|
+
type: import_zod6.z.literal("image"),
|
|
750
|
+
asset: AssetHashSchema,
|
|
751
|
+
/** The file's own pixels, not the drawn size. */
|
|
752
|
+
width: import_zod6.z.number().int().min(1).max(IMAGE_MAX_DRAWN.width),
|
|
753
|
+
height: import_zod6.z.number().int().min(1).max(IMAGE_MAX_DRAWN.height),
|
|
754
|
+
scale: import_zod6.z.number().int().min(1).max(IMAGE_MAX_SCALE).default(1),
|
|
755
|
+
align: AppAlignSchema.default("start"),
|
|
756
|
+
/** Drawn only when this is false, or absent. */
|
|
757
|
+
hideWhen: AppConditionSchema.optional()
|
|
758
|
+
});
|
|
759
|
+
var AppLeafSchema = import_zod6.z.discriminatedUnion("type", [
|
|
760
|
+
AppTextSchema,
|
|
761
|
+
AppDialSchema,
|
|
762
|
+
AppSparklineSchema,
|
|
763
|
+
AppBarSchema,
|
|
764
|
+
AppStatusSchema,
|
|
765
|
+
AppSpriteSchema,
|
|
766
|
+
AppImageSchema
|
|
767
|
+
]);
|
|
768
|
+
var AppGroupSchema = import_zod6.z.object({
|
|
769
|
+
type: import_zod6.z.literal("group"),
|
|
770
|
+
direction: import_zod6.z.enum(["row", "stack"]),
|
|
771
|
+
gap: import_zod6.z.number().int().min(0).max(64).default(4),
|
|
772
|
+
align: AppAlignSchema.default("start"),
|
|
773
|
+
children: import_zod6.z.array(AppLeafSchema).min(1).max(8)
|
|
774
|
+
});
|
|
775
|
+
var AppBlockSchema = import_zod6.z.union([AppLeafSchema, AppGroupSchema]);
|
|
776
|
+
var AppScreenSizeSchema = import_zod6.z.preprocess(
|
|
777
|
+
(value) => value === "240x320" ? "320x240" : value,
|
|
778
|
+
import_zod6.z.enum(["320x240"])
|
|
779
|
+
);
|
|
780
|
+
var AppDocumentSchema = import_zod6.z.object({
|
|
781
|
+
/** Bumped only for a breaking change; the device checks it before parsing. */
|
|
782
|
+
schemaVersion: import_zod6.z.literal(1),
|
|
783
|
+
id: import_zod6.z.string().regex(/^[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$/, "lowercase slug"),
|
|
784
|
+
name: import_zod6.z.string().min(1).max(48),
|
|
785
|
+
/** Free text. Never an email or anything else identifying — see the plan. */
|
|
786
|
+
author: import_zod6.z.string().max(32).optional(),
|
|
787
|
+
screen: AppScreenSizeSchema.default("320x240"),
|
|
788
|
+
background: AppColorSchema.default("background"),
|
|
789
|
+
/** Named so bindings can refer to them. */
|
|
790
|
+
sources: import_zod6.z.record(AppSourceSchema).default({}),
|
|
791
|
+
blocks: import_zod6.z.array(AppBlockSchema).min(1).max(12)
|
|
792
|
+
}).superRefine((doc, ctx) => {
|
|
793
|
+
const bytesPerRow = (width) => Math.ceil(width / 2);
|
|
794
|
+
const check = (block, path) => {
|
|
795
|
+
const b = block;
|
|
796
|
+
if (b?.type !== "sprite" || !b.width || !b.height || typeof b.pixels !== "string") return;
|
|
797
|
+
const want = bytesPerRow(b.width) * b.height;
|
|
798
|
+
const got = Math.floor(b.pixels.replace(/=+$/, "").length * 3 / 4);
|
|
799
|
+
if (got === want) return;
|
|
800
|
+
ctx.addIssue({
|
|
801
|
+
code: import_zod6.z.ZodIssueCode.custom,
|
|
802
|
+
path: [...path, "pixels"],
|
|
803
|
+
message: `${b.width}x${b.height} needs ${want} bytes of pixel data, and this decodes to ${got}. Rows are padded to whole bytes, so the length is ceil(width / 2) * height.`
|
|
804
|
+
});
|
|
805
|
+
};
|
|
806
|
+
const checkImage = (block, path) => {
|
|
807
|
+
const b = block;
|
|
808
|
+
if (b?.type !== "image" || !b.width || !b.height) return;
|
|
809
|
+
const scale = b.scale ?? 1;
|
|
810
|
+
const w = b.width * scale;
|
|
811
|
+
const h = b.height * scale;
|
|
812
|
+
if (w <= IMAGE_MAX_DRAWN.width && h <= IMAGE_MAX_DRAWN.height) return;
|
|
813
|
+
ctx.addIssue({
|
|
814
|
+
code: import_zod6.z.ZodIssueCode.custom,
|
|
815
|
+
path: [...path, "scale"],
|
|
816
|
+
message: `${b.width}x${b.height} at scale ${scale} draws ${w}x${h}, and a board draws at most ${IMAGE_MAX_DRAWN.width}x${IMAGE_MAX_DRAWN.height} inside its margin.`
|
|
817
|
+
});
|
|
818
|
+
};
|
|
819
|
+
doc.blocks.forEach((block, i) => {
|
|
820
|
+
check(block, ["blocks", i]);
|
|
821
|
+
checkImage(block, ["blocks", i]);
|
|
822
|
+
const children = block.children;
|
|
823
|
+
if (Array.isArray(children)) {
|
|
824
|
+
children.forEach((child, j) => {
|
|
825
|
+
check(child, ["blocks", i, "children", j]);
|
|
826
|
+
checkImage(child, ["blocks", i, "children", j]);
|
|
827
|
+
});
|
|
828
|
+
}
|
|
829
|
+
});
|
|
830
|
+
});
|
|
831
|
+
|
|
832
|
+
// src/apps/photos.ts
|
|
833
|
+
var import_zod7 = require("zod");
|
|
834
|
+
var ORIGINAL_MAX_SIDE = 3072;
|
|
835
|
+
var ORIGINAL_MAX_BYTES = 3e6;
|
|
836
|
+
var PHOTOS_PER_ACCOUNT = 50;
|
|
837
|
+
var PHOTO_UPLOADS_PER_HOUR = 30;
|
|
838
|
+
var PhotoUploadSchema = import_zod7.z.object({
|
|
839
|
+
rendition: import_zod7.z.string().min(4),
|
|
840
|
+
original: import_zod7.z.string().min(4)
|
|
841
|
+
});
|
|
842
|
+
var PhotoSummarySchema = import_zod7.z.object({
|
|
843
|
+
hash: AssetHashSchema,
|
|
844
|
+
/** The rendition's own pixels. */
|
|
845
|
+
width: import_zod7.z.number().int().positive(),
|
|
846
|
+
height: import_zod7.z.number().int().positive(),
|
|
847
|
+
renditionBytes: import_zod7.z.number().int().positive(),
|
|
848
|
+
originalWidth: import_zod7.z.number().int().positive(),
|
|
849
|
+
originalHeight: import_zod7.z.number().int().positive(),
|
|
850
|
+
originalBytes: import_zod7.z.number().int().positive(),
|
|
851
|
+
uploadedAt: import_zod7.z.number().int()
|
|
852
|
+
});
|
|
853
|
+
|
|
854
|
+
// src/apps/delivery.ts
|
|
855
|
+
var import_zod8 = require("zod");
|
|
856
|
+
var DeviceIdSchema = import_zod8.z.string().regex(/^[0-9A-HJKMNP-TV-Z]{8}$/, "eight characters, no I L O or U");
|
|
857
|
+
var PairCodeSchema = import_zod8.z.string().regex(/^\d{4}$/);
|
|
858
|
+
var DeviceRegistrationSchema = import_zod8.z.object({
|
|
859
|
+
deviceId: DeviceIdSchema,
|
|
860
|
+
code: PairCodeSchema,
|
|
861
|
+
/** Firmware build, so a support question has an answer. */
|
|
862
|
+
version: import_zod8.z.string().max(40).optional(),
|
|
863
|
+
/** Which board this is, from Boards.h — the two variants need different firmware. */
|
|
864
|
+
board: import_zod8.z.string().max(40).optional(),
|
|
865
|
+
/** dBm, always negative. -50 is across the room; -85 is a complaint. */
|
|
866
|
+
rssi: import_zod8.z.number().int().min(-127).max(0).optional(),
|
|
867
|
+
/** On the owner's own network. Long enough for IPv6, which this does not send yet. */
|
|
868
|
+
ip: import_zod8.z.string().max(45).optional(),
|
|
869
|
+
/** Seconds since boot. Not growing between check-ins means it is restarting. */
|
|
870
|
+
uptime: import_zod8.z.number().int().nonnegative().optional(),
|
|
871
|
+
/** Free heap in bytes. */
|
|
872
|
+
heap: import_zod8.z.number().int().nonnegative().optional(),
|
|
873
|
+
/** The app revision the board has actually drawn. */
|
|
874
|
+
drew: import_zod8.z.number().int().nonnegative().optional(),
|
|
875
|
+
/** Why it last restarted, already mapped to a word by the firmware. */
|
|
876
|
+
reset: import_zod8.z.string().max(40).optional()
|
|
877
|
+
});
|
|
878
|
+
var SendRequestSchema = import_zod8.z.object({
|
|
879
|
+
deviceId: DeviceIdSchema,
|
|
880
|
+
code: PairCodeSchema
|
|
881
|
+
});
|
|
882
|
+
var OwnedSendRequestSchema = import_zod8.z.object({
|
|
883
|
+
deviceId: DeviceIdSchema
|
|
884
|
+
});
|
|
885
|
+
var DeliveredAppSchema = import_zod8.z.object({
|
|
886
|
+
revision: import_zod8.z.number().int().nonnegative(),
|
|
887
|
+
sentAt: import_zod8.z.number().int().nonnegative()
|
|
888
|
+
});
|
|
889
|
+
var DeviceRecordSchema = import_zod8.z.object({
|
|
890
|
+
deviceId: DeviceIdSchema,
|
|
891
|
+
code: PairCodeSchema,
|
|
892
|
+
ownerId: import_zod8.z.string().nullable().default(null),
|
|
893
|
+
version: import_zod8.z.string().max(40).optional(),
|
|
894
|
+
createdAt: import_zod8.z.number().int().nonnegative(),
|
|
895
|
+
lastSeenAt: import_zod8.z.number().int().nonnegative()
|
|
896
|
+
});
|
|
897
|
+
var DEVICE_LABEL_MAX = 48;
|
|
898
|
+
var DEVICE_TTL_SECONDS = 60 * 60 * 24 * 30;
|
|
899
|
+
var CLAIMED_DEVICE_TTL_SECONDS = 60 * 60 * 24 * 400;
|
|
900
|
+
|
|
901
|
+
// src/apps/vitals.ts
|
|
902
|
+
var import_zod9 = require("zod");
|
|
903
|
+
var VitalSourceSchema = import_zod9.z.enum(["register", "poll", "send"]);
|
|
904
|
+
var DeviceVitalsSchema = import_zod9.z.object({
|
|
905
|
+
/** When the board last said any of this, by the server's clock. */
|
|
906
|
+
reportedAt: import_zod9.z.number().int().nonnegative().optional(),
|
|
907
|
+
/**
|
|
908
|
+
* The firmware build. Today every board sends the literal "doc-1", which is a
|
|
909
|
+
* protocol marker rather than a build id — so this is shown as reported and
|
|
910
|
+
* labelled as not yet a version. The real value lives in the published
|
|
911
|
+
* manifest until firmware carries it.
|
|
912
|
+
*/
|
|
913
|
+
firmwareVersion: import_zod9.z.string().max(40).optional(),
|
|
914
|
+
/** Which board this is. Nothing distinguishes a CYD from a Freenove S3 yet. */
|
|
915
|
+
board: import_zod9.z.string().max(40).optional(),
|
|
916
|
+
/** dBm, negative. -50 is across the room, -85 is a complaint. */
|
|
917
|
+
rssi: import_zod9.z.number().int().min(-127).max(0).optional(),
|
|
918
|
+
/** The board's address on its own network, as the board sees it. */
|
|
919
|
+
ip: import_zod9.z.string().max(45).optional(),
|
|
920
|
+
uptimeSeconds: import_zod9.z.number().int().nonnegative().optional(),
|
|
921
|
+
freeHeapBytes: import_zod9.z.number().int().nonnegative().optional(),
|
|
922
|
+
/**
|
|
923
|
+
* The revision the board is actually showing.
|
|
924
|
+
*
|
|
925
|
+
* Distinct from the revision that was sent, and the difference is the whole
|
|
926
|
+
* value: a send that was never drawn looks identical to a successful one until
|
|
927
|
+
* these two numbers disagree.
|
|
928
|
+
*/
|
|
929
|
+
drewRevision: import_zod9.z.number().int().nonnegative().optional(),
|
|
930
|
+
/** Why it last restarted, if it says. A board power-cycling in a loop is a fault. */
|
|
931
|
+
resetReason: import_zod9.z.string().max(40).optional(),
|
|
932
|
+
/** When it last polled — finer-grained than a registration, for liveness only. */
|
|
933
|
+
lastPollAt: import_zod9.z.number().int().nonnegative().optional()
|
|
934
|
+
});
|
|
935
|
+
var DeviceSeenSchema = import_zod9.z.object({
|
|
936
|
+
/** When the board last asked for its app. The freshest signal this system has. */
|
|
937
|
+
lastPollAt: import_zod9.z.number().int().nonnegative(),
|
|
938
|
+
/** The revision it reported drawing at that moment. */
|
|
939
|
+
drewRevision: import_zod9.z.number().int().nonnegative().optional()
|
|
940
|
+
});
|
|
941
|
+
var DEVICE_VITALS_FIELDS = [
|
|
942
|
+
{
|
|
943
|
+
key: "firmwareVersion",
|
|
944
|
+
label: "Firmware",
|
|
945
|
+
source: "register",
|
|
946
|
+
reportedByFirmware: true,
|
|
947
|
+
note: 'A build stamped in by CI. Boards flashed before that report the marker "doc-1".'
|
|
948
|
+
},
|
|
949
|
+
{ key: "board", label: "Board", source: "register", reportedByFirmware: true },
|
|
950
|
+
{ key: "drewRevision", label: "Showing revision", source: "poll", reportedByFirmware: true },
|
|
951
|
+
{ key: "rssi", label: "Wi-Fi signal", unit: "dBm", source: "register", reportedByFirmware: true },
|
|
952
|
+
{ key: "ip", label: "Address on your network", source: "register", reportedByFirmware: true },
|
|
953
|
+
{ key: "uptimeSeconds", label: "Uptime", unit: "s", source: "register", reportedByFirmware: true },
|
|
954
|
+
{
|
|
955
|
+
key: "freeHeapBytes",
|
|
956
|
+
label: "Free memory",
|
|
957
|
+
unit: "bytes",
|
|
958
|
+
source: "register",
|
|
959
|
+
reportedByFirmware: true
|
|
960
|
+
},
|
|
961
|
+
{ key: "resetReason", label: "Last restart", source: "register", reportedByFirmware: true }
|
|
962
|
+
];
|
|
963
|
+
var DEVICE_FRESH_MS = 7 * 60 * 60 * 1e3;
|
|
964
|
+
var DEVICE_STALE_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
965
|
+
|
|
966
|
+
// src/apps/glyphs.ts
|
|
967
|
+
var DEVICE_UNKNOWN_GLYPH = "?";
|
|
968
|
+
var DEVICE_GLYPHS = {
|
|
969
|
+
// Accented Latin, CP437 0x80-0xA5 and 0xE1
|
|
970
|
+
"\xC7": { byte: 128, shows: "\xC7" },
|
|
971
|
+
"\xFC": { byte: 129, shows: "\xFC" },
|
|
972
|
+
"\xE9": { byte: 130, shows: "\xE9" },
|
|
973
|
+
"\xE2": { byte: 131, shows: "\xE2" },
|
|
974
|
+
"\xE4": { byte: 132, shows: "\xE4" },
|
|
975
|
+
"\xE0": { byte: 133, shows: "\xE0" },
|
|
976
|
+
"\xE5": { byte: 134, shows: "\xE5" },
|
|
977
|
+
"\xE7": { byte: 135, shows: "\xE7" },
|
|
978
|
+
"\xEA": { byte: 136, shows: "\xEA" },
|
|
979
|
+
"\xEB": { byte: 137, shows: "\xEB" },
|
|
980
|
+
"\xE8": { byte: 138, shows: "\xE8" },
|
|
981
|
+
"\xEF": { byte: 139, shows: "\xEF" },
|
|
982
|
+
"\xEE": { byte: 140, shows: "\xEE" },
|
|
983
|
+
"\xEC": { byte: 141, shows: "\xEC" },
|
|
984
|
+
"\xC4": { byte: 142, shows: "\xC4" },
|
|
985
|
+
"\xC5": { byte: 143, shows: "\xC5" },
|
|
986
|
+
"\xC9": { byte: 144, shows: "\xC9" },
|
|
987
|
+
"\xE6": { byte: 145, shows: "\xE6" },
|
|
988
|
+
"\xC6": { byte: 146, shows: "\xC6" },
|
|
989
|
+
"\xF4": { byte: 147, shows: "\xF4" },
|
|
990
|
+
"\xF6": { byte: 148, shows: "\xF6" },
|
|
991
|
+
"\xF2": { byte: 149, shows: "\xF2" },
|
|
992
|
+
"\xFB": { byte: 150, shows: "\xFB" },
|
|
993
|
+
"\xF9": { byte: 151, shows: "\xF9" },
|
|
994
|
+
"\xFF": { byte: 152, shows: "\xFF" },
|
|
995
|
+
"\xD6": { byte: 153, shows: "\xD6" },
|
|
996
|
+
"\xDC": { byte: 154, shows: "\xDC" },
|
|
997
|
+
"\xE1": { byte: 160, shows: "\xE1" },
|
|
998
|
+
"\xED": { byte: 161, shows: "\xED" },
|
|
999
|
+
"\xF3": { byte: 162, shows: "\xF3" },
|
|
1000
|
+
"\xFA": { byte: 163, shows: "\xFA" },
|
|
1001
|
+
"\xF1": { byte: 164, shows: "\xF1" },
|
|
1002
|
+
"\xD1": { byte: 165, shows: "\xD1" },
|
|
1003
|
+
"\xDF": { byte: 225, shows: "\xDF" },
|
|
1004
|
+
// Symbols a readout uses
|
|
1005
|
+
"\xA2": { byte: 155, shows: "\xA2" },
|
|
1006
|
+
"\xA3": { byte: 156, shows: "\xA3" },
|
|
1007
|
+
"\xA5": { byte: 157, shows: "\xA5" },
|
|
1008
|
+
"\u0192": { byte: 159, shows: "\u0192" },
|
|
1009
|
+
"\xAA": { byte: 166, shows: "\xAA" },
|
|
1010
|
+
"\xBA": { byte: 167, shows: "\xBA" },
|
|
1011
|
+
"\xBF": { byte: 168, shows: "\xBF" },
|
|
1012
|
+
"\xAC": { byte: 170, shows: "\xAC" },
|
|
1013
|
+
"\xBD": { byte: 171, shows: "\xBD" },
|
|
1014
|
+
"\xBC": { byte: 172, shows: "\xBC" },
|
|
1015
|
+
"\xA1": { byte: 173, shows: "\xA1" },
|
|
1016
|
+
"\xAB": { byte: 174, shows: "\xAB" },
|
|
1017
|
+
"\xBB": { byte: 175, shows: "\xBB" },
|
|
1018
|
+
"\u03C0": { byte: 227, shows: "\u03C0" },
|
|
1019
|
+
"\xB5": { byte: 230, shows: "\xB5" },
|
|
1020
|
+
"\u03A9": { byte: 234, shows: "\u03A9" },
|
|
1021
|
+
"\u221E": { byte: 236, shows: "\u221E" },
|
|
1022
|
+
"\xB1": { byte: 241, shows: "\xB1" },
|
|
1023
|
+
"\u2265": { byte: 242, shows: "\u2265" },
|
|
1024
|
+
"\u2264": { byte: 243, shows: "\u2264" },
|
|
1025
|
+
"\xF7": { byte: 246, shows: "\xF7" },
|
|
1026
|
+
"\u2248": { byte: 247, shows: "\u2248" },
|
|
1027
|
+
"\xB0": { byte: 248, shows: "\xB0" },
|
|
1028
|
+
"\xB7": { byte: 250, shows: "\xB7" },
|
|
1029
|
+
"\u221A": { byte: 251, shows: "\u221A" },
|
|
1030
|
+
"\xB2": { byte: 253, shows: "\xB2" },
|
|
1031
|
+
// Punctuation an AI writes without being asked, folded to ASCII
|
|
1032
|
+
"\u2018": { byte: 39, shows: "'" },
|
|
1033
|
+
"\u2019": { byte: 39, shows: "'" },
|
|
1034
|
+
"\u201C": { byte: 34, shows: '"' },
|
|
1035
|
+
"\u201D": { byte: 34, shows: '"' },
|
|
1036
|
+
"\u2013": { byte: 45, shows: "-" },
|
|
1037
|
+
"\u2014": { byte: 45, shows: "-" },
|
|
1038
|
+
"\u2212": { byte: 45, shows: "-" },
|
|
1039
|
+
"\xA0": { byte: 32, shows: " " }
|
|
1040
|
+
};
|
|
1041
|
+
var DEVICE_PALETTE = {
|
|
1042
|
+
background: "17 17 17",
|
|
1043
|
+
foreground: "238 238 238",
|
|
1044
|
+
muted: "153 153 153",
|
|
1045
|
+
accent: "23 162 184",
|
|
1046
|
+
success: "34 197 94",
|
|
1047
|
+
warning: "245 158 11",
|
|
1048
|
+
danger: "220 53 69"
|
|
1049
|
+
};
|
|
1050
|
+
|
|
1051
|
+
// src/apps/timezones.ts
|
|
1052
|
+
var DEVICE_TIMEZONES = [
|
|
1053
|
+
// North America
|
|
1054
|
+
{ iana: "America/New_York", posix: "EST5EDT,M3.2.0,M11.1.0" },
|
|
1055
|
+
{ iana: "America/Toronto", posix: "EST5EDT,M3.2.0,M11.1.0" },
|
|
1056
|
+
{ iana: "America/Chicago", posix: "CST6CDT,M3.2.0,M11.1.0" },
|
|
1057
|
+
{ iana: "America/Denver", posix: "MST7MDT,M3.2.0,M11.1.0" },
|
|
1058
|
+
{ iana: "America/Phoenix", posix: "MST7" },
|
|
1059
|
+
{ iana: "America/Los_Angeles", posix: "PST8PDT,M3.2.0,M11.1.0" },
|
|
1060
|
+
{ iana: "America/Vancouver", posix: "PST8PDT,M3.2.0,M11.1.0" },
|
|
1061
|
+
{ iana: "America/Anchorage", posix: "AKST9AKDT,M3.2.0,M11.1.0" },
|
|
1062
|
+
{ iana: "Pacific/Honolulu", posix: "HST10" },
|
|
1063
|
+
{ iana: "America/Mexico_City", posix: "CST6" },
|
|
1064
|
+
{ iana: "America/Sao_Paulo", posix: "BRT3" },
|
|
1065
|
+
// Europe
|
|
1066
|
+
{ iana: "Europe/London", posix: "GMT0BST,M3.5.0/1,M10.5.0" },
|
|
1067
|
+
{ iana: "Europe/Dublin", posix: "GMT0IST,M3.5.0/1,M10.5.0" },
|
|
1068
|
+
{ iana: "Europe/Lisbon", posix: "WET0WEST,M3.5.0/1,M10.5.0" },
|
|
1069
|
+
{ iana: "Europe/Paris", posix: "CET-1CEST,M3.5.0,M10.5.0/3" },
|
|
1070
|
+
{ iana: "Europe/Berlin", posix: "CET-1CEST,M3.5.0,M10.5.0/3" },
|
|
1071
|
+
{ iana: "Europe/Madrid", posix: "CET-1CEST,M3.5.0,M10.5.0/3" },
|
|
1072
|
+
{ iana: "Europe/Rome", posix: "CET-1CEST,M3.5.0,M10.5.0/3" },
|
|
1073
|
+
{ iana: "Europe/Amsterdam", posix: "CET-1CEST,M3.5.0,M10.5.0/3" },
|
|
1074
|
+
{ iana: "Europe/Stockholm", posix: "CET-1CEST,M3.5.0,M10.5.0/3" },
|
|
1075
|
+
{ iana: "Europe/Warsaw", posix: "CET-1CEST,M3.5.0,M10.5.0/3" },
|
|
1076
|
+
{ iana: "Europe/Zurich", posix: "CET-1CEST,M3.5.0,M10.5.0/3" },
|
|
1077
|
+
{ iana: "Europe/Athens", posix: "EET-2EEST,M3.5.0/3,M10.5.0/4" },
|
|
1078
|
+
{ iana: "Europe/Helsinki", posix: "EET-2EEST,M3.5.0/3,M10.5.0/4" },
|
|
1079
|
+
{ iana: "Europe/Kyiv", posix: "EET-2EEST,M3.5.0/3,M10.5.0/4" },
|
|
1080
|
+
{ iana: "Europe/Moscow", posix: "MSK-3" },
|
|
1081
|
+
// Asia and the Middle East
|
|
1082
|
+
{ iana: "Asia/Jerusalem", posix: "IST-2IDT,M3.5.5/2,M10.5.0" },
|
|
1083
|
+
{ iana: "Asia/Dubai", posix: "GST-4" },
|
|
1084
|
+
{ iana: "Asia/Kolkata", posix: "IST-5:30" },
|
|
1085
|
+
{ iana: "Asia/Bangkok", posix: "ICT-7" },
|
|
1086
|
+
{ iana: "Asia/Shanghai", posix: "CST-8" },
|
|
1087
|
+
{ iana: "Asia/Hong_Kong", posix: "HKT-8" },
|
|
1088
|
+
{ iana: "Asia/Singapore", posix: "SGT-8" },
|
|
1089
|
+
{ iana: "Asia/Tokyo", posix: "JST-9" },
|
|
1090
|
+
{ iana: "Asia/Seoul", posix: "KST-9" },
|
|
1091
|
+
// Oceania
|
|
1092
|
+
{ iana: "Australia/Perth", posix: "AWST-8" },
|
|
1093
|
+
{ iana: "Australia/Brisbane", posix: "AEST-10" },
|
|
1094
|
+
{ iana: "Australia/Adelaide", posix: "ACST-9:30ACDT,M10.1.0,M4.1.0/3" },
|
|
1095
|
+
{ iana: "Australia/Sydney", posix: "AEST-10AEDT,M10.1.0,M4.1.0/3" },
|
|
1096
|
+
{ iana: "Australia/Melbourne", posix: "AEST-10AEDT,M10.1.0,M4.1.0/3" },
|
|
1097
|
+
{ iana: "Pacific/Auckland", posix: "NZST-12NZDT,M9.5.0,M4.1.0/3" },
|
|
1098
|
+
{ iana: "UTC", posix: "UTC0" }
|
|
1099
|
+
];
|
|
1100
|
+
var DEVICE_TIMEZONE_FALLBACK = "UTC0";
|
|
1101
|
+
|
|
1102
|
+
// src/ai/tools.ts
|
|
1103
|
+
var import_zod10 = require("zod");
|
|
1104
|
+
var telemetryGraphParameters = import_zod10.z.object({
|
|
1105
|
+
deviceId: import_zod10.z.string().min(1, "Device ID is required"),
|
|
1106
|
+
timeRange: import_zod10.z.enum(["1h", "24h", "7d"], {
|
|
351
1107
|
errorMap: () => ({ message: "Time range must be 1h, 24h, or 7d" })
|
|
352
1108
|
}),
|
|
353
|
-
metrics:
|
|
354
|
-
|
|
1109
|
+
metrics: import_zod10.z.array(
|
|
1110
|
+
import_zod10.z.enum(["temperature", "humidity", "vwc", "ec", "ph", "pressure", "co2"])
|
|
355
1111
|
).min(1, "At least one metric is required").max(4, "Maximum 4 metrics per graph")
|
|
356
1112
|
});
|
|
357
|
-
var stockChartParameters =
|
|
358
|
-
ticker:
|
|
359
|
-
timeRange:
|
|
1113
|
+
var stockChartParameters = import_zod10.z.object({
|
|
1114
|
+
ticker: import_zod10.z.string().min(1).describe("The stock ticker symbol explicitly requested by the user. YOU MUST EXTRACT AND PROVIDE THIS (e.g., 'AAPL', 'MSFT')."),
|
|
1115
|
+
timeRange: import_zod10.z.enum(["1D", "1W", "1M", "1Y"], {
|
|
360
1116
|
errorMap: () => ({ message: "Time range must be 1D, 1W, 1M, or 1Y" })
|
|
361
1117
|
}).describe("The time range for the chart. Choose based on user request or default to '1M'."),
|
|
362
|
-
metrics:
|
|
1118
|
+
metrics: import_zod10.z.array(import_zod10.z.enum(["price", "volume", "moving_average"])).min(1, "At least one metric is required").describe("Array of metrics to display. Always include 'price' and 'volume' unless user specifies otherwise.")
|
|
363
1119
|
});
|
|
364
|
-
var tickerParam =
|
|
365
|
-
var liveQuoteParameters =
|
|
366
|
-
var companyNewsParameters =
|
|
367
|
-
var companyProfileParameters =
|
|
1120
|
+
var tickerParam = import_zod10.z.string().min(1).describe("The stock ticker symbol (e.g., 'AAPL', 'TSLA', 'MSFT').");
|
|
1121
|
+
var liveQuoteParameters = import_zod10.z.object({ ticker: tickerParam });
|
|
1122
|
+
var companyNewsParameters = import_zod10.z.object({ ticker: tickerParam });
|
|
1123
|
+
var companyProfileParameters = import_zod10.z.object({ ticker: tickerParam });
|
|
1124
|
+
var counterpartyGraphParameters = import_zod10.z.object({
|
|
1125
|
+
ticker: tickerParam,
|
|
1126
|
+
hops: import_zod10.z.number().int().min(1).max(2).optional().describe("How many relationship hops to traverse (1 = direct counterparties only, 2 = counterparties-of-counterparties too). Defaults to 1 if omitted.")
|
|
1127
|
+
});
|
|
1128
|
+
var divergenceMetricsParameters = import_zod10.z.object({ ticker: tickerParam });
|
|
1129
|
+
var architectureReferenceParameters = import_zod10.z.object({});
|
|
368
1130
|
var AI_TOOLS = {
|
|
369
1131
|
get_telemetry_graph: {
|
|
370
1132
|
name: "get_telemetry_graph",
|
|
@@ -390,6 +1152,21 @@ var AI_TOOLS = {
|
|
|
390
1152
|
name: "get_company_profile",
|
|
391
1153
|
description: "Fetches fundamental company data including the business description, sector, industry, market cap, and P/E ratio.",
|
|
392
1154
|
parameters: companyProfileParameters
|
|
1155
|
+
},
|
|
1156
|
+
get_counterparty_graph: {
|
|
1157
|
+
name: "get_counterparty_graph",
|
|
1158
|
+
description: "Displays the inferred counterparty relationship graph for a company \u2014 suppliers, customers, partners, competitors, regulators, and investment/acquisition relationships that Fleet-Brain-Deep has extracted from alternative signals. Use this when the user asks about a company's business relationships, supply chain, competitors, or who it partners/invests with. Not for corporate ownership structure (parent/subsidiary) \u2014 use company profile data for that.",
|
|
1159
|
+
parameters: counterpartyGraphParameters
|
|
1160
|
+
},
|
|
1161
|
+
get_divergence_metrics: {
|
|
1162
|
+
name: "get_divergence_metrics",
|
|
1163
|
+
description: "Displays Fleet-Brain-Deep's operational and customer divergence scores for a company \u2014 a signed delta between expected (baseline) and observed performance, inferred from recent signals. Use this when the user asks whether something is going better or worse than expected operationally or from a customer-experience standpoint.",
|
|
1164
|
+
parameters: divergenceMetricsParameters
|
|
1165
|
+
},
|
|
1166
|
+
get_architecture_reference: {
|
|
1167
|
+
name: "get_architecture_reference",
|
|
1168
|
+
description: "Explains THIS PLATFORM'S OWN data architecture \u2014 its tech stack, database schema and data modeling, AI/LLM integration points, and background worker (sentinel) fleet. Use this for questions about how the system itself is built, not about a company or the market. Takes no parameters.",
|
|
1169
|
+
parameters: architectureReferenceParameters
|
|
393
1170
|
}
|
|
394
1171
|
};
|
|
395
1172
|
|
|
@@ -397,6 +1174,16 @@ var AI_TOOLS = {
|
|
|
397
1174
|
var DEFAULT_SCHEMA_MODEL = "gemini-2.5-flash";
|
|
398
1175
|
var DEFAULT_CHAT_MODEL = "gemini-2.5-flash";
|
|
399
1176
|
var DEFAULT_PRO_MODEL = "gemini-2.5-pro";
|
|
1177
|
+
var PROVIDER_DEFAULT_MODEL = {
|
|
1178
|
+
"google-gemini": "gemini-2.5-flash",
|
|
1179
|
+
"openai": "gpt-4o-mini",
|
|
1180
|
+
"anthropic": "claude-haiku-4-5-20251001",
|
|
1181
|
+
"grok": "grok-2-1212",
|
|
1182
|
+
"deepseek": "deepseek-chat",
|
|
1183
|
+
"ollama": "llama3.3"
|
|
1184
|
+
};
|
|
1185
|
+
var ASSISTANT_PROVIDER = "anthropic";
|
|
1186
|
+
var ASSISTANT_MODEL = PROVIDER_DEFAULT_MODEL[ASSISTANT_PROVIDER];
|
|
400
1187
|
var AI_ROSTER = {
|
|
401
1188
|
/** The Strategist: high creativity, exploratory conversation */
|
|
402
1189
|
STRATEGIST: {
|
|
@@ -574,13 +1361,150 @@ RULE: If you cannot express a UI intent with a semantic token from the \u2705 li
|
|
|
574
1361
|
use bg-card or bg-background as a safe fallback. NEVER invent raw colors.
|
|
575
1362
|
`;
|
|
576
1363
|
|
|
1364
|
+
// src/ai/prompts/appDocument.prompt.ts
|
|
1365
|
+
var APP_DOCUMENT_SYSTEM_PROMPT = `
|
|
1366
|
+
You write tiny apps for a small desk device whose screen is 320 pixels wide and
|
|
1367
|
+
240 pixels high \u2014 landscape.
|
|
1368
|
+
|
|
1369
|
+
Reply with ONE JSON object and nothing else. No markdown fences, no explanation.
|
|
1370
|
+
|
|
1371
|
+
THE SHAPE
|
|
1372
|
+
|
|
1373
|
+
{
|
|
1374
|
+
"schemaVersion": 1,
|
|
1375
|
+
"id": "lowercase-slug",
|
|
1376
|
+
"name": "Short Name",
|
|
1377
|
+
"screen": "320x240",
|
|
1378
|
+
"background": "background",
|
|
1379
|
+
"sources": { },
|
|
1380
|
+
"blocks": [ ]
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
BLOCKS \u2014 up to 12, drawn top to bottom. Each is one of:
|
|
1384
|
+
|
|
1385
|
+
{ "type": "text", "value": V, "size": S, "align": A, "color": C, "suffix": "\xB0" }
|
|
1386
|
+
{ "type": "dial", "value": V, "min": 0, "max": 100, "label": "CPU", "color": C }
|
|
1387
|
+
{ "type": "bar", "value": V, "min": 0, "max": 100, "color": C }
|
|
1388
|
+
{ "type": "sparkline", "series": V, "color": C }
|
|
1389
|
+
{ "type": "status", "state": V, "label": "Door", "color": C }
|
|
1390
|
+
{ "type": "sprite", "palette": [C, ...], "grid": "0011
|
|
1391
|
+
0110
|
|
1392
|
+
1100
|
|
1393
|
+
0011", "align": A }
|
|
1394
|
+
{ "type": "group", "direction": "row"|"stack", "gap": 8, "align": A, "children": [ ...leaves... ] }
|
|
1395
|
+
|
|
1396
|
+
DRAWING A SPRITE \u2014 you may, and here is the only form that works.
|
|
1397
|
+
|
|
1398
|
+
Write a "grid": one line per row, one hex character per pixel, each character
|
|
1399
|
+
indexing "palette" (so "0" is the first colour, "1" the second, up to "f").
|
|
1400
|
+
Every row must be exactly the same length. Up to 64x64, but 16x16 and 32x32
|
|
1401
|
+
look far better \u2014 small palettes and bold shapes read on a 320x240 panel, fine
|
|
1402
|
+
detail does not.
|
|
1403
|
+
|
|
1404
|
+
{ "type": "sprite",
|
|
1405
|
+
"palette": ["background", "255 214 10", "17 17 17"],
|
|
1406
|
+
"grid": "0011110
|
|
1407
|
+
0122210
|
|
1408
|
+
1222221
|
|
1409
|
+
1211121
|
|
1410
|
+
1222221
|
|
1411
|
+
0122210
|
|
1412
|
+
0011110" }
|
|
1413
|
+
|
|
1414
|
+
Put the background colour FIRST so "0" means empty, and use "." as a synonym
|
|
1415
|
+
for "0" if it makes the shape easier to see while you write it.
|
|
1416
|
+
|
|
1417
|
+
Palette entries are the same colours as everywhere else: a semantic token
|
|
1418
|
+
re-colours with the theme, which is what an icon wants, and literal "R G B"
|
|
1419
|
+
does not, which is what a picture wants.
|
|
1420
|
+
|
|
1421
|
+
NEVER write a "pixels" field yourself. That is base64 of packed nibbles, one
|
|
1422
|
+
wrong character shifts every pixel after it, and you cannot check it. Write the
|
|
1423
|
+
grid; it is converted for you. If a document you are editing already has
|
|
1424
|
+
"pixels" and no "grid", leave it exactly as it is.
|
|
1425
|
+
|
|
1426
|
+
PHOTOS \u2014 a document you are editing may hold { "type": "image", "asset": "<64 hex
|
|
1427
|
+
characters>", ... }. That is a picture someone uploaded, named by the hash of
|
|
1428
|
+
its file. Keep every image block exactly as it is unless asked to remove it, and
|
|
1429
|
+
never write one yourself: you cannot make the file it names, so any hash you
|
|
1430
|
+
invent draws nothing.
|
|
1431
|
+
|
|
1432
|
+
Count your rows before you answer. A grid whose rows are different lengths is
|
|
1433
|
+
the one mistake that will come back to you.
|
|
1434
|
+
|
|
1435
|
+
A group holds leaves only. Groups do NOT nest inside groups \u2014 the device has no
|
|
1436
|
+
layout engine, only computed offsets.
|
|
1437
|
+
|
|
1438
|
+
CONDITIONS \u2014 any block may also carry these:
|
|
1439
|
+
|
|
1440
|
+
"hideWhen": { "value": O, "op": "<", "than": 32 }
|
|
1441
|
+
leave it off the screen entirely while that is true
|
|
1442
|
+
|
|
1443
|
+
"rules": [ { "when": { "value": O, "op": "<", "than": 32 }, "color": "accent" },
|
|
1444
|
+
{ "when": { "value": O, "op": ">", "than": 85 }, "color": "danger" } ]
|
|
1445
|
+
style that applies only when something is true. First match wins, so write
|
|
1446
|
+
the narrowest band first. At most four. Each may set "color", "size" or both.
|
|
1447
|
+
|
|
1448
|
+
op is one of "<" "<=" ">" ">=" "==" "!="
|
|
1449
|
+
Only == and != work on words; the rest are for numbers.
|
|
1450
|
+
|
|
1451
|
+
O is an operand: { "literal": 32 } or { "source": "forecast", "field": "temperature" }
|
|
1452
|
+
|
|
1453
|
+
This is how "make it red when it is freezing" is expressed. Use it whenever a
|
|
1454
|
+
request contains "when", "if", "unless", "only", or a colour tied to a value.
|
|
1455
|
+
|
|
1456
|
+
S (size) "xs" | "sm" | "base" | "lg" | "xl" | "display"
|
|
1457
|
+
A (align) "start" | "center" | "end"
|
|
1458
|
+
C (color) "background" | "foreground" | "muted" | "accent" | "success" | "warning" | "danger"
|
|
1459
|
+
or three space-separated RGB numbers, e.g. "220 53 69"
|
|
1460
|
+
|
|
1461
|
+
VALUES \u2014 every V is one of:
|
|
1462
|
+
|
|
1463
|
+
{ "literal": "Hello" } text you wrote
|
|
1464
|
+
{ "source": "forecast", "field": "temperature" } read from a source
|
|
1465
|
+
{ "compute": "subtract", "of": [O, O], "round": true } arithmetic
|
|
1466
|
+
|
|
1467
|
+
compute is "add" | "subtract" | "multiply" | "divide", exactly two operands,
|
|
1468
|
+
and it does NOT nest \u2014 an operand is a literal or a source field, never
|
|
1469
|
+
another compute. "The difference between the high and the low" is the shape
|
|
1470
|
+
this is for.
|
|
1471
|
+
|
|
1472
|
+
SOURCES \u2014 declare what the app reads, then bind to it by name:
|
|
1473
|
+
|
|
1474
|
+
"forecast": { "kind": "weather", "latitude": 39.95, "longitude": -75.17,
|
|
1475
|
+
"units": "imperial", "refreshSeconds": 600 }
|
|
1476
|
+
fields: temperature, condition, high, low
|
|
1477
|
+
"now": { "kind": "clock", "timezone": "America/New_York", "twentyFourHour": false }
|
|
1478
|
+
fields: time, date, weekday, hour (hour is 0-23, for rules about time of day)
|
|
1479
|
+
"until": { "kind": "countdown", "target": "2026-12-25", "label": "Christmas" }
|
|
1480
|
+
fields: days, hours, minutes, seconds, label
|
|
1481
|
+
"fixed": { "kind": "static", "values": { "anything": 1 } }
|
|
1482
|
+
fields: whatever you put in values
|
|
1483
|
+
|
|
1484
|
+
RULES
|
|
1485
|
+
|
|
1486
|
+
1. 320x240 is small, and it is wider than it is tall. A "display" size text is
|
|
1487
|
+
about 56 pixels tall \u2014 one of those and two or three smaller lines fill the
|
|
1488
|
+
height. Use the width: a "row" group puts two or three things side by side.
|
|
1489
|
+
Prefer fewer, bigger things over a dense dashboard.
|
|
1490
|
+
2. Use semantic colours unless asked for a specific one. They follow the theme.
|
|
1491
|
+
3. There is no scrolling and no text wrapping. Long strings are cut off.
|
|
1492
|
+
4. No tables, no forms, no images, no buttons. The screen shows; it does not
|
|
1493
|
+
take input.
|
|
1494
|
+
5. If the request needs something the vocabulary cannot express, build the
|
|
1495
|
+
closest thing it can and do not invent a component.
|
|
1496
|
+
6. Prefer a rule over a fixed colour whenever the request ties appearance to a
|
|
1497
|
+
value. "Red when cold" is a rule; "red" is not.
|
|
1498
|
+
`.trim();
|
|
1499
|
+
var APP_DOCUMENT_EDIT_PREFIX = "Here is the current app. Change only what is asked:";
|
|
1500
|
+
|
|
577
1501
|
// src/theme/schema.ts
|
|
578
|
-
var
|
|
579
|
-
var RGBString =
|
|
1502
|
+
var import_zod11 = require("zod");
|
|
1503
|
+
var RGBString = import_zod11.z.string().regex(
|
|
580
1504
|
/^\d{1,3}\s+\d{1,3}\s+\d{1,3}$/,
|
|
581
1505
|
'Must be space-separated RGB integers (e.g. "13 110 253")'
|
|
582
1506
|
);
|
|
583
|
-
var ThemeOverridesSchema =
|
|
1507
|
+
var ThemeOverridesSchema = import_zod11.z.object({
|
|
584
1508
|
// ── Core Brand ───────────────────────────────────────────────────────────
|
|
585
1509
|
"--app-primary-color": RGBString.optional(),
|
|
586
1510
|
"--app-primary-foreground-color": RGBString.optional(),
|
|
@@ -596,9 +1520,9 @@ var ThemeOverridesSchema = import_zod6.z.object({
|
|
|
596
1520
|
"--app-muted-bg": RGBString.optional(),
|
|
597
1521
|
"--app-muted-text": RGBString.optional(),
|
|
598
1522
|
// ── Shape ────────────────────────────────────────────────────────────────
|
|
599
|
-
"--app-border-radius-sm":
|
|
600
|
-
"--app-border-radius-md":
|
|
601
|
-
"--app-border-radius-lg":
|
|
1523
|
+
"--app-border-radius-sm": import_zod11.z.string().optional(),
|
|
1524
|
+
"--app-border-radius-md": import_zod11.z.string().optional(),
|
|
1525
|
+
"--app-border-radius-lg": import_zod11.z.string().optional(),
|
|
602
1526
|
// ── Form Controls ────────────────────────────────────────────────────────
|
|
603
1527
|
"--app-input-bg-color": RGBString.optional(),
|
|
604
1528
|
"--app-input-text-color": RGBString.optional(),
|
|
@@ -612,19 +1536,19 @@ var ThemeOverridesSchema = import_zod6.z.object({
|
|
|
612
1536
|
"--app-chart-4": RGBString.optional(),
|
|
613
1537
|
"--app-chart-5": RGBString.optional()
|
|
614
1538
|
}).strict();
|
|
615
|
-
var ThemeFontsSchema =
|
|
1539
|
+
var ThemeFontsSchema = import_zod11.z.object({
|
|
616
1540
|
/** Google Font name for headings (h1–h4, .font-serif). Example: "Playfair Display" */
|
|
617
|
-
heading:
|
|
1541
|
+
heading: import_zod11.z.string(),
|
|
618
1542
|
/** Google Font name for body text. Example: "Inter" */
|
|
619
|
-
body:
|
|
1543
|
+
body: import_zod11.z.string(),
|
|
620
1544
|
/** Optional monospace font. Example: "Roboto Mono" */
|
|
621
|
-
mono:
|
|
1545
|
+
mono: import_zod11.z.string().optional()
|
|
622
1546
|
});
|
|
623
|
-
var AIThemeSchema =
|
|
1547
|
+
var AIThemeSchema = import_zod11.z.object({
|
|
624
1548
|
/** Short descriptive theme name. Example: "Midnight Garden" */
|
|
625
|
-
name:
|
|
1549
|
+
name: import_zod11.z.string(),
|
|
626
1550
|
/** One-sentence vibe description. Example: "Dark indigo with golden accents." */
|
|
627
|
-
description:
|
|
1551
|
+
description: import_zod11.z.string(),
|
|
628
1552
|
/** Google Font pairing for heading and body text. */
|
|
629
1553
|
fonts: ThemeFontsSchema.optional(),
|
|
630
1554
|
/**
|
|
@@ -635,13 +1559,13 @@ var AIThemeSchema = import_zod6.z.object({
|
|
|
635
1559
|
cssVars: ThemeOverridesSchema
|
|
636
1560
|
});
|
|
637
1561
|
var THEME_PRESETS = ["light", "dark", "system", "corporate", "midnight", "blueprint"];
|
|
638
|
-
var ThemeTokensSchema =
|
|
1562
|
+
var ThemeTokensSchema = import_zod11.z.object({
|
|
639
1563
|
primary: RGBString,
|
|
640
1564
|
neutral: RGBString,
|
|
641
1565
|
success: RGBString,
|
|
642
1566
|
warning: RGBString,
|
|
643
1567
|
destructive: RGBString,
|
|
644
|
-
radius:
|
|
1568
|
+
radius: import_zod11.z.enum(["none", "sm", "md", "lg", "full"])
|
|
645
1569
|
});
|
|
646
1570
|
var DEFAULT_THEME_TOKENS = {
|
|
647
1571
|
primary: "13 110 253",
|
|
@@ -653,22 +1577,101 @@ var DEFAULT_THEME_TOKENS = {
|
|
|
653
1577
|
};
|
|
654
1578
|
|
|
655
1579
|
// src/auth/schema.ts
|
|
656
|
-
var
|
|
657
|
-
var UserSchema =
|
|
658
|
-
id:
|
|
659
|
-
name:
|
|
660
|
-
email:
|
|
661
|
-
password:
|
|
662
|
-
role:
|
|
663
|
-
status:
|
|
664
|
-
joinedAt:
|
|
665
|
-
lastActive:
|
|
666
|
-
avatarUrl:
|
|
1580
|
+
var import_zod12 = require("zod");
|
|
1581
|
+
var UserSchema = import_zod12.z.object({
|
|
1582
|
+
id: import_zod12.z.string().default(""),
|
|
1583
|
+
name: import_zod12.z.string(),
|
|
1584
|
+
email: import_zod12.z.string().email(),
|
|
1585
|
+
password: import_zod12.z.string().optional(),
|
|
1586
|
+
role: import_zod12.z.string(),
|
|
1587
|
+
status: import_zod12.z.string().optional(),
|
|
1588
|
+
joinedAt: import_zod12.z.string().optional(),
|
|
1589
|
+
lastActive: import_zod12.z.string().optional(),
|
|
1590
|
+
avatarUrl: import_zod12.z.string().optional()
|
|
1591
|
+
});
|
|
1592
|
+
|
|
1593
|
+
// src/auth/accounts.ts
|
|
1594
|
+
var import_zod13 = require("zod");
|
|
1595
|
+
var AccountIdSchema = import_zod13.z.string().regex(/^acct_[0-9a-f]{12}$/, "acct_ and 12 hex digits");
|
|
1596
|
+
var AccountRoleSchema = import_zod13.z.enum(["member", "admin"]);
|
|
1597
|
+
var AccountStatusSchema = import_zod13.z.enum(["active", "suspended"]);
|
|
1598
|
+
var ScryptHashSchema = import_zod13.z.object({
|
|
1599
|
+
algo: import_zod13.z.literal("scrypt"),
|
|
1600
|
+
n: import_zod13.z.number().int().positive(),
|
|
1601
|
+
r: import_zod13.z.number().int().positive(),
|
|
1602
|
+
p: import_zod13.z.number().int().positive(),
|
|
1603
|
+
keylen: import_zod13.z.number().int().positive(),
|
|
1604
|
+
salt: import_zod13.z.string().min(16),
|
|
1605
|
+
hash: import_zod13.z.string().min(16)
|
|
1606
|
+
});
|
|
1607
|
+
var AccountRecordSchema = import_zod13.z.object({
|
|
1608
|
+
accountId: AccountIdSchema,
|
|
1609
|
+
/** Lowercased on write, because a login must not depend on how it was typed. */
|
|
1610
|
+
email: import_zod13.z.string().email().max(254),
|
|
1611
|
+
name: import_zod13.z.string().min(1).max(64),
|
|
1612
|
+
role: AccountRoleSchema,
|
|
1613
|
+
status: AccountStatusSchema,
|
|
1614
|
+
password: ScryptHashSchema,
|
|
1615
|
+
createdAt: import_zod13.z.number().int().nonnegative(),
|
|
1616
|
+
lastLoginAt: import_zod13.z.number().int().nonnegative().nullable().default(null),
|
|
1617
|
+
/** Which admin approved this, or null for the bootstrap account. */
|
|
1618
|
+
invitedBy: AccountIdSchema.nullable().default(null)
|
|
1619
|
+
});
|
|
1620
|
+
var PublicAccountSchema = import_zod13.z.object({
|
|
1621
|
+
accountId: AccountIdSchema,
|
|
1622
|
+
email: import_zod13.z.string().email(),
|
|
1623
|
+
name: import_zod13.z.string(),
|
|
1624
|
+
role: AccountRoleSchema,
|
|
1625
|
+
status: AccountStatusSchema
|
|
1626
|
+
});
|
|
1627
|
+
var SessionRecordSchema = import_zod13.z.object({
|
|
1628
|
+
accountId: AccountIdSchema,
|
|
1629
|
+
createdAt: import_zod13.z.number().int().nonnegative(),
|
|
1630
|
+
expiresAt: import_zod13.z.number().int().nonnegative(),
|
|
1631
|
+
lastSeenAt: import_zod13.z.number().int().nonnegative()
|
|
1632
|
+
});
|
|
1633
|
+
var InviteRecordSchema = import_zod13.z.object({
|
|
1634
|
+
email: import_zod13.z.string().email().max(254),
|
|
1635
|
+
role: AccountRoleSchema,
|
|
1636
|
+
createdAt: import_zod13.z.number().int().nonnegative(),
|
|
1637
|
+
expiresAt: import_zod13.z.number().int().nonnegative(),
|
|
1638
|
+
invitedBy: AccountIdSchema
|
|
667
1639
|
});
|
|
1640
|
+
var AccessRequestSchema = import_zod13.z.object({
|
|
1641
|
+
email: import_zod13.z.string().email().max(254),
|
|
1642
|
+
name: import_zod13.z.string().min(1).max(64),
|
|
1643
|
+
/** Optional, and never shown publicly. Long enough to be useful, short enough not to be an essay. */
|
|
1644
|
+
reason: import_zod13.z.string().max(500).optional()
|
|
1645
|
+
});
|
|
1646
|
+
var AccessRequestStatusSchema = import_zod13.z.enum(["pending", "approved", "denied"]);
|
|
1647
|
+
var AccessRequestRecordSchema = import_zod13.z.object({
|
|
1648
|
+
requestId: import_zod13.z.string().regex(/^req_[0-9a-f]{12}$/, "req_ and 12 hex digits"),
|
|
1649
|
+
email: import_zod13.z.string().email().max(254),
|
|
1650
|
+
name: import_zod13.z.string().min(1).max(64),
|
|
1651
|
+
reason: import_zod13.z.string().max(500).optional(),
|
|
1652
|
+
status: AccessRequestStatusSchema,
|
|
1653
|
+
createdAt: import_zod13.z.number().int().nonnegative(),
|
|
1654
|
+
decidedAt: import_zod13.z.number().int().nonnegative().nullable().default(null),
|
|
1655
|
+
decidedBy: AccountIdSchema.nullable().default(null)
|
|
1656
|
+
});
|
|
1657
|
+
var SCRYPT_PARAMS = {
|
|
1658
|
+
n: 32768,
|
|
1659
|
+
r: 8,
|
|
1660
|
+
p: 1,
|
|
1661
|
+
keylen: 64,
|
|
1662
|
+
maxmem: 64 * 1024 * 1024
|
|
1663
|
+
};
|
|
1664
|
+
var MIN_PASSWORD_LENGTH = 12;
|
|
1665
|
+
var MAX_PASSWORD_LENGTH = 200;
|
|
1666
|
+
var SESSION_COOKIE_NAME = "ramme_session";
|
|
1667
|
+
var SESSION_TTL_SECONDS = 60 * 60 * 24 * 30;
|
|
1668
|
+
var ACCOUNT_TTL_SECONDS = 60 * 60 * 24 * 400;
|
|
1669
|
+
var INVITE_TTL_SECONDS = 60 * 60 * 24 * 14;
|
|
1670
|
+
var ACCESS_REQUEST_TTL_SECONDS = 60 * 60 * 24 * 90;
|
|
668
1671
|
|
|
669
1672
|
// src/counterparty/schema.ts
|
|
670
|
-
var
|
|
671
|
-
var CounterpartyTypeSchema =
|
|
1673
|
+
var import_zod14 = require("zod");
|
|
1674
|
+
var CounterpartyTypeSchema = import_zod14.z.enum([
|
|
672
1675
|
"supplier",
|
|
673
1676
|
"customer",
|
|
674
1677
|
"partner",
|
|
@@ -676,92 +1679,332 @@ var CounterpartyTypeSchema = import_zod8.z.enum([
|
|
|
676
1679
|
"regulator",
|
|
677
1680
|
"unknown"
|
|
678
1681
|
]);
|
|
679
|
-
var
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
1682
|
+
var CounterpartyResolutionSchema = import_zod14.z.enum([
|
|
1683
|
+
"public",
|
|
1684
|
+
"public_uncovered",
|
|
1685
|
+
"private",
|
|
1686
|
+
"unresolved"
|
|
1687
|
+
]);
|
|
1688
|
+
var CounterpartyNodeSchema = import_zod14.z.object({
|
|
1689
|
+
id: import_zod14.z.string(),
|
|
1690
|
+
ticker: import_zod14.z.string().nullable(),
|
|
1691
|
+
/** Name as it appeared in the source signal — e.g. "Nike". Not the registered name. */
|
|
1692
|
+
name: import_zod14.z.string(),
|
|
1693
|
+
/** Registered legal name from `profiles` — e.g. "NIKE, Inc.". Null unless `public`. */
|
|
1694
|
+
publicName: import_zod14.z.string().nullable(),
|
|
1695
|
+
lei: import_zod14.z.string().nullable(),
|
|
1696
|
+
resolution: CounterpartyResolutionSchema,
|
|
683
1697
|
type: CounterpartyTypeSchema,
|
|
684
|
-
confidence:
|
|
685
|
-
sourceSignalIds:
|
|
686
|
-
firstSeenAt:
|
|
687
|
-
lastSeenAt:
|
|
1698
|
+
confidence: import_zod14.z.number().min(0).max(1),
|
|
1699
|
+
sourceSignalIds: import_zod14.z.array(import_zod14.z.number()),
|
|
1700
|
+
firstSeenAt: import_zod14.z.string().datetime(),
|
|
1701
|
+
lastSeenAt: import_zod14.z.string().datetime()
|
|
688
1702
|
});
|
|
689
|
-
var RelationshipEdgeTypeSchema =
|
|
1703
|
+
var RelationshipEdgeTypeSchema = import_zod14.z.enum([
|
|
690
1704
|
"supplies_to",
|
|
691
1705
|
"purchases_from",
|
|
692
1706
|
"partners_with",
|
|
693
1707
|
"competes_with",
|
|
694
|
-
"regulated_by"
|
|
1708
|
+
"regulated_by",
|
|
1709
|
+
"invests_in",
|
|
1710
|
+
"acquires",
|
|
1711
|
+
/**
|
|
1712
|
+
* Identity equivalence, not a business relationship: source and target are
|
|
1713
|
+
* the same real-world entity under two different node ids (typically a
|
|
1714
|
+
* slug-keyed node that predates LEI resolution, pointing at the canonical
|
|
1715
|
+
* LEI-keyed node once resolution succeeds). Never delete/merge either
|
|
1716
|
+
* node — this edge exists so a consumer wanting a deduped view can follow
|
|
1717
|
+
* it to the canonical id, reversibly.
|
|
1718
|
+
*/
|
|
1719
|
+
"same_as"
|
|
695
1720
|
]);
|
|
696
|
-
var RelationshipEdgeSchema =
|
|
697
|
-
id:
|
|
698
|
-
sourceId:
|
|
699
|
-
targetId:
|
|
1721
|
+
var RelationshipEdgeSchema = import_zod14.z.object({
|
|
1722
|
+
id: import_zod14.z.string(),
|
|
1723
|
+
sourceId: import_zod14.z.string(),
|
|
1724
|
+
targetId: import_zod14.z.string(),
|
|
700
1725
|
edgeType: RelationshipEdgeTypeSchema,
|
|
701
|
-
weight:
|
|
702
|
-
evidenceSignalIds:
|
|
703
|
-
updatedAt:
|
|
1726
|
+
weight: import_zod14.z.number().min(0).max(1),
|
|
1727
|
+
evidenceSignalIds: import_zod14.z.array(import_zod14.z.number()),
|
|
1728
|
+
updatedAt: import_zod14.z.string().datetime(),
|
|
1729
|
+
validFrom: import_zod14.z.string().datetime(),
|
|
1730
|
+
/** null = currently valid. Set when a differently-typed edge supersedes this one. */
|
|
1731
|
+
validTo: import_zod14.z.string().datetime().nullable()
|
|
704
1732
|
});
|
|
705
|
-
var SignalWeightSchema =
|
|
706
|
-
signalId:
|
|
707
|
-
weight:
|
|
708
|
-
reason:
|
|
1733
|
+
var SignalWeightSchema = import_zod14.z.object({
|
|
1734
|
+
signalId: import_zod14.z.number(),
|
|
1735
|
+
weight: import_zod14.z.number().min(0).max(1),
|
|
1736
|
+
reason: import_zod14.z.string().max(280)
|
|
709
1737
|
});
|
|
710
|
-
var DivergenceMetricSchema =
|
|
711
|
-
ticker:
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
1738
|
+
var DivergenceMetricSchema = import_zod14.z.object({
|
|
1739
|
+
ticker: import_zod14.z.string(),
|
|
1740
|
+
// 'operations'/'customer' are current; 'operational'/'ux' are pre-rename
|
|
1741
|
+
// values that still exist on rows written before the backend's rename —
|
|
1742
|
+
// kept here so reading old rows doesn't fail validation.
|
|
1743
|
+
metric: import_zod14.z.enum(["operations", "customer", "operational", "ux"]),
|
|
1744
|
+
score: import_zod14.z.number(),
|
|
1745
|
+
baseline: import_zod14.z.number(),
|
|
1746
|
+
observed: import_zod14.z.number(),
|
|
1747
|
+
computedAt: import_zod14.z.string().datetime(),
|
|
1748
|
+
contributingSignals: import_zod14.z.array(SignalWeightSchema)
|
|
718
1749
|
});
|
|
719
1750
|
|
|
720
1751
|
// src/non-public-entity/schema.ts
|
|
721
|
-
var
|
|
722
|
-
var NonPublicEntitySchema =
|
|
723
|
-
lei:
|
|
724
|
-
entityName:
|
|
725
|
-
jurisdiction:
|
|
726
|
-
registrationStatus:
|
|
727
|
-
parentEntityLei:
|
|
728
|
-
materialMetadata:
|
|
729
|
-
discoveredAt:
|
|
1752
|
+
var import_zod15 = require("zod");
|
|
1753
|
+
var NonPublicEntitySchema = import_zod15.z.object({
|
|
1754
|
+
lei: import_zod15.z.string().nullable(),
|
|
1755
|
+
entityName: import_zod15.z.string(),
|
|
1756
|
+
jurisdiction: import_zod15.z.string().nullable(),
|
|
1757
|
+
registrationStatus: import_zod15.z.string(),
|
|
1758
|
+
parentEntityLei: import_zod15.z.string().nullable(),
|
|
1759
|
+
materialMetadata: import_zod15.z.record(import_zod15.z.unknown()),
|
|
1760
|
+
discoveredAt: import_zod15.z.string().datetime()
|
|
1761
|
+
});
|
|
1762
|
+
|
|
1763
|
+
// src/events/schema.ts
|
|
1764
|
+
var import_zod16 = require("zod");
|
|
1765
|
+
var EventSourceSchema = import_zod16.z.enum(["db", "mock"]);
|
|
1766
|
+
var EntityEventKindSchema = import_zod16.z.enum(["news", "filing", "report"]);
|
|
1767
|
+
var ImpactScaleSchema = import_zod16.z.enum(["graded", "binary", "default", "none"]);
|
|
1768
|
+
var TimestampPrecisionSchema = import_zod16.z.enum(["second", "day"]);
|
|
1769
|
+
var EntityEventSchema = import_zod16.z.object({
|
|
1770
|
+
/** Namespaced so ids never collide across sources: `news:1234`, `filing:AAPL:2026-07-31`. */
|
|
1771
|
+
id: import_zod16.z.string(),
|
|
1772
|
+
kind: EntityEventKindSchema,
|
|
1773
|
+
/**
|
|
1774
|
+
* The producer's own type string, unmodified — `NEWS_YAHOO FINANCE_YAHOO RSS`,
|
|
1775
|
+
* `ANNUAL`, `SNAPSHOT`. There are 31 distinct NEWS variants in the live table,
|
|
1776
|
+
* so this is for filtering and debugging: never render it raw to a user.
|
|
1777
|
+
*/
|
|
1778
|
+
subtype: import_zod16.z.string().nullable(),
|
|
1779
|
+
ticker: import_zod16.z.string(),
|
|
1780
|
+
/** Always `YYYY-MM-DDTHH:MM:SSZ`. Fixed-width, so lexical order == chronological order. */
|
|
1781
|
+
occurredAt: import_zod16.z.string(),
|
|
1782
|
+
precision: TimestampPrecisionSchema,
|
|
1783
|
+
title: import_zod16.z.string(),
|
|
1784
|
+
summary: import_zod16.z.string().nullable(),
|
|
1785
|
+
url: import_zod16.z.string().nullable(),
|
|
1786
|
+
impact: import_zod16.z.number().nullable(),
|
|
1787
|
+
impactScale: ImpactScaleSchema,
|
|
1788
|
+
/** 0 bearish … 50 neutral … 100 bullish. */
|
|
1789
|
+
sentiment: import_zod16.z.number().nullable(),
|
|
1790
|
+
/** False for filings, and for any event sitting at exactly neutral. */
|
|
1791
|
+
sentimentIsMeaningful: import_zod16.z.boolean(),
|
|
1792
|
+
source: EventSourceSchema,
|
|
1793
|
+
meta: import_zod16.z.record(import_zod16.z.unknown()).nullable()
|
|
1794
|
+
});
|
|
1795
|
+
var PaginatedEntityEventsSchema = import_zod16.z.object({
|
|
1796
|
+
total: import_zod16.z.number(),
|
|
1797
|
+
page: import_zod16.z.number(),
|
|
1798
|
+
page_size: import_zod16.z.number(),
|
|
1799
|
+
data: import_zod16.z.array(EntityEventSchema)
|
|
730
1800
|
});
|
|
1801
|
+
var EventBucketSizeSchema = import_zod16.z.enum(["day", "week", "month"]);
|
|
1802
|
+
var EntityEventDensityBucketSchema = import_zod16.z.object({
|
|
1803
|
+
bucketStart: import_zod16.z.string(),
|
|
1804
|
+
kind: EntityEventKindSchema,
|
|
1805
|
+
count: import_zod16.z.number(),
|
|
1806
|
+
/** Null when no event in the bucket had meaningful sentiment. */
|
|
1807
|
+
avgSentiment: import_zod16.z.number().nullable(),
|
|
1808
|
+
maxImpact: import_zod16.z.number().nullable()
|
|
1809
|
+
});
|
|
1810
|
+
var EntityEventDensitySchema = import_zod16.z.object({
|
|
1811
|
+
ticker: import_zod16.z.string(),
|
|
1812
|
+
bucket: EventBucketSizeSchema,
|
|
1813
|
+
buckets: import_zod16.z.array(EntityEventDensityBucketSchema),
|
|
1814
|
+
/** So the client can set its time domain without a second request. */
|
|
1815
|
+
range: import_zod16.z.object({ min: import_zod16.z.string(), max: import_zod16.z.string() }),
|
|
1816
|
+
source: EventSourceSchema
|
|
1817
|
+
});
|
|
1818
|
+
var EntityEventFacetSchema = import_zod16.z.object({
|
|
1819
|
+
kind: EntityEventKindSchema,
|
|
1820
|
+
count: import_zod16.z.number(),
|
|
1821
|
+
earliest: import_zod16.z.string().nullable(),
|
|
1822
|
+
latest: import_zod16.z.string().nullable(),
|
|
1823
|
+
impactScale: ImpactScaleSchema,
|
|
1824
|
+
sentimentUsable: import_zod16.z.boolean()
|
|
1825
|
+
});
|
|
1826
|
+
var EntityEventFacetsSchema = import_zod16.z.object({
|
|
1827
|
+
ticker: import_zod16.z.string(),
|
|
1828
|
+
facets: import_zod16.z.array(EntityEventFacetSchema),
|
|
1829
|
+
source: EventSourceSchema
|
|
1830
|
+
});
|
|
1831
|
+
var DailyPricePointSchema = import_zod16.z.object({
|
|
1832
|
+
date: import_zod16.z.string(),
|
|
1833
|
+
open: import_zod16.z.number().nullable(),
|
|
1834
|
+
high: import_zod16.z.number().nullable(),
|
|
1835
|
+
low: import_zod16.z.number().nullable(),
|
|
1836
|
+
close: import_zod16.z.number(),
|
|
1837
|
+
volume: import_zod16.z.number().nullable()
|
|
1838
|
+
});
|
|
1839
|
+
var EntityPriceSeriesSchema = import_zod16.z.object({
|
|
1840
|
+
ticker: import_zod16.z.string(),
|
|
1841
|
+
series: import_zod16.z.array(DailyPricePointSchema),
|
|
1842
|
+
source: EventSourceSchema
|
|
1843
|
+
});
|
|
1844
|
+
var EVENT_KIND_LABELS = {
|
|
1845
|
+
news: "News",
|
|
1846
|
+
filing: "Filing",
|
|
1847
|
+
report: "Analyst report"
|
|
1848
|
+
};
|
|
1849
|
+
var IMPACT_FLAG_THRESHOLD = 7;
|
|
1850
|
+
var SENTIMENT_NEUTRAL = 50;
|
|
1851
|
+
var DEFAULT_HORIZON_QUARTERS = 5;
|
|
1852
|
+
var EXCLUDED_SOURCES = {
|
|
1853
|
+
insights: "insights.ANALYSIS is a verbatim 1:1 mirror of signals \u2014 every AAPL ANALYSIS row contains a news description verbatim and lands within 2s of it. Including it doubles every event.",
|
|
1854
|
+
divergence_metrics: "A continuously recomputed annotation, not an event: 524 AAPL rows in 2 days.",
|
|
1855
|
+
counterparty_edges: "No history exists \u2014 all rows were created within a 2-day window, so nothing can be placed on a time axis without fabricating it.",
|
|
1856
|
+
raw_filings: "Stale since April, superseded by signals.",
|
|
1857
|
+
market_metrics: "Two rows total.",
|
|
1858
|
+
job_log: "24.5M rows with no ticker index \u2014 never touch it in a request path."
|
|
1859
|
+
};
|
|
731
1860
|
// Annotate the CommonJS export names for ESM import in node:
|
|
732
1861
|
0 && (module.exports = {
|
|
1862
|
+
ACCESS_REQUEST_TTL_SECONDS,
|
|
1863
|
+
ACCOUNT_TTL_SECONDS,
|
|
733
1864
|
AIKeyManifestSchema,
|
|
734
1865
|
AIThemeSchema,
|
|
735
1866
|
AI_ROSTER,
|
|
736
1867
|
AI_TOOLS,
|
|
1868
|
+
APP_DOCUMENT_EDIT_PREFIX,
|
|
1869
|
+
APP_DOCUMENT_SYSTEM_PROMPT,
|
|
1870
|
+
ASSISTANT_MODEL,
|
|
1871
|
+
ASSISTANT_PROVIDER,
|
|
1872
|
+
AccessRequestRecordSchema,
|
|
1873
|
+
AccessRequestSchema,
|
|
1874
|
+
AccessRequestStatusSchema,
|
|
1875
|
+
AccountIdSchema,
|
|
1876
|
+
AccountRecordSchema,
|
|
1877
|
+
AccountRoleSchema,
|
|
1878
|
+
AccountStatusSchema,
|
|
737
1879
|
ActionSchema,
|
|
1880
|
+
AircraftAppConfigSchema,
|
|
1881
|
+
AppAlignSchema,
|
|
1882
|
+
AppBarSchema,
|
|
1883
|
+
AppBindingSchema,
|
|
1884
|
+
AppBlockSchema,
|
|
1885
|
+
AppColorSchema,
|
|
1886
|
+
AppColorTokenSchema,
|
|
1887
|
+
AppComputeSchema,
|
|
1888
|
+
AppConditionSchema,
|
|
1889
|
+
AppDialSchema,
|
|
1890
|
+
AppDocumentSchema,
|
|
1891
|
+
AppGroupSchema,
|
|
1892
|
+
AppImageSchema,
|
|
1893
|
+
AppLeafSchema,
|
|
1894
|
+
AppOperandSchema,
|
|
1895
|
+
AppRgbSchema,
|
|
1896
|
+
AppScreenSizeSchema,
|
|
738
1897
|
AppSignalSchema,
|
|
1898
|
+
AppSourceSchema,
|
|
1899
|
+
AppSparklineSchema,
|
|
739
1900
|
AppSpecificationSchema,
|
|
1901
|
+
AppSpriteSchema,
|
|
1902
|
+
AppStatusSchema,
|
|
1903
|
+
AppStyleRuleSchema,
|
|
1904
|
+
AppTextSchema,
|
|
1905
|
+
AppTextSizeSchema,
|
|
1906
|
+
AssetHashSchema,
|
|
740
1907
|
AuthStrategySchema,
|
|
741
1908
|
BlockSchema,
|
|
742
1909
|
Bodewell,
|
|
1910
|
+
CLAIMED_DEVICE_TTL_SECONDS,
|
|
1911
|
+
ClockAppConfigSchema,
|
|
743
1912
|
CounterpartyNodeSchema,
|
|
1913
|
+
CounterpartyResolutionSchema,
|
|
744
1914
|
CounterpartyTypeSchema,
|
|
745
1915
|
DEFAULT_CHAT_MODEL,
|
|
1916
|
+
DEFAULT_DEVICE_CONFIG,
|
|
1917
|
+
DEFAULT_HORIZON_QUARTERS,
|
|
746
1918
|
DEFAULT_PRO_MODEL,
|
|
747
1919
|
DEFAULT_SCHEMA_MODEL,
|
|
748
1920
|
DEFAULT_THEME_TOKENS,
|
|
1921
|
+
DEVICE_AP_SSID_PREFIX,
|
|
1922
|
+
DEVICE_ENDPOINTS,
|
|
1923
|
+
DEVICE_FRESH_MS,
|
|
1924
|
+
DEVICE_GLYPHS,
|
|
1925
|
+
DEVICE_LABEL_MAX,
|
|
1926
|
+
DEVICE_PALETTE,
|
|
1927
|
+
DEVICE_STALE_MS,
|
|
1928
|
+
DEVICE_TIMEZONES,
|
|
1929
|
+
DEVICE_TIMEZONE_FALLBACK,
|
|
1930
|
+
DEVICE_TTL_SECONDS,
|
|
1931
|
+
DEVICE_UNKNOWN_GLYPH,
|
|
1932
|
+
DEVICE_VITALS_FIELDS,
|
|
1933
|
+
DailyPricePointSchema,
|
|
1934
|
+
DeliveredAppSchema,
|
|
1935
|
+
DeviceAppIdSchema,
|
|
1936
|
+
DeviceAppsSchema,
|
|
1937
|
+
DeviceConfigSchema,
|
|
1938
|
+
DeviceDisplayConfigSchema,
|
|
1939
|
+
DeviceIdSchema,
|
|
1940
|
+
DeviceKindSchema,
|
|
1941
|
+
DeviceRecordSchema,
|
|
1942
|
+
DeviceRegistrationSchema,
|
|
1943
|
+
DeviceSeenSchema,
|
|
1944
|
+
DeviceStatusSchema,
|
|
1945
|
+
DeviceThemeSchema,
|
|
1946
|
+
DeviceVitalsSchema,
|
|
749
1947
|
DivergenceMetricSchema,
|
|
1948
|
+
EVENT_KIND_LABELS,
|
|
1949
|
+
EXCLUDED_SOURCES,
|
|
1950
|
+
EntityEventDensityBucketSchema,
|
|
1951
|
+
EntityEventDensitySchema,
|
|
1952
|
+
EntityEventFacetSchema,
|
|
1953
|
+
EntityEventFacetsSchema,
|
|
1954
|
+
EntityEventKindSchema,
|
|
1955
|
+
EntityEventSchema,
|
|
1956
|
+
EntityPriceSeriesSchema,
|
|
750
1957
|
EntitySchema,
|
|
1958
|
+
EventBucketSizeSchema,
|
|
1959
|
+
EventSourceSchema,
|
|
751
1960
|
FieldSchema,
|
|
752
1961
|
FloraTelemetrySchema,
|
|
753
1962
|
GENESIS_LIBRARY_CONTEXT,
|
|
754
1963
|
GENESIS_VALID_COMPONENTS,
|
|
1964
|
+
IMAGE_MAX_DRAWN,
|
|
1965
|
+
IMAGE_MAX_SCALE,
|
|
1966
|
+
IMPACT_FLAG_THRESHOLD,
|
|
1967
|
+
INVITE_TTL_SECONDS,
|
|
1968
|
+
ImpactScaleSchema,
|
|
1969
|
+
InviteRecordSchema,
|
|
1970
|
+
MAX_PASSWORD_LENGTH,
|
|
1971
|
+
MIN_PASSWORD_LENGTH,
|
|
755
1972
|
NonPublicEntitySchema,
|
|
1973
|
+
ORIGINAL_MAX_BYTES,
|
|
1974
|
+
ORIGINAL_MAX_SIDE,
|
|
1975
|
+
OwnedSendRequestSchema,
|
|
1976
|
+
PHOTOS_PER_ACCOUNT,
|
|
1977
|
+
PHOTO_UPLOADS_PER_HOUR,
|
|
1978
|
+
PROVIDER_DEFAULT_MODEL,
|
|
756
1979
|
PageSchema,
|
|
757
1980
|
PageSectionSchema,
|
|
1981
|
+
PaginatedEntityEventsSchema,
|
|
1982
|
+
PairCodeSchema,
|
|
1983
|
+
PhotoSummarySchema,
|
|
1984
|
+
PhotoUploadSchema,
|
|
1985
|
+
ProvisioningStateSchema,
|
|
1986
|
+
PublicAccountSchema,
|
|
1987
|
+
RETRO_RENDITION,
|
|
758
1988
|
RelationshipEdgeSchema,
|
|
759
1989
|
RelationshipEdgeTypeSchema,
|
|
760
1990
|
ResourceSchema,
|
|
1991
|
+
SCRYPT_PARAMS,
|
|
1992
|
+
SENTIMENT_NEUTRAL,
|
|
1993
|
+
SESSION_COOKIE_NAME,
|
|
1994
|
+
SESSION_TTL_SECONDS,
|
|
761
1995
|
SIGNAL_DOMAINS,
|
|
762
1996
|
SIGNAL_KINDS,
|
|
763
1997
|
SIGNAL_KIND_LABELS,
|
|
764
1998
|
SIGNAL_SOURCES,
|
|
1999
|
+
SPRITE_MAX_BASE64,
|
|
2000
|
+
SPRITE_MAX_ROW_BYTES,
|
|
2001
|
+
SPRITE_MAX_SIDE,
|
|
2002
|
+
SPR_FORMAT,
|
|
2003
|
+
SPR_MAX_BYTES,
|
|
2004
|
+
ScryptHashSchema,
|
|
2005
|
+
SendRequestSchema,
|
|
2006
|
+
SensorAppConfigSchema,
|
|
2007
|
+
SessionRecordSchema,
|
|
765
2008
|
SignalArraySchema,
|
|
766
2009
|
SignalKindSchema,
|
|
767
2010
|
SignalPacketSchema,
|
|
@@ -773,11 +2016,17 @@ var NonPublicEntitySchema = import_zod9.z.object({
|
|
|
773
2016
|
ThemeFontsSchema,
|
|
774
2017
|
ThemeOverridesSchema,
|
|
775
2018
|
ThemeTokensSchema,
|
|
2019
|
+
TimestampPrecisionSchema,
|
|
776
2020
|
TriggerSchema,
|
|
777
2021
|
UserSchema,
|
|
2022
|
+
VitalSourceSchema,
|
|
2023
|
+
WeatherAppConfigSchema,
|
|
778
2024
|
WorkflowSchema,
|
|
2025
|
+
architectureReferenceParameters,
|
|
779
2026
|
companyNewsParameters,
|
|
780
2027
|
companyProfileParameters,
|
|
2028
|
+
counterpartyGraphParameters,
|
|
2029
|
+
divergenceMetricsParameters,
|
|
781
2030
|
liveQuoteParameters,
|
|
782
2031
|
stockChartParameters,
|
|
783
2032
|
telemetryGraphParameters
|