pyre-cli 9.5.1 → 10.0.0

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 (94) hide show
  1. package/README.md +84 -14
  2. package/dist/alertChannels-TPSQIJ7S.js +8 -0
  3. package/dist/blender-FGH3ASEQ.js +7 -0
  4. package/dist/brewHealth-P2GW5Y5C.js +176 -0
  5. package/dist/buildCmd-CDPZ2ZFA.js +38 -0
  6. package/dist/{checkCmd-EWFNLBWE.js → checkCmd-RKW6QGDR.js} +10 -11
  7. package/dist/{chunk-RVGKEJXT.js → chunk-53O2RGSL.js} +47 -17
  8. package/dist/{chunk-MOAEGMFP.js → chunk-6UHZP4QP.js} +204 -46
  9. package/dist/chunk-GHRDW646.js +2506 -0
  10. package/dist/{prometheus-LFYHF6VO.js → chunk-HT4VQ4OH.js} +1 -0
  11. package/dist/chunk-M73HCQD2.js +95 -0
  12. package/dist/chunk-MZO5QKUR.js +32 -0
  13. package/dist/chunk-VIACN2RU.js +133 -0
  14. package/dist/chunk-Z2YV5HKV.js +87 -0
  15. package/dist/chunk-ZLVIVFSO.js +110 -0
  16. package/dist/{collectors-WD6VKH6M.js → collectors-H43PN4PS.js} +8 -2
  17. package/dist/{completions-VQMHQCXE.js → completions-JKYEJNGR.js} +34 -1
  18. package/dist/{config-4ZLF4HTS.js → config-GYGJXU2Q.js} +9 -1
  19. package/dist/doctor-GYHFTNZQ.js +387 -0
  20. package/dist/explainCmd-MF6PIMLW.js +222 -0
  21. package/dist/extensions-XJGHG7X3.js +134 -0
  22. package/dist/index.js +841 -206
  23. package/dist/ioreport.py +72 -0
  24. package/dist/netUsageCmd-WKBTW2YG.js +90 -0
  25. package/dist/{pipeCmd-7THXEGDH.js → pipeCmd-7REDBLBU.js} +5 -3
  26. package/dist/profileProcCmd-N4H6MCBT.js +107 -0
  27. package/dist/prometheus-5BL5PVLC.js +6 -0
  28. package/dist/prometheusCmd-PL64BLN5.js +93 -0
  29. package/dist/replayCmd-Z3PYXY7V.js +164 -0
  30. package/dist/run-HOGQDDTA.js +8 -0
  31. package/dist/serveCmd-2H5VLF3P.js +153 -0
  32. package/dist/service-Q74BBILO.js +181 -0
  33. package/dist/smartCmd-ODWKSFNG.js +166 -0
  34. package/dist/syncCmd-A2W3QB3S.js +126 -0
  35. package/dist/topoCmd-DU2HHZNH.js +148 -0
  36. package/dist/watchdogCmd-UF53JPZB.js +161 -0
  37. package/dist/{wizard-GVIAHIVV.js → wizard-TD7BGX6O.js} +1 -1
  38. package/install.ps1 +29 -0
  39. package/install.sh +10 -9
  40. package/package.json +7 -3
  41. package/src/ai/models.ts +138 -0
  42. package/src/alertChannels.ts +119 -0
  43. package/src/anomalies.ts +114 -60
  44. package/src/brewHealth.ts +157 -40
  45. package/src/buildCmd.ts +48 -0
  46. package/src/checkCmd.ts +5 -5
  47. package/src/completions.ts +35 -0
  48. package/src/doctor.ts +235 -7
  49. package/src/easy_features.test.ts +40 -0
  50. package/src/explainCmd.ts +261 -0
  51. package/src/extensions.ts +71 -7
  52. package/src/formatters/index.ts +1 -1
  53. package/src/formatters/output.ts +100 -13
  54. package/src/formatters/render.ts +274 -38
  55. package/src/formatters/themes.ts +8 -0
  56. package/src/formatters/types.ts +6 -1
  57. package/src/index.ts +298 -56
  58. package/src/live/input.ts +122 -4
  59. package/src/live/render.ts +98 -0
  60. package/src/live/state.ts +70 -52
  61. package/src/live/types.ts +2 -2
  62. package/src/monitors/batteryPredictor.ts +143 -0
  63. package/src/monitors/blender.ts +144 -0
  64. package/src/monitors/buildTracker.ts +121 -0
  65. package/src/monitors/collectors.ts +558 -147
  66. package/src/monitors/dns_cache.ts +48 -0
  67. package/src/monitors/index.ts +3 -2
  68. package/src/monitors/ioreport.py +72 -0
  69. package/src/monitors/platform/linux.ts +756 -0
  70. package/src/monitors/platform/windows.ts +519 -0
  71. package/src/monitors/run.ts +27 -3
  72. package/src/monitors/smc.ts +21 -1
  73. package/src/monitors/types.ts +112 -14
  74. package/src/netUsageCmd.ts +121 -0
  75. package/src/platform.test.ts +99 -0
  76. package/src/plugins/index.ts +143 -0
  77. package/src/profileProcCmd.ts +133 -0
  78. package/src/prometheusCmd.ts +107 -0
  79. package/src/replayCmd.ts +186 -0
  80. package/src/serveCmd.ts +180 -0
  81. package/src/service.ts +125 -7
  82. package/src/smartCmd.ts +205 -0
  83. package/src/state/config.ts +64 -17
  84. package/src/syncCmd.ts +166 -0
  85. package/src/topoCmd.ts +176 -0
  86. package/src/watchdogCmd.ts +198 -0
  87. package/src/xbar.ts +22 -11
  88. package/dist/brewHealth-F2BXF5M6.js +0 -74
  89. package/dist/chunk-FH5WDJBF.js +0 -15
  90. package/dist/chunk-HGRBBPYX.js +0 -937
  91. package/dist/doctor-L6FZYA7F.js +0 -184
  92. package/dist/extensions-DVA5YLGH.js +0 -74
  93. package/dist/service-WTS3NBQU.js +0 -73
  94. /package/dist/{chunk-SG26Y3WF.js → chunk-IM3IQMMT.js} +0 -0
