@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.
@@ -5482,7 +5482,7 @@ var ZodIssueCode = {
5482
5482
  var ZodFirstPartyTypeKind;
5483
5483
  ZodFirstPartyTypeKind || (ZodFirstPartyTypeKind = {});
5484
5484
  //#endregion
5485
- //#region ../types/dist/sleep-Crlmu_tO.mjs
5485
+ //#region ../types/dist/sleep-DJws6ho7.mjs
5486
5486
  /**
5487
5487
  * The audio chunk plane's byte format, and the ONE expansion from a coded
5488
5488
  * window to float samples (D455).
@@ -8638,6 +8638,7 @@ var CAP_NAMES = Object.freeze([
8638
8638
  "image-settings",
8639
8639
  "integrations",
8640
8640
  "intercom",
8641
+ "ir-transmitter",
8641
8642
  "keychain",
8642
8643
  "keychain-admin",
8643
8644
  "lawn-mower-control",
@@ -8696,6 +8697,7 @@ var CAP_NAMES = Object.freeze([
8696
8697
  "recording-onboard",
8697
8698
  "recording-signal",
8698
8699
  "records",
8700
+ "remote",
8699
8701
  "running-state",
8700
8702
  "scene-monitor",
8701
8703
  "script-runner",
@@ -8719,6 +8721,7 @@ var CAP_NAMES = Object.freeze([
8719
8721
  "system",
8720
8722
  "tamper",
8721
8723
  "temperature-sensor",
8724
+ "template",
8722
8725
  "terminal-session",
8723
8726
  "toast",
8724
8727
  "training",
@@ -9659,6 +9662,11 @@ Object.freeze({
9659
9662
  "standby"
9660
9663
  ]
9661
9664
  },
9665
+ {
9666
+ "path": "stateSource",
9667
+ "valueType": "enum",
9668
+ "enumValues": ["reported", "assumed"]
9669
+ },
9662
9670
  {
9663
9671
  "path": "volumeLevel",
9664
9672
  "valueType": "number"
@@ -9885,6 +9893,11 @@ Object.freeze({
9885
9893
  "path": "batteryPower",
9886
9894
  "valueType": "number"
9887
9895
  },
9896
+ {
9897
+ "path": "powerSource",
9898
+ "valueType": "enum",
9899
+ "enumValues": ["mains", "battery"]
9900
+ },
9888
9901
  {
9889
9902
  "path": "desiccantLeftDays",
9890
9903
  "valueType": "number"
@@ -9929,6 +9942,18 @@ Object.freeze({
9929
9942
  {
9930
9943
  "path": "volume",
9931
9944
  "valueType": "number"
9945
+ },
9946
+ {
9947
+ "path": "lastFeedGrams",
9948
+ "valueType": "number"
9949
+ },
9950
+ {
9951
+ "path": "lastFeedHopper1",
9952
+ "valueType": "number"
9953
+ },
9954
+ {
9955
+ "path": "lastFeedHopper2",
9956
+ "valueType": "number"
9932
9957
  }
9933
9958
  ],
9934
9959
  "power-meter": [
@@ -10468,7 +10493,7 @@ object({
10468
10493
  params: record(string(), union([string(), number()])).optional()
10469
10494
  });
10470
10495
  //#endregion
10471
- //#region ../types/dist/err-msg-DIorGYeC.mjs
10496
+ //#region ../types/dist/err-msg-BCdlR2Li.mjs
10472
10497
  var DeviceType = /* @__PURE__ */ function(DeviceType) {
10473
10498
  DeviceType["Camera"] = "camera";
10474
10499
  DeviceType["Hub"] = "hub";
@@ -10814,6 +10839,9 @@ var DeviceRole = /* @__PURE__ */ function(DeviceRole) {
10814
10839
  /** Fallback when the notifier service name doesn't match a known
10815
10840
  * pattern. */
10816
10841
  DeviceRole["GenericNotifier"] = "generic-notifier";
10842
+ /** Emits a pulse train (infrared or RF) on request — the `ir-transmitter`
10843
+ * cap. A `DeviceType.Generic` device. */
10844
+ DeviceRole["IrTransmitter"] = "ir-transmitter";
10817
10845
  return DeviceRole;
10818
10846
  }({});
10819
10847
  /**
@@ -10827,7 +10855,7 @@ function errMsg(err) {
10827
10855
  return String(err);
10828
10856
  }
10829
10857
  //#endregion
10830
- //#region ../types/dist/composition-CZImLpOI.mjs
10858
+ //#region ../types/dist/composition-bIBW5_13.mjs
10831
10859
  /**
10832
10860
  * The ffmpeg build every CamStack node downloads, per platform and arch.
10833
10861
  *
@@ -16543,9 +16571,21 @@ var AlertSeveritySchema = _enum([
16543
16571
  "error",
16544
16572
  "critical"
16545
16573
  ]);
16574
+ /**
16575
+ * An action that RUNS something instead of going somewhere: the admin UI calls
16576
+ * the addon's custom action (`addons.custom`) with exactly these fields. The
16577
+ * producer owns the meaning; the UI knows nothing about the addon or the kind.
16578
+ */
16579
+ var AlertActionInvokeSchema = object({
16580
+ addonId: string().min(1),
16581
+ action: string().min(1),
16582
+ input: record(string(), unknown()).optional()
16583
+ });
16584
+ /** An action has `href` (a link) OR `invoke` (a button that runs a custom action). */
16546
16585
  var AlertActionSchema = object({
16547
16586
  label: string(),
16548
16587
  href: string().optional(),
16588
+ invoke: AlertActionInvokeSchema.optional(),
16549
16589
  /**
16550
16590
  * How `href` is followed. Absent / `app`: an admin-ui route (client-side).
16551
16591
  * `server`: a route the HUB serves (an addon HTTP route such as an OAuth
@@ -19045,12 +19085,13 @@ var CHANGED = {
19045
19085
  expr: "now"
19046
19086
  };
19047
19087
  function numeric(input) {
19088
+ const { alsoFrom, ...base } = input;
19048
19089
  return {
19049
- ...input,
19090
+ ...base,
19050
19091
  family: "numeric",
19051
19092
  deviceType: DeviceType.Sensor,
19052
19093
  memberDeviceType: DeviceType.Sensor,
19053
- memberDeviceTypes: [DeviceType.Sensor],
19094
+ memberDeviceTypes: [DeviceType.Sensor, ...alsoFrom?.deviceTypes ?? []],
19054
19095
  activeWhen: void 0,
19055
19096
  commandCaps: [],
19056
19097
  baseUnit: baseUnitOf(input.quantity),
@@ -19058,9 +19099,10 @@ function numeric(input) {
19058
19099
  accept: [{
19059
19100
  cap: input.outputCap,
19060
19101
  fieldPath: input.outputField
19061
- }]
19102
+ }, ...alsoFrom === void 0 ? [] : [alsoFrom.accept]]
19062
19103
  };
19063
19104
  }
19105
+ var CLIMATE_DEVICES = [DeviceType.Thermostat, DeviceType.Climate];
19064
19106
  function binary(input) {
19065
19107
  return {
19066
19108
  ...input,
@@ -19086,7 +19128,14 @@ var GROUP_TEMPLATES = [
19086
19128
  quantity: "temperature",
19087
19129
  defaultAggregate: "mean",
19088
19130
  empty: "null",
19089
- companions: [NOW$2]
19131
+ companions: [NOW$2],
19132
+ alsoFrom: {
19133
+ deviceTypes: CLIMATE_DEVICES,
19134
+ accept: {
19135
+ cap: "climate-control",
19136
+ fieldPath: "currentTemp"
19137
+ }
19138
+ }
19090
19139
  }),
19091
19140
  numeric({
19092
19141
  id: "humidity",
@@ -19097,7 +19146,14 @@ var GROUP_TEMPLATES = [
19097
19146
  quantity: "humidity",
19098
19147
  defaultAggregate: "mean",
19099
19148
  empty: "null",
19100
- companions: [NOW$2]
19149
+ companions: [NOW$2],
19150
+ alsoFrom: {
19151
+ deviceTypes: CLIMATE_DEVICES,
19152
+ accept: {
19153
+ cap: "climate-control",
19154
+ fieldPath: "currentHumidity"
19155
+ }
19156
+ }
19101
19157
  }),
19102
19158
  numeric({
19103
19159
  id: "pressure",
@@ -43340,6 +43396,17 @@ var LlmProfileSchema = object({
43340
43396
  * field in its editor only when its descriptor lists it in `profileFields`. */
43341
43397
  topK: number().int().positive().optional(),
43342
43398
  maxTokens: number().int().positive().optional(),
43399
+ /** How hard the model "thinks" before it answers. Omitted = the model's own
43400
+ * default. `off` matters for structured output: a thinking model can spend
43401
+ * the whole completion on reasoning and return an empty `content`. Carried
43402
+ * only by the wires that have it — a kind offers the field in its editor
43403
+ * only when its descriptor lists it in `profileFields`. */
43404
+ reasoningEffort: _enum([
43405
+ "off",
43406
+ "low",
43407
+ "medium",
43408
+ "high"
43409
+ ]).optional(),
43343
43410
  /** Prompt context window. Advisory for cloud kinds (they enforce their own). */
43344
43411
  contextLength: number().int().positive().optional(),
43345
43412
  /** Default system prompt. A caller's `system` REPLACES it (never appends —
@@ -43378,6 +43445,7 @@ var LlmProfileFieldSchema = _enum([
43378
43445
  "topP",
43379
43446
  "topK",
43380
43447
  "maxTokens",
43448
+ "reasoningEffort",
43381
43449
  "contextLength",
43382
43450
  "systemPrompt",
43383
43451
  "timeoutMs",
@@ -44628,6 +44696,43 @@ var NotificationActionSchema = object({
44628
44696
  */
44629
44697
  mode: _enum(["navigate", "background"]).optional()
44630
44698
  });
44699
+ /** A delivery parameter value: what a notifier declared it takes. */
44700
+ var DeliveryParamValueSchema = union([
44701
+ string(),
44702
+ number(),
44703
+ boolean()
44704
+ ]);
44705
+ /**
44706
+ * One extra delivery parameter a notifier KIND declares (D938). A rule that
44707
+ * addresses a target of that kind may set it; a kind that declares nothing is
44708
+ * never handed one. The admin UI derives its control from this descriptor —
44709
+ * no editor knows a service by name.
44710
+ *
44711
+ * Optional fields are `.optional()`, never `.default()` (a Zod default does not
44712
+ * run on the addon cap path).
44713
+ */
44714
+ var DeliveryParamSchema = object({
44715
+ key: string().min(1),
44716
+ label: string(),
44717
+ /** i18n key of the label, resolved by the declaring addon's namespace. */
44718
+ labelKey: string().optional(),
44719
+ type: _enum([
44720
+ "enum",
44721
+ "number",
44722
+ "boolean",
44723
+ "string"
44724
+ ]),
44725
+ /** `enum` only: the closed set of accepted values. */
44726
+ options: array(object({
44727
+ value: string(),
44728
+ label: string()
44729
+ })).optional(),
44730
+ /** `number` only. */
44731
+ min: number().optional(),
44732
+ max: number().optional(),
44733
+ /** What the notifier does when the rule sets nothing; shown as the placeholder. */
44734
+ default: DeliveryParamValueSchema.optional()
44735
+ });
44631
44736
  /**
44632
44737
  * The canonical notification. `body` is the only hard field (Apprise model).
44633
44738
  * `priority` is a 5-level ORDINAL (1=lowest … 3=normal(default) … 5=urgent),
@@ -44650,7 +44755,13 @@ var NotificationSchema = object({
44650
44755
  tag: string().optional(),
44651
44756
  deviceId: number().optional(),
44652
44757
  eventId: string().optional(),
44653
- metadata: record(string(), unknown()).optional()
44758
+ metadata: record(string(), unknown()).optional(),
44759
+ /**
44760
+ * Values for the parameters the target's kind DECLARES in
44761
+ * {@link TargetKindSchema} `deliveryParams`. Already validated against the
44762
+ * declaration by the sender; a notifier reads only the keys it declared.
44763
+ */
44764
+ delivery: record(string(), DeliveryParamValueSchema).optional()
44654
44765
  });
