@peers-app/peers-ui 0.34.9 → 0.34.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (81) hide show
  1. package/dist/apps-home/apps-home.js +6 -4
  2. package/dist/components/router.d.ts +1 -1
  3. package/dist/components/router.js +1 -1
  4. package/dist/screens/identity/identity-routes.d.ts +2 -1
  5. package/dist/screens/identity/identity-routes.js +6 -1
  6. package/dist/screens/monitoring/alerts-tab.d.ts +13 -0
  7. package/dist/screens/monitoring/alerts-tab.js +68 -0
  8. package/dist/screens/monitoring/badges.d.ts +25 -0
  9. package/dist/screens/monitoring/badges.js +68 -0
  10. package/dist/screens/monitoring/calls-tab.d.ts +30 -0
  11. package/dist/screens/monitoring/calls-tab.js +104 -0
  12. package/dist/screens/monitoring/charts/chart-math.d.ts +103 -0
  13. package/dist/screens/monitoring/charts/chart-math.js +200 -0
  14. package/dist/screens/monitoring/charts/histogram-chart.d.ts +25 -0
  15. package/dist/screens/monitoring/charts/histogram-chart.js +74 -0
  16. package/dist/screens/monitoring/charts/line-chart.d.ts +33 -0
  17. package/dist/screens/monitoring/charts/line-chart.js +103 -0
  18. package/dist/screens/monitoring/charts/sparkline.d.ts +30 -0
  19. package/dist/screens/monitoring/charts/sparkline.js +61 -0
  20. package/dist/screens/monitoring/charts/use-width.d.ts +9 -0
  21. package/dist/screens/monitoring/charts/use-width.js +31 -0
  22. package/dist/screens/monitoring/definition-forms.d.ts +113 -0
  23. package/dist/screens/monitoring/definition-forms.js +341 -0
  24. package/dist/screens/monitoring/definitions-tab.d.ts +20 -0
  25. package/dist/screens/monitoring/definitions-tab.js +110 -0
  26. package/dist/screens/monitoring/device-picker.d.ts +23 -0
  27. package/dist/screens/monitoring/device-picker.js +30 -0
  28. package/dist/screens/monitoring/devices-tab.d.ts +6 -0
  29. package/dist/screens/monitoring/devices-tab.js +74 -0
  30. package/dist/screens/monitoring/form-fields.d.ts +76 -0
  31. package/dist/screens/monitoring/form-fields.js +65 -0
  32. package/dist/screens/monitoring/format.d.ts +51 -0
  33. package/dist/screens/monitoring/format.js +150 -0
  34. package/dist/screens/monitoring/log-lines.d.ts +74 -0
  35. package/dist/screens/monitoring/log-lines.js +138 -0
  36. package/dist/screens/monitoring/log-row.d.ts +12 -0
  37. package/dist/screens/monitoring/log-row.js +23 -0
  38. package/dist/screens/monitoring/logs-tab.d.ts +15 -0
  39. package/dist/screens/monitoring/logs-tab.js +256 -0
  40. package/dist/screens/monitoring/metric-definition-form.d.ts +15 -0
  41. package/dist/screens/monitoring/metric-definition-form.js +50 -0
  42. package/dist/screens/monitoring/metrics-tab.d.ts +37 -0
  43. package/dist/screens/monitoring/metrics-tab.js +149 -0
  44. package/dist/screens/monitoring/monitored-devices.d.ts +84 -0
  45. package/dist/screens/monitoring/monitored-devices.js +193 -0
  46. package/dist/screens/monitoring/monitoring-routes.d.ts +40 -0
  47. package/dist/screens/monitoring/monitoring-routes.js +82 -0
  48. package/dist/screens/monitoring/monitoring-screen.d.ts +18 -0
  49. package/dist/screens/monitoring/monitoring-screen.js +71 -0
  50. package/dist/screens/monitoring/overview-tab.d.ts +51 -0
  51. package/dist/screens/monitoring/overview-tab.js +136 -0
  52. package/dist/screens/monitoring/telemetry-client.d.ts +48 -0
  53. package/dist/screens/monitoring/telemetry-client.js +92 -0
  54. package/dist/screens/monitoring/trigger-form.d.ts +18 -0
  55. package/dist/screens/monitoring/trigger-form.js +71 -0
  56. package/dist/screens/monitoring/use-telemetry.d.ts +37 -0
  57. package/dist/screens/monitoring/use-telemetry.js +119 -0
  58. package/dist/screens/network-viewer/remote-logs-panel.d.ts +1 -1
  59. package/dist/screens/network-viewer/remote-logs-panel.js +5 -3
  60. package/dist/system-apps/index.d.ts +1 -1
  61. package/dist/system-apps/index.js +5 -5
  62. package/dist/system-apps/monitoring.app.d.ts +6 -0
  63. package/dist/system-apps/monitoring.app.js +13 -0
  64. package/dist/tabs-layout/tabs-state.d.ts +4 -2
  65. package/dist/tabs-layout/tabs-state.js +23 -11
  66. package/dist/theme.css +32 -0
  67. package/package.json +3 -3
  68. package/dist/screens/console-logs/console-logs-list.d.ts +0 -2
  69. package/dist/screens/console-logs/console-logs-list.js +0 -284
  70. package/dist/screens/console-logs/follow-newest.d.ts +0 -11
  71. package/dist/screens/console-logs/follow-newest.js +0 -17
  72. package/dist/screens/console-logs/log-display.d.ts +0 -12
  73. package/dist/screens/console-logs/log-display.js +0 -69
  74. package/dist/screens/console-logs/log-filters.d.ts +0 -10
  75. package/dist/screens/console-logs/log-filters.js +0 -8
  76. package/dist/screens/console-logs/mobile-log-card.d.ts +0 -8
  77. package/dist/screens/console-logs/mobile-log-card.js +0 -94
  78. package/dist/screens/console-logs/resizable-table-header.d.ts +0 -14
  79. package/dist/screens/console-logs/resizable-table-header.js +0 -62
  80. package/dist/system-apps/console-logs.app.d.ts +0 -2
  81. package/dist/system-apps/console-logs.app.js +0 -8
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OVERVIEW_METRICS = void 0;
4
+ exports.readOverview = readOverview;
5
+ exports.summarizeOverview = summarizeOverview;
6
+ exports.OverviewTab = OverviewTab;
7
+ const jsx_runtime_1 = require("react/jsx-runtime");
8
+ const peers_sdk_1 = require("@peers-app/peers-sdk");
9
+ const badges_1 = require("./badges");
10
+ const chart_math_1 = require("./charts/chart-math");
11
+ const sparkline_1 = require("./charts/sparkline");
12
+ const form_fields_1 = require("./form-fields");
13
+ const format_1 = require("./format");
14
+ const telemetry_client_1 = require("./telemetry-client");
15
+ const use_telemetry_1 = require("./use-telemetry");
16
+ /** Metrics the Overview's tiles read. */
17
+ exports.OVERVIEW_METRICS = {
18
+ errors: "logs.errors",
19
+ calls: "calls.duration",
20
+ failedDials: "mesh.attempt.failures",
21
+ };
22
+ /**
23
+ * Read everything the Overview shows: the last 24 hours of errors, calls and failed dials by hour,
24
+ * telemetry's own status, and the alerts. The calls leave out Monitoring's own reads, which would
25
+ * otherwise set their p95. One part failing leaves the rest.
26
+ *
27
+ * @param telemetry - The device's System Telemetry.
28
+ * @param now - The current time (for tests).
29
+ */
30
+ async function readOverview(telemetry, now = Date.now()) {
31
+ const from = now - peers_sdk_1.RESOLUTION_MS.day;
32
+ const range = { from, to: now, resolution: "hour" };
33
+ const [errors, calls, failedDials, status, alerts] = await Promise.allSettled([
34
+ telemetry.tools.queryMetric({ metricId: exports.OVERVIEW_METRICS.errors, ...range, stats: ["count"] }),
35
+ telemetry.tools.queryMetric({
36
+ metricId: exports.OVERVIEW_METRICS.calls,
37
+ ...range,
38
+ exclude: telemetry_client_1.OWN_READS,
39
+ stats: ["count", "p95"],
40
+ histogram: true,
41
+ }),
42
+ telemetry.tools.queryMetric({
43
+ metricId: exports.OVERVIEW_METRICS.failedDials,
44
+ ...range,
45
+ stats: ["count"],
46
+ }),
47
+ telemetry.tools.status({}),
48
+ telemetry.tools.alerts({ limit: 10 }),
49
+ ]);
50
+ const settled = [errors, calls, failedDials, status, alerts];
51
+ if (settled.every((result) => result.status === "rejected")) {
52
+ throw errors.reason;
53
+ }
54
+ const value = (result) => result.status === "fulfilled" ? result.value : undefined;
55
+ return {
56
+ errors: value(errors),
57
+ calls: value(calls),
58
+ failedDials: value(failedDials),
59
+ status: value(status),
60
+ alerts: value(alerts),
61
+ };
62
+ }
63
+ /**
64
+ * Work out the Overview's headline numbers from what {@link readOverview} read.
65
+ *
66
+ * @param data - The Overview's reads.
67
+ */
68
+ function summarizeOverview(data) {
69
+ return {
70
+ errors: data.errors?.points.reduce((total, point) => total + point.count, 0),
71
+ callCount: data.calls ? (0, chart_math_1.sumOf)(data.calls.points.map((p) => p.count)) : undefined,
72
+ p95: data.calls?.histogram ? (0, chart_math_1.percentileFromBins)(data.calls.histogram, 0.95) : undefined,
73
+ active: data.alerts?.triggers.filter((t) => t.state !== "ok" && !t.disabled),
74
+ databaseBytes: data.status?.databaseBytes,
75
+ };
76
+ }
77
+ /**
78
+ * Overview: errors, call latency, failed dials and the telemetry database's size over the last 24
79
+ * hours, then what's firing and the latest alerts.
80
+ */
81
+ function OverviewTab(props) {
82
+ const { data, error, loading, readAt, refresh } = (0, use_telemetry_1.useTelemetryRead)(props.location.deviceId, (telemetry) => readOverview(telemetry), []);
83
+ const toolbar = ((0, jsx_runtime_1.jsx)("div", { className: "d-flex justify-content-end mb-2", children: (0, jsx_runtime_1.jsx)(form_fields_1.RefreshButton, { onClick: refresh, loading: loading, readAt: data ? readAt : undefined }) }));
84
+ if (!data && error) {
85
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [toolbar, (0, jsx_runtime_1.jsx)("div", { className: "alert alert-warning", children: (0, telemetry_client_1.describeTelemetryError)(error) })] }));
86
+ }
87
+ if (!data)
88
+ return (0, jsx_runtime_1.jsx)("div", { className: "text-body-secondary", children: "Loading\u2026" });
89
+ const openMetric = (metricId) => props.navigate({ section: "metrics", metricId });
90
+ const errors = trendOf(data.errors, "count");
91
+ const dials = trendOf(data.failedDials, "count");
92
+ const callP95 = trendOf(data.calls, "p95");
93
+ const summary = summarizeOverview(data);
94
+ const { callCount, p95 } = summary;
95
+ const active = summary.active ?? [];
96
+ return ((0, jsx_runtime_1.jsxs)("div", { style: { opacity: loading ? 0.7 : 1, transition: "opacity 150ms" }, children: [toolbar, (0, jsx_runtime_1.jsxs)("div", { className: "row g-3 mb-4", children: [(0, jsx_runtime_1.jsx)(Tile, { label: "Errors, last 24 hours", value: summary.errors === undefined ? "–" : (0, format_1.formatNumber)(summary.errors), caption: "Error lines logged", trend: { ...errors, label: "Errors per hour", formatValue: format_1.formatNumber }, onOpen: () => openMetric(exports.OVERVIEW_METRICS.errors) }), (0, jsx_runtime_1.jsx)(Tile, { label: "Call p95, last 24 hours", value: (0, format_1.formatDuration)(p95), caption: callCount === undefined ? "Contract calls" : `${(0, format_1.formatNumber)(callCount)} calls`, trend: { ...callP95, label: "Call p95 per hour", formatValue: format_1.formatDuration }, onOpen: () => openMetric(exports.OVERVIEW_METRICS.calls) }), (0, jsx_runtime_1.jsx)(Tile, { label: "Failed dials, last 24 hours", value: data.failedDials ? (0, format_1.formatNumber)((0, chart_math_1.sumOf)(dials.values)) : "–", caption: "Connection attempts that failed", trend: { ...dials, label: "Failed dials per hour", formatValue: format_1.formatNumber }, onOpen: () => openMetric(exports.OVERVIEW_METRICS.failedDials) }), (0, jsx_runtime_1.jsx)(Tile, { label: "Telemetry database", value: (0, format_1.formatBytes)(summary.databaseBytes), caption: data.status
97
+ ? `${(0, format_1.formatNumber)(data.status.logRows)} log lines · ${(0, format_1.formatNumber)(data.status.rollupRows)} metric rows`
98
+ : "Size on disk" })] }), (0, jsx_runtime_1.jsx)(TelemetryHealth, { status: data.status, device: (0, telemetry_client_1.isThisDevice)(props.location.deviceId) ? "This device" : "That device" }), (0, jsx_runtime_1.jsxs)("h2", { className: "h6 d-flex align-items-center gap-2", children: ["Alerts", (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-link btn-sm p-0 ms-auto", onClick: () => props.navigate({ section: "alerts" }), children: "All alerts" })] }), !data.alerts ? ((0, jsx_runtime_1.jsx)("p", { className: "text-body-secondary small", children: "Couldn't read this device's alerts." })) : active.length === 0 ? ((0, jsx_runtime_1.jsxs)("p", { className: "text-body-secondary small", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-check-circle me-1", "aria-hidden": "true" }), "Nothing is firing."] })) : ((0, jsx_runtime_1.jsx)("ul", { className: "list-group mb-3", children: active.map((trigger) => ((0, jsx_runtime_1.jsxs)("li", { className: "list-group-item d-flex align-items-center gap-2", children: [(0, jsx_runtime_1.jsx)(badges_1.AlertStateBadge, { state: trigger.state }), (0, jsx_runtime_1.jsx)("span", { className: "flex-grow-1", children: trigger.description || trigger.triggerId }), (0, jsx_runtime_1.jsx)("span", { className: "small text-body-secondary", children: (0, format_1.formatAgo)(trigger.since) })] }, trigger.triggerId))) })), data.alerts && data.alerts.events.length > 0 ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("h3", { className: "h6 text-body-secondary small mt-3", children: "Recent" }), (0, jsx_runtime_1.jsx)("ul", { className: "list-unstyled small", children: data.alerts.events.slice(0, 5).map((event) => ((0, jsx_runtime_1.jsxs)("li", { className: "d-flex gap-2 align-items-center mb-1", children: [(0, jsx_runtime_1.jsx)(badges_1.AlertStateBadge, { state: event.state }), (0, jsx_runtime_1.jsx)("span", { className: "flex-grow-1 text-truncate", children: event.detail || event.triggerId }), (0, jsx_runtime_1.jsx)("span", { className: "text-body-secondary text-nowrap", children: (0, format_1.formatAgo)(event.at) })] }, `${event.triggerId}:${event.at}:${event.state}`))) })] })) : null] }));
99
+ }
100
+ /** A metric's last 24 hours by hour, as a sparkline draws it. */
101
+ function trendOf(result, stat) {
102
+ if (!result)
103
+ return { values: [], times: [] };
104
+ const data = (0, chart_math_1.toTimeSeries)(result, stat);
105
+ return { values: data.series[0]?.values ?? [], times: data.times };
106
+ }
107
+ function Tile(props) {
108
+ const { trend } = props;
109
+ const summary = trend ? (0, sparkline_1.describeTrend)(trend, trend.formatValue) : undefined;
110
+ const body = ((0, jsx_runtime_1.jsxs)("div", { className: "card-body", children: [(0, jsx_runtime_1.jsx)("div", { className: "small text-body-secondary", children: props.label }), (0, jsx_runtime_1.jsx)("div", { className: "fs-3 fw-semibold", children: props.value }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-end justify-content-between gap-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "small text-body-secondary", children: props.caption }), trend ? (0, jsx_runtime_1.jsx)(sparkline_1.Sparkline, { ...trend }) : null] })] }));
111
+ const name = [
112
+ `${props.label}: ${props.value}.`,
113
+ summary && trend ? `${trend.label}: ${summary}.` : "",
114
+ "Open in Metrics",
115
+ ];
116
+ return ((0, jsx_runtime_1.jsx)("div", { className: "col-12 col-sm-6 col-xl-3", children: props.onOpen ? ((0, jsx_runtime_1.jsx)("button", { type: "button", className: "card h-100 w-100 text-start", onClick: props.onOpen, "aria-label": name.filter(Boolean).join(" "), children: body })) : ((0, jsx_runtime_1.jsx)("div", { className: "card h-100", children: body })) }));
117
+ }
118
+ /**
119
+ * Telemetry's own trouble: definitions the device shown switched off or refused, and lines it
120
+ * dropped. `device` names it as Definitions does: this device, or that one.
121
+ */
122
+ function TelemetryHealth(props) {
123
+ const { status, device } = props;
124
+ if (!status)
125
+ return null;
126
+ // Earlier telemetry v1 devices report stopped metrics only.
127
+ const { stopped, stoppedTriggers = [] } = status;
128
+ if (stopped.length === 0 && stoppedTriggers.length === 0 && status.droppedLines === 0) {
129
+ return null;
130
+ }
131
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "alert alert-warning small", children: [stopped.length > 0 ? ((0, jsx_runtime_1.jsx)(StoppedList, { heading: `${device} switched off ${stopped.length === 1 ? "a metric" : `${stopped.length} metrics`}`, items: stopped.map((item) => ({ ...item, id: item.metricId })) })) : null, stoppedTriggers.length > 0 ? ((0, jsx_runtime_1.jsx)(StoppedList, { heading: `${device} refused ${stoppedTriggers.length === 1 ? "a trigger" : `${stoppedTriggers.length} triggers`}`, items: stoppedTriggers.map((item) => ({ ...item, id: item.triggerId })) })) : null, status.droppedLines > 0 ? ((0, jsx_runtime_1.jsxs)("div", { children: ["Log lines and calls dropped since startup \u00B7 ", (0, format_1.formatNumber)(status.droppedLines)] })) : null] }));
132
+ }
133
+ /** Definitions a device stopped, each with where it came from and why. */
134
+ function StoppedList(props) {
135
+ return ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "fw-semibold mb-1", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-exclamation-triangle-fill me-1", "aria-hidden": "true" }), props.heading] }), (0, jsx_runtime_1.jsx)("ul", { className: "mb-1", children: props.items.map((item) => ((0, jsx_runtime_1.jsxs)("li", { children: [(0, jsx_runtime_1.jsx)("code", { children: item.id }), item.origin ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [" ", (0, jsx_runtime_1.jsx)(badges_1.OriginBadge, { origin: item.origin, packageId: item.packageId })] })) : null, ": ", item.reason] }, `${item.origin ?? ""}:${item.packageId ?? ""}:${item.id}`))) })] }));
136
+ }
@@ -0,0 +1,48 @@
1
+ import { type ITelemetryConsumer } from "@peers-app/peers-sdk";
2
+ /**
3
+ * Monitoring's own reads as the call metrics label them: its calls to System Telemetry, made as it
4
+ * refreshes. Pass it as a query's `exclude` to leave them out of `calls.duration`.
5
+ */
6
+ export declare const OWN_READS: Readonly<Record<string, string>>;
7
+ /**
8
+ * Whether a device id names this device: no id, or this device's own.
9
+ *
10
+ * @param deviceId - The device being looked at.
11
+ */
12
+ export declare function isThisDevice(deviceId: string | undefined): boolean;
13
+ /**
14
+ * System Telemetry on this device, or on another of the user's devices. Another device's calls go
15
+ * through this device's host, which forwards them over the mesh; that device answers only its
16
+ * owner's devices (System Telemetry has no remote access level).
17
+ *
18
+ * @param deviceId - The device to read; omit for this device.
19
+ * @returns A consumer whose tools run on that device.
20
+ */
21
+ export declare function getTelemetry(deviceId?: string): Promise<ITelemetryConsumer>;
22
+ /**
23
+ * Why a telemetry call failed:
24
+ *
25
+ * - `unavailable`: the device runs a Peers version without telemetry.
26
+ * - `denied`: the device doesn't take this call from here (another device's `clearLogs`, say).
27
+ * - `unreachable`: the device isn't connected, or didn't answer.
28
+ * - `failed`: anything else, such as a definition the device refused to save.
29
+ */
30
+ export type TelemetryErrorKind = "unavailable" | "denied" | "unreachable" | "failed";
31
+ /**
32
+ * Classify a telemetry call's error, so a view can say what to do about it.
33
+ *
34
+ * @param error - What the call threw.
35
+ */
36
+ export declare function classifyTelemetryError(error: unknown): TelemetryErrorKind;
37
+ /**
38
+ * An error's text as the tool worded it.
39
+ *
40
+ * @param error - What a call threw.
41
+ */
42
+ export declare function errorText(error: unknown): string;
43
+ /**
44
+ * A sentence for a failed read, worded for its kind.
45
+ *
46
+ * @param error - What the call threw.
47
+ */
48
+ export declare function describeTelemetryError(error: unknown): string;
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OWN_READS = void 0;
4
+ exports.isThisDevice = isThisDevice;
5
+ exports.getTelemetry = getTelemetry;
6
+ exports.classifyTelemetryError = classifyTelemetryError;
7
+ exports.errorText = errorText;
8
+ exports.describeTelemetryError = describeTelemetryError;
9
+ const peers_sdk_1 = require("@peers-app/peers-sdk");
10
+ const local = (0, peers_sdk_1.hostContractConsumer)((0, peers_sdk_1.getTelemetryContractDefinition)());
11
+ /**
12
+ * Monitoring's own reads as the call metrics label them: its calls to System Telemetry, made as it
13
+ * refreshes. Pass it as a query's `exclude` to leave them out of `calls.duration`.
14
+ */
15
+ exports.OWN_READS = {
16
+ contract: (0, peers_sdk_1.getTelemetryContractDefinition)().name,
17
+ };
18
+ let remote;
19
+ /**
20
+ * Whether a device id names this device: no id, or this device's own.
21
+ *
22
+ * @param deviceId - The device being looked at.
23
+ */
24
+ function isThisDevice(deviceId) {
25
+ return !deviceId || deviceId === (0, peers_sdk_1.thisDeviceId)();
26
+ }
27
+ /**
28
+ * System Telemetry on this device, or on another of the user's devices. Another device's calls go
29
+ * through this device's host, which forwards them over the mesh; that device answers only its
30
+ * owner's devices (System Telemetry has no remote access level).
31
+ *
32
+ * @param deviceId - The device to read; omit for this device.
33
+ * @returns A consumer whose tools run on that device.
34
+ */
35
+ async function getTelemetry(deviceId) {
36
+ if (isThisDevice(deviceId)) {
37
+ return local.get();
38
+ }
39
+ const transport = (0, peers_sdk_1.getHostContractTransport)() ?? (await (0, peers_sdk_1.waitForHostContractTransport)({ timeoutMs: 5_000 }));
40
+ if (remote?.transport !== transport) {
41
+ remote?.consumer.dispose();
42
+ remote = {
43
+ transport,
44
+ consumer: (0, peers_sdk_1.createRemoteContractConsumer)((0, peers_sdk_1.getTelemetryContractDefinition)(), transport),
45
+ };
46
+ }
47
+ return remote.consumer.device(deviceId);
48
+ }
49
+ /**
50
+ * Classify a telemetry call's error, so a view can say what to do about it.
51
+ *
52
+ * @param error - What the call threw.
53
+ */
54
+ function classifyTelemetryError(error) {
55
+ const message = errorText(error);
56
+ if (/No contract provider registered|has no live resolver|no provider for/i.test(message)) {
57
+ return "unavailable";
58
+ }
59
+ if (/Permission denied/i.test(message)) {
60
+ return "denied";
61
+ }
62
+ if (message.includes(peers_sdk_1.CONNECTION_CLOSED_MESSAGE) ||
63
+ /not connected|not reachable|timed out|did not answer/i.test(message)) {
64
+ return "unreachable";
65
+ }
66
+ return "failed";
67
+ }
68
+ /**
69
+ * An error's text as the tool worded it.
70
+ *
71
+ * @param error - What a call threw.
72
+ */
73
+ function errorText(error) {
74
+ return error instanceof Error ? error.message : String(error);
75
+ }
76
+ /**
77
+ * A sentence for a failed read, worded for its kind.
78
+ *
79
+ * @param error - What the call threw.
80
+ */
81
+ function describeTelemetryError(error) {
82
+ switch (classifyTelemetryError(error)) {
83
+ case "unavailable":
84
+ return "This device runs a version of Peers without telemetry. Update it to see its logs and metrics.";
85
+ case "unreachable":
86
+ return `Couldn't reach this device: ${errorText(error)}`;
87
+ case "denied":
88
+ return `This device refused: ${errorText(error)}`;
89
+ default:
90
+ return errorText(error);
91
+ }
92
+ }
@@ -0,0 +1,18 @@
1
+ import type { IMetricInfo, ITriggerDefinition } from "@peers-app/peers-sdk";
2
+ /** Props for {@link TriggerForm}. */
3
+ export interface TriggerFormProps {
4
+ /** The trigger to edit; omit to create one. */
5
+ definition?: ITriggerDefinition;
6
+ /** The device's metrics, offered for the trigger's metric. */
7
+ metrics: IMetricInfo[];
8
+ /** Called once it's saved, with its id. */
9
+ onSaved: (triggerId: string) => void;
10
+ onCancel: () => void;
11
+ }
12
+ /**
13
+ * Create or edit one of the user's triggers: a condition on a metric, checked on each device as
14
+ * each minute closes, and what to do when it fires (notify, call a tool, or both). It's saved on
15
+ * this device and syncs to the user's other devices. A save the device refuses shows the reason as
16
+ * the device words it.
17
+ */
18
+ export declare function TriggerForm(props: TriggerFormProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TriggerForm = TriggerForm;
4
+ const jsx_runtime_1 = require("react/jsx-runtime");
5
+ const react_1 = require("react");
6
+ const definition_forms_1 = require("./definition-forms");
7
+ const form_fields_1 = require("./form-fields");
8
+ const telemetry_client_1 = require("./telemetry-client");
9
+ const STATS = [
10
+ { value: "count", label: "count" },
11
+ { value: "sum", label: "sum" },
12
+ { value: "avg", label: "average" },
13
+ { value: "min", label: "minimum" },
14
+ { value: "max", label: "maximum" },
15
+ { value: "last", label: "last" },
16
+ { value: "p50", label: "p50" },
17
+ { value: "p90", label: "p90" },
18
+ { value: "p95", label: "p95" },
19
+ { value: "p99", label: "p99" },
20
+ { value: "ratio", label: "ratio (share that matches)" },
21
+ ];
22
+ const OPS = [
23
+ { value: ">", label: "above (>)" },
24
+ { value: ">=", label: "at or above (≥)" },
25
+ { value: "<", label: "below (<)" },
26
+ { value: "<=", label: "at or below (≤)" },
27
+ ];
28
+ const LEVELS = [
29
+ { value: "priority", label: "Priority" },
30
+ { value: "quiet", label: "Quiet" },
31
+ { value: "loud", label: "Loud" },
32
+ ];
33
+ /**
34
+ * Create or edit one of the user's triggers: a condition on a metric, checked on each device as
35
+ * each minute closes, and what to do when it fires (notify, call a tool, or both). It's saved on
36
+ * this device and syncs to the user's other devices. A save the device refuses shows the reason as
37
+ * the device words it.
38
+ */
39
+ function TriggerForm(props) {
40
+ const editing = !!props.definition;
41
+ const [form, setForm] = (0, react_1.useState)(() => props.definition
42
+ ? (0, definition_forms_1.triggerDefinitionToForm)(props.definition)
43
+ : (0, definition_forms_1.emptyTriggerForm)(props.metrics[0]?.metricId));
44
+ const [error, setError] = (0, react_1.useState)();
45
+ const [saving, setSaving] = (0, react_1.useState)(false);
46
+ const set = (key) => (value) => setForm((prev) => ({ ...prev, [key]: value }));
47
+ const save = async () => {
48
+ const built = (0, definition_forms_1.toTriggerDefinition)(form);
49
+ if (built.error !== undefined) {
50
+ setError(built.error);
51
+ return;
52
+ }
53
+ setSaving(true);
54
+ setError(undefined);
55
+ try {
56
+ const telemetry = await (0, telemetry_client_1.getTelemetry)();
57
+ const result = await telemetry.tools.saveTriggerDefinition({ definition: built.definition });
58
+ props.onSaved(result.triggerId);
59
+ }
60
+ catch (cause) {
61
+ setError((0, telemetry_client_1.errorText)(cause));
62
+ }
63
+ finally {
64
+ setSaving(false);
65
+ }
66
+ };
67
+ return ((0, jsx_runtime_1.jsxs)("form", { className: "card card-body mb-3", "aria-label": editing ? `Edit trigger ${form.triggerId}` : "New trigger", onSubmit: (event) => {
68
+ event.preventDefault();
69
+ void save();
70
+ }, children: [(0, jsx_runtime_1.jsx)("h2", { className: "h6", children: editing ? `Edit ${form.triggerId}` : "New trigger" }), (0, jsx_runtime_1.jsxs)("div", { className: "row g-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "col-md-6", children: (0, jsx_runtime_1.jsx)(form_fields_1.TextField, { id: "trigger-id", label: "Trigger id", value: form.triggerId, onChange: set("triggerId"), disabled: editing, monospace: true, placeholder: "sync.slow" }) }), (0, jsx_runtime_1.jsxs)("div", { className: "col-md-6", children: [(0, jsx_runtime_1.jsx)(form_fields_1.TextField, { id: "trigger-metric", label: "Metric", value: form.metricId, onChange: set("metricId"), monospace: true, list: "trigger-metrics" }), (0, jsx_runtime_1.jsx)("datalist", { id: "trigger-metrics", children: props.metrics.map((metric) => ((0, jsx_runtime_1.jsx)("option", { value: metric.metricId }, metric.metricId))) })] })] }), (0, jsx_runtime_1.jsx)(form_fields_1.TextField, { id: "trigger-description", label: "Description", value: form.description, onChange: set("description") }), (0, jsx_runtime_1.jsx)(form_fields_1.TextAreaField, { id: "trigger-where", label: "Only these series", value: form.where, onChange: set("where"), placeholder: "groupId = 00abc\u2026", hint: 'One "label = value" per line; leave empty for every series.' }), (0, jsx_runtime_1.jsx)("h3", { className: "h6 small text-body-secondary mt-2", children: "Condition" }), (0, jsx_runtime_1.jsxs)("div", { className: "row g-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "col-6 col-md-3", children: (0, jsx_runtime_1.jsx)(form_fields_1.SelectField, { id: "trigger-stat", label: "Statistic", value: form.stat, options: STATS, onChange: set("stat") }) }), (0, jsx_runtime_1.jsx)("div", { className: "col-6 col-md-3", children: (0, jsx_runtime_1.jsx)(form_fields_1.TextField, { id: "trigger-window", label: "Over (minutes)", value: form.windowMinutes, onChange: set("windowMinutes"), inputMode: "numeric", hint: "1 to 60." }) }), (0, jsx_runtime_1.jsx)("div", { className: "col-6 col-md-3", children: (0, jsx_runtime_1.jsx)(form_fields_1.SelectField, { id: "trigger-op", label: "Is", value: form.op, options: OPS, onChange: set("op") }) }), (0, jsx_runtime_1.jsx)("div", { className: "col-6 col-md-3", children: (0, jsx_runtime_1.jsx)(form_fields_1.TextField, { id: "trigger-threshold", label: "Threshold", value: form.threshold, onChange: set("threshold"), inputMode: "decimal" }) })] }), form.stat === "ratio" ? ((0, jsx_runtime_1.jsx)(form_fields_1.TextAreaField, { id: "trigger-ratio-where", label: "Counted as matching", value: form.ratioWhere, onChange: set("ratioWhere"), placeholder: "outcome = error", hint: "The share of the window's count whose labels also equal these (0 to 1)." })) : null, (0, jsx_runtime_1.jsxs)("div", { className: "row g-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "col-6", children: (0, jsx_runtime_1.jsx)(form_fields_1.TextField, { id: "trigger-min-count", label: "Ignore until the window holds", value: form.minCount, onChange: set("minCount"), inputMode: "numeric", hint: "Observations; optional." }) }), (0, jsx_runtime_1.jsx)("div", { className: "col-6", children: (0, jsx_runtime_1.jsx)(form_fields_1.TextField, { id: "trigger-for", label: "Fire after it holds for (minutes)", value: form.forMinutes, onChange: set("forMinutes"), inputMode: "numeric" }) })] }), (0, jsx_runtime_1.jsx)("h3", { className: "h6 small text-body-secondary mt-2", children: "When it fires" }), (0, jsx_runtime_1.jsx)(form_fields_1.CheckField, { id: "trigger-notify", label: "Notify me (taken back when it resolves)", checked: form.notify, onChange: set("notify") }), form.notify ? ((0, jsx_runtime_1.jsxs)("div", { className: "row g-2 ms-3", children: [(0, jsx_runtime_1.jsx)("div", { className: "col-md-5", children: (0, jsx_runtime_1.jsx)(form_fields_1.TextField, { id: "trigger-notify-title", label: "Title", value: form.notifyTitle, onChange: set("notifyTitle") }) }), (0, jsx_runtime_1.jsx)("div", { className: "col-md-5", children: (0, jsx_runtime_1.jsx)(form_fields_1.TextField, { id: "trigger-notify-body", label: "Body", value: form.notifyBody, onChange: set("notifyBody") }) }), (0, jsx_runtime_1.jsx)("div", { className: "col-md-2", children: (0, jsx_runtime_1.jsx)(form_fields_1.SelectField, { id: "trigger-notify-level", label: "Level", value: form.notifyLevel, options: LEVELS, onChange: set("notifyLevel") }) })] })) : null, (0, jsx_runtime_1.jsx)(form_fields_1.CheckField, { id: "trigger-tool", label: "Call a tool (as you)", checked: form.tool, onChange: set("tool") }), form.tool ? ((0, jsx_runtime_1.jsxs)("div", { className: "ms-3", children: [(0, jsx_runtime_1.jsxs)("div", { className: "row g-2", children: [(0, jsx_runtime_1.jsx)("div", { className: "col-md-5", children: (0, jsx_runtime_1.jsx)(form_fields_1.TextField, { id: "trigger-tool-contract", label: "Contract id", value: form.toolContractId, onChange: set("toolContractId"), monospace: true }) }), (0, jsx_runtime_1.jsx)("div", { className: "col-md-2", children: (0, jsx_runtime_1.jsx)(form_fields_1.TextField, { id: "trigger-tool-version", label: "Version", value: form.toolVersion, onChange: set("toolVersion"), inputMode: "numeric" }) }), (0, jsx_runtime_1.jsx)("div", { className: "col-md-5", children: (0, jsx_runtime_1.jsx)(form_fields_1.TextField, { id: "trigger-tool-name", label: "Tool", value: form.toolName, onChange: set("toolName"), monospace: true }) })] }), (0, jsx_runtime_1.jsx)(form_fields_1.TextAreaField, { id: "trigger-tool-args", label: "Arguments (JSON)", value: form.toolArgs, onChange: set("toolArgs"), rows: 3, placeholder: '{ "reason": "sync is slow" }' }), (0, jsx_runtime_1.jsx)(form_fields_1.TextField, { id: "trigger-tool-provider", label: "Provider package id", value: form.toolProviderPackageId, onChange: set("toolProviderPackageId"), monospace: true, hint: "Only when the contract has more than one provider." })] })) : null, (0, jsx_runtime_1.jsx)(form_fields_1.CheckField, { id: "trigger-disabled", label: "Off (kept, but not checked)", checked: form.disabled, onChange: set("disabled") }), error ? ((0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger small py-2", role: "alert", children: error })) : null, (0, jsx_runtime_1.jsxs)("div", { className: "d-flex gap-2", children: [(0, jsx_runtime_1.jsx)("button", { type: "submit", className: "btn btn-primary btn-sm", disabled: saving, children: saving ? "Saving…" : "Save" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-outline-secondary btn-sm", onClick: props.onCancel, children: "Cancel" }), (0, jsx_runtime_1.jsx)("span", { className: "small text-body-secondary align-self-center ms-auto", children: "Syncs to your other devices." })] })] }));
71
+ }
@@ -0,0 +1,37 @@
1
+ import { type ITelemetryConsumer } from "@peers-app/peers-sdk";
2
+ import { type DependencyList } from "react";
3
+ import { type IMonitoredDevice } from "./monitored-devices";
4
+ /** A telemetry read's state. */
5
+ export interface ITelemetryRead<T> {
6
+ /** The latest result; kept while a refresh runs, cleared on failure or when the device changes. */
7
+ data: T | undefined;
8
+ /** What the latest attempt threw, until one succeeds. */
9
+ error: unknown;
10
+ /** Whether a read is running. */
11
+ loading: boolean;
12
+ /** When `data` was read, epoch ms. */
13
+ readAt: number | undefined;
14
+ /** Read again now. */
15
+ refresh: () => void;
16
+ }
17
+ /**
18
+ * Read from a device's System Telemetry, again whenever `deps` change and, while the page is
19
+ * visible, `refreshMs` after the last read finished. A refresh keeps the last result on screen (a
20
+ * view dims it); a failed read clears it; a different device starts empty, so one device's numbers
21
+ * never show under another's name.
22
+ *
23
+ * @param deviceId - The device to read; omit for this device.
24
+ * @param read - The read, given the device's consumer.
25
+ * @param deps - What the read depends on, besides the device.
26
+ * @param refreshMs - Read again this often; omit to read only on change.
27
+ */
28
+ export declare function useTelemetryRead<T>(deviceId: string | undefined, read: (telemetry: ITelemetryConsumer) => Promise<T>, deps: DependencyList, refreshMs?: number): ITelemetryRead<T>;
29
+ /**
30
+ * The devices Monitoring lists ({@link buildMonitoredDevices}): this one first, the user's others
31
+ * by name, then other users' connected devices that let them read their telemetry. `undefined`
32
+ * until the user's own are read; others' join the list once they've answered. Whether one of the
33
+ * user's own can be reached shows when Monitoring reads it.
34
+ *
35
+ * @param round - Ask other users' devices again whenever this changes (after the first).
36
+ */
37
+ export declare function useMonitoredDevices(round?: number): IMonitoredDevice[] | undefined;
@@ -0,0 +1,119 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTelemetryRead = useTelemetryRead;
4
+ exports.useMonitoredDevices = useMonitoredDevices;
5
+ const peers_sdk_1 = require("@peers-app/peers-sdk");
6
+ const react_1 = require("react");
7
+ const hooks_1 = require("../../hooks");
8
+ const monitored_devices_1 = require("./monitored-devices");
9
+ const telemetry_client_1 = require("./telemetry-client");
10
+ /**
11
+ * Read from a device's System Telemetry, again whenever `deps` change and, while the page is
12
+ * visible, `refreshMs` after the last read finished. A refresh keeps the last result on screen (a
13
+ * view dims it); a failed read clears it; a different device starts empty, so one device's numbers
14
+ * never show under another's name.
15
+ *
16
+ * @param deviceId - The device to read; omit for this device.
17
+ * @param read - The read, given the device's consumer.
18
+ * @param deps - What the read depends on, besides the device.
19
+ * @param refreshMs - Read again this often; omit to read only on change.
20
+ */
21
+ function useTelemetryRead(deviceId, read, deps, refreshMs) {
22
+ const [state, setState] = (0, react_1.useState)({
23
+ loading: true,
24
+ deviceId,
25
+ });
26
+ const runRef = (0, react_1.useRef)(0);
27
+ const readRef = (0, react_1.useRef)(read);
28
+ readRef.current = read;
29
+ const run = (0, react_1.useCallback)(async () => {
30
+ // A local save may finish and request a refresh after this section has closed.
31
+ if (!readRef.current)
32
+ return;
33
+ const id = ++runRef.current;
34
+ setState((prev) => prev.deviceId === deviceId ? { ...prev, loading: true } : { loading: true, deviceId });
35
+ try {
36
+ const telemetry = await (0, telemetry_client_1.getTelemetry)(deviceId);
37
+ if (id !== runRef.current)
38
+ return;
39
+ const data = await readRef.current(telemetry);
40
+ if (id === runRef.current)
41
+ setState({ data, loading: false, deviceId, readAt: Date.now() });
42
+ }
43
+ catch (error) {
44
+ if (id === runRef.current)
45
+ setState({ error, loading: false, deviceId });
46
+ }
47
+ }, [deviceId, ...deps]);
48
+ (0, react_1.useEffect)(() => {
49
+ readRef.current = read;
50
+ void run();
51
+ return () => {
52
+ runRef.current++;
53
+ readRef.current = undefined;
54
+ };
55
+ }, [run]);
56
+ // Start the interval from the latest settled read, including a manual refresh.
57
+ (0, react_1.useEffect)(() => {
58
+ if (!refreshMs || state.loading)
59
+ return;
60
+ const timer = setInterval(() => {
61
+ if (typeof document === "undefined" || !document.hidden)
62
+ void run();
63
+ }, refreshMs);
64
+ return () => clearInterval(timer);
65
+ }, [run, refreshMs, state]);
66
+ const current = state.deviceId === deviceId;
67
+ return {
68
+ data: current ? state.data : undefined,
69
+ error: current ? state.error : undefined,
70
+ loading: state.loading || !current,
71
+ readAt: current ? state.readAt : undefined,
72
+ refresh: () => void run(),
73
+ };
74
+ }
75
+ /**
76
+ * The devices Monitoring lists ({@link buildMonitoredDevices}): this one first, the user's others
77
+ * by name, then other users' connected devices that let them read their telemetry. `undefined`
78
+ * until the user's own are read; others' join the list once they've answered. Whether one of the
79
+ * user's own can be reached shows when Monitoring reads it.
80
+ *
81
+ * @param round - Ask other users' devices again whenever this changes (after the first).
82
+ */
83
+ function useMonitoredDevices(round = 0) {
84
+ const userContext = (0, hooks_1.usePromise)(peers_sdk_1.getUserContext);
85
+ const [thisId] = (0, hooks_1.useObservable)(peers_sdk_1.thisDeviceId);
86
+ const [rows, setRows] = (0, react_1.useState)();
87
+ const [others, setOthers] = (0, react_1.useState)([]);
88
+ (0, react_1.useEffect)(() => {
89
+ if (!userContext)
90
+ return;
91
+ let disposed = false;
92
+ const table = (0, peers_sdk_1.Devices)(userContext.userDataContext);
93
+ const load = async () => {
94
+ const list = await table.list();
95
+ if (!disposed)
96
+ setRows(list);
97
+ };
98
+ void load();
99
+ const subscription = table.dataChanged.subscribe(() => void load());
100
+ return () => {
101
+ disposed = true;
102
+ subscription.unsubscribe();
103
+ };
104
+ }, [userContext]);
105
+ (0, react_1.useEffect)(() => {
106
+ if (!userContext)
107
+ return;
108
+ // Leaving Monitoring, or a new round, ends this pass: it asks no device it hasn't asked yet.
109
+ const pass = new AbortController();
110
+ void (0, monitored_devices_1.readableOthersDevices)(userContext.userId, round > 0, pass.signal).then((list) => {
111
+ if (!pass.signal.aborted)
112
+ setOthers(list);
113
+ });
114
+ return () => pass.abort();
115
+ }, [userContext, round]);
116
+ return (0, react_1.useMemo)(() => userContext && rows
117
+ ? (0, monitored_devices_1.buildMonitoredDevices)({ thisDeviceId: thisId, userId: userContext.userId, rows, others })
118
+ : undefined, [userContext, rows, others, thisId]);
119
+ }
@@ -1,6 +1,6 @@
1
1
  interface RemoteLogsPanelProps {
2
2
  deviceId: string;
3
3
  }
4
- /** Read-only System Logs contract panel for a directly connected, provider-authorized device. */
4
+ /** Read-only panel of a directly connected, provider-authorized device's stored log lines. */
5
5
  export declare function RemoteLogsPanel({ deviceId }: RemoteLogsPanelProps): import("react/jsx-runtime").JSX.Element;
6
6
  export {};
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RemoteLogsPanel = RemoteLogsPanel;
4
4
  const jsx_runtime_1 = require("react/jsx-runtime");
5
5
  const react_1 = require("react");
6
+ const log_lines_1 = require("../monitoring/log-lines");
6
7
  const network_viewer_ipc_1 = require("./network-viewer-ipc");
7
8
  function RemoteLogRow({ log }) {
8
- return ((0, jsx_runtime_1.jsxs)("div", { className: "border-bottom py-2", children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-wrap gap-2 align-items-center small", children: [(0, jsx_runtime_1.jsx)("code", { children: new Date(log.timestamp).toLocaleTimeString() }), (0, jsx_runtime_1.jsx)("span", { className: `badge ${log.level === "error" ? "bg-danger" : "bg-secondary"}`, children: log.level }), (0, jsx_runtime_1.jsx)("span", { className: "badge bg-info text-dark", children: log.process }), log.source && (0, jsx_runtime_1.jsx)("span", { className: "text-muted", children: log.source })] }), (0, jsx_runtime_1.jsx)("div", { className: "mt-1", style: { whiteSpace: "pre-wrap", overflowWrap: "anywhere" }, children: log.message }), (log.context || log.stackTrace) && ((0, jsx_runtime_1.jsxs)("details", { className: "mt-1", children: [(0, jsx_runtime_1.jsx)("summary", { className: "small text-muted", children: "Details" }), (0, jsx_runtime_1.jsx)("pre", { className: "small bg-body-tertiary rounded p-2 mt-1", style: { maxHeight: "240px" }, children: JSON.stringify({ context: log.context, stackTrace: log.stackTrace }, null, 2) })] }))] }));
9
+ const error = (0, log_lines_1.lineError)(log);
10
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "border-bottom py-2", children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex flex-wrap gap-2 align-items-center small", children: [(0, jsx_runtime_1.jsx)("code", { children: new Date(log.timestamp).toLocaleTimeString() }), (0, jsx_runtime_1.jsx)("span", { className: `badge ${log.level === "error" ? "bg-danger" : "bg-secondary"}`, children: log.level }), (0, jsx_runtime_1.jsx)("span", { className: "badge bg-info text-dark", children: log.process }), log.source && (0, jsx_runtime_1.jsx)("span", { className: "text-muted", children: log.source }), log.event && (0, jsx_runtime_1.jsx)("code", { className: "text-muted", children: log.event })] }), (0, jsx_runtime_1.jsx)("div", { className: "mt-1", style: { whiteSpace: "pre-wrap", overflowWrap: "anywhere" }, children: log.message }), error?.stack && ((0, jsx_runtime_1.jsx)("pre", { className: "small rounded p-2 mt-1 mb-0 bg-danger bg-opacity-10 text-danger-emphasis", style: { maxHeight: "240px", whiteSpace: "pre-wrap" }, children: error.stack })), log.data && ((0, jsx_runtime_1.jsxs)("details", { className: "mt-1", children: [(0, jsx_runtime_1.jsx)("summary", { className: "small text-muted", children: "Data" }), (0, jsx_runtime_1.jsx)("pre", { className: "small bg-body-tertiary rounded p-2 mt-1", style: { maxHeight: "240px" }, children: JSON.stringify(log.data, null, 2) })] }))] }));
9
11
  }
10
- /** Read-only System Logs contract panel for a directly connected, provider-authorized device. */
12
+ /** Read-only panel of a directly connected, provider-authorized device's stored log lines. */
11
13
  function RemoteLogsPanel({ deviceId }) {
12
14
  const [result, setResult] = (0, react_1.useState)(null);
13
15
  const [loading, setLoading] = (0, react_1.useState)(false);
@@ -56,5 +58,5 @@ function RemoteLogsPanel({ deviceId }) {
56
58
  anchor.click();
57
59
  URL.revokeObjectURL(url);
58
60
  }, [deviceId, result]);
59
- return ((0, jsx_runtime_1.jsxs)("div", { className: "mb-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex justify-content-between align-items-center border-bottom pb-2 mb-3", children: [(0, jsx_runtime_1.jsx)("h6", { className: "mb-0", children: "Remote Console Logs" }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex gap-2", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-outline-secondary", onClick: exportLogs, disabled: !result, children: "Export JSON" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-primary", onClick: () => void loadLogs(), disabled: loading, children: loading ? "Loading..." : result ? "Refresh" : "Load logs" })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "row g-2 mb-3", children: [(0, jsx_runtime_1.jsxs)("div", { className: "col-md-3", children: [(0, jsx_runtime_1.jsx)("label", { className: "form-label small", htmlFor: "remote-logs-process", children: "Process" }), (0, jsx_runtime_1.jsx)("input", { id: "remote-logs-process", className: "form-control form-control-sm", value: processName, onChange: (event) => setProcessName(event.target.value), placeholder: "All processes" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "col-md-2", children: [(0, jsx_runtime_1.jsx)("label", { className: "form-label small", htmlFor: "remote-logs-level", children: "Level" }), (0, jsx_runtime_1.jsxs)("select", { id: "remote-logs-level", className: "form-select form-select-sm", value: level, onChange: (event) => setLevel(event.target.value), children: [(0, jsx_runtime_1.jsx)("option", { value: "", children: "All" }), (0, jsx_runtime_1.jsx)("option", { value: "debug", children: "Debug" }), (0, jsx_runtime_1.jsx)("option", { value: "info", children: "Info" }), (0, jsx_runtime_1.jsx)("option", { value: "log", children: "Log" }), (0, jsx_runtime_1.jsx)("option", { value: "warn", children: "Warn" }), (0, jsx_runtime_1.jsx)("option", { value: "error", children: "Error" })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "col-md-2", children: [(0, jsx_runtime_1.jsx)("label", { className: "form-label small", htmlFor: "remote-logs-minutes", children: "Time range" }), (0, jsx_runtime_1.jsxs)("select", { id: "remote-logs-minutes", className: "form-select form-select-sm", value: minutes, onChange: (event) => setMinutes(event.target.value), children: [(0, jsx_runtime_1.jsx)("option", { value: "15", children: "15 minutes" }), (0, jsx_runtime_1.jsx)("option", { value: "60", children: "1 hour" }), (0, jsx_runtime_1.jsx)("option", { value: "360", children: "6 hours" }), (0, jsx_runtime_1.jsx)("option", { value: "0", children: "All retained" })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "col-md-5", children: [(0, jsx_runtime_1.jsx)("label", { className: "form-label small", htmlFor: "remote-logs-search", children: "Message words" }), (0, jsx_runtime_1.jsx)("input", { id: "remote-logs-search", className: "form-control form-control-sm", value: search, onChange: (event) => setSearch(event.target.value), placeholder: "BrowserWebRTC" })] })] }), error && (0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger py-2", children: error }), result && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "small text-muted mb-2", children: ["Showing ", result.logs.length, result.truncated ? " newest" : "", " matching logs", result.truncated ? "; narrow the filters to see a different slice" : "", "; queried", " ", new Date(result.queriedAt).toLocaleString(), "."] }), (0, jsx_runtime_1.jsx)("div", { className: "border rounded px-2", style: { maxHeight: "420px", overflowY: "auto" }, children: result.logs.length ? (result.logs.map((log) => (0, jsx_runtime_1.jsx)(RemoteLogRow, { log: log }, log.logId))) : ((0, jsx_runtime_1.jsx)("div", { className: "text-muted py-3 text-center", children: "No matching remote logs." })) })] }))] }));
61
+ return ((0, jsx_runtime_1.jsxs)("div", { className: "mb-4", children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex justify-content-between align-items-center border-bottom pb-2 mb-3", children: [(0, jsx_runtime_1.jsx)("h6", { className: "mb-0", children: "Remote logs" }), (0, jsx_runtime_1.jsxs)("div", { className: "d-flex gap-2", children: [(0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-outline-secondary", onClick: exportLogs, disabled: !result, children: "Export JSON" }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-sm btn-primary", onClick: () => void loadLogs(), disabled: loading, children: loading ? "Loading..." : result ? "Refresh" : "Load logs" })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "row g-2 mb-3", children: [(0, jsx_runtime_1.jsxs)("div", { className: "col-md-3", children: [(0, jsx_runtime_1.jsx)("label", { className: "form-label small", htmlFor: "remote-logs-process", children: "Process" }), (0, jsx_runtime_1.jsx)("input", { id: "remote-logs-process", className: "form-control form-control-sm", value: processName, onChange: (event) => setProcessName(event.target.value), placeholder: "All processes" })] }), (0, jsx_runtime_1.jsxs)("div", { className: "col-md-2", children: [(0, jsx_runtime_1.jsx)("label", { className: "form-label small", htmlFor: "remote-logs-level", children: "Level" }), (0, jsx_runtime_1.jsxs)("select", { id: "remote-logs-level", className: "form-select form-select-sm", value: level, onChange: (event) => setLevel(event.target.value), children: [(0, jsx_runtime_1.jsx)("option", { value: "", children: "All" }), (0, jsx_runtime_1.jsx)("option", { value: "debug", children: "Debug" }), (0, jsx_runtime_1.jsx)("option", { value: "info", children: "Info" }), (0, jsx_runtime_1.jsx)("option", { value: "log", children: "Log" }), (0, jsx_runtime_1.jsx)("option", { value: "warn", children: "Warn" }), (0, jsx_runtime_1.jsx)("option", { value: "error", children: "Error" })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "col-md-2", children: [(0, jsx_runtime_1.jsx)("label", { className: "form-label small", htmlFor: "remote-logs-minutes", children: "Time range" }), (0, jsx_runtime_1.jsxs)("select", { id: "remote-logs-minutes", className: "form-select form-select-sm", value: minutes, onChange: (event) => setMinutes(event.target.value), children: [(0, jsx_runtime_1.jsx)("option", { value: "15", children: "15 minutes" }), (0, jsx_runtime_1.jsx)("option", { value: "60", children: "1 hour" }), (0, jsx_runtime_1.jsx)("option", { value: "360", children: "6 hours" }), (0, jsx_runtime_1.jsx)("option", { value: "0", children: "All retained" })] })] }), (0, jsx_runtime_1.jsxs)("div", { className: "col-md-5", children: [(0, jsx_runtime_1.jsx)("label", { className: "form-label small", htmlFor: "remote-logs-search", children: "Message words" }), (0, jsx_runtime_1.jsx)("input", { id: "remote-logs-search", className: "form-control form-control-sm", value: search, onChange: (event) => setSearch(event.target.value), placeholder: "BrowserWebRTC" })] })] }), error && (0, jsx_runtime_1.jsx)("div", { className: "alert alert-danger py-2", children: error }), result && ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsxs)("div", { className: "small text-muted mb-2", children: ["Showing ", result.logs.length, result.truncated ? " newest" : "", " matching logs", result.truncated ? "; narrow the filters to see a different slice" : "", "; queried", " ", new Date(result.queriedAt).toLocaleString(), "."] }), (0, jsx_runtime_1.jsx)("div", { className: "border rounded px-2", style: { maxHeight: "420px", overflowY: "auto" }, children: result.logs.length ? (result.logs.map((log) => (0, jsx_runtime_1.jsx)(RemoteLogRow, { log: log }, log.logId))) : ((0, jsx_runtime_1.jsx)("div", { className: "text-muted py-3 text-center", children: "No matching remote logs." })) })] }))] }));
60
62
  }
@@ -1,10 +1,10 @@
1
1
  import type { IAppNav } from "@peers-app/peers-sdk";
2
2
  import type { IPackageWithNavs } from "../ui-router/routes-loader";
3
3
  export { consoleApp, isConsolePath } from "./console.app";
4
- export { consoleLogsApp } from "./console-logs.app";
5
4
  export { dataExplorerApp } from "./data-explorer.app";
6
5
  export { identityApp } from "./identity.app";
7
6
  export { mobileSettingsApp } from "./mobile-settings.app";
7
+ export { monitoringApp } from "./monitoring.app";
8
8
  export { networkViewerApp } from "./network-viewer.app";
9
9
  export { notificationsApp } from "./notifications.app";
10
10
  export { packagesApp } from "./packages.app";