codex-flow 2.1.13__py3-none-any.whl
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.
- codex_flow/__init__.py +28 -0
- codex_flow/__main__.py +9 -0
- codex_flow/cli.py +242 -0
- codex_flow/data/LICENSE +21 -0
- codex_flow/data/README.en.md +303 -0
- codex_flow/data/README.md +305 -0
- codex_flow/data/VERSION +1 -0
- codex_flow/data/apps/chatgpt-mcp/README.md +86 -0
- codex_flow/data/apps/chatgpt-mcp/__init__.py +1 -0
- codex_flow/data/apps/chatgpt-mcp/adapter.py +458 -0
- codex_flow/data/apps/chatgpt-mcp/server.py +358 -0
- codex_flow/data/apps/chatgpt-mcp/widget.html +927 -0
- codex_flow/data/apps/macos-overlay/README.en.md +121 -0
- codex_flow/data/apps/macos-overlay/README.md +123 -0
- codex_flow/data/apps/macos-overlay/Sources/Controllers/OverlayRuntimeState.swift +126 -0
- codex_flow/data/apps/macos-overlay/Sources/Controllers/OverlayScreenGeometry.swift +82 -0
- codex_flow/data/apps/macos-overlay/Sources/Controllers/OverlayWindowController.swift +1052 -0
- codex_flow/data/apps/macos-overlay/Sources/Localization.swift +197 -0
- codex_flow/data/apps/macos-overlay/Sources/Models/TelemetryData.swift +1557 -0
- codex_flow/data/apps/macos-overlay/Sources/Services/AccountSnapshotService.swift +1101 -0
- codex_flow/data/apps/macos-overlay/Sources/Services/FlowPilotInstanceLock.swift +153 -0
- codex_flow/data/apps/macos-overlay/Sources/Services/IPCServer.swift +298 -0
- codex_flow/data/apps/macos-overlay/Sources/Services/TelemetryQueryEngine.swift +800 -0
- codex_flow/data/apps/macos-overlay/Sources/Services/TelemetryWatcher.swift +135 -0
- codex_flow/data/apps/macos-overlay/Sources/Services/UpdateService.swift +610 -0
- codex_flow/data/apps/macos-overlay/Sources/Views/AccountView.swift +610 -0
- codex_flow/data/apps/macos-overlay/Sources/Views/AnalyticsView.swift +566 -0
- codex_flow/data/apps/macos-overlay/Sources/Views/AutostartView.swift +293 -0
- codex_flow/data/apps/macos-overlay/Sources/Views/BubbleView.swift +317 -0
- codex_flow/data/apps/macos-overlay/Sources/Views/HistoryView.swift +1124 -0
- codex_flow/data/apps/macos-overlay/Sources/Views/HoverRevealText.swift +165 -0
- codex_flow/data/apps/macos-overlay/Sources/Views/InspectorSkillsToolsView.swift +121 -0
- codex_flow/data/apps/macos-overlay/Sources/Views/LogoView.swift +182 -0
- codex_flow/data/apps/macos-overlay/Sources/Views/SleekSwitch.swift +117 -0
- codex_flow/data/apps/macos-overlay/Sources/Views/StrategyModeView.swift +561 -0
- codex_flow/data/apps/macos-overlay/Sources/Views/SummaryView.swift +1273 -0
- codex_flow/data/apps/macos-overlay/Sources/Views/UpdateView.swift +352 -0
- codex_flow/data/apps/macos-overlay/Sources/main.swift +340 -0
- codex_flow/data/apps/macos-overlay/Tests/OverlayScreenGeometryTests.swift +163 -0
- codex_flow/data/apps/macos-overlay/Tests/TelemetryPhase1ContractTests.swift +357 -0
- codex_flow/data/apps/macos-overlay/Tests/TelemetryQueryEngineConcurrencyTests.swift +221 -0
- codex_flow/data/apps/macos-overlay/Tests/TelemetryQuotaSelectionTests.swift +158 -0
- codex_flow/data/apps/macos-overlay/Tests/TelemetryWorkerTokenTests.swift +122 -0
- codex_flow/data/apps/macos-overlay/build.sh +75 -0
- codex_flow/data/benchmark/corpus.json +103 -0
- codex_flow/data/benchmark/manifest.example.json +41 -0
- codex_flow/data/benchmark/manifest.schema.json +137 -0
- codex_flow/data/benchmark/prices/gpt-5.6-2026-08-30.json +5 -0
- codex_flow/data/benchmark/profiles.json +90 -0
- codex_flow/data/benchmark/schema.json +77 -0
- codex_flow/data/benchmark/tasks.json +50 -0
- codex_flow/data/completions/codex-flow.bash +34 -0
- codex_flow/data/completions/codex-flow.zsh +52 -0
- codex_flow/data/glama.json +6 -0
- codex_flow/data/install-release.ps1 +126 -0
- codex_flow/data/install-release.sh +155 -0
- codex_flow/data/install.ps1 +349 -0
- codex_flow/data/install.sh +362 -0
- codex_flow/data/policy/benchmark.toml +49 -0
- codex_flow/data/policy/defaults.toml +70 -0
- codex_flow/data/scripts/analyze-benchmark.py +510 -0
- codex_flow/data/scripts/benchmark-local.py +171 -0
- codex_flow/data/scripts/check-recommendation.py +277 -0
- codex_flow/data/scripts/doctor.py +449 -0
- codex_flow/data/scripts/generate-release-manifest.py +74 -0
- codex_flow/data/scripts/localization.py +192 -0
- codex_flow/data/scripts/manage-hooks.py +448 -0
- codex_flow/data/scripts/manage-instructions.py +389 -0
- codex_flow/data/scripts/manage-shell.py +151 -0
- codex_flow/data/scripts/materialize-corpus.py +193 -0
- codex_flow/data/scripts/menu.py +646 -0
- codex_flow/data/scripts/migrations/0001_update_settings.py +80 -0
- codex_flow/data/scripts/package-release.py +132 -0
- codex_flow/data/scripts/render-benchmark-report.py +292 -0
- codex_flow/data/scripts/run-benchmark.py +829 -0
- codex_flow/data/scripts/strategies/__init__.py +28 -0
- codex_flow/data/scripts/strategies/balanced.py +115 -0
- codex_flow/data/scripts/strategies/base.py +363 -0
- codex_flow/data/scripts/strategies/efficient.py +158 -0
- codex_flow/data/scripts/strategies/lifecycle_runtime.py +590 -0
- codex_flow/data/scripts/strategies/quality.py +209 -0
- codex_flow/data/scripts/strategies/speed.py +108 -0
- codex_flow/data/scripts/strategies/task_budget_runtime.py +644 -0
- codex_flow/data/scripts/strategies/task_phase_runtime.py +341 -0
- codex_flow/data/scripts/strategies/work_unit_runtime.py +421 -0
- codex_flow/data/scripts/strategy_runtime.py +1091 -0
- codex_flow/data/scripts/telemetry.py +400 -0
- codex_flow/data/scripts/telemetry_core/__init__.py +192 -0
- codex_flow/data/scripts/telemetry_core/app_server.py +1192 -0
- codex_flow/data/scripts/telemetry_core/collector.py +1247 -0
- codex_flow/data/scripts/telemetry_core/common.py +421 -0
- codex_flow/data/scripts/telemetry_core/latency.py +593 -0
- codex_flow/data/scripts/telemetry_core/query.py +427 -0
- codex_flow/data/scripts/telemetry_core/quota_ledger.py +598 -0
- codex_flow/data/scripts/telemetry_core/render.py +460 -0
- codex_flow/data/scripts/telemetry_core/repair.py +223 -0
- codex_flow/data/scripts/ui.py +266 -0
- codex_flow/data/scripts/update-homebrew-formula.py +146 -0
- codex_flow/data/scripts/update_runtime_config.py +134 -0
- codex_flow/data/scripts/updater.py +1718 -0
- codex_flow/data/smithery.yaml +18 -0
- codex_flow/data/templates/agents/worker-explorer.toml +24 -0
- codex_flow/data/templates/agents/worker-implementer.toml +49 -0
- codex_flow/data/templates/agents/worker-reviewer.toml +25 -0
- codex_flow/data/templates/flow-pilot-instructions.md +35 -0
- codex_flow/data/templates/skills/flow-pilot/SKILL.md +577 -0
- codex_flow/mcp.py +35 -0
- codex_flow-2.1.13.dist-info/METADATA +342 -0
- codex_flow-2.1.13.dist-info/RECORD +113 -0
- codex_flow-2.1.13.dist-info/WHEEL +5 -0
- codex_flow-2.1.13.dist-info/entry_points.txt +3 -0
- codex_flow-2.1.13.dist-info/licenses/LICENSE +21 -0
- codex_flow-2.1.13.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
public class TelemetryWatcher {
|
|
4
|
+
public let state: OverlayState
|
|
5
|
+
private var telemetryURL: URL
|
|
6
|
+
private var dirURL: URL
|
|
7
|
+
private var fileSource: DispatchSourceFileSystemObject?
|
|
8
|
+
private var dirSource: DispatchSourceFileSystemObject?
|
|
9
|
+
private var lastModifiedTime: Date = .distantPast
|
|
10
|
+
|
|
11
|
+
public init(state: OverlayState, telemetryPath: String? = nil) {
|
|
12
|
+
self.state = state
|
|
13
|
+
if let path = telemetryPath {
|
|
14
|
+
self.telemetryURL = URL(fileURLWithPath: path)
|
|
15
|
+
self.dirURL = self.telemetryURL.deletingLastPathComponent()
|
|
16
|
+
} else {
|
|
17
|
+
let home = FileManager.default.homeDirectoryForCurrentUser
|
|
18
|
+
let codexHome = ProcessInfo.processInfo.environment["CODEX_HOME"] ?? home.appendingPathComponent(".codex").path
|
|
19
|
+
self.dirURL = URL(fileURLWithPath: codexHome)
|
|
20
|
+
.appendingPathComponent("codex-flow")
|
|
21
|
+
.appendingPathComponent("telemetry")
|
|
22
|
+
self.telemetryURL = self.dirURL.appendingPathComponent("last.json")
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Initial load
|
|
26
|
+
loadLatestData()
|
|
27
|
+
startWatching()
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
deinit {
|
|
31
|
+
stopWatching()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/// Starts passive, kernel-driven file & directory monitoring (0% idle CPU, zero battery drain)
|
|
35
|
+
public func startWatching() {
|
|
36
|
+
stopWatching()
|
|
37
|
+
|
|
38
|
+
// Ensure directory exists
|
|
39
|
+
try? FileManager.default.createDirectory(at: dirURL, withIntermediateDirectories: true)
|
|
40
|
+
|
|
41
|
+
// 1. Watch directory for atomic writes / renames / replacements
|
|
42
|
+
let dirFD = open(dirURL.path, O_EVTONLY)
|
|
43
|
+
if dirFD >= 0 {
|
|
44
|
+
let source = DispatchSource.makeFileSystemObjectSource(
|
|
45
|
+
fileDescriptor: dirFD,
|
|
46
|
+
eventMask: [.write, .extend, .attrib, .link],
|
|
47
|
+
queue: DispatchQueue.global(qos: .utility)
|
|
48
|
+
)
|
|
49
|
+
|
|
50
|
+
source.setEventHandler { [weak self] in
|
|
51
|
+
self?.handleFileOrDirChanged()
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
source.setCancelHandler {
|
|
55
|
+
close(dirFD)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
source.resume()
|
|
59
|
+
self.dirSource = source
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// 2. Watch specific last.json file if it exists
|
|
63
|
+
if FileManager.default.fileExists(atPath: telemetryURL.path) {
|
|
64
|
+
let fileFD = open(telemetryURL.path, O_EVTONLY)
|
|
65
|
+
if fileFD >= 0 {
|
|
66
|
+
let source = DispatchSource.makeFileSystemObjectSource(
|
|
67
|
+
fileDescriptor: fileFD,
|
|
68
|
+
eventMask: [.write, .extend, .attrib, .rename, .delete],
|
|
69
|
+
queue: DispatchQueue.global(qos: .utility)
|
|
70
|
+
)
|
|
71
|
+
|
|
72
|
+
source.setEventHandler { [weak self] in
|
|
73
|
+
let data = source.data
|
|
74
|
+
if data.contains(.delete) || data.contains(.rename) {
|
|
75
|
+
self?.fileSource?.cancel()
|
|
76
|
+
self?.fileSource = nil
|
|
77
|
+
}
|
|
78
|
+
self?.handleFileOrDirChanged()
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
source.setCancelHandler {
|
|
82
|
+
close(fileFD)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
source.resume()
|
|
86
|
+
self.fileSource = source
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public func stopWatching() {
|
|
92
|
+
fileSource?.cancel()
|
|
93
|
+
fileSource = nil
|
|
94
|
+
dirSource?.cancel()
|
|
95
|
+
dirSource = nil
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
private func handleFileOrDirChanged() {
|
|
99
|
+
// Debounce slightly (50ms) to ensure file write buffer flushed
|
|
100
|
+
DispatchQueue.main.asyncAfter(deadline: .now() + 0.05) { [weak self] in
|
|
101
|
+
guard let self = self else { return }
|
|
102
|
+
self.checkAndReloadIfModified()
|
|
103
|
+
// Re-attach file watcher if file was recreated/renamed
|
|
104
|
+
if self.fileSource == nil && FileManager.default.fileExists(atPath: self.telemetryURL.path) {
|
|
105
|
+
self.startWatching()
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
public func checkAndReloadIfModified() {
|
|
111
|
+
guard FileManager.default.fileExists(atPath: telemetryURL.path) else { return }
|
|
112
|
+
do {
|
|
113
|
+
let attrs = try FileManager.default.attributesOfItem(atPath: telemetryURL.path)
|
|
114
|
+
if let modDate = attrs[.modificationDate] as? Date, modDate > lastModifiedTime {
|
|
115
|
+
lastModifiedTime = modDate
|
|
116
|
+
loadLatestData()
|
|
117
|
+
}
|
|
118
|
+
} catch {
|
|
119
|
+
// Ignore temporary read attribute errors
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public func loadLatestData() {
|
|
124
|
+
guard FileManager.default.fileExists(atPath: telemetryURL.path) else { return }
|
|
125
|
+
do {
|
|
126
|
+
let data = try Data(contentsOf: telemetryURL)
|
|
127
|
+
let decoder = JSONDecoder()
|
|
128
|
+
var run = try decoder.decode(TaskRun.self, from: data)
|
|
129
|
+
TelemetryQueryEngine.shared.enrichRunIfNeeded(&run)
|
|
130
|
+
state.update(run: run)
|
|
131
|
+
} catch {
|
|
132
|
+
// If decode fails, retain existing state
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|