@camstack/addon-export-alexa 1.2.173 → 1.2.174

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.
@@ -5453,7 +5453,7 @@ var ZodIssueCode = {
5453
5453
  var ZodFirstPartyTypeKind;
5454
5454
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5455
5455
  //#endregion
5456
- //#region ../types/dist/sleep-Crlmu_tO.mjs
5456
+ //#region ../types/dist/sleep-DJws6ho7.mjs
5457
5457
  /**
5458
5458
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5459
5459
  * window to float samples (D455).
@@ -8609,6 +8609,7 @@ var CAP_NAMES = Object.freeze([
8609
8609
  "image-settings",
8610
8610
  "integrations",
8611
8611
  "intercom",
8612
+ "ir-transmitter",
8612
8613
  "keychain",
8613
8614
  "keychain-admin",
8614
8615
  "lawn-mower-control",
@@ -8667,6 +8668,7 @@ var CAP_NAMES = Object.freeze([
8667
8668
  "recording-onboard",
8668
8669
  "recording-signal",
8669
8670
  "records",
8671
+ "remote",
8670
8672
  "running-state",
8671
8673
  "scene-monitor",
8672
8674
  "script-runner",
@@ -8690,6 +8692,7 @@ var CAP_NAMES = Object.freeze([
8690
8692
  "system",
8691
8693
  "tamper",
8692
8694
  "temperature-sensor",
8695
+ "template",
8693
8696
  "terminal-session",
8694
8697
  "toast",
8695
8698
  "training",
@@ -9630,6 +9633,11 @@ Object.freeze({
9630
9633
  "standby"
9631
9634
  ]
9632
9635
  },
9636
+ {
9637
+ "path": "stateSource",
9638
+ "valueType": "enum",
9639
+ "enumValues": ["reported", "assumed"]
9640
+ },
9633
9641
  {
9634
9642
  "path": "volumeLevel",
9635
9643
  "valueType": "number"
@@ -9856,6 +9864,11 @@ Object.freeze({
9856
9864
  "path": "batteryPower",
9857
9865
  "valueType": "number"
9858
9866
  },
9867
+ {
9868
+ "path": "powerSource",
9869
+ "valueType": "enum",
9870
+ "enumValues": ["mains", "battery"]
9871
+ },
9859
9872
  {
9860
9873
  "path": "desiccantLeftDays",
9861
9874
  "valueType": "number"
@@ -9900,6 +9913,18 @@ Object.freeze({
9900
9913
  {
9901
9914
  "path": "volume",
9902
9915
  "valueType": "number"
9916
+ },
9917
+ {
9918
+ "path": "lastFeedGrams",
9919
+ "valueType": "number"
9920
+ },
9921
+ {
9922
+ "path": "lastFeedHopper1",
9923
+ "valueType": "number"
9924
+ },
9925
+ {
9926
+ "path": "lastFeedHopper2",
9927
+ "valueType": "number"
9903
9928
  }
9904
9929
  ],
9905
9930
  "power-meter": [
@@ -10439,7 +10464,7 @@ object({
10439
10464
  params: record(string(), union([string(), number()])).optional()
10440
10465
  });
10441
10466
  //#endregion
10442
- //#region ../types/dist/err-msg-DIorGYeC.mjs
10467
+ //#region ../types/dist/err-msg-BCdlR2Li.mjs
10443
10468
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
10444
10469
  DeviceType["Camera"] = "camera";
10445
10470
  DeviceType["Hub"] = "hub";
@@ -10785,6 +10810,9 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
10785
10810
  /** Fallback when the notifier service name doesn't match a known
10786
10811
  * pattern. */
10787
10812
  DeviceRole["GenericNotifier"] = "generic-notifier";
10813
+ /** Emits a pulse train (infrared or RF) on request — the `ir-transmitter`
10814
+ * cap. A `DeviceType.Generic` device. */
10815
+ DeviceRole["IrTransmitter"] = "ir-transmitter";
10788
10816
  return DeviceRole;
10789
10817
  }({});