44655
44766
  /** One declared native severity/priority level for a kind. */
44656
44767
  var TargetKindLevelSchema = object({
@@ -44756,6 +44867,11 @@ var TargetKindSchema = object({
44756
44867
  */
44757
44868
  destinationKeys: array(string()).optional(),
44758
44869
  supportsDiscovery: boolean(),
44870
+ /**
44871
+ * Extra delivery parameters a rule may set for a target of this kind (D938).
44872
+ * Absent = none; the rule editor then offers nothing.
44873
+ */
44874
+ deliveryParams: array(DeliveryParamSchema).optional(),
44759
44875
  caps: TargetKindCapsSchema
44760
44876
  });
44761
44877
  /**
@@ -56942,7 +57058,9 @@ var ManifestShapeSchema = object({
56942
57058
  icon: string().optional()
56943
57059
  }).optional(),
56944
57060
  protected: boolean().optional(),
56945
- removable: boolean().optional()
57061
+ removable: boolean().optional(),
57062
+ /** Declared Integrations-page block (mirror of `AddonDeclaration.integrationSection`). */
57063
+ integrationSection: _enum(["system", "providers"]).optional()
56946
57064
  });
56947
57065
  var AddonProcessSchema = object({
56948
57066
  pid: number().optional(),
@@ -57671,11 +57789,373 @@ DeviceType.Light, method(object({
57671
57789
  level: number().min(0).max(100),
57672
57790
  lastChangedAt: number()
57673
57791
  });
57792
+ /**
57793
+ * The role vocabulary of a remote (D963): what a button MEANS, independent of
57794
+ * how it is wired. A layout template places buttons by role; a device binds a
57795
+ * role to an action; an exporter asks for a role by name. Roles are shared so
57796
+ * one layout fits every appliance and one voice command fits every binding.
57797
+ *
57798
+ * A role outside this list is `custom:<key>` — the operator's own button (a
57799
+ * SmartIR source, a channel preset). The key is a lowercase slug.
57800
+ */
57801
+ var REMOTE_KNOWN_ROLES = [
57802
+ "power",
57803
+ "power_on",
57804
+ "power_off",
57805
+ "volume_up",
57806
+ "volume_down",
57807
+ "mute",
57808
+ "channel_up",
57809
+ "channel_down",
57810
+ "up",
57811
+ "down",
57812
+ "left",
57813
+ "right",
57814
+ "ok",
57815
+ "back",
57816
+ "home",
57817
+ "menu",
57818
+ "info",
57819
+ "guide",
57820
+ "exit",
57821
+ "input",
57822
+ "play",
57823
+ "pause",
57824
+ "play_pause",
57825
+ "stop",
57826
+ "next",
57827
+ "previous",
57828
+ "fast_forward",
57829
+ "rewind",
57830
+ "digit_0",
57831
+ "digit_1",
57832
+ "digit_2",
57833
+ "digit_3",
57834
+ "digit_4",
57835
+ "digit_5",
57836
+ "digit_6",
57837
+ "digit_7",
57838
+ "digit_8",
57839
+ "digit_9"
57840
+ ];
57841
+ var CUSTOM_KEY_RE = /^[a-z0-9][a-z0-9_]{0,47}$/;
57842
+ var KNOWN_ROLES = new Set(REMOTE_KNOWN_ROLES);
57843
+ function isRemoteKnownRole(value) {
57844
+ return KNOWN_ROLES.has(value);
57845
+ }
57846
+ function isRemoteCustomKey(key) {
57847
+ return CUSTOM_KEY_RE.test(key);
57848
+ }
57849
+ /** The key of a `custom:<key>` role, or null for any other string. */
57850
+ function customKeyOfRole(role) {
57851
+ if (!role.startsWith("custom:")) return null;
57852
+ const key = role.slice(7);
57853
+ return isRemoteCustomKey(key) ? key : null;
57854
+ }
57855
+ function isRemoteRole(value) {
57856
+ return isRemoteKnownRole(value) || customKeyOfRole(value) !== null;
57857
+ }
57858
+ var RemoteRoleSchema = string().refine(isRemoteRole, { message: "a role is one of the known roles or custom:<key> (lowercase letters, digits, _)" });
57859
+ var RemoteBindingSchema = object({ action: AutomationCapStepSchema.extend({ deviceId: number().int().nonnegative() }) });
57860
+ var RemoteCustomButtonSchema = object({
57861
+ /** The slug after `custom:` in the role. */
57862
+ key: string().refine(isRemoteCustomKey, { message: "a lowercase slug" }),
57863
+ /** What the operator calls it, and what a voice command may name. */
57864
+ name: string().min(1).max(60)
57865
+ });
57866
+ var RemotePowerModeSchema = _enum(["toggle", "discrete"]);
57867
+ var RemoteConfigSchema = object({
57868
+ layoutTemplateId: string().min(1).nullable(),
57869
+ /**
57870
+ * The transmitter device new bindings and an import send through. A binding
57871
+ * names its own device, so one command may override it.
57872
+ */
57873
+ defaultTransmitterId: number().int().nonnegative().nullable().default(null),
57874
+ /** Keyed by role. A role with no entry falls back to the native cap. */
57875
+ bindings: record(string(), RemoteBindingSchema),
57876
+ customButtons: array(RemoteCustomButtonSchema).max(100),
57877
+ power: object({ mode: RemotePowerModeSchema })
57878
+ }).superRefine((config, ctx) => {
57879
+ const roles = Object.keys(config.bindings);
57880
+ if (roles.length > 200) ctx.addIssue({
57881
+ code: "custom",
57882
+ message: "too many bindings",
57883
+ path: ["bindings"]
57884
+ });
57885
+ for (const role of roles) if (!isRemoteRole(role)) ctx.addIssue({
57886
+ code: "custom",
57887
+ message: `"${role}" is not a role`,
57888
+ path: ["bindings", role]
57889
+ });
57890
+ const keys = /* @__PURE__ */ new Set();
57891
+ config.customButtons.forEach((button, index) => {
57892
+ if (keys.has(button.key)) ctx.addIssue({
57893
+ code: "custom",
57894
+ message: `custom button "${button.key}" is listed twice`,
57895
+ path: [
57896
+ "customButtons",
57897
+ index,
57898
+ "key"
57899
+ ]
57900
+ });
57901
+ keys.add(button.key);
57902
+ });
57903
+ for (const role of roles) {
57904
+ const key = customKeyOfRole(role);
57905
+ if (key !== null && !keys.has(key)) ctx.addIssue({
57906
+ code: "custom",
57907
+ message: `${role} is bound but has no entry in customButtons`,
57908
+ path: ["bindings", role]
57909
+ });
57910
+ }
57911
+ });
57912
+ object({
57913
+ power: object({
57914
+ state: _enum(["on", "off"]),
57915
+ at: number()
57916
+ }).nullable(),
57917
+ muted: object({
57918
+ value: boolean(),
57919
+ at: number()
57920
+ }).nullable()
57921
+ });
57922
+ var RemoteLayoutButtonSchema = object({
57923
+ id: string().min(1).max(40),
57924
+ /** 0-based grid position. */
57925
+ row: number().int().min(0).max(24),
57926
+ col: number().int().min(0).max(24),
57927
+ rowSpan: number().int().min(1).max(24),
57928
+ colSpan: number().int().min(1).max(24),
57929
+ icon: string().min(1).max(60).optional(),
57930
+ label: string().min(1).max(40).optional(),
57931
+ role: RemoteRoleSchema
57932
+ });
57933
+ object({
57934
+ columns: number().int().min(1).max(24),
57935
+ rows: number().int().min(1).max(24),
57936
+ buttons: array(RemoteLayoutButtonSchema).max(200)
57937
+ }).superRefine((grid, ctx) => {
57938
+ const ids = /* @__PURE__ */ new Set();
57939
+ const taken = /* @__PURE__ */ new Map();
57940
+ grid.buttons.forEach((button, index) => {
57941
+ if (ids.has(button.id)) ctx.addIssue({
57942
+ code: "custom",
57943
+ message: `button id "${button.id}" is used twice`,
57944
+ path: [
57945
+ "buttons",
57946
+ index,
57947
+ "id"
57948
+ ]
57949
+ });
57950
+ ids.add(button.id);
57951
+ if (button.row + button.rowSpan > grid.rows || button.col + button.colSpan > grid.columns) {
57952
+ ctx.addIssue({
57953
+ code: "custom",
57954
+ message: `button "${button.id}" leaves the grid`,
57955
+ path: ["buttons", index]
57956
+ });
57957
+ return;
57958
+ }
57959
+ for (let r = button.row; r < button.row + button.rowSpan; r += 1) for (let c = button.col; c < button.col + button.colSpan; c += 1) {
57960
+ const cell = `${r}:${c}`;
57961
+ const other = taken.get(cell);
57962
+ if (other !== void 0) {
57963
+ ctx.addIssue({
57964
+ code: "custom",
57965
+ message: `buttons "${other}" and "${button.id}" overlap`,
57966
+ path: ["buttons", index]
57967
+ });
57968
+ return;
57969
+ }
57970
+ taken.set(cell, button.id);
57971
+ }
57972
+ });
57973
+ });
57974
+ var RemoteBoundCommandSchema = object({
57975
+ role: RemoteRoleSchema,
57976
+ /** The operator's name for a custom button; absent for a known role. */
57977
+ label: string().optional(),
57978
+ custom: boolean()
57979
+ });
57980
+ var RemoteCommandListSchema = object({
57981
+ layoutTemplateId: string().nullable(),
57982
+ power: object({ mode: RemotePowerModeSchema }),
57983
+ /** Only the roles that are BOUND — the ones a press can reach. */
57984
+ commands: array(RemoteBoundCommandSchema)
57985
+ });
57986
+ var RemoteRefusalReasonSchema = _enum([
57987
+ "no-remote",
57988
+ "unbound-role",
57989
+ "action-failed"
57990
+ ]);
57991
+ var RemoteSendResultSchema = discriminatedUnion("status", [
57992
+ object({
57993
+ status: literal("sent"),
57994
+ /** How many times the action ran. */
57995
+ sends: number().int().min(1)
57996
+ }),
57997
+ object({
57998
+ status: literal("skipped"),
57999
+ reason: literal("already-in-state")
58000
+ }),
58001
+ object({
58002
+ status: literal("refused"),
58003
+ reason: RemoteRefusalReasonSchema,
58004
+ detail: string().optional()
58005
+ })
58006
+ ]);
58007
+ var RemoteMediaCommandSchema = _enum([
58008
+ "play",
58009
+ "pause",
58010
+ "stop",
58011
+ "next",
58012
+ "previous",
58013
+ "setMute",
58014
+ "selectSource"
58015
+ ]);
58016
+ /** A send result, or `not-routed`: the role is not bound, so the native cap answers. */
58017
+ var RemoteMediaCommandResultSchema = discriminatedUnion("status", [...RemoteSendResultSchema.options, object({ status: literal("not-routed") })]);
58018
+ var RemoteSetConfigResultSchema = discriminatedUnion("status", [object({ status: literal("saved") }), object({
58019
+ status: literal("refused"),
58020
+ reason: _enum(["unknown-template", "not-a-media-player"]),
58021
+ detail: string()
58022
+ })]);
58023
+ var deviceInput = object({ deviceId: number().int().nonnegative() });
58024
+ DeviceType.MediaPlayer;
58025
+ method(deviceInput, RemoteConfigSchema, { auth: "admin" }), method(deviceInput.extend({ config: RemoteConfigSchema }), RemoteSetConfigResultSchema, {
58026
+ kind: "mutation",
58027
+ auth: "admin"
58028
+ }), method(deviceInput, RemoteCommandListSchema, { auth: "protected" }), method(deviceInput.extend({
58029
+ role: RemoteRoleSchema,
58030
+ /** Sends in a row (volume steps). */
58031
+ repeat: number().int().min(1).max(50).default(1)
58032
+ }), RemoteSendResultSchema, {
58033
+ kind: "mutation",
58034
+ auth: "protected"
58035
+ }), method(deviceInput.extend({
58036
+ command: RemoteMediaCommandSchema,
58037
+ muted: boolean().optional(),
58038
+ source: string().optional(),
58039
+ repeat: number().int().min(1).max(50).default(1)
58040
+ }), RemoteMediaCommandResultSchema, {
58041
+ kind: "mutation",
58042
+ auth: "protected"
58043
+ });
58044
+ var TemplateKindSchema = _enum(["remote"]);
58045
+ /**
58046
+ * template — the generic store of reusable, named operator data (D963). A
58047
+ * record is `{ id, kind, name, payload }`; the kinds (today only `remote`, the
58048
+ * button grid of a remote) and the schema each payload must satisfy are
58049
+ * declared by the system in `template-kinds.ts`. Nothing here is specific to a
58050
+ * kind: the engine validates a payload against its kind's schema and, on a
58051
+ * delete, asks the kind's owner whether anything still points at the record.
58052
+ *
58053
+ * Every refusal is a typed result — a UI says "unknown kind" or names the
58054
+ * devices that still use a template, without parsing text.
58055
+ */
58056
+ var TemplateRecordSchema = object({
58057
+ id: string().min(1),
58058
+ kind: TemplateKindSchema,
58059
+ name: string().min(1).max(120),
58060
+ /** Shaped by the kind; `checkTemplatePayload(kind, payload)` reads it. */
58061
+ payload: unknown(),
58062
+ createdAt: number(),
58063
+ updatedAt: number()
58064
+ });
58065
+ var TemplateWriteResultSchema = discriminatedUnion("status", [object({
58066
+ status: literal("saved"),
58067
+ template: TemplateRecordSchema
58068
+ }), object({
58069
+ status: literal("refused"),
58070
+ reason: _enum(["invalid-payload", "not-found"]),
58071
+ detail: string()
58072
+ })]);
58073
+ /** A device still pointing at a template. */
58074
+ var TemplateUserSchema = object({
58075
+ deviceId: number().int().nonnegative(),
58076
+ name: string()
58077
+ });
58078
+ var TemplateDeleteResultSchema = discriminatedUnion("status", [
58079
+ object({ status: literal("deleted") }),
58080
+ object({ status: literal("not-found") }),
58081
+ object({
58082
+ status: literal("in-use"),
58083
+ devices: array(TemplateUserSchema).min(1)
58084
+ })
58085
+ ]);
58086
+ method(object({ kind: TemplateKindSchema.optional() }), array(TemplateRecordSchema), { auth: "protected" }), method(object({ id: string().min(1) }), TemplateRecordSchema.nullable(), { auth: "protected" }), method(object({
58087
+ kind: TemplateKindSchema,
58088
+ name: string().min(1).max(120),
58089
+ payload: unknown()
58090
+ }), TemplateWriteResultSchema, {
58091
+ kind: "mutation",
58092
+ auth: "admin"
58093
+ }), method(object({
58094
+ id: string().min(1),
58095
+ name: string().min(1).max(120).optional(),
58096
+ payload: unknown().optional()
58097
+ }), TemplateWriteResultSchema, {
58098
+ kind: "mutation",
58099
+ auth: "admin"
58100
+ }), method(object({ id: string().min(1) }), TemplateDeleteResultSchema, {
58101
+ kind: "mutation",
58102
+ auth: "admin"
58103
+ });
57674
58104
  DeviceType.Button, method(object({ deviceId: number().int().nonnegative() }), _void(), {
57675
58105
  kind: "mutation",
57676
58106
  auth: "protected"
57677
58107
  });
57678
58108
  /**
58109
+ * A pulse train in signed microseconds: mark (+) first, then space (-), strictly
58110
+ * alternating, no zeros, 2..1024 entries.
58111
+ */
58112
+ var IrTimingsSchema = array(number().int()).min(2).max(1024).superRefine((timings, ctx) => {
58113
+ timings.forEach((value, index) => {
58114
+ const expectMark = index % 2 === 0;
58115
+ if (value === 0 || value > 0 !== expectMark) ctx.addIssue({
58116
+ code: "custom",
58117
+ message: `timing ${index} must be a non-zero ${expectMark ? "mark (positive)" : "space (negative)"}`,
58118
+ path: [index]
58119
+ });
58120
+ });
58121
+ });
58122
+ /** Per-command transmit options. Every key is optional; a transmitter applies what it can. */
58123
+ var TransmitSettingsSchema = object({
58124
+ carrierHz: number().int().positive().optional(),
58125
+ dutyCyclePercent: number().int().min(1).max(100).optional(),
58126
+ repeat: number().int().min(0).max(20).optional(),
58127
+ repeatDelayMs: number().int().min(0).optional()
58128
+ });
58129
+ /** The setting keys a transmitter may declare as settable (`getInfo.settable`). */
58130
+ var TransmitSettingKeySchema = _enum([
58131
+ "carrierHz",
58132
+ "dutyCyclePercent",
58133
+ "repeat",
58134
+ "repeatDelayMs"
58135
+ ]);
58136
+ var IrMediumSchema = _enum(["ir", "rf"]);
58137
+ var IrSendResultSchema = object({
58138
+ ok: literal(true),
58139
+ /** Settings the transmitter could not apply; the train was still sent. */
58140
+ ignoredSettings: array(string())
58141
+ });
58142
+ var IrTransmitterInfoSchema = object({
58143
+ media: array(IrMediumSchema),
58144
+ settable: array(TransmitSettingKeySchema),
58145
+ maxTimings: number().int().positive()
58146
+ });
58147
+ DeviceType.Generic, method(object({
58148
+ deviceId: number().int().nonnegative(),
58149
+ timings: IrTimingsSchema,
58150
+ settings: TransmitSettingsSchema.optional()
58151
+ }), IrSendResultSchema, {
58152
+ kind: "mutation",
58153
+ auth: "protected"
58154
+ }), method(object({ deviceId: number().int().nonnegative() }), IrTransmitterInfoSchema, {
58155
+ kind: "query",
58156
+ auth: "protected"
58157
+ });
58158
+ /**
57679
58159
  * `calendar-source` — collection cap exposing per-provider calendars and
57680
58160
  * their events. Every addon that contributes calendars (Home Assistant,
57681
58161
  * a future Google Calendar addon, …) registers a provider here. The hub
@@ -60390,9 +60870,35 @@ var MediaInfoSchema = object({
60390
60870
  /** Optional cover-art / thumbnail URL. */
60391
60871
  imageUrl: string().optional()
60392
60872
  });
60873
+ /**
60874
+ * Where `state`, `volumeLevel`, `isMuted` and `source` come from. `reported`:
60875
+ * the device said so. `assumed`: the driver has no feedback (infrared) and
60876
+ * tracks what it last SENT; it moves only after a send was accepted, and a
60877
+ * human at the real remote makes it wrong. A UI shows an assumed value as a
60878
+ * guess, never as a reading.
60879
+ */
60880
+ var MediaPlayerStateSourceSchema = _enum(["reported", "assumed"]);
60881
+ /** The fields of a media-player status a driver can only guess. */
60882
+ var MediaPlayerAssumedFieldSchema = _enum([
60883
+ "state",
60884
+ "volumeLevel",
60885
+ "isMuted",
60886
+ "source"
60887
+ ]);
60393
60888
  object({
60394
60889
  /** Playback lifecycle state. */
60395
60890
  state: MediaPlayerStateSchema,
60891
+ /**
60892
+ * Whether the state fields are readings or the driver's own bookkeeping.
60893
+ * A slice written before this field existed parses as `reported`.
60894
+ */
60895
+ stateSource: MediaPlayerStateSourceSchema.default("reported"),
60896
+ /**
60897
+ * Which fields are the driver's own guess. `stateSource` is `assumed` when
60898
+ * this is not empty; a field not listed here is a reading even then (power
60899
+ * from a running-state source, mute guessed from the last send).
60900
+ */
60901
+ assumedFields: array(MediaPlayerAssumedFieldSchema).default([]),
60396
60902
  /** Volume as 0..100 inclusive. Null when the device has no volume
60397
60903
  * surface. Pair with `DeviceFeature.MediaPlayerVolume`. */
60398
60904
  volumeLevel: number().min(0).max(100).nullable().meta(readingMeta("percentage")),
@@ -61798,9 +62304,14 @@ object({
61798
62304
  * (`device_class: problem`, on = low). True when the tank reports empty,
61799
62305
  * or, on a dual-hopper model, when EITHER hopper is empty. */
61800
62306
  lowFood: boolean(),
61801
- /** Battery charge 0..100 (%). Null on mains-powered models or when the
61802
- * device has no battery reading. */
62307
+ /** Battery charge 0..100 (%). On a feeder running on `mains` this is the
62308
+ * BACKUP battery's charge, not the power source. Null when the device has
62309
+ * no battery reading. */
61803
62310
  batteryPower: number().min(0).max(100).nullable().meta(readingMeta("percentage")),
62311
+ /** What the feeder is powered from right now: `mains` (plugged in, the
62312
+ * battery is only a backup) or `battery`. Null when the device does not
62313
+ * report it. */
62314
+ powerSource: _enum(["mains", "battery"]).nullable(),
61804
62315
  /**
61805
62316
  * Desiccant life remaining, stored in seconds (duration base, D944).
61806
62317
  * Providers convert from the days the feeder reports. Null when the
@@ -61828,6 +62339,14 @@ object({
61828
62339
  feedSound: boolean(),
61829
62340
  /** Speaker / prompt volume level (device-scaled integer). */
61830
62341
  volume: number().meta(readingMeta("none")),
62342
+ /** Portion (grams) of the last manual feed sent from a single-hopper
62343
+ * stepper — the default the next manual feed starts from. Persisted per
62344
+ * device by the provider; null until a manual feed has been sent. */
62345
+ lastFeedGrams: gramsPortion.nullable(),
62346
+ /** Hopper-1 portion of the last manual feed (dual-hopper); null until sent. */
62347
+ lastFeedHopper1: gramsPortion.nullable(),
62348
+ /** Hopper-2 portion of the last manual feed (dual-hopper); null until sent. */
62349
+ lastFeedHopper2: gramsPortion.nullable(),
61831
62350
  /** Ms epoch when the slice was last refreshed from the cloud. */
61832
62351
  lastFetchedAt: number()
61833
62352
  });
@@ -66488,9 +67007,17 @@ method(object({}), array(TrainingBaseModelSchema).readonly(), { auth: "admin" })
66488
67007
  kind: "mutation",
66489
67008
  auth: "admin"
66490
67009
  });
67010
+ discriminatedUnion("kind", [object({
67011
+ kind: literal("raw"),
67012
+ timings: array(number().int()),
67013
+ settings: TransmitSettingsSchema.optional()
67014
+ }), object({
67015
+ kind: literal("pronto"),
67016
+ code: string()
67017
+ })]);
66491
67018
  DeviceFeature.FanSpeed, DeviceFeature.FanPreset, DeviceFeature.FanDirection, DeviceFeature.FanOscillating, DeviceFeature.CoverPositionable, DeviceFeature.CoverTilt, DeviceFeature.ValvePositionable, DeviceFeature.MediaPlayerVolume, DeviceFeature.ClimateFanMode;
66492
67019
  SOURCE_CAPS.filter((cap) => cap !== "switch" && cap !== "motion");
66493
- 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;
67020
+ 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;
66494
67021
  String.raw`rose\(active(\d+), changed(\d+), (\d+(?:\.\d+)?)\)`;
66495
67022
  DeviceRole.BinarySensor, DeviceRole.MotionSensor;
66496
67023
  new Set(CAP_NAMES);
@@ -70095,6 +70622,20 @@ Object.freeze({
70095
70622
  access: "create",
70096
70623
  role: "viewer"
70097
70624
  },
70625
+ "irTransmitter.getInfo": {
70626
+ capName: "ir-transmitter",
70627
+ capScope: "device",
70628
+ addonId: null,
70629
+ access: "view",
70630
+ role: "viewer"
70631
+ },
70632
+ "irTransmitter.send": {
70633
+ capName: "ir-transmitter",
70634
+ capScope: "device",
70635
+ addonId: null,
70636
+ access: "create",
70637
+ role: "viewer"
70638
+ },
70098
70639
  "keychain.delete": {
70099
70640
  capName: "keychain",
70100
70641
  capScope: "system",
@@ -74218,6 +74759,41 @@ Object.freeze({
74218
74759
  access: "create",
74219
74760
  role: "admin"
74220
74761
  },
74762
+ "remote.getConfig": {
74763
+ capName: "remote",
74764
+ capScope: "system",
74765
+ addonId: null,
74766
+ access: "view",
74767
+ role: "admin"
74768
+ },
74769
+ "remote.listCommands": {
74770
+ capName: "remote",
74771
+ capScope: "system",
74772
+ addonId: null,
74773
+ access: "view",
74774
+ role: "admin"
74775
+ },
74776
+ "remote.sendCommand": {
74777
+ capName: "remote",
74778
+ capScope: "system",
74779
+ addonId: null,
74780
+ access: "create",
74781
+ role: "admin"
74782
+ },
74783
+ "remote.sendMediaCommand": {
74784
+ capName: "remote",
74785
+ capScope: "system",
74786
+ addonId: null,
74787
+ access: "create",
74788
+ role: "admin"
74789
+ },
74790
+ "remote.setConfig": {
74791
+ capName: "remote",
74792
+ capScope: "system",
74793
+ addonId: null,
74794
+ access: "create",
74795
+ role: "admin"
74796
+ },
74221
74797
  "runningState.getStatus": {
74222
74798
  capName: "running-state",
74223
74799
  capScope: "device",
@@ -75408,6 +75984,41 @@ Object.freeze({
75408
75984
  access: "view",
75409
75985
  role: "viewer"
75410
75986
  },
75987
+ "template.create": {
75988
+ capName: "template",
75989
+ capScope: "system",
75990
+ addonId: null,
75991
+ access: "create",
75992
+ role: "admin"
75993
+ },
75994
+ "template.delete": {
75995
+ capName: "template",
75996
+ capScope: "system",
75997
+ addonId: null,
75998
+ access: "delete",
75999
+ role: "admin"
76000
+ },
76001
+ "template.get": {
76002
+ capName: "template",
76003
+ capScope: "system",
76004
+ addonId: null,
76005
+ access: "view",
76006
+ role: "admin"
76007
+ },
76008
+ "template.list": {
76009
+ capName: "template",
76010
+ capScope: "system",
76011
+ addonId: null,
76012
+ access: "view",
76013
+ role: "admin"
76014
+ },
76015
+ "template.update": {
76016
+ capName: "template",
76017
+ capScope: "system",
76018
+ addonId: null,
76019
+ access: "create",
76020
+ role: "admin"
76021
+ },
75411
76022
  "terminalSession.adoptLegacyMonitor": {
75412
76023
  capName: "terminal-session",
75413
76024
  capScope: "system",
@@ -77718,6 +78329,11 @@ var ACTUATOR_CAP_VOCABULARY = {
77718
78329
  icon: "circle-dot"
77719
78330
  }]
77720
78331
  },
78332
+ "ir-transmitter": {
78333
+ scope: "device",
78334
+ noun: t("IR / RF transmitter", "Trasmettitore IR / RF"),
78335
+ notOperatorFacing: { send: "a raw pulse train is not something an operator composes in an automation; the remote that owns the command table sends it" }
78336
+ },
77721
78337
  control: {
77722
78338
  scope: "device",
77723
78339
  noun: t("Control", "Controllo"),
@@ -80234,6 +80850,7 @@ var SYSTEM_CAP_VOCABULARY = {
80234
80850
  "recording-archive": system(STORAGE),
80235
80851
  "recording-export": system("recording exports — requested from the timeline, not an automation step"),
80236
80852
  records: system(INTERNAL),
80853
+ remote: system("the per-device remote setup — authored in the Customize remote editor, sent through the remote UI"),
80237
80854
  "server-management": system(CLUSTER),
80238
80855
  "settings-store": system(INTERNAL),
80239
80856
  "smtp-provider": system(INTERNAL),
@@ -80246,6 +80863,7 @@ var SYSTEM_CAP_VOCABULARY = {
80246
80863
  "storage-provider": system(STORAGE),
80247
80864
  "stream-broker": system(PIPELINE),
80248
80865
  system: system(CLUSTER),
80866
+ template: system("operator-authored templates — edited in their own editor, never actuated"),
80249
80867
  "terminal-session": system(CLUSTER),
80250
80868
  toast: system(UI_PLUMBING),
80251
80869
  training: system(ML),
@@ -81462,6 +82080,16 @@ Object.freeze({
81462
82080
  form: "single",
81463
82081
  optional: false
81464
82082
  }],
82083
+ "irTransmitter.getInfo": [{
82084
+ name: "deviceId",
82085
+ form: "single",
82086
+ optional: false
82087
+ }],
82088
+ "irTransmitter.send": [{
82089
+ name: "deviceId",
82090
+ form: "single",
82091
+ optional: false
82092
+ }],
81465
82093
  "keychain.deleteDeviceScope": [{
81466
82094
  name: "deviceId",
81467
82095
  form: "single",
@@ -82687,6 +83315,31 @@ Object.freeze({
82687
83315
  form: "single",
82688
83316
  optional: true
82689
83317
  }],
83318
+ "remote.getConfig": [{
83319
+ name: "deviceId",
83320
+ form: "single",
83321
+ optional: false
83322
+ }],
83323
+ "remote.listCommands": [{
83324
+ name: "deviceId",
83325
+ form: "single",
83326
+ optional: false
83327
+ }],
83328
+ "remote.sendCommand": [{
83329
+ name: "deviceId",
83330
+ form: "single",
83331
+ optional: false
83332
+ }],
83333
+ "remote.sendMediaCommand": [{
83334
+ name: "deviceId",
83335
+ form: "single",
83336
+ optional: false
83337
+ }],
83338
+ "remote.setConfig": [{
83339
+ name: "deviceId",
83340
+ form: "single",
83341
+ optional: false
83342
+ }],
82690
83343
  "runningState.getStatus": [{
82691
83344
  name: "deviceId",
82692
83345
  form: "single",
@@ -84596,6 +85249,14 @@ function resolveGrantDeviceIds(scopes, fleet, access) {
84596
85249
  String.raw`(?<=^|["'(\s>,\[{])`;
84597
85250
  var MB = 1024 * 1024;
84598
85251
  1024 * MB, 3072 * MB;
85252
+ object({
85253
+ manufacturer: string().optional(),
85254
+ supportedModels: array(string()).optional(),
85255
+ supportedController: string().optional(),
85256
+ commandsEncoding: string(),
85257
+ delay: number().nonnegative().optional(),
85258
+ commands: record(string(), unknown())
85259
+ });
84599
85260
  //#endregion
84600
85261
  //#region src/custom-actions.ts
84601
85262
  /**
@@ -84842,6 +85503,148 @@ async function profileForCamStream(input) {
84842
85503
  }
84843
85504
  }
84844
85505
  //#endregion
85506
+ //#region src/egress/alexa-source-profile.ts
85507
+ async function resolveAlexaSourceProfile(input) {
85508
+ const { api, deviceId, exposedEntry } = input;
85509
+ const log = input.logger;
85510
+ const pinnedProfile = (() => {
85511
+ const pref = exposedEntry?.settings?.streamPreference;
85512
+ if (pref === "low" || pref === "mid" || pref === "high") return pref;
85513
+ })();
85514
+ const allowTranscode = exposedEntry?.settings?.allowTranscode !== false;
85515
+ const scored = pinnedProfile === void 0 ? await api.cameraStreams.pickStream.query({
85516
+ deviceId,
85517
+ requirements: {
85518
+ acceptCodecs: ["h264"],
85519
+ minHeight: 480,
85520
+ maxHeight: ALEXA_MAX_LINES,
85521
+ excludeDerived: true,
85522
+ allowTranscode
85523
+ },
85524
+ preferences: { targetHeight: 720 }
85525
+ }).catch((err) => {
85526
+ log.warn("alexa rtc-session: pickStream threw — falling back to the high slot", {
85527
+ tags: { deviceId },
85528
+ meta: { error: err instanceof Error ? err.message : String(err) }
85529
+ });
85530
+ return null;
85531
+ }) : null;
85532
+ const scoredProfile = scored === null ? null : await profileForCamStream({
85533
+ api,
85534
+ deviceId,
85535
+ camStreamId: scored.camStreamId,
85536
+ logger: log
85537
+ });
85538
+ const sourceProfile = pinnedProfile ?? scoredProfile ?? "high";
85539
+ if (pinnedProfile === void 0) log.info("alexa rtc-session: source scored against the Echo requirements", {
85540
+ tags: { deviceId },
85541
+ meta: {
85542
+ chosen: sourceProfile,
85543
+ scored: scored === null ? "none-eligible" : scored.reason,
85544
+ camStreamId: scored?.camStreamId ?? null,
85545
+ slot: scoredProfile ?? (scored === null ? null : "no-slot"),
85546
+ height: scored?.resolution?.height ?? null,
85547
+ transcodes: scored?.transcodes ?? null,
85548
+ allowTranscode
85549
+ }
85550
+ });
85551
+ return sourceProfile;
85552
+ }
85553
+ var AlexaEgressPrewarm = class {
85554
+ deps;
85555
+ holds = /* @__PURE__ */ new Map();
85556
+ holdMs;
85557
+ disposed = false;
85558
+ constructor(deps) {
85559
+ this.deps = deps;
85560
+ this.holdMs = deps.holdMs ?? 3e4;
85561
+ }
85562
+ /** A doorbell press for `deviceId`. Never throws. */
85563
+ async onPress(deviceId) {
85564
+ const { api, logger } = this.deps;
85565
+ if (this.disposed) return;
85566
+ if (this.holds.has(deviceId)) {
85567
+ logger.debug("alexa egress prewarm: a hold is already pending, press ignored", { tags: { deviceId } });
85568
+ return;
85569
+ }
85570
+ if (this.deps.hasLiveSession(deviceId)) {
85571
+ logger.info("alexa egress prewarm: an Alexa session is already live, nothing to warm", { tags: { deviceId } });
85572
+ return;
85573
+ }
85574
+ const hold = {
85575
+ pipelineKey: null,
85576
+ timer: null
85577
+ };
85578
+ this.holds.set(deviceId, hold);
85579
+ const sessionId = `prewarm-${deviceId}-${Date.now()}`;
85580
+ try {
85581
+ const sourceProfile = await resolveAlexaSourceProfile({
85582
+ api,
85583
+ deviceId,
85584
+ exposedEntry: this.deps.listExposed().find((e) => e.deviceId === deviceId),
85585
+ logger
85586
+ });
85587
+ const acquired = await acquireAlexaEgress({
85588
+ api,
85589
+ deviceId,
85590
+ sourceProfile,
85591
+ sessionId,
85592
+ logger
85593
+ });
85594
+ hold.pipelineKey = acquired.pipelineKey;
85595
+ if (this.disposed || this.holds.get(deviceId) !== hold) {
85596
+ await this.release(deviceId, hold, "disposed before the hold was armed");
85597
+ return;
85598
+ }
85599
+ hold.timer = setTimeout(() => {
85600
+ this.release(deviceId, hold, "no session arrived");
85601
+ }, this.holdMs);
85602
+ hold.timer.unref?.();
85603
+ logger.info("alexa egress prewarm: transcode held for the coming session", {
85604
+ tags: { deviceId },
85605
+ meta: {
85606
+ pipelineKey: acquired.pipelineKey,
85607
+ sourceProfile,
85608
+ holdMs: this.holdMs
85609
+ }
85610
+ });
85611
+ } catch (err) {
85612
+ this.holds.delete(deviceId);
85613
+ logger.warn("alexa egress prewarm: acquire failed, the session will start the transcode", {
85614
+ tags: { deviceId },
85615
+ meta: { error: err instanceof Error ? err.message : String(err) }
85616
+ });
85617
+ }
85618
+ }
85619
+ /** Release every pending hold (addon shutdown). */
85620
+ async dispose() {
85621
+ this.disposed = true;
85622
+ const pending = [...this.holds.entries()];
85623
+ await Promise.all(pending.map(([deviceId, hold]) => this.release(deviceId, hold, "shutdown")));
85624
+ }
85625
+ async release(deviceId, hold, reason) {
85626
+ if (hold.timer) clearTimeout(hold.timer);
85627
+ hold.timer = null;
85628
+ if (this.holds.get(deviceId) === hold) this.holds.delete(deviceId);
85629
+ const pipelineKey = hold.pipelineKey;
85630
+ hold.pipelineKey = null;
85631
+ if (pipelineKey === null) return;
85632
+ await releaseAlexaEgress({
85633
+ api: this.deps.api,
85634
+ deviceId,
85635
+ pipelineKey,
85636
+ logger: this.deps.logger
85637
+ });
85638
+ this.deps.logger.info("alexa egress prewarm: hold released", {
85639
+ tags: { deviceId },
85640
+ meta: {
85641
+ pipelineKey,
85642
+ reason
85643
+ }
85644
+ });
85645
+ }
85646
+ };
85647
+ //#endregion
84845
85648
  //#region src/handlers/endpoint-id.ts
84846
85649
  /** The classes a camera publishes a detection sensor for (R1). */
84847
85650
  var DETECTION_SENSOR_CLASSES = [
@@ -85118,47 +85921,12 @@ async function handleInitiateSessionWithOffer(header, endpointRaw, payloadRaw, d
85118
85921
  if (sdpOffer.length === 0) return errorEnvelope(header, "INVALID_DIRECTIVE", "offer.value is empty");
85119
85922
  const api = deps.ctx.api;
85120
85923
  const exposedEntry = deps.listExposed().find((e) => e.deviceId === deviceId);
85121
- const pinnedProfile = (() => {
85122
- const pref = exposedEntry?.settings?.streamPreference;
85123
- if (pref === "low" || pref === "mid" || pref === "high") return pref;
85124
- })();
85125
- const allowTranscode = exposedEntry?.settings?.allowTranscode !== false;
85126
- const scored = pinnedProfile === void 0 ? await api.cameraStreams.pickStream.query({
85127
- deviceId,
85128
- requirements: {
85129
- acceptCodecs: ["h264"],
85130
- minHeight: 480,
85131
- maxHeight: ALEXA_MAX_LINES,
85132
- excludeDerived: true,
85133
- allowTranscode
85134
- },
85135
- preferences: { targetHeight: 720 }
85136
- }).catch((err) => {
85137
- log.warn("alexa rtc-session: pickStream threw — falling back to the high slot", {
85138
- tags: { deviceId },
85139
- meta: { error: err instanceof Error ? err.message : String(err) }
85140
- });
85141
- return null;
85142
- }) : null;
85143
- const scoredProfile = scored === null ? null : await profileForCamStream({
85924
+ const sourceProfile = await resolveAlexaSourceProfile({
85144
85925
  api,
85145
85926
  deviceId,
85146
- camStreamId: scored.camStreamId,
85927
+ exposedEntry,
85147
85928
  logger: log
85148
85929
  });
85149
- const sourceProfile = pinnedProfile ?? scoredProfile ?? "high";
85150
- if (pinnedProfile === void 0) log.info("alexa rtc-session: source scored against the Echo requirements", {
85151
- tags: { deviceId },
85152
- meta: {
85153
- chosen: sourceProfile,
85154
- scored: scored === null ? "none-eligible" : scored.reason,
85155
- camStreamId: scored?.camStreamId ?? null,
85156
- slot: scoredProfile ?? (scored === null ? null : "no-slot"),
85157
- height: scored?.resolution?.height ?? null,
85158
- transcodes: scored?.transcodes ?? null,
85159
- allowTranscode
85160
- }
85161
- });
85162
85930
  let derivedTarget;
85163
85931
  /**
85164
85932
  * The primitive's release handle, when this session acquired one. Recorded so
@@ -91971,6 +92739,7 @@ var LwaEventGateway = class {
91971
92739
  return;
91972
92740
  }
91973
92741
  if (!this.hasProactiveCredentials()) return;
92742
+ this.deps.onExposedDoorbellPress?.(parentDeviceId);
91974
92743
  for (const account of linked) {
91975
92744
  if (!this.mayPush(account.userId, parentDeviceId, "doorbell press")) continue;
91976
92745
  if (!this.findToken(account.userId)) {
@@ -95134,6 +95903,7 @@ var ExportAlexaAddon = class extends BaseAddon {
95134
95903
  "tokens[userId].brokerCredential"
95135
95904
  ];
95136
95905
  lwaGateway = null;
95906
+ egressPrewarm = null;
95137
95907
  syncEngine = null;
95138
95908
  /** S1 (D767): the linking user's live grants. Built in `onInitialize`, the
95139
95909
  * first point `ctx` exists. */
@@ -95300,10 +96070,19 @@ var ExportAlexaAddon = class extends BaseAddon {
95300
96070
  }
95301
96071
  }));
95302
96072
  const oauthIntegrationProvider = { getDescriptor: async () => buildAlexaOauthIntegration(this.config.publicHubUrl) };
96073
+ this.egressPrewarm = new AlexaEgressPrewarm({
96074
+ api: this.ctx.api,
96075
+ logger: this.ctx.logger,
96076
+ listExposed: () => this.config.exposed,
96077
+ hasLiveSession: (deviceId) => heldEgressHandles().some((h) => h.deviceId === deviceId)
96078
+ });
95303
96079
  this.lwaGateway = new LwaEventGateway({
95304
96080
  ctx: this.ctx,
95305
96081
  logger: this.ctx.logger,
95306
96082
  listExposed: () => this.config.exposed,
96083
+ onExposedDoorbellPress: (deviceId) => {
96084
+ this.egressPrewarm?.onPress(deviceId);
96085
+ },
95307
96086
  listLinkedAccounts: () => this.config.linkedAccounts,
95308
96087
  listTokens: () => this.config.tokens,
95309
96088
  upsertToken: (input) => this.upsertToken(input),
@@ -95457,6 +96236,10 @@ var ExportAlexaAddon = class extends BaseAddon {
95457
96236
  this.stateReconciler = null;
95458
96237
  this.stateReporter?.stop();
95459
96238
  this.stateReporter = null;
96239
+ if (this.egressPrewarm) {
96240
+ await this.egressPrewarm.dispose();
96241
+ this.egressPrewarm = null;
96242
+ }
95460
96243
  if (this.lwaGateway) {
95461
96244
  this.lwaGateway.stop();
95462
96245
  this.lwaGateway = null;