@@ -0,0 +1,48 @@
1
+ import dns from 'node:dns';
2
+
3
+ const cache = new Map<string, string>();
4
+ const pending = new Set<string>();
5
+
6
+ export function resolveIp(ip: string): string {
7
+ // Extract IP if it has port (e.g., 17.242.13.5:5223 or [2606:4700...]:443)
8
+ let cleanIp = ip;
9
+ if (cleanIp.includes(']:')) {
10
+ cleanIp = cleanIp.substring(1, cleanIp.indexOf(']'));
11
+ } else if (cleanIp.includes(':') && cleanIp.split(':').length === 2) {
12
+ cleanIp = cleanIp.split(':')[0];
13
+ } else if (cleanIp.includes(':') && !cleanIp.includes(']')) {
14
+ // ipv6 without port or brackets?
15
+ // If there's more than one colon, it's ipv6.
16
+ const lastColon = cleanIp.lastIndexOf(':');
17
+ const isPort = !cleanIp.includes(':', cleanIp.indexOf(':') + 1); // Only 1 colon means it's a port. Wait, ipv6 has many colons.
18
+ // E.g., 2606:4700:103::2.443 -> nettop uses `.` for port in ipv6!
19
+ }
20
+
21
+ // Handle nettop's IPv6 port format: 2606:4700:103::2.443 (the last dot separates the port)
22
+ if (cleanIp.includes(':') && cleanIp.includes('.')) {
23
+ const lastDot = cleanIp.lastIndexOf('.');
24
+ if (lastDot > cleanIp.lastIndexOf(':')) {
25
+ cleanIp = cleanIp.substring(0, lastDot);
26
+ }
27
+ }
28
+
29
+ if (cache.has(cleanIp)) return cache.get(cleanIp)!;
30
+ if (pending.has(cleanIp)) return ip;
31
+
32
+ // Don't resolve local/multicast/broadcast
33
+ if (cleanIp.startsWith('127.') || cleanIp.startsWith('192.168.') || cleanIp.startsWith('10.') || cleanIp.startsWith('172.16.') || cleanIp.startsWith('ff02:') || cleanIp === '*:*' || cleanIp === '*' || cleanIp.startsWith('fe80:')) {
34
+ return ip;
35
+ }
36
+
37
+ pending.add(cleanIp);
38
+ dns.reverse(cleanIp, (err, hostnames) => {
39
+ if (!err && hostnames && hostnames.length > 0) {
40
+ cache.set(cleanIp, hostnames[0]);
41
+ } else {
42
+ cache.set(cleanIp, cleanIp); // don't try again
43
+ }
44
+ pending.delete(cleanIp);
45
+ });
46
+
47
+ return ip;
48
+ }
@@ -10,5 +10,6 @@
10
10
  * - `collectors.ts` — individual metric collectors and the orchestrator
