@camstack/addon-terminal 0.1.31 → 0.1.32

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.
Files changed (3) hide show
  1. package/dist/addon.js +473 -363
  2. package/dist/addon.mjs +473 -363
  3. package/package.json +1 -1
package/dist/addon.mjs CHANGED
@@ -8096,6 +8096,15 @@ var LabelDefinitionSchema = object({
8096
8096
  description: string().optional(),
8097
8097
  icon: string().optional()
8098
8098
  });
8099
+ var ClassMapDefinitionSchema = object({
8100
+ mapping: record(string(), _enum([
8101
+ "person",
8102
+ "vehicle",
8103
+ "animal",
8104
+ "package"
8105
+ ])),
8106
+ preserveOriginal: boolean()
8107
+ });
8099
8108
  var MODEL_FORMATS = [
8100
8109
  "onnx",
8101
8110
  "coreml",
@@ -8274,7 +8283,13 @@ var ModelCatalogEntrySchema = object({
8274
8283
  * `id` stays the source of truth for resolution/download/persistence; grouping
8275
8284
  * is a presentation overlay resolved back to an `id`.
8276
8285
  */
8277
- group: ModelVariantGroupSchema.optional()
8286
+ group: ModelVariantGroupSchema.optional(),
8287
+ /**
8288
+ * Per-MODEL class map override. Absent ⇒ the step's `StepDefinition.classMap`
8289
+ * applies (Frigate / COCO public catalog). Set on a custom model whose raw
8290
+ * labels already ARE the CamStack macros (Scrypted identity map).
8291
+ */
8292
+ classMap: ClassMapDefinitionSchema.optional()
8278
8293
  });
8279
8294
  var ConvertTargetSchema = discriminatedUnion("format", [object({
8280
8295
  format: literal("openvino"),
@@ -8303,7 +8318,8 @@ var ModelConvertMetadataSchema = object({
8303
8318
  "ocr",
8304
8319
  "segmentation"
8305
8320
  ]),
8306
- faceAlignment: boolean().optional()
8321
+ faceAlignment: boolean().optional(),
8322
+ classMap: ClassMapDefinitionSchema.optional()
8307
8323
  });
8308
8324
  var ConvertResultSchema = object({
8309
8325
  entry: ModelCatalogEntrySchema,
@@ -17541,6 +17557,33 @@ var NativeCropRefSchema = object({
17541
17557
  h: number()
17542
17558
  })
17543
17559
  });
17560
+ object({
17561
+ crop: object({
17562
+ left: number(),
17563
+ top: number(),
17564
+ width: number().positive(),
17565
+ height: number().positive()
17566
+ }).optional(),
17567
+ content: object({
17568
+ width: number().int().positive(),
17569
+ height: number().int().positive()
17570
+ }),
17571
+ fit: _enum(["stretch", "contain"]),
17572
+ format: _enum([
17573
+ "rgb",
17574
+ "gray",
17575
+ "jpeg"
17576
+ ])
17577
+ });
17578
+ var FrameRefSchema = object({
17579
+ registryId: string().min(1),
17580
+ id: string().min(1),
17581
+ width: number().int().positive(),
17582
+ height: number().int().positive(),
17583
+ format: _enum(["rgb", "gray"]),
17584
+ timestamp: number(),
17585
+ capturedAt: number().optional()
17586
+ });
17544
17587
  var ModelFormatSchema$1 = _enum([
17545
17588
  "onnx",
17546
17589
  "coreml",
@@ -17785,6 +17828,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
17785
17828
  steps: array(PipelineStepInputSchema).min(1),
17786
17829
  frame: FrameInputSchema.optional(),
17787
17830
  /**
17831
+ * Process-local lazy frame. Valid only when caller and provider resolve
17832
+ * in the same execution-group process; split/cross-node callers use
17833
+ * `frame`/`image` inline compatibility instead.
17834
+ */
17835
+ frameRef: FrameRefSchema.optional(),
17836
+ /**
17788
17837
  * CB5 shm passthrough — a `FrameHandle` naming the same ring slot
17789
17838
  * the decoded pixels live in. One more member of the one-of
17790
17839
  * frame/frameHandle/image/imageBase64/referenceImage group.
@@ -18080,7 +18129,10 @@ var NativeCropResultSchema = object({
18080
18129
  * Which source served this crop, so a quality-sensitive consumer (the native
18081
18130
  * `keyFrame`) can reject a degraded fallback:
18082
18131
  * - `native` — cut from the decode worker's retained NATIVE surface (the
18083
- * quality path).
18132
+ * quality path). A subject-tile serve is also native-resolution and stays
18133
+ * `native` here: the public enum cannot name `tile` without a breaking cap
18134
+ * change. Runner telemetry distinguishes lease vs tile via `source` on the
18135
+ * internal crop result (`nativeHits` vs `tileHits`).
18084
18136
  * - `ram-fullframe` — the native surface MISSED but the request was full-frame,
18085
18137
  * so the ≤640 RAM `RetainedFrameStore` served it (honest lower-res; legit for
18086
18138
  * the blank-frame guard / 640-snapshot resolve, NOT for the clean keyFrame).
@@ -18571,12 +18623,41 @@ var RunnerLocalLoadSchema = object({
18571
18623
  * legacy `OrchestratorMetricsSchema` shape so existing dashboards keep
18572
18624
  * working unchanged when they switch to reading from the runner cap.
18573
18625
  */
18626
+ var FrameLazyCountersSchema = object({
18627
+ framesDecoded: number(),
18628
+ framesAdmitted: number(),
18629
+ framesDroppedPixelFree: number(),
18630
+ viewsMaterialized: number(),
18631
+ viewsSkipped: number(),
18632
+ workerToRunnerBytes: number(),
18633
+ runnerToPoolRawBytes: number(),
18634
+ runnerToPoolJpegBytes: number(),
18635
+ onDemandFullFrameRequests: number(),
18636
+ onDemandCropRequests: number(),
18637
+ nativeHits: number(),
18638
+ nativeMisses: number(),
18639
+ tileHits: number(),
18640
+ tileMisses: number(),
18641
+ fallbackHits: number(),
18642
+ fallbackMisses: number(),
18643
+ retainedWritesAvoided: number(),
18644
+ residentRefs: number(),
18645
+ residentBytes: number(),
18646
+ releases: number(),
18647
+ evictions: number(),
18648
+ staleMisses: number()
18649
+ });
18650
+ var FrameLazyMetricsSchema = object({
18651
+ node: FrameLazyCountersSchema,
18652
+ cameras: array(FrameLazyCountersSchema.extend({ deviceId: number() }))
18653
+ });
18574
18654
  var RunnerLocalMetricsSchema = object({
18575
18655
  nodeId: string(),
18576
18656
  activeCameras: number(),
18577
18657
  throttledCameras: number(),
18578
18658
  avgInferenceTimeMs: number(),
18579
- queueDepth: number()
18659
+ queueDepth: number(),
18660
+ frameLazy: FrameLazyMetricsSchema.optional()
18580
18661
  });
18581
18662
  method(RunnerCameraConfigSchema, object({ success: literal(true) }), { kind: "mutation" }), method(object({ deviceId: number() }), object({ success: literal(true) }), { kind: "mutation" }), method(ReportMotionInputSchema, object({ success: literal(true) }), { kind: "mutation" }), method(_void(), RunnerLocalLoadSchema), method(_void(), RunnerLocalMetricsSchema), method(object({ deviceId: number() }), CameraMetricsSchema.nullable()), method(_void(), array(CameraMetricsWithDeviceIdSchema).readonly()), method(_void(), array(number()).readonly()), method(object({
18582
18663
  handle: FrameHandleSchema,
@@ -24186,6 +24267,17 @@ var NotificationEndpointSchema = object({
24186
24267
  /** What the ranking currently resolves to (null when nothing is reachable). */
24187
24268
  resolved: string().nullable()
24188
24269
  });
24270
+ /**
24271
+ * The URLs the SDK / viewer should race for API access. `baseUrls` empty =
24272
+ * AUTO (every LAN IPv4 + the public tunnel). `resolved` is what that choice
24273
+ * currently expands to, so the UI can show the effective set either way.
24274
+ */
24275
+ var ViewerEndpointsSchema = object({
24276
+ /** The operator's explicit race set, or empty for AUTO. */
24277
+ baseUrls: array(string()).readonly(),
24278
+ /** What the ranking currently resolves to (may be empty if nothing is up). */
24279
+ resolved: array(string()).readonly()
24280
+ });
24189
24281
  var AllowedAddressesSchema = object({
24190
24282
  /**
24191
24283
  * Allowlist of interface addresses operators have explicitly opted
@@ -24217,17 +24309,18 @@ method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(obje
24217
24309
  */
24218
24310
  port: number().int().min(1).max(65535).optional(),
24219
24311
  /** Include `http(s)://127.0.0.1:<port>` as the lowest-priority
24220
- * candidate. Default `true`. */
24312
+ * candidate. Default `false` — loopback is not a client route. */
24221
24313
  includeLoopback: boolean().optional(),
24222
- /** Skip IPv6 entries. Some legacy clients can't parse them.
24223
- * Default `false`. */
24314
+ /** Skip IPv6 entries. Default `false` the palette includes stable
24315
+ * LAN IPv6 (ICE/WebRTC uses dual-stack regardless). Pass `true` to
24316
+ * hide them. The viewer HTTP/WS race is `getViewerEndpoints`. */
24224
24317
  ipv4Only: boolean().optional(),
24225
24318
  /** Scheme to emit for LAN/loopback URLs. Default `'http'`.
24226
24319
  * Pass `'https'` when the caller is itself loaded over HTTPS
24227
24320
  * to avoid mixed-content blocks in the browser. The public
24228
24321
  * tunnel always emits `https://` regardless. */
24229
24322
  scheme: _enum(["http", "https"]).optional()
24230
- }), GetConnectionEndpointsResultSchema), method(_void(), NotificationEndpointSchema), method(object({ baseUrl: string().nullable() }), NotificationEndpointSchema, { kind: "mutation" }), method(_void(), AllowedAddressesSchema), method(AllowedAddressesSchema, object({ success: literal(true) }), { kind: "mutation" }), method(_void(), AllowedAddressesSchema, { kind: "mutation" }), method(_void(), TlsStatusSchema), method(object({ reason: string().optional() }), TlsStatusSchema, {
24323
+ }), GetConnectionEndpointsResultSchema), method(_void(), NotificationEndpointSchema), method(object({ baseUrl: string().nullable() }), NotificationEndpointSchema, { kind: "mutation" }), method(_void(), ViewerEndpointsSchema), method(object({ baseUrls: array(string()).readonly() }), ViewerEndpointsSchema, { kind: "mutation" }), method(_void(), AllowedAddressesSchema), method(AllowedAddressesSchema, object({ success: literal(true) }), { kind: "mutation" }), method(_void(), AllowedAddressesSchema, { kind: "mutation" }), method(_void(), TlsStatusSchema), method(object({ reason: string().optional() }), TlsStatusSchema, {
24231
24324
  kind: "mutation",
24232
24325
  auth: "admin"
24233
24326
  }), method(object({
@@ -32301,6 +32394,12 @@ Object.freeze({
32301
32394
  addonId: null,
32302
32395
  access: "view"
32303
32396
  },
32397
+ "localNetwork.getViewerEndpoints": {
32398
+ capName: "local-network",
32399
+ capScope: "system",
32400
+ addonId: null,
32401
+ access: "view"
32402
+ },
32304
32403
  "localNetwork.list": {
32305
32404
  capName: "local-network",
32306
32405
  capScope: "system",
@@ -32337,6 +32436,12 @@ Object.freeze({
32337
32436
  addonId: null,
32338
32437
  access: "create"
32339
32438
  },
32439
+ "localNetwork.setViewerEndpoints": {
32440
+ capName: "local-network",
32441
+ capScope: "system",
32442
+ addonId: null,
32443
+ access: "create"
32444
+ },
32340
32445
  "localNetwork.uploadCertificate": {
32341
32446
  capName: "local-network",
32342
32447
  capScope: "system",
@@ -38116,356 +38221,6 @@ async function silenceAnalysisFor(deps, deviceId) {
38116
38221
  if (failures.length > 0) throw new Error(`terminal camera ${deviceId}: could not switch off ${failures.length} analyzer(s) — it will run at full detection cost (${failures.join("; ")})`);
38117
38222
  }
38118
38223
  //#endregion
38119
- //#region src/terminal-camera-declarations.ts
38120
- /**
38121
- * Feed DeclaredDevices every live declaration plus one deterministic orphan
38122
- * batch. The generic sweep intentionally refuses an over-limit set; selecting
38123
- * a batch here drains large historical Terminal orphan sets across convergence
38124
- * passes without weakening that global safety guard.
38125
- */
38126
- function terminalCameraReconciliationIndex(rows, integrationId, declarations, managedStableIds = /* @__PURE__ */ new Set()) {
38127
- if (!integrationId) return [];
38128
- const declared = new Set(declarations.map((camera) => camera.stableId));
38129
- const owned = rows.filter((row) => row.integrationId === integrationId && (declared.has(row.stableId) || managedStableIds.has(row.stableId) || row.stableId.startsWith("terminal-camera-instance-")));
38130
- return [...owned.filter((row) => declared.has(row.stableId)), ...owned.filter((row) => !declared.has(row.stableId)).sort((left, right) => left.id - right.id).slice(0, 32)];
38131
- }
38132
- /** Explicit persisted instances, never the node × profile template matrix. */
38133
- function buildTerminalInstanceCameraDeclarations(instances) {
38134
- return instances.filter((instance) => instance.enabled).map((instance) => ({
38135
- stableId: instance.cameraStableId,
38136
- name: instance.name,
38137
- config: {
38138
- instanceId: instance.id,
38139
- nodeId: instance.nodeId,
38140
- profileId: instance.profileId,
38141
- profileLabel: instance.profileLabel
38142
- }
38143
- }));
38144
- }
38145
- /**
38146
- * `DeviceConfig` materializes schema defaults in memory, so comparing
38147
- * `config.get()` cannot detect a legacy `{ nodeId }` row. Reconciliation must
38148
- * inspect the raw persisted blob to make the profile migration durable.
38149
- */
38150
- function needsTerminalCameraConfigMigration(persistedConfig, declaration) {
38151
- return persistedConfig.instanceId !== declaration.config.instanceId || persistedConfig.nodeId !== declaration.config.nodeId || persistedConfig.profileId !== declaration.config.profileId || persistedConfig.profileLabel !== declaration.config.profileLabel;
38152
- }
38153
- //#endregion
38154
- //#region src/terminal-cell-runs.ts
38155
- var TERMINAL_DEFAULT_FG = "#d7dce2";
38156
- var TERMINAL_DEFAULT_BG = "#0b0d10";
38157
- /**
38158
- * The 16 ANSI colours, in a dark-theme variant chosen to sit with the existing
38159
- * frame (`#0b0d10` ground, `#d7dce2` text) rather than the raw xterm defaults,
38160
- * whose pure `#0000ff` blue and `#008000` green are close to unreadable on a
38161
- * near-black background at 13px. Index 7 IS the default foreground, so plain
38162
- * `CSI 37m` text renders identically to unstyled text.
38163
- */
38164
- var TERMINAL_ANSI_PALETTE = [
38165
- "#282c34",
38166
- "#e06c75",
38167
- "#98c379",
38168
- "#e5c07b",
38169
- "#61afef",
38170
- "#c678dd",
38171
- "#56b6c2",
38172
- TERMINAL_DEFAULT_FG,
38173
- "#5c6370",
38174
- "#ef596f",
38175
- "#89ca78",
38176
- "#f0c674",
38177
- "#6cb6ff",
38178
- "#d55fde",
38179
- "#2bbac5",
38180
- "#ffffff"
38181
- ];
38182
- /** The six levels of the xterm 6×6×6 colour cube (indices 16-231). */
38183
- var TERMINAL_CUBE_LEVELS = [
38184
- 0,
38185
- 95,
38186
- 135,
38187
- 175,
38188
- 215,
38189
- 255
38190
- ];
38191
- var TERMINAL_CUBE_FIRST = 16;
38192
- var TERMINAL_GRAYSCALE_FIRST = 232;
38193
- var TERMINAL_GRAYSCALE_BASE = 8;
38194
- var TERMINAL_GRAYSCALE_STEP = 10;
38195
- /** SGR 2 keeps the foreground legible; it must not become the background. */
38196
- var TERMINAL_DIM_WEIGHT = .6;
38197
- function channel(value) {
38198
- return Math.max(0, Math.min(255, Math.round(value))).toString(16).padStart(2, "0");
38199
- }
38200
- function hex(red, green, blue) {
38201
- return `#${channel(red)}${channel(green)}${channel(blue)}`;
38202
- }
38203
- function parseHex(color) {
38204
- return [
38205
- Number.parseInt(color.slice(1, 3), 16),
38206
- Number.parseInt(color.slice(3, 5), 16),
38207
- Number.parseInt(color.slice(5, 7), 16)
38208
- ];
38209
- }
38210
- /** Resolve an xterm palette index (0-255) to a hex colour. */
38211
- function terminalPaletteColor(index) {
38212
- const ansi = TERMINAL_ANSI_PALETTE[index];
38213
- if (ansi !== void 0) return ansi;
38214
- if (index >= TERMINAL_GRAYSCALE_FIRST) {
38215
- const level = TERMINAL_GRAYSCALE_BASE + (index - TERMINAL_GRAYSCALE_FIRST) * TERMINAL_GRAYSCALE_STEP;
38216
- return hex(level, level, level);
38217
- }
38218
- if (index >= TERMINAL_CUBE_FIRST) {
38219
- const offset = index - TERMINAL_CUBE_FIRST;
38220
- return hex(TERMINAL_CUBE_LEVELS[Math.floor(offset / 36) % 6] ?? 0, TERMINAL_CUBE_LEVELS[Math.floor(offset / 6) % 6] ?? 0, TERMINAL_CUBE_LEVELS[offset % 6] ?? 0);
38221
- }
38222
- return TERMINAL_DEFAULT_FG;
38223
- }
38224
- /** Resolve a 0xRRGGBB truecolor value to a hex colour. */
38225
- function terminalRgbColor(value) {
38226
- return hex(value >> 16 & 255, value >> 8 & 255, value & 255);
38227
- }
38228
- function blend(color, toward, weight) {
38229
- const [red, green, blue] = parseHex(color);
38230
- const [targetRed, targetGreen, targetBlue] = parseHex(toward);
38231
- return hex(red * weight + targetRed * (1 - weight), green * weight + targetGreen * (1 - weight), blue * weight + targetBlue * (1 - weight));
38232
- }
38233
- function resolveForeground(cell) {
38234
- if (cell.isFgRGB()) return terminalRgbColor(cell.getFgColor());
38235
- if (cell.isFgPalette()) return terminalPaletteColor(cell.getFgColor());
38236
- return TERMINAL_DEFAULT_FG;
38237
- }
38238
- function resolveBackground(cell) {
38239
- if (cell.isBgRGB()) return terminalRgbColor(cell.getBgColor());
38240
- if (cell.isBgPalette()) return terminalPaletteColor(cell.getBgColor());
38241
- return TERMINAL_DEFAULT_BG;
38242
- }
38243
- /**
38244
- * Resolve one cell's attributes into concrete colours.
38245
- *
38246
- * Inverse is applied by SWAPPING the already-resolved pair, so inverse over two
38247
- * defaults is still a visible swap rather than a no-op — that is how a selected
38248
- * or highlighted row in Glances reads. Invisible is then conceal-by-equality
38249
- * (foreground painted in its own background): the cell keeps its columns, which
38250
- * a dropped cell would not, and dropping it would shift the whole rest of the
38251
- * row left.
38252
- */
38253
- function resolveCellStyle(cell) {
38254
- const inverse = cell.isInverse() !== 0;
38255
- const plainFg = resolveForeground(cell);
38256
- const plainBg = resolveBackground(cell);
38257
- const background = inverse ? plainFg : plainBg;
38258
- let foreground = inverse ? plainBg : plainFg;
38259
- if (cell.isDim() !== 0) foreground = blend(foreground, background, TERMINAL_DIM_WEIGHT);
38260
- if (cell.isInvisible() !== 0) foreground = background;
38261
- return {
38262
- fg: foreground === "#d7dce2" ? null : foreground,
38263
- bg: background === "#0b0d10" ? null : background,
38264
- bold: cell.isBold() !== 0
38265
- };
38266
- }
38267
- function sameStyle(left, right) {
38268
- return left.fg === right.fg && left.bg === right.bg && left.bold === right.bold;
38269
- }
38270
- /**
38271
- * Merge adjacent same-style cells into runs, then drop the trailing run of
38272
- * default-styled whitespace so a row costs what it draws — the same trim
38273
- * `translateToString(true)` performs. Whitespace carrying a BACKGROUND is kept:
38274
- * a green bar of spaces out to the right margin is a pixel Glances drew.
38275
- */
38276
- function buildCellRuns(cells) {
38277
- const runs = [];
38278
- let text = "";
38279
- let style = null;
38280
- for (const cell of cells) {
38281
- if (style !== null && sameStyle(style, cell.style)) {
38282
- text += cell.text;
38283
- continue;
38284
- }
38285
- if (style !== null) runs.push({
38286
- text,
38287
- ...style
38288
- });
38289
- text = cell.text;
38290
- style = cell.style;
38291
- }
38292
- if (style !== null) runs.push({
38293
- text,
38294
- ...style
38295
- });
38296
- while (runs.length > 0) {
38297
- const last = runs[runs.length - 1];
38298
- if (last === void 0 || last.bg !== null) break;
38299
- const trimmed = last.text.replace(/\s+$/u, "");
38300
- if (trimmed === last.text) break;
38301
- if (trimmed === "") {
38302
- runs.pop();
38303
- continue;
38304
- }
38305
- runs[runs.length - 1] = {
38306
- ...last,
38307
- text: trimmed
38308
- };
38309
- break;
38310
- }
38311
- return runs;
38312
- }
38313
- /**
38314
- * Monospace families to try, in order — NOT one family and a generic.
38315
- *
38316
- * A terminal screen is mostly box-drawing and block characters, and a font
38317
- * without them renders the frame as noise rather than as missing detail.
38318
- * `DejaVu Sans Mono` covers them and ships in the hub image; macOS has neither
38319
- * DejaVu nor fontconfig, so the Mac agent fell through to a generic whose
38320
- * coverage is not, and its Glances camera came out unreadable while the hub's
38321
- * was pixel-perfect (measured 2026-08-11, same Glances, two nodes).
38322
- *
38323
- * `Menlo` is the fix rather than a guess: it is macOS's default terminal face,
38324
- * present on every install, and derived from DejaVu Sans Mono — the same glyph
38325
- * coverage by ancestry. Monaco and Courier New follow as older fallbacks; the
38326
- * generic stays last so a host with none of them still draws something.
38327
- */
38328
- var TERMINAL_FONT_STACK = "DejaVu Sans Mono,Menlo,Monaco,Courier New,monospace";
38329
- var TERMINAL_FONT_SIZE = 13;
38330
- var TERMINAL_TEXT_MARGIN_X = 8;
38331
- var TERMINAL_ROW_HEIGHT = 15;
38332
- var TERMINAL_BASELINE_Y = 18;
38333
- /**
38334
- * Distance from a row's baseline up to the top of its cell box. Chosen so
38335
- * consecutive rows tile exactly: row N's box runs from `baseline - this` for
38336
- * `TERMINAL_ROW_HEIGHT`, and row N+1's box starts where it ends. A background
38337
- * bar that stopped short would draw as stripes across a `CSI 42m` panel.
38338
- */
38339
- var TERMINAL_CELL_ASCENT = 11.5;
38340
- var TERMINAL_CELL_WIDTH = TERMINAL_FONT_SIZE * (1233 / 2048);
38341
- /** Two decimals is under a tenth of a pixel and keeps the SVG small. */
38342
- function coordinate(value) {
38343
- return String(Number(value.toFixed(2)));
38344
- }
38345
- function escapeXml(value) {
38346
- return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&apos;");
38347
- }
38348
- /**
38349
- * Render already-interpreted terminal rows into a compact MJPEG frame.
38350
- *
38351
- * `xml:space="preserve"` is load-bearing, not tidiness. SVG `<text>` collapses
38352
- * runs of whitespace by default, and a terminal's entire column alignment IS
38353
- * runs of whitespace — Glances pads every field with spaces. Without it the
38354
- * frame drew each line at roughly half its true width, crammed into the
38355
- * top-left of a mostly-black image, while the SAME session over `attach`
38356
- * looked perfect — which is exactly how the operator reported it. Measured in
38357
- * the hub's own rasterizer 2026-08-11: `AAA<10 spaces>BBB<3>CCC` drew 92 px
38358
- * collapsed against 178 px preserved.
38359
- *
38360
- * Every run is anchored at its OWN column (`x = margin + startCol * cellW`),
38361
- * never appended to the one before it, so the background rects and the glyphs
38362
- * are placed off the same grid and cannot drift apart. `textLength` is emitted
38363
- * with it because it is the correct declaration and renderers that honour it
38364
- * get an exact grid — but it is not what makes this work: librsvg, which sharp
38365
- * uses, ignores it outright (measured 2026-08-12, a 120-glyph run pinned to
38366
- * 600 px still drew its natural 937 px). The anchoring is the guarantee.
38367
- */
38368
- function renderTerminalSvg(rows) {
38369
- const backgrounds = [];
38370
- const texts = [];
38371
- rows.slice(0, 40).forEach((row, index) => {
38372
- const baseline = TERMINAL_BASELINE_Y + index * TERMINAL_ROW_HEIGHT;
38373
- const top = baseline - TERMINAL_CELL_ASCENT;
38374
- let column = 0;
38375
- for (const run of row) {
38376
- if (column >= 120) break;
38377
- const clipped = clipRun(run, 120 - column);
38378
- const columns = [...clipped].length;
38379
- if (columns === 0) continue;
38380
- const x = TERMINAL_TEXT_MARGIN_X + column * TERMINAL_CELL_WIDTH;
38381
- const width = columns * TERMINAL_CELL_WIDTH;
38382
- if (run.bg !== null) backgrounds.push(`<rect x="${coordinate(x)}" y="${coordinate(top)}" width="${coordinate(width)}" height="${String(TERMINAL_ROW_HEIGHT)}" fill="${run.bg}"/>`);
38383
- if (clipped.trim() !== "") {
38384
- const fill = run.fg === null ? "" : ` fill="${run.fg}"`;
38385
- const weight = run.bold ? " font-weight=\"bold\"" : "";
38386
- texts.push(`<text xml:space="preserve" x="${coordinate(x)}" y="${coordinate(baseline)}" textLength="${coordinate(width)}" lengthAdjust="spacingAndGlyphs"${fill}${weight}>${escapeXml(clipped)}</text>`);
38387
- }
38388
- column += columns;
38389
- }
38390
- });
38391
- return `<svg xmlns="http://www.w3.org/2000/svg" width="${String(960)}" height="${String(640)}"><rect width="100%" height="100%" fill="${TERMINAL_DEFAULT_BG}"/>${backgrounds.join("")}<g fill="${TERMINAL_DEFAULT_FG}" font-family="${TERMINAL_FONT_STACK}" font-size="${String(TERMINAL_FONT_SIZE)}">${texts.join("")}</g></svg>`;
38392
- }
38393
- /** Cut a run to the columns still left in the row, by code point not unit. */
38394
- function clipRun(run, remaining) {
38395
- const points = [...run.text];
38396
- return points.length <= remaining ? run.text : points.slice(0, remaining).join("");
38397
- }
38398
- async function renderTerminalJpeg(rows) {
38399
- return sharp(Buffer.from(renderTerminalSvg(rows))).jpeg({
38400
- quality: 82,
38401
- chromaSubsampling: "4:2:0"
38402
- }).toBuffer();
38403
- }
38404
- //#endregion
38405
- //#region src/terminal-camera-device.ts
38406
- var terminalCameraSchema = object({
38407
- instanceId: string().min(1).optional(),
38408
- nodeId: string().min(1),
38409
- profileId: string().min(1).default("monitor"),
38410
- profileLabel: string().min(1).default("BTM")
38411
- });
38412
- var relay = null;
38413
- function installTerminalCameraRelay(next) {
38414
- relay = next;
38415
- }
38416
- var TerminalCameraDevice = class extends BaseDevice {
38417
- features = [DeviceFeature.NativeSnapshot];
38418
- constructor(ctx) {
38419
- super(ctx, terminalCameraSchema, { type: ctx.deviceMeta.type });
38420
- this.ctx.registerNativeCap(streamCatalogCapability, { getCatalog: async ({ deviceId }) => {
38421
- if (deviceId !== this.id) return [];
38422
- return this.catalog();
38423
- } });
38424
- this.ctx.registerNativeCap(snapshotCapability, {
38425
- getSnapshot: async ({ deviceId }) => {
38426
- if (deviceId !== this.id) throw new Error(`TerminalCameraDevice: deviceId mismatch, expected ${String(this.id)}, got ${String(deviceId)}`);
38427
- const activeRelay = relay;
38428
- if (!activeRelay) throw new Error("terminal camera relay is unavailable");
38429
- return {
38430
- base64: (await activeRelay.snapshot(this.relayInstanceId(), this.config.get("nodeId"), this.config.get("profileId"))).toString("base64"),
38431
- contentType: "image/jpeg"
38432
- };
38433
- },
38434
- invalidateCache: async () => {}
38435
- });
38436
- this.markOnline(true);
38437
- }
38438
- async catalog() {
38439
- const activeRelay = relay;
38440
- if (!activeRelay) throw new Error("terminal camera relay is unavailable");
38441
- const nodeId = this.config.get("nodeId");
38442
- const profileId = this.config.get("profileId");
38443
- const instanceId = this.relayInstanceId();
38444
- return [{
38445
- camStreamId: profileId,
38446
- kind: "pull-http",
38447
- url: activeRelay.streamUrl(instanceId, nodeId, profileId),
38448
- codec: "h264",
38449
- resolution: {
38450
- width: 960,
38451
- height: 640
38452
- },
38453
- fps: 2,
38454
- label: this.config.get("profileLabel")
38455
- }];
38456
- }
38457
- setNodeOnline(online) {
38458
- this.markOnline(online);
38459
- if (!online) relay?.closeInstance(this.relayInstanceId());
38460
- }
38461
- async removeDevice() {
38462
- await relay?.closeInstance(this.relayInstanceId());
38463
- }
38464
- relayInstanceId() {
38465
- return this.config.get("instanceId") ?? `legacy:${this.stableId}`;
38466
- }
38467
- };
38468
- //#endregion
38469
38224
  //#region ../../node_modules/@xterm/addon-serialize/lib/addon-serialize.js
38470
38225
  var require_addon_serialize = /* @__PURE__ */ __commonJSMin(((exports, module) => {
38471
38226
  (function(e, t) {
@@ -43273,11 +43028,176 @@ var require_xterm_headless = /* @__PURE__ */ __commonJSMin(((exports) => {
43273
43028
  })();
43274
43029
  }));
43275
43030
  //#endregion
43276
- //#region src/xterm-screen.ts
43031
+ //#region src/terminal-cell-runs.ts
43277
43032
  var import_addon_serialize = require_addon_serialize();
43278
43033
  var import_xterm_headless = require_xterm_headless();
43034
+ var TERMINAL_DEFAULT_FG = "#d7dce2";
43035
+ var TERMINAL_DEFAULT_BG = "#0b0d10";
43036
+ /**
43037
+ * The 16 ANSI colours, in a dark-theme variant chosen to sit with the existing
43038
+ * frame (`#0b0d10` ground, `#d7dce2` text) rather than the raw xterm defaults,
43039
+ * whose pure `#0000ff` blue and `#008000` green are close to unreadable on a
43040
+ * near-black background at 13px. Index 7 IS the default foreground, so plain
43041
+ * `CSI 37m` text renders identically to unstyled text.
43042
+ */
43043
+ var TERMINAL_ANSI_PALETTE = [
43044
+ "#282c34",
43045
+ "#e06c75",
43046
+ "#98c379",
43047
+ "#e5c07b",
43048
+ "#61afef",
43049
+ "#c678dd",
43050
+ "#56b6c2",
43051
+ TERMINAL_DEFAULT_FG,
43052
+ "#5c6370",
43053
+ "#ef596f",
43054
+ "#89ca78",
43055
+ "#f0c674",
43056
+ "#6cb6ff",
43057
+ "#d55fde",
43058
+ "#2bbac5",
43059
+ "#ffffff"
43060
+ ];
43061
+ /** The six levels of the xterm 6×6×6 colour cube (indices 16-231). */
43062
+ var TERMINAL_CUBE_LEVELS = [
43063
+ 0,
43064
+ 95,
43065
+ 135,
43066
+ 175,
43067
+ 215,
43068
+ 255
43069
+ ];
43070
+ var TERMINAL_CUBE_FIRST = 16;
43071
+ var TERMINAL_GRAYSCALE_FIRST = 232;
43072
+ var TERMINAL_GRAYSCALE_BASE = 8;
43073
+ var TERMINAL_GRAYSCALE_STEP = 10;
43074
+ /** SGR 2 keeps the foreground legible; it must not become the background. */
43075
+ var TERMINAL_DIM_WEIGHT = .6;
43076
+ function channel(value) {
43077
+ return Math.max(0, Math.min(255, Math.round(value))).toString(16).padStart(2, "0");
43078
+ }
43079
+ function hex(red, green, blue) {
43080
+ return `#${channel(red)}${channel(green)}${channel(blue)}`;
43081
+ }
43082
+ function parseHex(color) {
43083
+ return [
43084
+ Number.parseInt(color.slice(1, 3), 16),
43085
+ Number.parseInt(color.slice(3, 5), 16),
43086
+ Number.parseInt(color.slice(5, 7), 16)
43087
+ ];
43088
+ }
43089
+ /** Resolve an xterm palette index (0-255) to a hex colour. */
43090
+ function terminalPaletteColor(index) {
43091
+ const ansi = TERMINAL_ANSI_PALETTE[index];
43092
+ if (ansi !== void 0) return ansi;
43093
+ if (index >= TERMINAL_GRAYSCALE_FIRST) {
43094
+ const level = TERMINAL_GRAYSCALE_BASE + (index - TERMINAL_GRAYSCALE_FIRST) * TERMINAL_GRAYSCALE_STEP;
43095
+ return hex(level, level, level);
43096
+ }
43097
+ if (index >= TERMINAL_CUBE_FIRST) {
43098
+ const offset = index - TERMINAL_CUBE_FIRST;
43099
+ return hex(TERMINAL_CUBE_LEVELS[Math.floor(offset / 36) % 6] ?? 0, TERMINAL_CUBE_LEVELS[Math.floor(offset / 6) % 6] ?? 0, TERMINAL_CUBE_LEVELS[offset % 6] ?? 0);
43100
+ }
43101
+ return TERMINAL_DEFAULT_FG;
43102
+ }
43103
+ /** Resolve a 0xRRGGBB truecolor value to a hex colour. */
43104
+ function terminalRgbColor(value) {
43105
+ return hex(value >> 16 & 255, value >> 8 & 255, value & 255);
43106
+ }
43107
+ function blend(color, toward, weight) {
43108
+ const [red, green, blue] = parseHex(color);
43109
+ const [targetRed, targetGreen, targetBlue] = parseHex(toward);
43110
+ return hex(red * weight + targetRed * (1 - weight), green * weight + targetGreen * (1 - weight), blue * weight + targetBlue * (1 - weight));
43111
+ }
43112
+ function resolveForeground(cell) {
43113
+ if (cell.isFgRGB()) return terminalRgbColor(cell.getFgColor());
43114
+ if (cell.isFgPalette()) return terminalPaletteColor(cell.getFgColor());
43115
+ return TERMINAL_DEFAULT_FG;
43116
+ }
43117
+ function resolveBackground(cell) {
43118
+ if (cell.isBgRGB()) return terminalRgbColor(cell.getBgColor());
43119
+ if (cell.isBgPalette()) return terminalPaletteColor(cell.getBgColor());
43120
+ return TERMINAL_DEFAULT_BG;
43121
+ }
43122
+ /**
43123
+ * Resolve one cell's attributes into concrete colours.
43124
+ *
43125
+ * Inverse is applied by SWAPPING the already-resolved pair, so inverse over two
43126
+ * defaults is still a visible swap rather than a no-op — that is how a selected
43127
+ * or highlighted row in Glances reads. Invisible is then conceal-by-equality
43128
+ * (foreground painted in its own background): the cell keeps its columns, which
43129
+ * a dropped cell would not, and dropping it would shift the whole rest of the
43130
+ * row left.
43131
+ */
43132
+ function resolveCellStyle(cell) {
43133
+ const inverse = cell.isInverse() !== 0;
43134
+ const plainFg = resolveForeground(cell);
43135
+ const plainBg = resolveBackground(cell);
43136
+ const background = inverse ? plainFg : plainBg;
43137
+ let foreground = inverse ? plainBg : plainFg;
43138
+ if (cell.isDim() !== 0) foreground = blend(foreground, background, TERMINAL_DIM_WEIGHT);
43139
+ if (cell.isInvisible() !== 0) foreground = background;
43140
+ return {
43141
+ fg: foreground === "#d7dce2" ? null : foreground,
43142
+ bg: background === "#0b0d10" ? null : background,
43143
+ bold: cell.isBold() !== 0
43144
+ };
43145
+ }
43146
+ function sameStyle(left, right) {
43147
+ return left.fg === right.fg && left.bg === right.bg && left.bold === right.bold;
43148
+ }
43149
+ /**
43150
+ * Merge adjacent same-style cells into runs, then drop the trailing run of
43151
+ * default-styled whitespace so a row costs what it draws — the same trim
43152
+ * `translateToString(true)` performs. Whitespace carrying a BACKGROUND is kept:
43153
+ * a green bar of spaces out to the right margin is a pixel Glances drew.
43154
+ */
43155
+ function buildCellRuns(cells) {
43156
+ const runs = [];
43157
+ let text = "";
43158
+ let style = null;
43159
+ for (const cell of cells) {
43160
+ if (style !== null && sameStyle(style, cell.style)) {
43161
+ text += cell.text;
43162
+ continue;
43163
+ }
43164
+ if (style !== null) runs.push({
43165
+ text,
43166
+ ...style
43167
+ });
43168
+ text = cell.text;
43169
+ style = cell.style;
43170
+ }
43171
+ if (style !== null) runs.push({
43172
+ text,
43173
+ ...style
43174
+ });
43175
+ while (runs.length > 0) {
43176
+ const last = runs[runs.length - 1];
43177
+ if (last === void 0 || last.bg !== null) break;
43178
+ const trimmed = last.text.replace(/\s+$/u, "");
43179
+ if (trimmed === last.text) break;
43180
+ if (trimmed === "") {
43181
+ runs.pop();
43182
+ continue;
43183
+ }
43184
+ runs[runs.length - 1] = {
43185
+ ...last,
43186
+ text: trimmed
43187
+ };
43188
+ break;
43189
+ }
43190
+ return runs;
43191
+ }
43192
+ //#endregion
43193
+ //#region src/xterm-screen.ts
43194
+ /**
43195
+ * Real {@link ScreenBuffer} backed by `@xterm/headless` — the DOM-less xterm
43196
+ * build — plus the serialize addon, which turns the current buffer into a
43197
+ * self-contained repaint escape sequence for reconnecting clients.
43198
+ */
43279
43199
  var SCROLLBACK_LINES = 2e3;
43280
- function createXtermScreen$1(cols, rows) {
43200
+ function createXtermScreen(cols, rows) {
43281
43201
  const term = new import_xterm_headless.Terminal({
43282
43202
  cols,
43283
43203
  rows,
@@ -43342,6 +43262,196 @@ function createXtermScreen$1(cols, rows) {
43342
43262
  };
43343
43263
  }
43344
43264
  //#endregion
43265
+ //#region src/terminal-camera-declarations.ts
43266
+ /**
43267
+ * Feed DeclaredDevices every live declaration plus one deterministic orphan
43268
+ * batch. The generic sweep intentionally refuses an over-limit set; selecting
43269
+ * a batch here drains large historical Terminal orphan sets across convergence
43270
+ * passes without weakening that global safety guard.
43271
+ */
43272
+ function terminalCameraReconciliationIndex(rows, integrationId, declarations, managedStableIds = /* @__PURE__ */ new Set()) {
43273
+ if (!integrationId) return [];
43274
+ const declared = new Set(declarations.map((camera) => camera.stableId));
43275
+ const owned = rows.filter((row) => row.integrationId === integrationId && (declared.has(row.stableId) || managedStableIds.has(row.stableId) || row.stableId.startsWith("terminal-camera-instance-")));
43276
+ return [...owned.filter((row) => declared.has(row.stableId)), ...owned.filter((row) => !declared.has(row.stableId)).sort((left, right) => left.id - right.id).slice(0, 32)];
43277
+ }
43278
+ /** Explicit persisted instances, never the node × profile template matrix. */
43279
+ function buildTerminalInstanceCameraDeclarations(instances) {
43280
+ return instances.filter((instance) => instance.enabled).map((instance) => ({
43281
+ stableId: instance.cameraStableId,
43282
+ name: instance.name,
43283
+ config: {
43284
+ instanceId: instance.id,
43285
+ nodeId: instance.nodeId,
43286
+ profileId: instance.profileId,
43287
+ profileLabel: instance.profileLabel
43288
+ }
43289
+ }));
43290
+ }
43291
+ /**
43292
+ * `DeviceConfig` materializes schema defaults in memory, so comparing
43293
+ * `config.get()` cannot detect a legacy `{ nodeId }` row. Reconciliation must
43294
+ * inspect the raw persisted blob to make the profile migration durable.
43295
+ */
43296
+ function needsTerminalCameraConfigMigration(persistedConfig, declaration) {
43297
+ return persistedConfig.instanceId !== declaration.config.instanceId || persistedConfig.nodeId !== declaration.config.nodeId || persistedConfig.profileId !== declaration.config.profileId || persistedConfig.profileLabel !== declaration.config.profileLabel;
43298
+ }
43299
+ /**
43300
+ * Monospace families to try, in order — NOT one family and a generic.
43301
+ *
43302
+ * A terminal screen is mostly box-drawing and block characters, and a font
43303
+ * without them renders the frame as noise rather than as missing detail.
43304
+ * `DejaVu Sans Mono` covers them and ships in the hub image; macOS has neither
43305
+ * DejaVu nor fontconfig, so the Mac agent fell through to a generic whose
43306
+ * coverage is not, and its Glances camera came out unreadable while the hub's
43307
+ * was pixel-perfect (measured 2026-08-11, same Glances, two nodes).
43308
+ *
43309
+ * `Menlo` is the fix rather than a guess: it is macOS's default terminal face,
43310
+ * present on every install, and derived from DejaVu Sans Mono — the same glyph
43311
+ * coverage by ancestry. Monaco and Courier New follow as older fallbacks; the
43312
+ * generic stays last so a host with none of them still draws something.
43313
+ */
43314
+ var TERMINAL_FONT_STACK = "DejaVu Sans Mono,Menlo,Monaco,Courier New,monospace";
43315
+ var TERMINAL_FONT_SIZE = 13;
43316
+ var TERMINAL_TEXT_MARGIN_X = 8;
43317
+ var TERMINAL_ROW_HEIGHT = 15;
43318
+ var TERMINAL_BASELINE_Y = 18;
43319
+ /**
43320
+ * Distance from a row's baseline up to the top of its cell box. Chosen so
43321
+ * consecutive rows tile exactly: row N's box runs from `baseline - this` for
43322
+ * `TERMINAL_ROW_HEIGHT`, and row N+1's box starts where it ends. A background
43323
+ * bar that stopped short would draw as stripes across a `CSI 42m` panel.
43324
+ */
43325
+ var TERMINAL_CELL_ASCENT = 11.5;
43326
+ var TERMINAL_CELL_WIDTH = TERMINAL_FONT_SIZE * (1233 / 2048);
43327
+ /** Two decimals is under a tenth of a pixel and keeps the SVG small. */
43328
+ function coordinate(value) {
43329
+ return String(Number(value.toFixed(2)));
43330
+ }
43331
+ function escapeXml(value) {
43332
+ return value.replaceAll("&", "&amp;").replaceAll("<", "&lt;").replaceAll(">", "&gt;").replaceAll("\"", "&quot;").replaceAll("'", "&apos;");
43333
+ }
43334
+ /**
43335
+ * Render already-interpreted terminal rows into a compact MJPEG frame.
43336
+ *
43337
+ * `xml:space="preserve"` is load-bearing, not tidiness. SVG `<text>` collapses
43338
+ * runs of whitespace by default, and a terminal's entire column alignment IS
43339
+ * runs of whitespace — Glances pads every field with spaces. Without it the
43340
+ * frame drew each line at roughly half its true width, crammed into the
43341
+ * top-left of a mostly-black image, while the SAME session over `attach`
43342
+ * looked perfect — which is exactly how the operator reported it. Measured in
43343
+ * the hub's own rasterizer 2026-08-11: `AAA<10 spaces>BBB<3>CCC` drew 92 px
43344
+ * collapsed against 178 px preserved.
43345
+ *
43346
+ * Every run is anchored at its OWN column (`x = margin + startCol * cellW`),
43347
+ * never appended to the one before it, so the background rects and the glyphs
43348
+ * are placed off the same grid and cannot drift apart. `textLength` is emitted
43349
+ * with it because it is the correct declaration and renderers that honour it
43350
+ * get an exact grid — but it is not what makes this work: librsvg, which sharp
43351
+ * uses, ignores it outright (measured 2026-08-12, a 120-glyph run pinned to
43352
+ * 600 px still drew its natural 937 px). The anchoring is the guarantee.
43353
+ */
43354
+ function renderTerminalSvg(rows) {
43355
+ const backgrounds = [];
43356
+ const texts = [];
43357
+ rows.slice(0, 40).forEach((row, index) => {
43358
+ const baseline = TERMINAL_BASELINE_Y + index * TERMINAL_ROW_HEIGHT;
43359
+ const top = baseline - TERMINAL_CELL_ASCENT;
43360
+ let column = 0;
43361
+ for (const run of row) {
43362
+ if (column >= 120) break;
43363
+ const clipped = clipRun(run, 120 - column);
43364
+ const columns = [...clipped].length;
43365
+ if (columns === 0) continue;
43366
+ const x = TERMINAL_TEXT_MARGIN_X + column * TERMINAL_CELL_WIDTH;
43367
+ const width = columns * TERMINAL_CELL_WIDTH;
43368
+ if (run.bg !== null) backgrounds.push(`<rect x="${coordinate(x)}" y="${coordinate(top)}" width="${coordinate(width)}" height="${String(TERMINAL_ROW_HEIGHT)}" fill="${run.bg}"/>`);
43369
+ if (clipped.trim() !== "") {
43370
+ const fill = run.fg === null ? "" : ` fill="${run.fg}"`;
43371
+ const weight = run.bold ? " font-weight=\"bold\"" : "";
43372
+ texts.push(`<text xml:space="preserve" x="${coordinate(x)}" y="${coordinate(baseline)}" textLength="${coordinate(width)}" lengthAdjust="spacingAndGlyphs"${fill}${weight}>${escapeXml(clipped)}</text>`);
43373
+ }
43374
+ column += columns;
43375
+ }
43376
+ });
43377
+ return `<svg xmlns="http://www.w3.org/2000/svg" width="${String(960)}" height="${String(640)}"><rect width="100%" height="100%" fill="${TERMINAL_DEFAULT_BG}"/>${backgrounds.join("")}<g fill="${TERMINAL_DEFAULT_FG}" font-family="${TERMINAL_FONT_STACK}" font-size="${String(TERMINAL_FONT_SIZE)}">${texts.join("")}</g></svg>`;
43378
+ }
43379
+ /** Cut a run to the columns still left in the row, by code point not unit. */
43380
+ function clipRun(run, remaining) {
43381
+ const points = [...run.text];
43382
+ return points.length <= remaining ? run.text : points.slice(0, remaining).join("");
43383
+ }
43384
+ async function renderTerminalJpeg(rows) {
43385
+ return sharp(Buffer.from(renderTerminalSvg(rows))).jpeg({
43386
+ quality: 82,
43387
+ chromaSubsampling: "4:2:0"
43388
+ }).toBuffer();
43389
+ }
43390
+ //#endregion
43391
+ //#region src/terminal-camera-device.ts
43392
+ var terminalCameraSchema = object({
43393
+ instanceId: string().min(1).optional(),
43394
+ nodeId: string().min(1),
43395
+ profileId: string().min(1).default("monitor"),
43396
+ profileLabel: string().min(1).default("BTM")
43397
+ });
43398
+ var relay = null;
43399
+ function installTerminalCameraRelay(next) {
43400
+ relay = next;
43401
+ }
43402
+ var TerminalCameraDevice = class extends BaseDevice {
43403
+ features = [DeviceFeature.NativeSnapshot];
43404
+ constructor(ctx) {
43405
+ super(ctx, terminalCameraSchema, { type: ctx.deviceMeta.type });
43406
+ this.ctx.registerNativeCap(streamCatalogCapability, { getCatalog: async ({ deviceId }) => {
43407
+ if (deviceId !== this.id) return [];
43408
+ return this.catalog();
43409
+ } });
43410
+ this.ctx.registerNativeCap(snapshotCapability, {
43411
+ getSnapshot: async ({ deviceId }) => {
43412
+ if (deviceId !== this.id) throw new Error(`TerminalCameraDevice: deviceId mismatch, expected ${String(this.id)}, got ${String(deviceId)}`);
43413
+ const activeRelay = relay;
43414
+ if (!activeRelay) throw new Error("terminal camera relay is unavailable");
43415
+ return {
43416
+ base64: (await activeRelay.snapshot(this.relayInstanceId(), this.config.get("nodeId"), this.config.get("profileId"))).toString("base64"),
43417
+ contentType: "image/jpeg"
43418
+ };
43419
+ },
43420
+ invalidateCache: async () => {}
43421
+ });
43422
+ this.markOnline(true);
43423
+ }
43424
+ async catalog() {
43425
+ const activeRelay = relay;
43426
+ if (!activeRelay) throw new Error("terminal camera relay is unavailable");
43427
+ const nodeId = this.config.get("nodeId");
43428
+ const profileId = this.config.get("profileId");
43429
+ const instanceId = this.relayInstanceId();
43430
+ return [{
43431
+ camStreamId: profileId,
43432
+ kind: "pull-http",
43433
+ url: activeRelay.streamUrl(instanceId, nodeId, profileId),
43434
+ codec: "h264",
43435
+ resolution: {
43436
+ width: 960,
43437
+ height: 640
43438
+ },
43439
+ fps: 2,
43440
+ label: this.config.get("profileLabel")
43441
+ }];
43442
+ }
43443
+ setNodeOnline(online) {
43444
+ this.markOnline(online);
43445
+ if (!online) relay?.closeInstance(this.relayInstanceId());
43446
+ }
43447
+ async removeDevice() {
43448
+ await relay?.closeInstance(this.relayInstanceId());
43449
+ }
43450
+ relayInstanceId() {
43451
+ return this.config.get("instanceId") ?? `legacy:${this.stableId}`;
43452
+ }
43453
+ };
43454
+ //#endregion
43345
43455
  //#region src/terminal-camera-relay.ts
43346
43456
  var MJPEG_BOUNDARY = "camstack-terminal-frame";
43347
43457
  var SESSION_IDLE_MS = 3e4;
@@ -43421,7 +43531,7 @@ var TerminalCameraRelay = class {
43421
43531
  instanceId,
43422
43532
  nodeId,
43423
43533
  profileId,
43424
- screen: createXtermScreen$1(120, 40),
43534
+ screen: createXtermScreen(120, 40),
43425
43535
  sessionId: null,
43426
43536
  cursor: 0,
43427
43537
  clients: 0,
@@ -43478,7 +43588,7 @@ var TerminalCameraRelay = class {
43478
43588
  applyBatch(state, batch) {
43479
43589
  if (batch.reset) {
43480
43590
  state.screen.dispose();
43481
- state.screen = createXtermScreen$1(120, 40);
43591
+ state.screen = createXtermScreen(120, 40);
43482
43592
  if (batch.snapshot) state.screen.write(batch.snapshot);
43483
43593
  }
43484
43594
  let exited = false;
@@ -45236,4 +45346,4 @@ var TerminalAddon = class extends BaseAddon {
45236
45346
  }
45237
45347
  };
45238
45348
  //#endregion
45239
- export { TerminalAddon, createXtermScreen$1 as a, buildCellRuns as c, terminalRgbColor as d, createNodePtySpawner as f, createTerminalDataPlaneHandler as i, resolveCellStyle as l, buildProfiles as n, TERMINAL_DEFAULT_BG as o, warmNodePty as p, findProfile as r, TERMINAL_DEFAULT_FG as s, TerminalSessionManager as t, terminalPaletteColor as u };
45349
+ export { TerminalAddon, createXtermScreen as a, buildCellRuns as c, terminalRgbColor as d, createNodePtySpawner as f, createTerminalDataPlaneHandler as i, resolveCellStyle as l, buildProfiles as n, TERMINAL_DEFAULT_BG as o, warmNodePty as p, findProfile as r, TERMINAL_DEFAULT_FG as s, TerminalSessionManager as t, terminalPaletteColor as u };