camstack 1.2.202 → 1.2.204

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.
@@ -24024,9 +24024,9 @@ var require_zod = __commonJS({
24024
24024
  }
24025
24025
  });
24026
24026
 
24027
- // ../system/dist/dist-Dwi4JA96.js
24028
- var require_dist_Dwi4JA96 = __commonJS({
24029
- "../system/dist/dist-Dwi4JA96.js"(exports) {
24027
+ // ../system/dist/dist-l6zKmHEb.js
24028
+ var require_dist_l6zKmHEb = __commonJS({
24029
+ "../system/dist/dist-l6zKmHEb.js"(exports) {
24030
24030
  "use strict";
24031
24031
  var zod = require_zod();
24032
24032
  __require("crypto");
@@ -24110,6 +24110,8 @@ var require_dist_Dwi4JA96 = __commonJS({
24110
24110
  EventCategory2["PipelineCameraUnassigned"] = "pipeline.camera-unassigned";
24111
24111
  EventCategory2["PipelineNodeInferenceUnavailable"] = "pipeline.node-inference-unavailable";
24112
24112
  EventCategory2["PipelineDetectionBlind"] = "pipeline.detection-blind";
24113
+ EventCategory2["PipelineMotionNoisy"] = "pipeline.motion-noisy";
24114
+ EventCategory2["PipelineMotionCalm"] = "pipeline.motion-calm";
24113
24115
  EventCategory2["PipelineCameraUpdated"] = "pipeline.camera-updated";
24114
24116
  EventCategory2["PipelineIngestOwnerChanged"] = "pipeline.ingest-owner-changed";
24115
24117
  EventCategory2["PipelineRunnerLoadSnapshot"] = "pipeline.runner-load-snapshot";
@@ -26475,6 +26477,12 @@ var require_dist_Dwi4JA96 = __commonJS({
26475
26477
  this.name = "BatchTooLargeError";
26476
26478
  }
26477
26479
  };
26480
+ var TransactRefusedError = class extends RecordsError {
26481
+ constructor(detail) {
26482
+ super("transact-refused", detail);
26483
+ this.name = "TransactRefusedError";
26484
+ }
26485
+ };
26478
26486
  function defOf(schema) {
26479
26487
  const zodBag = Reflect.get(schema, "_zod");
26480
26488
  if (typeof zodBag !== "object" || zodBag === null) return {};
@@ -26655,7 +26663,7 @@ var require_dist_Dwi4JA96 = __commonJS({
26655
26663
  /** JSON Schema of the entry body; `secret: true` marks a password field. */
26656
26664
  fields: zod.z.record(zod.z.string(), zod.z.unknown())
26657
26665
  }).strict();
26658
- var RecordKindDeclarationSchema = zod.z.object({
26666
+ var RecordKindDeclarationShape = zod.z.object({
26659
26667
  database: zod.z.enum(RECORD_DATABASES).default("settings"),
26660
26668
  class: zod.z.enum(RECORD_CLASSES),
26661
26669
  writeTrigger: zod.z.string().min(1),
@@ -26673,18 +26681,12 @@ var require_dist_Dwi4JA96 = __commonJS({
26673
26681
  secretPaths: zod.z.array(zod.z.string().min(1)).default([]),
26674
26682
  /** The id key of each array that carries a secret (`{ headers: 'name' }`). */
26675
26683
  secretArrayKeys: zod.z.record(zod.z.string(), zod.z.string()).default({}),
26676
- /**
26677
- * RETIRED (D900): the legacy table a kind adopted from during the records
26678
- * migration. Nothing declares it any more and nothing reads it; the schema
26679
- * still ACCEPTS it because the catalog rows the migration wrote carry it
26680
- * (an orphaned kind is never redeclared) and an addon built before the
26681
- * removal still sends it. Never set it.
26682
- */
26683
- adoptsFrom: zod.z.string().min(1).optional(),
26684
26684
  /** Kinds that must agree through `transact` sit in one file under one family name. */
26685
26685
  transactFamily: zod.z.string().min(1).optional(),
26686
26686
  entry: EntryDescriptorSchema.optional()
26687
- }).strict();
26687
+ });
26688
+ var RecordKindDeclarationSchema = RecordKindDeclarationShape.strict();
26689
+ var StoredRecordKindDeclarationSchema = RecordKindDeclarationShape;
26688
26690
  var RecordKindNameSchema = zod.z.string().regex(/^[a-z][a-z0-9-]{0,47}$/);
26689
26691
  function assertValidDeclaration(name, decl) {
26690
26692
  const refuse = (why) => {
@@ -26762,6 +26764,16 @@ var require_dist_Dwi4JA96 = __commonJS({
26762
26764
  }
26763
26765
  return out;
26764
26766
  }
26767
+ function assertTransactScope(members) {
26768
+ const byKind = /* @__PURE__ */ new Map();
26769
+ for (const m of members) byKind.set(m.kind, m);
26770
+ const kinds = [...byKind.values()];
26771
+ if (new Set(kinds.map((m) => m.declaration.database)).size > 1) throw new TransactRefusedError(`cross-file: the ops span more than one database file (${kinds.map((m) => `${m.kind}@${m.declaration.database}`).join(", ")}); a transaction lives in ONE file`);
26772
+ if (kinds.length <= 1) return;
26773
+ const missing = kinds.filter((m) => m.declaration.transactFamily === void 0);
26774
+ if (missing.length > 0) throw new TransactRefusedError(`no-family: ${missing.map((m) => m.kind).join(", ")} declare no transactFamily; kinds that must agree through transact share one`);
26775
+ if (new Set(kinds.map((m) => m.declaration.transactFamily)).size > 1) throw new TransactRefusedError(`cross-family: the ops span more than one transactFamily (${kinds.map((m) => `${m.kind}=${String(m.declaration.transactFamily)}`).join(", ")})`);
26776
+ }
26765
26777
  var CamProfileSchema = zod.z.enum([
26766
26778
  "high",
26767
26779
  "mid",
@@ -31484,17 +31496,6 @@ var require_dist_Dwi4JA96 = __commonJS({
31484
31496
  createdAt: zod.z.number(),
31485
31497
  updatedAt: zod.z.number()
31486
31498
  });
31487
- var ApiKeyRecordSchema = zod.z.object({
31488
- id: zod.z.string(),
31489
- label: zod.z.string(),
31490
- isAdmin: zod.z.boolean().default(false),
31491
- allowedProviders: AllowedProviderSchema,
31492
- allowedDevices: AllowedDevicesSchema,
31493
- tokenHash: zod.z.string(),
31494
- tokenPrefix: zod.z.string(),
31495
- createdAt: zod.z.number(),
31496
- lastUsedAt: zod.z.number().optional()
31497
- });
31498
31499
  var ScopedTokenSchema = zod.z.object({
31499
31500
  id: zod.z.string(),
31500
31501
  userId: zod.z.string(),
@@ -36858,15 +36859,31 @@ var require_dist_Dwi4JA96 = __commonJS({
36858
36859
  var DeclareKindResultSchema = zod.z.object({
36859
36860
  kindId: zod.z.number().int(),
36860
36861
  state: RecordKindStateSchema,
36861
- createdIndexes: zod.z.array(zod.z.string()),
36862
- /**
36863
- * RETIRED (D900): always `null`. It carried the records-migration boot guard;
36864
- * it stays on the wire, null, because an addon built before the removal reads
36865
- * an ABSENT field as "adoption pending" and refuses to start.
36866
- */
36867
- adoptionPending: zod.z.null()
36862
+ createdIndexes: zod.z.array(zod.z.string())
36868
36863
  });
36869
36864
  var SecretRefsList = zod.z.array(zod.z.string());
36865
+ var RecordTransactOpSchema = zod.z.discriminatedUnion("op", [
36866
+ zod.z.object({
36867
+ op: zod.z.literal("put"),
36868
+ kind: RecordKindNameSchema,
36869
+ record: RecordInputSchema,
36870
+ ifRev: zod.z.number().int().min(0).optional()
36871
+ }),
36872
+ zod.z.object({
36873
+ op: zod.z.literal("patch"),
36874
+ kind: RecordKindNameSchema,
36875
+ id: RecordIdSchema,
36876
+ data: RecordBodySchema,
36877
+ at: zod.z.number().int().nullable().optional(),
36878
+ expiresAt: zod.z.number().int().nullable().optional(),
36879
+ ifRev: zod.z.number().int().min(1).optional()
36880
+ }),
36881
+ zod.z.object({
36882
+ op: zod.z.literal("delete"),
36883
+ kind: RecordKindNameSchema,
36884
+ id: RecordIdSchema
36885
+ })
36886
+ ]);
36870
36887
  var RecordSecretRefsSchema = zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.string()));
36871
36888
  var recordsCapability = {
36872
36889
  name: "records",
@@ -36998,6 +37015,22 @@ var require_dist_Dwi4JA96 = __commonJS({
36998
37015
  kind: "mutation",
36999
37016
  auth: "admin"
37000
37017
  }),
37018
+ /**
37019
+ * Several single-row writes (put / patch / delete) in ONE SQLite transaction:
37020
+ * all land or none does. Every op's kind must sit in one file and share one
37021
+ * `transactFamily` (`records/transact-refused` otherwise). Results are in op order.
37022
+ */
37023
+ transact: method(zod.z.object({ ops: zod.z.array(RecordTransactOpSchema).min(1).max(RECORD_BATCH_MAX) }), zod.z.object({
37024
+ results: zod.z.array(zod.z.object({
37025
+ rev: zod.z.number().int().nullable(),
37026
+ deleted: zod.z.boolean()
37027
+ })),
37028
+ releasedRefs: SecretRefsList,
37029
+ secretRefs: SecretRefsList
37030
+ }), {
37031
+ kind: "mutation",
37032
+ auth: "admin"
37033
+ }),
37001
37034
  /** The D865 hook body: every kind of this addon declared `deviceRemoval: 'delete'`. */
37002
37035
  deleteDevice: method(zod.z.object({
37003
37036
  deviceId: zod.z.number().int(),
@@ -63094,9 +63127,13 @@ var require_dist_Dwi4JA96 = __commonJS({
63094
63127
  "node-updating",
63095
63128
  "node-inference-unavailable",
63096
63129
  "detection-blind",
63130
+ "motion-noisy",
63131
+ "motion-calm",
63097
63132
  "recording-stalled",
63098
63133
  "recording-healthy",
63099
63134
  "recording-degraded",
63135
+ "device-attention-required",
63136
+ "device-attention-resolved",
63100
63137
  "storage-location-low",
63101
63138
  "storage-location-critical",
63102
63139
  "storage-location-ok",
@@ -68574,7 +68611,6 @@ var require_dist_Dwi4JA96 = __commonJS({
68574
68611
  modelId: zod.z.string()
68575
68612
  }),
68576
68613
  zod.z.object({ kind: zod.z.literal("cpu-device") }),
68577
- zod.z.object({ kind: zod.z.literal("coral-untouched") }),
68578
68614
  zod.z.object({ kind: zod.z.literal("device-disabled") }),
68579
68615
  zod.z.object({ kind: zod.z.literal("device-unavailable") }),
68580
68616
  zod.z.object({ kind: zod.z.literal("node-offline") }),
@@ -68667,11 +68703,6 @@ var require_dist_Dwi4JA96 = __commonJS({
68667
68703
  kind: zod.z.literal("detector-store-unreadable"),
68668
68704
  error: zod.z.string()
68669
68705
  }),
68670
- zod.z.object({
68671
- kind: zod.z.literal("coral-enabled"),
68672
- nodeId: zod.z.string(),
68673
- deviceKey: zod.z.string()
68674
- }),
68675
68706
  zod.z.object({
68676
68707
  kind: zod.z.literal("custom-pin-kept"),
68677
68708
  nodeId: zod.z.string(),
@@ -76537,6 +76568,16 @@ var require_dist_Dwi4JA96 = __commonJS({
76537
76568
  powerState: zod.z.string().nullable(),
76538
76569
  saltLevel: DishwasherConsumableLevelSchema.nullable(),
76539
76570
  rinseAidLevel: DishwasherConsumableLevelSchema.nullable(),
76571
+ /**
76572
+ * True while the appliance asks for its filter to be cleaned (smart-filter, filter-system or
76573
+ * combined care-and-filter reminder raised); false when every such reminder reads clear; null
76574
+ * when none is reported. A cleared reminder is not an unknown one.
76575
+ */
76576
+ filterCleaningDue: zod.z.boolean().nullable(),
76577
+ /** True while the machine-care (descaling / cleaning-program) reminder is raised; false when clear; null when not reported. */
76578
+ machineCareDue: zod.z.boolean().nullable(),
76579
+ /** Program runs left before the machine-care reminder is due; null when the appliance does not say. */
76580
+ machineCareRemainingRuns: zod.z.number().int().nonnegative().nullable(),
76540
76581
  /** Option states: null when the appliance does not expose the option or has not said. */
76541
76582
  halfLoad: zod.z.boolean().nullable(),
76542
76583
  hygienePlus: zod.z.boolean().nullable(),
@@ -84663,16 +84704,6 @@ var require_dist_Dwi4JA96 = __commonJS({
84663
84704
  allowedDevices: zod.z.record(zod.z.string(), zod.z.union([zod.z.array(zod.z.string()), zod.z.literal("*")])).optional(),
84664
84705
  scopes: zod.z.array(TokenScopeSchema).optional()
84665
84706
  });
84666
- var ApiKeySummarySchema = zod.z.object({
84667
- id: zod.z.string(),
84668
- label: zod.z.string(),
84669
- isAdmin: zod.z.boolean().default(false),
84670
- allowedProviders: zod.z.union([zod.z.array(zod.z.string()), zod.z.literal("*")]).optional(),
84671
- allowedDevices: zod.z.record(zod.z.string(), zod.z.union([zod.z.array(zod.z.string()), zod.z.literal("*")])).optional(),
84672
- tokenPrefix: zod.z.string(),
84673
- createdAt: zod.z.number(),
84674
- lastUsedAt: zod.z.number().optional()
84675
- });
84676
84707
  var OauthSessionSummarySchema = zod.z.object({
84677
84708
  id: zod.z.string(),
84678
84709
  userId: zod.z.string(),
@@ -84753,12 +84784,6 @@ var require_dist_Dwi4JA96 = __commonJS({
84753
84784
  kind: "mutation",
84754
84785
  access: "view"
84755
84786
  }),
84756
- listApiKeys: method(zod.z.void(), zod.z.array(ApiKeySummarySchema), { auth: "admin" }),
84757
- revokeApiKey: method(zod.z.object({ id: zod.z.string() }), zod.z.object({ success: zod.z.literal(true) }), {
84758
- kind: "mutation",
84759
- auth: "admin",
84760
- access: "delete"
84761
- }),
84762
84787
  setupTotp: method(zod.z.object({ userId: zod.z.string() }), TotpSetupResultSchema, {
84763
84788
  kind: "mutation",
84764
84789
  auth: "admin",
@@ -94106,6 +94131,12 @@ var require_dist_Dwi4JA96 = __commonJS({
94106
94131
  addonId: null,
94107
94132
  access: "view"
94108
94133
  },
94134
+ "records.transact": {
94135
+ capName: "records",
94136
+ capScope: "system",
94137
+ addonId: null,
94138
+ access: "create"
94139
+ },
94109
94140
  "sceneMonitor.captureReference": {
94110
94141
  capName: "scene-monitor",
94111
94142
  capScope: "device",
@@ -95438,12 +95469,6 @@ var require_dist_Dwi4JA96 = __commonJS({
95438
95469
  addonId: null,
95439
95470
  access: "view"
95440
95471
  },
95441
- "userManagement.listApiKeys": {
95442
- capName: "user-management",
95443
- capScope: "system",
95444
- addonId: null,
95445
- access: "view"
95446
- },
95447
95472
  "userManagement.listExternalIdentities": {
95448
95473
  capName: "user-management",
95449
95474
  capScope: "system",
@@ -95498,12 +95523,6 @@ var require_dist_Dwi4JA96 = __commonJS({
95498
95523
  addonId: null,
95499
95524
  access: "create"
95500
95525
  },
95501
- "userManagement.revokeApiKey": {
95502
- capName: "user-management",
95503
- capScope: "system",
95504
- addonId: null,
95505
- access: "delete"
95506
- },
95507
95526
  "userManagement.revokeOauthSession": {
95508
95527
  capName: "user-management",
95509
95528
  capScope: "system",
@@ -99702,9 +99721,13 @@ var require_dist_Dwi4JA96 = __commonJS({
99702
99721
  "stream-online": "device-events",
99703
99722
  "stream-offline": "device-events",
99704
99723
  "detection-blind": "device-events",
99724
+ "motion-noisy": "device-events",
99725
+ "motion-calm": "device-events",
99705
99726
  "recording-stalled": "device-events",
99706
99727
  "recording-healthy": "device-events",
99707
99728
  "recording-degraded": "device-events",
99729
+ "device-attention-required": "device-events",
99730
+ "device-attention-resolved": "device-events",
99708
99731
  "node-online": "system",
99709
99732
  "node-offline": "system",
99710
99733
  "node-restarting": "system",
@@ -99787,6 +99810,12 @@ var require_dist_Dwi4JA96 = __commonJS({
99787
99810
  label: "Detecting nothing",
99788
99811
  kinds: ["detection-blind"]
99789
99812
  },
99813
+ {
99814
+ id: "motion-noise",
99815
+ family: "device-events",
99816
+ label: "Motion without a subject",
99817
+ kinds: ["motion-noisy", "motion-calm"]
99818
+ },
99790
99819
  {
99791
99820
  id: "recording",
99792
99821
  family: "device-events",
@@ -99797,6 +99826,12 @@ var require_dist_Dwi4JA96 = __commonJS({
99797
99826
  "recording-degraded"
99798
99827
  ]
99799
99828
  },
99829
+ {
99830
+ id: "device-attention",
99831
+ family: "device-events",
99832
+ label: "Needs attention",
99833
+ kinds: ["device-attention-required", "device-attention-resolved"]
99834
+ },
99800
99835
  {
99801
99836
  id: "nodes",
99802
99837
  family: "system",
@@ -99948,6 +99983,7 @@ var require_dist_Dwi4JA96 = __commonJS({
99948
99983
  "alert-error",
99949
99984
  "alert-critical-resolved"
99950
99985
  ];
99986
+ var DEVICE_ATTENTION = ["device-attention-required", "device-attention-resolved"];
99951
99987
  var UPDATES = [
99952
99988
  "addon-update-available",
99953
99989
  "server-update-available",
@@ -99977,9 +100013,12 @@ var require_dist_Dwi4JA96 = __commonJS({
99977
100013
  "stream-online",
99978
100014
  "stream-offline",
99979
100015
  "detection-blind",
100016
+ "motion-noisy",
100017
+ "motion-calm",
99980
100018
  "recording-stalled",
99981
100019
  "recording-healthy",
99982
100020
  "recording-degraded",
100021
+ ...DEVICE_ATTENTION,
99983
100022
  ...ALARM
99984
100023
  ];
99985
100024
  var SUMMARISABLE = [...systemEventKindsOfFamily("device-events"), ...systemEventKindsOfFamily("system")];
@@ -100144,7 +100183,9 @@ var require_dist_Dwi4JA96 = __commonJS({
100144
100183
  [...RULE_TEXT],
100145
100184
  [...RULE_TEXT],
100146
100185
  [...RULE_TEXT],
100147
- ([...RULE_TEXT], [...ALERT_EPISODE]),
100186
+ [...RULE_TEXT],
100187
+ [...RULE_TEXT],
100188
+ ([...RULE_TEXT], [...DEVICE_ATTENTION, ...ALERT_EPISODE]),
100148
100189
  [...RULE_TEXT],
100149
100190
  [...RULE_TEXT],
100150
100191
  [...RULE_TEXT],
@@ -100166,11 +100207,11 @@ var require_dist_Dwi4JA96 = __commonJS({
100166
100207
  [...RULE_TEXT],
100167
100208
  [...RULE_TEXT],
100168
100209
  [...RULE_TEXT],
100210
+ ([...RULE_TEXT], [...DEVICE_ATTENTION, ...ALERT_EPISODE]),
100169
100211
  ([...RULE_TEXT], [...ALERT_EPISODE]),
100212
+ ([...RULE_TEXT], [...DEVICE_ATTENTION, ...ALERT_EPISODE]),
100170
100213
  ([...RULE_TEXT], [...ALERT_EPISODE]),
100171
- ([...RULE_TEXT], [...ALERT_EPISODE]),
100172
- ([...RULE_TEXT], [...ALERT_EPISODE]),
100173
- ([...RULE_TEXT], [...ALERT_EPISODE]),
100214
+ ([...RULE_TEXT], [...DEVICE_ATTENTION, ...ALERT_EPISODE]),
100174
100215
  [...RULE_TEXT],
100175
100216
  [...RULE_TEXT],
100176
100217
  [...RULE_TEXT],
@@ -100246,6 +100287,15 @@ var require_dist_Dwi4JA96 = __commonJS({
100246
100287
  snapshotLabel: "Tanks low or full now",
100247
100288
  snapshotSection: "tanks"
100248
100289
  },
100290
+ {
100291
+ id: "motion-noise",
100292
+ family: "device-events",
100293
+ label: "Motion without a subject (constant / calm again)",
100294
+ bad: ["motion-noisy"],
100295
+ recovery: ["motion-calm"],
100296
+ snapshotLabel: "Cameras with constant motion now",
100297
+ snapshotSection: null
100298
+ },
100249
100299
  {
100250
100300
  id: "recording-health",
100251
100301
  family: "device-events",
@@ -100255,6 +100305,15 @@ var require_dist_Dwi4JA96 = __commonJS({
100255
100305
  snapshotLabel: "Recordings stalled now",
100256
100306
  snapshotSection: null
100257
100307
  },
100308
+ {
100309
+ id: "device-attention",
100310
+ family: "device-events",
100311
+ label: "Device needs attention (raised / resolved)",
100312
+ bad: ["device-attention-required"],
100313
+ recovery: ["device-attention-resolved"],
100314
+ snapshotLabel: "Devices needing attention now",
100315
+ snapshotSection: null
100316
+ },
100258
100317
  {
100259
100318
  id: "node-connectivity",
100260
100319
  family: "system",
@@ -100899,12 +100958,6 @@ var require_dist_Dwi4JA96 = __commonJS({
100899
100958
  return AlertSchema;
100900
100959
  }
100901
100960
  });
100902
- Object.defineProperty(exports, "ApiKeyRecordSchema", {
100903
- enumerable: true,
100904
- get: function() {
100905
- return ApiKeyRecordSchema;
100906
- }
100907
- });
100908
100961
  Object.defineProperty(exports, "BaseAddon", {
100909
100962
  enumerable: true,
100910
100963
  get: function() {
@@ -101475,12 +101528,24 @@ var require_dist_Dwi4JA96 = __commonJS({
101475
101528
  return StorageMigrationJobSchema;
101476
101529
  }
101477
101530
  });
101531
+ Object.defineProperty(exports, "StoredRecordKindDeclarationSchema", {
101532
+ enumerable: true,
101533
+ get: function() {
101534
+ return StoredRecordKindDeclarationSchema;
101535
+ }
101536
+ });
101478
101537
  Object.defineProperty(exports, "TokenScopeSchema", {
101479
101538
  enumerable: true,
101480
101539
  get: function() {
101481
101540
  return TokenScopeSchema;
101482
101541
  }
101483
101542
  });
101543
+ Object.defineProperty(exports, "TransactRefusedError", {
101544
+ enumerable: true,
101545
+ get: function() {
101546
+ return TransactRefusedError;
101547
+ }
101548
+ });
101484
101549
  Object.defineProperty(exports, "UNATTRIBUTED_BUCKET_KEY", {
101485
101550
  enumerable: true,
101486
101551
  get: function() {
@@ -101571,6 +101636,12 @@ var require_dist_Dwi4JA96 = __commonJS({
101571
101636
  return asString$1;
101572
101637
  }
101573
101638
  });
101639
+ Object.defineProperty(exports, "assertTransactScope", {
101640
+ enumerable: true,
101641
+ get: function() {
101642
+ return assertTransactScope;
101643
+ }
101644
+ });
101574
101645
  Object.defineProperty(exports, "assertValidDeclaration", {
101575
101646
  enumerable: true,
101576
101647
  get: function() {
@@ -102636,40 +102707,6 @@ var require_dist_Dwi4JA96 = __commonJS({
102636
102707
  }
102637
102708
  });
102638
102709
 
102639
- // ../system/dist/read-all-rows-CVoO1ONM.js
102640
- var require_read_all_rows_CVoO1ONM = __commonJS({
102641
- "../system/dist/read-all-rows-CVoO1ONM.js"(exports) {
102642
- "use strict";
102643
- var require_read_all_rows = /* @__PURE__ */ require_chunk_Cek0wNdY().__commonJSMin(((exports2) => {
102644
- Object.defineProperty(exports2, "__esModule", { value: true });
102645
- exports2.readAllRows = readAllRows;
102646
- var PAGE_SIZE = 1e3;
102647
- var MAX_PAGES = 100;
102648
- async function readAllRows(kind, query = {}, options = {}) {
102649
- const out = [];
102650
- let cursor;
102651
- for (let page = 0; page < MAX_PAGES; page += 1) {
102652
- const answer = await kind.query({
102653
- ...query,
102654
- limit: PAGE_SIZE,
102655
- ...cursor === void 0 ? {} : { cursor }
102656
- }, options);
102657
- out.push(...answer.records);
102658
- if (answer.nextCursor === null) return out;
102659
- cursor = answer.nextCursor;
102660
- }
102661
- throw new Error(`record kind "${kind.name}" holds more than ${MAX_PAGES * PAGE_SIZE} rows`);
102662
- }
102663
- }));
102664
- Object.defineProperty(exports, "require_read_all_rows", {
102665
- enumerable: true,
102666
- get: function() {
102667
- return require_read_all_rows;
102668
- }
102669
- });
102670
- }
102671
- });
102672
-
102673
102710
  // ../system/dist/x509.es-C4cOo48M.js
102674
102711
  var require_x509_es_C4cOo48M = __commonJS({
102675
102712
  "../system/dist/x509.es-C4cOo48M.js"(exports) {
@@ -114141,11 +114178,11 @@ ${values.join("\n")}` : `${blockName} :`;
114141
114178
  }
114142
114179
  });
114143
114180
 
114144
- // ../system/dist/device-ca-B-Txwl4W.js
114145
- var require_device_ca_B_Txwl4W = __commonJS({
114146
- "../system/dist/device-ca-B-Txwl4W.js"(exports) {
114181
+ // ../system/dist/device-ca-CGcaSheI.js
114182
+ var require_device_ca_CGcaSheI = __commonJS({
114183
+ "../system/dist/device-ca-CGcaSheI.js"(exports) {
114147
114184
  "use strict";
114148
- var require_dist10 = require_dist_Dwi4JA96();
114185
+ var require_dist10 = require_dist_l6zKmHEb();
114149
114186
  var require_x509_es = require_x509_es_C4cOo48M();
114150
114187
  var node_crypto = __require("crypto");
114151
114188
  var SYSTEM_SECRET_OWNER = "system";
@@ -114560,6 +114597,40 @@ var require_device_ca_B_Txwl4W = __commonJS({
114560
114597
  }
114561
114598
  });
114562
114599
 
114600
+ // ../system/dist/read-all-rows-CVoO1ONM.js
114601
+ var require_read_all_rows_CVoO1ONM = __commonJS({
114602
+ "../system/dist/read-all-rows-CVoO1ONM.js"(exports) {
114603
+ "use strict";
114604
+ var require_read_all_rows = /* @__PURE__ */ require_chunk_Cek0wNdY().__commonJSMin(((exports2) => {
114605
+ Object.defineProperty(exports2, "__esModule", { value: true });
114606
+ exports2.readAllRows = readAllRows;
114607
+ var PAGE_SIZE = 1e3;
114608
+ var MAX_PAGES = 100;
114609
+ async function readAllRows(kind, query = {}, options = {}) {
114610
+ const out = [];
114611
+ let cursor;
114612
+ for (let page = 0; page < MAX_PAGES; page += 1) {
114613
+ const answer = await kind.query({
114614
+ ...query,
114615
+ limit: PAGE_SIZE,
114616
+ ...cursor === void 0 ? {} : { cursor }
114617
+ }, options);
114618
+ out.push(...answer.records);
114619
+ if (answer.nextCursor === null) return out;
114620
+ cursor = answer.nextCursor;
114621
+ }
114622
+ throw new Error(`record kind "${kind.name}" holds more than ${MAX_PAGES * PAGE_SIZE} rows`);
114623
+ }
114624
+ }));
114625
+ Object.defineProperty(exports, "require_read_all_rows", {
114626
+ enumerable: true,
114627
+ get: function() {
114628
+ return require_read_all_rows;
114629
+ }
114630
+ });
114631
+ }
114632
+ });
114633
+
114563
114634
  // ../system/dist/builtins/alerts/alerts.addon.js
114564
114635
  var require_alerts_addon = __commonJS({
114565
114636
  "../system/dist/builtins/alerts/alerts.addon.js"(exports) {
@@ -114569,7 +114640,7 @@ var require_alerts_addon = __commonJS({
114569
114640
  [Symbol.toStringTag]: { value: "Module" }
114570
114641
  });
114571
114642
  require_chunk_Cek0wNdY();
114572
- var require_dist10 = require_dist_Dwi4JA96();
114643
+ var require_dist10 = require_dist_l6zKmHEb();
114573
114644
  var require_read_all_rows$1 = require_read_all_rows_CVoO1ONM();
114574
114645
  function nextEpisodeId(input) {
114575
114646
  const { previous } = input;
@@ -116037,7 +116108,7 @@ var require_calendars_addon = __commonJS({
116037
116108
  [Symbol.toStringTag]: { value: "Module" }
116038
116109
  });
116039
116110
  require_chunk_Cek0wNdY();
116040
- var require_dist10 = require_dist_Dwi4JA96();
116111
+ var require_dist10 = require_dist_l6zKmHEb();
116041
116112
  var require_settle_sources = require_settle_sources_Bhsy57y();
116042
116113
  var zod = require_zod();
116043
116114
  var CALENDAR_COLOR_PALETTE = [
@@ -116253,11 +116324,11 @@ var require_calendars = __commonJS({
116253
116324
  }
116254
116325
  });
116255
116326
 
116256
- // ../system/dist/composition-sources-BG0E76VO.js
116257
- var require_composition_sources_BG0E76VO = __commonJS({
116258
- "../system/dist/composition-sources-BG0E76VO.js"(exports) {
116327
+ // ../system/dist/composition-sources-5rpWQhA1.js
116328
+ var require_composition_sources_5rpWQhA1 = __commonJS({
116329
+ "../system/dist/composition-sources-5rpWQhA1.js"(exports) {
116259
116330
  "use strict";
116260
- var require_dist10 = require_dist_Dwi4JA96();
116331
+ var require_dist10 = require_dist_l6zKmHEb();
116261
116332
  function normalizedNativeOwner(owner) {
116262
116333
  const trimmed = owner?.trim();
116263
116334
  return trimmed ? trimmed : null;
@@ -116372,8 +116443,8 @@ var require_composer_addon = __commonJS({
116372
116443
  [Symbol.toStringTag]: { value: "Module" }
116373
116444
  });
116374
116445
  require_chunk_Cek0wNdY();
116375
- var require_dist10 = require_dist_Dwi4JA96();
116376
- var require_composition_sources = require_composition_sources_BG0E76VO();
116446
+ var require_dist10 = require_dist_l6zKmHEb();
116447
+ var require_composition_sources = require_composition_sources_5rpWQhA1();
116377
116448
  var zod = require_zod();
116378
116449
  function isRecord$2(value) {
116379
116450
  return typeof value === "object" && value !== null && !Array.isArray(value);
@@ -120183,7 +120254,7 @@ var require_console_logging = __commonJS({
120183
120254
  [Symbol.toStringTag]: { value: "Module" }
120184
120255
  });
120185
120256
  require_chunk_Cek0wNdY();
120186
- var require_dist10 = require_dist_Dwi4JA96();
120257
+ var require_dist10 = require_dist_l6zKmHEb();
120187
120258
  var require_formatter = require_formatter_DqAKDlvN();
120188
120259
  var LEVEL_RANK = {
120189
120260
  debug: 0,
@@ -124847,9 +124918,9 @@ var require_core_blocks_addon = __commonJS({
124847
124918
  "use strict";
124848
124919
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
124849
124920
  var require_chunk = require_chunk_Cek0wNdY();
124850
- var require_dist10 = require_dist_Dwi4JA96();
124921
+ var require_dist10 = require_dist_l6zKmHEb();
124851
124922
  var require_read_all_rows$1 = require_read_all_rows_CVoO1ONM();
124852
- var require_composition_sources = require_composition_sources_BG0E76VO();
124923
+ var require_composition_sources = require_composition_sources_5rpWQhA1();
124853
124924
  var require_prefix_range = require_prefix_range_D_KueXbQ();
124854
124925
  var require_prefix_walk = require_prefix_walk_Dv6MLZlM();
124855
124926
  var zod = require_zod();
@@ -127047,9 +127118,9 @@ var require_core_blocks = __commonJS({
127047
127118
  }
127048
127119
  });
127049
127120
 
127050
- // ../types/dist/event-category-kpu1bZMs.js
127051
- var require_event_category_kpu1bZMs = __commonJS({
127052
- "../types/dist/event-category-kpu1bZMs.js"(exports) {
127121
+ // ../types/dist/event-category-7AwNbPjm.js
127122
+ var require_event_category_7AwNbPjm = __commonJS({
127123
+ "../types/dist/event-category-7AwNbPjm.js"(exports) {
127053
127124
  "use strict";
127054
127125
  var EventCategory = /* @__PURE__ */ (function(EventCategory2) {
127055
127126
  EventCategory2["SystemBoot"] = "system.boot";
@@ -127131,6 +127202,8 @@ var require_event_category_kpu1bZMs = __commonJS({
127131
127202
  EventCategory2["PipelineCameraUnassigned"] = "pipeline.camera-unassigned";
127132
127203
  EventCategory2["PipelineNodeInferenceUnavailable"] = "pipeline.node-inference-unavailable";
127133
127204
  EventCategory2["PipelineDetectionBlind"] = "pipeline.detection-blind";
127205
+ EventCategory2["PipelineMotionNoisy"] = "pipeline.motion-noisy";
127206
+ EventCategory2["PipelineMotionCalm"] = "pipeline.motion-calm";
127134
127207
  EventCategory2["PipelineCameraUpdated"] = "pipeline.camera-updated";
127135
127208
  EventCategory2["PipelineIngestOwnerChanged"] = "pipeline.ingest-owner-changed";
127136
127209
  EventCategory2["PipelineRunnerLoadSnapshot"] = "pipeline.runner-load-snapshot";
@@ -127254,11 +127327,11 @@ var require_event_category_kpu1bZMs = __commonJS({
127254
127327
  }
127255
127328
  });
127256
127329
 
127257
- // ../types/dist/sleep-Bo7fq491.js
127258
- var require_sleep_Bo7fq491 = __commonJS({
127259
- "../types/dist/sleep-Bo7fq491.js"(exports) {
127330
+ // ../types/dist/sleep-CD18m9HF.js
127331
+ var require_sleep_CD18m9HF = __commonJS({
127332
+ "../types/dist/sleep-CD18m9HF.js"(exports) {
127260
127333
  "use strict";
127261
- var require_event_category = require_event_category_kpu1bZMs();
127334
+ var require_event_category = require_event_category_7AwNbPjm();
127262
127335
  var zod = require_zod();
127263
127336
  var AUDIO_CHUNK_FORMATS = [
127264
127337
  "f32le",
@@ -129936,7 +130009,8 @@ var require_sleep_Bo7fq491 = __commonJS({
129936
130009
  "invalid-record",
129937
130010
  "declaration-refused",
129938
130011
  "no-caller",
129939
- "batch-too-large"
130012
+ "batch-too-large",
130013
+ "transact-refused"
129940
130014
  ];
129941
130015
  var PREFIX = "records/";
129942
130016
  var RecordsError = class extends Error {
@@ -130033,6 +130107,12 @@ var require_sleep_Bo7fq491 = __commonJS({
130033
130107
  this.name = "BatchTooLargeError";
130034
130108
  }
130035
130109
  };
130110
+ var TransactRefusedError = class extends RecordsError {
130111
+ constructor(detail) {
130112
+ super("transact-refused", detail);
130113
+ this.name = "TransactRefusedError";
130114
+ }
130115
+ };
130036
130116
  var FACTORIES = {
130037
130117
  "rev-conflict": (d) => new RevConflictError(d),
130038
130118
  "too-large": (d) => new RecordTooLargeError(d),
@@ -130047,7 +130127,8 @@ var require_sleep_Bo7fq491 = __commonJS({
130047
130127
  "invalid-record": (d) => new InvalidRecordError(d),
130048
130128
  "declaration-refused": (d) => new DeclarationRefusedError(d),
130049
130129
  "no-caller": (d) => new NoCallerError(d),
130050
- "batch-too-large": (d) => new BatchTooLargeError(d)
130130
+ "batch-too-large": (d) => new BatchTooLargeError(d),
130131
+ "transact-refused": (d) => new TransactRefusedError(d)
130051
130132
  };
130052
130133
  function isCode(value) {
130053
130134
  return RECORDS_ERROR_CODES.some((code) => code === value);
@@ -130250,7 +130331,7 @@ var require_sleep_Bo7fq491 = __commonJS({
130250
130331
  /** JSON Schema of the entry body; `secret: true` marks a password field. */
130251
130332
  fields: zod.z.record(zod.z.string(), zod.z.unknown())
130252
130333
  }).strict();
130253
- var RecordKindDeclarationSchema = zod.z.object({
130334
+ var RecordKindDeclarationShape = zod.z.object({
130254
130335
  database: zod.z.enum(RECORD_DATABASES).default("settings"),
130255
130336
  class: zod.z.enum(RECORD_CLASSES),
130256
130337
  writeTrigger: zod.z.string().min(1),
@@ -130268,18 +130349,12 @@ var require_sleep_Bo7fq491 = __commonJS({
130268
130349
  secretPaths: zod.z.array(zod.z.string().min(1)).default([]),
130269
130350
  /** The id key of each array that carries a secret (`{ headers: 'name' }`). */
130270
130351
  secretArrayKeys: zod.z.record(zod.z.string(), zod.z.string()).default({}),
130271
- /**
130272
- * RETIRED (D900): the legacy table a kind adopted from during the records
130273
- * migration. Nothing declares it any more and nothing reads it; the schema
130274
- * still ACCEPTS it because the catalog rows the migration wrote carry it
130275
- * (an orphaned kind is never redeclared) and an addon built before the
130276
- * removal still sends it. Never set it.
130277
- */
130278
- adoptsFrom: zod.z.string().min(1).optional(),
130279
130352
  /** Kinds that must agree through `transact` sit in one file under one family name. */
130280
130353
  transactFamily: zod.z.string().min(1).optional(),
130281
130354
  entry: EntryDescriptorSchema.optional()
130282
- }).strict();
130355
+ });
130356
+ var RecordKindDeclarationSchema = RecordKindDeclarationShape.strict();
130357
+ var StoredRecordKindDeclarationSchema = RecordKindDeclarationShape;
130283
130358
  var RecordKindNameSchema = zod.z.string().regex(/^[a-z][a-z0-9-]{0,47}$/);
130284
130359
  function assertValidDeclaration(name, decl) {
130285
130360
  const refuse = (why) => {
@@ -130360,6 +130435,16 @@ var require_sleep_Bo7fq491 = __commonJS({
130360
130435
  function declarationsOf(kinds) {
130361
130436
  return Object.fromEntries(Object.entries(kinds).map(([name, kind]) => [name, kind.declaration]));
130362
130437
  }
130438
+ function assertTransactScope(members) {
130439
+ const byKind = /* @__PURE__ */ new Map();
130440
+ for (const m of members) byKind.set(m.kind, m);
130441
+ const kinds = [...byKind.values()];
130442
+ if (new Set(kinds.map((m) => m.declaration.database)).size > 1) throw new TransactRefusedError(`cross-file: the ops span more than one database file (${kinds.map((m) => `${m.kind}@${m.declaration.database}`).join(", ")}); a transaction lives in ONE file`);
130443
+ if (kinds.length <= 1) return;
130444
+ const missing = kinds.filter((m) => m.declaration.transactFamily === void 0);
130445
+ if (missing.length > 0) throw new TransactRefusedError(`no-family: ${missing.map((m) => m.kind).join(", ")} declare no transactFamily; kinds that must agree through transact share one`);
130446
+ if (new Set(kinds.map((m) => m.declaration.transactFamily)).size > 1) throw new TransactRefusedError(`cross-family: the ops span more than one transactFamily (${kinds.map((m) => `${m.kind}=${String(m.declaration.transactFamily)}`).join(", ")})`);
130447
+ }
130363
130448
  function isRecord$2(value) {
130364
130449
  return typeof value === "object" && value !== null && !Array.isArray(value);
130365
130450
  }
@@ -130533,6 +130618,48 @@ var require_sleep_Bo7fq491 = __commonJS({
130533
130618
  };
130534
130619
  });
130535
130620
  }
130621
+ async txPut(input, opts = {}) {
130622
+ const checked = this.validate(input.data, input.id);
130623
+ const { body, rollback } = await this.storeSecrets(input.id, checked, "put");
130624
+ return {
130625
+ wire: {
130626
+ op: "put",
130627
+ kind: this.name,
130628
+ record: {
130629
+ ...input,
130630
+ data: toBody(body)
130631
+ },
130632
+ ...opts.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
130633
+ },
130634
+ rollback
130635
+ };
130636
+ }
130637
+ async txPatch(id, partial, opts = {}) {
130638
+ const { body, rollback } = await this.storeSecrets(id, partial, "patch");
130639
+ return {
130640
+ wire: {
130641
+ op: "patch",
130642
+ kind: this.name,
130643
+ id,
130644
+ data: toBody(body),
130645
+ ...opts.at === void 0 ? {} : { at: opts.at },
130646
+ ...opts.expiresAt === void 0 ? {} : { expiresAt: opts.expiresAt },
130647
+ ...opts.ifRev === void 0 ? {} : { ifRev: opts.ifRev }
130648
+ },
130649
+ rollback
130650
+ };
130651
+ }
130652
+ txDelete(id) {
130653
+ return {
130654
+ wire: {
130655
+ op: "delete",
130656
+ kind: this.name,
130657
+ id
130658
+ },
130659
+ rollback: async () => {
130660
+ }
130661
+ };
130662
+ }
130536
130663
  async put(input, opts = {}) {
130537
130664
  const checked = this.validate(input.data, input.id);
130538
130665
  const { body, rollback } = await this.storeSecrets(input.id, checked, "put");
@@ -130686,6 +130813,23 @@ var require_sleep_Bo7fq491 = __commonJS({
130686
130813
  handles.set(definition, handle);
130687
130814
  return handle;
130688
130815
  },
130816
+ async transact(ops) {
130817
+ if (ops.length === 0) return [];
130818
+ const result = await call(() => options.transport.transact({ ops: ops.map((op) => op.wire) })).catch(async (err) => {
130819
+ for (const op of ops) await op.rollback();
130820
+ throw err;
130821
+ });
130822
+ const released = [...result.releasedRefs, ...result.secretRefs];
130823
+ if (released.length > 0 && options.secrets !== null) try {
130824
+ await options.secrets.delete(released);
130825
+ } catch (err) {
130826
+ options.logger?.warn("records: could not remove released keychain values", { meta: {
130827
+ count: released.length,
130828
+ error: err instanceof Error ? err.message : "unknown"
130829
+ } });
130830
+ }
130831
+ return result.results;
130832
+ },
130689
130833
  async deleteDevice(deviceId, opts = {}) {
130690
130834
  const result = await call(() => options.transport.deleteDevice({
130691
130835
  deviceId,
@@ -131177,312 +131321,372 @@ var require_sleep_Bo7fq491 = __commonJS({
131177
131321
  secretRefs: refsOf(decl, gone)
131178
131322
  };
131179
131323
  };
131180
- return {
131181
- records: createRecordsAccess({
131182
- owner,
131183
- transport: {
131184
- declareKinds: async ({ kinds }) => {
131185
- const out = {};
131186
- for (const [name, raw] of Object.entries(kinds)) {
131187
- const decl = RecordKindDeclarationSchema.parse(raw);
131188
- assertValidDeclaration(name, decl);
131189
- const prior = decls.get(name);
131190
- if (prior !== void 0) assertAdditive(name, prior, decl);
131191
- const kindId = kindIds.get(name) ?? kindIds.size + 1;
131192
- kindIds.set(name, kindId);
131193
- const created = decl.indexes.filter((i) => prior?.indexes.every((p) => p.name !== i.name) ?? true).map((i) => i.name);
131194
- const state = prior === void 0 ? "created" : JSON.stringify(prior) === JSON.stringify(decl) ? "unchanged" : "updated";
131195
- decls.set(name, decl);
131196
- out[name] = {
131197
- kindId,
131198
- state,
131199
- createdIndexes: created,
131200
- adoptionPending: null
131201
- };
131202
- }
131203
- return { kinds: out };
131204
- },
131205
- get: async ({ kind, id }) => {
131206
- reading();
131207
- const decl = declOf(kind);
131208
- const row = table(kind).get(id);
131209
- return row === void 0 ? null : view(decl, row);
131210
- },
131211
- getMany: async ({ kind, ids }) => {
131212
- reading();
131213
- const decl = declOf(kind);
131214
- return [...new Set(ids)].sort((a, b) => compareSql(a, b)).flatMap((id) => {
131215
- const row = table(kind).get(id);
131216
- return row === void 0 ? [] : [view(decl, row)];
131217
- });
131218
- },
131219
- secretRefs: async ({ kind, ids }) => {
131220
- reading();
131221
- const decl = declOf(kind);
131222
- const out = {};
131223
- for (const id of ids) {
131224
- const row = table(kind).get(id);
131225
- if (row === void 0) continue;
131226
- const refs = Object.fromEntries(markersOf(decl, row.data));
131227
- if (Object.keys(refs).length > 0) out[id] = refs;
131228
- }
131229
- return out;
131230
- },
131231
- put: async ({ kind, record, ifRev }) => {
131232
- writing();
131233
- const written = writeRecord(kind, record, ifRev, now());
131234
- afterWrite(kind, [record.deviceId]);
131235
- return {
131236
- rev: written.rev,
131237
- releasedRefs: [...written.released]
131238
- };
131239
- },
131240
- putMany: async ({ kind, records }) => {
131241
- writing();
131242
- declOf(kind);
131243
- if (records.length > 1e3) throw new BatchTooLargeError(`${records.length} records exceed ${RECORD_BATCH_MAX}`);
131244
- const bytes = records.reduce((sum, r) => sum + Buffer.byteLength(JSON.stringify(r.data), "utf8"), 0);
131245
- if (bytes > 4194304) throw new BatchTooLargeError(`${bytes} bytes exceed ${RECORD_BATCH_MAX_BYTES}`);
131246
- const nowMs = now();
131247
- const before = new Map(table(kind));
131248
- const ridBefore = nextRid;
131249
- const released = [];
131250
- try {
131251
- for (const rec of records) released.push(...writeRecord(kind, rec, void 0, nowMs).released);
131252
- } catch (err) {
131253
- tables.set(kind, before);
131254
- nextRid = ridBefore;
131255
- throw err;
131324
+ const transport = {
131325
+ declareKinds: async ({ kinds }) => {
131326
+ const out = {};
131327
+ for (const [name, raw] of Object.entries(kinds)) {
131328
+ const decl = RecordKindDeclarationSchema.parse(raw);
131329
+ assertValidDeclaration(name, decl);
131330
+ const prior = decls.get(name);
131331
+ if (prior !== void 0) assertAdditive(name, prior, decl);
131332
+ const kindId = kindIds.get(name) ?? kindIds.size + 1;
131333
+ kindIds.set(name, kindId);
131334
+ const created = decl.indexes.filter((i) => prior?.indexes.every((p) => p.name !== i.name) ?? true).map((i) => i.name);
131335
+ const state = prior === void 0 ? "created" : JSON.stringify(prior) === JSON.stringify(decl) ? "unchanged" : "updated";
131336
+ decls.set(name, decl);
131337
+ out[name] = {
131338
+ kindId,
131339
+ state,
131340
+ createdIndexes: created
131341
+ };
131342
+ }
131343
+ return { kinds: out };
131344
+ },
131345
+ get: async ({ kind, id }) => {
131346
+ reading();
131347
+ const decl = declOf(kind);
131348
+ const row = table(kind).get(id);
131349
+ return row === void 0 ? null : view(decl, row);
131350
+ },
131351
+ getMany: async ({ kind, ids }) => {
131352
+ reading();
131353
+ const decl = declOf(kind);
131354
+ return [...new Set(ids)].sort((a, b) => compareSql(a, b)).flatMap((id) => {
131355
+ const row = table(kind).get(id);
131356
+ return row === void 0 ? [] : [view(decl, row)];
131357
+ });
131358
+ },
131359
+ secretRefs: async ({ kind, ids }) => {
131360
+ reading();
131361
+ const decl = declOf(kind);
131362
+ const out = {};
131363
+ for (const id of ids) {
131364
+ const row = table(kind).get(id);
131365
+ if (row === void 0) continue;
131366
+ const refs = Object.fromEntries(markersOf(decl, row.data));
131367
+ if (Object.keys(refs).length > 0) out[id] = refs;
131368
+ }
131369
+ return out;
131370
+ },
131371
+ put: async ({ kind, record, ifRev }) => {
131372
+ writing();
131373
+ const written = writeRecord(kind, record, ifRev, now());
131374
+ afterWrite(kind, [record.deviceId]);
131375
+ return {
131376
+ rev: written.rev,
131377
+ releasedRefs: [...written.released]
131378
+ };
131379
+ },
131380
+ putMany: async ({ kind, records }) => {
131381
+ writing();
131382
+ declOf(kind);
131383
+ if (records.length > 1e3) throw new BatchTooLargeError(`${records.length} records exceed ${RECORD_BATCH_MAX}`);
131384
+ const bytes = records.reduce((sum, r) => sum + Buffer.byteLength(JSON.stringify(r.data), "utf8"), 0);
131385
+ if (bytes > 4194304) throw new BatchTooLargeError(`${bytes} bytes exceed ${RECORD_BATCH_MAX_BYTES}`);
131386
+ const nowMs = now();
131387
+ const before = new Map(table(kind));
131388
+ const ridBefore = nextRid;
131389
+ const released = [];
131390
+ try {
131391
+ for (const rec of records) released.push(...writeRecord(kind, rec, void 0, nowMs).released);
131392
+ } catch (err) {
131393
+ tables.set(kind, before);
131394
+ nextRid = ridBefore;
131395
+ throw err;
131396
+ }
131397
+ let top = -1;
131398
+ for (const r of records) if (/^\d{1,15}$/.test(r.id)) top = Math.max(top, Number(r.id));
131399
+ if (top >= 0) sequences.set(kind, Math.max(sequences.get(kind) ?? 0, top + 1));
131400
+ afterWrite(kind, records.map((r) => r.deviceId));
131401
+ return {
131402
+ count: records.length,
131403
+ releasedRefs: released
131404
+ };
131405
+ },
131406
+ patch: async (input) => {
131407
+ writing();
131408
+ const decl = declOf(input.kind);
131409
+ if (input.at !== void 0 && decl.at !== "required") throw new InvalidRecordError(`${input.kind}: declared at: "none"`);
131410
+ if (input.at === null) throw new InvalidRecordError(`${input.kind}: "at" cannot be removed`);
131411
+ if (input.expiresAt !== void 0 && decl.secretPaths.length > 0) throw new InvalidRecordError(`${input.kind}: a kind with secret fields cannot expire by the engine (its keychain values would be orphaned)`);
131412
+ if (input.expiresAt !== void 0 && "ttlMs" in decl.retention) throw new InvalidRecordError(`${input.kind}: expiresAt is set by the engine`);
131413
+ const before = table(input.kind).get(input.id);
131414
+ const checked = enforceSecrets(owner, input.kind, decl, input.id, input.data, before?.data ?? null, "patch");
131415
+ if (before === void 0) throw new RecordNotFoundError(`${input.kind}/${input.id}: no such row`);
131416
+ if (input.ifRev !== void 0 && before.rev !== input.ifRev) throw new RevConflictError(`${input.kind}/${input.id}: expected rev ${String(input.ifRev)}, found rev ${before.rev}`);
131417
+ const merged = jsonCopy(mergePatch(before.data, jsonCopy(checked.body)));
131418
+ const size = [...JSON.stringify(merged)].length;
131419
+ if (size > decl.maxDataBytes) throw new RecordTooLargeError(`${input.kind}/${input.id}: the patched body is ${size} bytes, over maxDataBytes ${decl.maxDataBytes}`);
131420
+ assertUnique(input.kind, decl, input.id, merged);
131421
+ const rev = before.rev + 1;
131422
+ store2(input.kind, before, {
131423
+ ...before,
131424
+ at: input.at ?? before.at,
131425
+ expiresAt: input.expiresAt === void 0 ? before.expiresAt : input.expiresAt,
131426
+ rev,
131427
+ updatedAt: now(),
131428
+ data: merged
131429
+ });
131430
+ const kept = new Set(markersOf(decl, merged).values());
131431
+ return {
131432
+ rev,
131433
+ releasedRefs: [...markersOf(decl, before.data).values()].filter((r) => !kept.has(r))
131434
+ };
131435
+ },
131436
+ delete: async ({ kind, id }) => {
131437
+ writing();
131438
+ const decl = declOf(kind);
131439
+ const row = table(kind).get(id);
131440
+ if (row === void 0) return {
131441
+ deleted: false,
131442
+ secretRefs: []
131443
+ };
131444
+ table(kind).delete(id);
131445
+ return {
131446
+ deleted: true,
131447
+ secretRefs: refsOf(decl, [row])
131448
+ };
131449
+ },
131450
+ deleteMany: async ({ kind, ids }) => {
131451
+ writing();
131452
+ const wanted = new Set(ids);
131453
+ return removeWhere(kind, (row) => wanted.has(row.id));
131454
+ },
131455
+ query: async (q) => {
131456
+ reading();
131457
+ const decl = declOf(q.kind);
131458
+ queries.push({
131459
+ kind: q.kind,
131460
+ limit: q.limit
131461
+ });
131462
+ assertWindowAllowed(q.kind, decl, q);
131463
+ const desc = q.desc === true;
131464
+ const dir = desc ? "DESC" : "ASC";
131465
+ const where = planWhere(q.kind, decl, q.where, { allowIn: false });
131466
+ const cursor = q.cursor === void 0 ? void 0 : decodeCursor(q.cursor);
131467
+ let rows = [...table(q.kind).values()].filter((r) => inWindow(r, q));
131468
+ let keysOf;
131469
+ let keyCount;
131470
+ let tag;
131471
+ if (where !== null) {
131472
+ if (q.order !== void 0) throw new InvalidRecordError(`${q.kind}: with a where the order is the index's; drop "order"`);
131473
+ const fields = where.orderFields;
131474
+ keysOf = (row) => [...fields.map((f) => extractField(row.data, f)), row.rid];
131475
+ keyCount = fields.length;
131476
+ tag = `rx:${where.indexName}:${dir}`;
131477
+ rows = rows.filter((r) => where.matches(r.data));
131478
+ if (cursor !== void 0) {
131479
+ assertCursor(cursor, tag, fields.length + 1);
131480
+ rows = rows.filter((r) => rowValueAfter(keysOf(r), cursor.values, desc));
131481
+ }
131482
+ } else {
131483
+ const order = q.order ?? (decl.at === "required" ? "at" : "id");
131484
+ keyCount = 1;
131485
+ if (order === "at") {
131486
+ if (decl.at !== "required") throw new InvalidRecordError(`${q.kind}: declared at: "none", it has no time order - use order: "id"`);
131487
+ keysOf = (row) => [row.at, row.rid];
131488
+ tag = `at:${dir}`;
131489
+ if (cursor !== void 0) {
131490
+ assertCursor(cursor, tag, 2);
131491
+ rows = rows.filter((r) => rowValueAfter(keysOf(r), cursor.values, desc));
131256
131492
  }
131257
- let top = -1;
131258
- for (const r of records) if (/^\d{1,15}$/.test(r.id)) top = Math.max(top, Number(r.id));
131259
- if (top >= 0) sequences.set(kind, Math.max(sequences.get(kind) ?? 0, top + 1));
131260
- afterWrite(kind, records.map((r) => r.deviceId));
131261
- return {
131262
- count: records.length,
131263
- releasedRefs: released
131264
- };
131265
- },
131266
- patch: async (input) => {
131267
- writing();
131268
- const decl = declOf(input.kind);
131269
- if (input.at !== void 0 && decl.at !== "required") throw new InvalidRecordError(`${input.kind}: declared at: "none"`);
131270
- if (input.at === null) throw new InvalidRecordError(`${input.kind}: "at" cannot be removed`);
131271
- if (input.expiresAt !== void 0 && decl.secretPaths.length > 0) throw new InvalidRecordError(`${input.kind}: a kind with secret fields cannot expire by the engine (its keychain values would be orphaned)`);
131272
- if (input.expiresAt !== void 0 && "ttlMs" in decl.retention) throw new InvalidRecordError(`${input.kind}: expiresAt is set by the engine`);
131273
- const before = table(input.kind).get(input.id);
131274
- const checked = enforceSecrets(owner, input.kind, decl, input.id, input.data, before?.data ?? null, "patch");
131275
- if (before === void 0) throw new RecordNotFoundError(`${input.kind}/${input.id}: no such row`);
131276
- if (input.ifRev !== void 0 && before.rev !== input.ifRev) throw new RevConflictError(`${input.kind}/${input.id}: expected rev ${String(input.ifRev)}, found rev ${before.rev}`);
131277
- const merged = jsonCopy(mergePatch(before.data, jsonCopy(checked.body)));
131278
- const size = [...JSON.stringify(merged)].length;
131279
- if (size > decl.maxDataBytes) throw new RecordTooLargeError(`${input.kind}/${input.id}: the patched body is ${size} bytes, over maxDataBytes ${decl.maxDataBytes}`);
131280
- assertUnique(input.kind, decl, input.id, merged);
131281
- const rev = before.rev + 1;
131282
- store2(input.kind, before, {
131283
- ...before,
131284
- at: input.at ?? before.at,
131285
- expiresAt: input.expiresAt === void 0 ? before.expiresAt : input.expiresAt,
131286
- rev,
131287
- updatedAt: now(),
131288
- data: merged
131493
+ } else {
131494
+ if (q.deviceId !== void 0 || q.atFrom !== void 0 || q.atTo !== void 0) throw new UnindexedFilterError(`${q.kind}: order "id" cannot be combined with a device or time window (use order "at")`);
131495
+ keysOf = (row) => [row.id, row.rid];
131496
+ tag = `id:${dir}`;
131497
+ if (cursor !== void 0) {
131498
+ assertCursor(cursor, tag, 2);
131499
+ const last2 = cursor.values[0] ?? null;
131500
+ rows = rows.filter((r) => rowValueAfter([r.id], [last2], desc));
131501
+ }
131502
+ }
131503
+ }
131504
+ rows.sort((a, b) => (desc ? -1 : 1) * compareKeys(keysOf(a), keysOf(b)));
131505
+ const page = rows.slice(0, q.limit);
131506
+ const more = rows.length > q.limit;
131507
+ const last = page.at(-1);
131508
+ let nextCursor = null;
131509
+ if (more && last !== void 0) {
131510
+ const all = keysOf(last);
131511
+ const keys = [];
131512
+ for (let i = 0; i < keyCount; i += 1) {
131513
+ const value = all[i];
131514
+ if (typeof value !== "string" && typeof value !== "number") throw new InvalidRecordError(`${q.kind}: a row has no value for an ordering field, so this query cannot be paged`);
131515
+ keys.push(value);
131516
+ }
131517
+ keys.push(last.rid);
131518
+ nextCursor = encodeCursor(tag, keys);
131519
+ }
131520
+ return {
131521
+ records: page.map((r) => view(decl, r)),
131522
+ nextCursor
131523
+ };
131524
+ },
131525
+ count: async (q) => {
131526
+ reading();
131527
+ const decl = declOf(q.kind);
131528
+ assertWindowAllowed(q.kind, decl, q);
131529
+ const where = planWhere(q.kind, decl, q.where, { allowIn: true });
131530
+ let n = 0;
131531
+ for (const row of table(q.kind).values()) if (inWindow(row, q) && (where === null || where.matches(row.data))) n += 1;
131532
+ return { count: n };
131533
+ },
131534
+ histogram: async (q) => {
131535
+ reading();
131536
+ const decl = declOf(q.kind);
131537
+ assertWindowAllowed(q.kind, decl, {
131538
+ deviceId: q.deviceId,
131539
+ atFrom: q.from
131540
+ });
131541
+ if (!(q.to > q.from)) throw new InvalidRecordError(`${q.kind}: histogram needs from < to`);
131542
+ if (Math.ceil((q.to - q.from) / q.bucketMs) > 1e4) throw new InvalidRecordError(`${q.kind}: histogram would exceed ${HISTOGRAM_MAX_BUCKETS} buckets`);
131543
+ const from = Math.floor(q.from);
131544
+ const to = Math.ceil(q.to);
131545
+ const step = Math.trunc(q.bucketMs);
131546
+ const counts = /* @__PURE__ */ new Map();
131547
+ for (const row of table(q.kind).values()) {
131548
+ if (q.deviceId !== void 0 && row.deviceId !== q.deviceId) continue;
131549
+ if (row.at === null || row.at < from || row.at >= to) continue;
131550
+ const b = Math.trunc((row.at - from) / step);
131551
+ counts.set(b, (counts.get(b) ?? 0) + 1);
131552
+ }
131553
+ return { buckets: [...counts.entries()].sort(([a], [b]) => a - b).map(([b, count]) => ({
131554
+ bucketStart: from + b * q.bucketMs,
131555
+ count
131556
+ })) };
131557
+ },
131558
+ aggregate: async (q) => {
131559
+ reading();
131560
+ const decl = declOf(q.kind);
131561
+ if (q.op !== "count" && q.field === void 0) throw new InvalidRecordError(`${q.kind}: ${q.op} needs a field`);
131562
+ const extra = [q.field, q.groupBy].filter((f) => f !== void 0);
131563
+ if (extra.length === 0 && q.where === void 0) throw new InvalidRecordError(`${q.kind}: a count with no field and no groupBy is "count"`);
131564
+ const where = planWhere(q.kind, decl, q.where, {
131565
+ allowIn: true,
131566
+ extraFields: extra,
131567
+ groupBy: q.groupBy
131568
+ });
131569
+ if (where === null) throw new InvalidRecordError(`${q.kind}: aggregate has nothing to read`);
131570
+ const rows = [...table(q.kind).values()].filter((r) => where.matches(r.data));
131571
+ const groups = /* @__PURE__ */ new Map();
131572
+ if (q.groupBy === void 0) groups.set(null, rows);
131573
+ else {
131574
+ const by = q.groupBy;
131575
+ for (const row of rows) {
131576
+ const g = extractField(row.data, by);
131577
+ groups.set(g, [...groups.get(g) ?? [], row]);
131578
+ }
131579
+ }
131580
+ return { rows: [...groups.entries()].sort(([a], [b]) => compareSql(a, b)).map(([group, members]) => ({
131581
+ group,
131582
+ value: aggregateOf(q.op, q.field, members)
131583
+ })) };
131584
+ },
131585
+ deleteWhere: async (q) => {
131586
+ writing();
131587
+ const decl = declOf(q.kind);
131588
+ if (q.deviceId === void 0 && q.atBefore === void 0 && (q.where === void 0 || Object.keys(q.where).length === 0)) throw new FilterRequiredError(`${q.kind}: deleteWhere needs deviceId, atBefore or where - there is no "delete all"`);
131589
+ assertWindowAllowed(q.kind, decl, {
131590
+ deviceId: q.deviceId,
131591
+ atFrom: q.atBefore
131592
+ });
131593
+ const where = planWhere(q.kind, decl, q.where, { allowIn: true });
131594
+ return removeWhere(q.kind, (row) => {
131595
+ if (where !== null && !where.matches(row.data)) return false;
131596
+ if (q.deviceId !== void 0 && row.deviceId !== q.deviceId) return false;
131597
+ if (q.atBefore !== void 0 && (row.at === null || row.at >= q.atBefore)) return false;
131598
+ return true;
131599
+ });
131600
+ },
131601
+ transact: async ({ ops }) => {
131602
+ writing();
131603
+ assertTransactScope(ops.map((op) => ({
131604
+ kind: op.kind,
131605
+ declaration: declOf(op.kind)
131606
+ })));
131607
+ const before = new Map([...tables].map(([name, rows]) => [name, new Map(rows)]));
131608
+ const ridBefore = nextRid;
131609
+ const results = [];
131610
+ const releasedRefs = [];
131611
+ const secretRefs = [];
131612
+ try {
131613
+ for (const op of ops) if (op.op === "put") {
131614
+ const r = await transport.put({
131615
+ kind: op.kind,
131616
+ record: op.record,
131617
+ ...op.ifRev === void 0 ? {} : { ifRev: op.ifRev }
131289
131618
  });
131290
- const kept = new Set(markersOf(decl, merged).values());
131291
- return {
131292
- rev,
131293
- releasedRefs: [...markersOf(decl, before.data).values()].filter((r) => !kept.has(r))
131294
- };
131295
- },
131296
- delete: async ({ kind, id }) => {
131297
- writing();
131298
- const decl = declOf(kind);
131299
- const row = table(kind).get(id);
131300
- if (row === void 0) return {
131301
- deleted: false,
131302
- secretRefs: []
131303
- };
131304
- table(kind).delete(id);
131305
- return {
131306
- deleted: true,
131307
- secretRefs: refsOf(decl, [row])
131308
- };
131309
- },
131310
- deleteMany: async ({ kind, ids }) => {
131311
- writing();
131312
- const wanted = new Set(ids);
131313
- return removeWhere(kind, (row) => wanted.has(row.id));
131314
- },
131315
- query: async (q) => {
131316
- reading();
131317
- const decl = declOf(q.kind);
131318
- queries.push({
131319
- kind: q.kind,
131320
- limit: q.limit
131619
+ releasedRefs.push(...r.releasedRefs);
131620
+ results.push({
131621
+ rev: r.rev,
131622
+ deleted: false
131321
131623
  });
131322
- assertWindowAllowed(q.kind, decl, q);
131323
- const desc = q.desc === true;
131324
- const dir = desc ? "DESC" : "ASC";
131325
- const where = planWhere(q.kind, decl, q.where, { allowIn: false });
131326
- const cursor = q.cursor === void 0 ? void 0 : decodeCursor(q.cursor);
131327
- let rows = [...table(q.kind).values()].filter((r) => inWindow(r, q));
131328
- let keysOf;
131329
- let keyCount;
131330
- let tag;
131331
- if (where !== null) {
131332
- if (q.order !== void 0) throw new InvalidRecordError(`${q.kind}: with a where the order is the index's; drop "order"`);
131333
- const fields = where.orderFields;
131334
- keysOf = (row) => [...fields.map((f) => extractField(row.data, f)), row.rid];
131335
- keyCount = fields.length;
131336
- tag = `rx:${where.indexName}:${dir}`;
131337
- rows = rows.filter((r) => where.matches(r.data));
131338
- if (cursor !== void 0) {
131339
- assertCursor(cursor, tag, fields.length + 1);
131340
- rows = rows.filter((r) => rowValueAfter(keysOf(r), cursor.values, desc));
131341
- }
131342
- } else {
131343
- const order = q.order ?? (decl.at === "required" ? "at" : "id");
131344
- keyCount = 1;
131345
- if (order === "at") {
131346
- if (decl.at !== "required") throw new InvalidRecordError(`${q.kind}: declared at: "none", it has no time order - use order: "id"`);
131347
- keysOf = (row) => [row.at, row.rid];
131348
- tag = `at:${dir}`;
131349
- if (cursor !== void 0) {
131350
- assertCursor(cursor, tag, 2);
131351
- rows = rows.filter((r) => rowValueAfter(keysOf(r), cursor.values, desc));
131352
- }
131353
- } else {
131354
- if (q.deviceId !== void 0 || q.atFrom !== void 0 || q.atTo !== void 0) throw new UnindexedFilterError(`${q.kind}: order "id" cannot be combined with a device or time window (use order "at")`);
131355
- keysOf = (row) => [row.id, row.rid];
131356
- tag = `id:${dir}`;
131357
- if (cursor !== void 0) {
131358
- assertCursor(cursor, tag, 2);
131359
- const last2 = cursor.values[0] ?? null;
131360
- rows = rows.filter((r) => rowValueAfter([r.id], [last2], desc));
131361
- }
131362
- }
131363
- }
131364
- rows.sort((a, b) => (desc ? -1 : 1) * compareKeys(keysOf(a), keysOf(b)));
131365
- const page = rows.slice(0, q.limit);
131366
- const more = rows.length > q.limit;
131367
- const last = page.at(-1);
131368
- let nextCursor = null;
131369
- if (more && last !== void 0) {
131370
- const all = keysOf(last);
131371
- const keys = [];
131372
- for (let i = 0; i < keyCount; i += 1) {
131373
- const value = all[i];
131374
- if (typeof value !== "string" && typeof value !== "number") throw new InvalidRecordError(`${q.kind}: a row has no value for an ordering field, so this query cannot be paged`);
131375
- keys.push(value);
131376
- }
131377
- keys.push(last.rid);
131378
- nextCursor = encodeCursor(tag, keys);
131379
- }
131380
- return {
131381
- records: page.map((r) => view(decl, r)),
131382
- nextCursor
131383
- };
131384
- },
131385
- count: async (q) => {
131386
- reading();
131387
- const decl = declOf(q.kind);
131388
- assertWindowAllowed(q.kind, decl, q);
131389
- const where = planWhere(q.kind, decl, q.where, { allowIn: true });
131390
- let n = 0;
131391
- for (const row of table(q.kind).values()) if (inWindow(row, q) && (where === null || where.matches(row.data))) n += 1;
131392
- return { count: n };
131393
- },
131394
- histogram: async (q) => {
131395
- reading();
131396
- const decl = declOf(q.kind);
131397
- assertWindowAllowed(q.kind, decl, {
131398
- deviceId: q.deviceId,
131399
- atFrom: q.from
131624
+ } else if (op.op === "patch") {
131625
+ const r = await transport.patch({
131626
+ kind: op.kind,
131627
+ id: op.id,
131628
+ data: op.data,
131629
+ ...op.at === void 0 ? {} : { at: op.at },
131630
+ ...op.expiresAt === void 0 ? {} : { expiresAt: op.expiresAt },
131631
+ ...op.ifRev === void 0 ? {} : { ifRev: op.ifRev }
131400
131632
  });
131401
- if (!(q.to > q.from)) throw new InvalidRecordError(`${q.kind}: histogram needs from < to`);
131402
- if (Math.ceil((q.to - q.from) / q.bucketMs) > 1e4) throw new InvalidRecordError(`${q.kind}: histogram would exceed ${HISTOGRAM_MAX_BUCKETS} buckets`);
131403
- const from = Math.floor(q.from);
131404
- const to = Math.ceil(q.to);
131405
- const step = Math.trunc(q.bucketMs);
131406
- const counts = /* @__PURE__ */ new Map();
131407
- for (const row of table(q.kind).values()) {
131408
- if (q.deviceId !== void 0 && row.deviceId !== q.deviceId) continue;
131409
- if (row.at === null || row.at < from || row.at >= to) continue;
131410
- const b = Math.trunc((row.at - from) / step);
131411
- counts.set(b, (counts.get(b) ?? 0) + 1);
131412
- }
131413
- return { buckets: [...counts.entries()].sort(([a], [b]) => a - b).map(([b, count]) => ({
131414
- bucketStart: from + b * q.bucketMs,
131415
- count
131416
- })) };
131417
- },
131418
- aggregate: async (q) => {
131419
- reading();
131420
- const decl = declOf(q.kind);
131421
- if (q.op !== "count" && q.field === void 0) throw new InvalidRecordError(`${q.kind}: ${q.op} needs a field`);
131422
- const extra = [q.field, q.groupBy].filter((f) => f !== void 0);
131423
- if (extra.length === 0 && q.where === void 0) throw new InvalidRecordError(`${q.kind}: a count with no field and no groupBy is "count"`);
131424
- const where = planWhere(q.kind, decl, q.where, {
131425
- allowIn: true,
131426
- extraFields: extra,
131427
- groupBy: q.groupBy
131633
+ releasedRefs.push(...r.releasedRefs);
131634
+ results.push({
131635
+ rev: r.rev,
131636
+ deleted: false
131428
131637
  });
131429
- if (where === null) throw new InvalidRecordError(`${q.kind}: aggregate has nothing to read`);
131430
- const rows = [...table(q.kind).values()].filter((r) => where.matches(r.data));
131431
- const groups = /* @__PURE__ */ new Map();
131432
- if (q.groupBy === void 0) groups.set(null, rows);
131433
- else {
131434
- const by = q.groupBy;
131435
- for (const row of rows) {
131436
- const g = extractField(row.data, by);
131437
- groups.set(g, [...groups.get(g) ?? [], row]);
131438
- }
131439
- }
131440
- return { rows: [...groups.entries()].sort(([a], [b]) => compareSql(a, b)).map(([group, members]) => ({
131441
- group,
131442
- value: aggregateOf(q.op, q.field, members)
131443
- })) };
131444
- },
131445
- deleteWhere: async (q) => {
131446
- writing();
131447
- const decl = declOf(q.kind);
131448
- if (q.deviceId === void 0 && q.atBefore === void 0 && (q.where === void 0 || Object.keys(q.where).length === 0)) throw new FilterRequiredError(`${q.kind}: deleteWhere needs deviceId, atBefore or where - there is no "delete all"`);
131449
- assertWindowAllowed(q.kind, decl, {
131450
- deviceId: q.deviceId,
131451
- atFrom: q.atBefore
131638
+ } else {
131639
+ const r = await transport.delete({
131640
+ kind: op.kind,
131641
+ id: op.id
131452
131642
  });
131453
- const where = planWhere(q.kind, decl, q.where, { allowIn: true });
131454
- return removeWhere(q.kind, (row) => {
131455
- if (where !== null && !where.matches(row.data)) return false;
131456
- if (q.deviceId !== void 0 && row.deviceId !== q.deviceId) return false;
131457
- if (q.atBefore !== void 0 && (row.at === null || row.at >= q.atBefore)) return false;
131458
- return true;
131643
+ secretRefs.push(...r.secretRefs);
131644
+ results.push({
131645
+ rev: null,
131646
+ deleted: r.deleted
131459
131647
  });
131460
- },
131461
- deleteDevice: async ({ deviceId, kinds }) => {
131462
- writing();
131463
- const deleted = {};
131464
- const secretRefs = [];
131465
- for (const [kind, decl] of decls) {
131466
- if (decl.deviceRemoval !== "delete") continue;
131467
- if (kinds !== void 0 && !kinds.includes(kind)) continue;
131468
- const result = removeWhere(kind, (row) => row.deviceId === deviceId);
131469
- deleted[kind] = result.deleted;
131470
- secretRefs.push(...result.secretRefs);
131471
- }
131472
- return {
131473
- deleted,
131474
- secretRefs
131475
- };
131476
- },
131477
- allocateId: async ({ kind }) => {
131478
- writing();
131479
- declOf(kind);
131480
- const id = sequences.get(kind) ?? 1;
131481
- sequences.set(kind, id + 1);
131482
- pendingAllocated.add(`${kind}:${id}`);
131483
- return { id };
131484
131648
  }
131485
- },
131649
+ } catch (err) {
131650
+ tables.clear();
131651
+ for (const [name, rows] of before) tables.set(name, rows);
131652
+ nextRid = ridBefore;
131653
+ throw err;
131654
+ }
131655
+ return {
131656
+ results,
131657
+ releasedRefs,
131658
+ secretRefs
131659
+ };
131660
+ },
131661
+ deleteDevice: async ({ deviceId, kinds }) => {
131662
+ writing();
131663
+ const deleted = {};
131664
+ const secretRefs = [];
131665
+ for (const [kind, decl] of decls) {
131666
+ if (decl.deviceRemoval !== "delete") continue;
131667
+ if (kinds !== void 0 && !kinds.includes(kind)) continue;
131668
+ const result = removeWhere(kind, (row) => row.deviceId === deviceId);
131669
+ deleted[kind] = result.deleted;
131670
+ secretRefs.push(...result.secretRefs);
131671
+ }
131672
+ return {
131673
+ deleted,
131674
+ secretRefs
131675
+ };
131676
+ },
131677
+ allocateId: async ({ kind }) => {
131678
+ writing();
131679
+ declOf(kind);
131680
+ const id = sequences.get(kind) ?? 1;
131681
+ sequences.set(kind, id + 1);
131682
+ pendingAllocated.add(`${kind}:${id}`);
131683
+ return { id };
131684
+ }
131685
+ };
131686
+ return {
131687
+ records: createRecordsAccess({
131688
+ owner,
131689
+ transport,
131486
131690
  secrets: makeSpecKeychain(owner).access
131487
131691
  }),
131488
131692
  tables,
@@ -134507,6 +134711,12 @@ var require_sleep_Bo7fq491 = __commonJS({
134507
134711
  return SHARE_VIEW_KINDS;
134508
134712
  }
134509
134713
  });
134714
+ Object.defineProperty(exports, "StoredRecordKindDeclarationSchema", {
134715
+ enumerable: true,
134716
+ get: function() {
134717
+ return StoredRecordKindDeclarationSchema;
134718
+ }
134719
+ });
134510
134720
  Object.defineProperty(exports, "StreamSourceEntrySchema", {
134511
134721
  enumerable: true,
134512
134722
  get: function() {
@@ -134531,6 +134741,12 @@ var require_sleep_Bo7fq491 = __commonJS({
134531
134741
  return SubscribeAudioChunksResultSchema;
134532
134742
  }
134533
134743
  });
134744
+ Object.defineProperty(exports, "TransactRefusedError", {
134745
+ enumerable: true,
134746
+ get: function() {
134747
+ return TransactRefusedError;
134748
+ }
134749
+ });
134534
134750
  Object.defineProperty(exports, "UnindexedFilterError", {
134535
134751
  enumerable: true,
134536
134752
  get: function() {
@@ -134609,6 +134825,12 @@ var require_sleep_Bo7fq491 = __commonJS({
134609
134825
  return asString;
134610
134826
  }
134611
134827
  });
134828
+ Object.defineProperty(exports, "assertTransactScope", {
134829
+ enumerable: true,
134830
+ get: function() {
134831
+ return assertTransactScope;
134832
+ }
134833
+ });
134612
134834
  Object.defineProperty(exports, "assertValidDeclaration", {
134613
134835
  enumerable: true,
134614
134836
  get: function() {
@@ -135265,8 +135487,8 @@ var require_addon = __commonJS({
135265
135487
  "../types/dist/addon.js"(exports) {
135266
135488
  "use strict";
135267
135489
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
135268
- var require_sleep = require_sleep_Bo7fq491();
135269
- var require_event_category = require_event_category_kpu1bZMs();
135490
+ var require_sleep = require_sleep_CD18m9HF();
135491
+ var require_event_category = require_event_category_7AwNbPjm();
135270
135492
  var require_err_msg = require_err_msg_BhVbr0NX();
135271
135493
  var CAP_INPUT_DEFAULTS = Object.freeze({
135272
135494
  "addons": { "getLogs": { "limit": 100 } },
@@ -136282,6 +136504,18 @@ var require_addon = __commonJS({
136282
136504
  "empty"
136283
136505
  ]
136284
136506
  },
136507
+ {
136508
+ "path": "filterCleaningDue",
136509
+ "valueType": "boolean"
136510
+ },
136511
+ {
136512
+ "path": "machineCareDue",
136513
+ "valueType": "boolean"
136514
+ },
136515
+ {
136516
+ "path": "machineCareRemainingRuns",
136517
+ "valueType": "number"
136518
+ },
136285
136519
  {
136286
136520
  "path": "halfLoad",
136287
136521
  "valueType": "boolean"
@@ -137543,6 +137777,8 @@ var require_addon = __commonJS({
137543
137777
  exports.RevConflictError = require_sleep.RevConflictError;
137544
137778
  exports.SECRET_CLEAR = require_sleep.SECRET_CLEAR;
137545
137779
  exports.SECRET_REF_SCHEME = require_sleep.SECRET_REF_SCHEME;
137780
+ exports.StoredRecordKindDeclarationSchema = require_sleep.StoredRecordKindDeclarationSchema;
137781
+ exports.TransactRefusedError = require_sleep.TransactRefusedError;
137546
137782
  exports.UnindexedFilterError = require_sleep.UnindexedFilterError;
137547
137783
  exports.UnknownRecordKindError = require_sleep.UnknownRecordKindError;
137548
137784
  exports.addonSliceHandleApi = require_sleep.addonSliceHandleApi;
@@ -137551,6 +137787,7 @@ var require_addon = __commonJS({
137551
137787
  exports.asJsonObject = require_sleep.asJsonObject;
137552
137788
  exports.asRecordsError = require_sleep.asRecordsError;
137553
137789
  exports.asString = require_sleep.asString;
137790
+ exports.assertTransactScope = require_sleep.assertTransactScope;
137554
137791
  exports.assertValidDeclaration = require_sleep.assertValidDeclaration;
137555
137792
  exports.buildSecretRef = require_sleep.buildSecretRef;
137556
137793
  exports.classifySecretWrite = require_sleep.classifySecretWrite;
@@ -137908,7 +138145,7 @@ var require_device_manager_addon = __commonJS({
137908
138145
  [Symbol.toStringTag]: { value: "Module" }
137909
138146
  });
137910
138147
  require_chunk_Cek0wNdY();
137911
- var require_dist10 = require_dist_Dwi4JA96();
138148
+ var require_dist10 = require_dist_l6zKmHEb();
137912
138149
  var require_read_all_rows$1 = require_read_all_rows_CVoO1ONM();
137913
138150
  var require_prefix_range = require_prefix_range_D_KueXbQ();
137914
138151
  var require_prefix_walk = require_prefix_walk_Dv6MLZlM();
@@ -146980,7 +147217,7 @@ var require_hub_forwarder = __commonJS({
146980
147217
  [Symbol.toStringTag]: { value: "Module" }
146981
147218
  });
146982
147219
  require_chunk_Cek0wNdY();
146983
- var require_dist10 = require_dist_Dwi4JA96();
147220
+ var require_dist10 = require_dist_l6zKmHEb();
146984
147221
  var require_formatter = require_formatter_DqAKDlvN();
146985
147222
  var DEFAULT_OUTBOUND_BUFFER_SIZE = 500;
146986
147223
  var HubForwarderDestination = class {
@@ -147114,7 +147351,7 @@ var require_liveness_monitor_addon = __commonJS({
147114
147351
  "use strict";
147115
147352
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
147116
147353
  require_chunk_Cek0wNdY();
147117
- var require_dist10 = require_dist_Dwi4JA96();
147354
+ var require_dist10 = require_dist_l6zKmHEb();
147118
147355
  var NO_DEVICES = "liveness:no-devices";
147119
147356
  var ALL_OFFLINE = "liveness:all-devices-offline";
147120
147357
  var NO_FOOTAGE_PREFIX = "liveness:no-footage:";
@@ -147477,11 +147714,11 @@ var require_local_auth_addon = __commonJS({
147477
147714
  [Symbol.toStringTag]: { value: "Module" }
147478
147715
  });
147479
147716
  var require_chunk = require_chunk_Cek0wNdY();
147480
- var require_dist10 = require_dist_Dwi4JA96();
147481
- var require_read_all_rows$1 = require_read_all_rows_CVoO1ONM();
147717
+ var require_dist10 = require_dist_l6zKmHEb();
147482
147718
  var require_safe_buffer$1 = require_safe_buffer_D3aoa_7X();
147483
147719
  var require_ms$1 = require_ms_LB3giGoU();
147484
- var require_device_ca = require_device_ca_B_Txwl4W();
147720
+ var require_device_ca = require_device_ca_CGcaSheI();
147721
+ var require_read_all_rows$1 = require_read_all_rows_CVoO1ONM();
147485
147722
  var zod = require_zod();
147486
147723
  var node_crypto = __require("crypto");
147487
147724
  node_crypto = require_chunk.__toESM(node_crypto);
@@ -147491,75 +147728,6 @@ var require_local_auth_addon = __commonJS({
147491
147728
  node_path = require_chunk.__toESM(node_path);
147492
147729
  var node_fs = __require("fs");
147493
147730
  node_fs = require_chunk.__toESM(node_fs);
147494
- function parseRecord$2(kind, schema, data) {
147495
- try {
147496
- return schema.parse(data);
147497
- } catch (err) {
147498
- const topKeys = data && typeof data === "object" && !Array.isArray(data) ? Object.keys(data).join(", ") || "(empty)" : `(non-object: ${typeof data})`;
147499
- const detail = err instanceof Error ? err.message : String(err);
147500
- const hint = data && typeof data === "object" && !Array.isArray(data) && Object.keys(data).length === 1 && "data" in data ? " This shape is the legacy double-wrap from a stale settings-store query path. Restart the server with the latest @camstack/system build." : "";
147501
- throw new Error(`Failed to parse ${kind} from settings store. Top-level keys=[${topKeys}].${hint} Underlying: ${detail}`, { cause: err });
147502
- }
147503
- }
147504
- var import_read_all_rows = require_read_all_rows$1.require_read_all_rows();
147505
- var API_KEYS_COLLECTION$1 = "api_keys";
147506
- function parseApiKey(data) {
147507
- return parseRecord$2("api-key", require_dist10.ApiKeyRecordSchema, data);
147508
- }
147509
- function rowToApiKey(id, body) {
147510
- return parseApiKey({
147511
- id,
147512
- ...body
147513
- });
147514
- }
147515
- var ApiKeyManager = class {
147516
- kind;
147517
- legacyStore;
147518
- constructor(deps) {
147519
- if ("apiKeysKind" in deps) {
147520
- this.kind = deps.apiKeysKind;
147521
- this.legacyStore = deps.legacyStore ?? null;
147522
- } else {
147523
- this.kind = null;
147524
- this.legacyStore = deps.getStore();
147525
- }
147526
- }
147527
- get store() {
147528
- if (this.legacyStore === null) throw new Error("ApiKeyManager: legacy store unavailable on records-only path");
147529
- return this.legacyStore;
147530
- }
147531
- async listAll() {
147532
- const kind = this.kind;
147533
- return (kind !== null ? (await (0, import_read_all_rows.readAllRows)(kind)).map((row) => rowToApiKey(row.id, row.data)) : (await this.store.query.query({ collection: API_KEYS_COLLECTION$1 })).map((r2) => parseApiKey(r2.data))).map((parsed) => {
147534
- const { tokenHash: _th, ...rest } = parsed;
147535
- return rest;
147536
- });
147537
- }
147538
- async revoke(id) {
147539
- const kind = this.kind;
147540
- if (kind !== null) {
147541
- await kind.delete(id);
147542
- return;
147543
- }
147544
- await this.store.delete.mutate({
147545
- collection: API_KEYS_COLLECTION$1,
147546
- key: id
147547
- });
147548
- }
147549
- async findById(id) {
147550
- const kind = this.kind;
147551
- if (kind !== null) {
147552
- const row = await kind.get(id);
147553
- return row === null ? null : rowToApiKey(row.id, row.data);
147554
- }
147555
- const results = await this.store.query.query({
147556
- collection: API_KEYS_COLLECTION$1,
147557
- filter: { where: { id } }
147558
- });
147559
- if (results.length === 0) return null;
147560
- return parseApiKey(results[0].data);
147561
- }
147562
- };
147563
147731
  var randomFallback = null;
147564
147732
  function randomBytes$1(len) {
147565
147733
  try {
@@ -152264,6 +152432,7 @@ var require_local_auth_addon = __commonJS({
152264
152432
  }
152265
152433
  }
152266
152434
  };
152435
+ var import_read_all_rows = require_read_all_rows$1.require_read_all_rows();
152267
152436
  var AUTH_AUDIT_COLLECTION = "auth_audit";
152268
152437
  var AUTH_AUDIT_COLUMNS = [
152269
152438
  {
@@ -152312,7 +152481,7 @@ var require_local_auth_addon = __commonJS({
152312
152481
  ];
152313
152482
  var RETENTION_MS = 90 * 864e5;
152314
152483
  var MAX_LIST = 500;
152315
- function parseRecord$1(data) {
152484
+ function parseRecord$2(data) {
152316
152485
  const id = data["id"];
152317
152486
  const rawAt = data["at"];
152318
152487
  const at = typeof rawAt === "number" ? rawAt : typeof rawAt === "string" && rawAt.trim() !== "" && Number.isFinite(Number(rawAt)) ? Number(rawAt) : null;
@@ -152405,7 +152574,7 @@ var require_local_auth_addon = __commonJS({
152405
152574
  order: "at",
152406
152575
  desc: true,
152407
152576
  limit
152408
- })).records.map((row) => parseRecord$1({
152577
+ })).records.map((row) => parseRecord$2({
152409
152578
  id: row.id,
152410
152579
  at: row.at,
152411
152580
  action: row.data.action,
@@ -152416,7 +152585,7 @@ var require_local_auth_addon = __commonJS({
152416
152585
  return (await this.store.query.query({
152417
152586
  collection: AUTH_AUDIT_COLLECTION,
152418
152587
  ...input.userId !== void 0 ? { filter: { where: { userId: input.userId } } } : {}
152419
- })).map((row) => parseRecord$1(row.data)).filter((r2) => r2 !== null).toSorted((a2, b) => b.at - a2.at).slice(0, limit);
152588
+ })).map((row) => parseRecord$2(row.data)).filter((r2) => r2 !== null).toSorted((a2, b) => b.at - a2.at).slice(0, limit);
152420
152589
  }
152421
152590
  /** Delete rows older than 90 days. Returns how many. */
152422
152591
  async reap() {
@@ -152590,7 +152759,7 @@ var require_local_auth_addon = __commonJS({
152590
152759
  "web",
152591
152760
  "other"
152592
152761
  ];
152593
- function parseRecord(data) {
152762
+ function parseRecord$1(data) {
152594
152763
  const id = str$1(data, "id");
152595
152764
  const userId = str$1(data, "userId");
152596
152765
  const deviceName = str$1(data, "deviceName");
@@ -152655,7 +152824,7 @@ var require_local_auth_addon = __commonJS({
152655
152824
  const kind = this.deps.deviceCredentialsKind ?? null;
152656
152825
  if (kind !== null) {
152657
152826
  for (const row of await (0, import_read_all_rows.readAllRows)(kind)) {
152658
- const record = parseRecord({
152827
+ const record = parseRecord$1({
152659
152828
  id: row.id,
152660
152829
  ...row.data
152661
152830
  });
@@ -152665,7 +152834,7 @@ var require_local_auth_addon = __commonJS({
152665
152834
  }
152666
152835
  const rows = await this.store.query.query({ collection: DEVICE_CREDENTIALS_COLLECTION });
152667
152836
  for (const row of rows) {
152668
- const record = parseRecord(row.data);
152837
+ const record = parseRecord$1(row.data);
152669
152838
  if (record !== null) this.records.set(record.id, record);
152670
152839
  }
152671
152840
  }
@@ -153066,7 +153235,6 @@ var require_local_auth_addon = __commonJS({
153066
153235
  }
153067
153236
  };
153068
153237
  var USERS_COLLECTION$1 = "users";
153069
- var API_KEYS_COLLECTION = "api_keys";
153070
153238
  var SCOPED_TOKENS_COLLECTION = "scoped_tokens";
153071
153239
  var USER_TOTP_COLLECTION = "user_totp";
153072
153240
  var USER_EXTERNAL_IDENTITIES_COLLECTION = "user_external_identities";
@@ -153116,52 +153284,6 @@ var require_local_auth_addon = __commonJS({
153116
153284
  notNull: true
153117
153285
  }
153118
153286
  ];
153119
- var API_KEYS_COLUMNS = [
153120
- {
153121
- name: "id",
153122
- type: "TEXT",
153123
- primaryKey: true,
153124
- notNull: true
153125
- },
153126
- {
153127
- name: "label",
153128
- type: "TEXT",
153129
- notNull: true
153130
- },
153131
- {
153132
- name: "isAdmin",
153133
- type: "BOOLEAN",
153134
- notNull: true
153135
- },
153136
- {
153137
- name: "tokenHash",
153138
- type: "TEXT",
153139
- notNull: true,
153140
- unique: true
153141
- },
153142
- {
153143
- name: "tokenPrefix",
153144
- type: "TEXT",
153145
- notNull: true
153146
- },
153147
- {
153148
- name: "allowedProviders",
153149
- type: "JSON"
153150
- },
153151
- {
153152
- name: "allowedDevices",
153153
- type: "JSON"
153154
- },
153155
- {
153156
- name: "createdAt",
153157
- type: "INTEGER",
153158
- notNull: true
153159
- },
153160
- {
153161
- name: "lastUsedAt",
153162
- type: "INTEGER"
153163
- }
153164
- ];
153165
153287
  var USER_TOTP_COLUMNS = [
153166
153288
  {
153167
153289
  name: "userId",
@@ -153273,14 +153395,6 @@ var require_local_auth_addon = __commonJS({
153273
153395
  collection: USERS_COLLECTION$1,
153274
153396
  columns: USERS_COLUMNS
153275
153397
  });
153276
- if (!skip.has("api_keys")) await store.declareCollection.mutate({
153277
- collection: API_KEYS_COLLECTION,
153278
- columns: API_KEYS_COLUMNS,
153279
- indexes: [{
153280
- name: "idx_api_keys_token_prefix",
153281
- columns: ["tokenPrefix"]
153282
- }]
153283
- });
153284
153398
  if (!skip.has("scoped_tokens")) await store.declareCollection.mutate({
153285
153399
  collection: SCOPED_TOKENS_COLLECTION,
153286
153400
  columns: SCOPED_TOKENS_COLUMNS,
@@ -153340,7 +153454,6 @@ var require_local_auth_addon = __commonJS({
153340
153454
  }
153341
153455
  var DAY_MS = 864e5;
153342
153456
  var UserBodySchema = require_dist10.UserRecordSchema.omit({ id: true });
153343
- var ApiKeyBodySchema = require_dist10.ApiKeyRecordSchema.omit({ id: true });
153344
153457
  var ScopedTokenBodySchema = require_dist10.ScopedTokenSchema.omit({ id: true });
153345
153458
  var AdminTokenBodySchema = zod.z.object({
153346
153459
  createdBy: zod.z.string(),
@@ -153428,18 +153541,6 @@ var require_local_auth_addon = __commonJS({
153428
153541
  }],
153429
153542
  retention: { none: "row goes only when an operator deletes the user; destructive declareCollection rebuild wipes all accounts" }
153430
153543
  },
153431
- "api-keys": {
153432
- schema: ApiKeyBodySchema,
153433
- class: "config",
153434
- writeTrigger: "legacy list/revoke only \u2014 nothing creates new API keys",
153435
- device: "none",
153436
- at: "none",
153437
- indexes: [{
153438
- name: "prefix",
153439
- fields: ["tokenPrefix"]
153440
- }],
153441
- retention: { none: "explicit revoke only" }
153442
- },
153443
153544
  "scoped-tokens": {
153444
153545
  schema: ScopedTokenBodySchema,
153445
153546
  class: "config",
@@ -153576,7 +153677,6 @@ var require_local_auth_addon = __commonJS({
153576
153677
  });
153577
153678
  var localAuthRecordKinds = _localAuthRecordKinds;
153578
153679
  var localAuthUsersRecordKind = _localAuthRecordKinds.users;
153579
- var localAuthApiKeysRecordKind = _localAuthRecordKinds["api-keys"];
153580
153680
  _localAuthRecordKinds["scoped-tokens"];
153581
153681
  _localAuthRecordKinds["admin-tokens"];
153582
153682
  var localAuthLoginSessionsRecordKind = _localAuthRecordKinds["login-sessions"];
@@ -153588,7 +153688,6 @@ var require_local_auth_addon = __commonJS({
153588
153688
  var localAuthAuthAuditRecordKind = _localAuthRecordKinds["auth-audit"];
153589
153689
  var LOCAL_AUTH_RECORDS_LEGACY_COLLECTIONS = [
153590
153690
  USERS_COLLECTION$1,
153591
- API_KEYS_COLLECTION,
153592
153691
  SCOPED_TOKENS_COLLECTION,
153593
153692
  ADMIN_TOKENS_COLLECTION,
153594
153693
  LOGIN_SESSIONS_COLLECTION,
@@ -153601,7 +153700,6 @@ var require_local_auth_addon = __commonJS({
153601
153700
  function localAuthRecordStoresOf(records) {
153602
153701
  return {
153603
153702
  users: records.kind(localAuthUsersRecordKind),
153604
- apiKeys: records.kind(localAuthApiKeysRecordKind),
153605
153703
  loginSessions: records.kind(localAuthLoginSessionsRecordKind),
153606
153704
  loginSessionCutoffs: records.kind(localAuthLoginSessionCutoffsRecordKind),
153607
153705
  oauthSessions: records.kind(localAuthOauthSessionsRecordKind),
@@ -154433,11 +154531,21 @@ var require_local_auth_addon = __commonJS({
154433
154531
  if (internal === null || typeof internal !== "object") return null;
154434
154532
  return internal;
154435
154533
  }
154534
+ function parseRecord(kind, schema, data) {
154535
+ try {
154536
+ return schema.parse(data);
154537
+ } catch (err) {
154538
+ const topKeys = data && typeof data === "object" && !Array.isArray(data) ? Object.keys(data).join(", ") || "(empty)" : `(non-object: ${typeof data})`;
154539
+ const detail = err instanceof Error ? err.message : String(err);
154540
+ const hint = data && typeof data === "object" && !Array.isArray(data) && Object.keys(data).length === 1 && "data" in data ? " This shape is the legacy double-wrap from a stale settings-store query path. Restart the server with the latest @camstack/system build." : "";
154541
+ throw new Error(`Failed to parse ${kind} from settings store. Top-level keys=[${topKeys}].${hint} Underlying: ${detail}`, { cause: err });
154542
+ }
154543
+ }
154436
154544
  var USERS_COLLECTION = "users";
154437
154545
  var FIRST_BOOT_ADMIN_USERNAME = "admin";
154438
154546
  var FIRST_BOOT_ADMIN_PASSWORD = "changeme";
154439
154547
  function parseUser(data) {
154440
- return parseRecord$2("user", require_dist10.UserRecordSchema, data);
154548
+ return parseRecord("user", require_dist10.UserRecordSchema, data);
154441
154549
  }
154442
154550
  function userToBody(user) {
154443
154551
  const { id: _id, ...body } = user;
@@ -157253,7 +157361,6 @@ var require_local_auth_addon = __commonJS({
157253
157361
  var LocalAuthAddon = class extends require_dist10.BaseAddon {
157254
157362
  authManager = null;
157255
157363
  userManager = null;
157256
- apiKeyManager = null;
157257
157364
  oauthSessionManager = null;
157258
157365
  reapTimer = null;
157259
157366
  totpManager = null;
@@ -157289,10 +157396,6 @@ var require_local_auth_addon = __commonJS({
157289
157396
  usersKind: authStores.users,
157290
157397
  legacyStore: store
157291
157398
  }, this.authManager);
157292
- this.apiKeyManager = new ApiKeyManager({
157293
- apiKeysKind: authStores.apiKeys,
157294
- legacyStore: store
157295
- });
157296
157399
  this.oauthSessionManager = new OauthSessionManager({ oauthSessionsKind: authStores.oauthSessions });
157297
157400
  this.totpManager = new TotpManager({
157298
157401
  userTotpKind: authStores.userTotp,
@@ -157457,15 +157560,6 @@ var require_local_auth_addon = __commonJS({
157457
157560
  totpEnabled
157458
157561
  };
157459
157562
  },
157460
- listApiKeys: async () => {
157461
- if (!this.apiKeyManager) return [];
157462
- return this.apiKeyManager.listAll();
157463
- },
157464
- revokeApiKey: async (input) => {
157465
- if (!this.apiKeyManager) throw new Error("API key management not available");
157466
- await this.apiKeyManager.revoke(input.id);
157467
- return { success: true };
157468
- },
157469
157563
  oauthIssueCode: async (input) => {
157470
157564
  return lazyOauthGrants().oauthIssueCode(input);
157471
157565
  },
@@ -157826,7 +157920,6 @@ var require_local_auth_addon = __commonJS({
157826
157920
  }
157827
157921
  this.authManager = null;
157828
157922
  this.userManager = null;
157829
- this.apiKeyManager = null;
157830
157923
  this.oauthSessionManager = null;
157831
157924
  this.externalIdentities = null;
157832
157925
  this.loginSessions = null;
@@ -157835,7 +157928,6 @@ var require_local_auth_addon = __commonJS({
157835
157928
  this.deviceCa = null;
157836
157929
  }
157837
157930
  };
157838
- exports.ApiKeyManager = ApiKeyManager;
157839
157931
  exports.AuthAuditLog = AuthAuditLog;
157840
157932
  exports.AuthManager = AuthManager;
157841
157933
  exports.DeviceCaStore = DeviceCaStore;
@@ -158013,7 +158105,7 @@ var require_loki_logging = __commonJS({
158013
158105
  [Symbol.toStringTag]: { value: "Module" }
158014
158106
  });
158015
158107
  require_chunk_Cek0wNdY();
158016
- var require_dist10 = require_dist_Dwi4JA96();
158108
+ var require_dist10 = require_dist_l6zKmHEb();
158017
158109
  var require_log_read_filter = require_log_read_filter_Bi066jwU();
158018
158110
  var zod = require_zod();
158019
158111
  function sanitizeLabelName(raw) {
@@ -158974,7 +159066,7 @@ var require_native_metrics_addon = __commonJS({
158974
159066
  [Symbol.toStringTag]: { value: "Module" }
158975
159067
  });
158976
159068
  var require_chunk = require_chunk_Cek0wNdY();
158977
- var require_dist10 = require_dist_Dwi4JA96();
159069
+ var require_dist10 = require_dist_l6zKmHEb();
158978
159070
  var node_fs_promises = __require("fs/promises");
158979
159071
  var node_util = __require("util");
158980
159072
  var node_os = __require("os");
@@ -161541,7 +161633,7 @@ var require_device_history_addon = __commonJS({
161541
161633
  [Symbol.toStringTag]: { value: "Module" }
161542
161634
  });
161543
161635
  require_chunk_Cek0wNdY();
161544
- var require_dist10 = require_dist_Dwi4JA96();
161636
+ var require_dist10 = require_dist_l6zKmHEb();
161545
161637
  var FIVE_MINUTES_MS = 5 * 6e4;
161546
161638
  var HOUR_MS = 60 * 6e4;
161547
161639
  var DAY_MS = 24 * HOUR_MS;
@@ -164587,7 +164679,7 @@ var require_filesystem_storage_addon = __commonJS({
164587
164679
  [Symbol.toStringTag]: { value: "Module" }
164588
164680
  });
164589
164681
  var require_chunk = require_chunk_Cek0wNdY();
164590
- var require_dist10 = require_dist_Dwi4JA96();
164682
+ var require_dist10 = require_dist_l6zKmHEb();
164591
164683
  var node_crypto = __require("crypto");
164592
164684
  var node_fs_promises = __require("fs/promises");
164593
164685
  var node_path = __require("path");
@@ -165697,12 +165789,12 @@ var require_lib = __commonJS({
165697
165789
  }
165698
165790
  });
165699
165791
 
165700
- // ../system/dist/wal-maintenance-BQlvAduo.js
165701
- var require_wal_maintenance_BQlvAduo = __commonJS({
165702
- "../system/dist/wal-maintenance-BQlvAduo.js"(exports) {
165792
+ // ../system/dist/wal-maintenance-B6LSQ_OZ.js
165793
+ var require_wal_maintenance_B6LSQ_OZ = __commonJS({
165794
+ "../system/dist/wal-maintenance-B6LSQ_OZ.js"(exports) {
165703
165795
  "use strict";
165704
165796
  var require_chunk = require_chunk_Cek0wNdY();
165705
- var require_dist10 = require_dist_Dwi4JA96();
165797
+ var require_dist10 = require_dist_l6zKmHEb();
165706
165798
  var require_prefix_range = require_prefix_range_D_KueXbQ();
165707
165799
  var node_crypto = __require("crypto");
165708
165800
  var node_module = __require("module");
@@ -166162,7 +166254,7 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
166162
166254
  database: asDatabase(row.database),
166163
166255
  hash: row.manifest_hash,
166164
166256
  state: asState(row.state),
166165
- declaration: require_dist10.RecordKindDeclarationSchema.parse(JSON.parse(row.declaration))
166257
+ declaration: require_dist10.StoredRecordKindDeclarationSchema.parse(JSON.parse(row.declaration))
166166
166258
  };
166167
166259
  }
166168
166260
  function ensureRecordsSchema(db) {
@@ -166202,8 +166294,10 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
166202
166294
  state = "created";
166203
166295
  } else {
166204
166296
  kindId = prior.kindId;
166205
- if (prior.hash === hash) state = "unchanged";
166206
- else {
166297
+ if (prior.hash === hash) {
166298
+ db.prepare("UPDATE _record_kinds SET declaration = ? WHERE kind_id = ? AND declaration <> ?").run(JSON.stringify(declaration), kindId, JSON.stringify(declaration));
166299
+ state = "unchanged";
166300
+ } else {
166207
166301
  db.prepare("UPDATE _record_kinds SET manifest_hash = ?, declaration = ?, state = 'declared', orphaned_at = NULL WHERE kind_id = ?").run(hash, JSON.stringify(declaration), kindId);
166208
166302
  state = "updated";
166209
166303
  }
@@ -166230,8 +166324,7 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
166230
166324
  result: {
166231
166325
  kindId,
166232
166326
  state,
166233
- createdIndexes: created,
166234
- adoptionPending: null
166327
+ createdIndexes: created
166235
166328
  }
166236
166329
  };
166237
166330
  })();
@@ -166861,13 +166954,17 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
166861
166954
  }
166862
166955
  async patch(input) {
166863
166956
  const k = this.kindOf(input.owner, input.kind);
166864
- const decl = k.declaration;
166865
166957
  const nowMs = this.now();
166958
+ return this.timed("patch", input.kind, () => this.db.transaction(() => this.patchRecord(k, input, nowMs))());
166959
+ }
166960
+ /** One patch, inside the caller's transaction (shared with `transact`). */
166961
+ patchRecord(k, input, nowMs) {
166962
+ const decl = k.declaration;
166866
166963
  if (input.at !== void 0 && decl.at !== "required") throw new require_dist10.InvalidRecordError(`${input.kind}: declared at: "none"`);
166867
166964
  if (input.at === null) throw new require_dist10.InvalidRecordError(`${input.kind}: "at" cannot be removed`);
166868
166965
  if (input.expiresAt !== void 0 && decl.secretPaths.length > 0) throw new require_dist10.InvalidRecordError(`${input.kind}: a kind with secret fields cannot expire by the engine (its keychain values would be orphaned)`);
166869
166966
  if (input.expiresAt !== void 0 && "ttlMs" in decl.retention) throw new require_dist10.InvalidRecordError(`${input.kind}: expiresAt is set by the engine`);
166870
- const run = this.db.transaction(() => {
166967
+ {
166871
166968
  const hasSecrets = decl.secretPaths.length > 0;
166872
166969
  const before = hasSecrets || input.ifRev !== void 0 ? this.storedRow(k, input.id) : void 0;
166873
166970
  const checked = enforceSecrets(input.owner, input.kind, decl, input.id, input.data, before === void 0 ? null : parseBody(before.data), "patch");
@@ -166904,22 +167001,83 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
166904
167001
  rev: updated.rev,
166905
167002
  releasedRefs: released
166906
167003
  };
166907
- });
166908
- return this.timed("patch", input.kind, () => run());
167004
+ }
166909
167005
  }
166910
167006
  refsOfRows(k, rows) {
166911
167007
  if (k.declaration.secretPaths.length === 0) return [];
166912
167008
  return rows.flatMap((row) => [...markersOf(k.declaration, parseBody(row.data)).values()]);
166913
167009
  }
166914
167010
  async delete(input) {
166915
- const k = this.kindOf(input.owner, input.kind);
167011
+ return this.deleteRecord(this.kindOf(input.owner, input.kind), input.id);
167012
+ }
167013
+ /** One delete (shared with `transact`). */
167014
+ deleteRecord(k, id) {
166916
167015
  const hasSecrets = k.declaration.secretPaths.length > 0;
166917
- const rows = this.db.prepare(`DELETE FROM records WHERE ${kindClause(k.kindId)} AND id = ? RETURNING ${hasSecrets ? "json(data)" : "'{}'"} AS data`).all(input.id);
167016
+ const rows = this.db.prepare(`DELETE FROM records WHERE ${kindClause(k.kindId)} AND id = ? RETURNING ${hasSecrets ? "json(data)" : "'{}'"} AS data`).all(id);
166918
167017
  return {
166919
167018
  deleted: rows.length > 0,
166920
167019
  secretRefs: this.refsOfRows(k, rows)
166921
167020
  };
166922
167021
  }
167022
+ /**
167023
+ * Several put / patch / delete in ONE SQLite transaction. The scope rule
167024
+ * (one file, one `transactFamily`) is checked before a row moves; each op then
167025
+ * runs the very code of the single-row write, so secrets, indexes and size
167026
+ * bounds behave exactly as there. Any op throwing rolls the whole call back.
167027
+ */
167028
+ async transact(input) {
167029
+ const kinds = /* @__PURE__ */ new Map();
167030
+ for (const op of input.ops) if (!kinds.has(op.kind)) kinds.set(op.kind, this.kindOf(input.owner, op.kind));
167031
+ require_dist10.assertTransactScope([...kinds.values()].map((k) => ({
167032
+ kind: k.kind,
167033
+ declaration: k.declaration
167034
+ })));
167035
+ const nowMs = this.now();
167036
+ const results = [];
167037
+ const releasedRefs = [];
167038
+ const secretRefs = [];
167039
+ const label = [...kinds.keys()].join("+");
167040
+ this.timed("transact", label, () => this.db.transaction(() => {
167041
+ for (const op of input.ops) {
167042
+ const k = kinds.get(op.kind);
167043
+ if (k === void 0) throw new require_dist10.UnknownRecordKindError(`"${input.owner}" declared no kind "${op.kind}"`);
167044
+ if (op.op === "put") {
167045
+ const w = this.writeRecord(input.owner, k, op.record, op.ifRev, nowMs);
167046
+ releasedRefs.push(...w.releasedRefs);
167047
+ results.push({
167048
+ rev: w.rev,
167049
+ deleted: false
167050
+ });
167051
+ } else if (op.op === "patch") {
167052
+ const w = this.patchRecord(k, {
167053
+ ...op,
167054
+ owner: input.owner
167055
+ }, nowMs);
167056
+ releasedRefs.push(...w.releasedRefs);
167057
+ results.push({
167058
+ rev: w.rev,
167059
+ deleted: false
167060
+ });
167061
+ } else {
167062
+ const d = this.deleteRecord(k, op.id);
167063
+ secretRefs.push(...d.secretRefs);
167064
+ results.push({
167065
+ rev: null,
167066
+ deleted: d.deleted
167067
+ });
167068
+ }
167069
+ }
167070
+ })());
167071
+ for (const [name, k] of kinds) {
167072
+ const devices = input.ops.flatMap((op) => op.op === "put" && op.kind === name ? [op.record.deviceId] : []);
167073
+ if (devices.length > 0) this.afterWrite(k, devices);
167074
+ }
167075
+ return {
167076
+ results,
167077
+ releasedRefs,
167078
+ secretRefs
167079
+ };
167080
+ }
166923
167081
  async deleteMany(input) {
166924
167082
  const k = this.kindOf(input.owner, input.kind);
166925
167083
  const hasSecrets = k.declaration.secretPaths.length > 0;
@@ -167074,6 +167232,7 @@ CREATE TABLE IF NOT EXISTS _record_sequences (
167074
167232
  "histogram",
167075
167233
  "aggregate",
167076
167234
  "deleteWhere",
167235
+ "transact",
167077
167236
  "deleteDevice",
167078
167237
  "allocateId",
167079
167238
  "listKinds",
@@ -169819,9 +169978,9 @@ var require_sqlite_settings_addon = __commonJS({
169819
169978
  [Symbol.toStringTag]: { value: "Module" }
169820
169979
  });
169821
169980
  var require_chunk = require_chunk_Cek0wNdY();
169822
- var require_dist10 = require_dist_Dwi4JA96();
169981
+ var require_dist10 = require_dist_l6zKmHEb();
169823
169982
  var require_retired_settings_keys = require_retired_settings_keys_CGUqX_Oz();
169824
- var require_wal_maintenance = require_wal_maintenance_BQlvAduo();
169983
+ var require_wal_maintenance = require_wal_maintenance_B6LSQ_OZ();
169825
169984
  var require_sqlite_snapshot_protocol = require_sqlite_snapshot_protocol_B9OndqZv();
169826
169985
  var require_wal_checkpoint_policy = require_wal_checkpoint_policy_d2z2qPqx();
169827
169986
  var node_fs_promises = __require("fs/promises");
@@ -170994,12 +171153,6 @@ var require_sqlite_settings_addon = __commonJS({
170994
171153
  function keyOf(owner, kind) {
170995
171154
  return `${owner}\0${kind}`;
170996
171155
  }
170997
- function withoutRetiredKeys(declaration) {
170998
- return {
170999
- ...declaration,
171000
- adoptsFrom: void 0
171001
- };
171002
- }
171003
171156
  var RecordsProvider = class {
171004
171157
  router;
171005
171158
  logger;
@@ -171033,7 +171186,7 @@ var require_sqlite_settings_addon = __commonJS({
171033
171186
  const owner = recordsCallerOf(input);
171034
171187
  const byDatabase = /* @__PURE__ */ new Map();
171035
171188
  const parsed = /* @__PURE__ */ new Map();
171036
- for (const [kind, raw] of Object.entries(input.kinds)) parsed.set(kind, withoutRetiredKeys(require_dist10.RecordKindDeclarationSchema.parse(raw)));
171189
+ for (const [kind, raw] of Object.entries(input.kinds)) parsed.set(kind, require_dist10.RecordKindDeclarationSchema.parse(raw));
171037
171190
  await this.assertFamiliesInOneFile(owner, parsed);
171038
171191
  for (const [kind, declaration] of parsed) {
171039
171192
  const known = this.placement.get(keyOf(owner, kind));
@@ -171177,6 +171330,27 @@ var require_sqlite_settings_addon = __commonJS({
171177
171330
  owner
171178
171331
  });
171179
171332
  }
171333
+ /**
171334
+ * All ops must resolve to ONE file (`records/transact-refused` `cross-file`
171335
+ * otherwise); that file's engine then checks the family and runs one SQLite
171336
+ * transaction.
171337
+ */
171338
+ async transact(input) {
171339
+ const owner = recordsCallerOf(input);
171340
+ const files = /* @__PURE__ */ new Map();
171341
+ for (const op of input.ops) {
171342
+ const database = this.placement.get(keyOf(owner, op.kind));
171343
+ if (database === void 0) throw new require_dist10.UnknownRecordKindError(`"${owner}" declared no kind "${op.kind}"`);
171344
+ files.set(database, [...files.get(database) ?? [], op.kind]);
171345
+ }
171346
+ if (files.size > 1) throw new require_dist10.TransactRefusedError(`cross-file: the ops span more than one database file (${[...files.entries()].map(([db, kinds]) => `${[...new Set(kinds)].join("+")}@${db}`).join(", ")}); a transaction lives in ONE file`);
171347
+ const first = input.ops[0];
171348
+ if (first === void 0) throw new require_dist10.InvalidRecordError("transact: no ops");
171349
+ return (await this.fileOf(owner, first.kind)).records("transact", {
171350
+ ...input,
171351
+ owner
171352
+ });
171353
+ }
171180
171354
  async allocateId(input) {
171181
171355
  const owner = recordsCallerOf(input);
171182
171356
  return (await this.fileOf(owner, input.kind)).records("allocateId", {
@@ -171434,7 +171608,7 @@ var require_sqlite_storage = __commonJS({
171434
171608
  });
171435
171609
  require_chunk_Cek0wNdY();
171436
171610
  var require_builtins_sqlite_storage_filesystem_storage_addon = require_filesystem_storage_addon();
171437
- var require_wal_maintenance = require_wal_maintenance_BQlvAduo();
171611
+ var require_wal_maintenance = require_wal_maintenance_B6LSQ_OZ();
171438
171612
  var require_builtins_sqlite_storage_sqlite_settings_addon = require_sqlite_settings_addon();
171439
171613
  var ConfigStore = class {
171440
171614
  db;
@@ -171518,7 +171692,7 @@ var require_storage_orchestrator_addon = __commonJS({
171518
171692
  [Symbol.toStringTag]: { value: "Module" }
171519
171693
  });
171520
171694
  var require_chunk = require_chunk_Cek0wNdY();
171521
- var require_dist10 = require_dist_Dwi4JA96();
171695
+ var require_dist10 = require_dist_l6zKmHEb();
171522
171696
  var require_read_all_rows$1 = require_read_all_rows_CVoO1ONM();
171523
171697
  var zod = require_zod();
171524
171698
  var node_crypto = __require("crypto");
@@ -176105,12 +176279,12 @@ var require_storage_orchestrator = __commonJS({
176105
176279
  }
176106
176280
  });
176107
176281
 
176108
- // ../system/dist/agent-https-CzA1AmyI.js
176109
- var require_agent_https_CzA1AmyI = __commonJS({
176110
- "../system/dist/agent-https-CzA1AmyI.js"(exports) {
176282
+ // ../system/dist/agent-https-DJ8OzQOr.js
176283
+ var require_agent_https_DJ8OzQOr = __commonJS({
176284
+ "../system/dist/agent-https-DJ8OzQOr.js"(exports) {
176111
176285
  "use strict";
176112
176286
  var require_chunk = require_chunk_Cek0wNdY();
176113
- var require_dist10 = require_dist_Dwi4JA96();
176287
+ var require_dist10 = require_dist_l6zKmHEb();
176114
176288
  var require_x509_es = require_x509_es_C4cOo48M();
176115
176289
  var zod = require_zod();
176116
176290
  var node_crypto = __require("crypto");
@@ -177168,11 +177342,11 @@ var require_agent_https_CzA1AmyI = __commonJS({
177168
177342
  }
177169
177343
  });
177170
177344
 
177171
- // ../system/dist/constants-BYJ4ni7h.js
177172
- var require_constants_BYJ4ni7h = __commonJS({
177173
- "../system/dist/constants-BYJ4ni7h.js"(exports) {
177345
+ // ../system/dist/constants-CuO3rcw4.js
177346
+ var require_constants_CuO3rcw4 = __commonJS({
177347
+ "../system/dist/constants-CuO3rcw4.js"(exports) {
177174
177348
  "use strict";
177175
- var MESH_CA_KEY_REF = require_dist_Dwi4JA96().buildSecretRef({
177349
+ var MESH_CA_KEY_REF = require_dist_l6zKmHEb().buildSecretRef({
177176
177350
  owner: "system",
177177
177351
  scope: { kind: "global" },
177178
177352
  fieldPath: "meshCaKey"
@@ -194269,11 +194443,11 @@ var require_system_config_addon = __commonJS({
194269
194443
  [Symbol.toStringTag]: { value: "Module" }
194270
194444
  });
194271
194445
  var require_chunk = require_chunk_Cek0wNdY();
194272
- var require_dist10 = require_dist_Dwi4JA96();
194446
+ var require_dist10 = require_dist_l6zKmHEb();
194273
194447
  var require_safe_buffer$1 = require_safe_buffer_D3aoa_7X();
194274
194448
  var require_x509_es = require_x509_es_C4cOo48M();
194275
- var require_agent_https = require_agent_https_CzA1AmyI();
194276
- var require_constants$8 = require_constants_BYJ4ni7h();
194449
+ var require_agent_https = require_agent_https_DJ8OzQOr();
194450
+ var require_constants$8 = require_constants_CuO3rcw4();
194277
194451
  var require_src$1 = require_src_CnAqG6EF();
194278
194452
  var zod = require_zod();
194279
194453
  var node_crypto = __require("crypto");
@@ -275325,7 +275499,7 @@ var require_winston_logging = __commonJS({
275325
275499
  [Symbol.toStringTag]: { value: "Module" }
275326
275500
  });
275327
275501
  var require_chunk = require_chunk_Cek0wNdY();
275328
- var require_dist10 = require_dist_Dwi4JA96();
275502
+ var require_dist10 = require_dist_l6zKmHEb();
275329
275503
  var require_formatter = require_formatter_DqAKDlvN();
275330
275504
  var require_log_file_read_protocol = require_log_file_read_protocol_D0WcLbIV();
275331
275505
  var node_path = __require("path");
@@ -283128,14 +283302,14 @@ var require_lib_8oZrELLm = __commonJS({
283128
283302
  }
283129
283303
  });
283130
283304
 
283131
- // ../system/dist/hub-mdns-ciao-3qdHbtyp.js
283132
- var require_hub_mdns_ciao_3qdHbtyp = __commonJS({
283133
- "../system/dist/hub-mdns-ciao-3qdHbtyp.js"(exports) {
283305
+ // ../system/dist/hub-mdns-ciao-CIno_SNn.js
283306
+ var require_hub_mdns_ciao_CIno_SNn = __commonJS({
283307
+ "../system/dist/hub-mdns-ciao-CIno_SNn.js"(exports) {
283134
283308
  "use strict";
283135
283309
  var require_chunk = require_chunk_Cek0wNdY();
283136
- var require_dist10 = require_dist_Dwi4JA96();
283310
+ var require_dist10 = require_dist_l6zKmHEb();
283137
283311
  var require_x509_es = require_x509_es_C4cOo48M();
283138
- var require_agent_https = require_agent_https_CzA1AmyI();
283312
+ var require_agent_https = require_agent_https_DJ8OzQOr();
283139
283313
  var node_crypto = __require("crypto");
283140
283314
  var _camstack_types_node = require_node();
283141
283315
  var node_fs_promises = __require("fs/promises");
@@ -284147,12 +284321,12 @@ var require_platform_key_source_Di7HrlGR = __commonJS({
284147
284321
  }
284148
284322
  });
284149
284323
 
284150
- // ../system/dist/restore-archive-D1uxP8Eb.js
284151
- var require_restore_archive_D1uxP8Eb = __commonJS({
284152
- "../system/dist/restore-archive-D1uxP8Eb.js"(exports) {
284324
+ // ../system/dist/restore-archive-B71JI-sP.js
284325
+ var require_restore_archive_B71JI_sP = __commonJS({
284326
+ "../system/dist/restore-archive-B71JI-sP.js"(exports) {
284153
284327
  "use strict";
284154
284328
  var require_chunk = require_chunk_Cek0wNdY();
284155
- var require_dist10 = require_dist_Dwi4JA96();
284329
+ var require_dist10 = require_dist_l6zKmHEb();
284156
284330
  var zod = require_zod();
284157
284331
  var node_crypto = __require("crypto");
284158
284332
  var buffer = __require("buffer");
@@ -295393,9 +295567,9 @@ var require_dist3 = __commonJS({
295393
295567
  "use strict";
295394
295568
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
295395
295569
  var require_chunk = require_chunk_Cek0wNdY();
295396
- var require_dist10 = require_dist_Dwi4JA96();
295570
+ var require_dist10 = require_dist_l6zKmHEb();
295571
+ var require_device_ca = require_device_ca_CGcaSheI();
295397
295572
  var require_read_all_rows$1 = require_read_all_rows_CVoO1ONM();
295398
- var require_device_ca = require_device_ca_B_Txwl4W();
295399
295573
  var require_builtins_alerts_alerts_addon = require_alerts_addon();
295400
295574
  require_alerts();
295401
295575
  var require_builtins_calendars_calendars_addon = require_calendars_addon();
@@ -295419,21 +295593,21 @@ var require_dist3 = __commonJS({
295419
295593
  var require_builtins_native_metrics_native_metrics_addon = require_native_metrics_addon();
295420
295594
  var require_builtins_device_history_device_history_addon = require_device_history_addon();
295421
295595
  var require_builtins_sqlite_storage_filesystem_storage_addon = require_filesystem_storage_addon();
295422
- var require_wal_maintenance = require_wal_maintenance_BQlvAduo();
295596
+ var require_wal_maintenance = require_wal_maintenance_B6LSQ_OZ();
295423
295597
  var require_builtins_sqlite_storage_sqlite_settings_addon = require_sqlite_settings_addon();
295424
295598
  var require_builtins_sqlite_storage_index = require_sqlite_storage();
295425
295599
  var require_builtins_storage_orchestrator_storage_orchestrator_addon = require_storage_orchestrator_addon();
295426
295600
  require_storage_orchestrator();
295427
- var require_agent_https = require_agent_https_CzA1AmyI();
295428
- var require_constants15 = require_constants_BYJ4ni7h();
295601
+ var require_agent_https = require_agent_https_DJ8OzQOr();
295602
+ var require_constants15 = require_constants_CuO3rcw4();
295429
295603
  var require_builtins_system_config_system_config_addon = require_system_config_addon();
295430
295604
  require_system_config();
295431
295605
  var require_builtins_winston_logging_index = require_winston_logging();
295432
295606
  var require_custom_action_registry = require_custom_action_registry_MRyes5j0();
295433
- var require_hub_mdns_ciao = require_hub_mdns_ciao_3qdHbtyp();
295607
+ var require_hub_mdns_ciao = require_hub_mdns_ciao_CIno_SNn();
295434
295608
  var require_platform_key_source = require_platform_key_source_Di7HrlGR();
295435
295609
  var require_resource_monitor = require_resource_monitor_mio9dSCT();
295436
- var require_restore_archive = require_restore_archive_D1uxP8Eb();
295610
+ var require_restore_archive = require_restore_archive_B71JI_sP();
295437
295611
  var require_coral_accelerators = require_coral_accelerators_oUXmmbc2();
295438
295612
  var zod = require_zod();
295439
295613
  var node_crypto = __require("crypto");
@@ -308448,6 +308622,7 @@ var require_dist3 = __commonJS({
308448
308622
  histogram: (input) => r.histogram.query(input),
308449
308623
  aggregate: (input) => r.aggregate.query(input),
308450
308624
  deleteWhere: (input) => r.deleteWhere.mutate(input),
308625
+ transact: (input) => r.transact.mutate(input),
308451
308626
  deleteDevice: (input) => r.deleteDevice.mutate(input),
308452
308627
  allocateId: (input) => r.allocateId.mutate(input)
308453
308628
  };
@@ -318037,7 +318212,6 @@ var require_dist3 = __commonJS({
318037
318212
  exports.AgentMeshIdentityGate = AgentMeshIdentityGate;
318038
318213
  exports.AgentPairing = require_builtins_system_config_system_config_addon.AgentPairing;
318039
318214
  exports.AlertCenterAddon = require_builtins_alerts_alerts_addon.AlertCenterAddon;
318040
- exports.ApiKeyManager = require_builtins_local_auth_local_auth_addon.ApiKeyManager;
318041
318215
  exports.AuthAuditLog = require_builtins_local_auth_local_auth_addon.AuthAuditLog;
318042
318216
  exports.AuthManager = require_builtins_local_auth_local_auth_addon.AuthManager;
318043
318217
  exports.BackupDecryptError = require_restore_archive.BackupDecryptError;
@@ -318857,7 +319031,7 @@ var require_enums = __commonJS({
318857
319031
  "../types/dist/enums.js"(exports) {
318858
319032
  "use strict";
318859
319033
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
318860
- var require_event_category = require_event_category_kpu1bZMs();
319034
+ var require_event_category = require_event_category_7AwNbPjm();
318861
319035
  var EventSourceType = /* @__PURE__ */ (function(EventSourceType2) {
318862
319036
  EventSourceType2["Addon"] = "addon";
318863
319037
  EventSourceType2["Core"] = "core";
@@ -318877,8 +319051,8 @@ var require_dist4 = __commonJS({
318877
319051
  "../types/dist/index.js"(exports) {
318878
319052
  "use strict";
318879
319053
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
318880
- var require_sleep = require_sleep_Bo7fq491();
318881
- var require_event_category = require_event_category_kpu1bZMs();
319054
+ var require_sleep = require_sleep_CD18m9HF();
319055
+ var require_event_category = require_event_category_7AwNbPjm();
318882
319056
  var require_composition = require_composition_eoYYVfOp();
318883
319057
  var require_node_color2 = require_node_color();
318884
319058
  var require_err_msg = require_err_msg_BhVbr0NX();
@@ -323149,17 +323323,6 @@ var require_dist4 = __commonJS({
323149
323323
  createdAt: zod.z.number(),
323150
323324
  updatedAt: zod.z.number()
323151
323325
  });
323152
- var ApiKeyRecordSchema = zod.z.object({
323153
- id: zod.z.string(),
323154
- label: zod.z.string(),
323155
- isAdmin: zod.z.boolean().default(false),
323156
- allowedProviders: AllowedProviderSchema,
323157
- allowedDevices: AllowedDevicesSchema,
323158
- tokenHash: zod.z.string(),
323159
- tokenPrefix: zod.z.string(),
323160
- createdAt: zod.z.number(),
323161
- lastUsedAt: zod.z.number().optional()
323162
- });
323163
323326
  var ScopedTokenSchema = zod.z.object({
323164
323327
  id: zod.z.string(),
323165
323328
  userId: zod.z.string(),
@@ -329217,15 +329380,31 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
329217
329380
  var DeclareKindResultSchema = zod.z.object({
329218
329381
  kindId: zod.z.number().int(),
329219
329382
  state: RecordKindStateSchema,
329220
- createdIndexes: zod.z.array(zod.z.string()),
329221
- /**
329222
- * RETIRED (D900): always `null`. It carried the records-migration boot guard;
329223
- * it stays on the wire, null, because an addon built before the removal reads
329224
- * an ABSENT field as "adoption pending" and refuses to start.
329225
- */
329226
- adoptionPending: zod.z.null()
329383
+ createdIndexes: zod.z.array(zod.z.string())
329227
329384
  });
329228
329385
  var SecretRefsList = zod.z.array(zod.z.string());
329386
+ var RecordTransactOpSchema = zod.z.discriminatedUnion("op", [
329387
+ zod.z.object({
329388
+ op: zod.z.literal("put"),
329389
+ kind: require_sleep.RecordKindNameSchema,
329390
+ record: RecordInputSchema,
329391
+ ifRev: zod.z.number().int().min(0).optional()
329392
+ }),
329393
+ zod.z.object({
329394
+ op: zod.z.literal("patch"),
329395
+ kind: require_sleep.RecordKindNameSchema,
329396
+ id: RecordIdSchema,
329397
+ data: RecordBodySchema,
329398
+ at: zod.z.number().int().nullable().optional(),
329399
+ expiresAt: zod.z.number().int().nullable().optional(),
329400
+ ifRev: zod.z.number().int().min(1).optional()
329401
+ }),
329402
+ zod.z.object({
329403
+ op: zod.z.literal("delete"),
329404
+ kind: require_sleep.RecordKindNameSchema,
329405
+ id: RecordIdSchema
329406
+ })
329407
+ ]);
329229
329408
  var RecordSecretRefsSchema = zod.z.record(zod.z.string(), zod.z.record(zod.z.string(), zod.z.string()));
329230
329409
  var recordsCapability = {
329231
329410
  name: "records",
@@ -329357,6 +329536,22 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
329357
329536
  kind: "mutation",
329358
329537
  auth: "admin"
329359
329538
  }),
329539
+ /**
329540
+ * Several single-row writes (put / patch / delete) in ONE SQLite transaction:
329541
+ * all land or none does. Every op's kind must sit in one file and share one
329542
+ * `transactFamily` (`records/transact-refused` otherwise). Results are in op order.
329543
+ */
329544
+ transact: require_sleep.method(zod.z.object({ ops: zod.z.array(RecordTransactOpSchema).min(1).max(require_sleep.RECORD_BATCH_MAX) }), zod.z.object({
329545
+ results: zod.z.array(zod.z.object({
329546
+ rev: zod.z.number().int().nullable(),
329547
+ deleted: zod.z.boolean()
329548
+ })),
329549
+ releasedRefs: SecretRefsList,
329550
+ secretRefs: SecretRefsList
329551
+ }), {
329552
+ kind: "mutation",
329553
+ auth: "admin"
329554
+ }),
329360
329555
  /** The D865 hook body: every kind of this addon declared `deviceRemoval: 'delete'`. */
329361
329556
  deleteDevice: require_sleep.method(zod.z.object({
329362
329557
  deviceId: zod.z.number().int(),
@@ -356174,9 +356369,13 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
356174
356369
  "node-updating",
356175
356370
  "node-inference-unavailable",
356176
356371
  "detection-blind",
356372
+ "motion-noisy",
356373
+ "motion-calm",
356177
356374
  "recording-stalled",
356178
356375
  "recording-healthy",
356179
356376
  "recording-degraded",
356377
+ "device-attention-required",
356378
+ "device-attention-resolved",
356180
356379
  "storage-location-low",
356181
356380
  "storage-location-critical",
356182
356381
  "storage-location-ok",
@@ -357286,6 +357485,14 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
357286
357485
  value: "detection-blind",
357287
357486
  label: "Camera detecting nothing"
357288
357487
  },
357488
+ {
357489
+ value: "motion-noisy",
357490
+ label: "Camera motion constant, no subject"
357491
+ },
357492
+ {
357493
+ value: "motion-calm",
357494
+ label: "Camera motion calm again"
357495
+ },
357289
357496
  {
357290
357497
  value: "recording-stalled",
357291
357498
  label: "Recording stalled"
@@ -357298,6 +357505,14 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
357298
357505
  value: "recording-degraded",
357299
357506
  label: "Recording degraded (restart storm)"
357300
357507
  },
357508
+ {
357509
+ value: "device-attention-required",
357510
+ label: "Device needs attention"
357511
+ },
357512
+ {
357513
+ value: "device-attention-resolved",
357514
+ label: "Device attention resolved"
357515
+ },
357301
357516
  {
357302
357517
  value: "storage-location-low",
357303
357518
  label: "Storage location low"
@@ -362396,7 +362611,6 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
362396
362611
  modelId: zod.z.string()
362397
362612
  }),
362398
362613
  zod.z.object({ kind: zod.z.literal("cpu-device") }),
362399
- zod.z.object({ kind: zod.z.literal("coral-untouched") }),
362400
362614
  zod.z.object({ kind: zod.z.literal("device-disabled") }),
362401
362615
  zod.z.object({ kind: zod.z.literal("device-unavailable") }),
362402
362616
  zod.z.object({ kind: zod.z.literal("node-offline") }),
@@ -362489,11 +362703,6 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
362489
362703
  kind: zod.z.literal("detector-store-unreadable"),
362490
362704
  error: zod.z.string()
362491
362705
  }),
362492
- zod.z.object({
362493
- kind: zod.z.literal("coral-enabled"),
362494
- nodeId: zod.z.string(),
362495
- deviceKey: zod.z.string()
362496
- }),
362497
362706
  zod.z.object({
362498
362707
  kind: zod.z.literal("custom-pin-kept"),
362499
362708
  nodeId: zod.z.string(),
@@ -370685,6 +370894,16 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
370685
370894
  powerState: zod.z.string().nullable(),
370686
370895
  saltLevel: DishwasherConsumableLevelSchema.nullable(),
370687
370896
  rinseAidLevel: DishwasherConsumableLevelSchema.nullable(),
370897
+ /**
370898
+ * True while the appliance asks for its filter to be cleaned (smart-filter, filter-system or
370899
+ * combined care-and-filter reminder raised); false when every such reminder reads clear; null
370900
+ * when none is reported. A cleared reminder is not an unknown one.
370901
+ */
370902
+ filterCleaningDue: zod.z.boolean().nullable(),
370903
+ /** True while the machine-care (descaling / cleaning-program) reminder is raised; false when clear; null when not reported. */
370904
+ machineCareDue: zod.z.boolean().nullable(),
370905
+ /** Program runs left before the machine-care reminder is due; null when the appliance does not say. */
370906
+ machineCareRemainingRuns: zod.z.number().int().nonnegative().nullable(),
370688
370907
  /** Option states: null when the appliance does not expose the option or has not said. */
370689
370908
  halfLoad: zod.z.boolean().nullable(),
370690
370909
  hygienePlus: zod.z.boolean().nullable(),
@@ -379178,16 +379397,6 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
379178
379397
  allowedDevices: zod.z.record(zod.z.string(), zod.z.union([zod.z.array(zod.z.string()), zod.z.literal("*")])).optional(),
379179
379398
  scopes: zod.z.array(TokenScopeSchema).optional()
379180
379399
  });
379181
- var ApiKeySummarySchema = zod.z.object({
379182
- id: zod.z.string(),
379183
- label: zod.z.string(),
379184
- isAdmin: zod.z.boolean().default(false),
379185
- allowedProviders: zod.z.union([zod.z.array(zod.z.string()), zod.z.literal("*")]).optional(),
379186
- allowedDevices: zod.z.record(zod.z.string(), zod.z.union([zod.z.array(zod.z.string()), zod.z.literal("*")])).optional(),
379187
- tokenPrefix: zod.z.string(),
379188
- createdAt: zod.z.number(),
379189
- lastUsedAt: zod.z.number().optional()
379190
- });
379191
379400
  var OauthSessionSummarySchema = zod.z.object({
379192
379401
  id: zod.z.string(),
379193
379402
  userId: zod.z.string(),
@@ -379268,12 +379477,6 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
379268
379477
  kind: "mutation",
379269
379478
  access: "view"
379270
379479
  }),
379271
- listApiKeys: require_sleep.method(zod.z.void(), zod.z.array(ApiKeySummarySchema), { auth: "admin" }),
379272
- revokeApiKey: require_sleep.method(zod.z.object({ id: zod.z.string() }), zod.z.object({ success: zod.z.literal(true) }), {
379273
- kind: "mutation",
379274
- auth: "admin",
379275
- access: "delete"
379276
- }),
379277
379480
  setupTotp: require_sleep.method(zod.z.object({ userId: zod.z.string() }), TotpSetupResultSchema, {
379278
379481
  kind: "mutation",
379279
379482
  auth: "admin",
@@ -389960,6 +390163,12 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
389960
390163
  addonId: null,
389961
390164
  access: "view"
389962
390165
  },
390166
+ "records.transact": {
390167
+ capName: "records",
390168
+ capScope: "system",
390169
+ addonId: null,
390170
+ access: "create"
390171
+ },
389963
390172
  "sceneMonitor.captureReference": {
389964
390173
  capName: "scene-monitor",
389965
390174
  capScope: "device",
@@ -391292,12 +391501,6 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
391292
391501
  addonId: null,
391293
391502
  access: "view"
391294
391503
  },
391295
- "userManagement.listApiKeys": {
391296
- capName: "user-management",
391297
- capScope: "system",
391298
- addonId: null,
391299
- access: "view"
391300
- },
391301
391504
  "userManagement.listExternalIdentities": {
391302
391505
  capName: "user-management",
391303
391506
  capScope: "system",
@@ -391352,12 +391555,6 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
391352
391555
  addonId: null,
391353
391556
  access: "create"
391354
391557
  },
391355
- "userManagement.revokeApiKey": {
391356
- capName: "user-management",
391357
- capScope: "system",
391358
- addonId: null,
391359
- access: "delete"
391360
- },
391361
391558
  "userManagement.revokeOauthSession": {
391362
391559
  capName: "user-management",
391363
391560
  capScope: "system",
@@ -399617,8 +399814,6 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
399617
399814
  resetPassword: (input) => dispatch("userManagement", "resetPassword", "mutation", input),
399618
399815
  setUserScopes: (input) => dispatch("userManagement", "setUserScopes", "mutation", input),
399619
399816
  validateCredentials: (input) => dispatch("userManagement", "validateCredentials", "mutation", input),
399620
- listApiKeys: (input) => dispatch("userManagement", "listApiKeys", "query", input),
399621
- revokeApiKey: (input) => dispatch("userManagement", "revokeApiKey", "mutation", input),
399622
399817
  setupTotp: (input) => dispatch("userManagement", "setupTotp", "mutation", input),
399623
399818
  confirmTotp: (input) => dispatch("userManagement", "confirmTotp", "mutation", input),
399624
399819
  disableTotp: (input) => dispatch("userManagement", "disableTotp", "mutation", input),
@@ -400056,9 +400251,9 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
400056
400251
  function systemEventFilterApplies(kind, filter) {
400057
400252
  switch (filter) {
400058
400253
  case "deviceIds":
400059
- return kind.startsWith("device-") || kind.startsWith("stream-") || kind === "detection-blind" || kind.startsWith("recording-") || kind === "alarm-triggered";
400254
+ return kind.startsWith("device-") || kind.startsWith("stream-") || kind === "detection-blind" || kind.startsWith("motion-") || kind.startsWith("recording-") || kind === "alarm-triggered";
400060
400255
  case "deviceTypes":
400061
- return kind.startsWith("device-") || kind === "detection-blind";
400256
+ return kind.startsWith("device-") || kind === "detection-blind" || kind.startsWith("motion-");
400062
400257
  case "nodeIds":
400063
400258
  return kind.startsWith("node-") || kind === "addon-crash-loop" || kind === "addon-update-available" || kind === "addon-updated" || kind === "server-update-available" || kind === "wrapper-update-available" || kind === "server-updated" || kind.startsWith("storage-location-") || kind.startsWith("alert-");
400064
400259
  case "packageNames":
@@ -400093,9 +400288,13 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
400093
400288
  "stream-online": "device-events",
400094
400289
  "stream-offline": "device-events",
400095
400290
  "detection-blind": "device-events",
400291
+ "motion-noisy": "device-events",
400292
+ "motion-calm": "device-events",
400096
400293
  "recording-stalled": "device-events",
400097
400294
  "recording-healthy": "device-events",
400098
400295
  "recording-degraded": "device-events",
400296
+ "device-attention-required": "device-events",
400297
+ "device-attention-resolved": "device-events",
400099
400298
  "node-online": "system",
400100
400299
  "node-offline": "system",
400101
400300
  "node-restarting": "system",
@@ -400189,6 +400388,12 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
400189
400388
  label: "Detecting nothing",
400190
400389
  kinds: ["detection-blind"]
400191
400390
  },
400391
+ {
400392
+ id: "motion-noise",
400393
+ family: "device-events",
400394
+ label: "Motion without a subject",
400395
+ kinds: ["motion-noisy", "motion-calm"]
400396
+ },
400192
400397
  {
400193
400398
  id: "recording",
400194
400399
  family: "device-events",
@@ -400199,6 +400404,12 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
400199
400404
  "recording-degraded"
400200
400405
  ]
400201
400406
  },
400407
+ {
400408
+ id: "device-attention",
400409
+ family: "device-events",
400410
+ label: "Needs attention",
400411
+ kinds: ["device-attention-required", "device-attention-resolved"]
400412
+ },
400202
400413
  {
400203
400414
  id: "nodes",
400204
400415
  family: "system",
@@ -401607,6 +401818,10 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
401607
401818
  if (severity === "error" && phase === "raised") return "alert-error";
401608
401819
  return null;
401609
401820
  }
401821
+ function deviceAttentionKind(severity, phase) {
401822
+ if (severity !== "critical") return null;
401823
+ return phase === "raised" ? "device-attention-required" : "device-attention-resolved";
401824
+ }
401610
401825
  function alertEpisodePayload(alert, phase, at) {
401611
401826
  const nodeId = alertNodeId(alert);
401612
401827
  return {
@@ -401640,6 +401855,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
401640
401855
  "alert-error",
401641
401856
  "alert-critical-resolved"
401642
401857
  ];
401858
+ var DEVICE_ATTENTION = ["device-attention-required", "device-attention-resolved"];
401643
401859
  var UPDATES = [
401644
401860
  "addon-update-available",
401645
401861
  "server-update-available",
@@ -401669,9 +401885,12 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
401669
401885
  "stream-online",
401670
401886
  "stream-offline",
401671
401887
  "detection-blind",
401888
+ "motion-noisy",
401889
+ "motion-calm",
401672
401890
  "recording-stalled",
401673
401891
  "recording-healthy",
401674
401892
  "recording-degraded",
401893
+ ...DEVICE_ATTENTION,
401675
401894
  ...ALARM
401676
401895
  ];
401677
401896
  var SUMMARISABLE = [...systemEventKindsOfFamily("device-events"), ...systemEventKindsOfFamily("system")];
@@ -402242,7 +402461,36 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
402242
402461
  families: ["rule"],
402243
402462
  fields: [...RULE_TEXT],
402244
402463
  kinds: ["system"],
402245
- systemEventKinds: ["detection-blind", "recording-stalled"]
402464
+ systemEventKinds: [
402465
+ "detection-blind",
402466
+ "motion-noisy",
402467
+ "motion-calm",
402468
+ "recording-stalled"
402469
+ ]
402470
+ },
402471
+ {
402472
+ name: "duty",
402473
+ label: "Motion share (%)",
402474
+ example: "55",
402475
+ group: "system",
402476
+ families: ["rule"],
402477
+ fields: [...RULE_TEXT],
402478
+ kinds: ["system"],
402479
+ systemEventKinds: ["motion-noisy", "motion-calm"]
402480
+ },
402481
+ {
402482
+ name: "sessions",
402483
+ label: "Detection sessions",
402484
+ example: "96",
402485
+ group: "system",
402486
+ families: ["rule"],
402487
+ fields: [...RULE_TEXT],
402488
+ kinds: ["system"],
402489
+ systemEventKinds: [
402490
+ "detection-blind",
402491
+ "motion-noisy",
402492
+ "motion-calm"
402493
+ ]
402246
402494
  },
402247
402495
  {
402248
402496
  name: "message",
@@ -402252,7 +402500,11 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
402252
402500
  families: ["rule"],
402253
402501
  fields: [...RULE_TEXT],
402254
402502
  kinds: ["system"],
402255
- systemEventKinds: ["recording-degraded", ...ALERT_EPISODE]
402503
+ systemEventKinds: [
402504
+ "recording-degraded",
402505
+ ...DEVICE_ATTENTION,
402506
+ ...ALERT_EPISODE
402507
+ ]
402256
402508
  },
402257
402509
  {
402258
402510
  name: "ruleName",
@@ -402496,7 +402748,11 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
402496
402748
  families: ["rule"],
402497
402749
  fields: [...RULE_TEXT],
402498
402750
  kinds: ["system"],
402499
- systemEventKinds: ["export-completed", ...ALERT_EPISODE]
402751
+ systemEventKinds: [
402752
+ "export-completed",
402753
+ ...DEVICE_ATTENTION,
402754
+ ...ALERT_EPISODE
402755
+ ]
402500
402756
  },
402501
402757
  {
402502
402758
  name: "severity",
@@ -402516,7 +402772,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
402516
402772
  families: ["rule"],
402517
402773
  fields: [...RULE_TEXT],
402518
402774
  kinds: ["system"],
402519
- systemEventKinds: [...ALERT_EPISODE]
402775
+ systemEventKinds: [...DEVICE_ATTENTION, ...ALERT_EPISODE]
402520
402776
  },
402521
402777
  {
402522
402778
  name: "source",
@@ -402536,7 +402792,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
402536
402792
  families: ["rule"],
402537
402793
  fields: [...RULE_TEXT],
402538
402794
  kinds: ["system"],
402539
- systemEventKinds: [...ALERT_EPISODE]
402795
+ systemEventKinds: [...DEVICE_ATTENTION, ...ALERT_EPISODE]
402540
402796
  },
402541
402797
  {
402542
402798
  name: "exportId",
@@ -402736,6 +402992,8 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
402736
402992
  "alert-critical",
402737
402993
  "alert-error",
402738
402994
  "alert-critical-resolved",
402995
+ "device-attention-required",
402996
+ "device-attention-resolved",
402739
402997
  "rule-broken",
402740
402998
  "rule-repaired"
402741
402999
  ];
@@ -402849,6 +403107,15 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
402849
403107
  snapshotLabel: "Tanks low or full now",
402850
403108
  snapshotSection: "tanks"
402851
403109
  },
403110
+ {
403111
+ id: "motion-noise",
403112
+ family: "device-events",
403113
+ label: "Motion without a subject (constant / calm again)",
403114
+ bad: ["motion-noisy"],
403115
+ recovery: ["motion-calm"],
403116
+ snapshotLabel: "Cameras with constant motion now",
403117
+ snapshotSection: null
403118
+ },
402852
403119
  {
402853
403120
  id: "recording-health",
402854
403121
  family: "device-events",
@@ -402858,6 +403125,15 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
402858
403125
  snapshotLabel: "Recordings stalled now",
402859
403126
  snapshotSection: null
402860
403127
  },
403128
+ {
403129
+ id: "device-attention",
403130
+ family: "device-events",
403131
+ label: "Device needs attention (raised / resolved)",
403132
+ bad: ["device-attention-required"],
403133
+ recovery: ["device-attention-resolved"],
403134
+ snapshotLabel: "Devices needing attention now",
403135
+ snapshotSection: null
403136
+ },
402861
403137
  {
402862
403138
  id: "node-connectivity",
402863
403139
  family: "system",
@@ -404265,7 +404541,12 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
404265
404541
  fps: 19,
404266
404542
  measured: true
404267
404543
  }
404268
- }
404544
+ },
404545
+ coral: { "yolov9s-320-edgetpu": {
404546
+ p50Ms: 32,
404547
+ fps: 31,
404548
+ measured: false
404549
+ } }
404269
404550
  },
404270
404551
  "intel-n-series": {
404271
404552
  "intel-igpu": {
@@ -404391,7 +404672,12 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
404391
404672
  fps: 3,
404392
404673
  measured: true
404393
404674
  }
404394
- }
404675
+ },
404676
+ coral: { "yolov9s-320-edgetpu": {
404677
+ p50Ms: 32,
404678
+ fps: 31,
404679
+ measured: false
404680
+ } }
404395
404681
  },
404396
404682
  "amd-phoenix": {
404397
404683
  "x86-cpu": {
@@ -404458,96 +404744,120 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
404458
404744
  },
404459
404745
  "amd-igpu": {
404460
404746
  "yolov9t-320": {
404461
- p50Ms: 188,
404462
- fps: 5,
404747
+ p50Ms: 40,
404748
+ fps: 25,
404463
404749
  measured: true
404464
404750
  },
404465
404751
  "yolov9t-640": {
404466
- p50Ms: 671,
404467
- fps: 1,
404752
+ p50Ms: 89,
404753
+ fps: 11,
404468
404754
  measured: true
404469
404755
  },
404470
404756
  "yolov9s-320": {
404471
- p50Ms: 401,
404472
- fps: 2,
404757
+ p50Ms: 65,
404758
+ fps: 15,
404473
404759
  measured: true
404474
404760
  },
404475
404761
  "yolov9s-640": {
404476
- p50Ms: 1434,
404477
- fps: 1,
404762
+ p50Ms: 125,
404763
+ fps: 8,
404478
404764
  measured: true
404479
404765
  },
404480
404766
  "yolov9m-320": {
404481
- p50Ms: 1076,
404482
- fps: 1,
404767
+ p50Ms: 85,
404768
+ fps: 12,
404769
+ measured: true
404770
+ },
404771
+ "yolov9m-640": {
404772
+ p50Ms: 228,
404773
+ fps: 4,
404483
404774
  measured: true
404484
404775
  }
404485
- }
404486
- },
404487
- "apple-m-pro": { "apple-ane": {
404488
- "yolov9t-320": {
404489
- p50Ms: 1.1,
404490
- fps: 952,
404491
- measured: true
404492
- },
404493
- "yolov9t-640": {
404494
- p50Ms: 3,
404495
- fps: 333,
404496
- measured: true
404497
- },
404498
- "yolov9s-320": {
404499
- p50Ms: 1.5,
404500
- fps: 667,
404501
- measured: true
404502
- },
404503
- "yolov9s-640": {
404504
- p50Ms: 5.1,
404505
- fps: 196,
404506
- measured: true
404507
404776
  },
404508
- "yolov9m-320": {
404509
- p50Ms: 3.2,
404510
- fps: 312,
404777
+ coral: { "yolov9s-320-edgetpu": {
404778
+ p50Ms: 32,
404779
+ fps: 31,
404511
404780
  measured: true
404781
+ } }
404782
+ },
404783
+ "apple-m-pro": {
404784
+ "apple-ane": {
404785
+ "yolov9t-320": {
404786
+ p50Ms: 1.1,
404787
+ fps: 952,
404788
+ measured: true
404789
+ },
404790
+ "yolov9t-640": {
404791
+ p50Ms: 3,
404792
+ fps: 333,
404793
+ measured: true
404794
+ },
404795
+ "yolov9s-320": {
404796
+ p50Ms: 1.5,
404797
+ fps: 667,
404798
+ measured: true
404799
+ },
404800
+ "yolov9s-640": {
404801
+ p50Ms: 5.1,
404802
+ fps: 196,
404803
+ measured: true
404804
+ },
404805
+ "yolov9m-320": {
404806
+ p50Ms: 3.2,
404807
+ fps: 312,
404808
+ measured: true
404809
+ },
404810
+ "yolov9m-640": {
404811
+ p50Ms: 10.2,
404812
+ fps: 98,
404813
+ measured: true
404814
+ }
404512
404815
  },
404513
- "yolov9m-640": {
404514
- p50Ms: 10.2,
404515
- fps: 98,
404516
- measured: true
404517
- }
404518
- } },
404519
- "apple-m-base": { "apple-ane": {
404520
- "yolov9t-320": {
404521
- p50Ms: 1.32,
404522
- fps: 758,
404816
+ coral: { "yolov9s-320-edgetpu": {
404817
+ p50Ms: 32,
404818
+ fps: 31,
404523
404819
  measured: false
404820
+ } }
404821
+ },
404822
+ "apple-m-base": {
404823
+ "apple-ane": {
404824
+ "yolov9t-320": {
404825
+ p50Ms: 1.32,
404826
+ fps: 758,
404827
+ measured: false
404828
+ },
404829
+ "yolov9t-640": {
404830
+ p50Ms: 3.45,
404831
+ fps: 290,
404832
+ measured: true
404833
+ },
404834
+ "yolov9s-320": {
404835
+ p50Ms: 1.8,
404836
+ fps: 556,
404837
+ measured: false
404838
+ },
404839
+ "yolov9s-640": {
404840
+ p50Ms: 5.46,
404841
+ fps: 183,
404842
+ measured: true
404843
+ },
404844
+ "yolov9m-320": {
404845
+ p50Ms: 3.79,
404846
+ fps: 264,
404847
+ measured: true
404848
+ },
404849
+ "yolov9m-640": {
404850
+ p50Ms: 10.34,
404851
+ fps: 97,
404852
+ measured: true
404853
+ }
404524
404854
  },
404525
- "yolov9t-640": {
404526
- p50Ms: 3.45,
404527
- fps: 290,
404528
- measured: true
404529
- },
404530
- "yolov9s-320": {
404531
- p50Ms: 1.8,
404532
- fps: 556,
404855
+ coral: { "yolov9s-320-edgetpu": {
404856
+ p50Ms: 32,
404857
+ fps: 31,
404533
404858
  measured: false
404534
- },
404535
- "yolov9s-640": {
404536
- p50Ms: 5.46,
404537
- fps: 183,
404538
- measured: true
404539
- },
404540
- "yolov9m-320": {
404541
- p50Ms: 3.79,
404542
- fps: 264,
404543
- measured: true
404544
- },
404545
- "yolov9m-640": {
404546
- p50Ms: 10.34,
404547
- fps: 97,
404548
- measured: true
404549
- }
404550
- } }
404859
+ } }
404860
+ }
404551
404861
  };
404552
404862
  var DETECTOR_ACCURACY = {
404553
404863
  "yolov9m-320": {
@@ -404600,6 +404910,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
404600
404910
  }
404601
404911
  };
404602
404912
  var AUTO_TUNE_FAMILY = "yolov9";
404913
+ var CORAL_DEFAULT_MODEL_ID = "yolov9s-320-edgetpu";
404603
404914
  var RECALL_TIE = 0.02;
404604
404915
  var DEFAULT_HEADROOM = 0.4;
404605
404916
  var DEFAULT_CAMERA_FPS = 10;
@@ -404751,12 +405062,9 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
404751
405062
  const devices = node.devices.toSorted((a, b) => a.key.localeCompare(b.key));
404752
405063
  const contexts = /* @__PURE__ */ new Map();
404753
405064
  const early = /* @__PURE__ */ new Map();
405065
+ const corals = [];
404754
405066
  for (const device2 of devices) {
404755
405067
  const accelerator = acceleratorKindOf(device2.key, hardware);
404756
- if (accelerator === "coral") {
404757
- early.set(device2.key, device2.enabled ? [{ kind: "coral-untouched" }] : []);
404758
- continue;
404759
- }
404760
405068
  if (!device2.enabled) {
404761
405069
  early.set(device2.key, [{ kind: "device-disabled" }]);
404762
405070
  continue;
@@ -404765,6 +405073,23 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
404765
405073
  early.set(device2.key, [{ kind: "device-unavailable" }]);
404766
405074
  continue;
404767
405075
  }
405076
+ if (accelerator === "coral") {
405077
+ const column2 = overlayMeasured(classTable.coral, measured[device2.key]);
405078
+ const builds = node.formatsByModel["yolov9s-320-edgetpu"] ?? [];
405079
+ if (column2?.["yolov9s-320-edgetpu"] === void 0 || !builds.includes(device2.format)) {
405080
+ early.set(device2.key, [{
405081
+ kind: "no-family-build",
405082
+ format: device2.format
405083
+ }]);
405084
+ continue;
405085
+ }
405086
+ corals.push({
405087
+ device: device2,
405088
+ accelerator,
405089
+ column: column2
405090
+ });
405091
+ continue;
405092
+ }
404768
405093
  const column = accelerator === null ? void 0 : overlayMeasured(classTable[accelerator], measured[device2.key]);
404769
405094
  if (accelerator === null || column === void 0) {
404770
405095
  early.set(device2.key, [{
@@ -404815,6 +405140,12 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
404815
405140
  kind: "no-family-build",
404816
405141
  format: ctx.device.format
404817
405142
  }]);
405143
+ for (const ctx of corals) {
405144
+ const choice = choiceOn(ctx, CORAL_DEFAULT_MODEL_ID, sizing);
405145
+ if (choice === null) continue;
405146
+ chosenByKey.set(ctx.device.key, choice);
405147
+ reasonsByKey.set(ctx.device.key, deviceReasonsFor(choice, sizing));
405148
+ }
404818
405149
  for (const ctx of cpus) {
404819
405150
  const pick2 = pickForGroup([ctx], node.formatsByModel, sizing);
404820
405151
  const choice = pick2 === null ? null : choiceOn(ctx, pick2.modelId, sizing);
@@ -404862,10 +405193,11 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
404862
405193
  function electByShare(candidates) {
404863
405194
  if (candidates.length === 0) return { kind: "none" };
404864
405195
  const shareSum = candidates.reduce((s, c) => s + Math.max(c.share, 0), 0);
404865
- const running = candidates.reduce((s, c) => s + Math.max(c.running, 0), 0);
405196
+ const loadOf = (c) => Math.max(c.running, 0) + Math.max(c.recent ?? 0, 0);
405197
+ const running = candidates.reduce((s, c) => s + loadOf(c), 0);
404866
405198
  const scored = candidates.map((candidate) => ({
404867
405199
  candidate,
404868
- deficit: (shareSum > 0 ? Math.max(candidate.share, 0) / shareSum : 1 / candidates.length) * (running + 1) - candidate.running
405200
+ deficit: (shareSum > 0 ? Math.max(candidate.share, 0) / shareSum : 1 / candidates.length) * (running + 1) - loadOf(candidate)
404869
405201
  })).toSorted(byDeficit);
404870
405202
  const turn = scored[0].candidate;
404871
405203
  if (!turn.capped && !turn.saturated) return {
@@ -404944,6 +405276,28 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
404944
405276
  deviceWeights
404945
405277
  };
404946
405278
  }
405279
+ function capacityForModel(node, deviceKey, modelId) {
405280
+ if (node === void 0 || modelId === null) return void 0;
405281
+ return node.devices.filter((d) => d.deviceKey === deviceKey && d.modelId === modelId).toSorted((a, b) => b.measuredAtMs - a.measuredAtMs)[0];
405282
+ }
405283
+ function foreignCapacityCells(recommendations, measured) {
405284
+ const out = [];
405285
+ for (const rec of recommendations) {
405286
+ const node = measured.get(rec.nodeId);
405287
+ if (node === void 0) continue;
405288
+ for (const cell of node.devices) {
405289
+ const runs = rec.devices.find((d) => d.deviceKey === cell.deviceKey)?.chosen?.modelId ?? null;
405290
+ if (cell.modelId === null || cell.modelId === runs) continue;
405291
+ out.push({
405292
+ nodeId: rec.nodeId,
405293
+ deviceKey: cell.deviceKey,
405294
+ measuredModelId: cell.modelId,
405295
+ runsModelId: runs
405296
+ });
405297
+ }
405298
+ }
405299
+ return out;
405300
+ }
404947
405301
  var NO_MEASURED_CAPACITY = { readMeasuredCapacity: async () => /* @__PURE__ */ new Map() };
404948
405302
  function toPercentShares(weights) {
404949
405303
  const total = [...weights.values()].reduce((a, b) => a + b, 0);
@@ -404995,7 +405349,11 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
404995
405349
  if (input.source === "hardware") return fromHardware(null);
404996
405350
  if (!rec.reachable) return fromHardware(null);
404997
405351
  const results = input.measured.get(rec.nodeId);
404998
- const byKey = new Map((results?.devices ?? []).map((d) => [d.deviceKey, d]));
405352
+ const byKey = /* @__PURE__ */ new Map();
405353
+ for (const d of rec.devices) {
405354
+ const row = capacityForModel(results, d.deviceKey, d.chosen?.modelId ?? null);
405355
+ if (row !== void 0) byKey.set(d.deviceKey, row);
405356
+ }
404999
405357
  const usable = rec.devices.filter((d) => d.enabled && d.available);
405000
405358
  const mustCover = rec.devices.filter((d) => d.enabled && d.available && d.chosen !== null);
405001
405359
  const covered = usable.filter((d) => byKey.has(d.deviceKey));
@@ -405216,13 +405574,18 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
405216
405574
  }
405217
405575
  return out;
405218
405576
  }
405577
+ function sessionsOfDeviceCell(kMax) {
405578
+ return Math.max(0, Math.floor(kMax));
405579
+ }
405219
405580
  function measuredCapacityFromResults(rows, nodeIds, ctx) {
405220
405581
  const byNode = /* @__PURE__ */ new Map();
405221
405582
  for (const row of freshResults(rows, ctx)) {
405222
- if (!nodeIds.includes(row.nodeId) || row.cell.phase !== "pipeline") continue;
405583
+ if (!nodeIds.includes(row.nodeId)) continue;
405584
+ const candidate = capacityOfRow(row);
405223
405585
  const devices = byNode.get(row.nodeId) ?? /* @__PURE__ */ new Map();
405224
- const held = devices.get(row.cell.deviceKey);
405225
- if (held === void 0 || row.measuredAtMs > held.measuredAtMs) devices.set(row.cell.deviceKey, row);
405586
+ const key = `${candidate.deviceKey}\0${candidate.modelId ?? ""}`;
405587
+ const held = devices.get(key);
405588
+ if (held === void 0 || betterCapacityCell(candidate, held)) devices.set(key, candidate);
405226
405589
  byNode.set(row.nodeId, devices);
405227
405590
  }
405228
405591
  const out = /* @__PURE__ */ new Map();
@@ -405231,16 +405594,31 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
405231
405594
  if (devices === void 0) continue;
405232
405595
  out.set(nodeId, {
405233
405596
  nodeId,
405234
- devices: [...devices.values()].toSorted((a, b) => a.cell.deviceKey.localeCompare(b.cell.deviceKey)).map((r) => ({
405235
- deviceKey: r.cell.deviceKey,
405236
- maxSessions: r.cell.phase === "pipeline" ? r.cell.maxSessions : 0,
405237
- modelId: r.cell.modelId,
405238
- measuredAtMs: r.measuredAtMs
405239
- }))
405597
+ devices: [...devices.values()].toSorted((a, b) => a.deviceKey.localeCompare(b.deviceKey) || (a.modelId ?? "").localeCompare(b.modelId ?? ""))
405240
405598
  });
405241
405599
  }
405242
405600
  return out;
405243
405601
  }
405602
+ function capacityOfRow(row) {
405603
+ const { cell } = row;
405604
+ return cell.phase === "pipeline" ? {
405605
+ deviceKey: cell.deviceKey,
405606
+ maxSessions: cell.maxSessions,
405607
+ modelId: cell.modelId,
405608
+ measuredAtMs: row.measuredAtMs,
405609
+ phase: "pipeline"
405610
+ } : {
405611
+ deviceKey: cell.deviceKey,
405612
+ maxSessions: sessionsOfDeviceCell(cell.kMax),
405613
+ modelId: cell.modelId,
405614
+ measuredAtMs: row.measuredAtMs,
405615
+ phase: "device"
405616
+ };
405617
+ }
405618
+ function betterCapacityCell(a, b) {
405619
+ if (a.phase !== b.phase) return a.phase === "pipeline";
405620
+ return a.measuredAtMs > b.measuredAtMs;
405621
+ }
405244
405622
  var BENCH_ROOT_STEP_ID = "object-detection";
405245
405623
  function slotAddons(schema, slot) {
405246
405624
  return schema.slots.find((s) => s.id === slot)?.addons ?? [];
@@ -407035,8 +407413,6 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
407035
407413
  exports.AlertStatusSchema = AlertStatusSchema;
407036
407414
  exports.AmbientLightSensorStatusSchema = AmbientLightSensorStatusSchema;
407037
407415
  exports.AnalyticsLtsSeriesSchema = AnalyticsLtsSeriesSchema;
407038
- exports.ApiKeyRecordSchema = ApiKeyRecordSchema;
407039
- exports.ApiKeySummarySchema = ApiKeySummarySchema;
407040
407416
  exports.AppFlowPurposeSchema = AppFlowPurposeSchema;
407041
407417
  exports.AppLoginPathSchema = AppLoginPathSchema;
407042
407418
  exports.AppPageLangSchema = AppPageLangSchema;
@@ -407181,6 +407557,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
407181
407557
  exports.COMPOSITION_ITEM_KEY_RE = require_composition.COMPOSITION_ITEM_KEY_RE;
407182
407558
  exports.CONNECTION_TEST_TIMEOUT_MS = CONNECTION_TEST_TIMEOUT_MS;
407183
407559
  exports.CONTAINER_CHILD_PRIORITY = CONTAINER_CHILD_PRIORITY;
407560
+ exports.CORAL_DEFAULT_MODEL_ID = CORAL_DEFAULT_MODEL_ID;
407184
407561
  exports.CORE_BLOCKS_ADDON_ID = CORE_BLOCKS_ADDON_ID;
407185
407562
  exports.CORE_BLOCK_ADDON_PREFIX = CORE_BLOCK_ADDON_PREFIX;
407186
407563
  exports.CREDENTIAL_TOKEN_AUDIENCE = CREDENTIAL_TOKEN_AUDIENCE;
@@ -408423,6 +408800,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
408423
408800
  exports.RecordSecretRefsSchema = RecordSecretRefsSchema;
408424
408801
  exports.RecordSecretUnavailableError = require_sleep.RecordSecretUnavailableError;
408425
408802
  exports.RecordTooLargeError = require_sleep.RecordTooLargeError;
408803
+ exports.RecordTransactOpSchema = RecordTransactOpSchema;
408426
408804
  exports.RecordTriggerSchema = RecordTriggerSchema;
408427
408805
  exports.RecordUniqueViolationError = require_sleep.RecordUniqueViolationError;
408428
408806
  exports.RecordViewSchema = RecordViewSchema;
@@ -408692,6 +409070,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
408692
409070
  exports.StorageTableSchema = StorageTableSchema;
408693
409071
  exports.StorageTestLocationResultSchema = TestLocationResultSchema;
408694
409072
  exports.StorageWriteChunkInputSchema = WriteChunkInputSchema;
409073
+ exports.StoredRecordKindDeclarationSchema = require_sleep.StoredRecordKindDeclarationSchema;
408695
409074
  exports.StreamCodecSchema = StreamCodecSchema;
408696
409075
  exports.StreamFormatSchema = StreamFormatSchema;
408697
409076
  exports.StreamNetworkStatsSchema = StreamNetworkStatsSchema;
@@ -408798,6 +409177,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
408798
409177
  exports.TrainingResultSchema = TrainingResultSchema;
408799
409178
  exports.TrainingSplitPlanSchema = TrainingSplitPlanSchema;
408800
409179
  exports.TrainingStageSchema = TrainingStageSchema;
409180
+ exports.TransactRefusedError = require_sleep.TransactRefusedError;
408801
409181
  exports.TransportPlaneCountsSchema = TransportPlaneCountsSchema;
408802
409182
  exports.TransportPlaneSchema = TransportPlaneSchema;
408803
409183
  exports.TurnServerSchema = TurnServerSchema;
@@ -408932,6 +409312,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
408932
409312
  exports.asRecordsError = require_sleep.asRecordsError;
408933
409313
  exports.asString = require_sleep.asString;
408934
409314
  exports.assertTimelapseCadences = assertTimelapseCadences;
409315
+ exports.assertTransactScope = require_sleep.assertTransactScope;
408935
409316
  exports.assertValidDeclaration = require_sleep.assertValidDeclaration;
408936
409317
  exports.assignNodeColorId = require_node_color2.assignNodeColorId;
408937
409318
  exports.audioAnalysisCapability = audioAnalysisCapability;
@@ -408995,6 +409376,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
408995
409376
  exports.canonicalIconKey = canonicalIconKey;
408996
409377
  exports.canonicalizeAppCallback = canonicalizeAppCallback;
408997
409378
  exports.capabilityScopesOf = capabilityScopesOf;
409379
+ exports.capacityForModel = capacityForModel;
408998
409380
  exports.capacitySessionsOf = capacitySessionsOf;
408999
409381
  exports.carbonMonoxideCapability = carbonMonoxideCapability;
409000
409382
  exports.cellsToRects = cellsToRects;
@@ -409129,6 +409511,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
409129
409511
  exports.detectionPipelineCapability = detectionPipelineCapability;
409130
409512
  exports.deviceAdminLinkCapability = deviceAdminLinkCapability;
409131
409513
  exports.deviceAdoptionCapability = deviceAdoptionCapability;
409514
+ exports.deviceAttentionKind = deviceAttentionKind;
409132
409515
  exports.deviceBackendToFormat = deviceBackendToFormat;
409133
409516
  exports.deviceCredentialsCapability = deviceCredentialsCapability;
409134
409517
  exports.deviceCustomAction = require_sleep.deviceCustomAction;
@@ -409222,6 +409605,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
409222
409605
  exports.findTimezone = findTimezone;
409223
409606
  exports.floodCapability = floodCapability;
409224
409607
  exports.foldSnapshotByFunction = foldSnapshotByFunction;
409608
+ exports.foreignCapacityCells = foreignCapacityCells;
409225
409609
  exports.forgetKnownSecret = require_sleep.forgetKnownSecret;
409226
409610
  exports.formatDeviceRevoker = formatDeviceRevoker;
409227
409611
  exports.formatForRuntime = formatForRuntime;
@@ -409653,6 +410037,7 @@ ${recipe.triggers.map((t, i) => emitTrigger(t, i)).join("\n\n")}
409653
410037
  exports.sensorTransitionOffered = sensorTransitionOffered;
409654
410038
  exports.servedTemplateVars = servedTemplateVars;
409655
410039
  exports.serverManagementCapability = serverManagementCapability;
410040
+ exports.sessionsOfDeviceCell = sessionsOfDeviceCell;
409656
410041
  exports.setByPath = setByPath;
409657
410042
  exports.settingValuesEqual = settingValuesEqual;
409658
410043
  exports.settingsBelow = settingsBelow;
@@ -589765,6 +590150,7 @@ var require_addon_registry_service = __commonJS({
589765
590150
  histogram: (input) => provider().histogram(as(input)),
589766
590151
  aggregate: (input) => provider().aggregate(as(input)),
589767
590152
  deleteWhere: (input) => provider().deleteWhere(as(input)),
590153
+ transact: (input) => provider().transact(as(input)),
589768
590154
  deleteDevice: (input) => provider().deleteDevice(as(input)),
589769
590155
  allocateId: (input) => provider().allocateId(as(input))
589770
590156
  };
@@ -593880,7 +594266,8 @@ var require_logging_service = __commonJS({
593880
594266
  ...entry.tags,
593881
594267
  addonId: entry.addonId,
593882
594268
  ...nodeId !== void 0 ? { nodeId } : {},
593883
- ...agentId !== void 0 ? { agentId } : {}
594269
+ ...agentId !== void 0 ? { agentId } : {},
594270
+ ...typeof entry.tags?.nodeId === "string" ? { nodeId: entry.tags.nodeId } : {}
593884
594271
  };
593885
594272
  logger = logger.withTags(mergedTags);
593886
594273
  const level = entry.level;