@ramme-io/shared 3.1.2 → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -20,17 +20,55 @@ 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,
28
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,
29
58
  AppSignalSchema: () => AppSignalSchema,
59
+ AppSourceSchema: () => AppSourceSchema,
60
+ AppSparklineSchema: () => AppSparklineSchema,
30
61
  AppSpecificationSchema: () => AppSpecificationSchema,
62
+ AppSpriteSchema: () => AppSpriteSchema,
63
+ AppStatusSchema: () => AppStatusSchema,
64
+ AppStyleRuleSchema: () => AppStyleRuleSchema,
65
+ AppTextSchema: () => AppTextSchema,
66
+ AppTextSizeSchema: () => AppTextSizeSchema,
67
+ AssetHashSchema: () => AssetHashSchema,
31
68
  AuthStrategySchema: () => AuthStrategySchema,
32
69
  BlockSchema: () => BlockSchema,
33
70
  Bodewell: () => schema_exports,
71
+ CLAIMED_DEVICE_TTL_SECONDS: () => CLAIMED_DEVICE_TTL_SECONDS,
34
72
  ClockAppConfigSchema: () => ClockAppConfigSchema,
35
73
  CounterpartyNodeSchema: () => CounterpartyNodeSchema,
36
74
  CounterpartyResolutionSchema: () => CounterpartyResolutionSchema,
