@camstack/addon-terminal 0.1.53 → 0.1.54
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/dist/addon.js +731 -466
- package/dist/addon.mjs +731 -466
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -8117,6 +8117,20 @@ var RelocateJobSchema = object({
|
|
|
8117
8117
|
* in its row, not in its name, so `MediaRelocateEngine` never reconciles one.
|
|
8118
8118
|
*/
|
|
8119
8119
|
rowsReconciled: number().int().nonnegative().optional(),
|
|
8120
|
+
/**
|
|
8121
|
+
* Rows this run FORGOT because the file they name is not on disk.
|
|
8122
|
+
*
|
|
8123
|
+
* The mover derived the path from the row's own fields and `stat`ed it; an
|
|
8124
|
+
* ENOENT there is a per-path confirmation that the segment is gone (D296),
|
|
8125
|
+
* and the durable row is dropped through the same channel eviction uses. It
|
|
8126
|
+
* is reported for the same reason `rowsReconciled` is: this is a durable
|
|
8127
|
+
* mutation nobody asked for, and a migration that quietly erases hour rows is
|
|
8128
|
+
* the same failure as one that quietly skips them (D295).
|
|
8129
|
+
*
|
|
8130
|
+
* The production drain of 2026-08-30 would have reported 11 074 here — the
|
|
8131
|
+
* ledger claimed 5.65 GB of footage that no longer existed.
|
|
8132
|
+
*/
|
|
8133
|
+
rowsForgotten: number().int().nonnegative().optional(),
|
|
8120
8134
|
startedAt: number(),
|
|
8121
8135
|
finishedAt: number().nullable(),
|
|
8122
8136
|
error: string().nullable()
|
|
@@ -8480,6 +8494,91 @@ var RelocateResidueSchema = object({
|
|
|
8480
8494
|
segments: number().int().nonnegative(),
|
|
8481
8495
|
bytes: number().int().nonnegative()
|
|
8482
8496
|
}).nullable();
|
|
8497
|
+
/**
|
|
8498
|
+
* Ask one location whether its durable hour rows describe the disk — the walk
|
|
8499
|
+
* (D319).
|
|
8500
|
+
*
|
|
8501
|
+
* `apply` DEFAULTS TO FALSE and that default is the product: the operator's
|
|
8502
|
+
* missing tool is the question, and the dry run is how they sanity-check the
|
|
8503
|
+
* destructive run before authorising it.
|
|
8504
|
+
*/
|
|
8505
|
+
var LedgerWalkInputSchema = object({
|
|
8506
|
+
locationId: string().min(1),
|
|
8507
|
+
/** Forget the confirmed-absent rows, rather than only counting them. */
|
|
8508
|
+
apply: boolean().optional(),
|
|
8509
|
+
/** Narrow to one camera. */
|
|
8510
|
+
deviceId: number().int().positive().optional(),
|
|
8511
|
+
/** Narrow to these recording profiles; empty/absent = every profile. */
|
|
8512
|
+
profiles: array(string().min(1)).optional()
|
|
8513
|
+
});
|
|
8514
|
+
/** Why a whole walk did nothing. Every one leaves the ledger untouched. */
|
|
8515
|
+
var LedgerWalkRefusalSchema = _enum([
|
|
8516
|
+
"location-unknown",
|
|
8517
|
+
"source-writable",
|
|
8518
|
+
"no-ledger",
|
|
8519
|
+
"archive-unreadable",
|
|
8520
|
+
"anchor-absent",
|
|
8521
|
+
"anchor-unreadable",
|
|
8522
|
+
"anchor-moved"
|
|
8523
|
+
]);
|
|
8524
|
+
_enum([
|
|
8525
|
+
"live-tail",
|
|
8526
|
+
"listing-error",
|
|
8527
|
+
"path-mismatch",
|
|
8528
|
+
"durable-refused"
|
|
8529
|
+
]);
|
|
8530
|
+
/** Every skip reason, always present, always a number — so a reason that never
|
|
8531
|
+
* fired reports as zero rather than absent and the report shape is constant
|
|
8532
|
+
* between passes. Spelled out rather than `z.record` for exactly that. */
|
|
8533
|
+
var LedgerWalkSkipCountsSchema = object({
|
|
8534
|
+
"live-tail": number().int().nonnegative(),
|
|
8535
|
+
"listing-error": number().int().nonnegative(),
|
|
8536
|
+
"path-mismatch": number().int().nonnegative(),
|
|
8537
|
+
"durable-refused": number().int().nonnegative()
|
|
8538
|
+
});
|
|
8539
|
+
/** One camera's share of a walk, so a report names cameras and not rows. */
|
|
8540
|
+
var LedgerWalkDeviceReportSchema = object({
|
|
8541
|
+
deviceId: number().int(),
|
|
8542
|
+
hoursWalked: number().int().nonnegative(),
|
|
8543
|
+
hoursMissing: number().int().nonnegative(),
|
|
8544
|
+
ghostSegments: number().int().nonnegative(),
|
|
8545
|
+
ghostBytes: number().int().nonnegative(),
|
|
8546
|
+
forgottenSegments: number().int().nonnegative(),
|
|
8547
|
+
orphanFiles: number().int().nonnegative()
|
|
8548
|
+
});
|
|
8549
|
+
/**
|
|
8550
|
+
* What one walk claimed, listed, found and (only when armed) forgot.
|
|
8551
|
+
*
|
|
8552
|
+
* `archiveSegments` is the **M** and `segmentsClaimed` the **N** (D295), so a
|
|
8553
|
+
* walk that saw a fraction of the location is visible in its own report rather
|
|
8554
|
+
* than in the absence of one.
|
|
8555
|
+
*/
|
|
8556
|
+
var LedgerWalkReportSchema = object({
|
|
8557
|
+
locationId: string(),
|
|
8558
|
+
applied: boolean(),
|
|
8559
|
+
refused: LedgerWalkRefusalSchema.nullable(),
|
|
8560
|
+
archiveSegments: number().int().nonnegative().nullable(),
|
|
8561
|
+
archiveBytes: number().int().nonnegative().nullable(),
|
|
8562
|
+
hoursClaimed: number().int().nonnegative(),
|
|
8563
|
+
hoursWalked: number().int().nonnegative(),
|
|
8564
|
+
hoursMissing: number().int().nonnegative(),
|
|
8565
|
+
/** `readdir` calls issued — the cost, stated in the unit that is paid. */
|
|
8566
|
+
listings: number().int().nonnegative(),
|
|
8567
|
+
segmentsClaimed: number().int().nonnegative(),
|
|
8568
|
+
ghostSegments: number().int().nonnegative(),
|
|
8569
|
+
ghostBytes: number().int().nonnegative(),
|
|
8570
|
+
ghostHoursWhole: number().int().nonnegative(),
|
|
8571
|
+
forgottenSegments: number().int().nonnegative(),
|
|
8572
|
+
forgottenBytes: number().int().nonnegative(),
|
|
8573
|
+
/** Files under a claimed hour that no durable row names. Never deleted. */
|
|
8574
|
+
orphanFiles: number().int().nonnegative(),
|
|
8575
|
+
orphanSample: array(string()).readonly(),
|
|
8576
|
+
hoursSkipped: number().int().nonnegative(),
|
|
8577
|
+
skippedByReason: LedgerWalkSkipCountsSchema,
|
|
8578
|
+
/** The walk stopped at its per-pass hour bound with claims unwalked. */
|
|
8579
|
+
bounded: boolean(),
|
|
8580
|
+
byDevice: array(LedgerWalkDeviceReportSchema).readonly()
|
|
8581
|
+
});
|
|
8483
8582
|
/** How many rows a media pass would still act on against a given target — the
|
|
8484
8583
|
* media lane's denominator AND its residue, from ONE derivation so the two can
|
|
8485
8584
|
* never disagree. `null` = the count could not be taken. */
|
|
@@ -19040,13 +19139,15 @@ var ListGroupsPageSchema = object({
|
|
|
19040
19139
|
groups: array(AnalyticsGroupRecordSchema).readonly(),
|
|
19041
19140
|
nextCursor: string().nullable()
|
|
19042
19141
|
});
|
|
19142
|
+
var KEY_EVENTS_DEFAULT_LIMIT = 50;
|
|
19143
|
+
var KEY_EVENTS_MAX_LIMIT = 200;
|
|
19043
19144
|
var KeyEventQueryInput = object({
|
|
19044
19145
|
deviceId: number(),
|
|
19045
19146
|
/** Window lower bound (track firstSeen ≥ since). */
|
|
19046
19147
|
since: number(),
|
|
19047
19148
|
/** Window upper bound (track firstSeen ≤ until). */
|
|
19048
19149
|
until: number(),
|
|
19049
|
-
limit: number().int().min(1).max(
|
|
19150
|
+
limit: number().int().min(1).max(KEY_EVENTS_MAX_LIMIT).default(KEY_EVENTS_DEFAULT_LIMIT),
|
|
19050
19151
|
/** Drop tracks scoring below this importance. */
|
|
19051
19152
|
minImportance: number().min(0).max(1).optional(),
|
|
19052
19153
|
/** Restrict to a single class (e.g. 'person'). */
|
|
@@ -19068,6 +19169,32 @@ var KeyEventSchema = object({
|
|
|
19068
19169
|
...TrackFlagFields,
|
|
19069
19170
|
...TrackRetrainFields
|
|
19070
19171
|
});
|
|
19172
|
+
/** `getKeyEvents`' window and filters, asked of a SET of cameras at once. */
|
|
19173
|
+
var KeyEventBatchQueryInput = object({
|
|
19174
|
+
deviceIds: array(number()).min(1).max(200),
|
|
19175
|
+
since: number(),
|
|
19176
|
+
until: number(),
|
|
19177
|
+
/** Applied PER CAMERA, exactly as `getKeyEvents.limit` is — never a total
|
|
19178
|
+
* across the set, which would let a busy camera starve a quiet one of its
|
|
19179
|
+
* rows and change what the merged feed contains. */
|
|
19180
|
+
limit: number().int().min(1).max(KEY_EVENTS_MAX_LIMIT).default(KEY_EVENTS_DEFAULT_LIMIT),
|
|
19181
|
+
minImportance: number().min(0).max(1).optional(),
|
|
19182
|
+
classFilter: string().optional()
|
|
19183
|
+
});
|
|
19184
|
+
/**
|
|
19185
|
+
* One camera's key events in a batch answer.
|
|
19186
|
+
*
|
|
19187
|
+
* The row exists for every requested id. `getKeyEvents` degrades to `[]` on
|
|
19188
|
+
* error rather than throwing, so a camera whose store read failed and one with
|
|
19189
|
+
* no events in the window were ALREADY indistinguishable per camera — the
|
|
19190
|
+
* batch does not make that worse, and the row keeps the deviceId the single
|
|
19191
|
+
* method's output never carried (the caller used to stamp it from the fan-out
|
|
19192
|
+
* key, which only worked because there was one query per camera).
|
|
19193
|
+
*/
|
|
19194
|
+
var KeyEventsForDeviceSchema = object({
|
|
19195
|
+
deviceId: number(),
|
|
19196
|
+
events: array(KeyEventSchema).readonly()
|
|
19197
|
+
});
|
|
19071
19198
|
object({
|
|
19072
19199
|
trackId: string(),
|
|
19073
19200
|
className: string(),
|
|
@@ -19337,7 +19464,7 @@ DeviceType.Camera, method(object({ deviceId: number() }), array(TrackSchema).rea
|
|
|
19337
19464
|
until: number().optional(),
|
|
19338
19465
|
kinds: array(string()).optional(),
|
|
19339
19466
|
limit: number().int().min(1).max(MAX_EVENT_QUERY_LIMIT).default(DEFAULT_EVENT_QUERY_LIMIT)
|
|
19340
|
-
}), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(object({
|
|
19467
|
+
}), array(SensorEventSchema).readonly()), method(KeyEventQueryInput, array(KeyEventSchema).readonly()), method(KeyEventBatchQueryInput, array(KeyEventsForDeviceSchema).readonly()), method(object({
|
|
19341
19468
|
deviceId: number(),
|
|
19342
19469
|
since: number(),
|
|
19343
19470
|
until: number(),
|
|
@@ -28852,6 +28979,9 @@ method(object({
|
|
|
28852
28979
|
}), method(RelocateResidueInputSchema, RelocateResidueSchema, {
|
|
28853
28980
|
kind: "query",
|
|
28854
28981
|
auth: "admin"
|
|
28982
|
+
}), method(LedgerWalkInputSchema, LedgerWalkReportSchema, {
|
|
28983
|
+
kind: "mutation",
|
|
28984
|
+
auth: "admin"
|
|
28855
28985
|
}), method(object({ jobId: string() }), object({ cancelled: boolean() }), {
|
|
28856
28986
|
kind: "mutation",
|
|
28857
28987
|
auth: "admin"
|
|
@@ -29243,6 +29373,25 @@ var SceneMonitorStatusSchema = object({
|
|
|
29243
29373
|
monitors: array(SceneMonitorSchema),
|
|
29244
29374
|
lastFetchedAt: number()
|
|
29245
29375
|
});
|
|
29376
|
+
/**
|
|
29377
|
+
* One camera's row in a `listScenesBatch` answer.
|
|
29378
|
+
*
|
|
29379
|
+
* `status` is NULLABLE and the nullability is the whole point. `scene-monitor`
|
|
29380
|
+
* is a `defaultActive` wrapper, so every camera is asked; a camera whose
|
|
29381
|
+
* provider is absent (pipeline-analytics not deployed, the post-processing node
|
|
29382
|
+
* down) cannot answer, and that is not the same fact as a camera with no scenes
|
|
29383
|
+
* configured. Fanned out per camera the difference was visible — one query
|
|
29384
|
+
* errored while the others resolved — and a batch that returned only the rows
|
|
29385
|
+
* it managed would have destroyed it, silently, by making an unreachable camera
|
|
29386
|
+
* indistinguishable from one that answered `monitors: []`.
|
|
29387
|
+
*
|
|
29388
|
+
* So: EVERY requested deviceId gets a row. `status: null` means "this camera
|
|
29389
|
+
* could not be read"; `status.monitors: []` means "read, and it has none".
|
|
29390
|
+
*/
|
|
29391
|
+
var SceneMonitorStatusForDeviceSchema = object({
|
|
29392
|
+
deviceId: number(),
|
|
29393
|
+
status: SceneMonitorStatusSchema.nullable()
|
|
29394
|
+
});
|
|
29246
29395
|
var sceneMonitorCapability = {
|
|
29247
29396
|
name: "scene-monitor",
|
|
29248
29397
|
scope: "device",
|
|
@@ -29252,6 +29401,22 @@ var sceneMonitorCapability = {
|
|
|
29252
29401
|
deviceTypes: [DeviceType.Camera],
|
|
29253
29402
|
methods: {
|
|
29254
29403
|
listScenes: method(object({ deviceId: number() }), SceneMonitorStatusSchema),
|
|
29404
|
+
/**
|
|
29405
|
+
* The same answer, for a SET of cameras, in one round trip.
|
|
29406
|
+
*
|
|
29407
|
+
* `/scenes` renders every camera and re-reads them on a 30s safety-net
|
|
29408
|
+
* poll behind the push slice. Fanned out client-side that was one query
|
|
29409
|
+
* per camera — 29 round trips through the browser, the hub and the
|
|
29410
|
+
* post-analysis runner every 30 seconds to read an in-memory map the
|
|
29411
|
+
* owner had already merged. The work is unchanged (`statusFor` per
|
|
29412
|
+
* device, all in-process at the owner); what collapses is the transport.
|
|
29413
|
+
*
|
|
29414
|
+
* A camera that cannot answer still gets a row, with `status: null` —
|
|
29415
|
+
* see {@link SceneMonitorStatusForDeviceSchema}. Never fewer rows than
|
|
29416
|
+
* ids: a caller that asked for twenty-nine and got twenty-seven cannot
|
|
29417
|
+
* tell which two are missing, or that any are.
|
|
29418
|
+
*/
|
|
29419
|
+
listScenesBatch: method(object({ deviceIds: array(number()).min(1).max(200) }), array(SceneMonitorStatusForDeviceSchema).readonly()),
|
|
29255
29420
|
createScene: method(object({
|
|
29256
29421
|
deviceId: number(),
|
|
29257
29422
|
label: string(),
|
|
@@ -31087,6 +31252,27 @@ var CameraOccupancySnapshotSchema = object({
|
|
|
31087
31252
|
stationaryObjects: array(StationaryObjectSchema).readonly().optional()
|
|
31088
31253
|
});
|
|
31089
31254
|
/**
|
|
31255
|
+
* One camera's row in a `getCurrentSnapshotBatch` answer.
|
|
31256
|
+
*
|
|
31257
|
+
* THREE outcomes, and the single-camera method could only express two of them
|
|
31258
|
+
* because `snapshot: null` was already spoken for:
|
|
31259
|
+
*
|
|
31260
|
+
* - `read: 'read'`, `snapshot` present — the live occupancy reading.
|
|
31261
|
+
* - `read: 'read'`, `snapshot: null` — read, and this camera has no reading
|
|
31262
|
+
* yet: no frame since boot, and no parked-object registry to hydrate from.
|
|
31263
|
+
* - `read: 'unreadable'` — the owner could not answer for this
|
|
31264
|
+
* camera. `snapshot` is null, and it does NOT mean "nothing parked here".
|
|
31265
|
+
*
|
|
31266
|
+
* Collapsing the last two is the failure this field exists to prevent: a
|
|
31267
|
+
* hydration that threw would otherwise render as an empty Stationary section,
|
|
31268
|
+
* which is a definite claim about a camera nobody could read.
|
|
31269
|
+
*/
|
|
31270
|
+
var CameraOccupancySnapshotForDeviceSchema = object({
|
|
31271
|
+
deviceId: number(),
|
|
31272
|
+
read: _enum(["read", "unreadable"]),
|
|
31273
|
+
snapshot: CameraOccupancySnapshotSchema.nullable()
|
|
31274
|
+
});
|
|
31275
|
+
/**
|
|
31090
31276
|
* Time-series resolution. The history methods return one bucket per
|
|
31091
31277
|
* step over the requested range. Smaller resolutions cost more
|
|
31092
31278
|
* memory + bandwidth; bound to discrete steps so caller cannot ask
|
|
@@ -31143,6 +31329,20 @@ var zoneAnalyticsCapability = {
|
|
|
31143
31329
|
* (no inference result emitted since boot or since binding was
|
|
31144
31330
|
* activated). */
|
|
31145
31331
|
getCurrentSnapshot: method(object({ deviceId: number() }), CameraOccupancySnapshotSchema.nullable()),
|
|
31332
|
+
/**
|
|
31333
|
+
* The same snapshot, for a SET of cameras, in one round trip.
|
|
31334
|
+
*
|
|
31335
|
+
* The Events page's Stationary section polls this every 15s for every
|
|
31336
|
+
* selected camera. Fanned out client-side that is one query per camera to
|
|
31337
|
+
* read a `Map.get` at the owner — the answer costs nothing, the round trip
|
|
31338
|
+
* costs everything. Batched, N transports become one and the per-device
|
|
31339
|
+
* work is unchanged.
|
|
31340
|
+
*
|
|
31341
|
+
* Every requested deviceId gets a row, tagged `read` — see
|
|
31342
|
+
* {@link CameraOccupancySnapshotForDeviceSchema}. A camera the owner could
|
|
31343
|
+
* not answer for is `'unreadable'`, never an empty reading.
|
|
31344
|
+
*/
|
|
31345
|
+
getCurrentSnapshotBatch: method(object({ deviceIds: array(number()).min(1).max(200) }), array(CameraOccupancySnapshotForDeviceSchema).readonly()),
|
|
31146
31346
|
/** Time-series object count inside one zone. `className` optional —
|
|
31147
31347
|
* omit to count every class in the zone. */
|
|
31148
31348
|
getZoneHistory: method(object({
|
|
@@ -35562,6 +35762,12 @@ Object.freeze({
|
|
|
35562
35762
|
addonId: null,
|
|
35563
35763
|
access: "view"
|
|
35564
35764
|
},
|
|
35765
|
+
"pipelineAnalytics.getKeyEventsBatch": {
|
|
35766
|
+
capName: "pipeline-analytics",
|
|
35767
|
+
capScope: "device",
|
|
35768
|
+
addonId: null,
|
|
35769
|
+
access: "view"
|
|
35770
|
+
},
|
|
35565
35771
|
"pipelineAnalytics.getMotionEvents": {
|
|
35566
35772
|
capName: "pipeline-analytics",
|
|
35567
35773
|
capScope: "device",
|
|
@@ -36738,6 +36944,12 @@ Object.freeze({
|
|
|
36738
36944
|
addonId: null,
|
|
36739
36945
|
access: "view"
|
|
36740
36946
|
},
|
|
36947
|
+
"recording.reconcileLedgerAgainstDisk": {
|
|
36948
|
+
capName: "recording",
|
|
36949
|
+
capScope: "system",
|
|
36950
|
+
addonId: null,
|
|
36951
|
+
access: "create"
|
|
36952
|
+
},
|
|
36741
36953
|
"recording.refreshStorageLocationsForMigration": {
|
|
36742
36954
|
capName: "recording",
|
|
36743
36955
|
capScope: "system",
|
|
@@ -36864,6 +37076,12 @@ Object.freeze({
|
|
|
36864
37076
|
addonId: null,
|
|
36865
37077
|
access: "view"
|
|
36866
37078
|
},
|
|
37079
|
+
"sceneMonitor.listScenesBatch": {
|
|
37080
|
+
capName: "scene-monitor",
|
|
37081
|
+
capScope: "device",
|
|
37082
|
+
addonId: null,
|
|
37083
|
+
access: "view"
|
|
37084
|
+
},
|
|
36867
37085
|
"sceneMonitor.recheckNow": {
|
|
36868
37086
|
capName: "scene-monitor",
|
|
36869
37087
|
capScope: "device",
|
|
@@ -38220,6 +38438,12 @@ Object.freeze({
|
|
|
38220
38438
|
addonId: null,
|
|
38221
38439
|
access: "view"
|
|
38222
38440
|
},
|
|
38441
|
+
"zoneAnalytics.getCurrentSnapshotBatch": {
|
|
38442
|
+
capName: "zone-analytics",
|
|
38443
|
+
capScope: "device",
|
|
38444
|
+
addonId: null,
|
|
38445
|
+
access: "view"
|
|
38446
|
+
},
|
|
38223
38447
|
"zoneAnalytics.getUnzonedHistory": {
|
|
38224
38448
|
capName: "zone-analytics",
|
|
38225
38449
|
capScope: "device",
|
|
@@ -39224,6 +39448,11 @@ Object.freeze({
|
|
|
39224
39448
|
form: "single",
|
|
39225
39449
|
optional: false
|
|
39226
39450
|
}],
|
|
39451
|
+
"pipelineAnalytics.getKeyEventsBatch": [{
|
|
39452
|
+
name: "deviceIds",
|
|
39453
|
+
form: "array",
|
|
39454
|
+
optional: false
|
|
39455
|
+
}],
|
|
39227
39456
|
"pipelineAnalytics.getMotionEvents": [{
|
|
39228
39457
|
name: "deviceId",
|
|
39229
39458
|
form: "single",
|
|
@@ -39664,6 +39893,11 @@ Object.freeze({
|
|
|
39664
39893
|
form: "single",
|
|
39665
39894
|
optional: false
|
|
39666
39895
|
}],
|
|
39896
|
+
"recording.reconcileLedgerAgainstDisk": [{
|
|
39897
|
+
name: "deviceId",
|
|
39898
|
+
form: "single",
|
|
39899
|
+
optional: true
|
|
39900
|
+
}],
|
|
39667
39901
|
"recording.relocateFootage": [{
|
|
39668
39902
|
name: "deviceId",
|
|
39669
39903
|
form: "single",
|
|
@@ -39729,6 +39963,11 @@ Object.freeze({
|
|
|
39729
39963
|
form: "single",
|
|
39730
39964
|
optional: false
|
|
39731
39965
|
}],
|
|
39966
|
+
"sceneMonitor.listScenesBatch": [{
|
|
39967
|
+
name: "deviceIds",
|
|
39968
|
+
form: "array",
|
|
39969
|
+
optional: false
|
|
39970
|
+
}],
|
|
39732
39971
|
"sceneMonitor.recheckNow": [{
|
|
39733
39972
|
name: "deviceId",
|
|
39734
39973
|
form: "single",
|
|
@@ -39990,6 +40229,11 @@ Object.freeze({
|
|
|
39990
40229
|
form: "single",
|
|
39991
40230
|
optional: false
|
|
39992
40231
|
}],
|
|
40232
|
+
"zoneAnalytics.getCurrentSnapshotBatch": [{
|
|
40233
|
+
name: "deviceIds",
|
|
40234
|
+
form: "array",
|
|
40235
|
+
optional: false
|
|
40236
|
+
}],
|
|
39993
40237
|
"zoneAnalytics.getUnzonedHistory": [{
|
|
39994
40238
|
name: "deviceId",
|
|
39995
40239
|
form: "single",
|
|
@@ -40563,6 +40807,111 @@ function resolveGlancesCursesShimEnv(options) {
|
|
|
40563
40807
|
return { PYTHONPATH: existing ? `${options.shimDir}:${existing}` : options.shimDir };
|
|
40564
40808
|
}
|
|
40565
40809
|
//#endregion
|
|
40810
|
+
//#region src/profile-settings.ts
|
|
40811
|
+
var GLANCES_PLUGINS = [
|
|
40812
|
+
{
|
|
40813
|
+
key: "showCpu",
|
|
40814
|
+
plugin: "cpu",
|
|
40815
|
+
label: "CPU"
|
|
40816
|
+
},
|
|
40817
|
+
{
|
|
40818
|
+
key: "showMem",
|
|
40819
|
+
plugin: "mem",
|
|
40820
|
+
label: "Memory"
|
|
40821
|
+
},
|
|
40822
|
+
{
|
|
40823
|
+
key: "showLoad",
|
|
40824
|
+
plugin: "load",
|
|
40825
|
+
label: "Load"
|
|
40826
|
+
},
|
|
40827
|
+
{
|
|
40828
|
+
key: "showNetwork",
|
|
40829
|
+
plugin: "network",
|
|
40830
|
+
label: "Network"
|
|
40831
|
+
},
|
|
40832
|
+
{
|
|
40833
|
+
key: "showDiskIo",
|
|
40834
|
+
plugin: "diskio",
|
|
40835
|
+
label: "Disk I/O"
|
|
40836
|
+
},
|
|
40837
|
+
{
|
|
40838
|
+
key: "showFs",
|
|
40839
|
+
plugin: "fs",
|
|
40840
|
+
label: "Filesystems"
|
|
40841
|
+
},
|
|
40842
|
+
{
|
|
40843
|
+
key: "showProcessList",
|
|
40844
|
+
plugin: "processlist",
|
|
40845
|
+
label: "Process list"
|
|
40846
|
+
},
|
|
40847
|
+
{
|
|
40848
|
+
key: "showContainers",
|
|
40849
|
+
plugin: "containers",
|
|
40850
|
+
label: "Containers"
|
|
40851
|
+
},
|
|
40852
|
+
{
|
|
40853
|
+
key: "showSensors",
|
|
40854
|
+
plugin: "sensors",
|
|
40855
|
+
label: "Sensors"
|
|
40856
|
+
}
|
|
40857
|
+
];
|
|
40858
|
+
function glancesBooleanField(key, label) {
|
|
40859
|
+
return {
|
|
40860
|
+
type: "boolean",
|
|
40861
|
+
key,
|
|
40862
|
+
label,
|
|
40863
|
+
default: true,
|
|
40864
|
+
style: "switch"
|
|
40865
|
+
};
|
|
40866
|
+
}
|
|
40867
|
+
function glancesSettingsSchema() {
|
|
40868
|
+
return { sections: [{
|
|
40869
|
+
id: "glances-panels",
|
|
40870
|
+
title: "Glances panels",
|
|
40871
|
+
description: "Turn off a panel to pass --disable-plugin to this Terminal only. All on is the measured default (~1% of one core at the camera grid).",
|
|
40872
|
+
columns: 2,
|
|
40873
|
+
fields: GLANCES_PLUGINS.map((plugin) => glancesBooleanField(plugin.key, plugin.label))
|
|
40874
|
+
}] };
|
|
40875
|
+
}
|
|
40876
|
+
function settingsSchemaForProfile(profileId) {
|
|
40877
|
+
if (profileId === "glances") return glancesSettingsSchema();
|
|
40878
|
+
return null;
|
|
40879
|
+
}
|
|
40880
|
+
function glancesSettingsToArgs(settings) {
|
|
40881
|
+
const disabled = GLANCES_PLUGINS.filter((plugin) => settings[plugin.key] === false).map((plugin) => plugin.plugin);
|
|
40882
|
+
if (disabled.length === 0) return [];
|
|
40883
|
+
return ["--disable-plugin", disabled.join(",")];
|
|
40884
|
+
}
|
|
40885
|
+
function sanitizeProfileSettings(profileId, raw) {
|
|
40886
|
+
if (profileId !== "glances") return {};
|
|
40887
|
+
const bag = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
40888
|
+
const out = {
|
|
40889
|
+
showCpu: true,
|
|
40890
|
+
showMem: true,
|
|
40891
|
+
showLoad: true,
|
|
40892
|
+
showNetwork: true,
|
|
40893
|
+
showDiskIo: true,
|
|
40894
|
+
showFs: true,
|
|
40895
|
+
showProcessList: true,
|
|
40896
|
+
showContainers: true,
|
|
40897
|
+
showSensors: true
|
|
40898
|
+
};
|
|
40899
|
+
for (const plugin of GLANCES_PLUGINS) {
|
|
40900
|
+
const value = bag[plugin.key];
|
|
40901
|
+
if (typeof value === "boolean") out[plugin.key] = value;
|
|
40902
|
+
}
|
|
40903
|
+
return out;
|
|
40904
|
+
}
|
|
40905
|
+
function profileSettingsToArgs(profileId, settings) {
|
|
40906
|
+
if (profileId !== "glances") return [];
|
|
40907
|
+
return glancesSettingsToArgs(sanitizeProfileSettings(profileId, settings));
|
|
40908
|
+
}
|
|
40909
|
+
function spawnArgsForInstance(input) {
|
|
40910
|
+
const extra = profileSettingsToArgs(input.profileId, input.profileSettings);
|
|
40911
|
+
if (input.instanceArgs.length > 0) return [...input.instanceArgs, ...extra];
|
|
40912
|
+
if (extra.length > 0) return [...input.profileArgs, ...extra];
|
|
40913
|
+
}
|
|
40914
|
+
//#endregion
|
|
40566
40915
|
//#region src/pty.ts
|
|
40567
40916
|
/**
|
|
40568
40917
|
* Minimal pty abstraction. The manager depends on this interface, never on
|
|
@@ -40744,6 +41093,356 @@ async function silenceAnalysisFor(deps, deviceId) {
|
|
|
40744
41093
|
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("; ")})`);
|
|
40745
41094
|
}
|
|
40746
41095
|
//#endregion
|
|
41096
|
+
//#region src/terminal-camera-declarations.ts
|
|
41097
|
+
/**
|
|
41098
|
+
* Feed DeclaredDevices every live declaration plus one deterministic orphan
|
|
41099
|
+
* batch. The generic sweep intentionally refuses an over-limit set; selecting
|
|
41100
|
+
* a batch here drains large historical Terminal orphan sets across convergence
|
|
41101
|
+
* passes without weakening that global safety guard.
|
|
41102
|
+
*/
|
|
41103
|
+
function terminalCameraReconciliationIndex(rows, integrationId, declarations, managedStableIds = /* @__PURE__ */ new Set()) {
|
|
41104
|
+
if (!integrationId) return [];
|
|
41105
|
+
const declared = new Set(declarations.map((camera) => camera.stableId));
|
|
41106
|
+
const owned = rows.filter((row) => row.integrationId === integrationId && (declared.has(row.stableId) || managedStableIds.has(row.stableId) || row.stableId.startsWith("terminal-camera-instance-")));
|
|
41107
|
+
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)];
|
|
41108
|
+
}
|
|
41109
|
+
/** Explicit persisted instances, never the node × profile template matrix. */
|
|
41110
|
+
function buildTerminalInstanceCameraDeclarations(instances) {
|
|
41111
|
+
return instances.filter((instance) => instance.enabled).map((instance) => ({
|
|
41112
|
+
stableId: instance.cameraStableId,
|
|
41113
|
+
name: instance.name,
|
|
41114
|
+
config: {
|
|
41115
|
+
instanceId: instance.id,
|
|
41116
|
+
nodeId: instance.nodeId,
|
|
41117
|
+
profileId: instance.profileId,
|
|
41118
|
+
profileLabel: instance.profileLabel
|
|
41119
|
+
}
|
|
41120
|
+
}));
|
|
41121
|
+
}
|
|
41122
|
+
/**
|
|
41123
|
+
* `DeviceConfig` materializes schema defaults in memory, so comparing
|
|
41124
|
+
* `config.get()` cannot detect a legacy `{ nodeId }` row. Reconciliation must
|
|
41125
|
+
* inspect the raw persisted blob to make the profile migration durable.
|
|
41126
|
+
*/
|
|
41127
|
+
function needsTerminalCameraConfigMigration(persistedConfig, declaration) {
|
|
41128
|
+
return persistedConfig.instanceId !== declaration.config.instanceId || persistedConfig.nodeId !== declaration.config.nodeId || persistedConfig.profileId !== declaration.config.profileId || persistedConfig.profileLabel !== declaration.config.profileLabel;
|
|
41129
|
+
}
|
|
41130
|
+
//#endregion
|
|
41131
|
+
//#region src/terminal-cell-runs.ts
|
|
41132
|
+
var TERMINAL_DEFAULT_FG = "#d7dce2";
|
|
41133
|
+
var TERMINAL_DEFAULT_BG = "#0b0d10";
|
|
41134
|
+
/**
|
|
41135
|
+
* The 16 ANSI colours, in a dark-theme variant chosen to sit with the existing
|
|
41136
|
+
* frame (`#0b0d10` ground, `#d7dce2` text) rather than the raw xterm defaults,
|
|
41137
|
+
* whose pure `#0000ff` blue and `#008000` green are close to unreadable on a
|
|
41138
|
+
* near-black background at 13px. Index 7 IS the default foreground, so plain
|
|
41139
|
+
* `CSI 37m` text renders identically to unstyled text.
|
|
41140
|
+
*/
|
|
41141
|
+
var TERMINAL_ANSI_PALETTE = [
|
|
41142
|
+
"#282c34",
|
|
41143
|
+
"#e06c75",
|
|
41144
|
+
"#98c379",
|
|
41145
|
+
"#e5c07b",
|
|
41146
|
+
"#61afef",
|
|
41147
|
+
"#c678dd",
|
|
41148
|
+
"#56b6c2",
|
|
41149
|
+
TERMINAL_DEFAULT_FG,
|
|
41150
|
+
"#5c6370",
|
|
41151
|
+
"#ef596f",
|
|
41152
|
+
"#89ca78",
|
|
41153
|
+
"#f0c674",
|
|
41154
|
+
"#6cb6ff",
|
|
41155
|
+
"#d55fde",
|
|
41156
|
+
"#2bbac5",
|
|
41157
|
+
"#ffffff"
|
|
41158
|
+
];
|
|
41159
|
+
/** The six levels of the xterm 6×6×6 colour cube (indices 16-231). */
|
|
41160
|
+
var TERMINAL_CUBE_LEVELS = [
|
|
41161
|
+
0,
|
|
41162
|
+
95,
|
|
41163
|
+
135,
|
|
41164
|
+
175,
|
|
41165
|
+
215,
|
|
41166
|
+
255
|
|
41167
|
+
];
|
|
41168
|
+
var TERMINAL_CUBE_FIRST = 16;
|
|
41169
|
+
var TERMINAL_GRAYSCALE_FIRST = 232;
|
|
41170
|
+
var TERMINAL_GRAYSCALE_BASE = 8;
|
|
41171
|
+
var TERMINAL_GRAYSCALE_STEP = 10;
|
|
41172
|
+
/** SGR 2 keeps the foreground legible; it must not become the background. */
|
|
41173
|
+
var TERMINAL_DIM_WEIGHT = .6;
|
|
41174
|
+
function channel(value) {
|
|
41175
|
+
return Math.max(0, Math.min(255, Math.round(value))).toString(16).padStart(2, "0");
|
|
41176
|
+
}
|
|
41177
|
+
function hex(red, green, blue) {
|
|
41178
|
+
return `#${channel(red)}${channel(green)}${channel(blue)}`;
|
|
41179
|
+
}
|
|
41180
|
+
function parseHex(color) {
|
|
41181
|
+
return [
|
|
41182
|
+
Number.parseInt(color.slice(1, 3), 16),
|
|
41183
|
+
Number.parseInt(color.slice(3, 5), 16),
|
|
41184
|
+
Number.parseInt(color.slice(5, 7), 16)
|
|
41185
|
+
];
|
|
41186
|
+
}
|
|
41187
|
+
/** Resolve an xterm palette index (0-255) to a hex colour. */
|
|
41188
|
+
function terminalPaletteColor(index) {
|
|
41189
|
+
const ansi = TERMINAL_ANSI_PALETTE[index];
|
|
41190
|
+
if (ansi !== void 0) return ansi;
|
|
41191
|
+
if (index >= TERMINAL_GRAYSCALE_FIRST) {
|
|
41192
|
+
const level = TERMINAL_GRAYSCALE_BASE + (index - TERMINAL_GRAYSCALE_FIRST) * TERMINAL_GRAYSCALE_STEP;
|
|
41193
|
+
return hex(level, level, level);
|
|
41194
|
+
}
|
|
41195
|
+
if (index >= TERMINAL_CUBE_FIRST) {
|
|
41196
|
+
const offset = index - TERMINAL_CUBE_FIRST;
|
|
41197
|
+
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);
|
|
41198
|
+
}
|
|
41199
|
+
return TERMINAL_DEFAULT_FG;
|
|
41200
|
+
}
|
|
41201
|
+
/** Resolve a 0xRRGGBB truecolor value to a hex colour. */
|
|
41202
|
+
function terminalRgbColor(value) {
|
|
41203
|
+
return hex(value >> 16 & 255, value >> 8 & 255, value & 255);
|
|
41204
|
+
}
|
|
41205
|
+
function blend(color, toward, weight) {
|
|
41206
|
+
const [red, green, blue] = parseHex(color);
|
|
41207
|
+
const [targetRed, targetGreen, targetBlue] = parseHex(toward);
|
|
41208
|
+
return hex(red * weight + targetRed * (1 - weight), green * weight + targetGreen * (1 - weight), blue * weight + targetBlue * (1 - weight));
|
|
41209
|
+
}
|
|
41210
|
+
function resolveForeground(cell) {
|
|
41211
|
+
if (cell.isFgRGB()) return terminalRgbColor(cell.getFgColor());
|
|
41212
|
+
if (cell.isFgPalette()) return terminalPaletteColor(cell.getFgColor());
|
|
41213
|
+
return TERMINAL_DEFAULT_FG;
|
|
41214
|
+
}
|
|
41215
|
+
function resolveBackground(cell) {
|
|
41216
|
+
if (cell.isBgRGB()) return terminalRgbColor(cell.getBgColor());
|
|
41217
|
+
if (cell.isBgPalette()) return terminalPaletteColor(cell.getBgColor());
|
|
41218
|
+
return TERMINAL_DEFAULT_BG;
|
|
41219
|
+
}
|
|
41220
|
+
/**
|
|
41221
|
+
* Resolve one cell's attributes into concrete colours.
|
|
41222
|
+
*
|
|
41223
|
+
* Inverse is applied by SWAPPING the already-resolved pair, so inverse over two
|
|
41224
|
+
* defaults is still a visible swap rather than a no-op — that is how a selected
|
|
41225
|
+
* or highlighted row in Glances reads. Invisible is then conceal-by-equality
|
|
41226
|
+
* (foreground painted in its own background): the cell keeps its columns, which
|
|
41227
|
+
* a dropped cell would not, and dropping it would shift the whole rest of the
|
|
41228
|
+
* row left.
|
|
41229
|
+
*/
|
|
41230
|
+
function resolveCellStyle(cell) {
|
|
41231
|
+
const inverse = cell.isInverse() !== 0;
|
|
41232
|
+
const plainFg = resolveForeground(cell);
|
|
41233
|
+
const plainBg = resolveBackground(cell);
|
|
41234
|
+
const background = inverse ? plainFg : plainBg;
|
|
41235
|
+
let foreground = inverse ? plainBg : plainFg;
|
|
41236
|
+
if (cell.isDim() !== 0) foreground = blend(foreground, background, TERMINAL_DIM_WEIGHT);
|
|
41237
|
+
if (cell.isInvisible() !== 0) foreground = background;
|
|
41238
|
+
return {
|
|
41239
|
+
fg: foreground === "#d7dce2" ? null : foreground,
|
|
41240
|
+
bg: background === "#0b0d10" ? null : background,
|
|
41241
|
+
bold: cell.isBold() !== 0
|
|
41242
|
+
};
|
|
41243
|
+
}
|
|
41244
|
+
function sameStyle(left, right) {
|
|
41245
|
+
return left.fg === right.fg && left.bg === right.bg && left.bold === right.bold;
|
|
41246
|
+
}
|
|
41247
|
+
/**
|
|
41248
|
+
* Merge adjacent same-style cells into runs, then drop the trailing run of
|
|
41249
|
+
* default-styled whitespace so a row costs what it draws — the same trim
|
|
41250
|
+
* `translateToString(true)` performs. Whitespace carrying a BACKGROUND is kept:
|
|
41251
|
+
* a green bar of spaces out to the right margin is a pixel Glances drew.
|
|
41252
|
+
*/
|
|
41253
|
+
function buildCellRuns(cells) {
|
|
41254
|
+
const runs = [];
|
|
41255
|
+
let text = "";
|
|
41256
|
+
let style = null;
|
|
41257
|
+
for (const cell of cells) {
|
|
41258
|
+
if (style !== null && sameStyle(style, cell.style)) {
|
|
41259
|
+
text += cell.text;
|
|
41260
|
+
continue;
|
|
41261
|
+
}
|
|
41262
|
+
if (style !== null) runs.push({
|
|
41263
|
+
text,
|
|
41264
|
+
...style
|
|
41265
|
+
});
|
|
41266
|
+
text = cell.text;
|
|
41267
|
+
style = cell.style;
|
|
41268
|
+
}
|
|
41269
|
+
if (style !== null) runs.push({
|
|
41270
|
+
text,
|
|
41271
|
+
...style
|
|
41272
|
+
});
|
|
41273
|
+
while (runs.length > 0) {
|
|
41274
|
+
const last = runs[runs.length - 1];
|
|
41275
|
+
if (last === void 0 || last.bg !== null) break;
|
|
41276
|
+
const trimmed = last.text.replace(/\s+$/u, "");
|
|
41277
|
+
if (trimmed === last.text) break;
|
|
41278
|
+
if (trimmed === "") {
|
|
41279
|
+
runs.pop();
|
|
41280
|
+
continue;
|
|
41281
|
+
}
|
|
41282
|
+
runs[runs.length - 1] = {
|
|
41283
|
+
...last,
|
|
41284
|
+
text: trimmed
|
|
41285
|
+
};
|
|
41286
|
+
break;
|
|
41287
|
+
}
|
|
41288
|
+
return runs;
|
|
41289
|
+
}
|
|
41290
|
+
/**
|
|
41291
|
+
* Monospace families to try, in order — NOT one family and a generic.
|
|
41292
|
+
*
|
|
41293
|
+
* A terminal screen is mostly box-drawing and block characters, and a font
|
|
41294
|
+
* without them renders the frame as noise rather than as missing detail.
|
|
41295
|
+
* `DejaVu Sans Mono` covers them and ships in the hub image; macOS has neither
|
|
41296
|
+
* DejaVu nor fontconfig, so the Mac agent fell through to a generic whose
|
|
41297
|
+
* coverage is not, and its Glances camera came out unreadable while the hub's
|
|
41298
|
+
* was pixel-perfect (measured 2026-08-11, same Glances, two nodes).
|
|
41299
|
+
*
|
|
41300
|
+
* `Menlo` is the fix rather than a guess: it is macOS's default terminal face,
|
|
41301
|
+
* present on every install, and derived from DejaVu Sans Mono — the same glyph
|
|
41302
|
+
* coverage by ancestry. Monaco and Courier New follow as older fallbacks; the
|
|
41303
|
+
* generic stays last so a host with none of them still draws something.
|
|
41304
|
+
*/
|
|
41305
|
+
var TERMINAL_FONT_STACK = "DejaVu Sans Mono,Menlo,Monaco,Courier New,monospace";
|
|
41306
|
+
var TERMINAL_FONT_SIZE = 13;
|
|
41307
|
+
var TERMINAL_TEXT_MARGIN_X = 8;
|
|
41308
|
+
var TERMINAL_ROW_HEIGHT = 15;
|
|
41309
|
+
var TERMINAL_BASELINE_Y = 18;
|
|
41310
|
+
/**
|
|
41311
|
+
* Distance from a row's baseline up to the top of its cell box. Chosen so
|
|
41312
|
+
* consecutive rows tile exactly: row N's box runs from `baseline - this` for
|
|
41313
|
+
* `TERMINAL_ROW_HEIGHT`, and row N+1's box starts where it ends. A background
|
|
41314
|
+
* bar that stopped short would draw as stripes across a `CSI 42m` panel.
|
|
41315
|
+
*/
|
|
41316
|
+
var TERMINAL_CELL_ASCENT = 11.5;
|
|
41317
|
+
var TERMINAL_CELL_WIDTH = TERMINAL_FONT_SIZE * (1233 / 2048);
|
|
41318
|
+
/** Two decimals is under a tenth of a pixel and keeps the SVG small. */
|
|
41319
|
+
function coordinate(value) {
|
|
41320
|
+
return String(Number(value.toFixed(2)));
|
|
41321
|
+
}
|
|
41322
|
+
function escapeXml(value) {
|
|
41323
|
+
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
41324
|
+
}
|
|
41325
|
+
/**
|
|
41326
|
+
* Render already-interpreted terminal rows into a compact MJPEG frame.
|
|
41327
|
+
*
|
|
41328
|
+
* `xml:space="preserve"` is load-bearing, not tidiness. SVG `<text>` collapses
|
|
41329
|
+
* runs of whitespace by default, and a terminal's entire column alignment IS
|
|
41330
|
+
* runs of whitespace — Glances pads every field with spaces. Without it the
|
|
41331
|
+
* frame drew each line at roughly half its true width, crammed into the
|
|
41332
|
+
* top-left of a mostly-black image, while the SAME session over `attach`
|
|
41333
|
+
* looked perfect — which is exactly how the operator reported it. Measured in
|
|
41334
|
+
* the hub's own rasterizer 2026-08-11: `AAA<10 spaces>BBB<3>CCC` drew 92 px
|
|
41335
|
+
* collapsed against 178 px preserved.
|
|
41336
|
+
*
|
|
41337
|
+
* Every run is anchored at its OWN column (`x = margin + startCol * cellW`),
|
|
41338
|
+
* never appended to the one before it, so the background rects and the glyphs
|
|
41339
|
+
* are placed off the same grid and cannot drift apart. `textLength` is emitted
|
|
41340
|
+
* with it because it is the correct declaration and renderers that honour it
|
|
41341
|
+
* get an exact grid — but it is not what makes this work: librsvg, which sharp
|
|
41342
|
+
* uses, ignores it outright (measured 2026-08-12, a 120-glyph run pinned to
|
|
41343
|
+
* 600 px still drew its natural 937 px). The anchoring is the guarantee.
|
|
41344
|
+
*/
|
|
41345
|
+
function renderTerminalSvg(rows) {
|
|
41346
|
+
const backgrounds = [];
|
|
41347
|
+
const texts = [];
|
|
41348
|
+
rows.slice(0, 40).forEach((row, index) => {
|
|
41349
|
+
const baseline = TERMINAL_BASELINE_Y + index * TERMINAL_ROW_HEIGHT;
|
|
41350
|
+
const top = baseline - TERMINAL_CELL_ASCENT;
|
|
41351
|
+
let column = 0;
|
|
41352
|
+
for (const run of row) {
|
|
41353
|
+
if (column >= 120) break;
|
|
41354
|
+
const clipped = clipRun(run, 120 - column);
|
|
41355
|
+
const columns = [...clipped].length;
|
|
41356
|
+
if (columns === 0) continue;
|
|
41357
|
+
const x = TERMINAL_TEXT_MARGIN_X + column * TERMINAL_CELL_WIDTH;
|
|
41358
|
+
const width = columns * TERMINAL_CELL_WIDTH;
|
|
41359
|
+
if (run.bg !== null) backgrounds.push(`<rect x="${coordinate(x)}" y="${coordinate(top)}" width="${coordinate(width)}" height="${String(TERMINAL_ROW_HEIGHT)}" fill="${run.bg}"/>`);
|
|
41360
|
+
if (clipped.trim() !== "") {
|
|
41361
|
+
const fill = run.fg === null ? "" : ` fill="${run.fg}"`;
|
|
41362
|
+
const weight = run.bold ? " font-weight=\"bold\"" : "";
|
|
41363
|
+
texts.push(`<text xml:space="preserve" x="${coordinate(x)}" y="${coordinate(baseline)}" textLength="${coordinate(width)}" lengthAdjust="spacingAndGlyphs"${fill}${weight}>${escapeXml(clipped)}</text>`);
|
|
41364
|
+
}
|
|
41365
|
+
column += columns;
|
|
41366
|
+
}
|
|
41367
|
+
});
|
|
41368
|
+
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>`;
|
|
41369
|
+
}
|
|
41370
|
+
/** Cut a run to the columns still left in the row, by code point not unit. */
|
|
41371
|
+
function clipRun(run, remaining) {
|
|
41372
|
+
const points = [...run.text];
|
|
41373
|
+
return points.length <= remaining ? run.text : points.slice(0, remaining).join("");
|
|
41374
|
+
}
|
|
41375
|
+
async function renderTerminalJpeg(rows) {
|
|
41376
|
+
return (0, sharp.default)(Buffer.from(renderTerminalSvg(rows))).jpeg({
|
|
41377
|
+
quality: 82,
|
|
41378
|
+
chromaSubsampling: "4:2:0"
|
|
41379
|
+
}).toBuffer();
|
|
41380
|
+
}
|
|
41381
|
+
//#endregion
|
|
41382
|
+
//#region src/terminal-camera-device.ts
|
|
41383
|
+
var terminalCameraSchema = object({
|
|
41384
|
+
instanceId: string().min(1).optional(),
|
|
41385
|
+
nodeId: string().min(1),
|
|
41386
|
+
profileId: string().min(1).default("monitor"),
|
|
41387
|
+
profileLabel: string().min(1).default("BTM")
|
|
41388
|
+
});
|
|
41389
|
+
var relay = null;
|
|
41390
|
+
function installTerminalCameraRelay(next) {
|
|
41391
|
+
relay = next;
|
|
41392
|
+
}
|
|
41393
|
+
var TerminalCameraDevice = class extends BaseDevice {
|
|
41394
|
+
features = [DeviceFeature.NativeSnapshot];
|
|
41395
|
+
constructor(ctx) {
|
|
41396
|
+
super(ctx, terminalCameraSchema, { type: ctx.deviceMeta.type });
|
|
41397
|
+
this.ctx.registerNativeCap(streamCatalogCapability, { getCatalog: async ({ deviceId }) => {
|
|
41398
|
+
if (deviceId !== this.id) return [];
|
|
41399
|
+
return this.catalog();
|
|
41400
|
+
} });
|
|
41401
|
+
this.ctx.registerNativeCap(snapshotCapability, {
|
|
41402
|
+
getSnapshot: async ({ deviceId }) => {
|
|
41403
|
+
if (deviceId !== this.id) throw new Error(`TerminalCameraDevice: deviceId mismatch, expected ${String(this.id)}, got ${String(deviceId)}`);
|
|
41404
|
+
const activeRelay = relay;
|
|
41405
|
+
if (!activeRelay) throw new Error("terminal camera relay is unavailable");
|
|
41406
|
+
return {
|
|
41407
|
+
base64: (await activeRelay.snapshot(this.relayInstanceId(), this.config.get("nodeId"), this.config.get("profileId"))).toString("base64"),
|
|
41408
|
+
contentType: "image/jpeg"
|
|
41409
|
+
};
|
|
41410
|
+
},
|
|
41411
|
+
invalidateCache: async () => {}
|
|
41412
|
+
});
|
|
41413
|
+
this.markOnline(true);
|
|
41414
|
+
}
|
|
41415
|
+
async catalog() {
|
|
41416
|
+
const activeRelay = relay;
|
|
41417
|
+
if (!activeRelay) throw new Error("terminal camera relay is unavailable");
|
|
41418
|
+
const nodeId = this.config.get("nodeId");
|
|
41419
|
+
const profileId = this.config.get("profileId");
|
|
41420
|
+
const instanceId = this.relayInstanceId();
|
|
41421
|
+
return [{
|
|
41422
|
+
camStreamId: profileId,
|
|
41423
|
+
kind: "pull-http",
|
|
41424
|
+
url: activeRelay.streamUrl(instanceId, nodeId, profileId),
|
|
41425
|
+
codec: "h264",
|
|
41426
|
+
resolution: {
|
|
41427
|
+
width: 960,
|
|
41428
|
+
height: 640
|
|
41429
|
+
},
|
|
41430
|
+
fps: 2,
|
|
41431
|
+
label: this.config.get("profileLabel")
|
|
41432
|
+
}];
|
|
41433
|
+
}
|
|
41434
|
+
setNodeOnline(online) {
|
|
41435
|
+
this.markOnline(online);
|
|
41436
|
+
if (!online) relay?.closeInstance(this.relayInstanceId());
|
|
41437
|
+
}
|
|
41438
|
+
async removeDevice() {
|
|
41439
|
+
await relay?.closeInstance(this.relayInstanceId());
|
|
41440
|
+
}
|
|
41441
|
+
relayInstanceId() {
|
|
41442
|
+
return this.config.get("instanceId") ?? `legacy:${this.stableId}`;
|
|
41443
|
+
}
|
|
41444
|
+
};
|
|
41445
|
+
//#endregion
|
|
40747
41446
|
//#region ../../node_modules/@xterm/addon-serialize/lib/addon-serialize.js
|
|
40748
41447
|
var require_addon_serialize = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
40749
41448
|
(function(e, t) {
|
|
@@ -45551,174 +46250,9 @@ var require_xterm_headless = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
45551
46250
|
})();
|
|
45552
46251
|
}));
|
|
45553
46252
|
//#endregion
|
|
45554
|
-
//#region src/
|
|
46253
|
+
//#region src/xterm-screen.ts
|
|
45555
46254
|
var import_addon_serialize = require_addon_serialize();
|
|
45556
46255
|
var import_xterm_headless = require_xterm_headless();
|
|
45557
|
-
var TERMINAL_DEFAULT_FG = "#d7dce2";
|
|
45558
|
-
var TERMINAL_DEFAULT_BG = "#0b0d10";
|
|
45559
|
-
/**
|
|
45560
|
-
* The 16 ANSI colours, in a dark-theme variant chosen to sit with the existing
|
|
45561
|
-
* frame (`#0b0d10` ground, `#d7dce2` text) rather than the raw xterm defaults,
|
|
45562
|
-
* whose pure `#0000ff` blue and `#008000` green are close to unreadable on a
|
|
45563
|
-
* near-black background at 13px. Index 7 IS the default foreground, so plain
|
|
45564
|
-
* `CSI 37m` text renders identically to unstyled text.
|
|
45565
|
-
*/
|
|
45566
|
-
var TERMINAL_ANSI_PALETTE = [
|
|
45567
|
-
"#282c34",
|
|
45568
|
-
"#e06c75",
|
|
45569
|
-
"#98c379",
|
|
45570
|
-
"#e5c07b",
|
|
45571
|
-
"#61afef",
|
|
45572
|
-
"#c678dd",
|
|
45573
|
-
"#56b6c2",
|
|
45574
|
-
TERMINAL_DEFAULT_FG,
|
|
45575
|
-
"#5c6370",
|
|
45576
|
-
"#ef596f",
|
|
45577
|
-
"#89ca78",
|
|
45578
|
-
"#f0c674",
|
|
45579
|
-
"#6cb6ff",
|
|
45580
|
-
"#d55fde",
|
|
45581
|
-
"#2bbac5",
|
|
45582
|
-
"#ffffff"
|
|
45583
|
-
];
|
|
45584
|
-
/** The six levels of the xterm 6×6×6 colour cube (indices 16-231). */
|
|
45585
|
-
var TERMINAL_CUBE_LEVELS = [
|
|
45586
|
-
0,
|
|
45587
|
-
95,
|
|
45588
|
-
135,
|
|
45589
|
-
175,
|
|
45590
|
-
215,
|
|
45591
|
-
255
|
|
45592
|
-
];
|
|
45593
|
-
var TERMINAL_CUBE_FIRST = 16;
|
|
45594
|
-
var TERMINAL_GRAYSCALE_FIRST = 232;
|
|
45595
|
-
var TERMINAL_GRAYSCALE_BASE = 8;
|
|
45596
|
-
var TERMINAL_GRAYSCALE_STEP = 10;
|
|
45597
|
-
/** SGR 2 keeps the foreground legible; it must not become the background. */
|
|
45598
|
-
var TERMINAL_DIM_WEIGHT = .6;
|
|
45599
|
-
function channel(value) {
|
|
45600
|
-
return Math.max(0, Math.min(255, Math.round(value))).toString(16).padStart(2, "0");
|
|
45601
|
-
}
|
|
45602
|
-
function hex(red, green, blue) {
|
|
45603
|
-
return `#${channel(red)}${channel(green)}${channel(blue)}`;
|
|
45604
|
-
}
|
|
45605
|
-
function parseHex(color) {
|
|
45606
|
-
return [
|
|
45607
|
-
Number.parseInt(color.slice(1, 3), 16),
|
|
45608
|
-
Number.parseInt(color.slice(3, 5), 16),
|
|
45609
|
-
Number.parseInt(color.slice(5, 7), 16)
|
|
45610
|
-
];
|
|
45611
|
-
}
|
|
45612
|
-
/** Resolve an xterm palette index (0-255) to a hex colour. */
|
|
45613
|
-
function terminalPaletteColor(index) {
|
|
45614
|
-
const ansi = TERMINAL_ANSI_PALETTE[index];
|
|
45615
|
-
if (ansi !== void 0) return ansi;
|
|
45616
|
-
if (index >= TERMINAL_GRAYSCALE_FIRST) {
|
|
45617
|
-
const level = TERMINAL_GRAYSCALE_BASE + (index - TERMINAL_GRAYSCALE_FIRST) * TERMINAL_GRAYSCALE_STEP;
|
|
45618
|
-
return hex(level, level, level);
|
|
45619
|
-
}
|
|
45620
|
-
if (index >= TERMINAL_CUBE_FIRST) {
|
|
45621
|
-
const offset = index - TERMINAL_CUBE_FIRST;
|
|
45622
|
-
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);
|
|
45623
|
-
}
|
|
45624
|
-
return TERMINAL_DEFAULT_FG;
|
|
45625
|
-
}
|
|
45626
|
-
/** Resolve a 0xRRGGBB truecolor value to a hex colour. */
|
|
45627
|
-
function terminalRgbColor(value) {
|
|
45628
|
-
return hex(value >> 16 & 255, value >> 8 & 255, value & 255);
|
|
45629
|
-
}
|
|
45630
|
-
function blend(color, toward, weight) {
|
|
45631
|
-
const [red, green, blue] = parseHex(color);
|
|
45632
|
-
const [targetRed, targetGreen, targetBlue] = parseHex(toward);
|
|
45633
|
-
return hex(red * weight + targetRed * (1 - weight), green * weight + targetGreen * (1 - weight), blue * weight + targetBlue * (1 - weight));
|
|
45634
|
-
}
|
|
45635
|
-
function resolveForeground(cell) {
|
|
45636
|
-
if (cell.isFgRGB()) return terminalRgbColor(cell.getFgColor());
|
|
45637
|
-
if (cell.isFgPalette()) return terminalPaletteColor(cell.getFgColor());
|
|
45638
|
-
return TERMINAL_DEFAULT_FG;
|
|
45639
|
-
}
|
|
45640
|
-
function resolveBackground(cell) {
|
|
45641
|
-
if (cell.isBgRGB()) return terminalRgbColor(cell.getBgColor());
|
|
45642
|
-
if (cell.isBgPalette()) return terminalPaletteColor(cell.getBgColor());
|
|
45643
|
-
return TERMINAL_DEFAULT_BG;
|
|
45644
|
-
}
|
|
45645
|
-
/**
|
|
45646
|
-
* Resolve one cell's attributes into concrete colours.
|
|
45647
|
-
*
|
|
45648
|
-
* Inverse is applied by SWAPPING the already-resolved pair, so inverse over two
|
|
45649
|
-
* defaults is still a visible swap rather than a no-op — that is how a selected
|
|
45650
|
-
* or highlighted row in Glances reads. Invisible is then conceal-by-equality
|
|
45651
|
-
* (foreground painted in its own background): the cell keeps its columns, which
|
|
45652
|
-
* a dropped cell would not, and dropping it would shift the whole rest of the
|
|
45653
|
-
* row left.
|
|
45654
|
-
*/
|
|
45655
|
-
function resolveCellStyle(cell) {
|
|
45656
|
-
const inverse = cell.isInverse() !== 0;
|
|
45657
|
-
const plainFg = resolveForeground(cell);
|
|
45658
|
-
const plainBg = resolveBackground(cell);
|
|
45659
|
-
const background = inverse ? plainFg : plainBg;
|
|
45660
|
-
let foreground = inverse ? plainBg : plainFg;
|
|
45661
|
-
if (cell.isDim() !== 0) foreground = blend(foreground, background, TERMINAL_DIM_WEIGHT);
|
|
45662
|
-
if (cell.isInvisible() !== 0) foreground = background;
|
|
45663
|
-
return {
|
|
45664
|
-
fg: foreground === "#d7dce2" ? null : foreground,
|
|
45665
|
-
bg: background === "#0b0d10" ? null : background,
|
|
45666
|
-
bold: cell.isBold() !== 0
|
|
45667
|
-
};
|
|
45668
|
-
}
|
|
45669
|
-
function sameStyle(left, right) {
|
|
45670
|
-
return left.fg === right.fg && left.bg === right.bg && left.bold === right.bold;
|
|
45671
|
-
}
|
|
45672
|
-
/**
|
|
45673
|
-
* Merge adjacent same-style cells into runs, then drop the trailing run of
|
|
45674
|
-
* default-styled whitespace so a row costs what it draws — the same trim
|
|
45675
|
-
* `translateToString(true)` performs. Whitespace carrying a BACKGROUND is kept:
|
|
45676
|
-
* a green bar of spaces out to the right margin is a pixel Glances drew.
|
|
45677
|
-
*/
|
|
45678
|
-
function buildCellRuns(cells) {
|
|
45679
|
-
const runs = [];
|
|
45680
|
-
let text = "";
|
|
45681
|
-
let style = null;
|
|
45682
|
-
for (const cell of cells) {
|
|
45683
|
-
if (style !== null && sameStyle(style, cell.style)) {
|
|
45684
|
-
text += cell.text;
|
|
45685
|
-
continue;
|
|
45686
|
-
}
|
|
45687
|
-
if (style !== null) runs.push({
|
|
45688
|
-
text,
|
|
45689
|
-
...style
|
|
45690
|
-
});
|
|
45691
|
-
text = cell.text;
|
|
45692
|
-
style = cell.style;
|
|
45693
|
-
}
|
|
45694
|
-
if (style !== null) runs.push({
|
|
45695
|
-
text,
|
|
45696
|
-
...style
|
|
45697
|
-
});
|
|
45698
|
-
while (runs.length > 0) {
|
|
45699
|
-
const last = runs[runs.length - 1];
|
|
45700
|
-
if (last === void 0 || last.bg !== null) break;
|
|
45701
|
-
const trimmed = last.text.replace(/\s+$/u, "");
|
|
45702
|
-
if (trimmed === last.text) break;
|
|
45703
|
-
if (trimmed === "") {
|
|
45704
|
-
runs.pop();
|
|
45705
|
-
continue;
|
|
45706
|
-
}
|
|
45707
|
-
runs[runs.length - 1] = {
|
|
45708
|
-
...last,
|
|
45709
|
-
text: trimmed
|
|
45710
|
-
};
|
|
45711
|
-
break;
|
|
45712
|
-
}
|
|
45713
|
-
return runs;
|
|
45714
|
-
}
|
|
45715
|
-
//#endregion
|
|
45716
|
-
//#region src/xterm-screen.ts
|
|
45717
|
-
/**
|
|
45718
|
-
* Real {@link ScreenBuffer} backed by `@xterm/headless` — the DOM-less xterm
|
|
45719
|
-
* build — plus the serialize addon, which turns the current buffer into a
|
|
45720
|
-
* self-contained repaint escape sequence for reconnecting clients.
|
|
45721
|
-
*/
|
|
45722
46256
|
var SCROLLBACK_LINES = 2e3;
|
|
45723
46257
|
function createXtermScreen(cols, rows) {
|
|
45724
46258
|
const term = new import_xterm_headless.Terminal({
|
|
@@ -45785,196 +46319,6 @@ function createXtermScreen(cols, rows) {
|
|
|
45785
46319
|
};
|
|
45786
46320
|
}
|
|
45787
46321
|
//#endregion
|
|
45788
|
-
//#region src/terminal-camera-declarations.ts
|
|
45789
|
-
/**
|
|
45790
|
-
* Feed DeclaredDevices every live declaration plus one deterministic orphan
|
|
45791
|
-
* batch. The generic sweep intentionally refuses an over-limit set; selecting
|
|
45792
|
-
* a batch here drains large historical Terminal orphan sets across convergence
|
|
45793
|
-
* passes without weakening that global safety guard.
|
|
45794
|
-
*/
|
|
45795
|
-
function terminalCameraReconciliationIndex(rows, integrationId, declarations, managedStableIds = /* @__PURE__ */ new Set()) {
|
|
45796
|
-
if (!integrationId) return [];
|
|
45797
|
-
const declared = new Set(declarations.map((camera) => camera.stableId));
|
|
45798
|
-
const owned = rows.filter((row) => row.integrationId === integrationId && (declared.has(row.stableId) || managedStableIds.has(row.stableId) || row.stableId.startsWith("terminal-camera-instance-")));
|
|
45799
|
-
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)];
|
|
45800
|
-
}
|
|
45801
|
-
/** Explicit persisted instances, never the node × profile template matrix. */
|
|
45802
|
-
function buildTerminalInstanceCameraDeclarations(instances) {
|
|
45803
|
-
return instances.filter((instance) => instance.enabled).map((instance) => ({
|
|
45804
|
-
stableId: instance.cameraStableId,
|
|
45805
|
-
name: instance.name,
|
|
45806
|
-
config: {
|
|
45807
|
-
instanceId: instance.id,
|
|
45808
|
-
nodeId: instance.nodeId,
|
|
45809
|
-
profileId: instance.profileId,
|
|
45810
|
-
profileLabel: instance.profileLabel
|
|
45811
|
-
}
|
|
45812
|
-
}));
|
|
45813
|
-
}
|
|
45814
|
-
/**
|
|
45815
|
-
* `DeviceConfig` materializes schema defaults in memory, so comparing
|
|
45816
|
-
* `config.get()` cannot detect a legacy `{ nodeId }` row. Reconciliation must
|
|
45817
|
-
* inspect the raw persisted blob to make the profile migration durable.
|
|
45818
|
-
*/
|
|
45819
|
-
function needsTerminalCameraConfigMigration(persistedConfig, declaration) {
|
|
45820
|
-
return persistedConfig.instanceId !== declaration.config.instanceId || persistedConfig.nodeId !== declaration.config.nodeId || persistedConfig.profileId !== declaration.config.profileId || persistedConfig.profileLabel !== declaration.config.profileLabel;
|
|
45821
|
-
}
|
|
45822
|
-
/**
|
|
45823
|
-
* Monospace families to try, in order — NOT one family and a generic.
|
|
45824
|
-
*
|
|
45825
|
-
* A terminal screen is mostly box-drawing and block characters, and a font
|
|
45826
|
-
* without them renders the frame as noise rather than as missing detail.
|
|
45827
|
-
* `DejaVu Sans Mono` covers them and ships in the hub image; macOS has neither
|
|
45828
|
-
* DejaVu nor fontconfig, so the Mac agent fell through to a generic whose
|
|
45829
|
-
* coverage is not, and its Glances camera came out unreadable while the hub's
|
|
45830
|
-
* was pixel-perfect (measured 2026-08-11, same Glances, two nodes).
|
|
45831
|
-
*
|
|
45832
|
-
* `Menlo` is the fix rather than a guess: it is macOS's default terminal face,
|
|
45833
|
-
* present on every install, and derived from DejaVu Sans Mono — the same glyph
|
|
45834
|
-
* coverage by ancestry. Monaco and Courier New follow as older fallbacks; the
|
|
45835
|
-
* generic stays last so a host with none of them still draws something.
|
|
45836
|
-
*/
|
|
45837
|
-
var TERMINAL_FONT_STACK = "DejaVu Sans Mono,Menlo,Monaco,Courier New,monospace";
|
|
45838
|
-
var TERMINAL_FONT_SIZE = 13;
|
|
45839
|
-
var TERMINAL_TEXT_MARGIN_X = 8;
|
|
45840
|
-
var TERMINAL_ROW_HEIGHT = 15;
|
|
45841
|
-
var TERMINAL_BASELINE_Y = 18;
|
|
45842
|
-
/**
|
|
45843
|
-
* Distance from a row's baseline up to the top of its cell box. Chosen so
|
|
45844
|
-
* consecutive rows tile exactly: row N's box runs from `baseline - this` for
|
|
45845
|
-
* `TERMINAL_ROW_HEIGHT`, and row N+1's box starts where it ends. A background
|
|
45846
|
-
* bar that stopped short would draw as stripes across a `CSI 42m` panel.
|
|
45847
|
-
*/
|
|
45848
|
-
var TERMINAL_CELL_ASCENT = 11.5;
|
|
45849
|
-
var TERMINAL_CELL_WIDTH = TERMINAL_FONT_SIZE * (1233 / 2048);
|
|
45850
|
-
/** Two decimals is under a tenth of a pixel and keeps the SVG small. */
|
|
45851
|
-
function coordinate(value) {
|
|
45852
|
-
return String(Number(value.toFixed(2)));
|
|
45853
|
-
}
|
|
45854
|
-
function escapeXml(value) {
|
|
45855
|
-
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
45856
|
-
}
|
|
45857
|
-
/**
|
|
45858
|
-
* Render already-interpreted terminal rows into a compact MJPEG frame.
|
|
45859
|
-
*
|
|
45860
|
-
* `xml:space="preserve"` is load-bearing, not tidiness. SVG `<text>` collapses
|
|
45861
|
-
* runs of whitespace by default, and a terminal's entire column alignment IS
|
|
45862
|
-
* runs of whitespace — Glances pads every field with spaces. Without it the
|
|
45863
|
-
* frame drew each line at roughly half its true width, crammed into the
|
|
45864
|
-
* top-left of a mostly-black image, while the SAME session over `attach`
|
|
45865
|
-
* looked perfect — which is exactly how the operator reported it. Measured in
|
|
45866
|
-
* the hub's own rasterizer 2026-08-11: `AAA<10 spaces>BBB<3>CCC` drew 92 px
|
|
45867
|
-
* collapsed against 178 px preserved.
|
|
45868
|
-
*
|
|
45869
|
-
* Every run is anchored at its OWN column (`x = margin + startCol * cellW`),
|
|
45870
|
-
* never appended to the one before it, so the background rects and the glyphs
|
|
45871
|
-
* are placed off the same grid and cannot drift apart. `textLength` is emitted
|
|
45872
|
-
* with it because it is the correct declaration and renderers that honour it
|
|
45873
|
-
* get an exact grid — but it is not what makes this work: librsvg, which sharp
|
|
45874
|
-
* uses, ignores it outright (measured 2026-08-12, a 120-glyph run pinned to
|
|
45875
|
-
* 600 px still drew its natural 937 px). The anchoring is the guarantee.
|
|
45876
|
-
*/
|
|
45877
|
-
function renderTerminalSvg(rows) {
|
|
45878
|
-
const backgrounds = [];
|
|
45879
|
-
const texts = [];
|
|
45880
|
-
rows.slice(0, 40).forEach((row, index) => {
|
|
45881
|
-
const baseline = TERMINAL_BASELINE_Y + index * TERMINAL_ROW_HEIGHT;
|
|
45882
|
-
const top = baseline - TERMINAL_CELL_ASCENT;
|
|
45883
|
-
let column = 0;
|
|
45884
|
-
for (const run of row) {
|
|
45885
|
-
if (column >= 120) break;
|
|
45886
|
-
const clipped = clipRun(run, 120 - column);
|
|
45887
|
-
const columns = [...clipped].length;
|
|
45888
|
-
if (columns === 0) continue;
|
|
45889
|
-
const x = TERMINAL_TEXT_MARGIN_X + column * TERMINAL_CELL_WIDTH;
|
|
45890
|
-
const width = columns * TERMINAL_CELL_WIDTH;
|
|
45891
|
-
if (run.bg !== null) backgrounds.push(`<rect x="${coordinate(x)}" y="${coordinate(top)}" width="${coordinate(width)}" height="${String(TERMINAL_ROW_HEIGHT)}" fill="${run.bg}"/>`);
|
|
45892
|
-
if (clipped.trim() !== "") {
|
|
45893
|
-
const fill = run.fg === null ? "" : ` fill="${run.fg}"`;
|
|
45894
|
-
const weight = run.bold ? " font-weight=\"bold\"" : "";
|
|
45895
|
-
texts.push(`<text xml:space="preserve" x="${coordinate(x)}" y="${coordinate(baseline)}" textLength="${coordinate(width)}" lengthAdjust="spacingAndGlyphs"${fill}${weight}>${escapeXml(clipped)}</text>`);
|
|
45896
|
-
}
|
|
45897
|
-
column += columns;
|
|
45898
|
-
}
|
|
45899
|
-
});
|
|
45900
|
-
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>`;
|
|
45901
|
-
}
|
|
45902
|
-
/** Cut a run to the columns still left in the row, by code point not unit. */
|
|
45903
|
-
function clipRun(run, remaining) {
|
|
45904
|
-
const points = [...run.text];
|
|
45905
|
-
return points.length <= remaining ? run.text : points.slice(0, remaining).join("");
|
|
45906
|
-
}
|
|
45907
|
-
async function renderTerminalJpeg(rows) {
|
|
45908
|
-
return (0, sharp.default)(Buffer.from(renderTerminalSvg(rows))).jpeg({
|
|
45909
|
-
quality: 82,
|
|
45910
|
-
chromaSubsampling: "4:2:0"
|
|
45911
|
-
}).toBuffer();
|
|
45912
|
-
}
|
|
45913
|
-
//#endregion
|
|
45914
|
-
//#region src/terminal-camera-device.ts
|
|
45915
|
-
var terminalCameraSchema = object({
|
|
45916
|
-
instanceId: string().min(1).optional(),
|
|
45917
|
-
nodeId: string().min(1),
|
|
45918
|
-
profileId: string().min(1).default("monitor"),
|
|
45919
|
-
profileLabel: string().min(1).default("BTM")
|
|
45920
|
-
});
|
|
45921
|
-
var relay = null;
|
|
45922
|
-
function installTerminalCameraRelay(next) {
|
|
45923
|
-
relay = next;
|
|
45924
|
-
}
|
|
45925
|
-
var TerminalCameraDevice = class extends BaseDevice {
|
|
45926
|
-
features = [DeviceFeature.NativeSnapshot];
|
|
45927
|
-
constructor(ctx) {
|
|
45928
|
-
super(ctx, terminalCameraSchema, { type: ctx.deviceMeta.type });
|
|
45929
|
-
this.ctx.registerNativeCap(streamCatalogCapability, { getCatalog: async ({ deviceId }) => {
|
|
45930
|
-
if (deviceId !== this.id) return [];
|
|
45931
|
-
return this.catalog();
|
|
45932
|
-
} });
|
|
45933
|
-
this.ctx.registerNativeCap(snapshotCapability, {
|
|
45934
|
-
getSnapshot: async ({ deviceId }) => {
|
|
45935
|
-
if (deviceId !== this.id) throw new Error(`TerminalCameraDevice: deviceId mismatch, expected ${String(this.id)}, got ${String(deviceId)}`);
|
|
45936
|
-
const activeRelay = relay;
|
|
45937
|
-
if (!activeRelay) throw new Error("terminal camera relay is unavailable");
|
|
45938
|
-
return {
|
|
45939
|
-
base64: (await activeRelay.snapshot(this.relayInstanceId(), this.config.get("nodeId"), this.config.get("profileId"))).toString("base64"),
|
|
45940
|
-
contentType: "image/jpeg"
|
|
45941
|
-
};
|
|
45942
|
-
},
|
|
45943
|
-
invalidateCache: async () => {}
|
|
45944
|
-
});
|
|
45945
|
-
this.markOnline(true);
|
|
45946
|
-
}
|
|
45947
|
-
async catalog() {
|
|
45948
|
-
const activeRelay = relay;
|
|
45949
|
-
if (!activeRelay) throw new Error("terminal camera relay is unavailable");
|
|
45950
|
-
const nodeId = this.config.get("nodeId");
|
|
45951
|
-
const profileId = this.config.get("profileId");
|
|
45952
|
-
const instanceId = this.relayInstanceId();
|
|
45953
|
-
return [{
|
|
45954
|
-
camStreamId: profileId,
|
|
45955
|
-
kind: "pull-http",
|
|
45956
|
-
url: activeRelay.streamUrl(instanceId, nodeId, profileId),
|
|
45957
|
-
codec: "h264",
|
|
45958
|
-
resolution: {
|
|
45959
|
-
width: 960,
|
|
45960
|
-
height: 640
|
|
45961
|
-
},
|
|
45962
|
-
fps: 2,
|
|
45963
|
-
label: this.config.get("profileLabel")
|
|
45964
|
-
}];
|
|
45965
|
-
}
|
|
45966
|
-
setNodeOnline(online) {
|
|
45967
|
-
this.markOnline(online);
|
|
45968
|
-
if (!online) relay?.closeInstance(this.relayInstanceId());
|
|
45969
|
-
}
|
|
45970
|
-
async removeDevice() {
|
|
45971
|
-
await relay?.closeInstance(this.relayInstanceId());
|
|
45972
|
-
}
|
|
45973
|
-
relayInstanceId() {
|
|
45974
|
-
return this.config.get("instanceId") ?? `legacy:${this.stableId}`;
|
|
45975
|
-
}
|
|
45976
|
-
};
|
|
45977
|
-
//#endregion
|
|
45978
46322
|
//#region src/terminal-camera-relay.ts
|
|
45979
46323
|
var MJPEG_BOUNDARY = "camstack-terminal-frame";
|
|
45980
46324
|
var SESSION_IDLE_MS = 3e4;
|
|
@@ -46525,13 +46869,34 @@ function newTerminalCameraStableId(instanceId) {
|
|
|
46525
46869
|
* Legacy automatic cameras are migration candidates only. A tombstone is
|
|
46526
46870
|
* durable deletion intent, so a lingering failed device removal must never
|
|
46527
46871
|
* make that camera adoptable again.
|
|
46872
|
+
*
|
|
46873
|
+
* ## `config` is load-bearing — this read can never be `projection: 'slim'`
|
|
46874
|
+
*
|
|
46875
|
+
* `nodeId`, `profileId` and `profileLabel` all live in the device's `config`,
|
|
46876
|
+
* and a row without `nodeId` is skipped. The slim projection returns
|
|
46877
|
+
* `config: {}` for every row, so a slim answer here is shape-identical to a
|
|
46878
|
+
* fleet that has no legacy cameras — the whole migration section disappears
|
|
46879
|
+
* and nothing says why. `legacy-camera-read-shape.spec.ts` is the arm on that.
|
|
46880
|
+
*
|
|
46881
|
+
* `onSkipped` is why the disappearance would now be visible: a row that LOOKS
|
|
46882
|
+
* like a legacy camera (`terminal-camera-*`, not an instance camera, not
|
|
46883
|
+
* tombstoned, not already adopted) but carries no `nodeId` is reported with
|
|
46884
|
+
* its numeric device id, so the caller can log it per-camera. Rows that are
|
|
46885
|
+
* not candidates at all are silent — a fleet of 1 017 devices must not
|
|
46886
|
+
* produce 1 017 lines to say none of them is a Terminal monitor.
|
|
46528
46887
|
*/
|
|
46529
|
-
function listLegacyTerminalCameraCandidates(rows, instanceStableIds, tombstones) {
|
|
46888
|
+
function listLegacyTerminalCameraCandidates(rows, instanceStableIds, tombstones, onSkipped) {
|
|
46530
46889
|
const legacy = [];
|
|
46531
46890
|
for (const row of rows) {
|
|
46532
46891
|
if (tombstones.has(row.stableId) || instanceStableIds.has(row.stableId) || row.stableId.startsWith("terminal-camera-instance-") || !row.stableId.startsWith("terminal-camera-")) continue;
|
|
46533
46892
|
const nodeId = typeof row.config.nodeId === "string" ? row.config.nodeId : null;
|
|
46534
|
-
if (!nodeId)
|
|
46893
|
+
if (!nodeId) {
|
|
46894
|
+
onSkipped?.({
|
|
46895
|
+
deviceId: row.id,
|
|
46896
|
+
stableId: row.stableId
|
|
46897
|
+
});
|
|
46898
|
+
continue;
|
|
46899
|
+
}
|
|
46535
46900
|
const profileId = typeof row.config.profileId === "string" ? row.config.profileId : "monitor";
|
|
46536
46901
|
const profileLabel = typeof row.config.profileLabel === "string" ? row.config.profileLabel : profileId === "monitor" ? "BTM" : profileId;
|
|
46537
46902
|
legacy.push({
|
|
@@ -46692,111 +47057,6 @@ function findProfile(profiles, profileId) {
|
|
|
46692
47057
|
return profiles.find((p) => p.profileId === profileId);
|
|
46693
47058
|
}
|
|
46694
47059
|
//#endregion
|
|
46695
|
-
//#region src/profile-settings.ts
|
|
46696
|
-
var GLANCES_PLUGINS = [
|
|
46697
|
-
{
|
|
46698
|
-
key: "showCpu",
|
|
46699
|
-
plugin: "cpu",
|
|
46700
|
-
label: "CPU"
|
|
46701
|
-
},
|
|
46702
|
-
{
|
|
46703
|
-
key: "showMem",
|
|
46704
|
-
plugin: "mem",
|
|
46705
|
-
label: "Memory"
|
|
46706
|
-
},
|
|
46707
|
-
{
|
|
46708
|
-
key: "showLoad",
|
|
46709
|
-
plugin: "load",
|
|
46710
|
-
label: "Load"
|
|
46711
|
-
},
|
|
46712
|
-
{
|
|
46713
|
-
key: "showNetwork",
|
|
46714
|
-
plugin: "network",
|
|
46715
|
-
label: "Network"
|
|
46716
|
-
},
|
|
46717
|
-
{
|
|
46718
|
-
key: "showDiskIo",
|
|
46719
|
-
plugin: "diskio",
|
|
46720
|
-
label: "Disk I/O"
|
|
46721
|
-
},
|
|
46722
|
-
{
|
|
46723
|
-
key: "showFs",
|
|
46724
|
-
plugin: "fs",
|
|
46725
|
-
label: "Filesystems"
|
|
46726
|
-
},
|
|
46727
|
-
{
|
|
46728
|
-
key: "showProcessList",
|
|
46729
|
-
plugin: "processlist",
|
|
46730
|
-
label: "Process list"
|
|
46731
|
-
},
|
|
46732
|
-
{
|
|
46733
|
-
key: "showContainers",
|
|
46734
|
-
plugin: "containers",
|
|
46735
|
-
label: "Containers"
|
|
46736
|
-
},
|
|
46737
|
-
{
|
|
46738
|
-
key: "showSensors",
|
|
46739
|
-
plugin: "sensors",
|
|
46740
|
-
label: "Sensors"
|
|
46741
|
-
}
|
|
46742
|
-
];
|
|
46743
|
-
function glancesBooleanField(key, label) {
|
|
46744
|
-
return {
|
|
46745
|
-
type: "boolean",
|
|
46746
|
-
key,
|
|
46747
|
-
label,
|
|
46748
|
-
default: true,
|
|
46749
|
-
style: "switch"
|
|
46750
|
-
};
|
|
46751
|
-
}
|
|
46752
|
-
function glancesSettingsSchema() {
|
|
46753
|
-
return { sections: [{
|
|
46754
|
-
id: "glances-panels",
|
|
46755
|
-
title: "Glances panels",
|
|
46756
|
-
description: "Turn off a panel to pass --disable-plugin to this Terminal only. All on is the measured default (~1% of one core at the camera grid).",
|
|
46757
|
-
columns: 2,
|
|
46758
|
-
fields: GLANCES_PLUGINS.map((plugin) => glancesBooleanField(plugin.key, plugin.label))
|
|
46759
|
-
}] };
|
|
46760
|
-
}
|
|
46761
|
-
function settingsSchemaForProfile(profileId) {
|
|
46762
|
-
if (profileId === "glances") return glancesSettingsSchema();
|
|
46763
|
-
return null;
|
|
46764
|
-
}
|
|
46765
|
-
function glancesSettingsToArgs(settings) {
|
|
46766
|
-
const disabled = GLANCES_PLUGINS.filter((plugin) => settings[plugin.key] === false).map((plugin) => plugin.plugin);
|
|
46767
|
-
if (disabled.length === 0) return [];
|
|
46768
|
-
return ["--disable-plugin", disabled.join(",")];
|
|
46769
|
-
}
|
|
46770
|
-
function sanitizeProfileSettings(profileId, raw) {
|
|
46771
|
-
if (profileId !== "glances") return {};
|
|
46772
|
-
const bag = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
46773
|
-
const out = {
|
|
46774
|
-
showCpu: true,
|
|
46775
|
-
showMem: true,
|
|
46776
|
-
showLoad: true,
|
|
46777
|
-
showNetwork: true,
|
|
46778
|
-
showDiskIo: true,
|
|
46779
|
-
showFs: true,
|
|
46780
|
-
showProcessList: true,
|
|
46781
|
-
showContainers: true,
|
|
46782
|
-
showSensors: true
|
|
46783
|
-
};
|
|
46784
|
-
for (const plugin of GLANCES_PLUGINS) {
|
|
46785
|
-
const value = bag[plugin.key];
|
|
46786
|
-
if (typeof value === "boolean") out[plugin.key] = value;
|
|
46787
|
-
}
|
|
46788
|
-
return out;
|
|
46789
|
-
}
|
|
46790
|
-
function profileSettingsToArgs(profileId, settings) {
|
|
46791
|
-
if (profileId !== "glances") return [];
|
|
46792
|
-
return glancesSettingsToArgs(sanitizeProfileSettings(profileId, settings));
|
|
46793
|
-
}
|
|
46794
|
-
function spawnArgsForInstance(input) {
|
|
46795
|
-
const extra = profileSettingsToArgs(input.profileId, input.profileSettings);
|
|
46796
|
-
if (input.instanceArgs.length > 0) return [...input.instanceArgs, ...extra];
|
|
46797
|
-
if (extra.length > 0) return [...input.profileArgs, ...extra];
|
|
46798
|
-
}
|
|
46799
|
-
//#endregion
|
|
46800
47060
|
//#region src/terminal-session-manager.ts
|
|
46801
47061
|
var MIN_GRID = 1;
|
|
46802
47062
|
var MAX_COLS = 1e3;
|
|
@@ -47618,7 +47878,12 @@ var TerminalAddon = class extends BaseAddon {
|
|
|
47618
47878
|
async listLegacyTerminalCameras() {
|
|
47619
47879
|
const instances = this.terminalInstances();
|
|
47620
47880
|
const instanceStableIds = new Set(instances.map((instance) => instance.cameraStableId));
|
|
47621
|
-
return listLegacyTerminalCameraCandidates(await this.ctx.api.deviceManager.listAll.query({ addonId: this.ctx.id }), instanceStableIds, this.terminalCameraTombstones)
|
|
47881
|
+
return listLegacyTerminalCameraCandidates(await this.ctx.api.deviceManager.listAll.query({ addonId: this.ctx.id }), instanceStableIds, this.terminalCameraTombstones, ({ deviceId, stableId }) => {
|
|
47882
|
+
this.ctx.logger.warn("legacy Terminal camera skipped — its device config carries no nodeId, so it cannot be offered for adoption", {
|
|
47883
|
+
tags: { deviceId },
|
|
47884
|
+
meta: { stableId }
|
|
47885
|
+
});
|
|
47886
|
+
});
|
|
47622
47887
|
}
|
|
47623
47888
|
async adoptLegacyMonitor(stableId, requestedName) {
|
|
47624
47889
|
const instance = await this.instanceMutationQueue.run(() => this.adoptLegacyMonitorUnlocked(stableId, requestedName));
|