sneakoscope 6.7.0 → 7.0.2
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/README.md +3 -3
- package/crates/sks-core/Cargo.lock +1 -1
- package/crates/sks-core/Cargo.toml +1 -1
- package/dist/cli/install-helpers-codex-lb-config.js +71 -0
- package/dist/cli/install-helpers-codex-lb-selftest.js +11 -14
- package/dist/cli/install-helpers.js +305 -53
- package/dist/config/skills-manifest.json +52 -52
- package/dist/core/agents/agent-orchestrator.js +56 -5
- package/dist/core/agents/agent-roster.js +4 -2
- package/dist/core/codex-app/codex-app-fast-ui-repair.js +18 -1
- package/dist/core/codex-app/codex-app-ui-state-snapshot.js +16 -0
- package/dist/core/codex-app.js +52 -6
- package/dist/core/commands/naruto-command.js +23 -5
- package/dist/core/hooks-runtime.js +77 -3
- package/dist/core/managed-assets/managed-assets-manifest.js +1 -1
- package/dist/core/mission.js +74 -4
- package/dist/core/release/package-size-budget.js +1 -1
- package/dist/core/subagents/naruto-proof-projection.js +2 -2
- package/dist/core/subagents/official-subagent-config.js +8 -5
- package/dist/core/subagents/official-subagent-preparation.js +24 -1
- package/dist/core/subagents/official-subagent-prompt.js +3 -2
- package/dist/core/subagents/official-subagent-runner.js +8 -1
- package/dist/core/subagents/wave-lifecycle.js +20 -0
- package/dist/core/subagents/wave-parent-guidance.js +42 -0
- package/dist/core/version.js +1 -1
- package/dist/native/sks-menubar/Sources/AlertFactory.swift +21 -2
- package/dist/native/sks-menubar/Sources/AppDelegate.swift +3 -0
- package/dist/native/sks-menubar/Sources/AppIdentity.swift +28 -1
- package/dist/native/sks-menubar/Sources/ControlCenterWindowController.swift +14 -8
- package/dist/native/sks-menubar/Sources/DiagnosticsViewController.swift +71 -7
- package/dist/native/sks-menubar/Sources/MCPServersViewController.swift +50 -9
- package/dist/native/sks-menubar/Sources/OverviewViewController.swift +61 -8
- package/dist/native/sks-menubar/Sources/ProvidersViewController.swift +169 -31
- package/dist/native/sks-menubar/Sources/RemoteTelegramViewController.swift +58 -23
- package/dist/native/sks-menubar/Sources/SettingsViewController.swift +41 -7
- package/dist/native/sks-menubar/Sources/StatusItemController.swift +34 -3
- package/dist/native/sks-menubar/Sources/UpdatesViewController.swift +38 -8
- package/dist/scripts/docs-truthfulness-check.js +2 -2
- package/dist/scripts/doctor-fixes-codex-app-fast-ui-check.js +7 -3
- package/package.json +1 -1
|
@@ -26,20 +26,39 @@ enum AlertFactory {
|
|
|
26
26
|
alert.beginSheetModal(for: window) { completion($0 == .alertFirstButtonReturn) }
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
static func textSheet(
|
|
29
|
+
static func textSheet(
|
|
30
|
+
window: NSWindow,
|
|
31
|
+
title: String,
|
|
32
|
+
message: String,
|
|
33
|
+
secure: Bool = false,
|
|
34
|
+
placeholder: String? = nil,
|
|
35
|
+
completion: @escaping (String?) -> Void
|
|
36
|
+
) {
|
|
30
37
|
let alert = NSAlert()
|
|
31
38
|
alert.messageText = title
|
|
32
39
|
alert.informativeText = message
|
|
33
40
|
alert.addButton(withTitle: "Apply")
|
|
34
41
|
alert.addButton(withTitle: "Cancel")
|
|
35
|
-
let field: NSTextField = secure
|
|
42
|
+
let field: NSTextField = secure
|
|
43
|
+
? NSSecureTextField(frame: NSRect(x: 0, y: 0, width: 420, height: 24))
|
|
44
|
+
: NSTextField(frame: NSRect(x: 0, y: 0, width: 420, height: 24))
|
|
45
|
+
field.isEditable = true
|
|
46
|
+
field.isSelectable = true
|
|
47
|
+
field.placeholderString = placeholder
|
|
36
48
|
field.setAccessibilityLabel(title)
|
|
49
|
+
if let placeholder, !placeholder.isEmpty {
|
|
50
|
+
field.setAccessibilityPlaceholderValue(placeholder)
|
|
51
|
+
}
|
|
37
52
|
alert.accessoryView = field
|
|
53
|
+
alert.window.initialFirstResponder = field
|
|
38
54
|
AppIdentity.applyIcon(to: alert)
|
|
39
55
|
alert.beginSheetModal(for: window) { response in
|
|
40
56
|
let value = field.stringValue.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
41
57
|
completion(response == .alertFirstButtonReturn && !value.isEmpty ? value : nil)
|
|
42
58
|
}
|
|
59
|
+
DispatchQueue.main.async {
|
|
60
|
+
alert.window.makeFirstResponder(field)
|
|
61
|
+
}
|
|
43
62
|
}
|
|
44
63
|
|
|
45
64
|
static func choiceSheet(window: NSWindow, title: String, message: String, choices: [(String, String)], completion: @escaping (String?) -> Void) {
|
|
@@ -10,6 +10,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate {
|
|
|
10
10
|
func applicationDidFinishLaunching(_ notification: Notification) {
|
|
11
11
|
NSApp.setActivationPolicy(.accessory)
|
|
12
12
|
AppIdentity.configure()
|
|
13
|
+
// Accessory/menubar apps have no system Edit menu by default, so Cmd+C/V
|
|
14
|
+
// never reaches NSTextField/NSTextView responders without an explicit menu.
|
|
15
|
+
AppIdentity.installStandardEditMenu()
|
|
13
16
|
processClient = ProcessClient(actionScript: AppRuntime.actionScript, logPath: AppRuntime.lastActionLogPath, projectRoot: AppRuntime.projectRoot)
|
|
14
17
|
operations = OperationCoordinator(directory: AppRuntime.operationDirectory)
|
|
15
18
|
notifications = NotificationCoordinator()
|
|
@@ -8,12 +8,39 @@ enum AppIdentity {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
+
/// Install a minimal main menu so Cut/Copy/Paste/Select All key equivalents
|
|
12
|
+
/// work in Control Center sheets and editable fields under `.accessory` policy.
|
|
13
|
+
static func installStandardEditMenu() {
|
|
14
|
+
let mainMenu = NSMenu()
|
|
15
|
+
let appItem = NSMenuItem()
|
|
16
|
+
mainMenu.addItem(appItem)
|
|
17
|
+
let appMenu = NSMenu()
|
|
18
|
+
appItem.submenu = appMenu
|
|
19
|
+
appMenu.addItem(withTitle: "Quit SKS Center", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")
|
|
20
|
+
|
|
21
|
+
let editItem = NSMenuItem()
|
|
22
|
+
mainMenu.addItem(editItem)
|
|
23
|
+
let editMenu = NSMenu(title: "Edit")
|
|
24
|
+
editItem.submenu = editMenu
|
|
25
|
+
editMenu.addItem(withTitle: "Undo", action: Selector(("undo:")), keyEquivalent: "z")
|
|
26
|
+
editMenu.addItem(withTitle: "Redo", action: Selector(("redo:")), keyEquivalent: "Z")
|
|
27
|
+
editMenu.addItem(.separator())
|
|
28
|
+
editMenu.addItem(withTitle: "Cut", action: #selector(NSText.cut(_:)), keyEquivalent: "x")
|
|
29
|
+
editMenu.addItem(withTitle: "Copy", action: #selector(NSText.copy(_:)), keyEquivalent: "c")
|
|
30
|
+
editMenu.addItem(withTitle: "Paste", action: #selector(NSText.paste(_:)), keyEquivalent: "v")
|
|
31
|
+
editMenu.addItem(withTitle: "Delete", action: #selector(NSText.delete(_:)), keyEquivalent: "")
|
|
32
|
+
editMenu.addItem(withTitle: "Select All", action: #selector(NSText.selectAll(_:)), keyEquivalent: "a")
|
|
33
|
+
NSApp.mainMenu = mainMenu
|
|
34
|
+
}
|
|
35
|
+
|
|
11
36
|
static func applyIcon(to alert: NSAlert) {
|
|
12
37
|
alert.icon = NSApplication.shared.applicationIconImage
|
|
13
38
|
}
|
|
14
39
|
|
|
15
40
|
static func statusImage(resource: String, symbol: String) -> NSImage? {
|
|
16
|
-
|
|
41
|
+
// Prefer the validated custom status PDFs; fall back to SF Symbols only when missing.
|
|
42
|
+
let image = Bundle.main.image(forResource: resource)
|
|
43
|
+
?? NSImage(systemSymbolName: symbol, accessibilityDescription: "SKS status")
|
|
17
44
|
image?.isTemplate = true
|
|
18
45
|
return image
|
|
19
46
|
}
|
|
@@ -6,6 +6,7 @@ final class ControlCenterWindowController: NSWindowController, NSTableViewDataSo
|
|
|
6
6
|
private let controllers: [SidebarItem: NSViewController]
|
|
7
7
|
private let overviewController: OverviewViewController
|
|
8
8
|
private var selected: SidebarItem = .overview
|
|
9
|
+
private var hasPresented = false
|
|
9
10
|
|
|
10
11
|
init(processClient: ProcessClient, operations: OperationCoordinator, notifications: NotificationCoordinator) {
|
|
11
12
|
let overview = OverviewViewController(processClient: processClient, operations: operations)
|
|
@@ -14,9 +15,9 @@ final class ControlCenterWindowController: NSWindowController, NSTableViewDataSo
|
|
|
14
15
|
.overview: overview,
|
|
15
16
|
.updates: UpdatesViewController(processClient: processClient, operations: operations, notifications: notifications),
|
|
16
17
|
.mcpServers: MCPServersViewController(processClient: processClient, operations: operations, notifications: notifications),
|
|
17
|
-
.providers: ProvidersViewController(processClient: processClient),
|
|
18
|
+
.providers: ProvidersViewController(processClient: processClient, operations: operations),
|
|
18
19
|
.remoteTelegram: RemoteTelegramViewController(processClient: processClient),
|
|
19
|
-
.diagnostics: DiagnosticsViewController(processClient: processClient),
|
|
20
|
+
.diagnostics: DiagnosticsViewController(processClient: processClient, operations: operations),
|
|
20
21
|
.settings: SettingsViewController(notifications: notifications)
|
|
21
22
|
]
|
|
22
23
|
let window = NSWindow(
|
|
@@ -38,7 +39,10 @@ final class ControlCenterWindowController: NSWindowController, NSTableViewDataSo
|
|
|
38
39
|
if let row = SidebarItem.allCases.firstIndex(of: section) { sidebar.selectRowIndexes(IndexSet(integer: row), byExtendingSelection: false) }
|
|
39
40
|
display(section)
|
|
40
41
|
NSApp.activate(ignoringOtherApps: true)
|
|
41
|
-
|
|
42
|
+
if !hasPresented {
|
|
43
|
+
window?.center()
|
|
44
|
+
hasPresented = true
|
|
45
|
+
}
|
|
42
46
|
showWindow(nil)
|
|
43
47
|
window?.makeKeyAndOrderFront(nil)
|
|
44
48
|
}
|
|
@@ -97,12 +101,14 @@ final class ControlCenterWindowController: NSWindowController, NSTableViewDataSo
|
|
|
97
101
|
private func display(_ section: SidebarItem) {
|
|
98
102
|
contentHost.subviews.forEach { $0.removeFromSuperview() }
|
|
99
103
|
guard let controller = controllers[section] else { return }
|
|
100
|
-
let
|
|
101
|
-
|
|
102
|
-
contentHost.addSubview(view)
|
|
104
|
+
let page = NativeView.scrollable(controller.view)
|
|
105
|
+
contentHost.addSubview(page)
|
|
103
106
|
NSLayoutConstraint.activate([
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
page.leadingAnchor.constraint(equalTo: contentHost.leadingAnchor),
|
|
108
|
+
page.trailingAnchor.constraint(equalTo: contentHost.trailingAnchor),
|
|
109
|
+
page.topAnchor.constraint(equalTo: contentHost.topAnchor),
|
|
110
|
+
page.bottomAnchor.constraint(equalTo: contentHost.bottomAnchor)
|
|
106
111
|
])
|
|
112
|
+
(controller as? ControlCenterPage)?.refreshOnAppear()
|
|
107
113
|
}
|
|
108
114
|
}
|
|
@@ -1,9 +1,16 @@
|
|
|
1
1
|
import Cocoa
|
|
2
2
|
|
|
3
|
-
final class DiagnosticsViewController: NSViewController {
|
|
3
|
+
final class DiagnosticsViewController: NSViewController, ControlCenterPage {
|
|
4
4
|
private let processClient: ProcessClient
|
|
5
|
+
private let operations: OperationCoordinator
|
|
5
6
|
private let status = NativeView.detail("Diagnostics are idle.")
|
|
6
|
-
|
|
7
|
+
private var busy = false
|
|
8
|
+
|
|
9
|
+
init(processClient: ProcessClient, operations: OperationCoordinator) {
|
|
10
|
+
self.processClient = processClient
|
|
11
|
+
self.operations = operations
|
|
12
|
+
super.init(nibName: nil, bundle: nil)
|
|
13
|
+
}
|
|
7
14
|
required init?(coder: NSCoder) { nil }
|
|
8
15
|
|
|
9
16
|
override func loadView() {
|
|
@@ -15,15 +22,72 @@ final class DiagnosticsViewController: NSViewController {
|
|
|
15
22
|
buttons.orientation = .horizontal; buttons.spacing = 8
|
|
16
23
|
view = NativeView.stack([
|
|
17
24
|
NativeView.title("Diagnostics"),
|
|
18
|
-
NativeView.detail("Diagnostic output is bounded, redacted, and written with owner-only permissions."),
|
|
25
|
+
NativeView.detail("Diagnostic output is bounded, redacted, and written with owner-only permissions. Use this page when another Center action reports a blocker."),
|
|
19
26
|
status, buttons
|
|
20
27
|
])
|
|
28
|
+
refreshOnAppear()
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
func refreshOnAppear() {
|
|
32
|
+
guard !busy else { return }
|
|
33
|
+
if let latest = operations.latestSnapshot() {
|
|
34
|
+
status.stringValue = "Last operation: \(latest.kind) · \(latest.state.rawValue) · \(latest.publicSummary)"
|
|
35
|
+
} else if FileManager.default.fileExists(atPath: AppRuntime.lastActionLogPath) {
|
|
36
|
+
status.stringValue = "Diagnostics idle. A previous action log is available via Open Last Log."
|
|
37
|
+
} else {
|
|
38
|
+
status.stringValue = "Diagnostics are idle. No operation log exists yet."
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@objc private func doctor() {
|
|
43
|
+
busy = true
|
|
44
|
+
status.stringValue = "Doctor is running…"
|
|
45
|
+
processClient.run(["doctor", "--json"], timeout: NativeView.mutationTimeout) { [weak self] result in
|
|
46
|
+
guard let self = self else { return }
|
|
47
|
+
self.busy = false
|
|
48
|
+
if result.code == 0 {
|
|
49
|
+
self.status.stringValue = "Doctor completed with no blocking issue."
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
if let json = self.json(result.output) {
|
|
53
|
+
let ok = json["ok"] as? Bool
|
|
54
|
+
let blockers = (json["blockers"] as? [String])?.count ?? (json["issues"] as? [Any])?.count
|
|
55
|
+
if let blockers = blockers {
|
|
56
|
+
self.status.stringValue = "Doctor reported \(blockers) issue\(blockers == 1 ? "" : "s"). Open Last Log for redacted detail."
|
|
57
|
+
return
|
|
58
|
+
}
|
|
59
|
+
if ok == false {
|
|
60
|
+
self.status.stringValue = "Doctor reported a blocker. Open Last Log for redacted detail."
|
|
61
|
+
return
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
self.status.stringValue = "Doctor reported a blocker · \(NativeView.redactPreview(result.output))"
|
|
65
|
+
}
|
|
21
66
|
}
|
|
22
67
|
|
|
23
|
-
@objc private func doctor() { status.stringValue = "Doctor is running…"; processClient.run(["doctor", "--json"]) { [weak self] result in self?.status.stringValue = result.code == 0 ? "Doctor completed." : "Doctor reported a blocker." } }
|
|
24
68
|
@objc private func openLog() {
|
|
25
|
-
if FileManager.default.fileExists(atPath: AppRuntime.lastActionLogPath) {
|
|
26
|
-
|
|
69
|
+
if FileManager.default.fileExists(atPath: AppRuntime.lastActionLogPath) {
|
|
70
|
+
NSWorkspace.shared.open(URL(fileURLWithPath: AppRuntime.lastActionLogPath))
|
|
71
|
+
status.stringValue = "Opened the latest redacted action log."
|
|
72
|
+
} else {
|
|
73
|
+
status.stringValue = "No operation log exists yet. Run Doctor or another Center action first."
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
@objc private func restart() {
|
|
78
|
+
busy = true
|
|
79
|
+
status.stringValue = "Restarting Menu Bar…"
|
|
80
|
+
processClient.run(["menubar", "restart", "--json"], timeout: NativeView.mutationTimeout) { [weak self] result in
|
|
81
|
+
guard let self = self else { return }
|
|
82
|
+
self.busy = false
|
|
83
|
+
self.status.stringValue = result.code == 0
|
|
84
|
+
? "Restart requested. Control Center will reopen after the Menu Bar process returns."
|
|
85
|
+
: "Restart failed · \(NativeView.redactPreview(result.output))"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
private func json(_ text: String) -> [String: Any]? {
|
|
90
|
+
guard let data = text.data(using: .utf8) else { return nil }
|
|
91
|
+
return try? JSONSerialization.jsonObject(with: data) as? [String: Any]
|
|
27
92
|
}
|
|
28
|
-
@objc private func restart() { processClient.run(["menubar", "restart", "--json"]) { [weak self] result in self?.status.stringValue = result.code == 0 ? "Restart requested." : "Restart failed." } }
|
|
29
93
|
}
|
|
@@ -65,7 +65,7 @@ private struct McpRow {
|
|
|
65
65
|
|
|
66
66
|
private struct McpDraft { let scope: String; let payload: [String: Any] }
|
|
67
67
|
|
|
68
|
-
final class MCPServersViewController: NSViewController, NSTableViewDataSource, NSTableViewDelegate {
|
|
68
|
+
final class MCPServersViewController: NSViewController, NSTableViewDataSource, NSTableViewDelegate, ControlCenterPage {
|
|
69
69
|
private let processClient: ProcessClient
|
|
70
70
|
private let operations: OperationCoordinator
|
|
71
71
|
private let notifications: NotificationCoordinator
|
|
@@ -197,11 +197,18 @@ final class MCPServersViewController: NSViewController, NSTableViewDataSource, N
|
|
|
197
197
|
}
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
+
func refreshOnAppear() { refresh() }
|
|
201
|
+
|
|
200
202
|
@objc private func testConnection() {
|
|
201
|
-
guard let selection = selected(),
|
|
203
|
+
guard let selection = selected(), selection.row.managedBy != "plugin" else { return }
|
|
202
204
|
status.stringValue = "Testing \(selection.row.name) with bounded initialize and tools/list…"
|
|
203
|
-
processClient.run(["mcp", "config", "test", selection.row.name, "--scope", selection.row.scope] + scopeContext(selection.row.scope, mutation: false) + ["--json"]) { [weak self] result in
|
|
204
|
-
guard let self = self, let json = self.json(result.output) else {
|
|
205
|
+
processClient.run(["mcp", "config", "test", selection.row.name, "--scope", selection.row.scope] + scopeContext(selection.row.scope, mutation: false) + ["--json"], timeout: NativeView.mutationTimeout) { [weak self] result in
|
|
206
|
+
guard let self = self, let json = self.json(result.output) else {
|
|
207
|
+
self?.status.stringValue = result.code == 0
|
|
208
|
+
? "Connection test failed without a readable receipt."
|
|
209
|
+
: "Connection test failed · \(NativeView.redactPreview(result.output))"
|
|
210
|
+
return
|
|
211
|
+
}
|
|
205
212
|
let state = json["status"] as? String ?? "unknown"
|
|
206
213
|
let latency = json["latency_ms"] as? Int
|
|
207
214
|
let tools = json["tool_count"] as? Int
|
|
@@ -363,6 +370,8 @@ private final class McpEditorSheet: NSObject {
|
|
|
363
370
|
|
|
364
371
|
private func build() {
|
|
365
372
|
panel.title = row == nil ? "Add MCP Server" : "Edit \(row!.name)"
|
|
373
|
+
panel.styleMask = [.titled, .resizable]
|
|
374
|
+
panel.minSize = NSSize(width: 560, height: 480)
|
|
366
375
|
let grid = NSGridView(views: [
|
|
367
376
|
pair("Scope", scope), pair("Transport", transport), pair("Name", name), pair("Executable", command), pair("Remote URL", url),
|
|
368
377
|
pair("Arguments — one per line", area(args, "Command arguments")), pair("Working directory", cwd), pair("Environment names — no values", area(env, "Environment-variable names")),
|
|
@@ -399,20 +408,52 @@ private final class McpEditorSheet: NSObject {
|
|
|
399
408
|
guard (payload["startup_timeout_sec"] as? Int).map({ 1...30 ~= $0 }) == true, (payload["tool_timeout_sec"] as? Int).map({ 1...3600 ~= $0 }) == true else { return nil }
|
|
400
409
|
if selectedTransport == "stdio" {
|
|
401
410
|
let executable = command.stringValue.trimmingCharacters(in: .whitespacesAndNewlines); if row == nil || row?.transport != selectedTransport { guard !executable.isEmpty else { return nil } }; if !executable.isEmpty { payload["command"] = executable }
|
|
402
|
-
let argv =
|
|
403
|
-
let names =
|
|
411
|
+
let argv = orderedLines(args.string); if argv.contains(where: { $0.contains("=") || $0.lowercased().contains("token") || $0.lowercased().contains("secret") }) { return nil }; if !argv.isEmpty { payload["args"] = argv }
|
|
412
|
+
let names = uniqueSortedLines(env.string); guard names.allSatisfy({ $0.range(of: #"^[A-Za-z_][A-Za-z0-9_]*$"#, options: .regularExpression) != nil }) else { return nil }; if !names.isEmpty { payload["env_vars"] = names }
|
|
404
413
|
let directory = cwd.stringValue.trimmingCharacters(in: .whitespacesAndNewlines); if !directory.isEmpty { guard directory.hasPrefix("/") else { return nil }; payload["cwd"] = directory }
|
|
405
414
|
if remote.state == .on { payload["experimental_environment"] = "remote" }
|
|
406
415
|
} else {
|
|
407
416
|
let endpoint = url.stringValue.trimmingCharacters(in: .whitespacesAndNewlines); if row == nil || row?.transport != selectedTransport { guard !endpoint.isEmpty else { return nil } }; if !endpoint.isEmpty { guard let parsed = URL(string: endpoint), ["http", "https"].contains(parsed.scheme?.lowercased() ?? ""), parsed.user == nil, parsed.password == nil else { return nil }; payload["url"] = endpoint }
|
|
408
417
|
let envName = bearer.stringValue.trimmingCharacters(in: .whitespacesAndNewlines); if !envName.isEmpty { guard envName.range(of: #"^[A-Za-z_][A-Za-z0-9_]*$"#, options: .regularExpression) != nil else { return nil }; payload["bearer_token_env_var"] = envName }
|
|
409
418
|
}
|
|
410
|
-
let allow =
|
|
419
|
+
let allow = uniqueSortedLines(enabledTools.string); let deny = uniqueSortedLines(disabledTools.string); guard Set(allow).isDisjoint(with: Set(deny)) else { return nil }; if !allow.isEmpty { payload["enabled_tools"] = allow }; if !deny.isEmpty { payload["disabled_tools"] = deny }
|
|
411
420
|
return McpDraft(scope: scope.titleOfSelectedItem?.lowercased() ?? "global", payload: payload)
|
|
412
421
|
}
|
|
413
422
|
|
|
414
|
-
private func validationMessage() -> String {
|
|
423
|
+
private func validationMessage() -> String {
|
|
424
|
+
let server = name.stringValue.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
425
|
+
if server.range(of: #"^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$"#, options: .regularExpression) == nil {
|
|
426
|
+
return "Fix the server name: use 1–64 letters, numbers, underscores, or hyphens."
|
|
427
|
+
}
|
|
428
|
+
if transport.indexOfSelectedItem == 0 {
|
|
429
|
+
let executable = command.stringValue.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
430
|
+
if (row == nil || row?.transport != "stdio") && executable.isEmpty { return "Executable is required for a local command server." }
|
|
431
|
+
if orderedLines(args.string).contains(where: { $0.contains("=") || $0.lowercased().contains("token") || $0.lowercased().contains("secret") }) {
|
|
432
|
+
return "Arguments must stay secret-free. Remove token/secret values and inline assignments."
|
|
433
|
+
}
|
|
434
|
+
if !uniqueSortedLines(env.string).allSatisfy({ $0.range(of: #"^[A-Za-z_][A-Za-z0-9_]*$"#, options: .regularExpression) != nil }) {
|
|
435
|
+
return "Environment names must be bare variable names with no values."
|
|
436
|
+
}
|
|
437
|
+
} else {
|
|
438
|
+
let endpoint = url.stringValue.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
439
|
+
if (row == nil || row?.transport != "streamable-http") && endpoint.isEmpty { return "Remote URL is required for a remote MCP server." }
|
|
440
|
+
}
|
|
441
|
+
let startupSec = Int(startup.stringValue) ?? 0
|
|
442
|
+
let toolSec = Int(tool.stringValue) ?? 0
|
|
443
|
+
if !(1...30 ~= startupSec) { return "Startup timeout must be between 1 and 30 seconds." }
|
|
444
|
+
if !(1...3600 ~= toolSec) { return "Tool timeout must be between 1 and 3600 seconds." }
|
|
445
|
+
let allow = uniqueSortedLines(enabledTools.string); let deny = uniqueSortedLines(disabledTools.string)
|
|
446
|
+
if !Set(allow).isDisjoint(with: Set(deny)) { return "Enabled and disabled tool lists must not overlap." }
|
|
447
|
+
return "Check the selected connection field, timeout ranges, environment names, tool lists, and secret-free arguments before review."
|
|
448
|
+
}
|
|
415
449
|
private func pair(_ label: String, _ control: NSView) -> [NSView] { [NSTextField(labelWithString: label), control] }
|
|
416
450
|
private func area(_ text: NSTextView, _ label: String) -> NSScrollView { text.isRichText = false; text.font = NSFont.systemFont(ofSize: 12); text.setAccessibilityLabel(label); let scroll = NSScrollView(); scroll.documentView = text; scroll.hasVerticalScroller = true; scroll.borderType = .bezelBorder; scroll.heightAnchor.constraint(equalToConstant: 52).isActive = true; return scroll }
|
|
417
|
-
private func
|
|
451
|
+
private func uniqueSortedLines(_ value: String) -> [String] { Array(Set(rawLines(value))).sorted() }
|
|
452
|
+
private func orderedLines(_ value: String) -> [String] {
|
|
453
|
+
var seen = Set<String>()
|
|
454
|
+
return rawLines(value).filter { seen.insert($0).inserted }
|
|
455
|
+
}
|
|
456
|
+
private func rawLines(_ value: String) -> [String] {
|
|
457
|
+
value.split(whereSeparator: \.isNewline).map { $0.trimmingCharacters(in: .whitespacesAndNewlines) }.filter { !$0.isEmpty }
|
|
458
|
+
}
|
|
418
459
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import Cocoa
|
|
2
2
|
|
|
3
|
+
/// Pages that should reload local status whenever the Control Center section becomes visible.
|
|
4
|
+
protocol ControlCenterPage: AnyObject {
|
|
5
|
+
func refreshOnAppear()
|
|
6
|
+
}
|
|
7
|
+
|
|
3
8
|
enum NativeView {
|
|
9
|
+
static let statusTimeout: TimeInterval = 8
|
|
10
|
+
static let mutationTimeout: TimeInterval = 90
|
|
11
|
+
|
|
4
12
|
static func title(_ value: String) -> NSTextField {
|
|
5
13
|
let field = NSTextField(labelWithString: value)
|
|
6
14
|
field.font = NSFont.systemFont(ofSize: 18, weight: .semibold)
|
|
@@ -29,6 +37,35 @@ enum NativeView {
|
|
|
29
37
|
stack.edgeInsets = NSEdgeInsets(top: 22, left: 24, bottom: 22, right: 24)
|
|
30
38
|
return stack
|
|
31
39
|
}
|
|
40
|
+
|
|
41
|
+
static func scrollable(_ document: NSView) -> NSScrollView {
|
|
42
|
+
let scroll = NSScrollView()
|
|
43
|
+
scroll.drawsBackground = false
|
|
44
|
+
scroll.hasVerticalScroller = true
|
|
45
|
+
scroll.hasHorizontalScroller = false
|
|
46
|
+
scroll.borderType = .noBorder
|
|
47
|
+
scroll.autohidesScrollers = true
|
|
48
|
+
scroll.translatesAutoresizingMaskIntoConstraints = false
|
|
49
|
+
document.translatesAutoresizingMaskIntoConstraints = false
|
|
50
|
+
scroll.documentView = document
|
|
51
|
+
if let content = scroll.contentView.documentView {
|
|
52
|
+
NSLayoutConstraint.activate([
|
|
53
|
+
content.leadingAnchor.constraint(equalTo: scroll.contentView.leadingAnchor),
|
|
54
|
+
content.trailingAnchor.constraint(equalTo: scroll.contentView.trailingAnchor),
|
|
55
|
+
content.topAnchor.constraint(equalTo: scroll.contentView.topAnchor)
|
|
56
|
+
])
|
|
57
|
+
}
|
|
58
|
+
return scroll
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static func redactPreview(_ output: String, limit: Int = 160) -> String {
|
|
62
|
+
let compact = output
|
|
63
|
+
.replacingOccurrences(of: "\n", with: " ")
|
|
64
|
+
.trimmingCharacters(in: .whitespacesAndNewlines)
|
|
65
|
+
guard !compact.isEmpty else { return "No public detail was returned." }
|
|
66
|
+
if compact.count <= limit { return compact }
|
|
67
|
+
return String(compact.prefix(limit)) + "…"
|
|
68
|
+
}
|
|
32
69
|
}
|
|
33
70
|
|
|
34
71
|
enum OverviewSummary {
|
|
@@ -182,12 +219,14 @@ enum OverviewSummary {
|
|
|
182
219
|
}
|
|
183
220
|
}
|
|
184
221
|
|
|
185
|
-
final class OverviewViewController: NSViewController {
|
|
222
|
+
final class OverviewViewController: NSViewController, ControlCenterPage {
|
|
186
223
|
private let processClient: ProcessClient
|
|
187
224
|
private let operations: OperationCoordinator
|
|
188
225
|
private let status = NativeView.detail("Loading local SKS status…")
|
|
189
226
|
private let notificationInbox = NativeView.detail("Notifications: checking authorization…")
|
|
190
227
|
private var generation = 0
|
|
228
|
+
private var doctorButton: NSButton!
|
|
229
|
+
private var refreshButton: NSButton!
|
|
191
230
|
|
|
192
231
|
init(processClient: ProcessClient, operations: OperationCoordinator) {
|
|
193
232
|
self.processClient = processClient
|
|
@@ -197,9 +236,9 @@ final class OverviewViewController: NSViewController {
|
|
|
197
236
|
required init?(coder: NSCoder) { nil }
|
|
198
237
|
|
|
199
238
|
override func loadView() {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
let buttons = NSStackView(views: [
|
|
239
|
+
doctorButton = NativeView.button("Run Doctor", target: self, action: #selector(doctor))
|
|
240
|
+
refreshButton = NativeView.button("Refresh", target: self, action: #selector(refreshStatus))
|
|
241
|
+
let buttons = NSStackView(views: [doctorButton, refreshButton])
|
|
203
242
|
buttons.orientation = .horizontal
|
|
204
243
|
buttons.spacing = 8
|
|
205
244
|
view = NativeView.stack([
|
|
@@ -212,6 +251,10 @@ final class OverviewViewController: NSViewController {
|
|
|
212
251
|
loadStatus(forceUpdateRefresh: false)
|
|
213
252
|
}
|
|
214
253
|
|
|
254
|
+
func refreshOnAppear() {
|
|
255
|
+
loadStatus(forceUpdateRefresh: false)
|
|
256
|
+
}
|
|
257
|
+
|
|
215
258
|
func setNotificationAuthorizationDenied(_ denied: Bool) {
|
|
216
259
|
notificationInbox.stringValue = denied
|
|
217
260
|
? "Notifications: permission denied — operation results remain available in this Control Center inbox."
|
|
@@ -225,6 +268,7 @@ final class OverviewViewController: NSViewController {
|
|
|
225
268
|
private func loadStatus(forceUpdateRefresh: Bool) {
|
|
226
269
|
generation += 1
|
|
227
270
|
let requestGeneration = generation
|
|
271
|
+
refreshButton?.isEnabled = false
|
|
228
272
|
status.stringValue = "Checking versions, MCP servers, Telegram Hub, remote fleet, and operations…"
|
|
229
273
|
var update: [String: Any]?
|
|
230
274
|
var mcp: [String: Any]?
|
|
@@ -234,7 +278,7 @@ final class OverviewViewController: NSViewController {
|
|
|
234
278
|
var updateArguments = ["update", "status"]
|
|
235
279
|
if forceUpdateRefresh { updateArguments.append("--refresh") }
|
|
236
280
|
updateArguments.append("--json")
|
|
237
|
-
processClient.run(updateArguments) { [weak self] result in
|
|
281
|
+
processClient.run(updateArguments, timeout: NativeView.statusTimeout) { [weak self] result in
|
|
238
282
|
update = result.code == 0 ? self?.json(result.output) : nil
|
|
239
283
|
group.leave()
|
|
240
284
|
}
|
|
@@ -247,24 +291,33 @@ final class OverviewViewController: NSViewController {
|
|
|
247
291
|
group.leave()
|
|
248
292
|
}
|
|
249
293
|
group.enter()
|
|
250
|
-
processClient.run(["telegram", "status", "--project-root", AppRuntime.projectRoot, "--json"]) { [weak self] result in
|
|
294
|
+
processClient.run(["telegram", "status", "--project-root", AppRuntime.projectRoot, "--json"], timeout: NativeView.statusTimeout) { [weak self] result in
|
|
251
295
|
telegram = result.code == 0 ? self?.json(result.output) : nil
|
|
252
296
|
group.leave()
|
|
253
297
|
}
|
|
254
298
|
group.notify(queue: .main) { [weak self] in
|
|
255
299
|
guard let self = self, self.generation == requestGeneration else { return }
|
|
300
|
+
self.refreshButton?.isEnabled = true
|
|
256
301
|
self.status.stringValue = self.summary(update: update, mcp: mcp, telegram: telegram)
|
|
257
302
|
}
|
|
258
303
|
DispatchQueue.main.asyncAfter(deadline: .now() + 5) { [weak self] in
|
|
259
304
|
guard let self = self, self.generation == requestGeneration else { return }
|
|
305
|
+
self.refreshButton?.isEnabled = true
|
|
260
306
|
self.status.stringValue = self.summary(update: update, mcp: mcp, telegram: telegram)
|
|
261
307
|
}
|
|
262
308
|
}
|
|
263
309
|
|
|
264
310
|
@objc private func doctor() {
|
|
311
|
+
doctorButton?.isEnabled = false
|
|
265
312
|
status.stringValue = "Doctor is running…"
|
|
266
|
-
processClient.run(["doctor", "--json"]) { [weak self] result in
|
|
267
|
-
self
|
|
313
|
+
processClient.run(["doctor", "--json"], timeout: NativeView.mutationTimeout) { [weak self] result in
|
|
314
|
+
guard let self = self else { return }
|
|
315
|
+
self.doctorButton?.isEnabled = true
|
|
316
|
+
if result.code == 0 {
|
|
317
|
+
self.status.stringValue = "Doctor completed. No blocking issue was reported."
|
|
318
|
+
} else {
|
|
319
|
+
self.status.stringValue = "Doctor found an issue. Open Diagnostics · \(NativeView.redactPreview(result.output))"
|
|
320
|
+
}
|
|
268
321
|
}
|
|
269
322
|
}
|
|
270
323
|
|