@@ -43,14 +81,30 @@ __export(index_exports, {
43
81
  DEFAULT_THEME_TOKENS: () => DEFAULT_THEME_TOKENS,
44
82
  DEVICE_AP_SSID_PREFIX: () => DEVICE_AP_SSID_PREFIX,
45
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,
46
94
  DailyPricePointSchema: () => DailyPricePointSchema,
95
+ DeliveredAppSchema: () => DeliveredAppSchema,
47
96
  DeviceAppIdSchema: () => DeviceAppIdSchema,
48
97
  DeviceAppsSchema: () => DeviceAppsSchema,
49
98
  DeviceConfigSchema: () => DeviceConfigSchema,
50
99
  DeviceDisplayConfigSchema: () => DeviceDisplayConfigSchema,
100
+ DeviceIdSchema: () => DeviceIdSchema,
51
101
  DeviceKindSchema: () => DeviceKindSchema,
102
+ DeviceRecordSchema: () => DeviceRecordSchema,
103
+ DeviceRegistrationSchema: () => DeviceRegistrationSchema,
104
+ DeviceSeenSchema: () => DeviceSeenSchema,
52
105
  DeviceStatusSchema: () => DeviceStatusSchema,
53
106
  DeviceThemeSchema: () => DeviceThemeSchema,
107
+ DeviceVitalsSchema: () => DeviceVitalsSchema,
54
108
  DivergenceMetricSchema: () => DivergenceMetricSchema,
55
109
  EVENT_KIND_LABELS: () => EVENT_KIND_LABELS,
56
110
  EXCLUDED_SOURCES: () => EXCLUDED_SOURCES,
@@ -68,22 +122,50 @@ __export(index_exports, {
68
122
  FloraTelemetrySchema: () => FloraTelemetrySchema,
69
123
  GENESIS_LIBRARY_CONTEXT: () => GENESIS_LIBRARY_CONTEXT,
70
124
  GENESIS_VALID_COMPONENTS: () => GENESIS_VALID_COMPONENTS,
125
+ IMAGE_MAX_DRAWN: () => IMAGE_MAX_DRAWN,
126
+ IMAGE_MAX_SCALE: () => IMAGE_MAX_SCALE,
71
127
  IMPACT_FLAG_THRESHOLD: () => IMPACT_FLAG_THRESHOLD,
128
+ INVITE_TTL_SECONDS: () => INVITE_TTL_SECONDS,
72
129
  ImpactScaleSchema: () => ImpactScaleSchema,
130
+ InviteRecordSchema: () => InviteRecordSchema,
131
+ MAX_PASSWORD_LENGTH: () => MAX_PASSWORD_LENGTH,
132
+ MIN_PASSWORD_LENGTH: () => MIN_PASSWORD_LENGTH,
73
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,
74
140
  PageSchema: () => PageSchema,
75
141
  PageSectionSchema: () => PageSectionSchema,
76
142
  PaginatedEntityEventsSchema: () => PaginatedEntityEventsSchema,
143
+ PairCodeSchema: () => PairCodeSchema,
144
+ PhotoSummarySchema: () => PhotoSummarySchema,
145
+ PhotoUploadSchema: () => PhotoUploadSchema,
77
146
  ProvisioningStateSchema: () => ProvisioningStateSchema,
147
+ PublicAccountSchema: () => PublicAccountSchema,
148
+ RETRO_RENDITION: () => RETRO_RENDITION,
78
149
  RelationshipEdgeSchema: () => RelationshipEdgeSchema,
79
150
  RelationshipEdgeTypeSchema: () => RelationshipEdgeTypeSchema,
80
151
  ResourceSchema: () => ResourceSchema,
152
+ SCRYPT_PARAMS: () => SCRYPT_PARAMS,
81
153
  SENTIMENT_NEUTRAL: () => SENTIMENT_NEUTRAL,
154
+ SESSION_COOKIE_NAME: () => SESSION_COOKIE_NAME,
155
+ SESSION_TTL_SECONDS: () => SESSION_TTL_SECONDS,
82
156
  SIGNAL_DOMAINS: () => SIGNAL_DOMAINS,
83
157
  SIGNAL_KINDS: () => SIGNAL_KINDS,
84
158
  SIGNAL_KIND_LABELS: () => SIGNAL_KIND_LABELS,
85
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,
86
167
  SensorAppConfigSchema: () => SensorAppConfigSchema,
168
+ SessionRecordSchema: () => SessionRecordSchema,
87
169
  SignalArraySchema: () => SignalArraySchema,
88
170
  SignalKindSchema: () => SignalKindSchema,
89
171
  SignalPacketSchema: () => SignalPacketSchema,
@@ -98,6 +180,7 @@ __export(index_exports, {
98
180
  TimestampPrecisionSchema: () => TimestampPrecisionSchema,
99
181
  TriggerSchema: () => TriggerSchema,
100
182
  UserSchema: () => UserSchema,
183
+ VitalSourceSchema: () => VitalSourceSchema,
101
184
  WeatherAppConfigSchema: () => WeatherAppConfigSchema,
102
185
  WorkflowSchema: () => WorkflowSchema,
103
186
  architectureReferenceParameters: () => architectureReferenceParameters,
@@ -371,7 +454,8 @@ var BodewellTelemetrySchema = import_zod4.z.object({
371
454
  soil_temp_stemma: import_zod4.z.number().optional().describe("Celsius"),
372
455
  soil_vwc: import_zod4.z.number().describe("Volumetric Water Content / Raw Capacitance"),
373
456
  soil_moisture: import_zod4.z.number().optional().describe("Firmware alias for raw capacitance"),
374
- 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")
375
459
  }).passthrough();
376
460
  var BodewellCommandSchema = import_zod4.z.object({
377
461
  stick_id: BodewellDeviceID,
@@ -511,34 +595,554 @@ var DEFAULT_DEVICE_CONFIG = {
511
595
  theme: { preset: "dark" }
512
596
  };
513
597
 
514
- // src/ai/tools.ts
598
+ // src/apps/schema.ts
515
599
  var import_zod6 = require("zod");
516
- var telemetryGraphParameters = import_zod6.z.object({
517
- deviceId: import_zod6.z.string().min(1, "Device ID is required"),
518
- timeRange: import_zod6.z.enum(["1h", "24h", "7d"], {
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
+ * Taking turns: a number that counts 0, 1, 2 … up to `count - 1` and starts
639
+ * again, moving on every `minutes`. Its one field is `index`.
640
+ *
641
+ * It exists for the photo frame — each photo hides unless the index is its
642
+ * own — and works for anything that should alternate, like two lines of a
643
+ * sign. Counted from UTC minutes since 1970, so the browser and every board
644
+ * agree on which turn it is without talking to each other, and minutes
645
+ * because a board redraws once a minute and no faster (see loop() in
646
+ * hardware/weather-display/weather-display.ino).
647
+ */
648
+ import_zod6.z.object({
649
+ kind: import_zod6.z.literal("cycle"),
650
+ count: import_zod6.z.number().int().min(2).max(12),
651
+ minutes: import_zod6.z.number().int().min(1).max(1440).default(5)
652
+ })
653
+ ]);
654
+ var AppOperandSchema = import_zod6.z.union([
655
+ import_zod6.z.object({ literal: import_zod6.z.number() }),
656
+ import_zod6.z.object({ source: import_zod6.z.string().min(1), field: import_zod6.z.string().min(1) })
657
+ ]);
658
+ var AppComputeSchema = import_zod6.z.object({
659
+ compute: import_zod6.z.enum(["add", "subtract", "multiply", "divide"]),
660
+ of: import_zod6.z.tuple([AppOperandSchema, AppOperandSchema]),
661
+ round: import_zod6.z.boolean().default(true)
662
+ });
663
+ var AppBindingSchema = import_zod6.z.union([
664
+ import_zod6.z.object({ literal: import_zod6.z.union([import_zod6.z.string(), import_zod6.z.number(), import_zod6.z.boolean()]) }),
665
+ import_zod6.z.object({
666
+ /** Key into the document's `sources` map. */
667
+ source: import_zod6.z.string().min(1),
668
+ /** Field on that source, e.g. "temperature", "high", "condition". */
669
+ field: import_zod6.z.string().min(1)
670
+ }),
671
+ AppComputeSchema
672
+ ]);
673
+ var AppConditionSchema = import_zod6.z.object({
674
+ value: AppOperandSchema,
675
+ op: import_zod6.z.enum(["<", "<=", ">", ">=", "==", "!="]),
676
+ than: import_zod6.z.union([import_zod6.z.number(), import_zod6.z.string(), import_zod6.z.boolean()])
677
+ });
678
+ var AppStyleRuleSchema = import_zod6.z.object({
679
+ when: AppConditionSchema,
680
+ color: AppColorSchema.optional(),
681
+ size: AppTextSizeSchema.optional()
682
+ });
683
+ var leafBase = {
684
+ color: AppColorSchema.optional(),
685
+ /** Drawn only when this is false, or absent. */
686
+ hideWhen: AppConditionSchema.optional(),
687
+ /** Conditional style. First match wins. */
688
+ rules: import_zod6.z.array(AppStyleRuleSchema).max(4).optional()
689
+ };
690
+ var AppTextSchema = import_zod6.z.object({
691
+ type: import_zod6.z.literal("text"),
692
+ value: AppBindingSchema,
693
+ size: AppTextSizeSchema.default("base"),
694
+ align: AppAlignSchema.default("start"),
695
+ /** Printed after the value, e.g. a degree symbol. Never itself bound. */
696
+ suffix: import_zod6.z.string().max(8).optional(),
697
+ ...leafBase
698
+ });
699
+ var AppDialSchema = import_zod6.z.object({
700
+ type: import_zod6.z.literal("dial"),
701
+ value: AppBindingSchema,
702
+ min: import_zod6.z.number(),
703
+ max: import_zod6.z.number(),
704
+ label: import_zod6.z.string().max(24).optional(),
705
+ ...leafBase
706
+ });
707
+ var AppSparklineSchema = import_zod6.z.object({
708
+ type: import_zod6.z.literal("sparkline"),
709
+ /** A source field holding a series rather than a scalar. */
710
+ series: AppBindingSchema,
711
+ ...leafBase
712
+ });
713
+ var AppBarSchema = import_zod6.z.object({
714
+ type: import_zod6.z.literal("bar"),
715
+ value: AppBindingSchema,
716
+ min: import_zod6.z.number(),
717
+ max: import_zod6.z.number(),
718
+ ...leafBase
719
+ });
720
+ var AppStatusSchema = import_zod6.z.object({
721
+ type: import_zod6.z.literal("status"),
722
+ state: AppBindingSchema,
723
+ label: import_zod6.z.string().max(24).optional(),
724
+ ...leafBase
725
+ });
726
+ var SPRITE_MAX_SIDE = 64;
727
+ var SPRITE_MAX_ROW_BYTES = SPRITE_MAX_SIDE / 2;
728
+ var SPRITE_MAX_BASE64 = Math.ceil(SPRITE_MAX_ROW_BYTES * SPRITE_MAX_SIDE / 3) * 4;
729
+ var AppSpriteSchema = import_zod6.z.object({
730
+ type: import_zod6.z.literal("sprite"),
731
+ width: import_zod6.z.number().int().min(1).max(SPRITE_MAX_SIDE),
732
+ height: import_zod6.z.number().int().min(1).max(SPRITE_MAX_SIDE),
733
+ /**
734
+ * Up to sixteen colours, in the same form every other colour in a document
735
+ * takes: a semantic token, or literal RGB.
736
+ *
737
+ * Both are allowed on purpose. A token re-colours with the theme, which is
738
+ * what an icon wants; literal RGB does not, which is what a drawing wants.
739
+ * A picture of a dog is content, not chrome, and should not turn teal
740
+ * because somebody switched to the corporate theme.
741
+ */
742
+ palette: import_zod6.z.array(AppColorSchema).min(1).max(16),
743
+ /** base64 of the packed nibbles. */
744
+ pixels: import_zod6.z.string().min(4).max(SPRITE_MAX_BASE64),
745
+ align: AppAlignSchema.default("start"),
746
+ /** Drawn only when this is false, or absent. */
747
+ hideWhen: AppConditionSchema.optional()
748
+ });
749
+ var AssetHashSchema = import_zod6.z.string().regex(/^[0-9a-f]{64}$/, "a lowercase hex SHA-256");
750
+ var IMAGE_MAX_DRAWN = { width: 304, height: 224 };
751
+ var IMAGE_MAX_SCALE = 8;
752
+ var RETRO_RENDITION = { width: 76, height: 56, scale: 4, colors: 16 };
753
+ var SPR_FORMAT = {
754
+ /** "RSPR". */
755
+ magic: [82, 83, 80, 82],
756
+ version: 1,
757
+ /** magic 4, version 1, width u16, height u16, bits per pixel 1, palette count 1. */
758
+ headerBytes: 11,
759
+ /** Only 4 today: two pixels per byte, high nibble first, rows padded to a byte. */
760
+ bitsPerPixel: 4,
761
+ maxColors: 16
762
+ };
763
+ var SPR_MAX_BYTES = SPR_FORMAT.headerBytes + SPR_FORMAT.maxColors * 2 + Math.ceil(IMAGE_MAX_DRAWN.width / 2) * IMAGE_MAX_DRAWN.height;
764
+ var AppImageSchema = import_zod6.z.object({
765
+ type: import_zod6.z.literal("image"),
766
+ asset: AssetHashSchema,
767
+ /** The file's own pixels, not the drawn size. */
768
+ width: import_zod6.z.number().int().min(1).max(IMAGE_MAX_DRAWN.width),
769
+ height: import_zod6.z.number().int().min(1).max(IMAGE_MAX_DRAWN.height),
770
+ scale: import_zod6.z.number().int().min(1).max(IMAGE_MAX_SCALE).default(1),
771
+ align: AppAlignSchema.default("start"),
772
+ /** Drawn only when this is false, or absent. */
773
+ hideWhen: AppConditionSchema.optional()
774
+ });
775
+ var AppLeafSchema = import_zod6.z.discriminatedUnion("type", [
776
+ AppTextSchema,
777
+ AppDialSchema,
778
+ AppSparklineSchema,
779
+ AppBarSchema,
780
+ AppStatusSchema,
781
+ AppSpriteSchema,
782
+ AppImageSchema
783
+ ]);
784
+ var AppGroupSchema = import_zod6.z.object({
785
+ type: import_zod6.z.literal("group"),
786
+ direction: import_zod6.z.enum(["row", "stack"]),
787
+ gap: import_zod6.z.number().int().min(0).max(64).default(4),
788
+ align: AppAlignSchema.default("start"),
789
+ children: import_zod6.z.array(AppLeafSchema).min(1).max(8)
790
+ });
791
+ var AppBlockSchema = import_zod6.z.union([AppLeafSchema, AppGroupSchema]);
792
+ var AppScreenSizeSchema = import_zod6.z.preprocess(
793
+ (value) => value === "240x320" ? "320x240" : value,
794
+ import_zod6.z.enum(["320x240"])
795
+ );
796
+ var AppDocumentSchema = import_zod6.z.object({
797
+ /** Bumped only for a breaking change; the device checks it before parsing. */
798
+ schemaVersion: import_zod6.z.literal(1),
799
+ id: import_zod6.z.string().regex(/^[a-z0-9][a-z0-9-]{1,38}[a-z0-9]$/, "lowercase slug"),
800
+ name: import_zod6.z.string().min(1).max(48),
801
+ /** Free text. Never an email or anything else identifying — see the plan. */
802
+ author: import_zod6.z.string().max(32).optional(),
803
+ screen: AppScreenSizeSchema.default("320x240"),
804
+ background: AppColorSchema.default("background"),
805
+ /** Named so bindings can refer to them. */
806
+ sources: import_zod6.z.record(AppSourceSchema).default({}),
807
+ blocks: import_zod6.z.array(AppBlockSchema).min(1).max(12)
808
+ }).superRefine((doc, ctx) => {
809
+ const bytesPerRow = (width) => Math.ceil(width / 2);
810
+ const check = (block, path) => {
811
+ const b = block;
812
+ if (b?.type !== "sprite" || !b.width || !b.height || typeof b.pixels !== "string") return;
813
+ const want = bytesPerRow(b.width) * b.height;
814
+ const got = Math.floor(b.pixels.replace(/=+$/, "").length * 3 / 4);
815
+ if (got === want) return;
816
+ ctx.addIssue({
817
+ code: import_zod6.z.ZodIssueCode.custom,
818
+ path: [...path, "pixels"],
819
+ 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.`
820
+ });
821
+ };
822
+ const checkImage = (block, path) => {
823
+ const b = block;
824
+ if (b?.type !== "image" || !b.width || !b.height) return;
825
+ const scale = b.scale ?? 1;
826
+ const w = b.width * scale;
827
+ const h = b.height * scale;
828
+ if (w <= IMAGE_MAX_DRAWN.width && h <= IMAGE_MAX_DRAWN.height) return;
829
+ ctx.addIssue({
830
+ code: import_zod6.z.ZodIssueCode.custom,
831
+ path: [...path, "scale"],
832
+ 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.`
833
+ });
834
+ };
835
+ doc.blocks.forEach((block, i) => {
836
+ check(block, ["blocks", i]);
837
+ checkImage(block, ["blocks", i]);
838
+ const children = block.children;
839
+ if (Array.isArray(children)) {
840
+ children.forEach((child, j) => {
841
+ check(child, ["blocks", i, "children", j]);
842
+ checkImage(child, ["blocks", i, "children", j]);
843
+ });
844
+ }
845
+ });
846
+ });
847
+
848
+ // src/apps/photos.ts
849
+ var import_zod7 = require("zod");
850
+ var ORIGINAL_MAX_SIDE = 3072;
851
+ var ORIGINAL_MAX_BYTES = 3e6;
852
+ var PHOTOS_PER_ACCOUNT = 50;
853
+ var PHOTO_UPLOADS_PER_HOUR = 30;
854
+ var PhotoUploadSchema = import_zod7.z.object({
855
+ rendition: import_zod7.z.string().min(4),
856
+ original: import_zod7.z.string().min(4)
857
+ });
858
+ var PhotoSummarySchema = import_zod7.z.object({
859
+ hash: AssetHashSchema,
860
+ /** The rendition's own pixels. */
861
+ width: import_zod7.z.number().int().positive(),
862
+ height: import_zod7.z.number().int().positive(),
863
+ renditionBytes: import_zod7.z.number().int().positive(),
864
+ originalWidth: import_zod7.z.number().int().positive(),
865
+ originalHeight: import_zod7.z.number().int().positive(),
866
+ originalBytes: import_zod7.z.number().int().positive(),
867
+ uploadedAt: import_zod7.z.number().int()
868
+ });
869
+
870
+ // src/apps/delivery.ts
871
+ var import_zod8 = require("zod");
872
+ var DeviceIdSchema = import_zod8.z.string().regex(/^[0-9A-HJKMNP-TV-Z]{8}$/, "eight characters, no I L O or U");
873
+ var PairCodeSchema = import_zod8.z.string().regex(/^\d{4}$/);
874
+ var DeviceRegistrationSchema = import_zod8.z.object({
875
+ deviceId: DeviceIdSchema,
876
+ code: PairCodeSchema,
877
+ /** Firmware build, so a support question has an answer. */
878
+ version: import_zod8.z.string().max(40).optional(),
879
+ /** Which board this is, from Boards.h — the two variants need different firmware. */
880
+ board: import_zod8.z.string().max(40).optional(),
881
+ /** dBm, always negative. -50 is across the room; -85 is a complaint. */
882
+ rssi: import_zod8.z.number().int().min(-127).max(0).optional(),
883
+ /** On the owner's own network. Long enough for IPv6, which this does not send yet. */
884
+ ip: import_zod8.z.string().max(45).optional(),
885
+ /** Seconds since boot. Not growing between check-ins means it is restarting. */
886
+ uptime: import_zod8.z.number().int().nonnegative().optional(),
887
+ /** Free heap in bytes. */
888
+ heap: import_zod8.z.number().int().nonnegative().optional(),
889
+ /** The app revision the board has actually drawn. */
890
+ drew: import_zod8.z.number().int().nonnegative().optional(),
891
+ /** Why it last restarted, already mapped to a word by the firmware. */
892
+ reset: import_zod8.z.string().max(40).optional()
893
+ });
894
+ var SendRequestSchema = import_zod8.z.object({
895
+ deviceId: DeviceIdSchema,
896
+ code: PairCodeSchema
897
+ });
898
+ var OwnedSendRequestSchema = import_zod8.z.object({
899
+ deviceId: DeviceIdSchema
900
+ });
901
+ var DeliveredAppSchema = import_zod8.z.object({
902
+ revision: import_zod8.z.number().int().nonnegative(),
903
+ sentAt: import_zod8.z.number().int().nonnegative()
904
+ });
905
+ var DeviceRecordSchema = import_zod8.z.object({
906
+ deviceId: DeviceIdSchema,
907
+ code: PairCodeSchema,
908
+ ownerId: import_zod8.z.string().nullable().default(null),
909
+ version: import_zod8.z.string().max(40).optional(),
910
+ createdAt: import_zod8.z.number().int().nonnegative(),
911
+ lastSeenAt: import_zod8.z.number().int().nonnegative()
912
+ });
913
+ var DEVICE_LABEL_MAX = 48;
914
+ var DEVICE_TTL_SECONDS = 60 * 60 * 24 * 30;
915
+ var CLAIMED_DEVICE_TTL_SECONDS = 60 * 60 * 24 * 400;
916
+
917
+ // src/apps/vitals.ts
918
+ var import_zod9 = require("zod");
919
+ var VitalSourceSchema = import_zod9.z.enum(["register", "poll", "send"]);
920
+ var DeviceVitalsSchema = import_zod9.z.object({
921
+ /** When the board last said any of this, by the server's clock. */
922
+ reportedAt: import_zod9.z.number().int().nonnegative().optional(),
923
+ /**
924
+ * The firmware build. Today every board sends the literal "doc-1", which is a
925
+ * protocol marker rather than a build id — so this is shown as reported and
926
+ * labelled as not yet a version. The real value lives in the published
927
+ * manifest until firmware carries it.
928
+ */
929
+ firmwareVersion: import_zod9.z.string().max(40).optional(),
930
+ /** Which board this is. Nothing distinguishes a CYD from a Freenove S3 yet. */
931
+ board: import_zod9.z.string().max(40).optional(),
932
+ /** dBm, negative. -50 is across the room, -85 is a complaint. */
933
+ rssi: import_zod9.z.number().int().min(-127).max(0).optional(),
934
+ /** The board's address on its own network, as the board sees it. */
935
+ ip: import_zod9.z.string().max(45).optional(),
936
+ uptimeSeconds: import_zod9.z.number().int().nonnegative().optional(),
937
+ freeHeapBytes: import_zod9.z.number().int().nonnegative().optional(),
938
+ /**
939
+ * The revision the board is actually showing.
940
+ *
941
+ * Distinct from the revision that was sent, and the difference is the whole
942
+ * value: a send that was never drawn looks identical to a successful one until
943
+ * these two numbers disagree.
944
+ */
945
+ drewRevision: import_zod9.z.number().int().nonnegative().optional(),
946
+ /** Why it last restarted, if it says. A board power-cycling in a loop is a fault. */
947
+ resetReason: import_zod9.z.string().max(40).optional(),
948
+ /** When it last polled — finer-grained than a registration, for liveness only. */
949
+ lastPollAt: import_zod9.z.number().int().nonnegative().optional()
950
+ });
951
+ var DeviceSeenSchema = import_zod9.z.object({
952
+ /** When the board last asked for its app. The freshest signal this system has. */
953
+ lastPollAt: import_zod9.z.number().int().nonnegative(),
954
+ /** The revision it reported drawing at that moment. */
955
+ drewRevision: import_zod9.z.number().int().nonnegative().optional()
956
+ });
957
+ var DEVICE_VITALS_FIELDS = [
958
+ {
959
+ key: "firmwareVersion",
960
+ label: "Firmware",
961
+ source: "register",
962
+ reportedByFirmware: true,
963
+ note: 'A build stamped in by CI. Boards flashed before that report the marker "doc-1".'
964
+ },
965
+ { key: "board", label: "Board", source: "register", reportedByFirmware: true },
966
+ { key: "drewRevision", label: "Showing revision", source: "poll", reportedByFirmware: true },
967
+ { key: "rssi", label: "Wi-Fi signal", unit: "dBm", source: "register", reportedByFirmware: true },
968
+ { key: "ip", label: "Address on your network", source: "register", reportedByFirmware: true },
969
+ { key: "uptimeSeconds", label: "Uptime", unit: "s", source: "register", reportedByFirmware: true },
970
+ {
971
+ key: "freeHeapBytes",
972
+ label: "Free memory",
973
+ unit: "bytes",
974
+ source: "register",
975
+ reportedByFirmware: true
976
+ },
977
+ { key: "resetReason", label: "Last restart", source: "register", reportedByFirmware: true }
978
+ ];
979
+ var DEVICE_FRESH_MS = 7 * 60 * 60 * 1e3;
980
+ var DEVICE_STALE_MS = 30 * 24 * 60 * 60 * 1e3;
981
+
982
+ // src/apps/glyphs.ts
983
+ var DEVICE_UNKNOWN_GLYPH = "?";
984
+ var DEVICE_GLYPHS = {
985
+ // Accented Latin, CP437 0x80-0xA5 and 0xE1
986
+ "\xC7": { byte: 128, shows: "\xC7" },
987
+ "\xFC": { byte: 129, shows: "\xFC" },
988
+ "\xE9": { byte: 130, shows: "\xE9" },
989
+ "\xE2": { byte: 131, shows: "\xE2" },
990
+ "\xE4": { byte: 132, shows: "\xE4" },
991
+ "\xE0": { byte: 133, shows: "\xE0" },
992
+ "\xE5": { byte: 134, shows: "\xE5" },
993
+ "\xE7": { byte: 135, shows: "\xE7" },
994
+ "\xEA": { byte: 136, shows: "\xEA" },
995
+ "\xEB": { byte: 137, shows: "\xEB" },
996
+ "\xE8": { byte: 138, shows: "\xE8" },
997
+ "\xEF": { byte: 139, shows: "\xEF" },
998
+ "\xEE": { byte: 140, shows: "\xEE" },
999
+ "\xEC": { byte: 141, shows: "\xEC" },
1000
+ "\xC4": { byte: 142, shows: "\xC4" },
1001
+ "\xC5": { byte: 143, shows: "\xC5" },
1002
+ "\xC9": { byte: 144, shows: "\xC9" },
1003
+ "\xE6": { byte: 145, shows: "\xE6" },
1004
+ "\xC6": { byte: 146, shows: "\xC6" },
1005
+ "\xF4": { byte: 147, shows: "\xF4" },
1006
+ "\xF6": { byte: 148, shows: "\xF6" },
1007
+ "\xF2": { byte: 149, shows: "\xF2" },
1008
+ "\xFB": { byte: 150, shows: "\xFB" },
1009
+ "\xF9": { byte: 151, shows: "\xF9" },
1010
+ "\xFF": { byte: 152, shows: "\xFF" },
1011
+ "\xD6": { byte: 153, shows: "\xD6" },
1012
+ "\xDC": { byte: 154, shows: "\xDC" },
1013
+ "\xE1": { byte: 160, shows: "\xE1" },
1014
+ "\xED": { byte: 161, shows: "\xED" },
1015
+ "\xF3": { byte: 162, shows: "\xF3" },
1016
+ "\xFA": { byte: 163, shows: "\xFA" },
1017
+ "\xF1": { byte: 164, shows: "\xF1" },
1018
+ "\xD1": { byte: 165, shows: "\xD1" },
1019
+ "\xDF": { byte: 225, shows: "\xDF" },
1020
+ // Symbols a readout uses
1021
+ "\xA2": { byte: 155, shows: "\xA2" },
1022
+ "\xA3": { byte: 156, shows: "\xA3" },
1023
+ "\xA5": { byte: 157, shows: "\xA5" },
1024
+ "\u0192": { byte: 159, shows: "\u0192" },
1025
+ "\xAA": { byte: 166, shows: "\xAA" },
1026
+ "\xBA": { byte: 167, shows: "\xBA" },
1027
+ "\xBF": { byte: 168, shows: "\xBF" },
1028
+ "\xAC": { byte: 170, shows: "\xAC" },
1029
+ "\xBD": { byte: 171, shows: "\xBD" },
1030
+ "\xBC": { byte: 172, shows: "\xBC" },
1031
+ "\xA1": { byte: 173, shows: "\xA1" },
1032
+ "\xAB": { byte: 174, shows: "\xAB" },
1033
+ "\xBB": { byte: 175, shows: "\xBB" },
1034
+ "\u03C0": { byte: 227, shows: "\u03C0" },
1035
+ "\xB5": { byte: 230, shows: "\xB5" },
1036
+ "\u03A9": { byte: 234, shows: "\u03A9" },
1037
+ "\u221E": { byte: 236, shows: "\u221E" },
1038
+ "\xB1": { byte: 241, shows: "\xB1" },
1039
+ "\u2265": { byte: 242, shows: "\u2265" },
1040
+ "\u2264": { byte: 243, shows: "\u2264" },
1041
+ "\xF7": { byte: 246, shows: "\xF7" },
1042
+ "\u2248": { byte: 247, shows: "\u2248" },
1043
+ "\xB0": { byte: 248, shows: "\xB0" },
1044
+ "\xB7": { byte: 250, shows: "\xB7" },
1045
+ "\u221A": { byte: 251, shows: "\u221A" },
1046
+ "\xB2": { byte: 253, shows: "\xB2" },
1047
+ // Punctuation an AI writes without being asked, folded to ASCII
1048
+ "\u2018": { byte: 39, shows: "'" },
1049
+ "\u2019": { byte: 39, shows: "'" },
1050
+ "\u201C": { byte: 34, shows: '"' },
1051
+ "\u201D": { byte: 34, shows: '"' },
1052
+ "\u2013": { byte: 45, shows: "-" },
1053
+ "\u2014": { byte: 45, shows: "-" },
1054
+ "\u2212": { byte: 45, shows: "-" },
1055
+ "\xA0": { byte: 32, shows: " " }
1056
+ };
1057
+ var DEVICE_PALETTE = {
1058
+ background: "17 17 17",
1059
+ foreground: "238 238 238",
1060
+ muted: "153 153 153",
1061
+ accent: "23 162 184",
1062
+ success: "34 197 94",
1063
+ warning: "245 158 11",
1064
+ danger: "220 53 69"
1065
+ };
1066
+
1067
+ // src/apps/timezones.ts
1068
+ var DEVICE_TIMEZONES = [
1069
+ // North America
1070
+ { iana: "America/New_York", posix: "EST5EDT,M3.2.0,M11.1.0" },
1071
+ { iana: "America/Toronto", posix: "EST5EDT,M3.2.0,M11.1.0" },
1072
+ { iana: "America/Chicago", posix: "CST6CDT,M3.2.0,M11.1.0" },
1073
+ { iana: "America/Denver", posix: "MST7MDT,M3.2.0,M11.1.0" },
1074
+ { iana: "America/Phoenix", posix: "MST7" },
1075
+ { iana: "America/Los_Angeles", posix: "PST8PDT,M3.2.0,M11.1.0" },
1076
+ { iana: "America/Vancouver", posix: "PST8PDT,M3.2.0,M11.1.0" },
1077
+ { iana: "America/Anchorage", posix: "AKST9AKDT,M3.2.0,M11.1.0" },
1078
+ { iana: "Pacific/Honolulu", posix: "HST10" },
1079
+ { iana: "America/Mexico_City", posix: "CST6" },
1080
+ { iana: "America/Sao_Paulo", posix: "BRT3" },
1081
+ // Europe
1082
+ { iana: "Europe/London", posix: "GMT0BST,M3.5.0/1,M10.5.0" },
1083
+ { iana: "Europe/Dublin", posix: "GMT0IST,M3.5.0/1,M10.5.0" },
1084
+ { iana: "Europe/Lisbon", posix: "WET0WEST,M3.5.0/1,M10.5.0" },
1085
+ { iana: "Europe/Paris", posix: "CET-1CEST,M3.5.0,M10.5.0/3" },
1086
+ { iana: "Europe/Berlin", posix: "CET-1CEST,M3.5.0,M10.5.0/3" },
1087
+ { iana: "Europe/Madrid", posix: "CET-1CEST,M3.5.0,M10.5.0/3" },
1088
+ { iana: "Europe/Rome", posix: "CET-1CEST,M3.5.0,M10.5.0/3" },
1089
+ { iana: "Europe/Amsterdam", posix: "CET-1CEST,M3.5.0,M10.5.0/3" },
1090
+ { iana: "Europe/Stockholm", posix: "CET-1CEST,M3.5.0,M10.5.0/3" },
1091
+ { iana: "Europe/Warsaw", posix: "CET-1CEST,M3.5.0,M10.5.0/3" },
1092
+ { iana: "Europe/Zurich", posix: "CET-1CEST,M3.5.0,M10.5.0/3" },
1093
+ { iana: "Europe/Athens", posix: "EET-2EEST,M3.5.0/3,M10.5.0/4" },
1094
+ { iana: "Europe/Helsinki", posix: "EET-2EEST,M3.5.0/3,M10.5.0/4" },
1095
+ { iana: "Europe/Kyiv", posix: "EET-2EEST,M3.5.0/3,M10.5.0/4" },
1096
+ { iana: "Europe/Moscow", posix: "MSK-3" },
1097
+ // Asia and the Middle East
1098
+ { iana: "Asia/Jerusalem", posix: "IST-2IDT,M3.5.5/2,M10.5.0" },
1099
+ { iana: "Asia/Dubai", posix: "GST-4" },
1100
+ { iana: "Asia/Kolkata", posix: "IST-5:30" },
1101
+ { iana: "Asia/Bangkok", posix: "ICT-7" },
1102
+ { iana: "Asia/Shanghai", posix: "CST-8" },
1103
+ { iana: "Asia/Hong_Kong", posix: "HKT-8" },
1104
+ { iana: "Asia/Singapore", posix: "SGT-8" },
1105
+ { iana: "Asia/Tokyo", posix: "JST-9" },
1106
+ { iana: "Asia/Seoul", posix: "KST-9" },
1107
+ // Oceania
1108
+ { iana: "Australia/Perth", posix: "AWST-8" },
1109
+ { iana: "Australia/Brisbane", posix: "AEST-10" },
1110
+ { iana: "Australia/Adelaide", posix: "ACST-9:30ACDT,M10.1.0,M4.1.0/3" },
1111
+ { iana: "Australia/Sydney", posix: "AEST-10AEDT,M10.1.0,M4.1.0/3" },
1112
+ { iana: "Australia/Melbourne", posix: "AEST-10AEDT,M10.1.0,M4.1.0/3" },
1113
+ { iana: "Pacific/Auckland", posix: "NZST-12NZDT,M9.5.0,M4.1.0/3" },
1114
+ { iana: "UTC", posix: "UTC0" }
1115
+ ];
1116
+ var DEVICE_TIMEZONE_FALLBACK = "UTC0";
1117
+
1118
+ // src/ai/tools.ts
1119
+ var import_zod10 = require("zod");
1120
+ var telemetryGraphParameters = import_zod10.z.object({
1121
+ deviceId: import_zod10.z.string().min(1, "Device ID is required"),
1122
+ timeRange: import_zod10.z.enum(["1h", "24h", "7d"], {
519
1123
  errorMap: () => ({ message: "Time range must be 1h, 24h, or 7d" })
520
1124
  }),
521
- metrics: import_zod6.z.array(
522
- import_zod6.z.enum(["temperature", "humidity", "vwc", "ec", "ph", "pressure", "co2"])
1125
+ metrics: import_zod10.z.array(
1126
+ import_zod10.z.enum(["temperature", "humidity", "vwc", "ec", "ph", "pressure", "co2"])
523
1127
  ).min(1, "At least one metric is required").max(4, "Maximum 4 metrics per graph")
524
1128
  });
525
- var stockChartParameters = import_zod6.z.object({
526
- ticker: import_zod6.z.string().min(1).describe("The stock ticker symbol explicitly requested by the user. YOU MUST EXTRACT AND PROVIDE THIS (e.g., 'AAPL', 'MSFT')."),
527
- timeRange: import_zod6.z.enum(["1D", "1W", "1M", "1Y"], {
1129
+ var stockChartParameters = import_zod10.z.object({
1130
+ 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')."),
1131
+ timeRange: import_zod10.z.enum(["1D", "1W", "1M", "1Y"], {
528
1132
  errorMap: () => ({ message: "Time range must be 1D, 1W, 1M, or 1Y" })
529
1133
  }).describe("The time range for the chart. Choose based on user request or default to '1M'."),
530
- metrics: import_zod6.z.array(import_zod6.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.")
1134
+ 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.")
531
1135
  });
532
- var tickerParam = import_zod6.z.string().min(1).describe("The stock ticker symbol (e.g., 'AAPL', 'TSLA', 'MSFT').");
533
- var liveQuoteParameters = import_zod6.z.object({ ticker: tickerParam });
534
- var companyNewsParameters = import_zod6.z.object({ ticker: tickerParam });
535
- var companyProfileParameters = import_zod6.z.object({ ticker: tickerParam });
536
- var counterpartyGraphParameters = import_zod6.z.object({
1136
+ var tickerParam = import_zod10.z.string().min(1).describe("The stock ticker symbol (e.g., 'AAPL', 'TSLA', 'MSFT').");
1137
+ var liveQuoteParameters = import_zod10.z.object({ ticker: tickerParam });
1138
+ var companyNewsParameters = import_zod10.z.object({ ticker: tickerParam });
1139
+ var companyProfileParameters = import_zod10.z.object({ ticker: tickerParam });
1140
+ var counterpartyGraphParameters = import_zod10.z.object({
537
1141
  ticker: tickerParam,
538
- hops: import_zod6.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.")
1142
+ 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.")
539
1143
  });
540
- var divergenceMetricsParameters = import_zod6.z.object({ ticker: tickerParam });
541
- var architectureReferenceParameters = import_zod6.z.object({});
1144
+ var divergenceMetricsParameters = import_zod10.z.object({ ticker: tickerParam });
1145
+ var architectureReferenceParameters = import_zod10.z.object({});
542
1146
  var AI_TOOLS = {
543
1147
  get_telemetry_graph: {
544
1148
  name: "get_telemetry_graph",
@@ -586,6 +1190,16 @@ var AI_TOOLS = {
586
1190
  var DEFAULT_SCHEMA_MODEL = "gemini-2.5-flash";
587
1191
  var DEFAULT_CHAT_MODEL = "gemini-2.5-flash";
588
1192
  var DEFAULT_PRO_MODEL = "gemini-2.5-pro";
1193
+ var PROVIDER_DEFAULT_MODEL = {
1194
+ "google-gemini": "gemini-2.5-flash",
1195
+ "openai": "gpt-4o-mini",
1196
+ "anthropic": "claude-haiku-4-5-20251001",
1197
+ "grok": "grok-2-1212",
1198
+ "deepseek": "deepseek-chat",
1199
+ "ollama": "llama3.3"
1200
+ };
1201
+ var ASSISTANT_PROVIDER = "anthropic";
1202
+ var ASSISTANT_MODEL = PROVIDER_DEFAULT_MODEL[ASSISTANT_PROVIDER];
589
1203
  var AI_ROSTER = {
590
1204
  /** The Strategist: high creativity, exploratory conversation */
591
1205
  STRATEGIST: {
@@ -763,13 +1377,155 @@ RULE: If you cannot express a UI intent with a semantic token from the \u2705 li
763
1377
  use bg-card or bg-background as a safe fallback. NEVER invent raw colors.
764
1378
  `;
765
1379
 
1380
+ // src/ai/prompts/appDocument.prompt.ts
1381
+ var APP_DOCUMENT_SYSTEM_PROMPT = `
1382
+ You write tiny apps for a small desk device whose screen is 320 pixels wide and
1383
+ 240 pixels high \u2014 landscape.
1384
+
1385
+ Reply with ONE JSON object and nothing else. No markdown fences, no explanation.
1386
+
1387
+ THE SHAPE
1388
+
1389
+ {
1390
+ "schemaVersion": 1,
1391
+ "id": "lowercase-slug",
1392
+ "name": "Short Name",
1393
+ "screen": "320x240",
1394
+ "background": "background",
1395
+ "sources": { },
1396
+ "blocks": [ ]
1397
+ }
1398
+
1399
+ BLOCKS \u2014 up to 12, drawn top to bottom. Each is one of:
1400
+
1401
+ { "type": "text", "value": V, "size": S, "align": A, "color": C, "suffix": "\xB0" }
1402
+ { "type": "dial", "value": V, "min": 0, "max": 100, "label": "CPU", "color": C }
1403
+ { "type": "bar", "value": V, "min": 0, "max": 100, "color": C }
1404
+ { "type": "sparkline", "series": V, "color": C }
1405
+ { "type": "status", "state": V, "label": "Door", "color": C }
1406
+ { "type": "sprite", "palette": [C, ...], "grid": "0011
1407
+ 0110
1408
+ 1100
1409
+ 0011", "align": A }
1410
+ { "type": "group", "direction": "row"|"stack", "gap": 8, "align": A, "children": [ ...leaves... ] }
1411
+
1412
+ DRAWING A SPRITE \u2014 you may, and here is the only form that works.
1413
+
1414
+ Write a "grid": one line per row, one hex character per pixel, each character
1415
+ indexing "palette" (so "0" is the first colour, "1" the second, up to "f").
1416
+ Every row must be exactly the same length. Up to 64x64, but 16x16 and 32x32
1417
+ look far better \u2014 small palettes and bold shapes read on a 320x240 panel, fine
1418
+ detail does not.
1419
+
1420
+ { "type": "sprite",
1421
+ "palette": ["background", "255 214 10", "17 17 17"],
1422
+ "grid": "0011110
1423
+ 0122210
1424
+ 1222221
1425
+ 1211121
1426
+ 1222221
1427
+ 0122210
1428
+ 0011110" }
1429
+
1430
+ Put the background colour FIRST so "0" means empty, and use "." as a synonym
1431
+ for "0" if it makes the shape easier to see while you write it.
1432
+
1433
+ Palette entries are the same colours as everywhere else: a semantic token
1434
+ re-colours with the theme, which is what an icon wants, and literal "R G B"
1435
+ does not, which is what a picture wants.
1436
+
1437
+ NEVER write a "pixels" field yourself. That is base64 of packed nibbles, one
1438
+ wrong character shifts every pixel after it, and you cannot check it. Write the
1439
+ grid; it is converted for you. If a document you are editing already has
1440
+ "pixels" and no "grid", leave it exactly as it is.
1441
+
1442
+ PHOTOS \u2014 a document you are editing may hold { "type": "image", "asset": "<64 hex
1443
+ characters>", ... }. That is a picture someone uploaded, named by the hash of
1444
+ its file. Keep every image block exactly as it is unless asked to remove it, and
1445
+ never write one yourself: you cannot make the file it names, so any hash you
1446
+ invent draws nothing.
1447
+
1448
+ Count your rows before you answer. A grid whose rows are different lengths is
1449
+ the one mistake that will come back to you.
1450
+
1451
+ A group holds leaves only. Groups do NOT nest inside groups \u2014 the device has no
1452
+ layout engine, only computed offsets.
1453
+
1454
+ CONDITIONS \u2014 any block may also carry these:
1455
+
1456
+ "hideWhen": { "value": O, "op": "<", "than": 32 }
1457
+ leave it off the screen entirely while that is true
1458
+
1459
+ "rules": [ { "when": { "value": O, "op": "<", "than": 32 }, "color": "accent" },
1460
+ { "when": { "value": O, "op": ">", "than": 85 }, "color": "danger" } ]
1461
+ style that applies only when something is true. First match wins, so write
1462
+ the narrowest band first. At most four. Each may set "color", "size" or both.
1463
+
1464
+ op is one of "<" "<=" ">" ">=" "==" "!="
1465
+ Only == and != work on words; the rest are for numbers.
1466
+
1467
+ O is an operand: { "literal": 32 } or { "source": "forecast", "field": "temperature" }
1468
+
1469
+ This is how "make it red when it is freezing" is expressed. Use it whenever a
1470
+ request contains "when", "if", "unless", "only", or a colour tied to a value.
1471
+
1472
+ S (size) "xs" | "sm" | "base" | "lg" | "xl" | "display"
1473
+ A (align) "start" | "center" | "end"
1474
+ C (color) "background" | "foreground" | "muted" | "accent" | "success" | "warning" | "danger"
1475
+ or three space-separated RGB numbers, e.g. "220 53 69"
1476
+
1477
+ VALUES \u2014 every V is one of:
1478
+
1479
+ { "literal": "Hello" } text you wrote
1480
+ { "source": "forecast", "field": "temperature" } read from a source
1481
+ { "compute": "subtract", "of": [O, O], "round": true } arithmetic
1482
+
1483
+ compute is "add" | "subtract" | "multiply" | "divide", exactly two operands,
1484
+ and it does NOT nest \u2014 an operand is a literal or a source field, never
1485
+ another compute. "The difference between the high and the low" is the shape
1486
+ this is for.
1487
+
1488
+ SOURCES \u2014 declare what the app reads, then bind to it by name:
1489
+
1490
+ "forecast": { "kind": "weather", "latitude": 39.95, "longitude": -75.17,
1491
+ "units": "imperial", "refreshSeconds": 600 }
1492
+ fields: temperature, condition, high, low
1493
+ "now": { "kind": "clock", "timezone": "America/New_York", "twentyFourHour": false }
1494
+ fields: time, date, weekday, hour (hour is 0-23, for rules about time of day)
1495
+ "until": { "kind": "countdown", "target": "2026-12-25", "label": "Christmas" }
1496
+ fields: days, hours, minutes, seconds, label
1497
+ "fixed": { "kind": "static", "values": { "anything": 1 } }
1498
+ fields: whatever you put in values
1499
+ "turn": { "kind": "cycle", "count": 2, "minutes": 5 }
1500
+ fields: index (0, 1, \u2026 count-1, moving on every "minutes", then round again)
1501
+ For things that take turns: give each block "hideWhen": { "value":
1502
+ { "source": "turn", "field": "index" }, "op": "!=", "than": N } so only
1503
+ block N shows on turn N. The board changes at most once a minute.
1504
+
1505
+ RULES
1506
+
1507
+ 1. 320x240 is small, and it is wider than it is tall. A "display" size text is
1508
+ about 56 pixels tall \u2014 one of those and two or three smaller lines fill the
1509
+ height. Use the width: a "row" group puts two or three things side by side.
1510
+ Prefer fewer, bigger things over a dense dashboard.
1511
+ 2. Use semantic colours unless asked for a specific one. They follow the theme.
1512
+ 3. There is no scrolling and no text wrapping. Long strings are cut off.
1513
+ 4. No tables, no forms, no images, no buttons. The screen shows; it does not
1514
+ take input.
1515
+ 5. If the request needs something the vocabulary cannot express, build the
1516
+ closest thing it can and do not invent a component.
1517
+ 6. Prefer a rule over a fixed colour whenever the request ties appearance to a
1518
+ value. "Red when cold" is a rule; "red" is not.
1519
+ `.trim();
1520
+ var APP_DOCUMENT_EDIT_PREFIX = "Here is the current app. Change only what is asked:";
1521
+
766
1522
  // src/theme/schema.ts
767
- var import_zod7 = require("zod");
768
- var RGBString = import_zod7.z.string().regex(
1523
+ var import_zod11 = require("zod");
1524
+ var RGBString = import_zod11.z.string().regex(
769
1525
  /^\d{1,3}\s+\d{1,3}\s+\d{1,3}$/,
770
1526
  'Must be space-separated RGB integers (e.g. "13 110 253")'
771
1527
  );
772
- var ThemeOverridesSchema = import_zod7.z.object({
1528
+ var ThemeOverridesSchema = import_zod11.z.object({
773
1529
  // ── Core Brand ───────────────────────────────────────────────────────────
774
1530
  "--app-primary-color": RGBString.optional(),
775
1531
  "--app-primary-foreground-color": RGBString.optional(),
@@ -785,9 +1541,9 @@ var ThemeOverridesSchema = import_zod7.z.object({
785
1541
  "--app-muted-bg": RGBString.optional(),
786
1542
  "--app-muted-text": RGBString.optional(),
787
1543
  // ── Shape ────────────────────────────────────────────────────────────────
788
- "--app-border-radius-sm": import_zod7.z.string().optional(),
789
- "--app-border-radius-md": import_zod7.z.string().optional(),
790
- "--app-border-radius-lg": import_zod7.z.string().optional(),
1544
+ "--app-border-radius-sm": import_zod11.z.string().optional(),
1545
+ "--app-border-radius-md": import_zod11.z.string().optional(),
1546
+ "--app-border-radius-lg": import_zod11.z.string().optional(),
791
1547
  // ── Form Controls ────────────────────────────────────────────────────────
792
1548
  "--app-input-bg-color": RGBString.optional(),
793
1549
  "--app-input-text-color": RGBString.optional(),
@@ -801,19 +1557,19 @@ var ThemeOverridesSchema = import_zod7.z.object({
801
1557
  "--app-chart-4": RGBString.optional(),
802
1558
  "--app-chart-5": RGBString.optional()
803
1559
  }).strict();
804
- var ThemeFontsSchema = import_zod7.z.object({
1560
+ var ThemeFontsSchema = import_zod11.z.object({
805
1561
  /** Google Font name for headings (h1–h4, .font-serif). Example: "Playfair Display" */
806
- heading: import_zod7.z.string(),
1562
+ heading: import_zod11.z.string(),
807
1563
  /** Google Font name for body text. Example: "Inter" */
808
- body: import_zod7.z.string(),
1564
+ body: import_zod11.z.string(),
809
1565
  /** Optional monospace font. Example: "Roboto Mono" */
810
- mono: import_zod7.z.string().optional()
1566
+ mono: import_zod11.z.string().optional()
811
1567
  });
812
- var AIThemeSchema = import_zod7.z.object({
1568
+ var AIThemeSchema = import_zod11.z.object({
813
1569
  /** Short descriptive theme name. Example: "Midnight Garden" */
814
- name: import_zod7.z.string(),
1570
+ name: import_zod11.z.string(),
815
1571
  /** One-sentence vibe description. Example: "Dark indigo with golden accents." */
816
- description: import_zod7.z.string(),
1572
+ description: import_zod11.z.string(),
817
1573
  /** Google Font pairing for heading and body text. */
818
1574
  fonts: ThemeFontsSchema.optional(),
819
1575
  /**
@@ -824,13 +1580,13 @@ var AIThemeSchema = import_zod7.z.object({
824
1580
  cssVars: ThemeOverridesSchema
825
1581
  });
826
1582
  var THEME_PRESETS = ["light", "dark", "system", "corporate", "midnight", "blueprint"];
827
- var ThemeTokensSchema = import_zod7.z.object({
1583
+ var ThemeTokensSchema = import_zod11.z.object({
828
1584
  primary: RGBString,
829
1585
  neutral: RGBString,
830
1586
  success: RGBString,
831
1587
  warning: RGBString,
832
1588
  destructive: RGBString,
833
- radius: import_zod7.z.enum(["none", "sm", "md", "lg", "full"])
1589
+ radius: import_zod11.z.enum(["none", "sm", "md", "lg", "full"])
834
1590
  });
835
1591
  var DEFAULT_THEME_TOKENS = {
836
1592
  primary: "13 110 253",
@@ -842,22 +1598,101 @@ var DEFAULT_THEME_TOKENS = {
842
1598
  };
843
1599
 
844
1600
  // src/auth/schema.ts
845
- var import_zod8 = require("zod");
846
- var UserSchema = import_zod8.z.object({
847
- id: import_zod8.z.string().default(""),
848
- name: import_zod8.z.string(),
849
- email: import_zod8.z.string().email(),
850
- password: import_zod8.z.string().optional(),
851
- role: import_zod8.z.string(),
852
- status: import_zod8.z.string().optional(),
853
- joinedAt: import_zod8.z.string().optional(),
854
- lastActive: import_zod8.z.string().optional(),
855
- avatarUrl: import_zod8.z.string().optional()
1601
+ var import_zod12 = require("zod");
1602
+ var UserSchema = import_zod12.z.object({
1603
+ id: import_zod12.z.string().default(""),
1604
+ name: import_zod12.z.string(),
1605
+ email: import_zod12.z.string().email(),
1606
+ password: import_zod12.z.string().optional(),
1607
+ role: import_zod12.z.string(),
1608
+ status: import_zod12.z.string().optional(),
1609
+ joinedAt: import_zod12.z.string().optional(),
1610
+ lastActive: import_zod12.z.string().optional(),
1611
+ avatarUrl: import_zod12.z.string().optional()
856
1612
  });
857
1613
 
1614
+ // src/auth/accounts.ts
1615
+ var import_zod13 = require("zod");
1616
+ var AccountIdSchema = import_zod13.z.string().regex(/^acct_[0-9a-f]{12}$/, "acct_ and 12 hex digits");
1617
+ var AccountRoleSchema = import_zod13.z.enum(["member", "admin"]);
1618
+ var AccountStatusSchema = import_zod13.z.enum(["active", "suspended"]);
1619
+ var ScryptHashSchema = import_zod13.z.object({
1620
+ algo: import_zod13.z.literal("scrypt"),
1621
+ n: import_zod13.z.number().int().positive(),
1622
+ r: import_zod13.z.number().int().positive(),
1623
+ p: import_zod13.z.number().int().positive(),
1624
+ keylen: import_zod13.z.number().int().positive(),
1625
+ salt: import_zod13.z.string().min(16),
1626
+ hash: import_zod13.z.string().min(16)
1627
+ });
1628
+ var AccountRecordSchema = import_zod13.z.object({
1629
+ accountId: AccountIdSchema,
1630
+ /** Lowercased on write, because a login must not depend on how it was typed. */
1631
+ email: import_zod13.z.string().email().max(254),
1632
+ name: import_zod13.z.string().min(1).max(64),
1633
+ role: AccountRoleSchema,
1634
+ status: AccountStatusSchema,
1635
+ password: ScryptHashSchema,
1636
+ createdAt: import_zod13.z.number().int().nonnegative(),
1637
+ lastLoginAt: import_zod13.z.number().int().nonnegative().nullable().default(null),
1638
+ /** Which admin approved this, or null for the bootstrap account. */
1639
+ invitedBy: AccountIdSchema.nullable().default(null)
1640
+ });
1641
+ var PublicAccountSchema = import_zod13.z.object({
1642
+ accountId: AccountIdSchema,
1643
+ email: import_zod13.z.string().email(),
1644
+ name: import_zod13.z.string(),
1645
+ role: AccountRoleSchema,
1646
+ status: AccountStatusSchema
1647
+ });
1648
+ var SessionRecordSchema = import_zod13.z.object({
1649
+ accountId: AccountIdSchema,
1650
+ createdAt: import_zod13.z.number().int().nonnegative(),
1651
+ expiresAt: import_zod13.z.number().int().nonnegative(),
1652
+ lastSeenAt: import_zod13.z.number().int().nonnegative()
1653
+ });
1654
+ var InviteRecordSchema = import_zod13.z.object({
1655
+ email: import_zod13.z.string().email().max(254),
1656
+ role: AccountRoleSchema,
1657
+ createdAt: import_zod13.z.number().int().nonnegative(),
1658
+ expiresAt: import_zod13.z.number().int().nonnegative(),
1659
+ invitedBy: AccountIdSchema
1660
+ });
1661
+ var AccessRequestSchema = import_zod13.z.object({
1662
+ email: import_zod13.z.string().email().max(254),
1663
+ name: import_zod13.z.string().min(1).max(64),
1664
+ /** Optional, and never shown publicly. Long enough to be useful, short enough not to be an essay. */
1665
+ reason: import_zod13.z.string().max(500).optional()
1666
+ });
1667
+ var AccessRequestStatusSchema = import_zod13.z.enum(["pending", "approved", "denied"]);
1668
+ var AccessRequestRecordSchema = import_zod13.z.object({
1669
+ requestId: import_zod13.z.string().regex(/^req_[0-9a-f]{12}$/, "req_ and 12 hex digits"),
1670
+ email: import_zod13.z.string().email().max(254),
1671
+ name: import_zod13.z.string().min(1).max(64),
1672
+ reason: import_zod13.z.string().max(500).optional(),
1673
+ status: AccessRequestStatusSchema,
1674
+ createdAt: import_zod13.z.number().int().nonnegative(),
1675
+ decidedAt: import_zod13.z.number().int().nonnegative().nullable().default(null),
1676
+ decidedBy: AccountIdSchema.nullable().default(null)
1677
+ });
1678
+ var SCRYPT_PARAMS = {
1679
+ n: 32768,
1680
+ r: 8,
1681
+ p: 1,
1682
+ keylen: 64,
1683
+ maxmem: 64 * 1024 * 1024
1684
+ };
1685
+ var MIN_PASSWORD_LENGTH = 12;
1686
+ var MAX_PASSWORD_LENGTH = 200;
1687
+ var SESSION_COOKIE_NAME = "ramme_session";
1688
+ var SESSION_TTL_SECONDS = 60 * 60 * 24 * 30;
1689
+ var ACCOUNT_TTL_SECONDS = 60 * 60 * 24 * 400;
1690
+ var INVITE_TTL_SECONDS = 60 * 60 * 24 * 14;
1691
+ var ACCESS_REQUEST_TTL_SECONDS = 60 * 60 * 24 * 90;
1692
+
858
1693
  // src/counterparty/schema.ts
859
- var import_zod9 = require("zod");
860
- var CounterpartyTypeSchema = import_zod9.z.enum([
1694
+ var import_zod14 = require("zod");
1695
+ var CounterpartyTypeSchema = import_zod14.z.enum([
861
1696
  "supplier",
862
1697
  "customer",
863
1698
  "partner",
@@ -865,28 +1700,28 @@ var CounterpartyTypeSchema = import_zod9.z.enum([
865
1700
  "regulator",
866
1701
  "unknown"
867
1702
  ]);
868
- var CounterpartyResolutionSchema = import_zod9.z.enum([
1703
+ var CounterpartyResolutionSchema = import_zod14.z.enum([
869
1704
  "public",
870
1705
  "public_uncovered",
871
1706
  "private",
872
1707
  "unresolved"
873
1708
  ]);
874
- var CounterpartyNodeSchema = import_zod9.z.object({
875
- id: import_zod9.z.string(),
876
- ticker: import_zod9.z.string().nullable(),
1709
+ var CounterpartyNodeSchema = import_zod14.z.object({
1710
+ id: import_zod14.z.string(),
1711
+ ticker: import_zod14.z.string().nullable(),
877
1712
  /** Name as it appeared in the source signal — e.g. "Nike". Not the registered name. */
878
- name: import_zod9.z.string(),
1713
+ name: import_zod14.z.string(),
879
1714
  /** Registered legal name from `profiles` — e.g. "NIKE, Inc.". Null unless `public`. */
880
- publicName: import_zod9.z.string().nullable(),
881
- lei: import_zod9.z.string().nullable(),
1715
+ publicName: import_zod14.z.string().nullable(),
1716
+ lei: import_zod14.z.string().nullable(),
882
1717
  resolution: CounterpartyResolutionSchema,
883
1718
  type: CounterpartyTypeSchema,
884
- confidence: import_zod9.z.number().min(0).max(1),
885
- sourceSignalIds: import_zod9.z.array(import_zod9.z.number()),
886
- firstSeenAt: import_zod9.z.string().datetime(),
887
- lastSeenAt: import_zod9.z.string().datetime()
1719
+ confidence: import_zod14.z.number().min(0).max(1),
1720
+ sourceSignalIds: import_zod14.z.array(import_zod14.z.number()),
1721
+ firstSeenAt: import_zod14.z.string().datetime(),
1722
+ lastSeenAt: import_zod14.z.string().datetime()
888
1723
  });
889
- var RelationshipEdgeTypeSchema = import_zod9.z.enum([
1724
+ var RelationshipEdgeTypeSchema = import_zod14.z.enum([
890
1725
  "supplies_to",
891
1726
  "purchases_from",
892
1727
  "partners_with",
@@ -904,127 +1739,127 @@ var RelationshipEdgeTypeSchema = import_zod9.z.enum([
904
1739
  */
905
1740
  "same_as"
906
1741
  ]);
907
- var RelationshipEdgeSchema = import_zod9.z.object({
908
- id: import_zod9.z.string(),
909
- sourceId: import_zod9.z.string(),
910
- targetId: import_zod9.z.string(),
1742
+ var RelationshipEdgeSchema = import_zod14.z.object({
1743
+ id: import_zod14.z.string(),
1744
+ sourceId: import_zod14.z.string(),
1745
+ targetId: import_zod14.z.string(),
911
1746
  edgeType: RelationshipEdgeTypeSchema,
912
- weight: import_zod9.z.number().min(0).max(1),
913
- evidenceSignalIds: import_zod9.z.array(import_zod9.z.number()),
914
- updatedAt: import_zod9.z.string().datetime(),
915
- validFrom: import_zod9.z.string().datetime(),
1747
+ weight: import_zod14.z.number().min(0).max(1),
1748
+ evidenceSignalIds: import_zod14.z.array(import_zod14.z.number()),
1749
+ updatedAt: import_zod14.z.string().datetime(),
1750
+ validFrom: import_zod14.z.string().datetime(),
916
1751
  /** null = currently valid. Set when a differently-typed edge supersedes this one. */
917
- validTo: import_zod9.z.string().datetime().nullable()
1752
+ validTo: import_zod14.z.string().datetime().nullable()
918
1753
  });
919
- var SignalWeightSchema = import_zod9.z.object({
920
- signalId: import_zod9.z.number(),
921
- weight: import_zod9.z.number().min(0).max(1),
922
- reason: import_zod9.z.string().max(280)
1754
+ var SignalWeightSchema = import_zod14.z.object({
1755
+ signalId: import_zod14.z.number(),
1756
+ weight: import_zod14.z.number().min(0).max(1),
1757
+ reason: import_zod14.z.string().max(280)
923
1758
  });
924
- var DivergenceMetricSchema = import_zod9.z.object({
925
- ticker: import_zod9.z.string(),
1759
+ var DivergenceMetricSchema = import_zod14.z.object({
1760
+ ticker: import_zod14.z.string(),
926
1761
  // 'operations'/'customer' are current; 'operational'/'ux' are pre-rename
927
1762
  // values that still exist on rows written before the backend's rename —
928
1763
  // kept here so reading old rows doesn't fail validation.
929
- metric: import_zod9.z.enum(["operations", "customer", "operational", "ux"]),
930
- score: import_zod9.z.number(),
931
- baseline: import_zod9.z.number(),
932
- observed: import_zod9.z.number(),
933
- computedAt: import_zod9.z.string().datetime(),
934
- contributingSignals: import_zod9.z.array(SignalWeightSchema)
1764
+ metric: import_zod14.z.enum(["operations", "customer", "operational", "ux"]),
1765
+ score: import_zod14.z.number(),
1766
+ baseline: import_zod14.z.number(),
1767
+ observed: import_zod14.z.number(),
1768
+ computedAt: import_zod14.z.string().datetime(),
1769
+ contributingSignals: import_zod14.z.array(SignalWeightSchema)
935
1770
  });
936
1771
 
937
1772
  // src/non-public-entity/schema.ts
938
- var import_zod10 = require("zod");
939
- var NonPublicEntitySchema = import_zod10.z.object({
940
- lei: import_zod10.z.string().nullable(),
941
- entityName: import_zod10.z.string(),
942
- jurisdiction: import_zod10.z.string().nullable(),
943
- registrationStatus: import_zod10.z.string(),
944
- parentEntityLei: import_zod10.z.string().nullable(),
945
- materialMetadata: import_zod10.z.record(import_zod10.z.unknown()),
946
- discoveredAt: import_zod10.z.string().datetime()
1773
+ var import_zod15 = require("zod");
1774
+ var NonPublicEntitySchema = import_zod15.z.object({
1775
+ lei: import_zod15.z.string().nullable(),
1776
+ entityName: import_zod15.z.string(),
1777
+ jurisdiction: import_zod15.z.string().nullable(),
1778
+ registrationStatus: import_zod15.z.string(),
1779
+ parentEntityLei: import_zod15.z.string().nullable(),
1780
+ materialMetadata: import_zod15.z.record(import_zod15.z.unknown()),
1781
+ discoveredAt: import_zod15.z.string().datetime()
947
1782
  });
948
1783
 
949
1784
  // src/events/schema.ts
950
- var import_zod11 = require("zod");
951
- var EventSourceSchema = import_zod11.z.enum(["db", "mock"]);
952
- var EntityEventKindSchema = import_zod11.z.enum(["news", "filing", "report"]);
953
- var ImpactScaleSchema = import_zod11.z.enum(["graded", "binary", "default", "none"]);
954
- var TimestampPrecisionSchema = import_zod11.z.enum(["second", "day"]);
955
- var EntityEventSchema = import_zod11.z.object({
1785
+ var import_zod16 = require("zod");
1786
+ var EventSourceSchema = import_zod16.z.enum(["db", "mock"]);
1787
+ var EntityEventKindSchema = import_zod16.z.enum(["news", "filing", "report"]);
1788
+ var ImpactScaleSchema = import_zod16.z.enum(["graded", "binary", "default", "none"]);
1789
+ var TimestampPrecisionSchema = import_zod16.z.enum(["second", "day"]);
1790
+ var EntityEventSchema = import_zod16.z.object({
956
1791
  /** Namespaced so ids never collide across sources: `news:1234`, `filing:AAPL:2026-07-31`. */
957
- id: import_zod11.z.string(),
1792
+ id: import_zod16.z.string(),
958
1793
  kind: EntityEventKindSchema,
959
1794
  /**
960
1795
  * The producer's own type string, unmodified — `NEWS_YAHOO FINANCE_YAHOO RSS`,
961
1796
  * `ANNUAL`, `SNAPSHOT`. There are 31 distinct NEWS variants in the live table,
962
1797
  * so this is for filtering and debugging: never render it raw to a user.
963
1798
  */
964
- subtype: import_zod11.z.string().nullable(),
965
- ticker: import_zod11.z.string(),
1799
+ subtype: import_zod16.z.string().nullable(),
1800
+ ticker: import_zod16.z.string(),
966
1801
  /** Always `YYYY-MM-DDTHH:MM:SSZ`. Fixed-width, so lexical order == chronological order. */
967
- occurredAt: import_zod11.z.string(),
1802
+ occurredAt: import_zod16.z.string(),
968
1803
  precision: TimestampPrecisionSchema,
969
- title: import_zod11.z.string(),
970
- summary: import_zod11.z.string().nullable(),
971
- url: import_zod11.z.string().nullable(),
972
- impact: import_zod11.z.number().nullable(),
1804
+ title: import_zod16.z.string(),
1805
+ summary: import_zod16.z.string().nullable(),
1806
+ url: import_zod16.z.string().nullable(),
1807
+ impact: import_zod16.z.number().nullable(),
973
1808
  impactScale: ImpactScaleSchema,
974
1809
  /** 0 bearish … 50 neutral … 100 bullish. */
975
- sentiment: import_zod11.z.number().nullable(),
1810
+ sentiment: import_zod16.z.number().nullable(),
976
1811
  /** False for filings, and for any event sitting at exactly neutral. */
977
- sentimentIsMeaningful: import_zod11.z.boolean(),
1812
+ sentimentIsMeaningful: import_zod16.z.boolean(),
978
1813
  source: EventSourceSchema,
979
- meta: import_zod11.z.record(import_zod11.z.unknown()).nullable()
1814
+ meta: import_zod16.z.record(import_zod16.z.unknown()).nullable()
980
1815
  });
981
- var PaginatedEntityEventsSchema = import_zod11.z.object({
982
- total: import_zod11.z.number(),
983
- page: import_zod11.z.number(),
984
- page_size: import_zod11.z.number(),
985
- data: import_zod11.z.array(EntityEventSchema)
1816
+ var PaginatedEntityEventsSchema = import_zod16.z.object({
1817
+ total: import_zod16.z.number(),
1818
+ page: import_zod16.z.number(),
1819
+ page_size: import_zod16.z.number(),
1820
+ data: import_zod16.z.array(EntityEventSchema)
986
1821
  });
987
- var EventBucketSizeSchema = import_zod11.z.enum(["day", "week", "month"]);
988
- var EntityEventDensityBucketSchema = import_zod11.z.object({
989
- bucketStart: import_zod11.z.string(),
1822
+ var EventBucketSizeSchema = import_zod16.z.enum(["day", "week", "month"]);
1823
+ var EntityEventDensityBucketSchema = import_zod16.z.object({
1824
+ bucketStart: import_zod16.z.string(),
990
1825
  kind: EntityEventKindSchema,
991
- count: import_zod11.z.number(),
1826
+ count: import_zod16.z.number(),
992
1827
  /** Null when no event in the bucket had meaningful sentiment. */
993
- avgSentiment: import_zod11.z.number().nullable(),
994
- maxImpact: import_zod11.z.number().nullable()
1828
+ avgSentiment: import_zod16.z.number().nullable(),
1829
+ maxImpact: import_zod16.z.number().nullable()
995
1830
  });
996
- var EntityEventDensitySchema = import_zod11.z.object({
997
- ticker: import_zod11.z.string(),
1831
+ var EntityEventDensitySchema = import_zod16.z.object({
1832
+ ticker: import_zod16.z.string(),
998
1833
  bucket: EventBucketSizeSchema,
999
- buckets: import_zod11.z.array(EntityEventDensityBucketSchema),
1834
+ buckets: import_zod16.z.array(EntityEventDensityBucketSchema),
1000
1835
  /** So the client can set its time domain without a second request. */
1001
- range: import_zod11.z.object({ min: import_zod11.z.string(), max: import_zod11.z.string() }),
1836
+ range: import_zod16.z.object({ min: import_zod16.z.string(), max: import_zod16.z.string() }),
1002
1837
  source: EventSourceSchema
1003
1838
  });
1004
- var EntityEventFacetSchema = import_zod11.z.object({
1839
+ var EntityEventFacetSchema = import_zod16.z.object({
1005
1840
  kind: EntityEventKindSchema,
1006
- count: import_zod11.z.number(),
1007
- earliest: import_zod11.z.string().nullable(),
1008
- latest: import_zod11.z.string().nullable(),
1841
+ count: import_zod16.z.number(),
1842
+ earliest: import_zod16.z.string().nullable(),
1843
+ latest: import_zod16.z.string().nullable(),
1009
1844
  impactScale: ImpactScaleSchema,
1010
- sentimentUsable: import_zod11.z.boolean()
1845
+ sentimentUsable: import_zod16.z.boolean()
1011
1846
  });
1012
- var EntityEventFacetsSchema = import_zod11.z.object({
1013
- ticker: import_zod11.z.string(),
1014
- facets: import_zod11.z.array(EntityEventFacetSchema),
1847
+ var EntityEventFacetsSchema = import_zod16.z.object({
1848
+ ticker: import_zod16.z.string(),
1849
+ facets: import_zod16.z.array(EntityEventFacetSchema),
1015
1850
  source: EventSourceSchema
1016
1851
  });
1017
- var DailyPricePointSchema = import_zod11.z.object({
1018
- date: import_zod11.z.string(),
1019
- open: import_zod11.z.number().nullable(),
1020
- high: import_zod11.z.number().nullable(),
1021
- low: import_zod11.z.number().nullable(),
1022
- close: import_zod11.z.number(),
1023
- volume: import_zod11.z.number().nullable()
1024
- });
1025
- var EntityPriceSeriesSchema = import_zod11.z.object({
1026
- ticker: import_zod11.z.string(),
1027
- series: import_zod11.z.array(DailyPricePointSchema),
1852
+ var DailyPricePointSchema = import_zod16.z.object({
1853
+ date: import_zod16.z.string(),
1854
+ open: import_zod16.z.number().nullable(),
1855
+ high: import_zod16.z.number().nullable(),
1856
+ low: import_zod16.z.number().nullable(),
1857
+ close: import_zod16.z.number(),
1858
+ volume: import_zod16.z.number().nullable()
1859
+ });
1860
+ var EntityPriceSeriesSchema = import_zod16.z.object({
1861
+ ticker: import_zod16.z.string(),
1862
+ series: import_zod16.z.array(DailyPricePointSchema),
1028
1863
  source: EventSourceSchema
1029
1864
  });
1030
1865
  var EVENT_KIND_LABELS = {
@@ -1045,17 +1880,55 @@ var EXCLUDED_SOURCES = {
1045
1880
  };
1046
1881
  // Annotate the CommonJS export names for ESM import in node:
1047
1882
  0 && (module.exports = {
1883
+ ACCESS_REQUEST_TTL_SECONDS,
1884
+ ACCOUNT_TTL_SECONDS,
1048
1885
  AIKeyManifestSchema,
1049
1886
  AIThemeSchema,
1050
1887
  AI_ROSTER,
1051
1888
  AI_TOOLS,
1889
+ APP_DOCUMENT_EDIT_PREFIX,
1890
+ APP_DOCUMENT_SYSTEM_PROMPT,
1891
+ ASSISTANT_MODEL,
1892
+ ASSISTANT_PROVIDER,
1893
+ AccessRequestRecordSchema,
1894
+ AccessRequestSchema,
1895
+ AccessRequestStatusSchema,
1896
+ AccountIdSchema,
1897
+ AccountRecordSchema,
1898
+ AccountRoleSchema,
1899
+ AccountStatusSchema,
1052
1900
  ActionSchema,
1053
1901
  AircraftAppConfigSchema,
1902
+ AppAlignSchema,
1903
+ AppBarSchema,
1904
+ AppBindingSchema,
1905
+ AppBlockSchema,
1906
+ AppColorSchema,
1907
+ AppColorTokenSchema,
1908
+ AppComputeSchema,
1909
+ AppConditionSchema,
1910
+ AppDialSchema,
1911
+ AppDocumentSchema,
1912
+ AppGroupSchema,
1913
+ AppImageSchema,
1914
+ AppLeafSchema,
1915
+ AppOperandSchema,
1916
+ AppRgbSchema,
1917
+ AppScreenSizeSchema,
1054
1918
  AppSignalSchema,
1919
+ AppSourceSchema,
1920
+ AppSparklineSchema,
1055
1921
  AppSpecificationSchema,
1922
+ AppSpriteSchema,
1923
+ AppStatusSchema,
1924
+ AppStyleRuleSchema,
1925
+ AppTextSchema,
1926
+ AppTextSizeSchema,
1927
+ AssetHashSchema,
1056
1928
  AuthStrategySchema,
1057
1929
  BlockSchema,
1058
1930
  Bodewell,
1931
+ CLAIMED_DEVICE_TTL_SECONDS,
1059
1932
  ClockAppConfigSchema,
1060
1933
  CounterpartyNodeSchema,
1061
1934
  CounterpartyResolutionSchema,
@@ -1068,14 +1941,30 @@ var EXCLUDED_SOURCES = {
1068
1941
  DEFAULT_THEME_TOKENS,
1069
1942
  DEVICE_AP_SSID_PREFIX,
1070
1943
  DEVICE_ENDPOINTS,
1944
+ DEVICE_FRESH_MS,
1945
+ DEVICE_GLYPHS,
1946
+ DEVICE_LABEL_MAX,
1947
+ DEVICE_PALETTE,
1948
+ DEVICE_STALE_MS,
1949
+ DEVICE_TIMEZONES,
1950
+ DEVICE_TIMEZONE_FALLBACK,
1951
+ DEVICE_TTL_SECONDS,
1952
+ DEVICE_UNKNOWN_GLYPH,
1953
+ DEVICE_VITALS_FIELDS,
1071
1954
  DailyPricePointSchema,
1955
+ DeliveredAppSchema,
1072
1956
  DeviceAppIdSchema,
1073
1957
  DeviceAppsSchema,
1074
1958
  DeviceConfigSchema,
1075
1959
  DeviceDisplayConfigSchema,
1960
+ DeviceIdSchema,
1076
1961
  DeviceKindSchema,
1962
+ DeviceRecordSchema,
1963
+ DeviceRegistrationSchema,
1964
+ DeviceSeenSchema,
1077
1965
  DeviceStatusSchema,
1078
1966
  DeviceThemeSchema,
1967
+ DeviceVitalsSchema,
1079
1968
  DivergenceMetricSchema,
1080
1969
  EVENT_KIND_LABELS,
1081
1970
  EXCLUDED_SOURCES,
@@ -1093,22 +1982,50 @@ var EXCLUDED_SOURCES = {
1093
1982
  FloraTelemetrySchema,
1094
1983
  GENESIS_LIBRARY_CONTEXT,
1095
1984
  GENESIS_VALID_COMPONENTS,
1985
+ IMAGE_MAX_DRAWN,
1986
+ IMAGE_MAX_SCALE,
1096
1987
  IMPACT_FLAG_THRESHOLD,
1988
+ INVITE_TTL_SECONDS,
1097
1989
  ImpactScaleSchema,
1990
+ InviteRecordSchema,
1991
+ MAX_PASSWORD_LENGTH,
1992
+ MIN_PASSWORD_LENGTH,
1098
1993
  NonPublicEntitySchema,
1994
+ ORIGINAL_MAX_BYTES,
1995
+ ORIGINAL_MAX_SIDE,
1996
+ OwnedSendRequestSchema,
1997
+ PHOTOS_PER_ACCOUNT,
1998
+ PHOTO_UPLOADS_PER_HOUR,
1999
+ PROVIDER_DEFAULT_MODEL,
1099
2000
  PageSchema,
1100
2001
  PageSectionSchema,
1101
2002
  PaginatedEntityEventsSchema,
2003
+ PairCodeSchema,
2004
+ PhotoSummarySchema,
2005
+ PhotoUploadSchema,
1102
2006
  ProvisioningStateSchema,
2007
+ PublicAccountSchema,
2008
+ RETRO_RENDITION,
1103
2009
  RelationshipEdgeSchema,
1104
2010
  RelationshipEdgeTypeSchema,
1105
2011
  ResourceSchema,
2012
+ SCRYPT_PARAMS,
1106
2013
  SENTIMENT_NEUTRAL,
2014
+ SESSION_COOKIE_NAME,
2015
+ SESSION_TTL_SECONDS,
1107
2016
  SIGNAL_DOMAINS,
1108
2017
  SIGNAL_KINDS,
1109
2018
  SIGNAL_KIND_LABELS,
1110
2019
  SIGNAL_SOURCES,
2020
+ SPRITE_MAX_BASE64,
2021
+ SPRITE_MAX_ROW_BYTES,
2022
+ SPRITE_MAX_SIDE,
2023
+ SPR_FORMAT,
2024
+ SPR_MAX_BYTES,
2025
+ ScryptHashSchema,
2026
+ SendRequestSchema,
1111
2027
  SensorAppConfigSchema,
2028
+ SessionRecordSchema,
1112
2029
  SignalArraySchema,
1113
2030
  SignalKindSchema,
1114
2031
  SignalPacketSchema,
@@ -1123,6 +2040,7 @@ var EXCLUDED_SOURCES = {
1123
2040
  TimestampPrecisionSchema,
1124
2041
  TriggerSchema,
1125
2042
  UserSchema,
2043
+ VitalSourceSchema,
1126
2044
  WeatherAppConfigSchema,
1127
2045
  WorkflowSchema,
1128
2046
  architectureReferenceParameters,