@camstack/types 1.2.554 → 1.2.555

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.2.555] - 2026-11-12
11
+
12
+ ### Changed
13
+
14
+ - IR transmitters can learn a code and replay device-native (Tuya) codes: ir-transmitter gains learn, send takes a native code, and a remote command can store one
15
+
10
16
  ## [1.2.554] - 2026-11-12
11
17
 
12
18
  ### Changed
@@ -146,10 +152,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
146
152
 
147
153
  - holdVarSlots: the one helper that sets aside the {{ vars.x }} slots of a step text
148
154
 
149
- ### Added
150
-
151
- ### Changed
152
-
153
155
  ## [1.2.538] - 2026-11-10
154
156
 
155
157
  ### Changed
package/dist/addon.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sleep = require("./sleep-dcR4vBFG.js");
2
+ const require_sleep = require("./sleep-4qch9WKa.js");
3
3
  const require_event_category = require("./event-category-BC4RRerT.js");
4
4
  const require_composed_stable_id = require("./composed-stable-id-CDNLq7Y8.js");
5
5
  //#region src/generated/cap-input-defaults.ts
@@ -16,7 +16,7 @@ const require_composed_stable_id = require("./composed-stable-id-CDNLq7Y8.js");
16
16
  * Plain data, zero Zod: a forked runner must not import the schema barrel
17
17
  * (~144MB RSS per runner — D28).
18
18
  *
19
- * Coverage: 33 caps, 84 methods with defaults.
19
+ * Coverage: 34 caps, 85 methods with defaults.
20
20
  */
