@camstack/addon-terminal 0.1.30 → 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.
- package/dist/addon.js +608 -375
- package/dist/addon.mjs +608 -375
- package/package.json +1 -1
package/dist/addon.js
CHANGED
|
@@ -8119,6 +8119,15 @@ var LabelDefinitionSchema = object({
|
|
|
8119
8119
|
description: string().optional(),
|
|
8120
8120
|
icon: string().optional()
|
|
8121
8121
|
});
|
|
8122
|
+
var ClassMapDefinitionSchema = object({
|
|
8123
|
+
mapping: record(string(), _enum([
|
|
8124
|
+
"person",
|
|
8125
|
+
"vehicle",
|
|
8126
|
+
"animal",
|
|
8127
|
+
"package"
|
|
8128
|
+
])),
|
|
8129
|
+
preserveOriginal: boolean()
|
|
8130
|
+
});
|
|
8122
8131
|
var MODEL_FORMATS = [
|
|
8123
8132
|
"onnx",
|
|
8124
8133
|
"coreml",
|
|
@@ -8297,7 +8306,13 @@ var ModelCatalogEntrySchema = object({
|
|
|
8297
8306
|
* `id` stays the source of truth for resolution/download/persistence; grouping
|
|
8298
8307
|
* is a presentation overlay resolved back to an `id`.
|
|
8299
8308
|
*/
|
|
8300
|
-
group: ModelVariantGroupSchema.optional()
|
|
8309
|
+
group: ModelVariantGroupSchema.optional(),
|
|
8310
|
+
/**
|
|
8311
|
+
* Per-MODEL class map override. Absent ⇒ the step's `StepDefinition.classMap`
|
|
8312
|
+
* applies (Frigate / COCO public catalog). Set on a custom model whose raw
|
|
8313
|
+
* labels already ARE the CamStack macros (Scrypted identity map).
|
|
8314
|
+
*/
|
|
8315
|
+
classMap: ClassMapDefinitionSchema.optional()
|
|
8301
8316
|
});
|
|
8302
8317
|
var ConvertTargetSchema = discriminatedUnion("format", [object({
|
|
8303
8318
|
format: literal("openvino"),
|
|
@@ -8326,7 +8341,8 @@ var ModelConvertMetadataSchema = object({
|
|
|
8326
8341
|
"ocr",
|
|
8327
8342
|
"segmentation"
|
|
8328
8343
|
]),
|
|
8329
|
-
faceAlignment: boolean().optional()
|
|
8344
|
+
faceAlignment: boolean().optional(),
|
|
8345
|
+
classMap: ClassMapDefinitionSchema.optional()
|
|
8330
8346
|
});
|
|
8331
8347
|
var ConvertResultSchema = object({
|
|
8332
8348
|
entry: ModelCatalogEntrySchema,
|
|
@@ -17564,6 +17580,33 @@ var NativeCropRefSchema = object({
|
|
|
17564
17580
|
h: number()
|
|
17565
17581
|
})
|
|
17566
17582
|
});
|
|
17583
|
+
object({
|
|
17584
|
+
crop: object({
|
|
17585
|
+
left: number(),
|
|
17586
|
+
top: number(),
|
|
17587
|
+
width: number().positive(),
|
|
17588
|
+
height: number().positive()
|
|
17589
|
+
}).optional(),
|
|
17590
|
+
content: object({
|
|
17591
|
+
width: number().int().positive(),
|
|
17592
|
+
height: number().int().positive()
|
|
17593
|
+
}),
|
|
17594
|
+
fit: _enum(["stretch", "contain"]),
|
|
17595
|
+
format: _enum([
|
|
17596
|
+
"rgb",
|
|
17597
|
+
"gray",
|
|
17598
|
+
"jpeg"
|
|
17599
|
+
])
|
|
17600
|
+
});
|
|
17601
|
+
var FrameRefSchema = object({
|
|
17602
|
+
registryId: string().min(1),
|
|
17603
|
+
id: string().min(1),
|
|
17604
|
+
width: number().int().positive(),
|
|
17605
|
+
height: number().int().positive(),
|
|
17606
|
+
format: _enum(["rgb", "gray"]),
|
|
17607
|
+
timestamp: number(),
|
|
17608
|
+
capturedAt: number().optional()
|
|
17609
|
+
});
|
|
17567
17610
|
var ModelFormatSchema$1 = _enum([
|
|
17568
17611
|
"onnx",
|
|
17569
17612
|
"coreml",
|
|
@@ -17808,6 +17851,12 @@ method(_void(), array(PipelineEngineChoiceSchema)), method(_void(), PipelineEngi
|
|
|
17808
17851
|
steps: array(PipelineStepInputSchema).min(1),
|
|
17809
17852
|
frame: FrameInputSchema.optional(),
|
|
17810
17853
|
/**
|
|
17854
|
+
* Process-local lazy frame. Valid only when caller and provider resolve
|
|
17855
|
+
* in the same execution-group process; split/cross-node callers use
|
|
17856
|
+
* `frame`/`image` inline compatibility instead.
|
|
17857
|
+
*/
|
|
17858
|
+
frameRef: FrameRefSchema.optional(),
|
|
17859
|
+
/**
|
|
17811
17860
|
* CB5 shm passthrough — a `FrameHandle` naming the same ring slot
|
|
17812
17861
|
* the decoded pixels live in. One more member of the one-of
|
|
17813
17862
|
* frame/frameHandle/image/imageBase64/referenceImage group.
|
|
@@ -18103,7 +18152,10 @@ var NativeCropResultSchema = object({
|
|
|
18103
18152
|
* Which source served this crop, so a quality-sensitive consumer (the native
|
|
18104
18153
|
* `keyFrame`) can reject a degraded fallback:
|
|
18105
18154
|
* - `native` — cut from the decode worker's retained NATIVE surface (the
|
|
18106
|
-
* quality path).
|
|
18155
|
+
* quality path). A subject-tile serve is also native-resolution and stays
|
|
18156
|
+
* `native` here: the public enum cannot name `tile` without a breaking cap
|
|
18157
|
+
* change. Runner telemetry distinguishes lease vs tile via `source` on the
|
|
18158
|
+
* internal crop result (`nativeHits` vs `tileHits`).
|
|
18107
18159
|
* - `ram-fullframe` — the native surface MISSED but the request was full-frame,
|
|
18108
18160
|
* so the ≤640 RAM `RetainedFrameStore` served it (honest lower-res; legit for
|
|
18109
18161
|
* the blank-frame guard / 640-snapshot resolve, NOT for the clean keyFrame).
|
|
@@ -18594,12 +18646,41 @@ var RunnerLocalLoadSchema = object({
|
|
|
18594
18646
|
* legacy `OrchestratorMetricsSchema` shape so existing dashboards keep
|
|
18595
18647
|
* working unchanged when they switch to reading from the runner cap.
|
|
18596
18648
|
*/
|
|
18649
|
+
var FrameLazyCountersSchema = object({
|
|
18650
|
+
framesDecoded: number(),
|
|
18651
|
+
framesAdmitted: number(),
|
|
18652
|
+
framesDroppedPixelFree: number(),
|
|
18653
|
+
viewsMaterialized: number(),
|
|
18654
|
+
viewsSkipped: number(),
|
|
18655
|
+
workerToRunnerBytes: number(),
|
|
18656
|
+
runnerToPoolRawBytes: number(),
|
|
18657
|
+
runnerToPoolJpegBytes: number(),
|
|
18658
|
+
onDemandFullFrameRequests: number(),
|
|
18659
|
+
onDemandCropRequests: number(),
|
|
18660
|
+
nativeHits: number(),
|
|
18661
|
+
nativeMisses: number(),
|
|
18662
|
+
tileHits: number(),
|
|
18663
|
+
tileMisses: number(),
|
|
18664
|
+
fallbackHits: number(),
|
|
18665
|
+
fallbackMisses: number(),
|
|
18666
|
+
retainedWritesAvoided: number(),
|
|
18667
|
+
residentRefs: number(),
|
|
18668
|
+
residentBytes: number(),
|
|
18669
|
+
releases: number(),
|
|
18670
|
+
evictions: number(),
|
|
18671
|
+
staleMisses: number()
|
|
18672
|
+
});
|
|
18673
|
+
var FrameLazyMetricsSchema = object({
|
|
18674
|
+
node: FrameLazyCountersSchema,
|
|
18675
|
+
cameras: array(FrameLazyCountersSchema.extend({ deviceId: number() }))
|
|
18676
|
+
});
|
|
18597
18677
|
var RunnerLocalMetricsSchema = object({
|
|
18598
18678
|
nodeId: string(),
|
|
18599
18679
|
activeCameras: number(),
|
|
18600
18680
|
throttledCameras: number(),
|
|
18601
18681
|
avgInferenceTimeMs: number(),
|
|
18602
|
-
queueDepth: number()
|
|
18682
|
+
queueDepth: number(),
|
|
18683
|
+
frameLazy: FrameLazyMetricsSchema.optional()
|
|
18603
18684
|
});
|
|
18604
18685
|
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({
|
|
18605
18686
|
handle: FrameHandleSchema,
|
|
@@ -20003,6 +20084,9 @@ method(_void(), ProviderInfoSchema), method(object({ config: record(string(), un
|
|
|
20003
20084
|
location: StorageLocationSchema,
|
|
20004
20085
|
relativePath: string()
|
|
20005
20086
|
}), _void(), { kind: "mutation" }), method(object({ location: StorageLocationSchema }), number().nullable()), method(BeginUploadInputSchema, BeginUploadResultSchema, { kind: "mutation" }), method(WriteChunkInputSchema, _void(), { kind: "mutation" }), method(FinalizeUploadInputSchema, _void(), { kind: "mutation" }), method(AbortUploadInputSchema, _void(), { kind: "mutation" }), method(BeginDownloadInputSchema, BeginDownloadResultSchema, { kind: "mutation" }), method(ReadChunkInputSchema, _instanceof(Uint8Array)), method(EndDownloadInputSchema, _void(), { kind: "mutation" });
|
|
20087
|
+
/** Profile-exported FormBuilder schema. Shape is ConfigUISchema at the UI. */
|
|
20088
|
+
var ProfileSettingsSchemaBridge = unknown().nullable();
|
|
20089
|
+
var ProfileSettingsBagSchema = record(string(), unknown());
|
|
20006
20090
|
/**
|
|
20007
20091
|
* A live terminal session hosted by the provider addon. Output and input do
|
|
20008
20092
|
* NOT flow through the capability — they use the addon data plane
|
|
@@ -20037,7 +20121,9 @@ var TerminalProfileInfoSchema = object({
|
|
|
20037
20121
|
executable: string().optional(),
|
|
20038
20122
|
args: array(string()).readonly().optional(),
|
|
20039
20123
|
cwd: string().optional(),
|
|
20040
|
-
environment: array(string()).readonly().optional()
|
|
20124
|
+
environment: array(string()).readonly().optional(),
|
|
20125
|
+
/** ConfigUISchema for instance knobs, or null when the profile has none. */
|
|
20126
|
+
settingsSchema: ProfileSettingsSchemaBridge.optional()
|
|
20041
20127
|
});
|
|
20042
20128
|
/**
|
|
20043
20129
|
* A durable operator-created Terminal instance. Profiles are templates; only
|
|
@@ -20054,7 +20140,8 @@ var TerminalInstanceInfoSchema = object({
|
|
|
20054
20140
|
executable: string(),
|
|
20055
20141
|
args: array(string()).readonly(),
|
|
20056
20142
|
cwd: string(),
|
|
20057
|
-
environment: array(string()).readonly()
|
|
20143
|
+
environment: array(string()).readonly(),
|
|
20144
|
+
profileSettings: ProfileSettingsBagSchema
|
|
20058
20145
|
});
|
|
20059
20146
|
var TerminalLegacyCameraSchema = object({
|
|
20060
20147
|
stableId: string(),
|
|
@@ -20104,7 +20191,8 @@ var terminalSessionCapability = {
|
|
|
20104
20191
|
executable: string().max(1024).optional(),
|
|
20105
20192
|
args: array(string().max(2048)).max(64).optional(),
|
|
20106
20193
|
cwd: string().max(1024).optional(),
|
|
20107
|
-
environment: array(string().max(4096)).max(64).optional()
|
|
20194
|
+
environment: array(string().max(4096)).max(64).optional(),
|
|
20195
|
+
profileSettings: ProfileSettingsBagSchema.optional()
|
|
20108
20196
|
}), TerminalInstanceInfoSchema, {
|
|
20109
20197
|
kind: "mutation",
|
|
20110
20198
|
auth: "admin"
|
|
@@ -20115,7 +20203,8 @@ var terminalSessionCapability = {
|
|
|
20115
20203
|
executable: string().max(1024).optional(),
|
|
20116
20204
|
args: array(string().max(2048)).max(64).optional(),
|
|
20117
20205
|
cwd: string().max(1024).optional(),
|
|
20118
|
-
environment: array(string().max(4096)).max(64).optional()
|
|
20206
|
+
environment: array(string().max(4096)).max(64).optional(),
|
|
20207
|
+
profileSettings: ProfileSettingsBagSchema.optional()
|
|
20119
20208
|
}), TerminalInstanceInfoSchema, {
|
|
20120
20209
|
kind: "mutation",
|
|
20121
20210
|
auth: "admin"
|
|
@@ -24043,10 +24132,10 @@ var lawnMowerControlCapability = {
|
|
|
24043
24132
|
*
|
|
24044
24133
|
* • The SDK (mobile / web client) consumes `getConnectionEndpoints()`
|
|
24045
24134
|
* to receive an ordered list of candidate base URLs it should race
|
|
24046
|
-
* on connect — LAN IPv4 first (lowest latency
|
|
24047
|
-
* then public hostname (if a tunnel is
|
|
24048
|
-
* race them with short timeouts and stick with the
|
|
24049
|
-
* session.
|
|
24135
|
+
* on connect — LAN IPv4 and stable LAN IPv6 first (lowest latency
|
|
24136
|
+
* when on the same network), then public hostname (if a tunnel is
|
|
24137
|
+
* up). The SDK can race them with short timeouts and stick with the
|
|
24138
|
+
* winner for the session.
|
|
24050
24139
|
*
|
|
24051
24140
|
* Why hub-only: agents are not directly addressable by the operator's
|
|
24052
24141
|
* clients — they reverse-connect to the hub. Exposing their interfaces
|
|
@@ -24201,6 +24290,17 @@ var NotificationEndpointSchema = object({
|
|
|
24201
24290
|
/** What the ranking currently resolves to (null when nothing is reachable). */
|
|
24202
24291
|
resolved: string().nullable()
|
|
24203
24292
|
});
|
|
24293
|
+
/**
|
|
24294
|
+
* The URLs the SDK / viewer should race for API access. `baseUrls` empty =
|
|
24295
|
+
* AUTO (every LAN IPv4 + the public tunnel). `resolved` is what that choice
|
|
24296
|
+
* currently expands to, so the UI can show the effective set either way.
|
|
24297
|
+
*/
|
|
24298
|
+
var ViewerEndpointsSchema = object({
|
|
24299
|
+
/** The operator's explicit race set, or empty for AUTO. */
|
|
24300
|
+
baseUrls: array(string()).readonly(),
|
|
24301
|
+
/** What the ranking currently resolves to (may be empty if nothing is up). */
|
|
24302
|
+
resolved: array(string()).readonly()
|
|
24303
|
+
});
|
|
24204
24304
|
var AllowedAddressesSchema = object({
|
|
24205
24305
|
/**
|
|
24206
24306
|
* Allowlist of interface addresses operators have explicitly opted
|
|
@@ -24232,17 +24332,18 @@ method(_void(), ListResultSchema), method(_void(), PreferredSchema), method(obje
|
|
|
24232
24332
|
*/
|
|
24233
24333
|
port: number().int().min(1).max(65535).optional(),
|
|
24234
24334
|
/** Include `http(s)://127.0.0.1:<port>` as the lowest-priority
|
|
24235
|
-
* candidate. Default `
|
|
24335
|
+
* candidate. Default `false` — loopback is not a client route. */
|
|
24236
24336
|
includeLoopback: boolean().optional(),
|
|
24237
|
-
/** Skip IPv6 entries.
|
|
24238
|
-
*
|
|
24337
|
+
/** Skip IPv6 entries. Default `false` — the palette includes stable
|
|
24338
|
+
* LAN IPv6 (ICE/WebRTC uses dual-stack regardless). Pass `true` to
|
|
24339
|
+
* hide them. The viewer HTTP/WS race is `getViewerEndpoints`. */
|
|
24239
24340
|
ipv4Only: boolean().optional(),
|
|
24240
24341
|
/** Scheme to emit for LAN/loopback URLs. Default `'http'`.
|
|
24241
24342
|
* Pass `'https'` when the caller is itself loaded over HTTPS
|
|
24242
24343
|
* to avoid mixed-content blocks in the browser. The public
|
|
24243
24344
|
* tunnel always emits `https://` regardless. */
|
|
24244
24345
|
scheme: _enum(["http", "https"]).optional()
|
|
24245
|
-
}), 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, {
|
|
24346
|
+
}), 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, {
|
|
24246
24347
|
kind: "mutation",
|
|
24247
24348
|
auth: "admin"
|
|
24248
24349
|
}), method(object({
|
|
@@ -32316,6 +32417,12 @@ Object.freeze({
|
|
|
32316
32417
|
addonId: null,
|
|
32317
32418
|
access: "view"
|
|
32318
32419
|
},
|
|
32420
|
+
"localNetwork.getViewerEndpoints": {
|
|
32421
|
+
capName: "local-network",
|
|
32422
|
+
capScope: "system",
|
|
32423
|
+
addonId: null,
|
|
32424
|
+
access: "view"
|
|
32425
|
+
},
|
|
32319
32426
|
"localNetwork.list": {
|
|
32320
32427
|
capName: "local-network",
|
|
32321
32428
|
capScope: "system",
|
|
@@ -32352,6 +32459,12 @@ Object.freeze({
|
|
|
32352
32459
|
addonId: null,
|
|
32353
32460
|
access: "create"
|
|
32354
32461
|
},
|
|
32462
|
+
"localNetwork.setViewerEndpoints": {
|
|
32463
|
+
capName: "local-network",
|
|
32464
|
+
capScope: "system",
|
|
32465
|
+
addonId: null,
|
|
32466
|
+
access: "create"
|
|
32467
|
+
},
|
|
32355
32468
|
"localNetwork.uploadCertificate": {
|
|
32356
32469
|
capName: "local-network",
|
|
32357
32470
|
capScope: "system",
|
|
@@ -38131,356 +38244,6 @@ async function silenceAnalysisFor(deps, deviceId) {
|
|
|
38131
38244
|
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("; ")})`);
|
|
38132
38245
|
}
|
|
38133
38246
|
//#endregion
|
|
38134
|
-
//#region src/terminal-camera-declarations.ts
|
|
38135
|
-
/**
|
|
38136
|
-
* Feed DeclaredDevices every live declaration plus one deterministic orphan
|
|
38137
|
-
* batch. The generic sweep intentionally refuses an over-limit set; selecting
|
|
38138
|
-
* a batch here drains large historical Terminal orphan sets across convergence
|
|
38139
|
-
* passes without weakening that global safety guard.
|
|
38140
|
-
*/
|
|
38141
|
-
function terminalCameraReconciliationIndex(rows, integrationId, declarations, managedStableIds = /* @__PURE__ */ new Set()) {
|
|
38142
|
-
if (!integrationId) return [];
|
|
38143
|
-
const declared = new Set(declarations.map((camera) => camera.stableId));
|
|
38144
|
-
const owned = rows.filter((row) => row.integrationId === integrationId && (declared.has(row.stableId) || managedStableIds.has(row.stableId) || row.stableId.startsWith("terminal-camera-instance-")));
|
|
38145
|
-
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)];
|
|
38146
|
-
}
|
|
38147
|
-
/** Explicit persisted instances, never the node × profile template matrix. */
|
|
38148
|
-
function buildTerminalInstanceCameraDeclarations(instances) {
|
|
38149
|
-
return instances.filter((instance) => instance.enabled).map((instance) => ({
|
|
38150
|
-
stableId: instance.cameraStableId,
|
|
38151
|
-
name: instance.name,
|
|
38152
|
-
config: {
|
|
38153
|
-
instanceId: instance.id,
|
|
38154
|
-
nodeId: instance.nodeId,
|
|
38155
|
-
profileId: instance.profileId,
|
|
38156
|
-
profileLabel: instance.profileLabel
|
|
38157
|
-
}
|
|
38158
|
-
}));
|
|
38159
|
-
}
|
|
38160
|
-
/**
|
|
38161
|
-
* `DeviceConfig` materializes schema defaults in memory, so comparing
|
|
38162
|
-
* `config.get()` cannot detect a legacy `{ nodeId }` row. Reconciliation must
|
|
38163
|
-
* inspect the raw persisted blob to make the profile migration durable.
|
|
38164
|
-
*/
|
|
38165
|
-
function needsTerminalCameraConfigMigration(persistedConfig, declaration) {
|
|
38166
|
-
return persistedConfig.instanceId !== declaration.config.instanceId || persistedConfig.nodeId !== declaration.config.nodeId || persistedConfig.profileId !== declaration.config.profileId || persistedConfig.profileLabel !== declaration.config.profileLabel;
|
|
38167
|
-
}
|
|
38168
|
-
//#endregion
|
|
38169
|
-
//#region src/terminal-cell-runs.ts
|
|
38170
|
-
var TERMINAL_DEFAULT_FG = "#d7dce2";
|
|
38171
|
-
var TERMINAL_DEFAULT_BG = "#0b0d10";
|
|
38172
|
-
/**
|
|
38173
|
-
* The 16 ANSI colours, in a dark-theme variant chosen to sit with the existing
|
|
38174
|
-
* frame (`#0b0d10` ground, `#d7dce2` text) rather than the raw xterm defaults,
|
|
38175
|
-
* whose pure `#0000ff` blue and `#008000` green are close to unreadable on a
|
|
38176
|
-
* near-black background at 13px. Index 7 IS the default foreground, so plain
|
|
38177
|
-
* `CSI 37m` text renders identically to unstyled text.
|
|
38178
|
-
*/
|
|
38179
|
-
var TERMINAL_ANSI_PALETTE = [
|
|
38180
|
-
"#282c34",
|
|
38181
|
-
"#e06c75",
|
|
38182
|
-
"#98c379",
|
|
38183
|
-
"#e5c07b",
|
|
38184
|
-
"#61afef",
|
|
38185
|
-
"#c678dd",
|
|
38186
|
-
"#56b6c2",
|
|
38187
|
-
TERMINAL_DEFAULT_FG,
|
|
38188
|
-
"#5c6370",
|
|
38189
|
-
"#ef596f",
|
|
38190
|
-
"#89ca78",
|
|
38191
|
-
"#f0c674",
|
|
38192
|
-
"#6cb6ff",
|
|
38193
|
-
"#d55fde",
|
|
38194
|
-
"#2bbac5",
|
|
38195
|
-
"#ffffff"
|
|
38196
|
-
];
|
|
38197
|
-
/** The six levels of the xterm 6×6×6 colour cube (indices 16-231). */
|
|
38198
|
-
var TERMINAL_CUBE_LEVELS = [
|
|
38199
|
-
0,
|
|
38200
|
-
95,
|
|
38201
|
-
135,
|
|
38202
|
-
175,
|
|
38203
|
-
215,
|
|
38204
|
-
255
|
|
38205
|
-
];
|
|
38206
|
-
var TERMINAL_CUBE_FIRST = 16;
|
|
38207
|
-
var TERMINAL_GRAYSCALE_FIRST = 232;
|
|
38208
|
-
var TERMINAL_GRAYSCALE_BASE = 8;
|
|
38209
|
-
var TERMINAL_GRAYSCALE_STEP = 10;
|
|
38210
|
-
/** SGR 2 keeps the foreground legible; it must not become the background. */
|
|
38211
|
-
var TERMINAL_DIM_WEIGHT = .6;
|
|
38212
|
-
function channel(value) {
|
|
38213
|
-
return Math.max(0, Math.min(255, Math.round(value))).toString(16).padStart(2, "0");
|
|
38214
|
-
}
|
|
38215
|
-
function hex(red, green, blue) {
|
|
38216
|
-
return `#${channel(red)}${channel(green)}${channel(blue)}`;
|
|
38217
|
-
}
|
|
38218
|
-
function parseHex(color) {
|
|
38219
|
-
return [
|
|
38220
|
-
Number.parseInt(color.slice(1, 3), 16),
|
|
38221
|
-
Number.parseInt(color.slice(3, 5), 16),
|
|
38222
|
-
Number.parseInt(color.slice(5, 7), 16)
|
|
38223
|
-
];
|
|
38224
|
-
}
|
|
38225
|
-
/** Resolve an xterm palette index (0-255) to a hex colour. */
|
|
38226
|
-
function terminalPaletteColor(index) {
|
|
38227
|
-
const ansi = TERMINAL_ANSI_PALETTE[index];
|
|
38228
|
-
if (ansi !== void 0) return ansi;
|
|
38229
|
-
if (index >= TERMINAL_GRAYSCALE_FIRST) {
|
|
38230
|
-
const level = TERMINAL_GRAYSCALE_BASE + (index - TERMINAL_GRAYSCALE_FIRST) * TERMINAL_GRAYSCALE_STEP;
|
|
38231
|
-
return hex(level, level, level);
|
|
38232
|
-
}
|
|
38233
|
-
if (index >= TERMINAL_CUBE_FIRST) {
|
|
38234
|
-
const offset = index - TERMINAL_CUBE_FIRST;
|
|
38235
|
-
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);
|
|
38236
|
-
}
|
|
38237
|
-
return TERMINAL_DEFAULT_FG;
|
|
38238
|
-
}
|
|
38239
|
-
/** Resolve a 0xRRGGBB truecolor value to a hex colour. */
|
|
38240
|
-
function terminalRgbColor(value) {
|
|
38241
|
-
return hex(value >> 16 & 255, value >> 8 & 255, value & 255);
|
|
38242
|
-
}
|
|
38243
|
-
function blend(color, toward, weight) {
|
|
38244
|
-
const [red, green, blue] = parseHex(color);
|
|
38245
|
-
const [targetRed, targetGreen, targetBlue] = parseHex(toward);
|
|
38246
|
-
return hex(red * weight + targetRed * (1 - weight), green * weight + targetGreen * (1 - weight), blue * weight + targetBlue * (1 - weight));
|
|
38247
|
-
}
|
|
38248
|
-
function resolveForeground(cell) {
|
|
38249
|
-
if (cell.isFgRGB()) return terminalRgbColor(cell.getFgColor());
|
|
38250
|
-
if (cell.isFgPalette()) return terminalPaletteColor(cell.getFgColor());
|
|
38251
|
-
return TERMINAL_DEFAULT_FG;
|
|
38252
|
-
}
|
|
38253
|
-
function resolveBackground(cell) {
|
|
38254
|
-
if (cell.isBgRGB()) return terminalRgbColor(cell.getBgColor());
|
|
38255
|
-
if (cell.isBgPalette()) return terminalPaletteColor(cell.getBgColor());
|
|
38256
|
-
return TERMINAL_DEFAULT_BG;
|
|
38257
|
-
}
|
|
38258
|
-
/**
|
|
38259
|
-
* Resolve one cell's attributes into concrete colours.
|
|
38260
|
-
*
|
|
38261
|
-
* Inverse is applied by SWAPPING the already-resolved pair, so inverse over two
|
|
38262
|
-
* defaults is still a visible swap rather than a no-op — that is how a selected
|
|
38263
|
-
* or highlighted row in Glances reads. Invisible is then conceal-by-equality
|
|
38264
|
-
* (foreground painted in its own background): the cell keeps its columns, which
|
|
38265
|
-
* a dropped cell would not, and dropping it would shift the whole rest of the
|
|
38266
|
-
* row left.
|
|
38267
|
-
*/
|
|
38268
|
-
function resolveCellStyle(cell) {
|
|
38269
|
-
const inverse = cell.isInverse() !== 0;
|
|
38270
|
-
const plainFg = resolveForeground(cell);
|
|
38271
|
-
const plainBg = resolveBackground(cell);
|
|
38272
|
-
const background = inverse ? plainFg : plainBg;
|
|
38273
|
-
let foreground = inverse ? plainBg : plainFg;
|
|
38274
|
-
if (cell.isDim() !== 0) foreground = blend(foreground, background, TERMINAL_DIM_WEIGHT);
|
|
38275
|
-
if (cell.isInvisible() !== 0) foreground = background;
|
|
38276
|
-
return {
|
|
38277
|
-
fg: foreground === "#d7dce2" ? null : foreground,
|
|
38278
|
-
bg: background === "#0b0d10" ? null : background,
|
|
38279
|
-
bold: cell.isBold() !== 0
|
|
38280
|
-
};
|
|
38281
|
-
}
|
|
38282
|
-
function sameStyle(left, right) {
|
|
38283
|
-
return left.fg === right.fg && left.bg === right.bg && left.bold === right.bold;
|
|
38284
|
-
}
|
|
38285
|
-
/**
|
|
38286
|
-
* Merge adjacent same-style cells into runs, then drop the trailing run of
|
|
38287
|
-
* default-styled whitespace so a row costs what it draws — the same trim
|
|
38288
|
-
* `translateToString(true)` performs. Whitespace carrying a BACKGROUND is kept:
|
|
38289
|
-
* a green bar of spaces out to the right margin is a pixel Glances drew.
|
|
38290
|
-
*/
|
|
38291
|
-
function buildCellRuns(cells) {
|
|
38292
|
-
const runs = [];
|
|
38293
|
-
let text = "";
|
|
38294
|
-
let style = null;
|
|
38295
|
-
for (const cell of cells) {
|
|
38296
|
-
if (style !== null && sameStyle(style, cell.style)) {
|
|
38297
|
-
text += cell.text;
|
|
38298
|
-
continue;
|
|
38299
|
-
}
|
|
38300
|
-
if (style !== null) runs.push({
|
|
38301
|
-
text,
|
|
38302
|
-
...style
|
|
38303
|
-
});
|
|
38304
|
-
text = cell.text;
|
|
38305
|
-
style = cell.style;
|
|
38306
|
-
}
|
|
38307
|
-
if (style !== null) runs.push({
|
|
38308
|
-
text,
|
|
38309
|
-
...style
|
|
38310
|
-
});
|
|
38311
|
-
while (runs.length > 0) {
|
|
38312
|
-
const last = runs[runs.length - 1];
|
|
38313
|
-
if (last === void 0 || last.bg !== null) break;
|
|
38314
|
-
const trimmed = last.text.replace(/\s+$/u, "");
|
|
38315
|
-
if (trimmed === last.text) break;
|
|
38316
|
-
if (trimmed === "") {
|
|
38317
|
-
runs.pop();
|
|
38318
|
-
continue;
|
|
38319
|
-
}
|
|
38320
|
-
runs[runs.length - 1] = {
|
|
38321
|
-
...last,
|
|
38322
|
-
text: trimmed
|
|
38323
|
-
};
|
|
38324
|
-
break;
|
|
38325
|
-
}
|
|
38326
|
-
return runs;
|
|
38327
|
-
}
|
|
38328
|
-
/**
|
|
38329
|
-
* Monospace families to try, in order — NOT one family and a generic.
|
|
38330
|
-
*
|
|
38331
|
-
* A terminal screen is mostly box-drawing and block characters, and a font
|
|
38332
|
-
* without them renders the frame as noise rather than as missing detail.
|
|
38333
|
-
* `DejaVu Sans Mono` covers them and ships in the hub image; macOS has neither
|
|
38334
|
-
* DejaVu nor fontconfig, so the Mac agent fell through to a generic whose
|
|
38335
|
-
* coverage is not, and its Glances camera came out unreadable while the hub's
|
|
38336
|
-
* was pixel-perfect (measured 2026-08-11, same Glances, two nodes).
|
|
38337
|
-
*
|
|
38338
|
-
* `Menlo` is the fix rather than a guess: it is macOS's default terminal face,
|
|
38339
|
-
* present on every install, and derived from DejaVu Sans Mono — the same glyph
|
|
38340
|
-
* coverage by ancestry. Monaco and Courier New follow as older fallbacks; the
|
|
38341
|
-
* generic stays last so a host with none of them still draws something.
|
|
38342
|
-
*/
|
|
38343
|
-
var TERMINAL_FONT_STACK = "DejaVu Sans Mono,Menlo,Monaco,Courier New,monospace";
|
|
38344
|
-
var TERMINAL_FONT_SIZE = 13;
|
|
38345
|
-
var TERMINAL_TEXT_MARGIN_X = 8;
|
|
38346
|
-
var TERMINAL_ROW_HEIGHT = 15;
|
|
38347
|
-
var TERMINAL_BASELINE_Y = 18;
|
|
38348
|
-
/**
|
|
38349
|
-
* Distance from a row's baseline up to the top of its cell box. Chosen so
|
|
38350
|
-
* consecutive rows tile exactly: row N's box runs from `baseline - this` for
|
|
38351
|
-
* `TERMINAL_ROW_HEIGHT`, and row N+1's box starts where it ends. A background
|
|
38352
|
-
* bar that stopped short would draw as stripes across a `CSI 42m` panel.
|
|
38353
|
-
*/
|
|
38354
|
-
var TERMINAL_CELL_ASCENT = 11.5;
|
|
38355
|
-
var TERMINAL_CELL_WIDTH = TERMINAL_FONT_SIZE * (1233 / 2048);
|
|
38356
|
-
/** Two decimals is under a tenth of a pixel and keeps the SVG small. */
|
|
38357
|
-
function coordinate(value) {
|
|
38358
|
-
return String(Number(value.toFixed(2)));
|
|
38359
|
-
}
|
|
38360
|
-
function escapeXml(value) {
|
|
38361
|
-
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
38362
|
-
}
|
|
38363
|
-
/**
|
|
38364
|
-
* Render already-interpreted terminal rows into a compact MJPEG frame.
|
|
38365
|
-
*
|
|
38366
|
-
* `xml:space="preserve"` is load-bearing, not tidiness. SVG `<text>` collapses
|
|
38367
|
-
* runs of whitespace by default, and a terminal's entire column alignment IS
|
|
38368
|
-
* runs of whitespace — Glances pads every field with spaces. Without it the
|
|
38369
|
-
* frame drew each line at roughly half its true width, crammed into the
|
|
38370
|
-
* top-left of a mostly-black image, while the SAME session over `attach`
|
|
38371
|
-
* looked perfect — which is exactly how the operator reported it. Measured in
|
|
38372
|
-
* the hub's own rasterizer 2026-08-11: `AAA<10 spaces>BBB<3>CCC` drew 92 px
|
|
38373
|
-
* collapsed against 178 px preserved.
|
|
38374
|
-
*
|
|
38375
|
-
* Every run is anchored at its OWN column (`x = margin + startCol * cellW`),
|
|
38376
|
-
* never appended to the one before it, so the background rects and the glyphs
|
|
38377
|
-
* are placed off the same grid and cannot drift apart. `textLength` is emitted
|
|
38378
|
-
* with it because it is the correct declaration and renderers that honour it
|
|
38379
|
-
* get an exact grid — but it is not what makes this work: librsvg, which sharp
|
|
38380
|
-
* uses, ignores it outright (measured 2026-08-12, a 120-glyph run pinned to
|
|
38381
|
-
* 600 px still drew its natural 937 px). The anchoring is the guarantee.
|
|
38382
|
-
*/
|
|
38383
|
-
function renderTerminalSvg(rows) {
|
|
38384
|
-
const backgrounds = [];
|
|
38385
|
-
const texts = [];
|
|
38386
|
-
rows.slice(0, 40).forEach((row, index) => {
|
|
38387
|
-
const baseline = TERMINAL_BASELINE_Y + index * TERMINAL_ROW_HEIGHT;
|
|
38388
|
-
const top = baseline - TERMINAL_CELL_ASCENT;
|
|
38389
|
-
let column = 0;
|
|
38390
|
-
for (const run of row) {
|
|
38391
|
-
if (column >= 120) break;
|
|
38392
|
-
const clipped = clipRun(run, 120 - column);
|
|
38393
|
-
const columns = [...clipped].length;
|
|
38394
|
-
if (columns === 0) continue;
|
|
38395
|
-
const x = TERMINAL_TEXT_MARGIN_X + column * TERMINAL_CELL_WIDTH;
|
|
38396
|
-
const width = columns * TERMINAL_CELL_WIDTH;
|
|
38397
|
-
if (run.bg !== null) backgrounds.push(`<rect x="${coordinate(x)}" y="${coordinate(top)}" width="${coordinate(width)}" height="${String(TERMINAL_ROW_HEIGHT)}" fill="${run.bg}"/>`);
|
|
38398
|
-
if (clipped.trim() !== "") {
|
|
38399
|
-
const fill = run.fg === null ? "" : ` fill="${run.fg}"`;
|
|
38400
|
-
const weight = run.bold ? " font-weight=\"bold\"" : "";
|
|
38401
|
-
texts.push(`<text xml:space="preserve" x="${coordinate(x)}" y="${coordinate(baseline)}" textLength="${coordinate(width)}" lengthAdjust="spacingAndGlyphs"${fill}${weight}>${escapeXml(clipped)}</text>`);
|
|
38402
|
-
}
|
|
38403
|
-
column += columns;
|
|
38404
|
-
}
|
|
38405
|
-
});
|
|
38406
|
-
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>`;
|
|
38407
|
-
}
|
|
38408
|
-
/** Cut a run to the columns still left in the row, by code point not unit. */
|
|
38409
|
-
function clipRun(run, remaining) {
|
|
38410
|
-
const points = [...run.text];
|
|
38411
|
-
return points.length <= remaining ? run.text : points.slice(0, remaining).join("");
|
|
38412
|
-
}
|
|
38413
|
-
async function renderTerminalJpeg(rows) {
|
|
38414
|
-
return (0, sharp.default)(Buffer.from(renderTerminalSvg(rows))).jpeg({
|
|
38415
|
-
quality: 82,
|
|
38416
|
-
chromaSubsampling: "4:2:0"
|
|
38417
|
-
}).toBuffer();
|
|
38418
|
-
}
|
|
38419
|
-
//#endregion
|
|
38420
|
-
//#region src/terminal-camera-device.ts
|
|
38421
|
-
var terminalCameraSchema = object({
|
|
38422
|
-
instanceId: string().min(1).optional(),
|
|
38423
|
-
nodeId: string().min(1),
|
|
38424
|
-
profileId: string().min(1).default("monitor"),
|
|
38425
|
-
profileLabel: string().min(1).default("BTM")
|
|
38426
|
-
});
|
|
38427
|
-
var relay = null;
|
|
38428
|
-
function installTerminalCameraRelay(next) {
|
|
38429
|
-
relay = next;
|
|
38430
|
-
}
|
|
38431
|
-
var TerminalCameraDevice = class extends BaseDevice {
|
|
38432
|
-
features = [DeviceFeature.NativeSnapshot];
|
|
38433
|
-
constructor(ctx) {
|
|
38434
|
-
super(ctx, terminalCameraSchema, { type: ctx.deviceMeta.type });
|
|
38435
|
-
this.ctx.registerNativeCap(streamCatalogCapability, { getCatalog: async ({ deviceId }) => {
|
|
38436
|
-
if (deviceId !== this.id) return [];
|
|
38437
|
-
return this.catalog();
|
|
38438
|
-
} });
|
|
38439
|
-
this.ctx.registerNativeCap(snapshotCapability, {
|
|
38440
|
-
getSnapshot: async ({ deviceId }) => {
|
|
38441
|
-
if (deviceId !== this.id) throw new Error(`TerminalCameraDevice: deviceId mismatch, expected ${String(this.id)}, got ${String(deviceId)}`);
|
|
38442
|
-
const activeRelay = relay;
|
|
38443
|
-
if (!activeRelay) throw new Error("terminal camera relay is unavailable");
|
|
38444
|
-
return {
|
|
38445
|
-
base64: (await activeRelay.snapshot(this.relayInstanceId(), this.config.get("nodeId"), this.config.get("profileId"))).toString("base64"),
|
|
38446
|
-
contentType: "image/jpeg"
|
|
38447
|
-
};
|
|
38448
|
-
},
|
|
38449
|
-
invalidateCache: async () => {}
|
|
38450
|
-
});
|
|
38451
|
-
this.markOnline(true);
|
|
38452
|
-
}
|
|
38453
|
-
async catalog() {
|
|
38454
|
-
const activeRelay = relay;
|
|
38455
|
-
if (!activeRelay) throw new Error("terminal camera relay is unavailable");
|
|
38456
|
-
const nodeId = this.config.get("nodeId");
|
|
38457
|
-
const profileId = this.config.get("profileId");
|
|
38458
|
-
const instanceId = this.relayInstanceId();
|
|
38459
|
-
return [{
|
|
38460
|
-
camStreamId: profileId,
|
|
38461
|
-
kind: "pull-http",
|
|
38462
|
-
url: activeRelay.streamUrl(instanceId, nodeId, profileId),
|
|
38463
|
-
codec: "h264",
|
|
38464
|
-
resolution: {
|
|
38465
|
-
width: 960,
|
|
38466
|
-
height: 640
|
|
38467
|
-
},
|
|
38468
|
-
fps: 2,
|
|
38469
|
-
label: this.config.get("profileLabel")
|
|
38470
|
-
}];
|
|
38471
|
-
}
|
|
38472
|
-
setNodeOnline(online) {
|
|
38473
|
-
this.markOnline(online);
|
|
38474
|
-
if (!online) relay?.closeInstance(this.relayInstanceId());
|
|
38475
|
-
}
|
|
38476
|
-
async removeDevice() {
|
|
38477
|
-
await relay?.closeInstance(this.relayInstanceId());
|
|
38478
|
-
}
|
|
38479
|
-
relayInstanceId() {
|
|
38480
|
-
return this.config.get("instanceId") ?? `legacy:${this.stableId}`;
|
|
38481
|
-
}
|
|
38482
|
-
};
|
|
38483
|
-
//#endregion
|
|
38484
38247
|
//#region ../../node_modules/@xterm/addon-serialize/lib/addon-serialize.js
|
|
38485
38248
|
var require_addon_serialize = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
38486
38249
|
(function(e, t) {
|
|
@@ -43288,9 +43051,174 @@ var require_xterm_headless = /* @__PURE__ */ __commonJSMin(((exports) => {
|
|
|
43288
43051
|
})();
|
|
43289
43052
|
}));
|
|
43290
43053
|
//#endregion
|
|
43291
|
-
//#region src/
|
|
43054
|
+
//#region src/terminal-cell-runs.ts
|
|
43292
43055
|
var import_addon_serialize = require_addon_serialize();
|
|
43293
43056
|
var import_xterm_headless = require_xterm_headless();
|
|
43057
|
+
var TERMINAL_DEFAULT_FG = "#d7dce2";
|
|
43058
|
+
var TERMINAL_DEFAULT_BG = "#0b0d10";
|
|
43059
|
+
/**
|
|
43060
|
+
* The 16 ANSI colours, in a dark-theme variant chosen to sit with the existing
|
|
43061
|
+
* frame (`#0b0d10` ground, `#d7dce2` text) rather than the raw xterm defaults,
|
|
43062
|
+
* whose pure `#0000ff` blue and `#008000` green are close to unreadable on a
|
|
43063
|
+
* near-black background at 13px. Index 7 IS the default foreground, so plain
|
|
43064
|
+
* `CSI 37m` text renders identically to unstyled text.
|
|
43065
|
+
*/
|
|
43066
|
+
var TERMINAL_ANSI_PALETTE = [
|
|
43067
|
+
"#282c34",
|
|
43068
|
+
"#e06c75",
|
|
43069
|
+
"#98c379",
|
|
43070
|
+
"#e5c07b",
|
|
43071
|
+
"#61afef",
|
|
43072
|
+
"#c678dd",
|
|
43073
|
+
"#56b6c2",
|
|
43074
|
+
TERMINAL_DEFAULT_FG,
|
|
43075
|
+
"#5c6370",
|
|
43076
|
+
"#ef596f",
|
|
43077
|
+
"#89ca78",
|
|
43078
|
+
"#f0c674",
|
|
43079
|
+
"#6cb6ff",
|
|
43080
|
+
"#d55fde",
|
|
43081
|
+
"#2bbac5",
|
|
43082
|
+
"#ffffff"
|
|
43083
|
+
];
|
|
43084
|
+
/** The six levels of the xterm 6×6×6 colour cube (indices 16-231). */
|
|
43085
|
+
var TERMINAL_CUBE_LEVELS = [
|
|
43086
|
+
0,
|
|
43087
|
+
95,
|
|
43088
|
+
135,
|
|
43089
|
+
175,
|
|
43090
|
+
215,
|
|
43091
|
+
255
|
|
43092
|
+
];
|
|
43093
|
+
var TERMINAL_CUBE_FIRST = 16;
|
|
43094
|
+
var TERMINAL_GRAYSCALE_FIRST = 232;
|
|
43095
|
+
var TERMINAL_GRAYSCALE_BASE = 8;
|
|
43096
|
+
var TERMINAL_GRAYSCALE_STEP = 10;
|
|
43097
|
+
/** SGR 2 keeps the foreground legible; it must not become the background. */
|
|
43098
|
+
var TERMINAL_DIM_WEIGHT = .6;
|
|
43099
|
+
function channel(value) {
|
|
43100
|
+
return Math.max(0, Math.min(255, Math.round(value))).toString(16).padStart(2, "0");
|
|
43101
|
+
}
|
|
43102
|
+
function hex(red, green, blue) {
|
|
43103
|
+
return `#${channel(red)}${channel(green)}${channel(blue)}`;
|
|
43104
|
+
}
|
|
43105
|
+
function parseHex(color) {
|
|
43106
|
+
return [
|
|
43107
|
+
Number.parseInt(color.slice(1, 3), 16),
|
|
43108
|
+
Number.parseInt(color.slice(3, 5), 16),
|
|
43109
|
+
Number.parseInt(color.slice(5, 7), 16)
|
|
43110
|
+
];
|
|
43111
|
+
}
|
|
43112
|
+
/** Resolve an xterm palette index (0-255) to a hex colour. */
|
|
43113
|
+
function terminalPaletteColor(index) {
|
|
43114
|
+
const ansi = TERMINAL_ANSI_PALETTE[index];
|
|
43115
|
+
if (ansi !== void 0) return ansi;
|
|
43116
|
+
if (index >= TERMINAL_GRAYSCALE_FIRST) {
|
|
43117
|
+
const level = TERMINAL_GRAYSCALE_BASE + (index - TERMINAL_GRAYSCALE_FIRST) * TERMINAL_GRAYSCALE_STEP;
|
|
43118
|
+
return hex(level, level, level);
|
|
43119
|
+
}
|
|
43120
|
+
if (index >= TERMINAL_CUBE_FIRST) {
|
|
43121
|
+
const offset = index - TERMINAL_CUBE_FIRST;
|
|
43122
|
+
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);
|
|
43123
|
+
}
|
|
43124
|
+
return TERMINAL_DEFAULT_FG;
|
|
43125
|
+
}
|
|
43126
|
+
/** Resolve a 0xRRGGBB truecolor value to a hex colour. */
|
|
43127
|
+
function terminalRgbColor(value) {
|
|
43128
|
+
return hex(value >> 16 & 255, value >> 8 & 255, value & 255);
|
|
43129
|
+
}
|
|
43130
|
+
function blend(color, toward, weight) {
|
|
43131
|
+
const [red, green, blue] = parseHex(color);
|
|
43132
|
+
const [targetRed, targetGreen, targetBlue] = parseHex(toward);
|
|
43133
|
+
return hex(red * weight + targetRed * (1 - weight), green * weight + targetGreen * (1 - weight), blue * weight + targetBlue * (1 - weight));
|
|
43134
|
+
}
|
|
43135
|
+
function resolveForeground(cell) {
|
|
43136
|
+
if (cell.isFgRGB()) return terminalRgbColor(cell.getFgColor());
|
|
43137
|
+
if (cell.isFgPalette()) return terminalPaletteColor(cell.getFgColor());
|
|
43138
|
+
return TERMINAL_DEFAULT_FG;
|
|
43139
|
+
}
|
|
43140
|
+
function resolveBackground(cell) {
|
|
43141
|
+
if (cell.isBgRGB()) return terminalRgbColor(cell.getBgColor());
|
|
43142
|
+
if (cell.isBgPalette()) return terminalPaletteColor(cell.getBgColor());
|
|
43143
|
+
return TERMINAL_DEFAULT_BG;
|
|
43144
|
+
}
|
|
43145
|
+
/**
|
|
43146
|
+
* Resolve one cell's attributes into concrete colours.
|
|
43147
|
+
*
|
|
43148
|
+
* Inverse is applied by SWAPPING the already-resolved pair, so inverse over two
|
|
43149
|
+
* defaults is still a visible swap rather than a no-op — that is how a selected
|
|
43150
|
+
* or highlighted row in Glances reads. Invisible is then conceal-by-equality
|
|
43151
|
+
* (foreground painted in its own background): the cell keeps its columns, which
|
|
43152
|
+
* a dropped cell would not, and dropping it would shift the whole rest of the
|
|
43153
|
+
* row left.
|
|
43154
|
+
*/
|
|
43155
|
+
function resolveCellStyle(cell) {
|
|
43156
|
+
const inverse = cell.isInverse() !== 0;
|
|
43157
|
+
const plainFg = resolveForeground(cell);
|
|
43158
|
+
const plainBg = resolveBackground(cell);
|
|
43159
|
+
const background = inverse ? plainFg : plainBg;
|
|
43160
|
+
let foreground = inverse ? plainBg : plainFg;
|
|
43161
|
+
if (cell.isDim() !== 0) foreground = blend(foreground, background, TERMINAL_DIM_WEIGHT);
|
|
43162
|
+
if (cell.isInvisible() !== 0) foreground = background;
|
|
43163
|
+
return {
|
|
43164
|
+
fg: foreground === "#d7dce2" ? null : foreground,
|
|
43165
|
+
bg: background === "#0b0d10" ? null : background,
|
|
43166
|
+
bold: cell.isBold() !== 0
|
|
43167
|
+
};
|
|
43168
|
+
}
|
|
43169
|
+
function sameStyle(left, right) {
|
|
43170
|
+
return left.fg === right.fg && left.bg === right.bg && left.bold === right.bold;
|
|
43171
|
+
}
|
|
43172
|
+
/**
|
|
43173
|
+
* Merge adjacent same-style cells into runs, then drop the trailing run of
|
|
43174
|
+
* default-styled whitespace so a row costs what it draws — the same trim
|
|
43175
|
+
* `translateToString(true)` performs. Whitespace carrying a BACKGROUND is kept:
|
|
43176
|
+
* a green bar of spaces out to the right margin is a pixel Glances drew.
|
|
43177
|
+
*/
|
|
43178
|
+
function buildCellRuns(cells) {
|
|
43179
|
+
const runs = [];
|
|
43180
|
+
let text = "";
|
|
43181
|
+
let style = null;
|
|
43182
|
+
for (const cell of cells) {
|
|
43183
|
+
if (style !== null && sameStyle(style, cell.style)) {
|
|
43184
|
+
text += cell.text;
|
|
43185
|
+
continue;
|
|
43186
|
+
}
|
|
43187
|
+
if (style !== null) runs.push({
|
|
43188
|
+
text,
|
|
43189
|
+
...style
|
|
43190
|
+
});
|
|
43191
|
+
text = cell.text;
|
|
43192
|
+
style = cell.style;
|
|
43193
|
+
}
|
|
43194
|
+
if (style !== null) runs.push({
|
|
43195
|
+
text,
|
|
43196
|
+
...style
|
|
43197
|
+
});
|
|
43198
|
+
while (runs.length > 0) {
|
|
43199
|
+
const last = runs[runs.length - 1];
|
|
43200
|
+
if (last === void 0 || last.bg !== null) break;
|
|
43201
|
+
const trimmed = last.text.replace(/\s+$/u, "");
|
|
43202
|
+
if (trimmed === last.text) break;
|
|
43203
|
+
if (trimmed === "") {
|
|
43204
|
+
runs.pop();
|
|
43205
|
+
continue;
|
|
43206
|
+
}
|
|
43207
|
+
runs[runs.length - 1] = {
|
|
43208
|
+
...last,
|
|
43209
|
+
text: trimmed
|
|
43210
|
+
};
|
|
43211
|
+
break;
|
|
43212
|
+
}
|
|
43213
|
+
return runs;
|
|
43214
|
+
}
|
|
43215
|
+
//#endregion
|
|
43216
|
+
//#region src/xterm-screen.ts
|
|
43217
|
+
/**
|
|
43218
|
+
* Real {@link ScreenBuffer} backed by `@xterm/headless` — the DOM-less xterm
|
|
43219
|
+
* build — plus the serialize addon, which turns the current buffer into a
|
|
43220
|
+
* self-contained repaint escape sequence for reconnecting clients.
|
|
43221
|
+
*/
|
|
43294
43222
|
var SCROLLBACK_LINES = 2e3;
|
|
43295
43223
|
function createXtermScreen(cols, rows) {
|
|
43296
43224
|
const term = new import_xterm_headless.Terminal({
|
|
@@ -43357,6 +43285,196 @@ function createXtermScreen(cols, rows) {
|
|
|
43357
43285
|
};
|
|
43358
43286
|
}
|
|
43359
43287
|
//#endregion
|
|
43288
|
+
//#region src/terminal-camera-declarations.ts
|
|
43289
|
+
/**
|
|
43290
|
+
* Feed DeclaredDevices every live declaration plus one deterministic orphan
|
|
43291
|
+
* batch. The generic sweep intentionally refuses an over-limit set; selecting
|
|
43292
|
+
* a batch here drains large historical Terminal orphan sets across convergence
|
|
43293
|
+
* passes without weakening that global safety guard.
|
|
43294
|
+
*/
|
|
43295
|
+
function terminalCameraReconciliationIndex(rows, integrationId, declarations, managedStableIds = /* @__PURE__ */ new Set()) {
|
|
43296
|
+
if (!integrationId) return [];
|
|
43297
|
+
const declared = new Set(declarations.map((camera) => camera.stableId));
|
|
43298
|
+
const owned = rows.filter((row) => row.integrationId === integrationId && (declared.has(row.stableId) || managedStableIds.has(row.stableId) || row.stableId.startsWith("terminal-camera-instance-")));
|
|
43299
|
+
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)];
|
|
43300
|
+
}
|
|
43301
|
+
/** Explicit persisted instances, never the node × profile template matrix. */
|
|
43302
|
+
function buildTerminalInstanceCameraDeclarations(instances) {
|
|
43303
|
+
return instances.filter((instance) => instance.enabled).map((instance) => ({
|
|
43304
|
+
stableId: instance.cameraStableId,
|
|
43305
|
+
name: instance.name,
|
|
43306
|
+
config: {
|
|
43307
|
+
instanceId: instance.id,
|
|
43308
|
+
nodeId: instance.nodeId,
|
|
43309
|
+
profileId: instance.profileId,
|
|
43310
|
+
profileLabel: instance.profileLabel
|
|
43311
|
+
}
|
|
43312
|
+
}));
|
|
43313
|
+
}
|
|
43314
|
+
/**
|
|
43315
|
+
* `DeviceConfig` materializes schema defaults in memory, so comparing
|
|
43316
|
+
* `config.get()` cannot detect a legacy `{ nodeId }` row. Reconciliation must
|
|
43317
|
+
* inspect the raw persisted blob to make the profile migration durable.
|
|
43318
|
+
*/
|
|
43319
|
+
function needsTerminalCameraConfigMigration(persistedConfig, declaration) {
|
|
43320
|
+
return persistedConfig.instanceId !== declaration.config.instanceId || persistedConfig.nodeId !== declaration.config.nodeId || persistedConfig.profileId !== declaration.config.profileId || persistedConfig.profileLabel !== declaration.config.profileLabel;
|
|
43321
|
+
}
|
|
43322
|
+
/**
|
|
43323
|
+
* Monospace families to try, in order — NOT one family and a generic.
|
|
43324
|
+
*
|
|
43325
|
+
* A terminal screen is mostly box-drawing and block characters, and a font
|
|
43326
|
+
* without them renders the frame as noise rather than as missing detail.
|
|
43327
|
+
* `DejaVu Sans Mono` covers them and ships in the hub image; macOS has neither
|
|
43328
|
+
* DejaVu nor fontconfig, so the Mac agent fell through to a generic whose
|
|
43329
|
+
* coverage is not, and its Glances camera came out unreadable while the hub's
|
|
43330
|
+
* was pixel-perfect (measured 2026-08-11, same Glances, two nodes).
|
|
43331
|
+
*
|
|
43332
|
+
* `Menlo` is the fix rather than a guess: it is macOS's default terminal face,
|
|
43333
|
+
* present on every install, and derived from DejaVu Sans Mono — the same glyph
|
|
43334
|
+
* coverage by ancestry. Monaco and Courier New follow as older fallbacks; the
|
|
43335
|
+
* generic stays last so a host with none of them still draws something.
|
|
43336
|
+
*/
|
|
43337
|
+
var TERMINAL_FONT_STACK = "DejaVu Sans Mono,Menlo,Monaco,Courier New,monospace";
|
|
43338
|
+
var TERMINAL_FONT_SIZE = 13;
|
|
43339
|
+
var TERMINAL_TEXT_MARGIN_X = 8;
|
|
43340
|
+
var TERMINAL_ROW_HEIGHT = 15;
|
|
43341
|
+
var TERMINAL_BASELINE_Y = 18;
|
|
43342
|
+
/**
|
|
43343
|
+
* Distance from a row's baseline up to the top of its cell box. Chosen so
|
|
43344
|
+
* consecutive rows tile exactly: row N's box runs from `baseline - this` for
|
|
43345
|
+
* `TERMINAL_ROW_HEIGHT`, and row N+1's box starts where it ends. A background
|
|
43346
|
+
* bar that stopped short would draw as stripes across a `CSI 42m` panel.
|
|
43347
|
+
*/
|
|
43348
|
+
var TERMINAL_CELL_ASCENT = 11.5;
|
|
43349
|
+
var TERMINAL_CELL_WIDTH = TERMINAL_FONT_SIZE * (1233 / 2048);
|
|
43350
|
+
/** Two decimals is under a tenth of a pixel and keeps the SVG small. */
|
|
43351
|
+
function coordinate(value) {
|
|
43352
|
+
return String(Number(value.toFixed(2)));
|
|
43353
|
+
}
|
|
43354
|
+
function escapeXml(value) {
|
|
43355
|
+
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll("\"", """).replaceAll("'", "'");
|
|
43356
|
+
}
|
|
43357
|
+
/**
|
|
43358
|
+
* Render already-interpreted terminal rows into a compact MJPEG frame.
|
|
43359
|
+
*
|
|
43360
|
+
* `xml:space="preserve"` is load-bearing, not tidiness. SVG `<text>` collapses
|
|
43361
|
+
* runs of whitespace by default, and a terminal's entire column alignment IS
|
|
43362
|
+
* runs of whitespace — Glances pads every field with spaces. Without it the
|
|
43363
|
+
* frame drew each line at roughly half its true width, crammed into the
|
|
43364
|
+
* top-left of a mostly-black image, while the SAME session over `attach`
|
|
43365
|
+
* looked perfect — which is exactly how the operator reported it. Measured in
|
|
43366
|
+
* the hub's own rasterizer 2026-08-11: `AAA<10 spaces>BBB<3>CCC` drew 92 px
|
|
43367
|
+
* collapsed against 178 px preserved.
|
|
43368
|
+
*
|
|
43369
|
+
* Every run is anchored at its OWN column (`x = margin + startCol * cellW`),
|
|
43370
|
+
* never appended to the one before it, so the background rects and the glyphs
|
|
43371
|
+
* are placed off the same grid and cannot drift apart. `textLength` is emitted
|
|
43372
|
+
* with it because it is the correct declaration and renderers that honour it
|
|
43373
|
+
* get an exact grid — but it is not what makes this work: librsvg, which sharp
|
|
43374
|
+
* uses, ignores it outright (measured 2026-08-12, a 120-glyph run pinned to
|
|
43375
|
+
* 600 px still drew its natural 937 px). The anchoring is the guarantee.
|
|
43376
|
+
*/
|
|
43377
|
+
function renderTerminalSvg(rows) {
|
|
43378
|
+
const backgrounds = [];
|
|
43379
|
+
const texts = [];
|
|
43380
|
+
rows.slice(0, 40).forEach((row, index) => {
|
|
43381
|
+
const baseline = TERMINAL_BASELINE_Y + index * TERMINAL_ROW_HEIGHT;
|
|
43382
|
+
const top = baseline - TERMINAL_CELL_ASCENT;
|
|
43383
|
+
let column = 0;
|
|
43384
|
+
for (const run of row) {
|
|
43385
|
+
if (column >= 120) break;
|
|
43386
|
+
const clipped = clipRun(run, 120 - column);
|
|
43387
|
+
const columns = [...clipped].length;
|
|
43388
|
+
if (columns === 0) continue;
|
|
43389
|
+
const x = TERMINAL_TEXT_MARGIN_X + column * TERMINAL_CELL_WIDTH;
|
|
43390
|
+
const width = columns * TERMINAL_CELL_WIDTH;
|
|
43391
|
+
if (run.bg !== null) backgrounds.push(`<rect x="${coordinate(x)}" y="${coordinate(top)}" width="${coordinate(width)}" height="${String(TERMINAL_ROW_HEIGHT)}" fill="${run.bg}"/>`);
|
|
43392
|
+
if (clipped.trim() !== "") {
|
|
43393
|
+
const fill = run.fg === null ? "" : ` fill="${run.fg}"`;
|
|
43394
|
+
const weight = run.bold ? " font-weight=\"bold\"" : "";
|
|
43395
|
+
texts.push(`<text xml:space="preserve" x="${coordinate(x)}" y="${coordinate(baseline)}" textLength="${coordinate(width)}" lengthAdjust="spacingAndGlyphs"${fill}${weight}>${escapeXml(clipped)}</text>`);
|
|
43396
|
+
}
|
|
43397
|
+
column += columns;
|
|
43398
|
+
}
|
|
43399
|
+
});
|
|
43400
|
+
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>`;
|
|
43401
|
+
}
|
|
43402
|
+
/** Cut a run to the columns still left in the row, by code point not unit. */
|
|
43403
|
+
function clipRun(run, remaining) {
|
|
43404
|
+
const points = [...run.text];
|
|
43405
|
+
return points.length <= remaining ? run.text : points.slice(0, remaining).join("");
|
|
43406
|
+
}
|
|
43407
|
+
async function renderTerminalJpeg(rows) {
|
|
43408
|
+
return (0, sharp.default)(Buffer.from(renderTerminalSvg(rows))).jpeg({
|
|
43409
|
+
quality: 82,
|
|
43410
|
+
chromaSubsampling: "4:2:0"
|
|
43411
|
+
}).toBuffer();
|
|
43412
|
+
}
|
|
43413
|
+
//#endregion
|
|
43414
|
+
//#region src/terminal-camera-device.ts
|
|
43415
|
+
var terminalCameraSchema = object({
|
|
43416
|
+
instanceId: string().min(1).optional(),
|
|
43417
|
+
nodeId: string().min(1),
|
|
43418
|
+
profileId: string().min(1).default("monitor"),
|
|
43419
|
+
profileLabel: string().min(1).default("BTM")
|
|
43420
|
+
});
|
|
43421
|
+
var relay = null;
|
|
43422
|
+
function installTerminalCameraRelay(next) {
|
|
43423
|
+
relay = next;
|
|
43424
|
+
}
|
|
43425
|
+
var TerminalCameraDevice = class extends BaseDevice {
|
|
43426
|
+
features = [DeviceFeature.NativeSnapshot];
|
|
43427
|
+
constructor(ctx) {
|
|
43428
|
+
super(ctx, terminalCameraSchema, { type: ctx.deviceMeta.type });
|
|
43429
|
+
this.ctx.registerNativeCap(streamCatalogCapability, { getCatalog: async ({ deviceId }) => {
|
|
43430
|
+
if (deviceId !== this.id) return [];
|
|
43431
|
+
return this.catalog();
|
|
43432
|
+
} });
|
|
43433
|
+
this.ctx.registerNativeCap(snapshotCapability, {
|
|
43434
|
+
getSnapshot: async ({ deviceId }) => {
|
|
43435
|
+
if (deviceId !== this.id) throw new Error(`TerminalCameraDevice: deviceId mismatch, expected ${String(this.id)}, got ${String(deviceId)}`);
|
|
43436
|
+
const activeRelay = relay;
|
|
43437
|
+
if (!activeRelay) throw new Error("terminal camera relay is unavailable");
|
|
43438
|
+
return {
|
|
43439
|
+
base64: (await activeRelay.snapshot(this.relayInstanceId(), this.config.get("nodeId"), this.config.get("profileId"))).toString("base64"),
|
|
43440
|
+
contentType: "image/jpeg"
|
|
43441
|
+
};
|
|
43442
|
+
},
|
|
43443
|
+
invalidateCache: async () => {}
|
|
43444
|
+
});
|
|
43445
|
+
this.markOnline(true);
|
|
43446
|
+
}
|
|
43447
|
+
async catalog() {
|
|
43448
|
+
const activeRelay = relay;
|
|
43449
|
+
if (!activeRelay) throw new Error("terminal camera relay is unavailable");
|
|
43450
|
+
const nodeId = this.config.get("nodeId");
|
|
43451
|
+
const profileId = this.config.get("profileId");
|
|
43452
|
+
const instanceId = this.relayInstanceId();
|
|
43453
|
+
return [{
|
|
43454
|
+
camStreamId: profileId,
|
|
43455
|
+
kind: "pull-http",
|
|
43456
|
+
url: activeRelay.streamUrl(instanceId, nodeId, profileId),
|
|
43457
|
+
codec: "h264",
|
|
43458
|
+
resolution: {
|
|
43459
|
+
width: 960,
|
|
43460
|
+
height: 640
|
|
43461
|
+
},
|
|
43462
|
+
fps: 2,
|
|
43463
|
+
label: this.config.get("profileLabel")
|
|
43464
|
+
}];
|
|
43465
|
+
}
|
|
43466
|
+
setNodeOnline(online) {
|
|
43467
|
+
this.markOnline(online);
|
|
43468
|
+
if (!online) relay?.closeInstance(this.relayInstanceId());
|
|
43469
|
+
}
|
|
43470
|
+
async removeDevice() {
|
|
43471
|
+
await relay?.closeInstance(this.relayInstanceId());
|
|
43472
|
+
}
|
|
43473
|
+
relayInstanceId() {
|
|
43474
|
+
return this.config.get("instanceId") ?? `legacy:${this.stableId}`;
|
|
43475
|
+
}
|
|
43476
|
+
};
|
|
43477
|
+
//#endregion
|
|
43360
43478
|
//#region src/terminal-camera-relay.ts
|
|
43361
43479
|
var MJPEG_BOUNDARY = "camstack-terminal-frame";
|
|
43362
43480
|
var SESSION_IDLE_MS = 3e4;
|
|
@@ -43859,7 +43977,8 @@ var TerminalInstanceSchema = object({
|
|
|
43859
43977
|
executable: string().max(1024).default(""),
|
|
43860
43978
|
args: array(string().max(2048)).max(64).default([]),
|
|
43861
43979
|
cwd: string().max(1024).default(""),
|
|
43862
|
-
environment: array(string().max(4096)).max(64).default([])
|
|
43980
|
+
environment: array(string().max(4096)).max(64).default([]),
|
|
43981
|
+
profileSettings: record(string(), unknown()).default({})
|
|
43863
43982
|
});
|
|
43864
43983
|
function environmentEntriesToRecord(entries) {
|
|
43865
43984
|
const out = {};
|
|
@@ -44073,6 +44192,108 @@ function findProfile(profiles, profileId) {
|
|
|
44073
44192
|
return profiles.find((p) => p.profileId === profileId);
|
|
44074
44193
|
}
|
|
44075
44194
|
//#endregion
|
|
44195
|
+
//#region src/profile-settings.ts
|
|
44196
|
+
var GLANCES_PLUGINS = [
|
|
44197
|
+
{
|
|
44198
|
+
key: "showCpu",
|
|
44199
|
+
plugin: "cpu",
|
|
44200
|
+
label: "CPU"
|
|
44201
|
+
},
|
|
44202
|
+
{
|
|
44203
|
+
key: "showMem",
|
|
44204
|
+
plugin: "mem",
|
|
44205
|
+
label: "Memory"
|
|
44206
|
+
},
|
|
44207
|
+
{
|
|
44208
|
+
key: "showLoad",
|
|
44209
|
+
plugin: "load",
|
|
44210
|
+
label: "Load"
|
|
44211
|
+
},
|
|
44212
|
+
{
|
|
44213
|
+
key: "showNetwork",
|
|
44214
|
+
plugin: "network",
|
|
44215
|
+
label: "Network"
|
|
44216
|
+
},
|
|
44217
|
+
{
|
|
44218
|
+
key: "showDiskIo",
|
|
44219
|
+
plugin: "diskio",
|
|
44220
|
+
label: "Disk I/O"
|
|
44221
|
+
},
|
|
44222
|
+
{
|
|
44223
|
+
key: "showFs",
|
|
44224
|
+
plugin: "fs",
|
|
44225
|
+
label: "Filesystems"
|
|
44226
|
+
},
|
|
44227
|
+
{
|
|
44228
|
+
key: "showProcessList",
|
|
44229
|
+
plugin: "processlist",
|
|
44230
|
+
label: "Process list"
|
|
44231
|
+
},
|
|
44232
|
+
{
|
|
44233
|
+
key: "showContainers",
|
|
44234
|
+
plugin: "containers",
|
|
44235
|
+
label: "Containers"
|
|
44236
|
+
},
|
|
44237
|
+
{
|
|
44238
|
+
key: "showSensors",
|
|
44239
|
+
plugin: "sensors",
|
|
44240
|
+
label: "Sensors"
|
|
44241
|
+
}
|
|
44242
|
+
];
|
|
44243
|
+
function glancesBooleanField(key, label) {
|
|
44244
|
+
return {
|
|
44245
|
+
type: "boolean",
|
|
44246
|
+
key,
|
|
44247
|
+
label,
|
|
44248
|
+
default: true,
|
|
44249
|
+
style: "switch"
|
|
44250
|
+
};
|
|
44251
|
+
}
|
|
44252
|
+
function glancesSettingsSchema() {
|
|
44253
|
+
return { sections: [{
|
|
44254
|
+
id: "glances-panels",
|
|
44255
|
+
title: "Glances panels",
|
|
44256
|
+
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).",
|
|
44257
|
+
columns: 2,
|
|
44258
|
+
fields: GLANCES_PLUGINS.map((plugin) => glancesBooleanField(plugin.key, plugin.label))
|
|
44259
|
+
}] };
|
|
44260
|
+
}
|
|
44261
|
+
function settingsSchemaForProfile(profileId) {
|
|
44262
|
+
if (profileId === "glances") return glancesSettingsSchema();
|
|
44263
|
+
return null;
|
|
44264
|
+
}
|
|
44265
|
+
function glancesSettingsToArgs(settings) {
|
|
44266
|
+
const disabled = GLANCES_PLUGINS.filter((plugin) => settings[plugin.key] === false).map((plugin) => plugin.plugin);
|
|
44267
|
+
if (disabled.length === 0) return [];
|
|
44268
|
+
return ["--disable-plugin", disabled.join(",")];
|
|
44269
|
+
}
|
|
44270
|
+
function sanitizeProfileSettings(profileId, raw) {
|
|
44271
|
+
if (profileId !== "glances") return {};
|
|
44272
|
+
const bag = raw && typeof raw === "object" && !Array.isArray(raw) ? raw : {};
|
|
44273
|
+
const out = {
|
|
44274
|
+
showCpu: true,
|
|
44275
|
+
showMem: true,
|
|
44276
|
+
showLoad: true,
|
|
44277
|
+
showNetwork: true,
|
|
44278
|
+
showDiskIo: true,
|
|
44279
|
+
showFs: true,
|
|
44280
|
+
showProcessList: true,
|
|
44281
|
+
showContainers: true,
|
|
44282
|
+
showSensors: true
|
|
44283
|
+
};
|
|
44284
|
+
for (const plugin of GLANCES_PLUGINS) if (typeof bag[plugin.key] === "boolean") out[plugin.key] = bag[plugin.key];
|
|
44285
|
+
return out;
|
|
44286
|
+
}
|
|
44287
|
+
function profileSettingsToArgs(profileId, settings) {
|
|
44288
|
+
if (profileId !== "glances") return [];
|
|
44289
|
+
return glancesSettingsToArgs(sanitizeProfileSettings(profileId, settings));
|
|
44290
|
+
}
|
|
44291
|
+
function spawnArgsForInstance(input) {
|
|
44292
|
+
const extra = profileSettingsToArgs(input.profileId, input.profileSettings);
|
|
44293
|
+
if (input.instanceArgs.length > 0) return [...input.instanceArgs, ...extra];
|
|
44294
|
+
if (extra.length > 0) return [...input.profileArgs, ...extra];
|
|
44295
|
+
}
|
|
44296
|
+
//#endregion
|
|
44076
44297
|
//#region src/terminal-session-manager.ts
|
|
44077
44298
|
var MIN_GRID = 1;
|
|
44078
44299
|
var MAX_COLS = 1e3;
|
|
@@ -44141,7 +44362,8 @@ var TerminalSessionManager = class {
|
|
|
44141
44362
|
executable: p.file,
|
|
44142
44363
|
args: [...p.args],
|
|
44143
44364
|
cwd: p.cwd ?? "",
|
|
44144
|
-
environment: environmentRecordToEntries(p.env)
|
|
44365
|
+
environment: environmentRecordToEntries(p.env),
|
|
44366
|
+
settingsSchema: settingsSchemaForProfile(p.profileId)
|
|
44145
44367
|
}));
|
|
44146
44368
|
}
|
|
44147
44369
|
setInstanceControl(control) {
|
|
@@ -44542,15 +44764,22 @@ var TerminalAddon = class extends BaseAddon {
|
|
|
44542
44764
|
const localNodeId = declarationOwnerNodeId(this.ctx.kernel.localNodeId);
|
|
44543
44765
|
const cameraRelay = new TerminalCameraRelay({
|
|
44544
44766
|
listProfiles: (nodeId) => nodeId === localNodeId ? manager.listProfiles() : this.ctx.api.terminalSession.listProfiles.query(void 0, nodePin(nodeId)),
|
|
44545
|
-
openSession: (nodeId, input) => {
|
|
44767
|
+
openSession: async (nodeId, input) => {
|
|
44546
44768
|
const instance = input.instanceId ? this.terminalInstances().find((row) => row.id === input.instanceId) : void 0;
|
|
44769
|
+
const profile = (nodeId === localNodeId ? await manager.listProfiles() : await this.ctx.api.terminalSession.listProfiles.query(void 0, nodePin(nodeId))).find((candidate) => candidate.profileId === (instance?.profileId ?? input.profileId));
|
|
44770
|
+
const args = instance ? spawnArgsForInstance({
|
|
44771
|
+
profileId: instance.profileId,
|
|
44772
|
+
instanceArgs: instance.args,
|
|
44773
|
+
profileArgs: profile?.args ?? [],
|
|
44774
|
+
profileSettings: instance.profileSettings
|
|
44775
|
+
}) : void 0;
|
|
44547
44776
|
const payload = {
|
|
44548
44777
|
profileId: input.profileId,
|
|
44549
44778
|
cols: input.cols,
|
|
44550
44779
|
rows: input.rows,
|
|
44551
44780
|
...instance ? {
|
|
44552
44781
|
...instance.executable ? { executable: instance.executable } : {},
|
|
44553
|
-
...
|
|
44782
|
+
...args !== void 0 ? { args: [...args] } : {},
|
|
44554
44783
|
...instance.cwd ? { cwd: instance.cwd } : {},
|
|
44555
44784
|
...instance.environment.length > 0 ? { environment: [...instance.environment] } : {}
|
|
44556
44785
|
} : {}
|
|
@@ -44785,7 +45014,8 @@ var TerminalAddon = class extends BaseAddon {
|
|
|
44785
45014
|
executable: instance.executable,
|
|
44786
45015
|
args: instance.args,
|
|
44787
45016
|
cwd: instance.cwd,
|
|
44788
|
-
environment: instance.environment
|
|
45017
|
+
environment: instance.environment,
|
|
45018
|
+
profileSettings: instance.profileSettings
|
|
44789
45019
|
};
|
|
44790
45020
|
}
|
|
44791
45021
|
replaceTerminalCameraTombstones(stableIds) {
|
|
@@ -44817,7 +45047,8 @@ var TerminalAddon = class extends BaseAddon {
|
|
|
44817
45047
|
executable: input.executable?.trim() || profile.executable || "",
|
|
44818
45048
|
args: input.args ? [...input.args] : [...profile.args ?? []],
|
|
44819
45049
|
cwd: input.cwd?.trim() || profile.cwd || "",
|
|
44820
|
-
environment: input.environment ? [...input.environment] : [...profile.environment ?? []]
|
|
45050
|
+
environment: input.environment ? [...input.environment] : [...profile.environment ?? []],
|
|
45051
|
+
profileSettings: sanitizeProfileSettings(profile.profileId, input.profileSettings)
|
|
44821
45052
|
};
|
|
44822
45053
|
await this.updateGlobalSettings({ terminalInstances: [...this.config.terminalInstances, instance] });
|
|
44823
45054
|
return this.instanceInfo(instance);
|
|
@@ -44837,7 +45068,8 @@ var TerminalAddon = class extends BaseAddon {
|
|
|
44837
45068
|
...input.executable !== void 0 ? { executable: input.executable.trim() } : {},
|
|
44838
45069
|
...input.args !== void 0 ? { args: [...input.args] } : {},
|
|
44839
45070
|
...input.cwd !== void 0 ? { cwd: input.cwd.trim() } : {},
|
|
44840
|
-
...input.environment !== void 0 ? { environment: [...input.environment] } : {}
|
|
45071
|
+
...input.environment !== void 0 ? { environment: [...input.environment] } : {},
|
|
45072
|
+
...input.profileSettings !== void 0 ? { profileSettings: sanitizeProfileSettings(instance.profileId, input.profileSettings) } : {}
|
|
44841
45073
|
};
|
|
44842
45074
|
await this.updateGlobalSettings({ terminalInstances: this.config.terminalInstances.map((candidate) => candidate.id === input.instanceId ? updated : candidate) });
|
|
44843
45075
|
return this.instanceInfo(updated);
|
|
@@ -44905,7 +45137,8 @@ var TerminalAddon = class extends BaseAddon {
|
|
|
44905
45137
|
executable: "",
|
|
44906
45138
|
args: [],
|
|
44907
45139
|
cwd: "",
|
|
44908
|
-
environment: []
|
|
45140
|
+
environment: [],
|
|
45141
|
+
profileSettings: {}
|
|
44909
45142
|
};
|
|
44910
45143
|
await this.updateGlobalSettings({ terminalInstances: [...this.config.terminalInstances, instance] });
|
|
44911
45144
|
return this.instanceInfo(instance);
|