10790
10818
  /**
@@ -10798,7 +10826,7 @@ function errMsg(err) {
10798
10826
  return String(err);
10799
10827
  }
10800
10828
  //#endregion
10801
- //#region ../types/dist/composition-CZImLpOI.mjs
10829
+ //#region ../types/dist/composition-bIBW5_13.mjs
10802
10830
  /**
10803
10831
  * The ffmpeg build every CamStack node downloads, per platform and arch.
10804
10832
  *
@@ -16514,9 +16542,21 @@ var AlertSeveritySchema = _enum([
16514
16542
  "error",
16515
16543
  "critical"
16516
16544
  ]);
16545
+ /**
16546
+ * An action that RUNS something instead of going somewhere: the admin UI calls
16547
+ * the addon's custom action (`addons.custom`) with exactly these fields. The
16548
+ * producer owns the meaning; the UI knows nothing about the addon or the kind.
16549
+ */
16550
+ var AlertActionInvokeSchema = object({
16551
+ addonId: string().min(1),
16552
+ action: string().min(1),
16553
+ input: record(string(), unknown()).optional()
16554
+ });
16555
+ /** An action has `href` (a link) OR `invoke` (a button that runs a custom action). */
16517
16556
  var AlertActionSchema = object({
16518
16557
  label: string(),
16519
16558
  href: string().optional(),
16559
+ invoke: AlertActionInvokeSchema.optional(),
16520
16560
  /**
16521
16561
  * How `href` is followed. Absent / `app`: an admin-ui route (client-side).
16522
16562
  * `server`: a route the HUB serves (an addon HTTP route such as an OAuth
@@ -19016,12 +19056,13 @@ var CHANGED = {
19016
19056
  expr: "now"
19017
19057
  };
19018
19058
  function numeric(input) {
19059
+ const { alsoFrom, ...base } = input;
19019
19060
  return {
19020
- ...input,
19061
+ ...base,
19021
19062
  family: "numeric",
19022
19063
  deviceType: DeviceType.Sensor,
19023
19064
  memberDeviceType: DeviceType.Sensor,
19024
- memberDeviceTypes: [DeviceType.Sensor],
19065
+ memberDeviceTypes: [DeviceType.Sensor, ...alsoFrom?.deviceTypes ?? []],
19025
19066
  activeWhen: void 0,
19026
19067
  commandCaps: [],
19027
19068
  baseUnit: baseUnitOf(input.quantity),
@@ -19029,9 +19070,10 @@ function numeric(input) {
19029
19070
  accept: [{
19030
19071
  cap: input.outputCap,
19031
19072
  fieldPath: input.outputField
19032
- }]
19073
+ }, ...alsoFrom === void 0 ? [] : [alsoFrom.accept]]
19033
19074
  };
19034
19075
  }
19076
+ var CLIMATE_DEVICES = [DeviceType.Thermostat, DeviceType.Climate];
19035
19077
  function binary(input) {
19036
19078
  return {
19037
19079
  ...input,
@@ -19057,7 +19099,14 @@ var GROUP_TEMPLATES = [
19057
19099
  quantity: "temperature",
19058
19100
  defaultAggregate: "mean",
19059
19101
  empty: "null",
19060
- companions: [NOW$2]
19102
+ companions: [NOW$2],
19103
+ alsoFrom: {
19104
+ deviceTypes: CLIMATE_DEVICES,
19105
+ accept: {
19106
+ cap: "climate-control",
19107
+ fieldPath: "currentTemp"
19108
+ }
19109
+ }
19061
19110
  }),
19062
19111
  numeric({
19063
19112
  id: "humidity",
@@ -19068,7 +19117,14 @@ var GROUP_TEMPLATES = [
19068
19117
  quantity: "humidity",
19069
19118
  defaultAggregate: "mean",
19070
19119
  empty: "null",
19071
- companions: [NOW$2]
19120
+ companions: [NOW$2],
19121
+ alsoFrom: {
19122
+ deviceTypes: CLIMATE_DEVICES,
19123
+ accept: {
19124
+ cap: "climate-control",
19125
+ fieldPath: "currentHumidity"
19126
+ }
19127
+ }
19072
19128
  }),
19073
19129
  numeric({
19074
19130
  id: "pressure",
@@ -43311,6 +43367,17 @@ var LlmProfileSchema = object({
43311
43367
  * field in its editor only when its descriptor lists it in `profileFields`. */
43312
43368
  topK: number().int().positive().optional(),
43313
43369
  maxTokens: number().int().positive().optional(),
43370
+ /** How hard the model "thinks" before it answers. Omitted = the model's own
43371
+ * default. `off` matters for structured output: a thinking model can spend
43372
+ * the whole completion on reasoning and return an empty `content`. Carried
43373
+ * only by the wires that have it — a kind offers the field in its editor
43374
+ * only when its descriptor lists it in `profileFields`. */
43375
+ reasoningEffort: _enum([
43376
+ "off",
43377
+ "low",
43378
+ "medium",
43379
+ "high"
43380
+ ]).optional(),
43314
43381
  /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
43315
43382
  contextLength: number().int().positive().optional(),
43316
43383
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
@@ -43349,6 +43416,7 @@ var LlmProfileFieldSchema = _enum([
43349
43416
  "topP",
43350
43417
  "topK",
43351
43418
  "maxTokens",
43419
+ "reasoningEffort",
43352
43420
  "contextLength",
43353
43421
  "systemPrompt",
43354
43422
  "timeoutMs",
@@ -44599,6 +44667,43 @@ var NotificationActionSchema = object({
44599
44667
  */
44600
44668
  mode: _enum(["navigate", "background"]).optional()
44601
44669
  });
44670
+ /** A delivery parameter value: what a notifier declared it takes. */
44671
+ var DeliveryParamValueSchema = union([
44672
+ string(),
44673
+ number(),
44674
+ boolean()
44675
+ ]);
44676
+ /**
44677
+ * One extra delivery parameter a notifier KIND declares (D938). A rule that
44678
+ * addresses a target of that kind may set it; a kind that declares nothing is
44679
+ * never handed one. The admin UI derives its control from this descriptor —
44680
+ * no editor knows a service by name.
44681
+ *
44682
+ * Optional fields are `.optional()`, never `.default()` (a Zod default does not
44683
+ * run on the addon cap path).
44684
+ */
44685
+ var DeliveryParamSchema = object({
44686
+ key: string().min(1),
44687
+ label: string(),
44688
+ /** i18n key of the label, resolved by the declaring addon's namespace. */
44689
+ labelKey: string().optional(),
44690
+ type: _enum([
44691
+ "enum",
44692
+ "number",
44693
+ "boolean",
44694
+ "string"
44695
+ ]),
44696
+ /** `enum` only: the closed set of accepted values. */
44697
+ options: array(object({
44698
+ value: string(),
44699
+ label: string()
44700
+ })).optional(),
44701
+ /** `number` only. */
44702
+ min: number().optional(),
44703
+ max: number().optional(),
44704
+ /** What the notifier does when the rule sets nothing; shown as the placeholder. */
44705
+ default: DeliveryParamValueSchema.optional()
44706
+ });
44602
44707
  /**
44603
44708
  * The canonical notification. `body` is the only hard field (Apprise model).
44604
44709
  * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
@@ -44621,7 +44726,13 @@ var NotificationSchema = object({
44621
44726
  tag: string().optional(),
44622
44727
  deviceId: number().optional(),
44623
44728
  eventId: string().optional(),
44624
- metadata: record(string(), unknown()).optional()
44729
+ metadata: record(string(), unknown()).optional(),
44730
+ /**
44731
+ * Values for the parameters the target's kind DECLARES in
44732
+ * {@link TargetKindSchema} `deliveryParams`. Already validated against the
44733
+ * declaration by the sender; a notifier reads only the keys it declared.
44734
+ */
44735
+ delivery: record(string(), DeliveryParamValueSchema).optional()
44625
44736
  });
44626
44737
  /** One declared native severity/priority level for a kind. */
44627
44738
  var TargetKindLevelSchema = object({
@@ -44727,6 +44838,11 @@ var TargetKindSchema = object({
44727
44838
  */
44728
44839
  destinationKeys: array(string()).optional(),
44729
44840
  supportsDiscovery: boolean(),
44841
+ /**
44842
+ * Extra delivery parameters a rule may set for a target of this kind (D938).
44843
+ * Absent = none; the rule editor then offers nothing.
44844
+ */
44845
+ deliveryParams: array(DeliveryParamSchema).optional(),
44730
44846
  caps: TargetKindCapsSchema
44731
44847
  });
44732
44848
  /**
@@ -56913,7 +57029,9 @@ var ManifestShapeSchema = object({
56913
57029
  icon: string().optional()
56914
57030
  }).optional(),
56915
57031
  protected: boolean().optional(),
56916
- removable: boolean().optional()
57032
+ removable: boolean().optional(),
57033
+ /** Declared Integrations-page block (mirror of `AddonDeclaration.integrationSection`). */
57034
+ integrationSection: _enum(["system", "providers"]).optional()
56917
57035
  });
56918
57036
  var AddonProcessSchema = object({
56919
57037
  pid: number().optional(),
@@ -57642,11 +57760,373 @@ DeviceType.Light, method(object({
57642
57760
  level: number().min(0).max(100),
57643
57761
  lastChangedAt: number()
57644
57762
  });
57763
+ /**
57764
+ * The role vocabulary of a remote (D963): what a button MEANS, independent of
57765
+ * how it is wired. A layout template places buttons by role; a device binds a
57766
+ * role to an action; an exporter asks for a role by name. Roles are shared so
57767
+ * one layout fits every appliance and one voice command fits every binding.
57768
+ *
57769
+ * A role outside this list is `custom:<key>` — the operator's own button (a
57770
+ * SmartIR source, a channel preset). The key is a lowercase slug.
57771
+ */
57772
+ var REMOTE_KNOWN_ROLES = [
57773
+ "power",
57774
+ "power_on",
57775
+ "power_off",
57776
+ "volume_up",
57777
+ "volume_down",
57778
+ "mute",
57779
+ "channel_up",
57780
+ "channel_down",
57781
+ "up",
57782
+ "down",
57783
+ "left",
57784
+ "right",
57785
+ "ok",
57786
+ "back",
57787
+ "home",
57788
+ "menu",
57789
+ "info",
57790
+ "guide",
57791
+ "exit",
57792
+ "input",
57793
+ "play",
57794
+ "pause",
57795
+ "play_pause",
57796
+ "stop",
57797
+ "next",
57798
+ "previous",
57799
+ "fast_forward",
57800
+ "rewind",
57801
+ "digit_0",
57802
+ "digit_1",
57803
+ "digit_2",
57804
+ "digit_3",
57805
+ "digit_4",
57806
+ "digit_5",
57807
+ "digit_6",
57808
+ "digit_7",
57809
+ "digit_8",
57810
+ "digit_9"
57811
+ ];
57812
+ var CUSTOM_KEY_RE = /^[a-z0-9][a-z0-9_]{0,47}$/;
57813
+ var KNOWN_ROLES = new Set(REMOTE_KNOWN_ROLES);
57814
+ function isRemoteKnownRole(value) {
57815
+ return KNOWN_ROLES.has(value);
57816
+ }
57817
+ function isRemoteCustomKey(key) {
57818
+ return CUSTOM_KEY_RE.test(key);
57819
+ }
57820
+ /** The key of a `custom:<key>` role, or null for any other string. */
57821
+ function customKeyOfRole(role) {
57822
+ if (!role.startsWith("custom:")) return null;
57823
+ const key = role.slice(7);
57824
+ return isRemoteCustomKey(key) ? key : null;
57825
+ }
57826
+ function isRemoteRole(value) {
57827
+ return isRemoteKnownRole(value) || customKeyOfRole(value) !== null;
57828
+ }
57829
+ var RemoteRoleSchema = string().refine(isRemoteRole, { message: "a role is one of the known roles or custom:<key> (lowercase letters, digits, _)" });
57830
+ var RemoteBindingSchema = object({ action: AutomationCapStepSchema.extend({ deviceId: number().int().nonnegative() }) });
57831
+ var RemoteCustomButtonSchema = object({
57832
+ /** The slug after `custom:` in the role. */
57833
+ key: string().refine(isRemoteCustomKey, { message: "a lowercase slug" }),
57834
+ /** What the operator calls it, and what a voice command may name. */
57835
+ name: string().min(1).max(60)
57836
+ });
57837
+ var RemotePowerModeSchema = _enum(["toggle", "discrete"]);
57838
+ var RemoteConfigSchema = object({
57839
+ layoutTemplateId: string().min(1).nullable(),
57840
+ /**
57841
+ * The transmitter device new bindings and an import send through. A binding
57842
+ * names its own device, so one command may override it.
57843
+ */
57844
+ defaultTransmitterId: number().int().nonnegative().nullable().default(null),
57845
+ /** Keyed by role. A role with no entry falls back to the native cap. */
57846
+ bindings: record(string(), RemoteBindingSchema),
57847
+ customButtons: array(RemoteCustomButtonSchema).max(100),
57848
+ power: object({ mode: RemotePowerModeSchema })
57849
+ }).superRefine((config, ctx) => {
57850
+ const roles = Object.keys(config.bindings);
57851
+ if (roles.length > 200) ctx.addIssue({
57852
+ code: "custom",
57853
+ message: "too many bindings",
57854
+ path: ["bindings"]
57855
+ });
57856
+ for (const role of roles) if (!isRemoteRole(role)) ctx.addIssue({
57857
+ code: "custom",
57858
+ message: `"${role}" is not a role`,
57859
+ path: ["bindings", role]
57860
+ });
57861
+ const keys = /* @__PURE__ */ new Set();
57862
+ config.customButtons.forEach((button, index) => {
57863
+ if (keys.has(button.key)) ctx.addIssue({
57864
+ code: "custom",
57865
+ message: `custom button "${button.key}" is listed twice`,
57866
+ path: [
57867
+ "customButtons",
57868
+ index,
57869
+ "key"
57870
+ ]
57871
+ });
57872
+ keys.add(button.key);
57873
+ });
57874
+ for (const role of roles) {
57875
+ const key = customKeyOfRole(role);
57876
+ if (key !== null && !keys.has(key)) ctx.addIssue({
57877
+ code: "custom",
57878
+ message: `${role} is bound but has no entry in customButtons`,
57879
+ path: ["bindings", role]
57880
+ });
57881
+ }
57882
+ });
57883
+ object({
57884
+ power: object({
57885
+ state: _enum(["on", "off"]),
57886
+ at: number()
57887
+ }).nullable(),
57888
+ muted: object({
57889
+ value: boolean(),
57890
+ at: number()
57891
+ }).nullable()
57892
+ });
57893
+ var RemoteLayoutButtonSchema = object({
57894
+ id: string().min(1).max(40),
57895
+ /** 0-based grid position. */
57896
+ row: number().int().min(0).max(24),
57897
+ col: number().int().min(0).max(24),
57898
+ rowSpan: number().int().min(1).max(24),
57899
+ colSpan: number().int().min(1).max(24),
57900
+ icon: string().min(1).max(60).optional(),
57901
+ label: string().min(1).max(40).optional(),
57902
+ role: RemoteRoleSchema
57903
+ });
57904
+ object({
57905
+ columns: number().int().min(1).max(24),
57906
+ rows: number().int().min(1).max(24),
57907
+ buttons: array(RemoteLayoutButtonSchema).max(200)
57908
+ }).superRefine((grid, ctx) => {
57909
+ const ids = /* @__PURE__ */ new Set();
57910
+ const taken = /* @__PURE__ */ new Map();
57911
+ grid.buttons.forEach((button, index) => {
57912
+ if (ids.has(button.id)) ctx.addIssue({
57913
+ code: "custom",
57914
+ message: `button id "${button.id}" is used twice`,
57915
+ path: [
57916
+ "buttons",
57917
+ index,
57918
+ "id"
57919
+ ]
57920
+ });
57921
+ ids.add(button.id);
57922
+ if (button.row + button.rowSpan > grid.rows || button.col + button.colSpan > grid.columns) {
57923
+ ctx.addIssue({
57924
+ code: "custom",
57925
+ message: `button "${button.id}" leaves the grid`,
57926
+ path: ["buttons", index]
57927
+ });
57928
+ return;
57929
+ }
57930
+ for (let r = button.row; r < button.row + button.rowSpan; r += 1) for (let c = button.col; c < button.col + button.colSpan; c += 1) {
57931
+ const cell = `${r}:${c}`;
57932
+ const other = taken.get(cell);
57933
+ if (other !== void 0) {
57934
+ ctx.addIssue({
57935
+ code: "custom",
57936
+ message: `buttons "${other}" and "${button.id}" overlap`,
57937
+ path: ["buttons", index]
57938
+ });
57939
+ return;
57940
+ }
57941
+ taken.set(cell, button.id);
57942
+ }
57943
+ });
57944
+ });
57945
+ var RemoteBoundCommandSchema = object({
57946
+ role: RemoteRoleSchema,
57947
+ /** The operator's name for a custom button; absent for a known role. */
57948
+ label: string().optional(),
57949
+ custom: boolean()
57950
+ });
57951
+ var RemoteCommandListSchema = object({
57952
+ layoutTemplateId: string().nullable(),
57953
+ power: object({ mode: RemotePowerModeSchema }),
57954
+ /** Only the roles that are BOUND — the ones a press can reach. */
57955
+ commands: array(RemoteBoundCommandSchema)
57956
+ });
57957
+ var RemoteRefusalReasonSchema = _enum([
57958
+ "no-remote",
57959
+ "unbound-role",
57960
+ "action-failed"
57961
+ ]);
57962
+ var RemoteSendResultSchema = discriminatedUnion("status", [
57963
+ object({
57964
+ status: literal("sent"),
57965
+ /** How many times the action ran. */
57966
+ sends: number().int().min(1)
57967
+ }),
57968
+ object({
57969
+ status: literal("skipped"),
57970
+ reason: literal("already-in-state")
57971
+ }),
57972
+ object({
57973
+ status: literal("refused"),
57974
+ reason: RemoteRefusalReasonSchema,
57975
+ detail: string().optional()
57976
+ })
57977
+ ]);
57978
+ var RemoteMediaCommandSchema = _enum([
57979
+ "play",
57980
+ "pause",
57981
+ "stop",
57982
+ "next",
57983
+ "previous",
57984
+ "setMute",
57985
+ "selectSource"
57986
+ ]);
57987
+ /** A send result, or `not-routed`: the role is not bound, so the native cap answers. */
57988
+ var RemoteMediaCommandResultSchema = discriminatedUnion("status", [...RemoteSendResultSchema.options, object({ status: literal("not-routed") })]);
57989
+ var RemoteSetConfigResultSchema = discriminatedUnion("status", [object({ status: literal("saved") }), object({
57990
+ status: literal("refused"),
57991
+ reason: _enum(["unknown-template", "not-a-media-player"]),
57992
+ detail: string()
57993
+ })]);
57994
+ var deviceInput = object({ deviceId: number().int().nonnegative() });
57995
+ DeviceType.MediaPlayer;
57996
+ method(deviceInput, RemoteConfigSchema, { auth: "admin" }), method(deviceInput.extend({ config: RemoteConfigSchema }), RemoteSetConfigResultSchema, {
57997
+ kind: "mutation",
57998
+ auth: "admin"
57999
+ }), method(deviceInput, RemoteCommandListSchema, { auth: "protected" }), method(deviceInput.extend({
58000
+ role: RemoteRoleSchema,
58001
+ /** Sends in a row (volume steps). */
58002
+ repeat: number().int().min(1).max(50).default(1)
58003
+ }), RemoteSendResultSchema, {
58004
+ kind: "mutation",
58005
+ auth: "protected"
58006
+ }), method(deviceInput.extend({
58007
+ command: RemoteMediaCommandSchema,
58008
+ muted: boolean().optional(),
58009
+ source: string().optional(),
58010
+ repeat: number().int().min(1).max(50).default(1)
58011
+ }), RemoteMediaCommandResultSchema, {
58012
+ kind: "mutation",
58013
+ auth: "protected"
58014
+ });
58015
+ var TemplateKindSchema = _enum(["remote"]);
58016
+ /**
58017
+ * template — the generic store of reusable, named operator data (D963). A
58018
+ * record is `{ id, kind, name, payload }`; the kinds (today only `remote`, the
58019
+ * button grid of a remote) and the schema each payload must satisfy are
58020
+ * declared by the system in `template-kinds.ts`. Nothing here is specific to a
58021
+ * kind: the engine validates a payload against its kind's schema and, on a
58022
+ * delete, asks the kind's owner whether anything still points at the record.
58023
+ *
58024
+ * Every refusal is a typed result — a UI says "unknown kind" or names the
58025
+ * devices that still use a template, without parsing text.
58026
+ */
58027
+ var TemplateRecordSchema = object({
58028
+ id: string().min(1),
58029
+ kind: TemplateKindSchema,
58030
+ name: string().min(1).max(120),
58031
+ /** Shaped by the kind; `checkTemplatePayload(kind, payload)` reads it. */
58032
+ payload: unknown(),
58033
+ createdAt: number(),
58034
+ updatedAt: number()
58035
+ });
58036
+ var TemplateWriteResultSchema = discriminatedUnion("status", [object({
58037
+ status: literal("saved"),
58038
+ template: TemplateRecordSchema
58039
+ }), object({
58040
+ status: literal("refused"),
58041
+ reason: _enum(["invalid-payload", "not-found"]),
58042
+ detail: string()
58043
+ })]);
58044
+ /** A device still pointing at a template. */
58045
+ var TemplateUserSchema = object({
58046
+ deviceId: number().int().nonnegative(),
58047
+ name: string()
58048
+ });
58049
+ var TemplateDeleteResultSchema = discriminatedUnion("status", [
58050
+ object({ status: literal("deleted") }),
58051
+ object({ status: literal("not-found") }),
58052
+ object({
58053
+ status: literal("in-use"),
58054
+ devices: array(TemplateUserSchema).min(1)
58055
+ })
58056
+ ]);
58057
+ method(object({ kind: TemplateKindSchema.optional() }), array(TemplateRecordSchema), { auth: "protected" }), method(object({ id: string().min(1) }), TemplateRecordSchema.nullable(), { auth: "protected" }), method(object({
58058
+ kind: TemplateKindSchema,
58059
+ name: string().min(1).max(120),
58060
+ payload: unknown()
58061
+ }), TemplateWriteResultSchema, {
58062
+ kind: "mutation",
58063
+ auth: "admin"
58064
+ }), method(object({
58065
+ id: string().min(1),
58066
+ name: string().min(1).max(120).optional(),
58067
+ payload: unknown().optional()
58068
+ }), TemplateWriteResultSchema, {
58069
+ kind: "mutation",
58070
+ auth: "admin"
58071
+ }), method(object({ id: string().min(1) }), TemplateDeleteResultSchema, {
58072
+ kind: "mutation",
58073
+ auth: "admin"
58074
+ });
57645
58075
  DeviceType.Button, method(object({ deviceId: number().int().nonnegative() }), _void(), {
57646
58076
  kind: "mutation",
57647
58077
  auth: "protected"
57648
58078
  });
57649
58079
  /**
58080
+ * A pulse train in signed microseconds: mark (+) first, then space (-), strictly
58081
+ * alternating, no zeros, 2..1024 entries.
58082
+ */
58083
+ var IrTimingsSchema = array(number().int()).min(2).max(1024).superRefine((timings, ctx) => {
58084
+ timings.forEach((value, index) => {
58085
+ const expectMark = index % 2 === 0;
58086
+ if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
58087
+ code: "custom",
58088
+ message: `timing ${index} must be a non-zero ${expectMark ? "mark (positive)" : "space (negative)"}`,
58089
+ path: [index]
58090
+ });
58091
+ });
58092
+ });
58093
+ /** Per-command transmit options. Every key is optional; a transmitter applies what it can. */
58094
+ var TransmitSettingsSchema = object({
58095
+ carrierHz: number().int().positive().optional(),
58096
+ dutyCyclePercent: number().int().min(1).max(100).optional(),
58097
+ repeat: number().int().min(0).max(20).optional(),
58098
+ repeatDelayMs: number().int().min(0).optional()
58099
+ });
58100
+ /** The setting keys a transmitter may declare as settable (`getInfo.settable`). */
58101
+ var TransmitSettingKeySchema = _enum([
58102
+ "carrierHz",
58103
+ "dutyCyclePercent",
58104
+ "repeat",
58105
+ "repeatDelayMs"
58106
+ ]);
58107
+ var IrMediumSchema = _enum(["ir", "rf"]);
58108
+ var IrSendResultSchema = object({
58109
+ ok: literal(true),
58110
+ /** Settings the transmitter could not apply; the train was still sent. */
58111
+ ignoredSettings: array(string())
58112
+ });
58113
+ var IrTransmitterInfoSchema = object({
58114
+ media: array(IrMediumSchema),
58115
+ settable: array(TransmitSettingKeySchema),
58116
+ maxTimings: number().int().positive()
58117
+ });
58118
+ DeviceType.Generic, method(object({
58119
+ deviceId: number().int().nonnegative(),
58120
+ timings: IrTimingsSchema,
58121
+ settings: TransmitSettingsSchema.optional()
58122
+ }), IrSendResultSchema, {
58123
+ kind: "mutation",
58124
+ auth: "protected"
58125
+ }), method(object({ deviceId: number().int().nonnegative() }), IrTransmitterInfoSchema, {
58126
+ kind: "query",
58127
+ auth: "protected"
58128
+ });
58129
+ /**
57650
58130
  * `calendar-source` — collection cap exposing per-provider calendars and
57651
58131
  * their events. Every addon that contributes calendars (Home Assistant,
57652
58132
  * a future Google Calendar addon, …) registers a provider here. The hub
@@ -60361,9 +60841,35 @@ var MediaInfoSchema = object({
60361
60841
  /** Optional cover-art / thumbnail URL. */
60362
60842
  imageUrl: string().optional()
60363
60843
  });
60844
+ /**
60845
+ * Where `state`, `volumeLevel`, `isMuted` and `source` come from. `reported`:
60846
+ * the device said so. `assumed`: the driver has no feedback (infrared) and
60847
+ * tracks what it last SENT; it moves only after a send was accepted, and a
60848
+ * human at the real remote makes it wrong. A UI shows an assumed value as a
60849
+ * guess, never as a reading.
60850
+ */
60851
+ var MediaPlayerStateSourceSchema = _enum(["reported", "assumed"]);
60852
+ /** The fields of a media-player status a driver can only guess. */
60853
+ var MediaPlayerAssumedFieldSchema = _enum([
60854
+ "state",
60855
+ "volumeLevel",
60856
+ "isMuted",
60857
+ "source"
60858
+ ]);
60364
60859
  object({
60365
60860
  /** Playback lifecycle state. */
60366
60861
  state: MediaPlayerStateSchema,
60862
+ /**
60863
+ * Whether the state fields are readings or the driver's own bookkeeping.
60864
+ * A slice written before this field existed parses as `reported`.
60865
+ */
60866
+ stateSource: MediaPlayerStateSourceSchema.default("reported"),
60867
+ /**
60868
+ * Which fields are the driver's own guess. `stateSource` is `assumed` when
60869
+ * this is not empty; a field not listed here is a reading even then (power
60870
+ * from a running-state source, mute guessed from the last send).
60871
+ */
60872
+ assumedFields: array(MediaPlayerAssumedFieldSchema).default([]),
60367
60873
  /** Volume as 0..100 inclusive. Null when the device has no volume
60368
60874
  * surface. Pair with `DeviceFeature.MediaPlayerVolume`. */
60369
60875
  volumeLevel: number().min(0).max(100).nullable().meta(readingMeta("percentage")),
@@ -61769,9 +62275,14 @@ object({
61769
62275
  * (`device_class: problem`, on = low). True when the tank reports empty,
61770
62276
  * or, on a dual-hopper model, when EITHER hopper is empty. */
61771
62277
  lowFood: boolean(),
61772
- /** Battery charge 0..100 (%). Null on mains-powered models or when the
61773
- * device has no battery reading. */
62278
+ /** Battery charge 0..100 (%). On a feeder running on `mains` this is the
62279
+ * BACKUP battery's charge, not the power source. Null when the device has
62280
+ * no battery reading. */
61774
62281
  batteryPower: number().min(0).max(100).nullable().meta(readingMeta("percentage")),
62282
+ /** What the feeder is powered from right now: `mains` (plugged in, the
62283
+ * battery is only a backup) or `battery`. Null when the device does not
62284
+ * report it. */
62285
+ powerSource: _enum(["mains", "battery"]).nullable(),
61775
62286
  /**
61776
62287
  * Desiccant life remaining, stored in seconds (duration base, D944).
61777
62288
  * Providers convert from the days the feeder reports. Null when the
@@ -61799,6 +62310,14 @@ object({
61799
62310
  feedSound: boolean(),
61800
62311
  /** Speaker / prompt volume level (device-scaled integer). */
61801
62312
  volume: number().meta(readingMeta("none")),
62313
+ /** Portion (grams) of the last manual feed sent from a single-hopper
62314
+ * stepper — the default the next manual feed starts from. Persisted per
62315
+ * device by the provider; null until a manual feed has been sent. */
62316
+ lastFeedGrams: gramsPortion.nullable(),
62317
+ /** Hopper-1 portion of the last manual feed (dual-hopper); null until sent. */
62318
+ lastFeedHopper1: gramsPortion.nullable(),
62319
+ /** Hopper-2 portion of the last manual feed (dual-hopper); null until sent. */
62320
+ lastFeedHopper2: gramsPortion.nullable(),
61802
62321
  /** Ms epoch when the slice was last refreshed from the cloud. */
61803
62322
  lastFetchedAt: number()
61804
62323
  });
@@ -66459,9 +66978,17 @@ method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" })
66459
66978
  kind: "mutation",
66460
66979
  auth: "admin"
66461
66980
  });
66981
+ discriminatedUnion("kind", [object({
66982
+ kind: literal("raw"),
66983
+ timings: array(number().int()),
66984
+ settings: TransmitSettingsSchema.optional()
66985
+ }), object({
66986
+ kind: literal("pronto"),
66987
+ code: string()
66988
+ })]);
66462
66989
  DeviceFeature.FanSpeed, DeviceFeature.FanPreset, DeviceFeature.FanDirection, DeviceFeature.FanOscillating, DeviceFeature.CoverPositionable, DeviceFeature.CoverTilt, DeviceFeature.ValvePositionable, DeviceFeature.MediaPlayerVolume, DeviceFeature.ClimateFanMode;
66463
66990
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
66464
- DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Thermostat, DeviceType.EventEmitter, DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Camera, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.PetFeeder;
66991
+ DeviceType.Camera, DeviceType.Sensor, DeviceType.Button, DeviceType.Switch, DeviceType.PetFeeder, DeviceType.Container, DeviceType.Thermostat, DeviceType.EventEmitter, DeviceType.Camera, DeviceType.Hub, DeviceType.Light, DeviceType.Siren, DeviceType.Switch, DeviceType.Sensor, DeviceType.Thermostat, DeviceType.Climate, DeviceType.Button, DeviceType.EventEmitter, DeviceType.Update, DeviceType.Generic, DeviceType.Notifier, DeviceType.Script, DeviceType.Automation, DeviceType.Lock, DeviceType.Cover, DeviceType.Valve, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.Fan, DeviceType.MediaPlayer, DeviceType.AlarmPanel, DeviceType.Control, DeviceType.Presence, DeviceType.Weather, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.Container, DeviceType.Image, DeviceType.PetFeeder, DeviceType.Dishwasher, DeviceType.Washer, DeviceType.Dryer, DeviceType.Camera, DeviceType.Camera, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.Switch, DeviceType.Light, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.Humidifier, DeviceType.WaterHeater, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.PetFeeder, DeviceType.MediaPlayer, DeviceType.Washer, DeviceType.Dryer, DeviceType.Dishwasher, DeviceType.Vacuum, DeviceType.LawnMower, DeviceType.MediaPlayer, DeviceType.WaterHeater, DeviceType.Humidifier, DeviceType.Fan, DeviceType.Climate, DeviceType.Thermostat, DeviceType.PetFeeder;
66465
66992
  String.raw`rose\(active(\d+), changed(\d+), (\d+(?:\.\d+)?)\)`;
66466
66993
  DeviceRole.BinarySensor, DeviceRole.MotionSensor;
66467
66994
  new Set(CAP_NAMES);
@@ -70066,6 +70593,20 @@ Object.freeze({
70066
70593
  access: "create",
70067
70594
  role: "viewer"
70068
70595
  },
70596
+ "irTransmitter.getInfo": {
70597
+ capName: "ir-transmitter",
70598
+ capScope: "device",
70599
+ addonId: null,
70600
+ access: "view",
70601
+ role: "viewer"
70602
+ },
70603
+ "irTransmitter.send": {
70604
+ capName: "ir-transmitter",
70605
+ capScope: "device",
70606
+ addonId: null,
70607
+ access: "create",
70608
+ role: "viewer"
70609
+ },
70069
70610
  "keychain.delete": {
70070
70611
  capName: "keychain",
70071
70612
  capScope: "system",
@@ -74189,6 +74730,41 @@ Object.freeze({
74189
74730
  access: "create",
74190
74731
  role: "admin"
74191
74732
  },
74733
+ "remote.getConfig": {
74734
+ capName: "remote",
74735
+ capScope: "system",
74736
+ addonId: null,
74737
+ access: "view",
74738
+ role: "admin"
74739
+ },
74740
+ "remote.listCommands": {
74741
+ capName: "remote",
74742
+ capScope: "system",
74743
+ addonId: null,
74744
+ access: "view",
74745
+ role: "admin"
74746
+ },
74747
+ "remote.sendCommand": {
74748
+ capName: "remote",
74749
+ capScope: "system",
74750
+ addonId: null,
74751
+ access: "create",
74752
+ role: "admin"
74753
+ },
74754
+ "remote.sendMediaCommand": {
74755
+ capName: "remote",
74756
+ capScope: "system",
74757
+ addonId: null,
74758
+ access: "create",
74759
+ role: "admin"
74760
+ },
74761
+ "remote.setConfig": {
74762
+ capName: "remote",
74763
+ capScope: "system",
74764
+ addonId: null,
74765
+ access: "create",
74766
+ role: "admin"
74767
+ },
74192
74768
  "runningState.getStatus": {
74193
74769
  capName: "running-state",
74194
74770
  capScope: "device",
@@ -75379,6 +75955,41 @@ Object.freeze({
75379
75955
  access: "view",
75380
75956
  role: "viewer"
75381
75957
  },
75958
+ "template.create": {
75959
+ capName: "template",
75960
+ capScope: "system",
75961
+ addonId: null,
75962
+ access: "create",
75963
+ role: "admin"
75964
+ },
75965
+ "template.delete": {
75966
+ capName: "template",
75967
+ capScope: "system",
75968
+ addonId: null,
75969
+ access: "delete",
75970
+ role: "admin"
75971
+ },
75972
+ "template.get": {
75973
+ capName: "template",
75974
+ capScope: "system",
75975
+ addonId: null,
75976
+ access: "view",
75977
+ role: "admin"
75978
+ },
75979
+ "template.list": {
75980
+ capName: "template",
75981
+ capScope: "system",
75982
+ addonId: null,
75983
+ access: "view",
75984
+ role: "admin"
75985
+ },
75986
+ "template.update": {
75987
+ capName: "template",
75988
+ capScope: "system",
75989
+ addonId: null,
75990
+ access: "create",
75991
+ role: "admin"
75992
+ },
75382
75993
  "terminalSession.adoptLegacyMonitor": {
75383
75994
  capName: "terminal-session",
75384
75995
  capScope: "system",
@@ -77689,6 +78300,11 @@ var ACTUATOR_CAP_VOCABULARY = {
77689
78300
  icon: "circle-dot"
77690
78301
  }]
77691
78302
  },
78303
+ "ir-transmitter": {
78304
+ scope: "device",
78305
+ noun: t("IR / RF transmitter", "Trasmettitore IR / RF"),
78306
+ notOperatorFacing: { send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it" }
78307
+ },
77692
78308
  control: {
77693
78309
  scope: "device",
77694
78310
  noun: t("Control", "Controllo"),
@@ -80205,6 +80821,7 @@ var SYSTEM_CAP_VOCABULARY = {
80205
80821
  "recording-archive": system(STORAGE),
80206
80822
  "recording-export": system("recording exports — requested from the timeline, not an automation step"),
80207
80823
  records: system(INTERNAL),
80824
+ remote: system("the per-device remote setup — authored in the Customize remote editor, sent through the remote UI"),
80208
80825
  "server-management": system(CLUSTER),
80209
80826
  "settings-store": system(INTERNAL),
80210
80827
  "smtp-provider": system(INTERNAL),
@@ -80217,6 +80834,7 @@ var SYSTEM_CAP_VOCABULARY = {
80217
80834
  "storage-provider": system(STORAGE),
80218
80835
  "stream-broker": system(PIPELINE),
80219
80836
  system: system(CLUSTER),
80837
+ template: system("operator-authored templates — edited in their own editor, never actuated"),
80220
80838
  "terminal-session": system(CLUSTER),
80221
80839
  toast: system(UI_PLUMBING),
80222
80840
  training: system(ML),
@@ -81433,6 +82051,16 @@ Object.freeze({
81433
82051
  form: "single",
81434
82052
  optional: false
81435
82053
  }],
82054
+ "irTransmitter.getInfo": [{
82055
+ name: "deviceId",
82056
+ form: "single",
82057
+ optional: false
82058
+ }],
82059
+ "irTransmitter.send": [{
82060
+ name: "deviceId",
82061
+ form: "single",
82062
+ optional: false
82063
+ }],
81436
82064
  "keychain.deleteDeviceScope": [{
81437
82065
  name: "deviceId",
81438
82066
  form: "single",
@@ -82658,6 +83286,31 @@ Object.freeze({
82658
83286
  form: "single",
82659
83287
  optional: true
82660
83288
  }],
83289
+ "remote.getConfig": [{
83290
+ name: "deviceId",
83291
+ form: "single",
83292
+ optional: false
83293
+ }],
83294
+ "remote.listCommands": [{
83295
+ name: "deviceId",
83296
+ form: "single",
83297
+ optional: false
83298
+ }],
83299
+ "remote.sendCommand": [{
83300
+ name: "deviceId",
83301
+ form: "single",
83302
+ optional: false
83303
+ }],
83304
+ "remote.sendMediaCommand": [{
83305
+ name: "deviceId",
83306
+ form: "single",
83307
+ optional: false
83308
+ }],
83309
+ "remote.setConfig": [{
83310
+ name: "deviceId",
83311
+ form: "single",
83312
+ optional: false
83313
+ }],
82661
83314
  "runningState.getStatus": [{
82662
83315
  name: "deviceId",
82663
83316
  form: "single",
@@ -84567,6 +85220,14 @@ function resolveGrantDeviceIds(scopes, fleet, access) {
84567
85220
  String.raw`(?<=^|["'(\s>,\[{])`;
84568
85221
  var MB = 1024 * 1024;
84569
85222
  1024 * MB, 3072 * MB;
85223
+ object({
85224
+ manufacturer: string().optional(),
85225
+ supportedModels: array(string()).optional(),
85226
+ supportedController: string().optional(),
85227
+ commandsEncoding: string(),
85228
+ delay: number().nonnegative().optional(),
85229
+ commands: record(string(), unknown())
85230
+ });
84570
85231
  //#endregion
84571
85232
  //#region src/custom-actions.ts
84572
85233
  /**
@@ -84813,6 +85474,148 @@ async function profileForCamStream(input) {
84813
85474
  }
84814
85475
  }
84815
85476
  //#endregion
85477
+ //#region src/egress/alexa-source-profile.ts
85478
+ async function resolveAlexaSourceProfile(input) {
85479
+ const { api, deviceId, exposedEntry } = input;
85480
+ const log = input.logger;
85481
+ const pinnedProfile = (() => {
85482
+ const pref = exposedEntry?.settings?.streamPreference;
85483
+ if (pref === "low" || pref === "mid" || pref === "high") return pref;
85484
+ })();
85485
+ const allowTranscode = exposedEntry?.settings?.allowTranscode !== false;
85486
+ const scored = pinnedProfile === void 0 ? await api.cameraStreams.pickStream.query({
85487
+ deviceId,
85488
+ requirements: {
85489
+ acceptCodecs: ["h264"],
85490
+ minHeight: 480,
85491
+ maxHeight: ALEXA_MAX_LINES,
85492
+ excludeDerived: true,
85493
+ allowTranscode
85494
+ },
85495
+ preferences: { targetHeight: 720 }
85496
+ }).catch((err) => {
85497
+ log.warn("alexa rtc-session: pickStream threw — falling back to the high slot", {
85498
+ tags: { deviceId },
85499
+ meta: { error: err instanceof Error ? err.message : String(err) }
85500
+ });
85501
+ return null;
85502
+ }) : null;
85503
+ const scoredProfile = scored === null ? null : await profileForCamStream({
85504
+ api,
85505
+ deviceId,
85506
+ camStreamId: scored.camStreamId,
85507
+ logger: log
85508
+ });
85509
+ const sourceProfile = pinnedProfile ?? scoredProfile ?? "high";
85510
+ if (pinnedProfile === void 0) log.info("alexa rtc-session: source scored against the Echo requirements", {
85511
+ tags: { deviceId },
85512
+ meta: {
85513
+ chosen: sourceProfile,
85514
+ scored: scored === null ? "none-eligible" : scored.reason,
85515
+ camStreamId: scored?.camStreamId ?? null,
85516
+ slot: scoredProfile ?? (scored === null ? null : "no-slot"),
85517
+ height: scored?.resolution?.height ?? null,
85518
+ transcodes: scored?.transcodes ?? null,
85519
+ allowTranscode
85520
+ }
85521
+ });
85522
+ return sourceProfile;
85523
+ }
85524
+ var AlexaEgressPrewarm = class {
85525
+ deps;
85526
+ holds = /* @__PURE__ */ new Map();
85527
+ holdMs;
85528
+ disposed = false;
85529
+ constructor(deps) {
85530
+ this.deps = deps;
85531
+ this.holdMs = deps.holdMs ?? 3e4;
85532
+ }
85533
+ /** A doorbell press for `deviceId`. Never throws. */
85534
+ async onPress(deviceId) {
85535
+ const { api, logger } = this.deps;
85536
+ if (this.disposed) return;
85537
+ if (this.holds.has(deviceId)) {
85538
+ logger.debug("alexa egress prewarm: a hold is already pending, press ignored", { tags: { deviceId } });
85539
+ return;
85540
+ }
85541
+ if (this.deps.hasLiveSession(deviceId)) {
85542
+ logger.info("alexa egress prewarm: an Alexa session is already live, nothing to warm", { tags: { deviceId } });
85543
+ return;
85544
+ }
85545
+ const hold = {
85546
+ pipelineKey: null,
85547
+ timer: null
85548
+ };
85549
+ this.holds.set(deviceId, hold);
85550
+ const sessionId = `prewarm-${deviceId}-${Date.now()}`;
85551
+ try {
85552
+ const sourceProfile = await resolveAlexaSourceProfile({
85553
+ api,
85554
+ deviceId,
85555
+ exposedEntry: this.deps.listExposed().find((e) => e.deviceId === deviceId),
85556
+ logger
85557
+ });
85558
+ const acquired = await acquireAlexaEgress({
85559
+ api,
85560
+ deviceId,
85561
+ sourceProfile,
85562
+ sessionId,
85563
+ logger
85564
+ });
85565
+ hold.pipelineKey = acquired.pipelineKey;
85566
+ if (this.disposed || this.holds.get(deviceId) !== hold) {
85567
+ await this.release(deviceId, hold, "disposed before the hold was armed");
85568
+ return;
85569
+ }
85570
+ hold.timer = setTimeout(() => {
85571
+ this.release(deviceId, hold, "no session arrived");
85572
+ }, this.holdMs);
85573
+ hold.timer.unref?.();
85574
+ logger.info("alexa egress prewarm: transcode held for the coming session", {
85575
+ tags: { deviceId },
85576
+ meta: {
85577
+ pipelineKey: acquired.pipelineKey,
85578
+ sourceProfile,
85579
+ holdMs: this.holdMs
85580
+ }
85581
+ });
85582
+ } catch (err) {
85583
+ this.holds.delete(deviceId);
85584
+ logger.warn("alexa egress prewarm: acquire failed, the session will start the transcode", {
85585
+ tags: { deviceId },
85586
+ meta: { error: err instanceof Error ? err.message : String(err) }
85587
+ });
85588
+ }
85589
+ }
85590
+ /** Release every pending hold (addon shutdown). */
85591
+ async dispose() {
85592
+ this.disposed = true;
85593
+ const pending = [...this.holds.entries()];
85594
+ await Promise.all(pending.map(([deviceId, hold]) => this.release(deviceId, hold, "shutdown")));
85595
+ }
85596
+ async release(deviceId, hold, reason) {
85597
+ if (hold.timer) clearTimeout(hold.timer);
85598
+ hold.timer = null;
85599
+ if (this.holds.get(deviceId) === hold) this.holds.delete(deviceId);
85600
+ const pipelineKey = hold.pipelineKey;
85601
+ hold.pipelineKey = null;
85602
+ if (pipelineKey === null) return;
85603
+ await releaseAlexaEgress({
85604
+ api: this.deps.api,
85605
+ deviceId,
85606
+ pipelineKey,
85607
+ logger: this.deps.logger
85608
+ });
85609
+ this.deps.logger.info("alexa egress prewarm: hold released", {
85610
+ tags: { deviceId },
85611
+ meta: {
85612
+ pipelineKey,
85613
+ reason
85614
+ }
85615
+ });
85616
+ }
85617
+ };
85618
+ //#endregion
84816
85619
  //#region src/handlers/endpoint-id.ts
84817
85620
  /** The classes a camera publishes a detection sensor for (R1). */
84818
85621
  var DETECTION_SENSOR_CLASSES = [
@@ -85089,47 +85892,12 @@ async function handleInitiateSessionWithOffer(header, endpointRaw, payloadRaw, d
85089
85892
  if (sdpOffer.length === 0) return errorEnvelope(header, "INVALID_DIRECTIVE", "offer.value is empty");
85090
85893
  const api = deps.ctx.api;
85091
85894
  const exposedEntry = deps.listExposed().find((e) => e.deviceId === deviceId);
85092
- const pinnedProfile = (() => {
85093
- const pref = exposedEntry?.settings?.streamPreference;
85094
- if (pref === "low" || pref === "mid" || pref === "high") return pref;
85095
- })();
85096
- const allowTranscode = exposedEntry?.settings?.allowTranscode !== false;
85097
- const scored = pinnedProfile === void 0 ? await api.cameraStreams.pickStream.query({
85098
- deviceId,
85099
- requirements: {
85100
- acceptCodecs: ["h264"],
85101
- minHeight: 480,
85102
- maxHeight: ALEXA_MAX_LINES,
85103
- excludeDerived: true,
85104
- allowTranscode
85105
- },
85106
- preferences: { targetHeight: 720 }
85107
- }).catch((err) => {
85108
- log.warn("alexa rtc-session: pickStream threw — falling back to the high slot", {
85109
- tags: { deviceId },
85110
- meta: { error: err instanceof Error ? err.message : String(err) }
85111
- });
85112
- return null;
85113
- }) : null;
85114
- const scoredProfile = scored === null ? null : await profileForCamStream({
85895
+ const sourceProfile = await resolveAlexaSourceProfile({
85115
85896
  api,
85116
85897
  deviceId,
85117
- camStreamId: scored.camStreamId,
85898
+ exposedEntry,
85118
85899
  logger: log
85119
85900
  });
85120
- const sourceProfile = pinnedProfile ?? scoredProfile ?? "high";
85121
- if (pinnedProfile === void 0) log.info("alexa rtc-session: source scored against the Echo requirements", {
85122
- tags: { deviceId },
85123
- meta: {
85124
- chosen: sourceProfile,
85125
- scored: scored === null ? "none-eligible" : scored.reason,
85126
- camStreamId: scored?.camStreamId ?? null,
85127
- slot: scoredProfile ?? (scored === null ? null : "no-slot"),
85128
- height: scored?.resolution?.height ?? null,
85129
- transcodes: scored?.transcodes ?? null,
85130
- allowTranscode
85131
- }
85132
- });
85133
85901
  let derivedTarget;
85134
85902
  /**
85135
85903
  * The primitive's release handle, when this session acquired one. Recorded so
@@ -91942,6 +92710,7 @@ var LwaEventGateway = class {
91942
92710
  return;
91943
92711
  }
91944
92712
  if (!this.hasProactiveCredentials()) return;
92713
+ this.deps.onExposedDoorbellPress?.(parentDeviceId);
91945
92714
  for (const account of linked) {
91946
92715
  if (!this.mayPush(account.userId, parentDeviceId, "doorbell press")) continue;
91947
92716
  if (!this.findToken(account.userId)) {
@@ -95105,6 +95874,7 @@ var ExportAlexaAddon = class extends BaseAddon {
95105
95874
  "tokens[userId].brokerCredential"
95106
95875
  ];
95107
95876
  lwaGateway = null;
95877
+ egressPrewarm = null;
95108
95878
  syncEngine = null;
95109
95879
  /** S1 (D767): the linking user's live grants. Built in `onInitialize`, the
95110
95880
  * first point `ctx` exists. */
@@ -95271,10 +96041,19 @@ var ExportAlexaAddon = class extends BaseAddon {
95271
96041
  }
95272
96042
  }));
95273
96043
  const oauthIntegrationProvider = { getDescriptor: async () => buildAlexaOauthIntegration(this.config.publicHubUrl) };
96044
+ this.egressPrewarm = new AlexaEgressPrewarm({
96045
+ api: this.ctx.api,
96046
+ logger: this.ctx.logger,
96047
+ listExposed: () => this.config.exposed,
96048
+ hasLiveSession: (deviceId) => heldEgressHandles().some((h) => h.deviceId === deviceId)
96049
+ });
95274
96050
  this.lwaGateway = new LwaEventGateway({
95275
96051
  ctx: this.ctx,
95276
96052
  logger: this.ctx.logger,
95277
96053
  listExposed: () => this.config.exposed,
96054
+ onExposedDoorbellPress: (deviceId) => {
96055
+ this.egressPrewarm?.onPress(deviceId);
96056
+ },
95278
96057
  listLinkedAccounts: () => this.config.linkedAccounts,
95279
96058
  listTokens: () => this.config.tokens,
95280
96059
  upsertToken: (input) => this.upsertToken(input),
@@ -95428,6 +96207,10 @@ var ExportAlexaAddon = class extends BaseAddon {
95428
96207
  this.stateReconciler = null;
95429
96208
  this.stateReporter?.stop();
95430
96209
  this.stateReporter = null;
96210
+ if (this.egressPrewarm) {
96211
+ await this.egressPrewarm.dispose();
96212
+ this.egressPrewarm = null;
96213
+ }
95431
96214
  if (this.lwaGateway) {
95432
96215
  this.lwaGateway.stop();
95433
96216
  this.lwaGateway = null;