11
11
  * - `run.ts` — shared shell-execution helper
12
12
  */
13
- export { collectAll, collectPower, collectPackets, collectTasks } from './collectors.js';
14
- export type { StatsData, CpuData, MemoryData, ThermalData, BatteryData, PowerData, DiskData, NetworkData, ProcessData, GpuData, PacketData, NetworkProcess, TaskData } from './types.js';
13
+ export { collectAll, collectPower, collectPackets, collectTasks, collectContainers } from './collectors.js';
14
+ export { collectBlenderRenders } from './blender.js';
15
+ export type { StatsData, CpuData, MemoryData, ThermalData, BatteryData, PowerData, DiskData, NetworkData, ProcessData, GpuData, PacketData, NetworkProcess, TaskData, ContainerData, BlenderRenderData } from './types.js';
@@ -0,0 +1,72 @@
1
+ import ctypes, ctypes.util, json, time, sys
2
+
3
+ try:
4
+ libIOReport = ctypes.cdll.LoadLibrary('/usr/lib/libIOReport.dylib')
5
+ CF = ctypes.cdll.LoadLibrary(ctypes.util.find_library('CoreFoundation'))
6
+ CFStringRef = ctypes.c_void_p
7
+ CFDictionaryRef = ctypes.c_void_p
8
+ CFArrayRef = ctypes.c_void_p
9
+ CFIndex = ctypes.c_long
10
+
11
+ CF.CFStringCreateWithCString.restype = CFStringRef
12
+ CF.CFStringCreateWithCString.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_uint32]
13
+ CF.CFStringGetCString.restype = ctypes.c_bool
14
+ CF.CFStringGetCString.argtypes = [CFStringRef, ctypes.c_char_p, CFIndex, ctypes.c_uint32]
15
+ CF.CFDictionaryGetValue.restype = ctypes.c_void_p
16
+ CF.CFDictionaryGetValue.argtypes = [CFDictionaryRef, ctypes.c_void_p]
17
+ CF.CFArrayGetCount.restype = CFIndex
18
+ CF.CFArrayGetCount.argtypes = [CFArrayRef]
19
+ CF.CFArrayGetValueAtIndex.restype = ctypes.c_void_p
20
+ CF.CFArrayGetValueAtIndex.argtypes = [CFArrayRef, CFIndex]
21
+
22
+ def cf_str(t):
23
+ return CF.CFStringCreateWithCString(None, t.encode('utf-8'), 0x08000100)
24
+
25
+ def cf_to_str(c):
26
+ if not c: return ''
27
+ b = ctypes.create_string_buffer(128)
28
+ return b.value.decode('utf-8') if CF.CFStringGetCString(c, b, 128, 0x08000100) else ''
29
+
30
+ libIOReport.IOReportCopyChannelsInGroup.restype = CFDictionaryRef
31
+ libIOReport.IOReportCopyChannelsInGroup.argtypes = [CFStringRef, CFStringRef, ctypes.c_uint64, ctypes.c_uint64, ctypes.c_uint64]
32
+ libIOReport.IOReportCreateSubscription.restype = ctypes.c_void_p
33
+ libIOReport.IOReportCreateSubscription.argtypes = [ctypes.c_void_p, CFDictionaryRef, ctypes.POINTER(CFDictionaryRef), ctypes.c_uint64, ctypes.c_void_p]
34
+ libIOReport.IOReportCreateSamples.restype = CFDictionaryRef
35
+ libIOReport.IOReportCreateSamples.argtypes = [ctypes.c_void_p, CFDictionaryRef, ctypes.c_void_p]
36
+ libIOReport.IOReportCreateSamplesDelta.restype = CFDictionaryRef
37
+ libIOReport.IOReportCreateSamplesDelta.argtypes = [CFDictionaryRef, CFDictionaryRef, ctypes.c_void_p]
38
+ libIOReport.IOReportChannelGetChannelName.restype = CFStringRef
39
+ libIOReport.IOReportChannelGetChannelName.argtypes = [CFDictionaryRef]
40
+ libIOReport.IOReportChannelGetUnitLabel.restype = CFStringRef
41
+ libIOReport.IOReportChannelGetUnitLabel.argtypes = [CFDictionaryRef]
42
+ libIOReport.IOReportSimpleGetIntegerValue.restype = ctypes.c_int64
43
+ libIOReport.IOReportSimpleGetIntegerValue.argtypes = [CFDictionaryRef, ctypes.c_int32]
44
+
45
+ ch = libIOReport.IOReportCopyChannelsInGroup(cf_str('Energy Model'), None, 0, 0, 0)
46
+ sub_ch = CFDictionaryRef()
47
+ sub = libIOReport.IOReportCreateSubscription(None, ch, ctypes.byref(sub_ch), 0, None)
48
+ s1 = libIOReport.IOReportCreateSamples(sub, sub_ch, None)
49
+ dt = 0.08
50
+ time.sleep(dt)
51
+ s2 = libIOReport.IOReportCreateSamples(sub, sub_ch, None)
52
+ delta = libIOReport.IOReportCreateSamplesDelta(s1, s2, None)
53
+ arr = CF.CFDictionaryGetValue(delta, cf_str('IOReportChannels'))
54
+ cnt = CF.CFArrayGetCount(arr)
55
+ cpu_w = 0.0
56
+ gpu_w = 0.0
57
+ ane_w = 0.0
58
+ for i in range(cnt):
59
+ item = CF.CFArrayGetValueAtIndex(arr, i)
60
+ n = cf_to_str(libIOReport.IOReportChannelGetChannelName(item))
61
+ if n in ('GPU Energy', 'CPU Energy', 'ANE'):
62
+ u = cf_to_str(libIOReport.IOReportChannelGetUnitLabel(item))
63
+ v = libIOReport.IOReportSimpleGetIntegerValue(item, 0)
64
+ sc = 1e9 if u == 'nJ' else (1e6 if u == 'uJ' else 1e3)
65
+ w = round((v / sc) / dt, 2)
66
+ if n == 'CPU Energy': cpu_w = w
67
+ elif n == 'GPU Energy': gpu_w = w
68
+ elif n == 'ANE': ane_w = w
69
+ combined_w = round(cpu_w + gpu_w + ane_w, 2)
70
+ print(json.dumps({'cpuWatts': cpu_w, 'gpuWatts': gpu_w, 'aneWatts': ane_w, 'combinedWatts': combined_w}))
71
+ except Exception:
72
+ print('{}')