@ramme-io/shared 3.7.0 → 4.1.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 +0 -2
- package/dist/index.cjs +843 -458
- package/dist/index.d.cts +31627 -1365
- package/dist/index.d.ts +31627 -1365
- package/dist/index.js +787 -425
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -166,8 +166,10 @@ var SIGNAL_DOMAINS = {
|
|
|
166
166
|
// Track C — latency, uptime, queue depth
|
|
167
167
|
USER_BEHAVIOR: "user_behavior",
|
|
168
168
|
// Track D — engagement, conversion, NPS
|
|
169
|
-
LOGIC: "logic"
|
|
169
|
+
LOGIC: "logic",
|
|
170
170
|
// Derived — Methodology Engine outputs
|
|
171
|
+
ENVIRONMENT: "environment"
|
|
172
|
+
// A device's surroundings — temperature, humidity, light
|
|
171
173
|
};
|
|
172
174
|
|
|
173
175
|
// src/signals/base.schema.ts
|
|
@@ -458,7 +460,30 @@ var AppSourceSchema = z6.discriminatedUnion("kind", [
|
|
|
458
460
|
z6.object({
|
|
459
461
|
kind: z6.literal("cycle"),
|
|
460
462
|
count: z6.number().int().min(2).max(12),
|
|
461
|
-
minutes: z6.number().int().min(1).max(1440).default(5)
|
|
463
|
+
minutes: z6.number().int().min(1).max(1440).default(5),
|
|
464
|
+
/**
|
|
465
|
+
* A turn shorter than a minute — a slideshow at 5, 15 or 30 seconds. Wins
|
|
466
|
+
* over `minutes` where it is given; `minutes` stays the nearest whole
|
|
467
|
+
* minute, so a board whose firmware predates this still takes turns,
|
|
468
|
+
* once a minute. Counted the same way: seconds since 1970, in turns.
|
|
469
|
+
*/
|
|
470
|
+
seconds: z6.number().int().min(5).max(86400).optional()
|
|
471
|
+
}),
|
|
472
|
+
/**
|
|
473
|
+
* The board's own parts: what a sensor plugged into the board it is drawn
|
|
474
|
+
* on is reading right now (docs/superpowers/specs/ramme-lab.md, "The
|
|
475
|
+
* differentiator"). Fields: `temperature`, from a temperature probe, a
|
|
476
|
+
* whole number in `units` like the weather's; and `connected`, whether a
|
|
477
|
+
* probe is plugged in at all. A board with nothing plugged in has no
|
|
478
|
+
* `temperature`, so a binding to it draws the placeholder.
|
|
479
|
+
*
|
|
480
|
+
* The board fills it from the probe (drawApp() in the sketch); a page
|
|
481
|
+
* previewing that board fills it from the readings the board reported
|
|
482
|
+
* (useAppData); the Studio, with no board, shows the placeholder.
|
|
483
|
+
*/
|
|
484
|
+
z6.object({
|
|
485
|
+
kind: z6.literal("board"),
|
|
486
|
+
units: z6.enum(["imperial", "metric"]).default("imperial")
|
|
462
487
|
})
|
|
463
488
|
]);
|
|
464
489
|
var AppOperandSchema = z6.union([
|
|
@@ -631,6 +656,11 @@ var AppGroupSchema = z6.object({
|
|
|
631
656
|
children: z6.array(AppLeafSchema).min(1).max(8)
|
|
632
657
|
});
|
|
633
658
|
var AppBlockSchema = z6.union([AppLeafSchema, AppGroupSchema]);
|
|
659
|
+
var PanelOrientationSchema = z6.enum(["landscape", "portrait"]);
|
|
660
|
+
var PANEL_SIZE = {
|
|
661
|
+
landscape: { width: 320, height: 240 },
|
|
662
|
+
portrait: { width: 240, height: 320 }
|
|
663
|
+
};
|
|
634
664
|
var AppScreenSizeSchema = z6.preprocess(
|
|
635
665
|
(value) => value === "240x320" ? "320x240" : value,
|
|
636
666
|
z6.enum(["320x240"])
|
|
@@ -661,6 +691,17 @@ var AppDocumentSchema = z6.object({
|
|
|
661
691
|
* Older firmware draws from the left.
|
|
662
692
|
*/
|
|
663
693
|
halign: z6.enum(["start", "center"]).optional(),
|
|
694
|
+
/**
|
|
695
|
+
* The lettering. `inter` (the default) is Inter, anti-aliased, drawn at
|
|
696
|
+
* each text size from its own font — SMOOTH_FONT_ADVANCES in
|
|
697
|
+
* ./deviceFonts.generated.ts are its widths. `pixel` is the board's
|
|
698
|
+
* built-in 5x7 bitmap font scaled up: the retro look, chunky on purpose.
|
|
699
|
+
* `tay` is TAY Dreamboat, the Ramme display face — capitals only, so
|
|
700
|
+
* lowercase is drawn as capitals; best for signs, times and numbers.
|
|
701
|
+
* Firmware older than 2026-10-18 draws everything in pixel, and older than
|
|
702
|
+
* 2026-10-20 draws `tay` as Inter.
|
|
703
|
+
*/
|
|
704
|
+
font: z6.enum(["inter", "pixel", "tay"]).optional(),
|
|
664
705
|
/** Named so bindings can refer to them. */
|
|
665
706
|
sources: z6.record(AppSourceSchema).default({}),
|
|
666
707
|
blocks: z6.array(AppBlockSchema).min(1).max(12)
|
|
@@ -750,82 +791,32 @@ var PhotoSummarySchema = z7.object({
|
|
|
750
791
|
});
|
|
751
792
|
|
|
752
793
|
// src/apps/delivery.ts
|
|
753
|
-
import { z as
|
|
754
|
-
var DeviceIdSchema = z8.string().regex(/^[0-9A-HJKMNP-TV-Z]{8}$/, "eight characters, no I L O or U");
|
|
755
|
-
var PairCodeSchema = z8.string().regex(/^\d{4}$/);
|
|
756
|
-
var DeviceRegistrationSchema = z8.object({
|
|
757
|
-
deviceId: DeviceIdSchema,
|
|
758
|
-
code: PairCodeSchema,
|
|
759
|
-
/** Firmware build, so a support question has an answer. */
|
|
760
|
-
version: z8.string().max(40).optional(),
|
|
761
|
-
/** Which board this is, from Boards.h — the two variants need different firmware. */
|
|
762
|
-
board: z8.string().max(40).optional(),
|
|
763
|
-
/** dBm, always negative. -50 is across the room; -85 is a complaint. */
|
|
764
|
-
rssi: z8.number().int().min(-127).max(0).optional(),
|
|
765
|
-
/** On the owner's own network. Long enough for IPv6, which this does not send yet. */
|
|
766
|
-
ip: z8.string().max(45).optional(),
|
|
767
|
-
/** Seconds since boot. Not growing between check-ins means it is restarting. */
|
|
768
|
-
uptime: z8.number().int().nonnegative().optional(),
|
|
769
|
-
/** Free heap in bytes. */
|
|
770
|
-
heap: z8.number().int().nonnegative().optional(),
|
|
771
|
-
/** The app revision the board has actually drawn. */
|
|
772
|
-
drew: z8.number().int().nonnegative().optional(),
|
|
773
|
-
/** Why it last restarted, already mapped to a word by the firmware. */
|
|
774
|
-
reset: z8.string().max(40).optional()
|
|
775
|
-
});
|
|
776
|
-
var SendRequestSchema = z8.object({
|
|
777
|
-
deviceId: DeviceIdSchema,
|
|
778
|
-
code: PairCodeSchema
|
|
779
|
-
});
|
|
780
|
-
var OwnedSendRequestSchema = z8.object({
|
|
781
|
-
deviceId: DeviceIdSchema
|
|
782
|
-
});
|
|
783
|
-
var DeliveredAppSchema = z8.object({
|
|
784
|
-
revision: z8.number().int().nonnegative(),
|
|
785
|
-
sentAt: z8.number().int().nonnegative()
|
|
786
|
-
});
|
|
787
|
-
var DeviceRecordSchema = z8.object({
|
|
788
|
-
deviceId: DeviceIdSchema,
|
|
789
|
-
code: PairCodeSchema,
|
|
790
|
-
ownerId: z8.string().nullable().default(null),
|
|
791
|
-
version: z8.string().max(40).optional(),
|
|
792
|
-
createdAt: z8.number().int().nonnegative(),
|
|
793
|
-
lastSeenAt: z8.number().int().nonnegative()
|
|
794
|
-
});
|
|
795
|
-
var DEVICE_LABEL_MAX = 48;
|
|
796
|
-
var DEVICE_TTL_SECONDS = 60 * 60 * 24 * 30;
|
|
797
|
-
var CLAIMED_DEVICE_TTL_SECONDS = 60 * 60 * 24 * 400;
|
|
798
|
-
var FirmwareUpdateSchema = z8.object({
|
|
799
|
-
version: z8.string().min(1).max(40),
|
|
800
|
-
url: z8.string().url().max(200),
|
|
801
|
-
sha256: z8.string().regex(/^[0-9a-f]{64}$/),
|
|
802
|
-
bytes: z8.number().int().positive(),
|
|
803
|
-
requestedAt: z8.number().int().nonnegative()
|
|
804
|
-
});
|
|
805
|
-
var FIRMWARE_UPDATE_PREFIX = "https://www.ramme.io/firmware/weather-display/";
|
|
806
|
-
var FIRMWARE_UPDATE_ATTEMPTS = 3;
|
|
794
|
+
import { z as z9 } from "zod";
|
|
807
795
|
|
|
808
796
|
// src/apps/vitals.ts
|
|
809
|
-
import { z as
|
|
810
|
-
var VitalSourceSchema =
|
|
811
|
-
var
|
|
797
|
+
import { z as z8 } from "zod";
|
|
798
|
+
var VitalSourceSchema = z8.enum(["register", "poll", "send"]);
|
|
799
|
+
var DeviceFeatureStateSchema = z8.enum(["working", "missing", "unsupported", "fault"]);
|
|
800
|
+
var DeviceFeatureKeySchema = z8.string().regex(/^[a-z][a-z0-9-]{0,23}$/);
|
|
801
|
+
var DeviceFeaturesSchema = z8.record(DeviceFeatureKeySchema, DeviceFeatureStateSchema).refine((f) => Object.keys(f).length <= 16, { message: "at most 16 features" });
|
|
802
|
+
var DeviceVitalsSchema = z8.object({
|
|
812
803
|
/** When the board last said any of this, by the server's clock. */
|
|
813
|
-
reportedAt:
|
|
804
|
+
reportedAt: z8.number().int().nonnegative().optional(),
|
|
814
805
|
/**
|
|
815
806
|
* The firmware build. Today every board sends the literal "doc-1", which is a
|
|
816
807
|
* protocol marker rather than a build id — so this is shown as reported and
|
|
817
808
|
* labelled as not yet a version. The real value lives in the published
|
|
818
809
|
* manifest until firmware carries it.
|
|
819
810
|
*/
|
|
820
|
-
firmwareVersion:
|
|
811
|
+
firmwareVersion: z8.string().max(40).optional(),
|
|
821
812
|
/** Which board this is. Nothing distinguishes a CYD from a Freenove S3 yet. */
|
|
822
|
-
board:
|
|
813
|
+
board: z8.string().max(40).optional(),
|
|
823
814
|
/** dBm, negative. -50 is across the room, -85 is a complaint. */
|
|
824
|
-
rssi:
|
|
815
|
+
rssi: z8.number().int().min(-127).max(0).optional(),
|
|
825
816
|
/** The board's address on its own network, as the board sees it. */
|
|
826
|
-
ip:
|
|
827
|
-
uptimeSeconds:
|
|
828
|
-
freeHeapBytes:
|
|
817
|
+
ip: z8.string().max(45).optional(),
|
|
818
|
+
uptimeSeconds: z8.number().int().nonnegative().optional(),
|
|
819
|
+
freeHeapBytes: z8.number().int().nonnegative().optional(),
|
|
829
820
|
/**
|
|
830
821
|
* The revision the board is actually showing.
|
|
831
822
|
*
|
|
@@ -833,30 +824,69 @@ var DeviceVitalsSchema = z9.object({
|
|
|
833
824
|
* value: a send that was never drawn looks identical to a successful one until
|
|
834
825
|
* these two numbers disagree.
|
|
835
826
|
*/
|
|
836
|
-
drewRevision:
|
|
827
|
+
drewRevision: z8.number().int().nonnegative().optional(),
|
|
837
828
|
/** Why it last restarted, if it says. A board power-cycling in a loop is a fault. */
|
|
838
|
-
resetReason:
|
|
829
|
+
resetReason: z8.string().max(40).optional(),
|
|
830
|
+
/** Its parts and whether each works — see `DeviceFeaturesSchema`. */
|
|
831
|
+
features: DeviceFeaturesSchema.optional(),
|
|
839
832
|
/** When it last polled — finer-grained than a registration, for liveness only. */
|
|
840
|
-
lastPollAt:
|
|
833
|
+
lastPollAt: z8.number().int().nonnegative().optional()
|
|
841
834
|
});
|
|
842
|
-
var DeviceSeenSchema =
|
|
835
|
+
var DeviceSeenSchema = z8.object({
|
|
843
836
|
/** When the board last asked for its app. The freshest signal this system has. */
|
|
844
|
-
lastPollAt:
|
|
837
|
+
lastPollAt: z8.number().int().nonnegative(),
|
|
845
838
|
/** The revision it reported drawing at that moment. */
|
|
846
|
-
drewRevision:
|
|
839
|
+
drewRevision: z8.number().int().nonnegative().optional(),
|
|
847
840
|
/**
|
|
848
841
|
* The firmware it is running, sent on every poll by builds that can update
|
|
849
842
|
* remotely — so its presence is also the answer to "can this board be
|
|
850
843
|
* updated from its page?". Registration reports the version too, but only
|
|
851
844
|
* every six hours; after a remote update this is what shows it took.
|
|
852
845
|
*/
|
|
853
|
-
firmware:
|
|
846
|
+
firmware: z8.string().max(40).optional(),
|
|
854
847
|
/** Photos its app names, and how many of those it holds in flash. */
|
|
855
|
-
photosWanted:
|
|
856
|
-
photosHeld:
|
|
848
|
+
photosWanted: z8.number().int().nonnegative().optional(),
|
|
849
|
+
photosHeld: z8.number().int().nonnegative().optional(),
|
|
857
850
|
/** What happened to the last firmware update it tried, in a few words. */
|
|
858
|
-
updateResult:
|
|
859
|
-
|
|
851
|
+
updateResult: z8.string().max(80).optional(),
|
|
852
|
+
/**
|
|
853
|
+
* What the battery line reads, in millivolts — S3 boards only, which have a
|
|
854
|
+
* divider on GPIO9; a CYD has no way to measure a battery. Shown raw on the
|
|
855
|
+
* board's page until it has been checked against a real battery, and only
|
|
856
|
+
* then turned into an icon and a percentage on the glass.
|
|
857
|
+
*/
|
|
858
|
+
batteryMv: z8.number().int().min(0).max(1e4).optional(),
|
|
859
|
+
/**
|
|
860
|
+
* The quarter turn its screen is set to (Settings → Turn), 0-3 as LovyanGFX
|
|
861
|
+
* counts them: even is upright, odd is sideways, the board's 240x320 panel
|
|
862
|
+
* turned. Its page previews apps the way the board stands (PANEL_SIZE).
|
|
863
|
+
* Absent from a board older than 2026-10-28, which only ever stood sideways.
|
|
864
|
+
*/
|
|
865
|
+
rotation: z8.number().int().min(0).max(3).optional()
|
|
866
|
+
});
|
|
867
|
+
var DeviceReadingSchema = z8.object({
|
|
868
|
+
key: DeviceFeatureKeySchema,
|
|
869
|
+
value: z8.union([z8.number().finite(), z8.string().max(64), z8.boolean()]),
|
|
870
|
+
unit: z8.string().max(16).optional(),
|
|
871
|
+
at: z8.number().int().nonnegative().optional()
|
|
872
|
+
});
|
|
873
|
+
var DeviceReportSchema = z8.object({
|
|
874
|
+
readings: z8.array(DeviceReadingSchema).min(1).max(16)
|
|
875
|
+
});
|
|
876
|
+
var DEVICE_FEATURES = [
|
|
877
|
+
{ key: "screen", label: "Screen" },
|
|
878
|
+
{ key: "touch", label: "Touch" },
|
|
879
|
+
{ key: "speaker", label: "Speaker" },
|
|
880
|
+
{ key: "microphone", label: "Microphone" },
|
|
881
|
+
{ key: "battery", label: "Battery" },
|
|
882
|
+
{ key: "temperature", label: "Temperature probe" }
|
|
883
|
+
];
|
|
884
|
+
var DEVICE_FEATURE_STATE_LABELS = {
|
|
885
|
+
working: "Working",
|
|
886
|
+
missing: "None on this board",
|
|
887
|
+
unsupported: "Not supported yet",
|
|
888
|
+
fault: "Not working"
|
|
889
|
+
};
|
|
860
890
|
var DEVICE_VITALS_FIELDS = [
|
|
861
891
|
{
|
|
862
892
|
key: "firmwareVersion",
|
|
@@ -877,11 +907,84 @@ var DEVICE_VITALS_FIELDS = [
|
|
|
877
907
|
source: "register",
|
|
878
908
|
reportedByFirmware: true
|
|
879
909
|
},
|
|
880
|
-
{ key: "resetReason", label: "Last restart", source: "register", reportedByFirmware: true }
|
|
910
|
+
{ key: "resetReason", label: "Last restart", source: "register", reportedByFirmware: true },
|
|
911
|
+
{
|
|
912
|
+
key: "batteryMv",
|
|
913
|
+
label: "Battery line",
|
|
914
|
+
unit: "mV",
|
|
915
|
+
source: "poll",
|
|
916
|
+
reportedByFirmware: true,
|
|
917
|
+
note: "Black (S3) boards only, raw and not yet calibrated. A yellow board cannot measure a battery."
|
|
918
|
+
}
|
|
881
919
|
];
|
|
882
920
|
var DEVICE_FRESH_MS = 7 * 60 * 60 * 1e3;
|
|
883
921
|
var DEVICE_STALE_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
884
922
|
|
|
923
|
+
// src/apps/delivery.ts
|
|
924
|
+
var DeviceIdSchema = z9.string().regex(/^[0-9A-HJKMNP-TV-Z]{8}$/, "eight characters, no I L O or U");
|
|
925
|
+
var PairCodeSchema = z9.string().regex(/^\d{4}$/);
|
|
926
|
+
var DeviceRegistrationSchema = z9.object({
|
|
927
|
+
deviceId: DeviceIdSchema,
|
|
928
|
+
code: PairCodeSchema,
|
|
929
|
+
/** Firmware build, so a support question has an answer. */
|
|
930
|
+
version: z9.string().max(40).optional(),
|
|
931
|
+
/** Which board this is, from Boards.h — the two variants need different firmware. */
|
|
932
|
+
board: z9.string().max(40).optional(),
|
|
933
|
+
/** dBm, always negative. -50 is across the room; -85 is a complaint. */
|
|
934
|
+
rssi: z9.number().int().min(-127).max(0).optional(),
|
|
935
|
+
/** On the owner's own network. Long enough for IPv6, which this does not send yet. */
|
|
936
|
+
ip: z9.string().max(45).optional(),
|
|
937
|
+
/** Seconds since boot. Not growing between check-ins means it is restarting. */
|
|
938
|
+
uptime: z9.number().int().nonnegative().optional(),
|
|
939
|
+
/** Free heap in bytes. */
|
|
940
|
+
heap: z9.number().int().nonnegative().optional(),
|
|
941
|
+
/** The app revision the board has actually drawn. */
|
|
942
|
+
drew: z9.number().int().nonnegative().optional(),
|
|
943
|
+
/** Why it last restarted, already mapped to a word by the firmware. */
|
|
944
|
+
reset: z9.string().max(40).optional(),
|
|
945
|
+
/**
|
|
946
|
+
* What the board has and whether each part works: "speaker: working",
|
|
947
|
+
* "battery: missing". This describes the device — its own hardware, as its
|
|
948
|
+
* own check screen reports it — and never the room: a state, not a reading.
|
|
949
|
+
* What the microphone heard, a sensor's value, or anything a part could
|
|
950
|
+
* learn about its surroundings does not belong here and is not representable
|
|
951
|
+
* (DeviceFeatureStateSchema is four words). Readings, when they come, travel
|
|
952
|
+
* as Signals and are argued for on their own.
|
|
953
|
+
*/
|
|
954
|
+
features: DeviceFeaturesSchema.optional()
|
|
955
|
+
});
|
|
956
|
+
var SendRequestSchema = z9.object({
|
|
957
|
+
deviceId: DeviceIdSchema,
|
|
958
|
+
code: PairCodeSchema
|
|
959
|
+
});
|
|
960
|
+
var OwnedSendRequestSchema = z9.object({
|
|
961
|
+
deviceId: DeviceIdSchema
|
|
962
|
+
});
|
|
963
|
+
var DeliveredAppSchema = z9.object({
|
|
964
|
+
revision: z9.number().int().nonnegative(),
|
|
965
|
+
sentAt: z9.number().int().nonnegative()
|
|
966
|
+
});
|
|
967
|
+
var DeviceRecordSchema = z9.object({
|
|
968
|
+
deviceId: DeviceIdSchema,
|
|
969
|
+
code: PairCodeSchema,
|
|
970
|
+
ownerId: z9.string().nullable().default(null),
|
|
971
|
+
version: z9.string().max(40).optional(),
|
|
972
|
+
createdAt: z9.number().int().nonnegative(),
|
|
973
|
+
lastSeenAt: z9.number().int().nonnegative()
|
|
974
|
+
});
|
|
975
|
+
var DEVICE_LABEL_MAX = 48;
|
|
976
|
+
var DEVICE_TTL_SECONDS = 60 * 60 * 24 * 30;
|
|
977
|
+
var CLAIMED_DEVICE_TTL_SECONDS = 60 * 60 * 24 * 400;
|
|
978
|
+
var FirmwareUpdateSchema = z9.object({
|
|
979
|
+
version: z9.string().min(1).max(40),
|
|
980
|
+
url: z9.string().url().max(200),
|
|
981
|
+
sha256: z9.string().regex(/^[0-9a-f]{64}$/),
|
|
982
|
+
bytes: z9.number().int().positive(),
|
|
983
|
+
requestedAt: z9.number().int().nonnegative()
|
|
984
|
+
});
|
|
985
|
+
var FIRMWARE_UPDATE_PREFIX = "https://www.ramme.io/firmware/weather-display/";
|
|
986
|
+
var FIRMWARE_UPDATE_ATTEMPTS = 3;
|
|
987
|
+
|
|
885
988
|
// src/apps/glyphs.ts
|
|
886
989
|
var DEVICE_UNKNOWN_GLYPH = "?";
|
|
887
990
|
var DEVICE_GLYPHS = {
|
|
@@ -957,6 +1060,7 @@ var DEVICE_GLYPHS = {
|
|
|
957
1060
|
"\u2212": { byte: 45, shows: "-" },
|
|
958
1061
|
"\xA0": { byte: 32, shows: " " }
|
|
959
1062
|
};
|
|
1063
|
+
var DISPLAY_FACE_MIN_PX = 28;
|
|
960
1064
|
var DEVICE_PALETTE = {
|
|
961
1065
|
background: "17 17 17",
|
|
962
1066
|
foreground: "238 238 238",
|
|
@@ -1087,74 +1191,183 @@ var WEATHER_ICONS = {
|
|
|
1087
1191
|
]
|
|
1088
1192
|
};
|
|
1089
1193
|
|
|
1090
|
-
// src/
|
|
1194
|
+
// src/apps/shelf.ts
|
|
1091
1195
|
import { z as z10 } from "zod";
|
|
1092
|
-
var
|
|
1093
|
-
|
|
1094
|
-
|
|
1196
|
+
var SHELF_MAX_APPS = 8;
|
|
1197
|
+
var SHELF_MAX_BYTES = 24e3;
|
|
1198
|
+
var SHELF_ROTATE_MINUTES = [0, 1, 5, 15, 30, 60];
|
|
1199
|
+
var ShelfSchema = z10.object({
|
|
1200
|
+
apps: z10.array(AppDocumentSchema).min(1).max(SHELF_MAX_APPS),
|
|
1201
|
+
/** Which app to show — an index into `apps`. */
|
|
1202
|
+
show: z10.number().int().min(0).max(SHELF_MAX_APPS - 1),
|
|
1203
|
+
/** Move to the next app every this many minutes; 0 holds still. */
|
|
1204
|
+
rotateMinutes: z10.number().int().min(0).max(1440).default(0),
|
|
1205
|
+
/**
|
|
1206
|
+
* When each app was last sent, aligned with `apps`. The server's
|
|
1207
|
+
* bookkeeping, not the board's: a send to a full shelf takes off the app
|
|
1208
|
+
* sent longest ago, so sending always works. Missing reads as oldest.
|
|
1209
|
+
*/
|
|
1210
|
+
added: z10.array(z10.number().int().nonnegative()).max(SHELF_MAX_APPS).optional()
|
|
1211
|
+
});
|
|
1212
|
+
var ShelfEditSchema = z10.discriminatedUnion("op", [
|
|
1213
|
+
z10.object({ op: z10.literal("show"), deviceId: DeviceIdSchema, index: z10.number().int().min(0) }),
|
|
1214
|
+
z10.object({ op: z10.literal("remove"), deviceId: DeviceIdSchema, index: z10.number().int().min(0) }),
|
|
1215
|
+
z10.object({
|
|
1216
|
+
op: z10.literal("move"),
|
|
1217
|
+
deviceId: DeviceIdSchema,
|
|
1218
|
+
from: z10.number().int().min(0),
|
|
1219
|
+
to: z10.number().int().min(0)
|
|
1220
|
+
}),
|
|
1221
|
+
z10.object({ op: z10.literal("rotate"), deviceId: DeviceIdSchema, minutes: z10.number().int().min(0).max(1440) }),
|
|
1222
|
+
/**
|
|
1223
|
+
* Swap the panel's light and dark. Not about apps, but it rides the same
|
|
1224
|
+
* route and the same poll: some units of the same board carry a panel wired
|
|
1225
|
+
* the other way, so one shows white on black and its twin black on white
|
|
1226
|
+
* from identical firmware. It is a fact about one board's glass, so it is a
|
|
1227
|
+
* per-board setting rather than a build.
|
|
1228
|
+
*/
|
|
1229
|
+
z10.object({ op: z10.literal("screen"), deviceId: DeviceIdSchema, invert: z10.boolean() }),
|
|
1230
|
+
/**
|
|
1231
|
+
* Remove one entry from the list of apps sent to this board, by the revision
|
|
1232
|
+
* it was sent as. The record only: what the board holds is the shelf's
|
|
1233
|
+
* business, and `remove` above is how an app comes off it.
|
|
1234
|
+
*/
|
|
1235
|
+
z10.object({ op: z10.literal("forget"), deviceId: DeviceIdSchema, revision: z10.number().int().min(1) })
|
|
1236
|
+
]);
|
|
1237
|
+
|
|
1238
|
+
// src/apps/protocol.ts
|
|
1239
|
+
import { z as z12 } from "zod";
|
|
1240
|
+
|
|
1241
|
+
// src/theme/account.ts
|
|
1242
|
+
import { z as z11 } from "zod";
|
|
1243
|
+
var ThemeRgbSchema = z11.string().regex(/^\d{1,3} \d{1,3} \d{1,3}$/, 'Must be "R G B", e.g. "13 110 253"').refine((v) => v.split(" ").every((n) => Number(n) <= 255), "Each channel is 0\u2013255");
|
|
1244
|
+
var ThemePaletteSchema = z11.object({
|
|
1245
|
+
background: ThemeRgbSchema,
|
|
1246
|
+
/** Text. */
|
|
1247
|
+
foreground: ThemeRgbSchema,
|
|
1248
|
+
/** Quieter text: labels, captions, the second line. */
|
|
1249
|
+
muted: ThemeRgbSchema,
|
|
1250
|
+
/** The brand colour: buttons and links on the site, highlights on a board. */
|
|
1251
|
+
accent: ThemeRgbSchema,
|
|
1252
|
+
success: ThemeRgbSchema,
|
|
1253
|
+
warning: ThemeRgbSchema,
|
|
1254
|
+
danger: ThemeRgbSchema
|
|
1255
|
+
});
|
|
1256
|
+
var THEME_PALETTE_TOKENS = [
|
|
1257
|
+
"background",
|
|
1258
|
+
"foreground",
|
|
1259
|
+
"muted",
|
|
1260
|
+
"accent",
|
|
1261
|
+
"success",
|
|
1262
|
+
"warning",
|
|
1263
|
+
"danger"
|
|
1264
|
+
];
|
|
1265
|
+
var ThemeLetteringSchema = z11.enum(["inter", "tay", "pixel"]);
|
|
1266
|
+
var THEME_RADII = ["0rem", "0.25rem", "0.5rem", "0.75rem", "1rem"];
|
|
1267
|
+
var AccountThemeSchema = z11.object({
|
|
1268
|
+
name: z11.string().trim().min(1).max(40),
|
|
1269
|
+
/** The preset it started from, when it started from one. */
|
|
1270
|
+
base: z11.string().max(40).optional(),
|
|
1271
|
+
light: ThemePaletteSchema,
|
|
1272
|
+
dark: ThemePaletteSchema,
|
|
1273
|
+
lettering: ThemeLetteringSchema,
|
|
1274
|
+
radius: z11.enum(THEME_RADII)
|
|
1275
|
+
});
|
|
1276
|
+
|
|
1277
|
+
// src/apps/protocol.ts
|
|
1278
|
+
var DEVICE_PROTOCOL = {
|
|
1279
|
+
/** POST `DeviceRegistration` → 200. On boot and every six hours. */
|
|
1280
|
+
register: { method: "POST", path: "/api/device/register" },
|
|
1281
|
+
/**
|
|
1282
|
+
* GET `?id=&since=<revision>` plus what the board says about itself
|
|
1283
|
+
* (`DEVICE_POLL_QUERY`) → 200 `DevicePollReply`, 304 when nothing is newer
|
|
1284
|
+
* than `since`, 204 when nothing has ever been sent.
|
|
1285
|
+
*/
|
|
1286
|
+
poll: { method: "GET", path: "/api/device/app" },
|
|
1287
|
+
/** POST `DeviceReport` → 202. Only while the board has readings to give. */
|
|
1288
|
+
report: { method: "POST", path: "/api/device/report" },
|
|
1289
|
+
/**
|
|
1290
|
+
* GET `?id=&hash=<sha256>` → 200 raw bytes, 404 for anything it may not
|
|
1291
|
+
* have. Only a hash an app on the board names; the board keeps the file.
|
|
1292
|
+
*/
|
|
1293
|
+
photo: { method: "GET", path: "/api/device/photo" },
|
|
1294
|
+
/**
|
|
1295
|
+
* POST `?id=` with a clip (`DEVICE_VOICE_CLIP`) as the raw body → 200
|
|
1296
|
+
* `DeviceVoiceReply`. Only while the talk button is held: a board never
|
|
1297
|
+
* listens on its own. 501 means this server has no transcriber, which a
|
|
1298
|
+
* board shows as "voice is off here" rather than an error; 403 that this
|
|
1299
|
+
* board may not use it; 413 a clip over the limit.
|
|
1300
|
+
*
|
|
1301
|
+
* Which machine turns speech into text is the server's business, not the
|
|
1302
|
+
* board's (docs/superpowers/specs/ramme-lab.md, "Voice"): a home server runs
|
|
1303
|
+
* a local model, ramme.io a metered cloud one. The board sends the same clip
|
|
1304
|
+
* to either.
|
|
1305
|
+
*/
|
|
1306
|
+
voice: { method: "POST", path: "/api/device/voice" }
|
|
1307
|
+
};
|
|
1308
|
+
var DEVICE_VOICE_CLIP = {
|
|
1309
|
+
contentType: "audio/wav",
|
|
1310
|
+
sampleRate: 16e3,
|
|
1311
|
+
bitsPerSample: 16,
|
|
1312
|
+
channels: 1,
|
|
1313
|
+
maxSeconds: 15,
|
|
1314
|
+
/** The 44-byte header plus fifteen seconds of samples. */
|
|
1315
|
+
maxBytes: 44 + 16e3 * 2 * 15
|
|
1316
|
+
};
|
|
1317
|
+
var DeviceVoiceReplySchema = z12.object({
|
|
1318
|
+
text: z12.string().max(2e3)
|
|
1319
|
+
});
|
|
1320
|
+
var DEVICE_POLL_QUERY = {
|
|
1321
|
+
id: "the board id (required)",
|
|
1322
|
+
since: "the revision on the glass now",
|
|
1323
|
+
v: "the firmware version it runs",
|
|
1324
|
+
ph: 'photos held / photos wanted, as "3/4"',
|
|
1325
|
+
sh: '"1" when it can hold a shelf of apps rather than one',
|
|
1326
|
+
inv: 'its light/dark panel setting, "0" or "1"',
|
|
1327
|
+
rot: "which way it stands, 0\u20133",
|
|
1328
|
+
pl: "the palette it draws in, as 42 hex digits",
|
|
1329
|
+
fn: "the lettering it draws in",
|
|
1330
|
+
bt: "battery millivolts",
|
|
1331
|
+
u: "what happened to the last update it was asked to install"
|
|
1332
|
+
};
|
|
1333
|
+
var BoardPaletteHexSchema = z12.string().regex(/^[0-9a-f]{42}$/);
|
|
1334
|
+
var BoardFontSchema = z12.union([z12.literal("auto"), ThemeLetteringSchema]);
|
|
1335
|
+
var DevicePollReplySchema = z12.object({
|
|
1336
|
+
revision: z12.number().int().nonnegative(),
|
|
1337
|
+
sentAt: z12.number().int().nonnegative().optional(),
|
|
1338
|
+
document: AppDocumentSchema.optional(),
|
|
1339
|
+
shelf: ShelfSchema.optional(),
|
|
1340
|
+
update: FirmwareUpdateSchema.optional(),
|
|
1341
|
+
screen: z12.object({ invert: z12.boolean() }).optional(),
|
|
1342
|
+
palette: BoardPaletteHexSchema.optional(),
|
|
1343
|
+
font: BoardFontSchema.optional()
|
|
1344
|
+
});
|
|
1345
|
+
|
|
1346
|
+
// src/apps/deviceFonts.generated.ts
|
|
1347
|
+
var SMOOTH_FACES = { "inter": { "family": "Inter", "weight": 500, "caps": false }, "tay": { "family": "TAY Dreamboat", "weight": 400, "caps": true } };
|
|
1348
|
+
var SMOOTH_FONT_ADVANCES = { "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, "\xA0": 3, "\xA1": 3, "\xA2": 6, "\xA3": 6, "\xA5": 6, "\xAA": 5, "\xAB": 6, "\xAC": 7, "\xB0": 5, "\xB1": 7, "\xB2": 4, "\xB5": 6, "\xB7": 3, "\xBA": 5, "\xBB": 6, "\xBC": 8, "\xBD": 9, "\xBF": 5, "\xC4": 7, "\xC5": 7, "\xC6": 10, "\xC7": 7, "\xC9": 6, "\xD1": 8, "\xD6": 8, "\xDC": 7, "\xDF": 6, "\xE0": 6, "\xE1": 6, "\xE2": 6, "\xE4": 6, "\xE5": 6, "\xE6": 9, "\xE7": 6, "\xE8": 6, "\xE9": 6, "\xEA": 6, "\xEB": 6, "\xEC": 3, "\xED": 3, "\xEE": 3, "\xEF": 3, "\xF1": 6, "\xF2": 6, "\xF3": 6, "\xF4": 6, "\xF6": 6, "\xF7": 7, "\xF9": 6, "\xFA": 6, "\xFB": 6, "\xFC": 6, "\xFF": 6, "\u0192": 5, "\u03A9": 8, "\u03C0": 5, "\u2013": 5, "\u2014": 10, "\u2018": 3, "\u2019": 3, "\u201C": 5, "\u201D": 5, "\u2212": 7, "\u221A": 5, "\u221E": 7, "\u2248": 5, "\u2264": 5, "\u2265": 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, "\xA0": 3, "\xA1": 4, "\xA2": 7, "\xA3": 7, "\xA5": 7, "\xAA": 5, "\xAB": 7, "\xAC": 8, "\xB0": 5, "\xB1": 8, "\xB2": 5, "\xB5": 7, "\xB7": 4, "\xBA": 6, "\xBB": 7, "\xBC": 10, "\xBD": 10, "\xBF": 6, "\xC4": 9, "\xC5": 9, "\xC6": 12, "\xC7": 9, "\xC9": 7, "\xD1": 9, "\xD6": 9, "\xDC": 9, "\xDF": 8, "\xE0": 7, "\xE1": 7, "\xE2": 7, "\xE4": 7, "\xE5": 7, "\xE6": 11, "\xE7": 7, "\xE8": 7, "\xE9": 7, "\xEA": 7, "\xEB": 7, "\xEC": 3, "\xED": 3, "\xEE": 3, "\xEF": 3, "\xF1": 7, "\xF2": 7, "\xF3": 7, "\xF4": 7, "\xF6": 7, "\xF7": 8, "\xF9": 7, "\xFA": 7, "\xFB": 7, "\xFC": 7, "\xFF": 7, "\u0192": 6, "\u03A9": 9, "\u03C0": 7, "\u2013": 6, "\u2014": 12, "\u2018": 3, "\u2019": 3, "\u201C": 6, "\u201D": 6, "\u2212": 8, "\u221A": 7, "\u221E": 9, "\u2248": 7, "\u2264": 7, "\u2265": 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, "\xA0": 4, "\xA1": 5, "\xA2": 9, "\xA3": 10, "\xA5": 9, "\xAA": 7, "\xAB": 10, "\xAC": 11, "\xB0": 7, "\xB1": 11, "\xB2": 7, "\xB5": 10, "\xB7": 5, "\xBA": 8, "\xBB": 10, "\xBC": 13, "\xBD": 14, "\xBF": 8, "\xC4": 11, "\xC5": 11, "\xC6": 16, "\xC7": 12, "\xC9": 10, "\xD1": 12, "\xD6": 12, "\xDC": 12, "\xDF": 10, "\xE0": 9, "\xE1": 9, "\xE2": 9, "\xE4": 9, "\xE5": 9, "\xE6": 15, "\xE7": 9, "\xE8": 9, "\xE9": 9, "\xEA": 9, "\xEB": 9, "\xEC": 4, "\xED": 4, "\xEE": 4, "\xEF": 4, "\xF1": 10, "\xF2": 10, "\xF3": 10, "\xF4": 10, "\xF6": 10, "\xF7": 11, "\xF9": 10, "\xFA": 10, "\xFB": 10, "\xFC": 10, "\xFF": 9, "\u0192": 8, "\u03A9": 12, "\u03C0": 9, "\u2013": 8, "\u2014": 16, "\u2018": 4, "\u2019": 4, "\u201C": 8, "\u201D": 8, "\u2212": 11, "\u221A": 9, "\u221E": 11, "\u2248": 9, "\u2264": 9, "\u2265": 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, "\xA0": 5, "\xA1": 6, "\xA2": 12, "\xA3": 12, "\xA5": 11, "\xAA": 9, "\xAB": 12, "\xAC": 13, "\xB0": 9, "\xB1": 13, "\xB2": 9, "\xB5": 12, "\xB7": 6, "\xBA": 10, "\xBB": 12, "\xBC": 16, "\xBD": 17, "\xBF": 11, "\xC4": 14, "\xC5": 14, "\xC6": 20, "\xC7": 15, "\xC9": 12, "\xD1": 15, "\xD6": 15, "\xDC": 15, "\xDF": 13, "\xE0": 11, "\xE1": 11, "\xE2": 11, "\xE4": 11, "\xE5": 11, "\xE6": 18, "\xE7": 12, "\xE8": 12, "\xE9": 12, "\xEA": 12, "\xEB": 12, "\xEC": 5, "\xED": 5, "\xEE": 5, "\xEF": 5, "\xF1": 12, "\xF2": 12, "\xF3": 12, "\xF4": 12, "\xF6": 12, "\xF7": 13, "\xF9": 12, "\xFA": 12, "\xFB": 12, "\xFC": 12, "\xFF": 12, "\u0192": 10, "\u03A9": 15, "\u03C0": 11, "\u2013": 10, "\u2014": 20, "\u2018": 6, "\u2019": 6, "\u201C": 9, "\u201D": 9, "\u2212": 13, "\u221A": 11, "\u221E": 14, "\u2248": 11, "\u2264": 11, "\u2265": 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, "\xA0": 7, "\xA1": 9, "\xA2": 16, "\xA3": 17, "\xA5": 16, "\xAA": 13, "\xAB": 17, "\xAC": 19, "\xB0": 13, "\xB1": 19, "\xB2": 13, "\xB5": 17, "\xB7": 8, "\xBA": 14, "\xBB": 17, "\xBC": 23, "\xBD": 24, "\xBF": 15, "\xC4": 20, "\xC5": 20, "\xC6": 28, "\xC7": 21, "\xC9": 17, "\xD1": 21, "\xD6": 21, "\xDC": 21, "\xDF": 18, "\xE0": 16, "\xE1": 16, "\xE2": 16, "\xE4": 16, "\xE5": 16, "\xE6": 26, "\xE7": 16, "\xE8": 16, "\xE9": 16, "\xEA": 16, "\xEB": 16, "\xEC": 7, "\xED": 7, "\xEE": 7, "\xEF": 7, "\xF1": 17, "\xF2": 17, "\xF3": 17, "\xF4": 17, "\xF6": 17, "\xF7": 19, "\xF9": 17, "\xFA": 17, "\xFB": 17, "\xFC": 17, "\xFF": 16, "\u0192": 14, "\u03A9": 22, "\u03C0": 15, "\u2013": 14, "\u2014": 28, "\u2018": 8, "\u2019": 8, "\u201C": 13, "\u201D": 13, "\u2212": 19, "\u221A": 15, "\u221E": 20, "\u2248": 15, "\u2264": 15, "\u2265": 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, "\xB0": 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, "\xA0": 8, "\xA1": 15, "\xA2": 14, "\xA3": 26, "\xA5": 31, "\xAA": 8, "\xAB": 14, "\xAC": 16, "\xB0": 14, "\xB1": 15, "\xB2": 8, "\xB7": 7, "\xBA": 9, "\xBB": 14, "\xBC": 21, "\xBD": 21, "\xBF": 26, "\xC4": 28, "\xC5": 28, "\xC6": 25, "\xC7": 28, "\xC9": 30, "\xD1": 32, "\xD6": 29, "\xDC": 29, "\xF7": 15, "\u03A9": 22, "\u2013": 14, "\u2014": 28, "\u2018": 9, "\u2019": 9, "\u201C": 12, "\u201D": 12, "\u2212": 16, "\u221A": 15, "\u221E": 20, "\u2248": 15, "\u2264": 15, "\u2265": 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, "\xB0": 27 } } };
|
|
1349
|
+
|
|
1350
|
+
// src/ai/tools.ts
|
|
1351
|
+
import { z as z13 } from "zod";
|
|
1352
|
+
var telemetryGraphParameters = z13.object({
|
|
1353
|
+
deviceId: z13.string().min(1, "Device ID is required"),
|
|
1354
|
+
timeRange: z13.enum(["1h", "24h", "7d"], {
|
|
1095
1355
|
errorMap: () => ({ message: "Time range must be 1h, 24h, or 7d" })
|
|
1096
1356
|
}),
|
|
1097
|
-
metrics:
|
|
1098
|
-
|
|
1357
|
+
metrics: z13.array(
|
|
1358
|
+
z13.enum(["temperature", "humidity", "vwc", "ec", "ph", "pressure", "co2"])
|
|
1099
1359
|
).min(1, "At least one metric is required").max(4, "Maximum 4 metrics per graph")
|
|
1100
1360
|
});
|
|
1101
|
-
var stockChartParameters = z10.object({
|
|
1102
|
-
ticker: z10.string().min(1).describe("The stock ticker symbol explicitly requested by the user. YOU MUST EXTRACT AND PROVIDE THIS (e.g., 'AAPL', 'MSFT')."),
|
|
1103
|
-
timeRange: z10.enum(["1D", "1W", "1M", "1Y"], {
|
|
1104
|
-
errorMap: () => ({ message: "Time range must be 1D, 1W, 1M, or 1Y" })
|
|
1105
|
-
}).describe("The time range for the chart. Choose based on user request or default to '1M'."),
|
|
1106
|
-
metrics: z10.array(z10.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.")
|
|
1107
|
-
});
|
|
1108
|
-
var tickerParam = z10.string().min(1).describe("The stock ticker symbol (e.g., 'AAPL', 'TSLA', 'MSFT').");
|
|
1109
|
-
var liveQuoteParameters = z10.object({ ticker: tickerParam });
|
|
1110
|
-
var companyNewsParameters = z10.object({ ticker: tickerParam });
|
|
1111
|
-
var companyProfileParameters = z10.object({ ticker: tickerParam });
|
|
1112
|
-
var counterpartyGraphParameters = z10.object({
|
|
1113
|
-
ticker: tickerParam,
|
|
1114
|
-
hops: z10.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.")
|
|
1115
|
-
});
|
|
1116
|
-
var divergenceMetricsParameters = z10.object({ ticker: tickerParam });
|
|
1117
|
-
var architectureReferenceParameters = z10.object({});
|
|
1118
1361
|
var AI_TOOLS = {
|
|
1119
1362
|
get_telemetry_graph: {
|
|
1120
1363
|
name: "get_telemetry_graph",
|
|
1121
1364
|
description: "Displays an interactive line chart of historical sensor telemetry data. Use this when the user asks to visualize trends, compare metrics over time, or analyze device performance. Supports temperature, humidity, VWC (volumetric water content), EC (electrical conductivity), pH, pressure, and CO2.",
|
|
1122
|
-
parameters: telemetryGraphParameters
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
},
|
|
1129
|
-
get_live_quote: {
|
|
1130
|
-
name: "get_live_quote",
|
|
1131
|
-
description: "Fetches and displays the real-time stock price and daily change percentage for a given company ticker symbol.",
|
|
1132
|
-
parameters: liveQuoteParameters
|
|
1133
|
-
},
|
|
1134
|
-
get_company_news: {
|
|
1135
|
-
name: "get_company_news",
|
|
1136
|
-
description: "Fetches and displays the 5 most recent news headlines and sentiment impact scores for a given company ticker symbol.",
|
|
1137
|
-
parameters: companyNewsParameters
|
|
1138
|
-
},
|
|
1139
|
-
get_company_profile: {
|
|
1140
|
-
name: "get_company_profile",
|
|
1141
|
-
description: "Fetches fundamental company data including the business description, sector, industry, market cap, and P/E ratio.",
|
|
1142
|
-
parameters: companyProfileParameters
|
|
1143
|
-
},
|
|
1144
|
-
get_counterparty_graph: {
|
|
1145
|
-
name: "get_counterparty_graph",
|
|
1146
|
-
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.",
|
|
1147
|
-
parameters: counterpartyGraphParameters
|
|
1148
|
-
},
|
|
1149
|
-
get_divergence_metrics: {
|
|
1150
|
-
name: "get_divergence_metrics",
|
|
1151
|
-
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.",
|
|
1152
|
-
parameters: divergenceMetricsParameters
|
|
1153
|
-
},
|
|
1154
|
-
get_architecture_reference: {
|
|
1155
|
-
name: "get_architecture_reference",
|
|
1156
|
-
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.",
|
|
1157
|
-
parameters: architectureReferenceParameters
|
|
1365
|
+
parameters: telemetryGraphParameters,
|
|
1366
|
+
promptParameters: `{
|
|
1367
|
+
"deviceId": "string (required)",
|
|
1368
|
+
"timeRange": "enum: '1h' | '24h' | '7d' (required)",
|
|
1369
|
+
"metrics": "array of enum: 'temperature' | 'humidity' | 'vwc' | 'ec' | 'ph' | 'pressure' | 'co2' (1-4 items required)"
|
|
1370
|
+
}`
|
|
1158
1371
|
}
|
|
1159
1372
|
};
|
|
1160
1373
|
|
|
@@ -1386,6 +1599,9 @@ A row splits the width into equal cells. Add "pack": true and each child takes
|
|
|
1386
1599
|
only its own width, "gap" apart \u2014 a number with its icon right beside it, or
|
|
1387
1600
|
"H 68\xB0 L 56\xB0" as one line. Put "valign": "center" at the top level of the
|
|
1388
1601
|
document to centre the blocks on the screen rather than start at the top, and
|
|
1602
|
+
"font": "pixel" for chunky retro lettering or "font": "tay" for the Ramme
|
|
1603
|
+
display face, all capitals, good for signs and big numbers (the default is a
|
|
1604
|
+
smooth plain face), and
|
|
1389
1605
|
"halign": "center" to centre them across it \u2014 the lines keep their own
|
|
1390
1606
|
alignment inside a column as wide as the widest, and the column is centred.
|
|
1391
1607
|
|
|
@@ -1487,6 +1703,14 @@ SOURCES \u2014 declare what the app reads, then bind to it by name:
|
|
|
1487
1703
|
For things that take turns: give each block "hideWhen": { "value":
|
|
1488
1704
|
{ "source": "turn", "field": "index" }, "op": "!=", "than": N } so only
|
|
1489
1705
|
block N shows on turn N. The board changes at most once a minute.
|
|
1706
|
+
"probe": { "kind": "board", "units": "imperial" }
|
|
1707
|
+
fields: temperature, connected
|
|
1708
|
+
What a sensor plugged into the board itself is reading: a temperature
|
|
1709
|
+
probe's temperature, a whole number in units, updated about once a
|
|
1710
|
+
second. connected is false when nothing is plugged in, and temperature
|
|
1711
|
+
is then missing (it draws "--"): use hideWhen on connected to show
|
|
1712
|
+
"Plug in the probe" instead. Use this, not weather, for "my sensor",
|
|
1713
|
+
"the probe", "water temperature" and the like.
|
|
1490
1714
|
|
|
1491
1715
|
RULES
|
|
1492
1716
|
|
|
@@ -1506,12 +1730,12 @@ RULES
|
|
|
1506
1730
|
var APP_DOCUMENT_EDIT_PREFIX = "Here is the current app. Change only what is asked:";
|
|
1507
1731
|
|
|
1508
1732
|
// src/theme/schema.ts
|
|
1509
|
-
import { z as
|
|
1510
|
-
var RGBString =
|
|
1733
|
+
import { z as z14 } from "zod";
|
|
1734
|
+
var RGBString = z14.string().regex(
|
|
1511
1735
|
/^\d{1,3}\s+\d{1,3}\s+\d{1,3}$/,
|
|
1512
1736
|
'Must be space-separated RGB integers (e.g. "13 110 253")'
|
|
1513
1737
|
);
|
|
1514
|
-
var ThemeOverridesSchema =
|
|
1738
|
+
var ThemeOverridesSchema = z14.object({
|
|
1515
1739
|
// ── Core Brand ───────────────────────────────────────────────────────────
|
|
1516
1740
|
"--app-primary-color": RGBString.optional(),
|
|
1517
1741
|
"--app-primary-foreground-color": RGBString.optional(),
|
|
@@ -1527,9 +1751,9 @@ var ThemeOverridesSchema = z11.object({
|
|
|
1527
1751
|
"--app-muted-bg": RGBString.optional(),
|
|
1528
1752
|
"--app-muted-text": RGBString.optional(),
|
|
1529
1753
|
// ── Shape ────────────────────────────────────────────────────────────────
|
|
1530
|
-
"--app-border-radius-sm":
|
|
1531
|
-
"--app-border-radius-md":
|
|
1532
|
-
"--app-border-radius-lg":
|
|
1754
|
+
"--app-border-radius-sm": z14.string().optional(),
|
|
1755
|
+
"--app-border-radius-md": z14.string().optional(),
|
|
1756
|
+
"--app-border-radius-lg": z14.string().optional(),
|
|
1533
1757
|
// ── Form Controls ────────────────────────────────────────────────────────
|
|
1534
1758
|
"--app-input-bg-color": RGBString.optional(),
|
|
1535
1759
|
"--app-input-text-color": RGBString.optional(),
|
|
@@ -1543,19 +1767,19 @@ var ThemeOverridesSchema = z11.object({
|
|
|
1543
1767
|
"--app-chart-4": RGBString.optional(),
|
|
1544
1768
|
"--app-chart-5": RGBString.optional()
|
|
1545
1769
|
}).strict();
|
|
1546
|
-
var ThemeFontsSchema =
|
|
1770
|
+
var ThemeFontsSchema = z14.object({
|
|
1547
1771
|
/** Google Font name for headings (h1–h4, .font-serif). Example: "Playfair Display" */
|
|
1548
|
-
heading:
|
|
1772
|
+
heading: z14.string(),
|
|
1549
1773
|
/** Google Font name for body text. Example: "Inter" */
|
|
1550
|
-
body:
|
|
1774
|
+
body: z14.string(),
|
|
1551
1775
|
/** Optional monospace font. Example: "Roboto Mono" */
|
|
1552
|
-
mono:
|
|
1776
|
+
mono: z14.string().optional()
|
|
1553
1777
|
});
|
|
1554
|
-
var AIThemeSchema =
|
|
1778
|
+
var AIThemeSchema = z14.object({
|
|
1555
1779
|
/** Short descriptive theme name. Example: "Midnight Garden" */
|
|
1556
|
-
name:
|
|
1780
|
+
name: z14.string(),
|
|
1557
1781
|
/** One-sentence vibe description. Example: "Dark indigo with golden accents." */
|
|
1558
|
-
description:
|
|
1782
|
+
description: z14.string(),
|
|
1559
1783
|
/** Google Font pairing for heading and body text. */
|
|
1560
1784
|
fonts: ThemeFontsSchema.optional(),
|
|
1561
1785
|
/**
|
|
@@ -1566,13 +1790,13 @@ var AIThemeSchema = z11.object({
|
|
|
1566
1790
|
cssVars: ThemeOverridesSchema
|
|
1567
1791
|
});
|
|
1568
1792
|
var THEME_PRESETS = ["light", "dark", "system", "corporate", "midnight", "blueprint"];
|
|
1569
|
-
var ThemeTokensSchema =
|
|
1793
|
+
var ThemeTokensSchema = z14.object({
|
|
1570
1794
|
primary: RGBString,
|
|
1571
1795
|
neutral: RGBString,
|
|
1572
1796
|
success: RGBString,
|
|
1573
1797
|
warning: RGBString,
|
|
1574
1798
|
destructive: RGBString,
|
|
1575
|
-
radius:
|
|
1799
|
+
radius: z14.enum(["none", "sm", "md", "lg", "full"])
|
|
1576
1800
|
});
|
|
1577
1801
|
var DEFAULT_THEME_TOKENS = {
|
|
1578
1802
|
primary: "13 110 253",
|
|
@@ -1583,82 +1807,355 @@ var DEFAULT_THEME_TOKENS = {
|
|
|
1583
1807
|
radius: "md"
|
|
1584
1808
|
};
|
|
1585
1809
|
|
|
1810
|
+
// src/theme/controls.ts
|
|
1811
|
+
var CONTROL_STATES = ["rest", "pressed", "busy", "disabled", "focused"];
|
|
1812
|
+
var CONTROL_STATE_MEANINGS = {
|
|
1813
|
+
rest: { means: "The control, in the theme\u2019s surface or accent.", web: "default" },
|
|
1814
|
+
pressed: { means: "Lit the moment a finger lands on it.", web: ":active" },
|
|
1815
|
+
busy: { means: "Stays lit while its action runs; nothing else on screen moves.", web: "loading" },
|
|
1816
|
+
disabled: { means: "Muted, and a tap does nothing.", web: "disabled" },
|
|
1817
|
+
focused: { means: "Highlighted by a knob or a key: the control choosing would press.", web: ":focus-visible" }
|
|
1818
|
+
};
|
|
1819
|
+
|
|
1820
|
+
// src/enclosures/schema.ts
|
|
1821
|
+
import { z as z15 } from "zod";
|
|
1822
|
+
var Mm = z15.number().finite();
|
|
1823
|
+
var PositiveMm = Mm.positive();
|
|
1824
|
+
var NonNegativeMm = Mm.nonnegative();
|
|
1825
|
+
var PrinterProfileSchema = z15.object({
|
|
1826
|
+
name: z15.string().min(1).default("Bambu Lab X1 Carbon"),
|
|
1827
|
+
/** Walls are whole multiples of this. */
|
|
1828
|
+
nozzle: PositiveMm.default(0.4),
|
|
1829
|
+
/** Gap for parts that slide together: the case's lip, a lid. */
|
|
1830
|
+
clearance_slip: NonNegativeMm.default(0.2),
|
|
1831
|
+
/** Gap for a friction fit. */
|
|
1832
|
+
clearance_press: NonNegativeMm.default(0.1)
|
|
1833
|
+
});
|
|
1834
|
+
var EdgeSchema = z15.enum(["east", "west", "north", "south", "top", "bottom"]);
|
|
1835
|
+
var FlexButtonSchema = z15.object({
|
|
1836
|
+
/** The tongue's length, from its free end to where it joins the floor. */
|
|
1837
|
+
length: PositiveMm.default(12),
|
|
1838
|
+
/** Its width. */
|
|
1839
|
+
width: PositiveMm.default(5),
|
|
1840
|
+
/** The way from the switch to where the tongue joins the floor. */
|
|
1841
|
+
hinge: z15.enum(["east", "west", "north", "south"])
|
|
1842
|
+
});
|
|
1843
|
+
var InterfaceSchema = z15.object({
|
|
1844
|
+
/** usb_c, screen, reset_button, status_led, sd_card… */
|
|
1845
|
+
name: z15.string().min(1),
|
|
1846
|
+
edge: EdgeSchema,
|
|
1847
|
+
/** From the centre of that face — see COORDINATES above. */
|
|
1848
|
+
offset_from_center: z15.tuple([Mm, Mm]).default([0, 0]),
|
|
1849
|
+
/**
|
|
1850
|
+
* A grille is a field of small round holes filling an ellipse of
|
|
1851
|
+
* `cutout_size` — a speaker's — on a top or bottom face only.
|
|
1852
|
+
*/
|
|
1853
|
+
cutout_shape: z15.enum(["rect", "rounded_rect", "circle", "grille"]),
|
|
1854
|
+
/** [width, height] of the opening, including room for a plug's boot. A circle uses the first as its diameter. */
|
|
1855
|
+
cutout_size: z15.tuple([PositiveMm, PositiveMm]),
|
|
1856
|
+
/** How far the part sticks out past the component's edge. */
|
|
1857
|
+
protrusion: NonNegativeMm.default(0),
|
|
1858
|
+
/** A wider recess on the outside face, [width, height, depth], for a thick cable boot. */
|
|
1859
|
+
outer_recess: z15.tuple([PositiveMm, PositiveMm, PositiveMm]).optional(),
|
|
1860
|
+
/** Press it through the floor instead of opening a hole — see FlexButtonSchema. */
|
|
1861
|
+
flex_button: FlexButtonSchema.optional(),
|
|
1862
|
+
/**
|
|
1863
|
+
* A 45° ramp this deep round the opening at the outside face, widening it
|
|
1864
|
+
* by this much a side there. For a screen set back behind a bezel: the
|
|
1865
|
+
* picture's edges stay in view and a fingertip reaches them. Top or bottom
|
|
1866
|
+
* openings only.
|
|
1867
|
+
*/
|
|
1868
|
+
chamfer: NonNegativeMm.optional()
|
|
1869
|
+
});
|
|
1870
|
+
var MountHolesSchema = z15.object({
|
|
1871
|
+
/** Four holes, this far in from each corner: [east-west, north-south]. */
|
|
1872
|
+
inset_from_corners: z15.tuple([PositiveMm, PositiveMm]).optional(),
|
|
1873
|
+
/** Or exactly where they are: [east, north] from the footprint centre. */
|
|
1874
|
+
positions: z15.array(z15.tuple([Mm, Mm])).min(1).optional(),
|
|
1875
|
+
thread: z15.enum(["M2", "M2.5", "M3"]),
|
|
1876
|
+
/** Heat-set insert outer diameter and depth. split_shell_lip only: tray_bezel's screws cut their own thread. */
|
|
1877
|
+
insert_od: PositiveMm.optional(),
|
|
1878
|
+
insert_depth: PositiveMm.optional()
|
|
1879
|
+
}).refine((m) => (m.inset_from_corners ? 1 : 0) + (m.positions ? 1 : 0) === 1, {
|
|
1880
|
+
message: "give either inset_from_corners or positions, not both or neither"
|
|
1881
|
+
});
|
|
1882
|
+
var PlacementSchema = z15.object({
|
|
1883
|
+
relative_to: z15.string().min(1),
|
|
1884
|
+
where: z15.enum(["below", "above", "east", "west", "north", "south"]),
|
|
1885
|
+
/** Space between the two keep-outs. */
|
|
1886
|
+
gap: NonNegativeMm.default(1),
|
|
1887
|
+
/** Moved this far [east, north] from centred on the other, once placed. */
|
|
1888
|
+
offset: z15.tuple([Mm, Mm]).default([0, 0])
|
|
1889
|
+
});
|
|
1890
|
+
var ComponentSchema = z15.object({
|
|
1891
|
+
id: z15.string().regex(/^[a-z][a-z0-9_]*$/, "lowercase letters, digits and underscores"),
|
|
1892
|
+
type: z15.enum(["pcb", "display", "battery", "speaker", "module"]),
|
|
1893
|
+
/** [east, north, up] — see COORDINATES. */
|
|
1894
|
+
dimensions: z15.tuple([PositiveMm, PositiveMm, PositiveMm]),
|
|
1895
|
+
/**
|
|
1896
|
+
* Radius of the footprint's corners: most boards are rounded. The case's
|
|
1897
|
+
* inside corners follow it, so a rounded board gets a rounded tray without
|
|
1898
|
+
* the tray growing wider. Leave it at 0 for a square one, or when unsure —
|
|
1899
|
+
* assuming sharper than the part is safe, rounder is not.
|
|
1900
|
+
*/
|
|
1901
|
+
corner_radius: NonNegativeMm.default(0),
|
|
1902
|
+
/** Height of the tallest part on top (headers, capacitors, a connector), kept clear. */
|
|
1903
|
+
clearance_z_top: NonNegativeMm.default(0),
|
|
1904
|
+
/** Height of what is underneath (solder joints, a microSD socket), kept clear. */
|
|
1905
|
+
clearance_z_bottom: NonNegativeMm.default(0),
|
|
1906
|
+
/** Quarter turns about Z, applied before placement. */
|
|
1907
|
+
rotation: z15.union([z15.literal(0), z15.literal(90), z15.literal(180), z15.literal(270)]).default(0),
|
|
1908
|
+
placement: PlacementSchema.optional(),
|
|
1909
|
+
mount_holes: MountHolesSchema.optional(),
|
|
1910
|
+
interfaces: z15.array(InterfaceSchema).default([]),
|
|
1911
|
+
/** How it is held if it has no screw holes. */
|
|
1912
|
+
retention: z15.enum(["none", "cradle_ribs"]).default("none")
|
|
1913
|
+
});
|
|
1914
|
+
var EmblemSchema = z15.object({
|
|
1915
|
+
/** The SVG file, relative to the manifest. Filled paths only; strokes are ignored. */
|
|
1916
|
+
svg: z15.string().min(1),
|
|
1917
|
+
face: z15.enum(["top", "bottom"]).default("bottom"),
|
|
1918
|
+
/** Height of the mark on the face, along north. Its width follows the SVG's proportions. */
|
|
1919
|
+
height: PositiveMm,
|
|
1920
|
+
/** How deep it is pressed in. */
|
|
1921
|
+
depth: PositiveMm.default(0.6),
|
|
1922
|
+
/** From the centre of the case's footprint, [east, north]. */
|
|
1923
|
+
offset: z15.tuple([Mm, Mm]).default([0, 0]),
|
|
1924
|
+
/**
|
|
1925
|
+
* Cut it right through the face instead, as a stencil — a speaker's grille
|
|
1926
|
+
* in the shape of the mark. Whatever its lines enclose would fall out, so
|
|
1927
|
+
* each enclosed piece is held by bridges across a line: give them here, in
|
|
1928
|
+
* millimetres from the mark's centre as it reads (y up), each turned
|
|
1929
|
+
* `angle` degrees from running east-west. Pieces too small to hold
|
|
1930
|
+
* (STENCIL_SPECK) are cut away; a larger one with no bridge fails the fit
|
|
1931
|
+
* check, by where it is.
|
|
1932
|
+
*/
|
|
1933
|
+
stencil: z15.object({
|
|
1934
|
+
bridges: z15.array(z15.object({ at: z15.tuple([Mm, Mm]), angle: z15.number().default(0), length: PositiveMm.default(3) })).default([])
|
|
1935
|
+
}).optional()
|
|
1936
|
+
});
|
|
1937
|
+
var HardwareManifestSchema = z15.object({
|
|
1938
|
+
project: z15.string().regex(/^[a-z0-9][a-z0-9_-]*$/, "lowercase, digits, - and _"),
|
|
1939
|
+
/** How the case goes together — see TWO STYLES above. */
|
|
1940
|
+
enclosure_style: z15.enum(["split_shell_lip", "tray_bezel"]).default("split_shell_lip"),
|
|
1941
|
+
wall_thickness: PositiveMm.default(2.4),
|
|
1942
|
+
/**
|
|
1943
|
+
* Thicker walls on chosen sides, in place of `wall_thickness` there. A
|
|
1944
|
+
* screen whose glass is as wide as its board otherwise gets 2.4mm of frame
|
|
1945
|
+
* along its sides and 11mm at its ends, which looks off balance (the
|
|
1946
|
+
* black ESP32-S3 board's flush case, 2026-10-25). Each is a whole number
|
|
1947
|
+
* of nozzle lines, and no thinner than `wall_thickness`.
|
|
1948
|
+
*/
|
|
1949
|
+
walls: z15.object({ east: PositiveMm, west: PositiveMm, north: PositiveMm, south: PositiveMm }).partial().default({}),
|
|
1950
|
+
/** Radius of the vertical outside corners. */
|
|
1951
|
+
corner_radius: NonNegativeMm.default(2),
|
|
1952
|
+
/**
|
|
1953
|
+
* The outside's front and back edges — where the face meets the sides.
|
|
1954
|
+
* `chamfer` bevels them flat at 45°, `round` rounds them; `soften` then
|
|
1955
|
+
* rounds every edge the bevel leaves, so nothing on the outside is sharp.
|
|
1956
|
+
* Without it they are square, and a case reads as a printed box.
|
|
1957
|
+
*/
|
|
1958
|
+
edges: z15.object({
|
|
1959
|
+
style: z15.enum(["chamfer", "round"]),
|
|
1960
|
+
size: PositiveMm,
|
|
1961
|
+
soften: NonNegativeMm.default(0)
|
|
1962
|
+
}).optional(),
|
|
1963
|
+
printer: PrinterProfileSchema.default({}),
|
|
1964
|
+
components: z15.array(ComponentSchema).min(1),
|
|
1965
|
+
emblem: EmblemSchema.optional()
|
|
1966
|
+
}).superRefine((m, ctx) => {
|
|
1967
|
+
const lines = m.wall_thickness / m.printer.nozzle;
|
|
1968
|
+
if (Math.abs(lines - Math.round(lines)) > 1e-6) {
|
|
1969
|
+
ctx.addIssue({
|
|
1970
|
+
code: z15.ZodIssueCode.custom,
|
|
1971
|
+
path: ["wall_thickness"],
|
|
1972
|
+
message: `${m.wall_thickness}mm is not a whole number of ${m.printer.nozzle}mm lines \u2014 try ${(Math.round(lines) * m.printer.nozzle).toFixed(2)}`
|
|
1973
|
+
});
|
|
1974
|
+
}
|
|
1975
|
+
for (const [side, t] of Object.entries(m.walls)) {
|
|
1976
|
+
if (t === void 0) continue;
|
|
1977
|
+
const n = t / m.printer.nozzle;
|
|
1978
|
+
if (Math.abs(n - Math.round(n)) > 1e-6) {
|
|
1979
|
+
ctx.addIssue({
|
|
1980
|
+
code: z15.ZodIssueCode.custom,
|
|
1981
|
+
path: ["walls", side],
|
|
1982
|
+
message: `${t}mm is not a whole number of ${m.printer.nozzle}mm lines \u2014 try ${(Math.round(n) * m.printer.nozzle).toFixed(2)}`
|
|
1983
|
+
});
|
|
1984
|
+
}
|
|
1985
|
+
if (t < m.wall_thickness) {
|
|
1986
|
+
ctx.addIssue({
|
|
1987
|
+
code: z15.ZodIssueCode.custom,
|
|
1988
|
+
path: ["walls", side],
|
|
1989
|
+
message: `${t}mm is thinner than wall_thickness (${m.wall_thickness}mm): walls only thicken on chosen sides`
|
|
1990
|
+
});
|
|
1991
|
+
}
|
|
1992
|
+
}
|
|
1993
|
+
const ids = m.components.map((c) => c.id);
|
|
1994
|
+
ids.forEach((id, i) => {
|
|
1995
|
+
if (ids.indexOf(id) !== i) {
|
|
1996
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "id"], message: `"${id}" is used twice` });
|
|
1997
|
+
}
|
|
1998
|
+
});
|
|
1999
|
+
const roots = m.components.filter((c) => !c.placement);
|
|
2000
|
+
if (roots.length !== 1) {
|
|
2001
|
+
ctx.addIssue({
|
|
2002
|
+
code: z15.ZodIssueCode.custom,
|
|
2003
|
+
path: ["components"],
|
|
2004
|
+
message: `exactly one component must have no placement (the origin); found ${roots.length}: ${roots.map((r) => r.id).join(", ") || "none"}`
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
2007
|
+
const byId = new Map(m.components.map((c) => [c.id, c]));
|
|
2008
|
+
m.components.forEach((c, i) => {
|
|
2009
|
+
if (!c.placement) return;
|
|
2010
|
+
const target = c.placement.relative_to;
|
|
2011
|
+
if (!byId.has(target)) {
|
|
2012
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "placement", "relative_to"], message: `no component "${target}"` });
|
|
2013
|
+
return;
|
|
2014
|
+
}
|
|
2015
|
+
const seen = /* @__PURE__ */ new Set([c.id]);
|
|
2016
|
+
for (let at = byId.get(target); at?.placement; at = byId.get(at.placement.relative_to)) {
|
|
2017
|
+
if (seen.has(at.id)) {
|
|
2018
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "placement"], message: `placement loops back to "${at.id}"` });
|
|
2019
|
+
return;
|
|
2020
|
+
}
|
|
2021
|
+
seen.add(at.id);
|
|
2022
|
+
}
|
|
2023
|
+
});
|
|
2024
|
+
m.components.forEach((c, i) => {
|
|
2025
|
+
if (m.enclosure_style === "split_shell_lip" && c.mount_holes && (!c.mount_holes.insert_od || !c.mount_holes.insert_depth)) {
|
|
2026
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "mount_holes"], message: "a split_shell_lip case holds boards on heat-set inserts: give insert_od and insert_depth" });
|
|
2027
|
+
}
|
|
2028
|
+
c.interfaces.forEach((f, j) => {
|
|
2029
|
+
if (f.chamfer && f.edge !== "top" && f.edge !== "bottom") {
|
|
2030
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "interfaces", j, "chamfer"], message: `a chamfer ramps an opening in the bezel or the floor: its edge must be top or bottom, not ${f.edge}` });
|
|
2031
|
+
}
|
|
2032
|
+
if (f.cutout_shape === "grille" && f.edge !== "top" && f.edge !== "bottom") {
|
|
2033
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "interfaces", j, "cutout_shape"], message: `a grille is a field of holes in the bezel or the floor: its edge must be top or bottom, not ${f.edge}` });
|
|
2034
|
+
}
|
|
2035
|
+
if (f.flex_button && f.edge !== "bottom") {
|
|
2036
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "interfaces", j, "flex_button"], message: `a flex button is pressed through the floor: its edge must be bottom, not ${f.edge}` });
|
|
2037
|
+
}
|
|
2038
|
+
});
|
|
2039
|
+
const [x, y] = c.dimensions;
|
|
2040
|
+
c.mount_holes?.positions?.forEach((p, j) => {
|
|
2041
|
+
if (Math.abs(p[0]) > x / 2 || Math.abs(p[1]) > y / 2) {
|
|
2042
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "mount_holes", "positions", j], message: `hole at [${p}] is outside the ${x}\xD7${y} footprint` });
|
|
2043
|
+
}
|
|
2044
|
+
});
|
|
2045
|
+
const inset = c.mount_holes?.inset_from_corners;
|
|
2046
|
+
if (inset && (inset[0] * 2 >= x || inset[1] * 2 >= y)) {
|
|
2047
|
+
ctx.addIssue({ code: z15.ZodIssueCode.custom, path: ["components", i, "mount_holes", "inset_from_corners"], message: `insets [${inset}] meet in the middle of a ${x}\xD7${y} footprint` });
|
|
2048
|
+
}
|
|
2049
|
+
});
|
|
2050
|
+
});
|
|
2051
|
+
var FamilyChoiceSchema = z15.object({
|
|
2052
|
+
label: z15.string().min(1),
|
|
2053
|
+
/** One sentence: what it is for. */
|
|
2054
|
+
description: z15.string().optional(),
|
|
2055
|
+
/** Components added to the base manifest's. */
|
|
2056
|
+
components: z15.array(ComponentSchema).default([]),
|
|
2057
|
+
/** Top-level manifest fields this choice sets: wall_thickness, emblem… */
|
|
2058
|
+
set: z15.record(z15.unknown()).default({}),
|
|
2059
|
+
/**
|
|
2060
|
+
* Changes to the base's own components, by id: fields to set, null to
|
|
2061
|
+
* remove one, and `interfaces` by name the same way — a null interface is
|
|
2062
|
+
* removed, an unknown one added. How a flush top lowers the board's
|
|
2063
|
+
* clearance and widens its screen opening to the glass.
|
|
2064
|
+
*/
|
|
2065
|
+
patch: z15.record(z15.record(z15.unknown())).default({})
|
|
2066
|
+
});
|
|
2067
|
+
var FamilyOptionSchema = z15.object({
|
|
2068
|
+
label: z15.string().min(1),
|
|
2069
|
+
/** In order; the first is the default. Ids are lowercase words and dashes. */
|
|
2070
|
+
choices: z15.array(FamilyChoiceSchema.extend({ id: z15.string().regex(/^[a-z0-9][a-z0-9-]*$/) })).min(1)
|
|
2071
|
+
});
|
|
2072
|
+
var CaseFamilySchema = z15.object({
|
|
2073
|
+
/** The base manifest, relative to this file. */
|
|
2074
|
+
manifest: z15.string().min(1),
|
|
2075
|
+
/** Option groups, in the order they are offered: base, top… */
|
|
2076
|
+
options: z15.record(z15.string().regex(/^[a-z][a-z0-9-]*$/), FamilyOptionSchema)
|
|
2077
|
+
});
|
|
2078
|
+
|
|
1586
2079
|
// src/auth/schema.ts
|
|
1587
|
-
import { z as
|
|
1588
|
-
var UserSchema =
|
|
1589
|
-
id:
|
|
1590
|
-
name:
|
|
1591
|
-
email:
|
|
1592
|
-
password:
|
|
1593
|
-
role:
|
|
1594
|
-
status:
|
|
1595
|
-
joinedAt:
|
|
1596
|
-
lastActive:
|
|
1597
|
-
avatarUrl:
|
|
2080
|
+
import { z as z16 } from "zod";
|
|
2081
|
+
var UserSchema = z16.object({
|
|
2082
|
+
id: z16.string().default(""),
|
|
2083
|
+
name: z16.string(),
|
|
2084
|
+
email: z16.string().email(),
|
|
2085
|
+
password: z16.string().optional(),
|
|
2086
|
+
role: z16.string(),
|
|
2087
|
+
status: z16.string().optional(),
|
|
2088
|
+
joinedAt: z16.string().optional(),
|
|
2089
|
+
lastActive: z16.string().optional(),
|
|
2090
|
+
avatarUrl: z16.string().optional()
|
|
1598
2091
|
});
|
|
1599
2092
|
|
|
1600
2093
|
// src/auth/accounts.ts
|
|
1601
|
-
import { z as
|
|
1602
|
-
var AccountIdSchema =
|
|
1603
|
-
var AccountRoleSchema =
|
|
1604
|
-
var AccountStatusSchema =
|
|
1605
|
-
var ScryptHashSchema =
|
|
1606
|
-
algo:
|
|
1607
|
-
n:
|
|
1608
|
-
r:
|
|
1609
|
-
p:
|
|
1610
|
-
keylen:
|
|
1611
|
-
salt:
|
|
1612
|
-
hash:
|
|
1613
|
-
});
|
|
1614
|
-
var AccountRecordSchema =
|
|
2094
|
+
import { z as z17 } from "zod";
|
|
2095
|
+
var AccountIdSchema = z17.string().regex(/^acct_[0-9a-f]{12}$/, "acct_ and 12 hex digits");
|
|
2096
|
+
var AccountRoleSchema = z17.enum(["member", "admin"]);
|
|
2097
|
+
var AccountStatusSchema = z17.enum(["active", "suspended"]);
|
|
2098
|
+
var ScryptHashSchema = z17.object({
|
|
2099
|
+
algo: z17.literal("scrypt"),
|
|
2100
|
+
n: z17.number().int().positive(),
|
|
2101
|
+
r: z17.number().int().positive(),
|
|
2102
|
+
p: z17.number().int().positive(),
|
|
2103
|
+
keylen: z17.number().int().positive(),
|
|
2104
|
+
salt: z17.string().min(16),
|
|
2105
|
+
hash: z17.string().min(16)
|
|
2106
|
+
});
|
|
2107
|
+
var AccountRecordSchema = z17.object({
|
|
1615
2108
|
accountId: AccountIdSchema,
|
|
1616
2109
|
/** Lowercased on write, because a login must not depend on how it was typed. */
|
|
1617
|
-
email:
|
|
1618
|
-
name:
|
|
2110
|
+
email: z17.string().email().max(254),
|
|
2111
|
+
name: z17.string().min(1).max(64),
|
|
1619
2112
|
role: AccountRoleSchema,
|
|
1620
2113
|
status: AccountStatusSchema,
|
|
1621
2114
|
password: ScryptHashSchema,
|
|
1622
|
-
createdAt:
|
|
1623
|
-
lastLoginAt:
|
|
2115
|
+
createdAt: z17.number().int().nonnegative(),
|
|
2116
|
+
lastLoginAt: z17.number().int().nonnegative().nullable().default(null),
|
|
1624
2117
|
/** Which admin approved this, or null for the bootstrap account. */
|
|
1625
2118
|
invitedBy: AccountIdSchema.nullable().default(null)
|
|
1626
2119
|
});
|
|
1627
|
-
var
|
|
2120
|
+
var DISPLAY_NAME_MAX = 40;
|
|
2121
|
+
var DisplayNameSchema = z17.string().transform((s) => s.trim().replace(/\s+/g, " ")).pipe(
|
|
2122
|
+
z17.string().min(1, "Give a name.").max(DISPLAY_NAME_MAX, `At most ${DISPLAY_NAME_MAX} characters.`).refine((s) => !/[\u0000-\u001f\u007f-\u009f\u200b-\u200f\u2028-\u202e\u2066-\u2069]/.test(s), "Letters, numbers, spaces and punctuation only.")
|
|
2123
|
+
);
|
|
2124
|
+
var PublicAccountSchema = z17.object({
|
|
1628
2125
|
accountId: AccountIdSchema,
|
|
1629
|
-
email:
|
|
1630
|
-
name:
|
|
2126
|
+
email: z17.string().email(),
|
|
2127
|
+
name: z17.string(),
|
|
1631
2128
|
role: AccountRoleSchema,
|
|
1632
2129
|
status: AccountStatusSchema
|
|
1633
2130
|
});
|
|
1634
|
-
var SessionRecordSchema =
|
|
2131
|
+
var SessionRecordSchema = z17.object({
|
|
1635
2132
|
accountId: AccountIdSchema,
|
|
1636
|
-
createdAt:
|
|
1637
|
-
expiresAt:
|
|
1638
|
-
lastSeenAt:
|
|
2133
|
+
createdAt: z17.number().int().nonnegative(),
|
|
2134
|
+
expiresAt: z17.number().int().nonnegative(),
|
|
2135
|
+
lastSeenAt: z17.number().int().nonnegative()
|
|
1639
2136
|
});
|
|
1640
|
-
var InviteRecordSchema =
|
|
1641
|
-
email:
|
|
2137
|
+
var InviteRecordSchema = z17.object({
|
|
2138
|
+
email: z17.string().email().max(254),
|
|
1642
2139
|
role: AccountRoleSchema,
|
|
1643
|
-
createdAt:
|
|
1644
|
-
expiresAt:
|
|
2140
|
+
createdAt: z17.number().int().nonnegative(),
|
|
2141
|
+
expiresAt: z17.number().int().nonnegative(),
|
|
1645
2142
|
invitedBy: AccountIdSchema
|
|
1646
2143
|
});
|
|
1647
|
-
var AccessRequestSchema =
|
|
1648
|
-
email:
|
|
1649
|
-
name:
|
|
2144
|
+
var AccessRequestSchema = z17.object({
|
|
2145
|
+
email: z17.string().email().max(254),
|
|
2146
|
+
name: z17.string().min(1).max(64),
|
|
1650
2147
|
/** Optional, and never shown publicly. Long enough to be useful, short enough not to be an essay. */
|
|
1651
|
-
reason:
|
|
1652
|
-
});
|
|
1653
|
-
var AccessRequestStatusSchema =
|
|
1654
|
-
var AccessRequestRecordSchema =
|
|
1655
|
-
requestId:
|
|
1656
|
-
email:
|
|
1657
|
-
name:
|
|
1658
|
-
reason:
|
|
2148
|
+
reason: z17.string().max(500).optional()
|
|
2149
|
+
});
|
|
2150
|
+
var AccessRequestStatusSchema = z17.enum(["pending", "approved", "denied"]);
|
|
2151
|
+
var AccessRequestRecordSchema = z17.object({
|
|
2152
|
+
requestId: z17.string().regex(/^req_[0-9a-f]{12}$/, "req_ and 12 hex digits"),
|
|
2153
|
+
email: z17.string().email().max(254),
|
|
2154
|
+
name: z17.string().min(1).max(64),
|
|
2155
|
+
reason: z17.string().max(500).optional(),
|
|
1659
2156
|
status: AccessRequestStatusSchema,
|
|
1660
|
-
createdAt:
|
|
1661
|
-
decidedAt:
|
|
2157
|
+
createdAt: z17.number().int().nonnegative(),
|
|
2158
|
+
decidedAt: z17.number().int().nonnegative().nullable().default(null),
|
|
1662
2159
|
decidedBy: AccountIdSchema.nullable().default(null)
|
|
1663
2160
|
});
|
|
1664
2161
|
var SCRYPT_PARAMS = {
|
|
@@ -1676,196 +2173,44 @@ var ACCOUNT_TTL_SECONDS = 60 * 60 * 24 * 400;
|
|
|
1676
2173
|
var INVITE_TTL_SECONDS = 60 * 60 * 24 * 14;
|
|
1677
2174
|
var ACCESS_REQUEST_TTL_SECONDS = 60 * 60 * 24 * 90;
|
|
1678
2175
|
|
|
1679
|
-
// src/
|
|
1680
|
-
import { z as
|
|
1681
|
-
var
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
"
|
|
1685
|
-
"
|
|
1686
|
-
"regulator",
|
|
1687
|
-
"unknown"
|
|
1688
|
-
]);
|
|
1689
|
-
var CounterpartyResolutionSchema = z14.enum([
|
|
1690
|
-
"public",
|
|
1691
|
-
"public_uncovered",
|
|
1692
|
-
"private",
|
|
1693
|
-
"unresolved"
|
|
1694
|
-
]);
|
|
1695
|
-
var CounterpartyNodeSchema = z14.object({
|
|
1696
|
-
id: z14.string(),
|
|
1697
|
-
ticker: z14.string().nullable(),
|
|
1698
|
-
/** Name as it appeared in the source signal — e.g. "Nike". Not the registered name. */
|
|
1699
|
-
name: z14.string(),
|
|
1700
|
-
/** Registered legal name from `profiles` — e.g. "NIKE, Inc.". Null unless `public`. */
|
|
1701
|
-
publicName: z14.string().nullable(),
|
|
1702
|
-
lei: z14.string().nullable(),
|
|
1703
|
-
resolution: CounterpartyResolutionSchema,
|
|
1704
|
-
type: CounterpartyTypeSchema,
|
|
1705
|
-
confidence: z14.number().min(0).max(1),
|
|
1706
|
-
sourceSignalIds: z14.array(z14.number()),
|
|
1707
|
-
firstSeenAt: z14.string().datetime(),
|
|
1708
|
-
lastSeenAt: z14.string().datetime()
|
|
1709
|
-
});
|
|
1710
|
-
var RelationshipEdgeTypeSchema = z14.enum([
|
|
1711
|
-
"supplies_to",
|
|
1712
|
-
"purchases_from",
|
|
1713
|
-
"partners_with",
|
|
1714
|
-
"competes_with",
|
|
1715
|
-
"regulated_by",
|
|
1716
|
-
"invests_in",
|
|
1717
|
-
"acquires",
|
|
1718
|
-
/**
|
|
1719
|
-
* Identity equivalence, not a business relationship: source and target are
|
|
1720
|
-
* the same real-world entity under two different node ids (typically a
|
|
1721
|
-
* slug-keyed node that predates LEI resolution, pointing at the canonical
|
|
1722
|
-
* LEI-keyed node once resolution succeeds). Never delete/merge either
|
|
1723
|
-
* node — this edge exists so a consumer wanting a deduped view can follow
|
|
1724
|
-
* it to the canonical id, reversibly.
|
|
1725
|
-
*/
|
|
1726
|
-
"same_as"
|
|
1727
|
-
]);
|
|
1728
|
-
var RelationshipEdgeSchema = z14.object({
|
|
1729
|
-
id: z14.string(),
|
|
1730
|
-
sourceId: z14.string(),
|
|
1731
|
-
targetId: z14.string(),
|
|
1732
|
-
edgeType: RelationshipEdgeTypeSchema,
|
|
1733
|
-
weight: z14.number().min(0).max(1),
|
|
1734
|
-
evidenceSignalIds: z14.array(z14.number()),
|
|
1735
|
-
updatedAt: z14.string().datetime(),
|
|
1736
|
-
validFrom: z14.string().datetime(),
|
|
1737
|
-
/** null = currently valid. Set when a differently-typed edge supersedes this one. */
|
|
1738
|
-
validTo: z14.string().datetime().nullable()
|
|
1739
|
-
});
|
|
1740
|
-
var SignalWeightSchema = z14.object({
|
|
1741
|
-
signalId: z14.number(),
|
|
1742
|
-
weight: z14.number().min(0).max(1),
|
|
1743
|
-
reason: z14.string().max(280)
|
|
1744
|
-
});
|
|
1745
|
-
var DivergenceMetricSchema = z14.object({
|
|
1746
|
-
ticker: z14.string(),
|
|
1747
|
-
// 'operations'/'customer' are current; 'operational'/'ux' are pre-rename
|
|
1748
|
-
// values that still exist on rows written before the backend's rename —
|
|
1749
|
-
// kept here so reading old rows doesn't fail validation.
|
|
1750
|
-
metric: z14.enum(["operations", "customer", "operational", "ux"]),
|
|
1751
|
-
score: z14.number(),
|
|
1752
|
-
baseline: z14.number(),
|
|
1753
|
-
observed: z14.number(),
|
|
1754
|
-
computedAt: z14.string().datetime(),
|
|
1755
|
-
contributingSignals: z14.array(SignalWeightSchema)
|
|
1756
|
-
});
|
|
1757
|
-
|
|
1758
|
-
// src/non-public-entity/schema.ts
|
|
1759
|
-
import { z as z15 } from "zod";
|
|
1760
|
-
var NonPublicEntitySchema = z15.object({
|
|
1761
|
-
lei: z15.string().nullable(),
|
|
1762
|
-
entityName: z15.string(),
|
|
1763
|
-
jurisdiction: z15.string().nullable(),
|
|
1764
|
-
registrationStatus: z15.string(),
|
|
1765
|
-
parentEntityLei: z15.string().nullable(),
|
|
1766
|
-
materialMetadata: z15.record(z15.unknown()),
|
|
1767
|
-
discoveredAt: z15.string().datetime()
|
|
1768
|
-
});
|
|
1769
|
-
|
|
1770
|
-
// src/events/schema.ts
|
|
1771
|
-
import { z as z16 } from "zod";
|
|
1772
|
-
var EventSourceSchema = z16.enum(["db", "mock"]);
|
|
1773
|
-
var EntityEventKindSchema = z16.enum(["news", "filing", "report"]);
|
|
1774
|
-
var ImpactScaleSchema = z16.enum(["graded", "binary", "default", "none"]);
|
|
1775
|
-
var TimestampPrecisionSchema = z16.enum(["second", "day"]);
|
|
1776
|
-
var EntityEventSchema = z16.object({
|
|
1777
|
-
/** Namespaced so ids never collide across sources: `news:1234`, `filing:AAPL:2026-07-31`. */
|
|
1778
|
-
id: z16.string(),
|
|
1779
|
-
kind: EntityEventKindSchema,
|
|
1780
|
-
/**
|
|
1781
|
-
* The producer's own type string, unmodified — `NEWS_YAHOO FINANCE_YAHOO RSS`,
|
|
1782
|
-
* `ANNUAL`, `SNAPSHOT`. There are 31 distinct NEWS variants in the live table,
|
|
1783
|
-
* so this is for filtering and debugging: never render it raw to a user.
|
|
1784
|
-
*/
|
|
1785
|
-
subtype: z16.string().nullable(),
|
|
1786
|
-
ticker: z16.string(),
|
|
1787
|
-
/** Always `YYYY-MM-DDTHH:MM:SSZ`. Fixed-width, so lexical order == chronological order. */
|
|
1788
|
-
occurredAt: z16.string(),
|
|
1789
|
-
precision: TimestampPrecisionSchema,
|
|
1790
|
-
title: z16.string(),
|
|
1791
|
-
summary: z16.string().nullable(),
|
|
1792
|
-
url: z16.string().nullable(),
|
|
1793
|
-
impact: z16.number().nullable(),
|
|
1794
|
-
impactScale: ImpactScaleSchema,
|
|
1795
|
-
/** 0 bearish … 50 neutral … 100 bullish. */
|
|
1796
|
-
sentiment: z16.number().nullable(),
|
|
1797
|
-
/** False for filings, and for any event sitting at exactly neutral. */
|
|
1798
|
-
sentimentIsMeaningful: z16.boolean(),
|
|
1799
|
-
source: EventSourceSchema,
|
|
1800
|
-
meta: z16.record(z16.unknown()).nullable()
|
|
1801
|
-
});
|
|
1802
|
-
var PaginatedEntityEventsSchema = z16.object({
|
|
1803
|
-
total: z16.number(),
|
|
1804
|
-
page: z16.number(),
|
|
1805
|
-
page_size: z16.number(),
|
|
1806
|
-
data: z16.array(EntityEventSchema)
|
|
1807
|
-
});
|
|
1808
|
-
var EventBucketSizeSchema = z16.enum(["day", "week", "month"]);
|
|
1809
|
-
var EntityEventDensityBucketSchema = z16.object({
|
|
1810
|
-
bucketStart: z16.string(),
|
|
1811
|
-
kind: EntityEventKindSchema,
|
|
1812
|
-
count: z16.number(),
|
|
1813
|
-
/** Null when no event in the bucket had meaningful sentiment. */
|
|
1814
|
-
avgSentiment: z16.number().nullable(),
|
|
1815
|
-
maxImpact: z16.number().nullable()
|
|
1816
|
-
});
|
|
1817
|
-
var EntityEventDensitySchema = z16.object({
|
|
1818
|
-
ticker: z16.string(),
|
|
1819
|
-
bucket: EventBucketSizeSchema,
|
|
1820
|
-
buckets: z16.array(EntityEventDensityBucketSchema),
|
|
1821
|
-
/** So the client can set its time domain without a second request. */
|
|
1822
|
-
range: z16.object({ min: z16.string(), max: z16.string() }),
|
|
1823
|
-
source: EventSourceSchema
|
|
1824
|
-
});
|
|
1825
|
-
var EntityEventFacetSchema = z16.object({
|
|
1826
|
-
kind: EntityEventKindSchema,
|
|
1827
|
-
count: z16.number(),
|
|
1828
|
-
earliest: z16.string().nullable(),
|
|
1829
|
-
latest: z16.string().nullable(),
|
|
1830
|
-
impactScale: ImpactScaleSchema,
|
|
1831
|
-
sentimentUsable: z16.boolean()
|
|
1832
|
-
});
|
|
1833
|
-
var EntityEventFacetsSchema = z16.object({
|
|
1834
|
-
ticker: z16.string(),
|
|
1835
|
-
facets: z16.array(EntityEventFacetSchema),
|
|
1836
|
-
source: EventSourceSchema
|
|
1837
|
-
});
|
|
1838
|
-
var DailyPricePointSchema = z16.object({
|
|
1839
|
-
date: z16.string(),
|
|
1840
|
-
open: z16.number().nullable(),
|
|
1841
|
-
high: z16.number().nullable(),
|
|
1842
|
-
low: z16.number().nullable(),
|
|
1843
|
-
close: z16.number(),
|
|
1844
|
-
volume: z16.number().nullable()
|
|
1845
|
-
});
|
|
1846
|
-
var EntityPriceSeriesSchema = z16.object({
|
|
1847
|
-
ticker: z16.string(),
|
|
1848
|
-
series: z16.array(DailyPricePointSchema),
|
|
1849
|
-
source: EventSourceSchema
|
|
1850
|
-
});
|
|
1851
|
-
var EVENT_KIND_LABELS = {
|
|
1852
|
-
news: "News",
|
|
1853
|
-
filing: "Filing",
|
|
1854
|
-
report: "Analyst report"
|
|
1855
|
-
};
|
|
1856
|
-
var IMPACT_FLAG_THRESHOLD = 7;
|
|
1857
|
-
var SENTIMENT_NEUTRAL = 50;
|
|
1858
|
-
var DEFAULT_HORIZON_QUARTERS = 5;
|
|
1859
|
-
var EXCLUDED_SOURCES = {
|
|
1860
|
-
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.",
|
|
1861
|
-
divergence_metrics: "A continuously recomputed annotation, not an event: 524 AAPL rows in 2 days.",
|
|
1862
|
-
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.",
|
|
1863
|
-
raw_filings: "Stale since April, superseded by signals.",
|
|
1864
|
-
market_metrics: "Two rows total.",
|
|
1865
|
-
job_log: "24.5M rows with no ticker index \u2014 never touch it in a request path."
|
|
2176
|
+
// src/auth/accessTokens.ts
|
|
2177
|
+
import { z as z18 } from "zod";
|
|
2178
|
+
var ACCESS_TOKEN_SCOPES = ["boards:read", "boards:send"];
|
|
2179
|
+
var AccessTokenScopeSchema = z18.enum(ACCESS_TOKEN_SCOPES);
|
|
2180
|
+
var ACCESS_TOKEN_SCOPE_LABELS = {
|
|
2181
|
+
"boards:read": "See my boards",
|
|
2182
|
+
"boards:send": "Send apps to my boards"
|
|
1866
2183
|
};
|
|
2184
|
+
var ACCESS_TOKEN_PREFIX = "rmk_";
|
|
2185
|
+
var ACCESS_TOKEN_LIFETIMES_DAYS = [7, 30, 90, 365];
|
|
2186
|
+
var ACCESS_TOKEN_MAX_PER_ACCOUNT = 20;
|
|
2187
|
+
var ACCESS_TOKEN_RATE_PER_MINUTE = 60;
|
|
2188
|
+
var AccessTokenRecordSchema = z18.object({
|
|
2189
|
+
/** The first 12 hex digits of the hash: what the owner sees and revokes by. */
|
|
2190
|
+
tokenId: z18.string().regex(/^[0-9a-f]{12}$/),
|
|
2191
|
+
accountId: AccountIdSchema,
|
|
2192
|
+
/** What the owner called it: "laptop", "Claude Code". */
|
|
2193
|
+
name: z18.string().trim().min(1).max(60),
|
|
2194
|
+
scopes: z18.array(AccessTokenScopeSchema).min(1),
|
|
2195
|
+
createdAt: z18.number().int().nonnegative(),
|
|
2196
|
+
expiresAt: z18.number().int().nonnegative(),
|
|
2197
|
+
/** Moved forward at most once a day, so using a token is not a write per request. */
|
|
2198
|
+
lastUsedAt: z18.number().int().nonnegative().nullable().default(null)
|
|
2199
|
+
});
|
|
2200
|
+
var PublicAccessTokenSchema = AccessTokenRecordSchema.omit({ accountId: true });
|
|
2201
|
+
var NewAccessTokenSchema = z18.object({
|
|
2202
|
+
name: z18.string().trim().min(1, "Give it a name.").max(60),
|
|
2203
|
+
scopes: z18.array(AccessTokenScopeSchema).min(1, "Choose at least one thing it can do."),
|
|
2204
|
+
days: z18.union(ACCESS_TOKEN_LIFETIMES_DAYS.map((d) => z18.literal(d)))
|
|
2205
|
+
});
|
|
1867
2206
|
export {
|
|
1868
2207
|
ACCESS_REQUEST_TTL_SECONDS,
|
|
2208
|
+
ACCESS_TOKEN_LIFETIMES_DAYS,
|
|
2209
|
+
ACCESS_TOKEN_MAX_PER_ACCOUNT,
|
|
2210
|
+
ACCESS_TOKEN_PREFIX,
|
|
2211
|
+
ACCESS_TOKEN_RATE_PER_MINUTE,
|
|
2212
|
+
ACCESS_TOKEN_SCOPES,
|
|
2213
|
+
ACCESS_TOKEN_SCOPE_LABELS,
|
|
1869
2214
|
ACCOUNT_TTL_SECONDS,
|
|
1870
2215
|
AIKeyManifestSchema,
|
|
1871
2216
|
AIThemeSchema,
|
|
@@ -1878,10 +2223,13 @@ export {
|
|
|
1878
2223
|
AccessRequestRecordSchema,
|
|
1879
2224
|
AccessRequestSchema,
|
|
1880
2225
|
AccessRequestStatusSchema,
|
|
2226
|
+
AccessTokenRecordSchema,
|
|
2227
|
+
AccessTokenScopeSchema,
|
|
1881
2228
|
AccountIdSchema,
|
|
1882
2229
|
AccountRecordSchema,
|
|
1883
2230
|
AccountRoleSchema,
|
|
1884
2231
|
AccountStatusSchema,
|
|
2232
|
+
AccountThemeSchema,
|
|
1885
2233
|
ActionSchema,
|
|
1886
2234
|
AircraftAppConfigSchema,
|
|
1887
2235
|
AppAlignSchema,
|
|
@@ -1913,106 +2261,122 @@ export {
|
|
|
1913
2261
|
AssetHashSchema,
|
|
1914
2262
|
AuthStrategySchema,
|
|
1915
2263
|
BlockSchema,
|
|
2264
|
+
BoardFontSchema,
|
|
2265
|
+
BoardPaletteHexSchema,
|
|
1916
2266
|
schema_exports as Bodewell,
|
|
1917
2267
|
CLAIMED_DEVICE_TTL_SECONDS,
|
|
2268
|
+
CONTROL_STATES,
|
|
2269
|
+
CONTROL_STATE_MEANINGS,
|
|
2270
|
+
CaseFamilySchema,
|
|
1918
2271
|
ClockAppConfigSchema,
|
|
1919
|
-
|
|
1920
|
-
CounterpartyResolutionSchema,
|
|
1921
|
-
CounterpartyTypeSchema,
|
|
2272
|
+
ComponentSchema,
|
|
1922
2273
|
DEFAULT_CHAT_MODEL,
|
|
1923
2274
|
DEFAULT_DEVICE_CONFIG,
|
|
1924
|
-
DEFAULT_HORIZON_QUARTERS,
|
|
1925
2275
|
DEFAULT_PRO_MODEL,
|
|
1926
2276
|
DEFAULT_SCHEMA_MODEL,
|
|
1927
2277
|
DEFAULT_THEME_TOKENS,
|
|
1928
2278
|
DEVICE_AP_SSID_PREFIX,
|
|
1929
2279
|
DEVICE_ENDPOINTS,
|
|
2280
|
+
DEVICE_FEATURES,
|
|
2281
|
+
DEVICE_FEATURE_STATE_LABELS,
|
|
1930
2282
|
DEVICE_FRESH_MS,
|
|
1931
2283
|
DEVICE_GLYPHS,
|
|
1932
2284
|
DEVICE_LABEL_MAX,
|
|
1933
2285
|
DEVICE_PALETTE,
|
|
2286
|
+
DEVICE_POLL_QUERY,
|
|
2287
|
+
DEVICE_PROTOCOL,
|
|
1934
2288
|
DEVICE_STALE_MS,
|
|
1935
2289
|
DEVICE_TIMEZONES,
|
|
1936
2290
|
DEVICE_TIMEZONE_FALLBACK,
|
|
1937
2291
|
DEVICE_TTL_SECONDS,
|
|
1938
2292
|
DEVICE_UNKNOWN_GLYPH,
|
|
1939
2293
|
DEVICE_VITALS_FIELDS,
|
|
1940
|
-
|
|
2294
|
+
DEVICE_VOICE_CLIP,
|
|
2295
|
+
DISPLAY_FACE_MIN_PX,
|
|
2296
|
+
DISPLAY_NAME_MAX,
|
|
1941
2297
|
DeliveredAppSchema,
|
|
1942
2298
|
DeviceAppIdSchema,
|
|
1943
2299
|
DeviceAppsSchema,
|
|
1944
2300
|
DeviceConfigSchema,
|
|
1945
2301
|
DeviceDisplayConfigSchema,
|
|
2302
|
+
DeviceFeatureKeySchema,
|
|
2303
|
+
DeviceFeatureStateSchema,
|
|
2304
|
+
DeviceFeaturesSchema,
|
|
1946
2305
|
DeviceIdSchema,
|
|
1947
2306
|
DeviceKindSchema,
|
|
2307
|
+
DevicePollReplySchema,
|
|
2308
|
+
DeviceReadingSchema,
|
|
1948
2309
|
DeviceRecordSchema,
|
|
1949
2310
|
DeviceRegistrationSchema,
|
|
2311
|
+
DeviceReportSchema,
|
|
1950
2312
|
DeviceSeenSchema,
|
|
1951
2313
|
DeviceStatusSchema,
|
|
1952
2314
|
DeviceThemeSchema,
|
|
1953
2315
|
DeviceVitalsSchema,
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1957
|
-
|
|
1958
|
-
EntityEventDensitySchema,
|
|
1959
|
-
EntityEventFacetSchema,
|
|
1960
|
-
EntityEventFacetsSchema,
|
|
1961
|
-
EntityEventKindSchema,
|
|
1962
|
-
EntityEventSchema,
|
|
1963
|
-
EntityPriceSeriesSchema,
|
|
2316
|
+
DeviceVoiceReplySchema,
|
|
2317
|
+
DisplayNameSchema,
|
|
2318
|
+
EdgeSchema,
|
|
2319
|
+
EmblemSchema,
|
|
1964
2320
|
EntitySchema,
|
|
1965
|
-
EventBucketSizeSchema,
|
|
1966
|
-
EventSourceSchema,
|
|
1967
2321
|
FIRMWARE_UPDATE_ATTEMPTS,
|
|
1968
2322
|
FIRMWARE_UPDATE_PREFIX,
|
|
1969
2323
|
FULL_COLOUR_FRAME_MAX,
|
|
1970
2324
|
FULL_RENDITION,
|
|
2325
|
+
FamilyChoiceSchema,
|
|
2326
|
+
FamilyOptionSchema,
|
|
1971
2327
|
FieldSchema,
|
|
1972
2328
|
FirmwareUpdateSchema,
|
|
2329
|
+
FlexButtonSchema,
|
|
1973
2330
|
FloraTelemetrySchema,
|
|
1974
2331
|
GENESIS_LIBRARY_CONTEXT,
|
|
1975
2332
|
GENESIS_VALID_COMPONENTS,
|
|
2333
|
+
HardwareManifestSchema,
|
|
1976
2334
|
ICON_GRID,
|
|
1977
2335
|
ICON_SIZE_PX,
|
|
1978
2336
|
ICON_STROKE,
|
|
1979
2337
|
IMAGE_MAX_DRAWN,
|
|
1980
2338
|
IMAGE_MAX_SCALE,
|
|
1981
|
-
IMPACT_FLAG_THRESHOLD,
|
|
1982
2339
|
INVITE_TTL_SECONDS,
|
|
1983
|
-
|
|
2340
|
+
InterfaceSchema,
|
|
1984
2341
|
InviteRecordSchema,
|
|
1985
2342
|
MAX_PASSWORD_LENGTH,
|
|
1986
2343
|
MIN_PASSWORD_LENGTH,
|
|
1987
|
-
|
|
2344
|
+
MountHolesSchema,
|
|
2345
|
+
NewAccessTokenSchema,
|
|
1988
2346
|
ORIGINAL_MAX_BYTES,
|
|
1989
2347
|
ORIGINAL_MAX_SIDE,
|
|
1990
2348
|
OwnedSendRequestSchema,
|
|
2349
|
+
PANEL_SIZE,
|
|
1991
2350
|
PHOTOS_PER_ACCOUNT,
|
|
1992
2351
|
PHOTO_UPLOADS_PER_HOUR,
|
|
1993
2352
|
PROVIDER_DEFAULT_MODEL,
|
|
1994
2353
|
PageSchema,
|
|
1995
2354
|
PageSectionSchema,
|
|
1996
|
-
PaginatedEntityEventsSchema,
|
|
1997
2355
|
PairCodeSchema,
|
|
2356
|
+
PanelOrientationSchema,
|
|
1998
2357
|
PhotoCropSchema,
|
|
1999
2358
|
PhotoFullSchema,
|
|
2000
2359
|
PhotoSummarySchema,
|
|
2001
2360
|
PhotoUploadSchema,
|
|
2361
|
+
PlacementSchema,
|
|
2362
|
+
PrinterProfileSchema,
|
|
2002
2363
|
ProvisioningStateSchema,
|
|
2364
|
+
PublicAccessTokenSchema,
|
|
2003
2365
|
PublicAccountSchema,
|
|
2004
2366
|
RETRO_RENDITION,
|
|
2005
|
-
RelationshipEdgeSchema,
|
|
2006
|
-
RelationshipEdgeTypeSchema,
|
|
2007
2367
|
ResourceSchema,
|
|
2008
2368
|
SCRYPT_PARAMS,
|
|
2009
|
-
SENTIMENT_NEUTRAL,
|
|
2010
2369
|
SESSION_COOKIE_NAME,
|
|
2011
2370
|
SESSION_TTL_SECONDS,
|
|
2371
|
+
SHELF_MAX_APPS,
|
|
2372
|
+
SHELF_MAX_BYTES,
|
|
2373
|
+
SHELF_ROTATE_MINUTES,
|
|
2012
2374
|
SIGNAL_DOMAINS,
|
|
2013
2375
|
SIGNAL_KINDS,
|
|
2014
2376
|
SIGNAL_KIND_LABELS,
|
|
2015
2377
|
SIGNAL_SOURCES,
|
|
2378
|
+
SMOOTH_FACES,
|
|
2379
|
+
SMOOTH_FONT_ADVANCES,
|
|
2016
2380
|
SPRITE_MAX_BASE64,
|
|
2017
2381
|
SPRITE_MAX_ROW_BYTES,
|
|
2018
2382
|
SPRITE_MAX_SIDE,
|
|
@@ -2022,18 +2386,23 @@ export {
|
|
|
2022
2386
|
SendRequestSchema,
|
|
2023
2387
|
SensorAppConfigSchema,
|
|
2024
2388
|
SessionRecordSchema,
|
|
2389
|
+
ShelfEditSchema,
|
|
2390
|
+
ShelfSchema,
|
|
2025
2391
|
SignalArraySchema,
|
|
2026
2392
|
SignalKindSchema,
|
|
2027
2393
|
SignalPacketSchema,
|
|
2028
2394
|
SignalSchema,
|
|
2029
2395
|
SignalSourceSchema,
|
|
2030
|
-
|
|
2396
|
+
THEME_PALETTE_TOKENS,
|
|
2031
2397
|
THEME_PRESETS,
|
|
2398
|
+
THEME_RADII,
|
|
2032
2399
|
THEME_SYSTEM_PROMPT,
|
|
2033
2400
|
ThemeFontsSchema,
|
|
2401
|
+
ThemeLetteringSchema,
|
|
2034
2402
|
ThemeOverridesSchema,
|
|
2403
|
+
ThemePaletteSchema,
|
|
2404
|
+
ThemeRgbSchema,
|
|
2035
2405
|
ThemeTokensSchema,
|
|
2036
|
-
TimestampPrecisionSchema,
|
|
2037
2406
|
TriggerSchema,
|
|
2038
2407
|
UserSchema,
|
|
2039
2408
|
VitalSourceSchema,
|
|
@@ -2042,12 +2411,5 @@ export {
|
|
|
2042
2411
|
WEATHER_ICON_NAMES,
|
|
2043
2412
|
WeatherAppConfigSchema,
|
|
2044
2413
|
WorkflowSchema,
|
|
2045
|
-
architectureReferenceParameters,
|
|
2046
|
-
companyNewsParameters,
|
|
2047
|
-
companyProfileParameters,
|
|
2048
|
-
counterpartyGraphParameters,
|
|
2049
|
-
divergenceMetricsParameters,
|
|
2050
|
-
liveQuoteParameters,
|
|
2051
|
-
stockChartParameters,
|
|
2052
2414
|
telemetryGraphParameters
|
|
2053
2415
|
};
|