21
21
  var CAP_INPUT_DEFAULTS = Object.freeze({
22
22
  "addons": { "getLogs": { "limit": 100 } },
@@ -63,6 +63,7 @@ var CAP_INPUT_DEFAULTS = Object.freeze({
63
63
  "listRecentTransitions": { "limit": 50 },
64
64
  "listTransitions": { "limit": 50 }
65
65
  },
66
+ "ir-transmitter": { "learn": { "timeoutMs": 2e4 } },
66
67
  "llm-runtime": {
67
68
  "complete": { "runtime": { "__nested__": {
68
69
  "contextSize": 4096,
package/dist/addon.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as DEVICE_CHILDREN_BATCH_MAX, $r as RECORD_DATABASES, A as CAP_ADVANCE_FIELDS, Ai as RecordSecretUnavailableError, An as CALLER_USERNAME_HEADER, Ar as nodeIdOfScopedKey, Bn as RecordKindNameSchema, Ci as FilterRequiredError, Cn as scrubKnownSecrets, Ct as createDebugEmitter, Di as PlaintextSecretError, Dn as PEER_BYTES_STALL_MS, Ei as NoCallerError, En as PEER_BYTES_MAX_OUTSTANDING, F as withoutCallerStamp, Fi as TransactRefusedError, Fn as entryBody, G as readNodePin, Gn as defineRecordKinds, Gr as parseSecretPath, H as commandOrigin, Hn as StoredRecordKindDeclarationSchema, Hr as REMOVE_LEAF, I as customAction, Ii as UnindexedFilterError, In as EntryDescriptorSchema, J as PipelineRunResultBridge, Jn as isZodSecret, Jr as recordSecretRef, Kr as recordArrayItemPath, L as defineCustomActions, Li as UnknownRecordKindError, Ln as RecordFieldPathSchema, Mi as RecordUniqueViolationError, Mr as resolvedValues, N as CAP_STATE_LEAVES, Ni as RecordsError, Nn as DisposerChain, O as HF_REPO, Oi as RECORDS_ERROR_CODES, On as PEER_BYTES_TICKET_TTL_MS, P as CALLER_STAMPED_CAPABILITIES, Pi as RevConflictError, Pn as defineEntryKind, Q as deviceOpsCapability, Qr as RECORD_CLASSES, R as describeCustomActions, Ri as asRecordsError, Rn as RecordIndexSchema, Sa as findMigrationsBlocked, Si as DeclarationRefusedError, Sn as registerKnownSecret, T as isCommand, Ti as InvalidRecordError, Tn as PEER_BYTES_CHUNK_BYTES, U as nodePin, Un as assertValidDeclaration, Ur as collectSecretLeaves, Vn as RecordRetentionSchema, Vr as secretViewsOf, W as readCommandOrigin, Wn as declarationsOf, Wr as mapSecretLeaves, X as MIGRATION_API_VERSION, Xi as emitReadiness, Xr as RECORD_BATCH_MAX, Y as PipelineStepInputSchema, Yi as createEvent, Yr as secretArrayPrefixes, Zr as RECORD_BATCH_MAX_BYTES, _i as parseSecretRef, _n as createSecretsAccess, ai as RECORD_MAX_INDEX_FIELDS, bn as forgetKnownSecret, c as asString, ca as isSecretClear, ci as RECORD_SETTINGS_MAX_ROWS, d as parseJsonUnknown, da as isSecretMarkerLike, di as arrayItemFieldPath, dn as ruleFireOfClaim, dr as ErrorI18nPayloadSchema, dt as ReadinessRegistry, ei as RECORD_DEFAULT_MAX_DATA_BYTES, et as adminUiCapability, f as hfModelUrl, fa as makeSecretMarker, fi as buildSecretRef, fn as makeInMemoryRecords, ft as ReadinessTimeoutError, g as createDeviceProxy, gi as normalizeSecretOwner, gn as REVALIDATE_AFTER_MS, gr as BaseAddon, h as isDeviceScopedCap, hi as isSecretRef, hn as resolveSecretViewsIn, ht as scopeKey, ii as RECORD_MAX_INDEXES, j as CAP_METHOD_TIMEOUTS_MS, ji as RecordTooLargeError, jn as DATAPLANE_SECRET_HEADER, jr as resolveDeviceSettings, ki as RecordNotFoundError, kr as SCOPED_SETTINGS_SCOPES, la as isSecretFieldView, li as RECORD_SWEEP_INTERVAL_MS, ln as CommandOriginClaimSchema, m as DEVICE_SCOPED_CAPS, mi as globalSecretScope, mn as assertTransactScope, mr as readErrorI18n, ni as RECORD_ID_MAX_LENGTH, nr as expandCapMethods, nt as addonPagesSourceCapability, o as asJsonObject, oa as SECRET_CLEAR, oi as RECORD_QUERY_MAX, p as BOOT_RECOVERY_BACKOFF_MS, pa as toSecretFieldView, pi as formatSecretScope, pn as createRecordsAccess, q as viewerUiCapability, qn as collectZodSecretPaths, qr as recordSecretCollection, r as maskUrlCredentials, ri as RECORD_MAX_DATA_BYTES, sa as classifySecretWrite, si as RECORD_SECRET_COLLECTION_PREFIX, t as sleep, ti as RECORD_DELETE_BATCH, ua as isSecretMarker, ui as SECRET_REF_SCHEME, un as RuleFireOriginSchema, ut as MODEL_FORMATS, v as addonSliceHandleApi, vn as MIN_SCRUBBED_LENGTH, wi as ForeignSecretMarkerError, wn as shortSecretRefHash, xa as AddonMigrationsBlockedError, xi as BatchTooLargeError, xn as knownSecretCount, y as createEventBusSliceSource, yn as clearKnownSecrets, yr as normalizeAddonInitResult, zi as recordsErrorFromMessage, zn as RecordKindDeclarationSchema } from "./sleep-D0roI_CZ.mjs";
1
+ import { $ as DEVICE_CHILDREN_BATCH_MAX, $r as RECORD_DATABASES, A as CAP_ADVANCE_FIELDS, Ai as RecordSecretUnavailableError, An as CALLER_USERNAME_HEADER, Ar as nodeIdOfScopedKey, Bn as RecordKindNameSchema, Ci as FilterRequiredError, Cn as scrubKnownSecrets, Ct as createDebugEmitter, Di as PlaintextSecretError, Dn as PEER_BYTES_STALL_MS, Ei as NoCallerError, En as PEER_BYTES_MAX_OUTSTANDING, F as withoutCallerStamp, Fi as TransactRefusedError, Fn as entryBody, G as readNodePin, Gn as defineRecordKinds, Gr as parseSecretPath, H as commandOrigin, Hn as StoredRecordKindDeclarationSchema, Hr as REMOVE_LEAF, I as customAction, Ii as UnindexedFilterError, In as EntryDescriptorSchema, J as PipelineRunResultBridge, Jn as isZodSecret, Jr as recordSecretRef, Kr as recordArrayItemPath, L as defineCustomActions, Li as UnknownRecordKindError, Ln as RecordFieldPathSchema, Mi as RecordUniqueViolationError, Mr as resolvedValues, N as CAP_STATE_LEAVES, Ni as RecordsError, Nn as DisposerChain, O as HF_REPO, Oi as RECORDS_ERROR_CODES, On as PEER_BYTES_TICKET_TTL_MS, P as CALLER_STAMPED_CAPABILITIES, Pi as RevConflictError, Pn as defineEntryKind, Q as deviceOpsCapability, Qr as RECORD_CLASSES, R as describeCustomActions, Ri as asRecordsError, Rn as RecordIndexSchema, Sa as findMigrationsBlocked, Si as DeclarationRefusedError, Sn as registerKnownSecret, T as isCommand, Ti as InvalidRecordError, Tn as PEER_BYTES_CHUNK_BYTES, U as nodePin, Un as assertValidDeclaration, Ur as collectSecretLeaves, Vn as RecordRetentionSchema, Vr as secretViewsOf, W as readCommandOrigin, Wn as declarationsOf, Wr as mapSecretLeaves, X as MIGRATION_API_VERSION, Xi as emitReadiness, Xr as RECORD_BATCH_MAX, Y as PipelineStepInputSchema, Yi as createEvent, Yr as secretArrayPrefixes, Zr as RECORD_BATCH_MAX_BYTES, _i as parseSecretRef, _n as createSecretsAccess, ai as RECORD_MAX_INDEX_FIELDS, bn as forgetKnownSecret, c as asString, ca as isSecretClear, ci as RECORD_SETTINGS_MAX_ROWS, d as parseJsonUnknown, da as isSecretMarkerLike, di as arrayItemFieldPath, dn as ruleFireOfClaim, dr as ErrorI18nPayloadSchema, dt as ReadinessRegistry, ei as RECORD_DEFAULT_MAX_DATA_BYTES, et as adminUiCapability, f as hfModelUrl, fa as makeSecretMarker, fi as buildSecretRef, fn as makeInMemoryRecords, ft as ReadinessTimeoutError, g as createDeviceProxy, gi as normalizeSecretOwner, gn as REVALIDATE_AFTER_MS, gr as BaseAddon, h as isDeviceScopedCap, hi as isSecretRef, hn as resolveSecretViewsIn, ht as scopeKey, ii as RECORD_MAX_INDEXES, j as CAP_METHOD_TIMEOUTS_MS, ji as RecordTooLargeError, jn as DATAPLANE_SECRET_HEADER, jr as resolveDeviceSettings, ki as RecordNotFoundError, kr as SCOPED_SETTINGS_SCOPES, la as isSecretFieldView, li as RECORD_SWEEP_INTERVAL_MS, ln as CommandOriginClaimSchema, m as DEVICE_SCOPED_CAPS, mi as globalSecretScope, mn as assertTransactScope, mr as readErrorI18n, ni as RECORD_ID_MAX_LENGTH, nr as expandCapMethods, nt as addonPagesSourceCapability, o as asJsonObject, oa as SECRET_CLEAR, oi as RECORD_QUERY_MAX, p as BOOT_RECOVERY_BACKOFF_MS, pa as toSecretFieldView, pi as formatSecretScope, pn as createRecordsAccess, q as viewerUiCapability, qn as collectZodSecretPaths, qr as recordSecretCollection, r as maskUrlCredentials, ri as RECORD_MAX_DATA_BYTES, sa as classifySecretWrite, si as RECORD_SECRET_COLLECTION_PREFIX, t as sleep, ti as RECORD_DELETE_BATCH, ua as isSecretMarker, ui as SECRET_REF_SCHEME, un as RuleFireOriginSchema, ut as MODEL_FORMATS, v as addonSliceHandleApi, vn as MIN_SCRUBBED_LENGTH, wi as ForeignSecretMarkerError, wn as shortSecretRefHash, xa as AddonMigrationsBlockedError, xi as BatchTooLargeError, xn as knownSecretCount, y as createEventBusSliceSource, yn as clearKnownSecrets, yr as normalizeAddonInitResult, zi as recordsErrorFromMessage, zn as RecordKindDeclarationSchema } from "./sleep-Ba1dJYDo.mjs";
2
2
  import { t as EventCategory } from "./event-category-78tcBemo.mjs";
3
3
  import { a as DeviceType, s as errMsg, t as COMPOSED_DEVICE_STABLE_ID_PREFIX } from "./composed-stable-id-CPp3votu.mjs";
4
4
  //#region src/generated/cap-input-defaults.ts
@@ -15,7 +15,7 @@ import { a as DeviceType, s as errMsg, t as COMPOSED_DEVICE_STABLE_ID_PREFIX } f
15
15
  * Plain data, zero Zod: a forked runner must not import the schema barrel
16
16
  * (~144MB RSS per runner — D28).
17
17
  *
18
- * Coverage: 33 caps, 84 methods with defaults.
18
+ * Coverage: 34 caps, 85 methods with defaults.
19
19
  */
20
20
  var CAP_INPUT_DEFAULTS = Object.freeze({
21
21
  "addons": { "getLogs": { "limit": 100 } },
@@ -62,6 +62,7 @@ var CAP_INPUT_DEFAULTS = Object.freeze({
62
62
  "listRecentTransitions": { "limit": 50 },
63
63
  "listTransitions": { "limit": 50 }
64
64
  },
65
+ "ir-transmitter": { "learn": { "timeoutMs": 2e4 } },
65
66
  "llm-runtime": {
66
67
  "complete": { "runtime": { "__nested__": {
67
68
  "contextSize": 4096,
@@ -176,7 +176,7 @@ export { HERO_ROW_MODELS_MAX, heroLayoutCapability, type HeroLayoutRows, HeroLay
176
176
  export { type ITemplateProvider, TEMPLATE_WRITE_REFUSALS, type TemplateDeleteResult, TemplateDeleteResultSchema, type TemplateRecord, TemplateRecordSchema, type TemplateUser, TemplateUserSchema, type TemplateWriteResult, TemplateWriteResultSchema, templateCapability, } from './template.cap.js';
177
177
  export { type IRemoteLayoutComponentsProvider, remoteLayoutComponentsCapability, } from './remote-layout-components.cap.js';
178
178
  export { buttonCapability, type IButtonProvider } from './button.cap.js';
179
- export { irTransmitterCapability, TransmitSettingKeySchema, IrMediumSchema, IrSendResultSchema, IrTransmitterInfoSchema, type IIrTransmitterProvider, type TransmitSettingKey, type IrMedium, type IrSendResult, type IrTransmitterInfo, } from './ir-transmitter.cap.js';
179
+ export { irTransmitterCapability, TransmitSettingKeySchema, IrMediumSchema, IrSendResultSchema, IrTransmitterInfoSchema, type IIrTransmitterProvider, type TransmitSettingKey, type IrMedium, type IrSendResult, type IrTransmitterInfo, IrLearnResultSchema, type IrLearnResult, IR_LEARN_TIMEOUT_DEFAULT_MS, IR_LEARN_TIMEOUT_MAX_MS, } from './ir-transmitter.cap.js';
180
180
  export type { CalendarEvent, CalendarInfo, CalendarListEventsInput, CalendarLocalSpan, CalendarSourceKind, ICalendarSourceProvider, } from './calendar-source.cap.js';
181
181
  export { CalendarEventSchema, CalendarInfoSchema, CalendarListEventsInputSchema, CalendarSourceKindSchema, calendarEventLocalSpan, calendarEventOnLocalDay, calendarSourceCapability, } from './calendar-source.cap.js';
182
182
  export type { CalendarColor, CalendarEntry, CalendarPreferenceEntry, CalendarPreferences, CalendarSetPreferenceInput, ICalendarsProvider, } from './calendars.cap.js';
@@ -31,8 +31,25 @@ export declare const IrTransmitterInfoSchema: z.ZodObject<{
31
31
  repeatDelayMs: "repeatDelayMs";
32
32
  }>>;
33
33
  maxTimings: z.ZodNumber;
34
+ learn: z.ZodDefault<z.ZodBoolean>;
35
+ formats: z.ZodDefault<z.ZodArray<z.ZodEnum<{
36
+ tuya: "tuya";
37
+ }>>>;
34
38
  }, z.core.$strip>;
35
39
  export type IrTransmitterInfo = z.infer<typeof IrTransmitterInfoSchema>;
40
+ export declare const IR_LEARN_TIMEOUT_DEFAULT_MS = 20000;
41
+ export declare const IR_LEARN_TIMEOUT_MAX_MS = 60000;
42
+ export declare const IrLearnResultSchema: z.ZodObject<{
43
+ native: z.ZodNullable<z.ZodObject<{
44
+ format: z.ZodEnum<{
45
+ tuya: "tuya";
46
+ }>;
47
+ code: z.ZodString;
48
+ }, z.core.$strip>>;
49
+ timings: z.ZodArray<z.ZodNumber>;
50
+ carrierHz: z.ZodNullable<z.ZodNumber>;
51
+ }, z.core.$strip>;
52
+ export type IrLearnResult = z.infer<typeof IrLearnResultSchema>;
36
53
  /**
37
54
  * ir-transmitter — emit a pulse train (infrared or RF) with settings. One cap
38
55
  * for both media: everything medium-specific is a per-call setting, validated
@@ -42,7 +59,12 @@ export type IrTransmitterInfo = z.infer<typeof IrTransmitterInfoSchema>;
42
59
  * transmitter cannot be reached) and `ir-transmitter.too-long` (more pulses
43
60
  * than the transmitter's `maxTimings`). A setting the transmitter cannot apply
44
61
  * is NOT a refusal: the train is sent and the key comes back in
45
- * `ignoredSettings`.
62
+ * `ignoredSettings`. `send` takes exactly one of `timings` or `native` (a code
63
+ * in a format listed in `getInfo.formats`).
64
+ *
65
+ * `learn` waits for the user to point a remote at the transmitter and refuses
66
+ * with `ir-transmitter.learn-unsupported`, `ir-transmitter.learn-timeout` or
67
+ * `ir-transmitter.learn-undecodable`.
46
68
  */
47
69
  export declare const irTransmitterCapability: {
48
70
  readonly name: 'ir-transmitter';
@@ -53,7 +75,13 @@ export declare const irTransmitterCapability: {
53
75
  readonly methods: {
54
76
  readonly send: import("./capability-definition.js").CapabilityMethodSchema<z.ZodObject<{
55
77
  deviceId: z.ZodNumber;
56
- timings: z.ZodArray<z.ZodNumber>;
78
+ timings: z.ZodOptional<z.ZodArray<z.ZodNumber>>;
79
+ native: z.ZodOptional<z.ZodObject<{
80
+ format: z.ZodEnum<{
81
+ tuya: "tuya";
82
+ }>;
83
+ code: z.ZodString;
84
+ }, z.core.$strip>>;
57
85
  settings: z.ZodOptional<z.ZodObject<{
58
86
  carrierHz: z.ZodOptional<z.ZodNumber>;
59
87
  dutyCyclePercent: z.ZodOptional<z.ZodNumber>;
@@ -64,6 +92,19 @@ export declare const irTransmitterCapability: {
64
92
  ok: z.ZodLiteral<true>;
65
93
  ignoredSettings: z.ZodArray<z.ZodString>;
66
94
  }, z.core.$strip>, "mutation">;
95
+ readonly learn: import("./capability-definition.js").CapabilityMethodSchema<z.ZodObject<{
96
+ deviceId: z.ZodNumber;
97
+ timeoutMs: z.ZodDefault<z.ZodNumber>;
98
+ }, z.core.$strip>, z.ZodObject<{
99
+ native: z.ZodNullable<z.ZodObject<{
100
+ format: z.ZodEnum<{
101
+ tuya: "tuya";
102
+ }>;
103
+ code: z.ZodString;
104
+ }, z.core.$strip>>;
105
+ timings: z.ZodArray<z.ZodNumber>;
106
+ carrierHz: z.ZodNullable<z.ZodNumber>;
107
+ }, z.core.$strip>, "mutation">;
67
108
  readonly getInfo: import("./capability-definition.js").CapabilityMethodSchema<z.ZodObject<{
68
109
  deviceId: z.ZodNumber;
69
110
  }, z.core.$strip>, z.ZodObject<{
@@ -78,6 +119,10 @@ export declare const irTransmitterCapability: {
78
119
  repeatDelayMs: "repeatDelayMs";
79
120
  }>>;
80
121
  maxTimings: z.ZodNumber;
122
+ learn: z.ZodDefault<z.ZodBoolean>;
123
+ formats: z.ZodDefault<z.ZodArray<z.ZodEnum<{
124
+ tuya: "tuya";
125
+ }>>>;
81
126
  }, z.core.$strip>, "query">;
82
127
  };
83
128
  };
@@ -61,6 +61,12 @@ export declare const RemoteCommandListSchema: z.ZodObject<{
61
61
  }, z.core.$strip>, z.ZodObject<{
62
62
  kind: z.ZodLiteral<"pronto">;
63
63
  code: z.ZodString;
64
+ }, z.core.$strip>, z.ZodObject<{
65
+ kind: z.ZodLiteral<"native">;
66
+ format: z.ZodEnum<{
67
+ tuya: "tuya";
68
+ }>;
69
+ code: z.ZodString;
64
70
  }, z.core.$strip>], "kind">;
65
71
  }, z.core.$strip>], "kind">>;
66
72
  }, z.core.$strip>;
@@ -220,6 +226,12 @@ export declare const remoteCapability: {
220
226
  }, z.core.$strip>, z.ZodObject<{
221
227
  kind: z.ZodLiteral<"pronto">;
222
228
  code: z.ZodString;
229
+ }, z.core.$strip>, z.ZodObject<{
230
+ kind: z.ZodLiteral<"native">;
231
+ format: z.ZodEnum<{
232
+ tuya: "tuya";
233
+ }>;
234
+ code: z.ZodString;
223
235
  }, z.core.$strip>], "kind">;
224
236
  }, z.core.$strip>], "kind">>>;
225
237
  stepDelayMs: z.ZodDefault<z.ZodNumber>;
@@ -276,6 +288,12 @@ export declare const remoteCapability: {
276
288
  }, z.core.$strip>, z.ZodObject<{
277
289
  kind: z.ZodLiteral<"pronto">;
278
290
  code: z.ZodString;
291
+ }, z.core.$strip>, z.ZodObject<{
292
+ kind: z.ZodLiteral<"native">;
293
+ format: z.ZodEnum<{
294
+ tuya: "tuya";
295
+ }>;
296
+ code: z.ZodString;
279
297
  }, z.core.$strip>], "kind">;
280
298
  }, z.core.$strip>], "kind">>>;
281
299
  stepDelayMs: z.ZodDefault<z.ZodNumber>;
@@ -332,6 +350,12 @@ export declare const remoteCapability: {
332
350
  }, z.core.$strip>, z.ZodObject<{
333
351
  kind: z.ZodLiteral<"pronto">;
334
352
  code: z.ZodString;
353
+ }, z.core.$strip>, z.ZodObject<{
354
+ kind: z.ZodLiteral<"native">;
355
+ format: z.ZodEnum<{
356
+ tuya: "tuya";
357
+ }>;
358
+ code: z.ZodString;
335
359
  }, z.core.$strip>], "kind">;
336
360
  }, z.core.$strip>], "kind">>;
337
361
  }, z.core.$strip>, import("./capability-definition.js").CapabilityMethodKind>;
package/dist/client.js CHANGED
@@ -27272,6 +27272,7 @@ function createDeviceProxy(api, binding, opts) {
27272
27272
  };
27273
27273
  const irTransmitterInterface = {
27274
27274
  send: (input) => dispatch("ir-transmitter", "irTransmitter", "send", "mutation", input),
27275
+ learn: (input) => dispatch("ir-transmitter", "irTransmitter", "learn", "mutation", input),
27275
27276
  getInfo: (input) => dispatch("ir-transmitter", "irTransmitter", "getInfo", "query", input)
27276
27277
  };
27277
27278
  const lawnMowerControlInterface = {
package/dist/client.mjs CHANGED
@@ -27271,6 +27271,7 @@ function createDeviceProxy(api, binding, opts) {
27271
27271
  };
27272
27272
  const irTransmitterInterface = {
27273
27273
  send: (input) => dispatch("ir-transmitter", "irTransmitter", "send", "mutation", input),
27274
+ learn: (input) => dispatch("ir-transmitter", "irTransmitter", "learn", "mutation", input),
27274
27275
  getInfo: (input) => dispatch("ir-transmitter", "irTransmitter", "getInfo", "query", input)
27275
27276
  };
27276
27277
  const lawnMowerControlInterface = {
@@ -4658,6 +4658,13 @@ export type AppRouter = TrpcCoreRouter<{
4658
4658
  output: z.infer<typeof irTransmitterCapability.methods.send.output>;
4659
4659
  meta: object;
4660
4660
  }>;
4661
+ learn: TRPCMutationProcedure<{
4662
+ input: {
4663
+ [x: string]: unknown;
4664
+ } & z.input<typeof irTransmitterCapability.methods.learn.input>;
4665
+ output: z.infer<typeof irTransmitterCapability.methods.learn.output>;
4666
+ meta: object;
4667
+ }>;
4661
4668
  getInfo: TRPCQueryProcedure<{
4662
4669
  input: {
4663
4670
  [x: string]: unknown;
@@ -11,7 +11,7 @@
11
11
  * Plain data, zero Zod: a forked runner must not import the schema barrel
12
12
  * (~144MB RSS per runner — D28).
13
13
  *
14
- * Coverage: 33 caps, 84 methods with defaults.
14
+ * Coverage: 34 caps, 85 methods with defaults.
15
15
  */
16
16
  export declare const CAP_INPUT_DEFAULTS: Readonly<Record<string, Readonly<Record<string, Readonly<Record<string, unknown>>>>>>;
17
17
  /**
@@ -6,7 +6,7 @@
6
6
  * scope+access check inside `protectedProcedure` (see
7
7
  * `server/backend/src/api/trpc/trpc.middleware.ts`).
8
8
  *
9
- * Coverage: 1483 method paths across 205 capabilities.
9
+ * Coverage: 1484 method paths across 205 capabilities.
10
10
  */
11
11
  import type { MethodRole } from '../auth/viewer-access.js';
12
12
  import type { CapabilityMethodAccess } from '../capabilities/capability-definition.js';
@@ -6,7 +6,7 @@
6
6
  * system-scope cap that takes a deviceId was previously never device-filtered
7
7
  * — see the generator header).
8
8
  *
9
- * Coverage: 613 methods carry a device reference, of which
9
+ * Coverage: 614 methods carry a device reference, of which
10
10
  * 195 are on SYSTEM-scope caps.
11
11
  *
12
12
  * Top-level fields, number arrays, and one-level arrays of objects carrying
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
2
- const require_sleep = require("./sleep-dcR4vBFG.js");
2
+ const require_sleep = require("./sleep-4qch9WKa.js");
3
3
  const require_event_category = require("./event-category-BC4RRerT.js");
4
4
  const require_composed_stable_id = require("./composed-stable-id-CDNLq7Y8.js");
5
5
  const require_implemented_methods = require("./implemented-methods-Cj65uy2F.js");
@@ -46059,16 +46059,193 @@ function decodePronto(code) {
46059
46059
  };
46060
46060
  }
46061
46061
  //#endregion
46062
+ //#region src/ir/fastlz.ts
46063
+ /**
46064
+ * FastLZ level 1: a byte-oriented LZ77 stream. A control byte below 32 starts a
46065
+ * literal run of `ctrl + 1` bytes; otherwise it is a back-reference whose length
46066
+ * is `ctrl >> 5` (extended by one byte when 7) and whose distance is split
46067
+ * between the low 5 bits and the next byte.
46068
+ */
46069
+ var MAX_DISTANCE = 8192;
46070
+ var MAX_LITERAL_RUN = 32;
46071
+ var MIN_MATCH = 3;
46072
+ var MAX_MATCH = 264;
46073
+ /**
46074
+ * Most bytes a decoded IR code may hold: two bytes per timing. A level-1 stream
46075
+ * can expand ~130x, so the decoder checks this bound before every write.
46076
+ */
46077
+ var IR_DECOMPRESSED_MAX = IR_TIMINGS_MAX * 2;
46078
+ function fastlzDecompress(input) {
46079
+ const out = [];
46080
+ let ip = 0;
46081
+ const room = (count) => {
46082
+ if (out.length + count > IR_DECOMPRESSED_MAX) throw new IrCodecError("tuya-malformed", "decompressed code is larger than any IR train");
46083
+ };
46084
+ const next = () => {
46085
+ const byte = input[ip++];
46086
+ if (byte === void 0) throw new IrCodecError("tuya-malformed", "compressed stream is truncated");
46087
+ return byte;
46088
+ };
46089
+ while (ip < input.length) {
46090
+ const ctrl = next();
46091
+ if (ctrl < 32) {
46092
+ room(ctrl + 1);
46093
+ for (let i = 0; i <= ctrl; i++) out.push(next());
46094
+ continue;
46095
+ }
46096
+ let len = (ctrl >> 5) - 1;
46097
+ if (len === 6) len += next();
46098
+ const distance = ((ctrl & 31) << 8) + next() + 1;
46099
+ const start = out.length - distance;
46100
+ if (start < 0) throw new IrCodecError("tuya-malformed", "back-reference points before the stream");
46101
+ room(len + 3);
46102
+ for (let i = 0; i < len + 3; i++) {
46103
+ const byte = out[start + i];
46104
+ if (byte === void 0) throw new IrCodecError("tuya-malformed", "back-reference is invalid");
46105
+ out.push(byte);
46106
+ }
46107
+ }
46108
+ return Uint8Array.from(out);
46109
+ }
46110
+ function fastlzCompress(input) {
46111
+ const out = [];
46112
+ const lastSeen = /* @__PURE__ */ new Map();
46113
+ let literalStart = 0;
46114
+ const flushLiterals = (end) => {
46115
+ for (let from = literalStart; from < end; from += MAX_LITERAL_RUN) {
46116
+ const to = Math.min(from + MAX_LITERAL_RUN, end);
46117
+ out.push(to - from - 1);
46118
+ for (let i = from; i < to; i++) out.push(input[i] ?? 0);
46119
+ }
46120
+ };
46121
+ let pos = 0;
46122
+ while (pos < input.length) {
46123
+ let matchLen = 0;
46124
+ let matchDistance = 0;
46125
+ if (pos + MIN_MATCH <= input.length) {
46126
+ const key = (input[pos] ?? 0) << 16 | (input[pos + 1] ?? 0) << 8 | (input[pos + 2] ?? 0);
46127
+ const candidate = lastSeen.get(key);
46128
+ lastSeen.set(key, pos);
46129
+ if (candidate !== void 0 && pos - candidate <= MAX_DISTANCE) {
46130
+ let len = 0;
46131
+ while (pos + len < input.length && len < MAX_MATCH && input[candidate + len] === input[pos + len]) len++;
46132
+ if (len >= MIN_MATCH) {
46133
+ matchLen = len;
46134
+ matchDistance = pos - candidate - 1;
46135
+ }
46136
+ }
46137
+ }
46138
+ if (matchLen === 0) {
46139
+ pos++;
46140
+ continue;
46141
+ }
46142
+ flushLiterals(pos);
46143
+ const enc = matchLen - 2;
46144
+ if (enc < 7) out.push(enc << 5 | matchDistance >> 8);
46145
+ else out.push(224 | matchDistance >> 8, enc - 7);
46146
+ out.push(matchDistance & 255);
46147
+ pos += matchLen;
46148
+ literalStart = pos;
46149
+ }
46150
+ flushLiterals(input.length);
46151
+ return Uint8Array.from(out);
46152
+ }
46153
+ //#endregion
46154
+ //#region src/ir/tuya.ts
46155
+ var ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
46156
+ var MAX_DURATION_US = 65535;
46157
+ function toBase64(bytes) {
46158
+ let out = "";
46159
+ for (let i = 0; i < bytes.length; i += 3) {
46160
+ const a = bytes[i] ?? 0;
46161
+ const b = bytes[i + 1] ?? 0;
46162
+ const c = bytes[i + 2] ?? 0;
46163
+ const word = a << 16 | b << 8 | c;
46164
+ out += ALPHABET[word >> 18 & 63];
46165
+ out += ALPHABET[word >> 12 & 63];
46166
+ out += i + 1 < bytes.length ? ALPHABET[word >> 6 & 63] : "=";
46167
+ out += i + 2 < bytes.length ? ALPHABET[word & 63] : "=";
46168
+ }
46169
+ return out;
46170
+ }
46171
+ function fromBase64(text) {
46172
+ const clean = text.trim().replace(/=+$/, "");
46173
+ if (clean.length === 0 || clean.length % 4 === 1) throw new IrCodecError("tuya-malformed", "not a base64 string");
46174
+ const out = [];
46175
+ let bits = 0;
46176
+ let acc = 0;
46177
+ for (const ch of clean) {
46178
+ const value = ALPHABET.indexOf(ch);
46179
+ if (value < 0) throw new IrCodecError("tuya-malformed", "not a base64 string");
46180
+ acc = acc << 6 | value;
46181
+ bits += 6;
46182
+ if (bits >= 8) {
46183
+ bits -= 8;
46184
+ out.push(acc >> bits & 255);
46185
+ }
46186
+ }
46187
+ return Uint8Array.from(out);
46188
+ }
46189
+ /** Signed pulse train to a Tuya IR code: base64(FastLZ(uint16 LE durations)). */
46190
+ function encodeTuya(timings) {
46191
+ const bytes = new Uint8Array(timings.length * 2);
46192
+ timings.forEach((value, index) => {
46193
+ const duration = Math.abs(value);
46194
+ if (duration === 0 || duration > MAX_DURATION_US) throw new IrCodecError("invalid-timings", `timing ${index} does not fit 16 bits`);
46195
+ bytes[index * 2] = duration & 255;
46196
+ bytes[index * 2 + 1] = duration >> 8;
46197
+ });
46198
+ return toBase64(fastlzCompress(bytes));
46199
+ }
46200
+ /** A Tuya IR code to a signed pulse train (mark first). Throws `IrCodecError`. */
46201
+ function decodeTuya(code) {
46202
+ const bytes = fastlzDecompress(fromBase64(code));
46203
+ if (bytes.length === 0 || bytes.length % 2 !== 0) throw new IrCodecError("tuya-malformed", "payload is not a list of 16-bit durations");
46204
+ const timings = [];
46205
+ for (let i = 0; i < bytes.length; i += 2) {
46206
+ const duration = (bytes[i] ?? 0) | (bytes[i + 1] ?? 0) << 8;
46207
+ timings.push(i / 2 % 2 === 0 ? duration : -duration);
46208
+ }
46209
+ const checked = IrTimingsSchema.safeParse(timings);
46210
+ if (!checked.success) throw new IrCodecError("tuya-malformed", checked.error.message);
46211
+ return checked.data;
46212
+ }
46213
+ //#endregion
46214
+ //#region src/ir/native.ts
46215
+ /** Device-native IR code formats a transmitter can replay verbatim. */
46216
+ var IrNativeFormatSchema = zod.z.enum(["tuya"]);
46217
+ /**
46218
+ * Longest native code accepted: base64 of the worst-case compressed stream
46219
+ * (every decoded byte as a literal, plus one control byte per 32), with margin.
46220
+ */
46221
+ var IR_NATIVE_CODE_MAX_CHARS = Math.ceil((IR_DECOMPRESSED_MAX + Math.ceil(IR_DECOMPRESSED_MAX / 32)) / 3) * 4 + 256;
46222
+ var IrNativeCodeSchema = zod.z.object({
46223
+ format: IrNativeFormatSchema,
46224
+ code: zod.z.string().min(1).max(IR_NATIVE_CODE_MAX_CHARS)
46225
+ });
46226
+ var IR_NATIVE_CODECS = { tuya: {
46227
+ encode: encodeTuya,
46228
+ decode: decodeTuya
46229
+ } };
46230
+ //#endregion
46062
46231
  //#region src/ir/ir-payload.ts
46063
- /** What a remote command stores: a raw pulse train, or a learned Pronto code. */
46064
- var IrPayloadSchema = zod.z.discriminatedUnion("kind", [zod.z.object({
46065
- kind: zod.z.literal("raw"),
46066
- timings: zod.z.array(zod.z.number().int()),
46067
- settings: TransmitSettingsSchema.optional()
46068
- }), zod.z.object({
46069
- kind: zod.z.literal("pronto"),
46070
- code: zod.z.string()
46071
- })]);
46232
+ /** What a remote command stores: a raw pulse train, a learned Pronto code, or a device-native code. */
46233
+ var IrPayloadSchema = zod.z.discriminatedUnion("kind", [
46234
+ zod.z.object({
46235
+ kind: zod.z.literal("raw"),
46236
+ timings: zod.z.array(zod.z.number().int()),
46237
+ settings: TransmitSettingsSchema.optional()
46238
+ }),
46239
+ zod.z.object({
46240
+ kind: zod.z.literal("pronto"),
46241
+ code: zod.z.string()
46242
+ }),
46243
+ zod.z.object({
46244
+ kind: zod.z.literal("native"),
46245
+ format: IrNativeFormatSchema,
46246
+ code: zod.z.string()
46247
+ })
46248
+ ]);
46072
46249
  /** Resolve a payload to what `ir-transmitter.send` takes. Throws `IrCodecError`. */
46073
46250
  function toTimings(payload) {
46074
46251
  if (payload.kind === "pronto") {
@@ -46078,6 +46255,10 @@ function toTimings(payload) {
46078
46255
  settings: { carrierHz: decoded.carrierHz }
46079
46256
  };
46080
46257
  }
46258
+ if (payload.kind === "native") return {
46259
+ timings: IR_NATIVE_CODECS[payload.format].decode(payload.code),
46260
+ settings: {}
46261
+ };
46081
46262
  const checked = IrTimingsSchema.safeParse(payload.timings);
46082
46263
  if (!checked.success) throw new IrCodecError("invalid-timings", checked.error.message);
46083
46264
  return {
@@ -61558,7 +61739,19 @@ var IrSendResultSchema = zod.z.object({
61558
61739
  var IrTransmitterInfoSchema = zod.z.object({
61559
61740
  media: zod.z.array(IrMediumSchema),
61560
61741
  settable: zod.z.array(TransmitSettingKeySchema),
61561
- maxTimings: zod.z.number().int().positive()
61742
+ maxTimings: zod.z.number().int().positive(),
61743
+ /** The transmitter can learn a code (`learn`). */
61744
+ learn: zod.z.boolean().default(false),
61745
+ /** Native code formats the transmitter replays verbatim (`send.native`). */
61746
+ formats: zod.z.array(IrNativeFormatSchema).default([])
61747
+ });
61748
+ var IR_LEARN_TIMEOUT_DEFAULT_MS = 2e4;
61749
+ var IR_LEARN_TIMEOUT_MAX_MS = 6e4;
61750
+ var IrLearnResultSchema = zod.z.object({
61751
+ /** The code in the device's own format, when it reports one. */
61752
+ native: IrNativeCodeSchema.nullable(),
61753
+ timings: IrTimingsSchema,
61754
+ carrierHz: zod.z.number().int().positive().nullable()
61562
61755
  });
61563
61756
  /**
61564
61757
  * ir-transmitter — emit a pulse train (infrared or RF) with settings. One cap
@@ -61569,7 +61762,12 @@ var IrTransmitterInfoSchema = zod.z.object({
61569
61762
  * transmitter cannot be reached) and `ir-transmitter.too-long` (more pulses
61570
61763
  * than the transmitter's `maxTimings`). A setting the transmitter cannot apply
61571
61764
  * is NOT a refusal: the train is sent and the key comes back in
61572
- * `ignoredSettings`.
61765
+ * `ignoredSettings`. `send` takes exactly one of `timings` or `native` (a code
61766
+ * in a format listed in `getInfo.formats`).
61767
+ *
61768
+ * `learn` waits for the user to point a remote at the transmitter and refuses
61769
+ * with `ir-transmitter.learn-unsupported`, `ir-transmitter.learn-timeout` or
61770
+ * `ir-transmitter.learn-undecodable`.
61573
61771
  */
61574
61772
  var irTransmitterCapability = {
61575
61773
  name: "ir-transmitter",
@@ -61580,9 +61778,17 @@ var irTransmitterCapability = {
61580
61778
  methods: {
61581
61779
  send: require_sleep.method(zod.z.object({
61582
61780
  deviceId: zod.z.number().int().nonnegative(),
61583
- timings: IrTimingsSchema,
61781
+ timings: IrTimingsSchema.optional(),
61782
+ native: IrNativeCodeSchema.optional(),
61584
61783
  settings: TransmitSettingsSchema.optional()
61585
- }), IrSendResultSchema, {
61784
+ }).refine((input) => input.timings === void 0 !== (input.native === void 0), { message: "send takes exactly one of timings or native" }), IrSendResultSchema, {
61785
+ kind: "mutation",
61786
+ auth: "protected"
61787
+ }),
61788
+ learn: require_sleep.method(zod.z.object({
61789
+ deviceId: zod.z.number().int().nonnegative(),
61790
+ timeoutMs: zod.z.number().int().positive().max(IR_LEARN_TIMEOUT_MAX_MS).default(IR_LEARN_TIMEOUT_DEFAULT_MS)
61791
+ }), IrLearnResultSchema, {
61586
61792
  kind: "mutation",
61587
61793
  auth: "protected"
61588
61794
  }),
@@ -112900,6 +113106,13 @@ var METHOD_ACCESS_MAP = Object.freeze({
112900
113106
  access: "view",
112901
113107
  role: "viewer"
112902
113108
  },
113109
+ "irTransmitter.learn": {
113110
+ capName: "ir-transmitter",
113111
+ capScope: "device",
113112
+ addonId: null,
113113
+ access: "create",
113114
+ role: "viewer"
113115
+ },
112903
113116
  "irTransmitter.send": {
112904
113117
  capName: "ir-transmitter",
112905
113118
  capScope: "device",
@@ -123187,6 +123400,11 @@ var METHOD_DEVICE_SELECTORS = Object.freeze({
123187
123400
  form: "single",
123188
123401
  optional: false
123189
123402
  }],
123403
+ "irTransmitter.learn": [{
123404
+ name: "deviceId",
123405
+ form: "single",
123406
+ optional: false
123407
+ }],
123190
123408
  "irTransmitter.send": [{
123191
123409
  name: "deviceId",
123192
123410
  form: "single",
@@ -139943,6 +140161,10 @@ exports.INITIAL_SPAN = INITIAL_SPAN;
139943
140161
  exports.INTEGRAL_OUTPUTS = require_implemented_methods.INTEGRAL_OUTPUTS;
139944
140162
  exports.INTERNAL_ACTION_PREFIX = INTERNAL_ACTION_PREFIX;
139945
140163
  exports.INVERTIBLE_CAPS = INVERTIBLE_CAPS;
140164
+ exports.IR_LEARN_TIMEOUT_DEFAULT_MS = IR_LEARN_TIMEOUT_DEFAULT_MS;
140165
+ exports.IR_LEARN_TIMEOUT_MAX_MS = IR_LEARN_TIMEOUT_MAX_MS;
140166
+ exports.IR_NATIVE_CODECS = IR_NATIVE_CODECS;
140167
+ exports.IR_NATIVE_CODE_MAX_CHARS = IR_NATIVE_CODE_MAX_CHARS;
139946
140168
  exports.IR_TIMINGS_MAX = IR_TIMINGS_MAX;
139947
140169
  exports.IconKeySchema = IconKeySchema;
139948
140170
  exports.ImageContractSchema = ImageContractSchema;
@@ -139978,7 +140200,10 @@ exports.IntercomAbilitySchema = IntercomAbilitySchema;
139978
140200
  exports.IntercomStatusSchema = IntercomStatusSchema;
139979
140201
  exports.InvalidRecordError = require_sleep.InvalidRecordError;
139980
140202
  exports.IrCodecError = IrCodecError;
140203
+ exports.IrLearnResultSchema = IrLearnResultSchema;
139981
140204
  exports.IrMediumSchema = IrMediumSchema;
140205
+ exports.IrNativeCodeSchema = IrNativeCodeSchema;
140206
+ exports.IrNativeFormatSchema = IrNativeFormatSchema;
139982
140207
  exports.IrPayloadSchema = IrPayloadSchema;
139983
140208
  exports.IrSendResultSchema = IrSendResultSchema;
139984
140209
  exports.IrTimingsSchema = IrTimingsSchema;
@@ -141783,6 +142008,7 @@ exports.decodeKeyedArrayOverride = decodeKeyedArrayOverride;
141783
142008
  exports.decodePronto = decodePronto;
141784
142009
  exports.decodePulseOverride = decodePulseOverride;
141785
142010
  exports.decodeScalarOverride = decodeScalarOverride;
142011
+ exports.decodeTuya = decodeTuya;
141786
142012
  exports.decodeVectorBase64 = decodeVectorBase64;
141787
142013
  exports.decoderCapability = decoderCapability;
141788
142014
  exports.defaultDeliveryForSection = defaultDeliveryForSection;
@@ -141888,6 +142114,7 @@ exports.encodeCardsToComposition = encodeCardsToComposition;
141888
142114
  exports.encodeFlipperParsed = encodeFlipperParsed;
141889
142115
  exports.encodeProfileFromStreamShape = encodeProfileFromStreamShape;
141890
142116
  exports.encodeSamsung = encodeSamsung;
142117
+ exports.encodeTuya = encodeTuya;
141891
142118
  exports.encodeVectorBase64 = encodeVectorBase64;
141892
142119
  exports.ensureAlarmProfiles = ensureAlarmProfiles;
141893
142120
  exports.entryBody = require_sleep.entryBody;