@lattices/cli 0.4.9 → 0.4.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 (201) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +13 -13
  3. package/{app → apps/mac}/Lattices.app/Contents/Info.plist +10 -2
  4. package/{app → apps/mac}/Lattices.app/Contents/MacOS/Lattices +0 -0
  5. package/{app → apps/mac}/Package.swift +2 -1
  6. package/apps/mac/Resources/Pets/assistant-spark/pet.json +62 -0
  7. package/apps/mac/Resources/Pets/assistant-spark/spritesheet.webp +0 -0
  8. package/apps/mac/Resources/Pets/scout-ranger/pet.json +6 -0
  9. package/apps/mac/Resources/Pets/scout-ranger/spritesheet.webp +0 -0
  10. package/apps/mac/Sources/AppShell/AppActivationCoordinator.swift +27 -0
  11. package/apps/mac/Sources/AppShell/AppDelegate.swift +189 -0
  12. package/apps/mac/Sources/AppShell/AppServicesBootstrap.swift +25 -0
  13. package/{app → apps/mac}/Sources/AppShell/AppShellView.swift +18 -3
  14. package/{app → apps/mac}/Sources/AppShell/AppUpdater.swift +4 -3
  15. package/apps/mac/Sources/AppShell/HotkeyBootstrap.swift +87 -0
  16. package/{app → apps/mac}/Sources/AppShell/LatticesRuntime.swift +43 -0
  17. package/{app → apps/mac}/Sources/AppShell/MainView.swift +116 -63
  18. package/apps/mac/Sources/AppShell/MenuBarController.swift +177 -0
  19. package/{app → apps/mac}/Sources/AppShell/OnboardingView.swift +72 -60
  20. package/apps/mac/Sources/AppShell/PermissionsAssistantView.swift +366 -0
  21. package/apps/mac/Sources/AppShell/PermissionsAssistantWindow.swift +70 -0
  22. package/{app → apps/mac}/Sources/AppShell/Preferences.swift +37 -2
  23. package/{app → apps/mac}/Sources/AppShell/SettingsView.swift +815 -156
  24. package/{app → apps/mac}/Sources/AppShell/SettingsWindow.swift +10 -0
  25. package/apps/mac/Sources/AppShell/WorkspaceInspectorPresenter.swift +13 -0
  26. package/{app → apps/mac}/Sources/Core/Actions/HotkeyStore.swift +6 -1
  27. package/{app → apps/mac}/Sources/Core/Actions/IntentEngine.swift +2 -0
  28. package/{app → apps/mac}/Sources/Core/Daemon/DaemonServer.swift +5 -0
  29. package/{app → apps/mac}/Sources/Core/Daemon/LatticesApi.swift +365 -0
  30. package/{app → apps/mac}/Sources/Core/Desktop/DesktopModel.swift +1 -0
  31. package/{app → apps/mac}/Sources/Core/Desktop/OcrModel.swift +17 -13
  32. package/apps/mac/Sources/Core/Desktop/WindowCapture.swift +33 -0
  33. package/{app → apps/mac}/Sources/Core/Desktop/WindowDragSnapController.swift +18 -217
  34. package/{app → apps/mac}/Sources/Core/Desktop/WindowPreviewStore.swift +4 -5
  35. package/{app → apps/mac}/Sources/Core/Desktop/WindowTiler.swift +19 -13
  36. package/apps/mac/Sources/Core/Input/EventTapBreaker.swift +124 -0
  37. package/apps/mac/Sources/Core/Input/EventTapThread.swift +54 -0
  38. package/apps/mac/Sources/Core/Input/InputCaptureResetCenter.swift +20 -0
  39. package/apps/mac/Sources/Core/Input/KeyboardRemapController.swift +335 -0
  40. package/apps/mac/Sources/Core/Input/KeyboardRemapStore.swift +141 -0
  41. package/{app → apps/mac}/Sources/Core/Input/MouseGestureConfig.swift +155 -20
  42. package/apps/mac/Sources/Core/Input/MouseGestureController.swift +2259 -0
  43. package/apps/mac/Sources/Core/Input/MouseShortcutStore.swift +170 -0
  44. package/apps/mac/Sources/Core/Input/SecureEventInputMonitor.swift +39 -0
  45. package/apps/mac/Sources/Core/Input/ShapeRecognizer.swift +624 -0
  46. package/apps/mac/Sources/Core/Input/TapBudgetMeter.swift +56 -0
  47. package/{app → apps/mac}/Sources/Core/Overlays/ScreenMap/ScreenMapState.swift +46 -27
  48. package/{app → apps/mac}/Sources/Core/Overlays/ScreenMap/ScreenMapView.swift +580 -162
  49. package/apps/mac/Sources/Core/Overlays/ScreenOverlayCanvasController.swift +1240 -0
  50. package/{app → apps/mac}/Sources/Core/Overlays/Voice/VoiceCommandWindow.swift +11 -23
  51. package/{app → apps/mac}/Sources/Core/Pi/PiChatDock.swift +90 -43
  52. package/{app → apps/mac}/Sources/Core/Pi/PiChatSession.swift +676 -43
  53. package/{app → apps/mac}/Sources/Core/Pi/PiProviderSetupCallout.swift +5 -5
  54. package/{app → apps/mac}/Sources/Core/Pi/PiWorkspaceView.swift +93 -44
  55. package/apps/mac/Sources/Core/System/Capability.swift +79 -0
  56. package/{app → apps/mac}/Sources/Core/System/PermissionChecker.swift +43 -8
  57. package/{app → apps/mac}/Sources/Core/Voice/AudioProvider.swift +225 -56
  58. package/bin/handsoff-infer.ts +14 -5
  59. package/bin/handsoff-worker.ts +11 -7
  60. package/bin/infer.ts +406 -0
  61. package/bin/lattices-app.ts +57 -7
  62. package/bin/lattices-dev +40 -1
  63. package/bin/lattices.ts +1 -1
  64. package/docs/agent-execution-plan.md +9 -9
  65. package/docs/api.md +119 -0
  66. package/docs/app.md +1 -0
  67. package/docs/companion-deck.md +1 -1
  68. package/docs/gesture-customization-proposal.md +520 -0
  69. package/docs/mouse-gestures.md +79 -0
  70. package/docs/overview.md +2 -2
  71. package/docs/presentation-execution-review.md +9 -9
  72. package/docs/proposals/LAT-001-gesture-visual-customization.md +522 -0
  73. package/docs/proposals/LAT-002-shared-overlay-canvas.md +353 -0
  74. package/docs/proposals/LAT-003-menu-bar-controller-architecture.md +291 -0
  75. package/docs/proposals/LAT-004-interactive-overlay-actors.md +534 -0
  76. package/docs/reference/dewey.config.ts +74 -0
  77. package/docs/reference/install-agent.md +79 -0
  78. package/docs/repo-structure.md +100 -0
  79. package/docs/voice-error-model.md +7 -7
  80. package/docs/voice.md +18 -0
  81. package/package.json +23 -13
  82. package/swift/Package.swift +20 -0
  83. package/swift/Sources/DeckKit/DeckAction.swift +51 -0
  84. package/swift/Sources/DeckKit/DeckBridgeSecurity.swift +152 -0
  85. package/swift/Sources/DeckKit/DeckCockpit.swift +82 -0
  86. package/swift/Sources/DeckKit/DeckHost.swift +7 -0
  87. package/swift/Sources/DeckKit/DeckManifest.swift +145 -0
  88. package/swift/Sources/DeckKit/DeckRuntimeSnapshot.swift +533 -0
  89. package/swift/Sources/DeckKit/DeckTrackpad.swift +63 -0
  90. package/swift/Sources/DeckKit/DeckValue.swift +93 -0
  91. package/swift/Sources/DeckKit/DeckVoiceError.swift +88 -0
  92. package/swift/Tests/DeckKitTests/DeckKitTests.swift +286 -0
  93. package/app/Sources/AppShell/AppDelegate.swift +0 -408
  94. package/app/Sources/Core/Input/KeyboardRemapController.swift +0 -184
  95. package/app/Sources/Core/Input/KeyboardRemapStore.swift +0 -84
  96. package/app/Sources/Core/Input/MouseGestureController.swift +0 -1203
  97. package/app/Sources/Core/Input/MouseShortcutStore.swift +0 -107
  98. /package/{app → apps/mac}/Info.plist +0 -0
  99. /package/{app → apps/mac}/Lattices.app/Contents/Resources/AppIcon.icns +0 -0
  100. /package/{app → apps/mac}/Lattices.app/Contents/Resources/tap.wav +0 -0
  101. /package/{app → apps/mac}/Lattices.app/Contents/_CodeSignature/CodeResources +0 -0
  102. /package/{app → apps/mac}/Lattices.entitlements +0 -0
  103. /package/{app → apps/mac}/Resources/tap.wav +0 -0
  104. /package/{app → apps/mac}/Sources/AppShell/App.swift +0 -0
  105. /package/{app → apps/mac}/Sources/AppShell/CliActionLauncher.swift +0 -0
  106. /package/{app → apps/mac}/Sources/AppShell/HomeDashboardView.swift +0 -0
  107. /package/{app → apps/mac}/Sources/AppShell/KeyRecorderView.swift +0 -0
  108. /package/{app → apps/mac}/Sources/AppShell/MainWindow.swift +0 -0
  109. /package/{app → apps/mac}/Sources/Core/Actions/HotkeyManager.swift +0 -0
  110. /package/{app → apps/mac}/Sources/Core/Actions/IntentSchema.swift +0 -0
  111. /package/{app → apps/mac}/Sources/Core/Actions/Intents/CreateLayerIntent.swift +0 -0
  112. /package/{app → apps/mac}/Sources/Core/Actions/Intents/DistributeIntent.swift +0 -0
  113. /package/{app → apps/mac}/Sources/Core/Actions/Intents/FocusIntent.swift +0 -0
  114. /package/{app → apps/mac}/Sources/Core/Actions/Intents/HelpIntent.swift +0 -0
  115. /package/{app → apps/mac}/Sources/Core/Actions/Intents/KillIntent.swift +0 -0
  116. /package/{app → apps/mac}/Sources/Core/Actions/Intents/LatticeIntent.swift +0 -0
  117. /package/{app → apps/mac}/Sources/Core/Actions/Intents/LaunchIntent.swift +0 -0
  118. /package/{app → apps/mac}/Sources/Core/Actions/Intents/ListSessionsIntent.swift +0 -0
  119. /package/{app → apps/mac}/Sources/Core/Actions/Intents/ListWindowsIntent.swift +0 -0
  120. /package/{app → apps/mac}/Sources/Core/Actions/Intents/ScanIntent.swift +0 -0
  121. /package/{app → apps/mac}/Sources/Core/Actions/Intents/SearchIntent.swift +0 -0
  122. /package/{app → apps/mac}/Sources/Core/Actions/Intents/SwitchLayerIntent.swift +0 -0
  123. /package/{app → apps/mac}/Sources/Core/Actions/Intents/TileIntent.swift +0 -0
  124. /package/{app → apps/mac}/Sources/Core/Actions/PaletteCommand.swift +0 -0
  125. /package/{app → apps/mac}/Sources/Core/Actions/VoiceIntentResolver.swift +0 -0
  126. /package/{app → apps/mac}/Sources/Core/Companion/CompanionActivityLog.swift +0 -0
  127. /package/{app → apps/mac}/Sources/Core/Companion/CompanionKeyboardController.swift +0 -0
  128. /package/{app → apps/mac}/Sources/Core/Companion/LatticesCompanionBridgeServer.swift +0 -0
  129. /package/{app → apps/mac}/Sources/Core/Companion/LatticesCompanionCockpit.swift +0 -0
  130. /package/{app → apps/mac}/Sources/Core/Companion/LatticesCompanionSecurityCoordinator.swift +0 -0
  131. /package/{app → apps/mac}/Sources/Core/Companion/LatticesCompanionTrackpadController.swift +0 -0
  132. /package/{app → apps/mac}/Sources/Core/Companion/LatticesDeckHost.swift +0 -0
  133. /package/{app → apps/mac}/Sources/Core/Daemon/DaemonProtocol.swift +0 -0
  134. /package/{app → apps/mac}/Sources/Core/Desktop/AccessibilityTextExtractor.swift +0 -0
  135. /package/{app → apps/mac}/Sources/Core/Desktop/AppTypeClassifier.swift +0 -0
  136. /package/{app → apps/mac}/Sources/Core/Desktop/DesktopModelTypes.swift +0 -0
  137. /package/{app → apps/mac}/Sources/Core/Desktop/InventoryManager.swift +0 -0
  138. /package/{app → apps/mac}/Sources/Core/Desktop/InventoryPath.swift +0 -0
  139. /package/{app → apps/mac}/Sources/Core/Desktop/MouseFinder.swift +0 -0
  140. /package/{app → apps/mac}/Sources/Core/Desktop/OcrStore.swift +0 -0
  141. /package/{app → apps/mac}/Sources/Core/Desktop/PlacementSpec.swift +0 -0
  142. /package/{app → apps/mac}/Sources/Core/Desktop/SessionWindowLocator.swift +0 -0
  143. /package/{app → apps/mac}/Sources/Core/Desktop/TilePickerView.swift +0 -0
  144. /package/{app → apps/mac}/Sources/Core/Desktop/WindowPreviewCard.swift +0 -0
  145. /package/{app → apps/mac}/Sources/Core/Desktop/WindowSelectionStore.swift +0 -0
  146. /package/{app → apps/mac}/Sources/Core/Input/KeyboardRemapConfig.swift +0 -0
  147. /package/{app → apps/mac}/Sources/Core/Input/MouseInputDeviceStore.swift +0 -0
  148. /package/{app → apps/mac}/Sources/Core/Input/MouseInputEventViewer.swift +0 -0
  149. /package/{app → apps/mac}/Sources/Core/Overlays/AppWindowShell.swift +0 -0
  150. /package/{app → apps/mac}/Sources/Core/Overlays/CommandMode/CommandModeState.swift +0 -0
  151. /package/{app → apps/mac}/Sources/Core/Overlays/CommandMode/CommandModeView.swift +0 -0
  152. /package/{app → apps/mac}/Sources/Core/Overlays/CommandMode/CommandModeWindow.swift +0 -0
  153. /package/{app → apps/mac}/Sources/Core/Overlays/CommandPalette/CommandPaletteView.swift +0 -0
  154. /package/{app → apps/mac}/Sources/Core/Overlays/CommandPalette/CommandPaletteWindow.swift +0 -0
  155. /package/{app → apps/mac}/Sources/Core/Overlays/HUD/CheatSheetHUD.swift +0 -0
  156. /package/{app → apps/mac}/Sources/Core/Overlays/HUD/HUDBottomBar.swift +0 -0
  157. /package/{app → apps/mac}/Sources/Core/Overlays/HUD/HUDController.swift +0 -0
  158. /package/{app → apps/mac}/Sources/Core/Overlays/HUD/HUDLeftBar.swift +0 -0
  159. /package/{app → apps/mac}/Sources/Core/Overlays/HUD/HUDMinimap.swift +0 -0
  160. /package/{app → apps/mac}/Sources/Core/Overlays/HUD/HUDRightBar.swift +0 -0
  161. /package/{app → apps/mac}/Sources/Core/Overlays/HUD/HUDState.swift +0 -0
  162. /package/{app → apps/mac}/Sources/Core/Overlays/HUD/HUDTopBar.swift +0 -0
  163. /package/{app → apps/mac}/Sources/Core/Overlays/HUD/LauncherHUD.swift +0 -0
  164. /package/{app → apps/mac}/Sources/Core/Overlays/HUD/LayerBezel.swift +0 -0
  165. /package/{app → apps/mac}/Sources/Core/Overlays/OmniSearch/OmniSearchState.swift +0 -0
  166. /package/{app → apps/mac}/Sources/Core/Overlays/OmniSearch/OmniSearchView.swift +0 -0
  167. /package/{app → apps/mac}/Sources/Core/Overlays/OmniSearch/OmniSearchWindow.swift +0 -0
  168. /package/{app → apps/mac}/Sources/Core/Overlays/OverlayPanelShell.swift +0 -0
  169. /package/{app → apps/mac}/Sources/Core/Overlays/ScreenMap/ScreenMapWindowController.swift +0 -0
  170. /package/{app → apps/mac}/Sources/Core/Pi/PiAuthNextStepCard.swift +0 -0
  171. /package/{app → apps/mac}/Sources/Core/Pi/PiAuthPromptCard.swift +0 -0
  172. /package/{app → apps/mac}/Sources/Core/Pi/PiInstallCallout.swift +0 -0
  173. /package/{app → apps/mac}/Sources/Core/System/DiagnosticLog.swift +0 -0
  174. /package/{app → apps/mac}/Sources/Core/System/EventBus.swift +0 -0
  175. /package/{app → apps/mac}/Sources/Core/System/ProcessModel.swift +0 -0
  176. /package/{app → apps/mac}/Sources/Core/System/ProcessQuery.swift +0 -0
  177. /package/{app → apps/mac}/Sources/Core/System/SystemTelemetryMonitor.swift +0 -0
  178. /package/{app → apps/mac}/Sources/Core/Voice/AdvisorLearningStore.swift +0 -0
  179. /package/{app → apps/mac}/Sources/Core/Voice/AgentSession.swift +0 -0
  180. /package/{app → apps/mac}/Sources/Core/Voice/HandsOffSession.swift +0 -0
  181. /package/{app → apps/mac}/Sources/Core/Voice/VoiceChatView.swift +0 -0
  182. /package/{app → apps/mac}/Sources/Core/Voice/VoxClient.swift +0 -0
  183. /package/{app → apps/mac}/Sources/Core/Workspace/Project.swift +0 -0
  184. /package/{app → apps/mac}/Sources/Core/Workspace/ProjectScanner.swift +0 -0
  185. /package/{app → apps/mac}/Sources/Core/Workspace/SessionLayerStore.swift +0 -0
  186. /package/{app → apps/mac}/Sources/Core/Workspace/SessionManager.swift +0 -0
  187. /package/{app → apps/mac}/Sources/Core/Workspace/Terminal/Terminal.swift +0 -0
  188. /package/{app → apps/mac}/Sources/Core/Workspace/Terminal/TerminalQuery.swift +0 -0
  189. /package/{app → apps/mac}/Sources/Core/Workspace/Terminal/TerminalSynthesizer.swift +0 -0
  190. /package/{app → apps/mac}/Sources/Core/Workspace/Tmux/TmuxModel.swift +0 -0
  191. /package/{app → apps/mac}/Sources/Core/Workspace/Tmux/TmuxQuery.swift +0 -0
  192. /package/{app → apps/mac}/Sources/Core/Workspace/WorkspaceManager.swift +0 -0
  193. /package/{app → apps/mac}/Sources/UI/ActionRow.swift +0 -0
  194. /package/{app → apps/mac}/Sources/UI/OrphanRow.swift +0 -0
  195. /package/{app → apps/mac}/Sources/UI/ProjectRow.swift +0 -0
  196. /package/{app → apps/mac}/Sources/UI/TabGroupRow.swift +0 -0
  197. /package/{app → apps/mac}/Sources/UI/Theme.swift +0 -0
  198. /package/{app → apps/mac}/Tests/StageDragTests.swift +0 -0
  199. /package/{app → apps/mac}/Tests/StageJoinTests.swift +0 -0
  200. /package/{app → apps/mac}/Tests/StageManagerTests.swift +0 -0
  201. /package/{app → apps/mac}/Tests/StageTileTests.swift +0 -0
@@ -0,0 +1,63 @@
1
+ import Foundation
2
+
3
+ public struct DeckTrackpadState: Codable, Equatable, Sendable {
4
+ public var isEnabled: Bool
5
+ public var isAvailable: Bool
6
+ public var statusTitle: String
7
+ public var statusDetail: String?
8
+ public var pointerScale: Double
9
+ public var scrollScale: Double
10
+ public var supportsDragLock: Bool
11
+
12
+ public init(
13
+ isEnabled: Bool,
14
+ isAvailable: Bool,
15
+ statusTitle: String,
16
+ statusDetail: String? = nil,
17
+ pointerScale: Double = 1.6,
18
+ scrollScale: Double = 1.0,
19
+ supportsDragLock: Bool = true
20
+ ) {
21
+ self.isEnabled = isEnabled
22
+ self.isAvailable = isAvailable
23
+ self.statusTitle = statusTitle
24
+ self.statusDetail = statusDetail
25
+ self.pointerScale = pointerScale
26
+ self.scrollScale = scrollScale
27
+ self.supportsDragLock = supportsDragLock
28
+ }
29
+ }
30
+
31
+ public struct DeckTrackpadEventRequest: Codable, Equatable, Sendable {
32
+ public var event: DeckTrackpadEvent
33
+ public var dx: Double
34
+ public var dy: Double
35
+
36
+ public init(
37
+ event: DeckTrackpadEvent,
38
+ dx: Double = 0,
39
+ dy: Double = 0
40
+ ) {
41
+ self.event = event
42
+ self.dx = dx
43
+ self.dy = dy
44
+ }
45
+ }
46
+
47
+ public enum DeckTrackpadEvent: String, Codable, CaseIterable, Sendable {
48
+ case move
49
+ case click
50
+ case rightClick
51
+ case scroll
52
+ case mouseDown
53
+ case mouseUp
54
+ case drag
55
+ }
56
+
57
+ public struct DeckTrackpadEventResult: Codable, Equatable, Sendable {
58
+ public var ok: Bool
59
+
60
+ public init(ok: Bool) {
61
+ self.ok = ok
62
+ }
63
+ }
@@ -0,0 +1,93 @@
1
+ import Foundation
2
+
3
+ public enum DeckValue: Codable, Equatable, Sendable {
4
+ case string(String)
5
+ case int(Int)
6
+ case double(Double)
7
+ case bool(Bool)
8
+ case array([DeckValue])
9
+ case object([String: DeckValue])
10
+ case null
11
+
12
+ public init(from decoder: Decoder) throws {
13
+ let container = try decoder.singleValueContainer()
14
+
15
+ if container.decodeNil() {
16
+ self = .null
17
+ } else if let bool = try? container.decode(Bool.self) {
18
+ self = .bool(bool)
19
+ } else if let int = try? container.decode(Int.self) {
20
+ self = .int(int)
21
+ } else if let double = try? container.decode(Double.self) {
22
+ self = .double(double)
23
+ } else if let string = try? container.decode(String.self) {
24
+ self = .string(string)
25
+ } else if let array = try? container.decode([DeckValue].self) {
26
+ self = .array(array)
27
+ } else if let object = try? container.decode([String: DeckValue].self) {
28
+ self = .object(object)
29
+ } else {
30
+ throw DecodingError.dataCorruptedError(
31
+ in: container,
32
+ debugDescription: "Unsupported DeckValue payload"
33
+ )
34
+ }
35
+ }
36
+
37
+ public func encode(to encoder: Encoder) throws {
38
+ var container = encoder.singleValueContainer()
39
+
40
+ switch self {
41
+ case .string(let value):
42
+ try container.encode(value)
43
+ case .int(let value):
44
+ try container.encode(value)
45
+ case .double(let value):
46
+ try container.encode(value)
47
+ case .bool(let value):
48
+ try container.encode(value)
49
+ case .array(let value):
50
+ try container.encode(value)
51
+ case .object(let value):
52
+ try container.encode(value)
53
+ case .null:
54
+ try container.encodeNil()
55
+ }
56
+ }
57
+
58
+ public var stringValue: String? {
59
+ guard case .string(let value) = self else { return nil }
60
+ return value
61
+ }
62
+
63
+ public var intValue: Int? {
64
+ guard case .int(let value) = self else { return nil }
65
+ return value
66
+ }
67
+
68
+ public var doubleValue: Double? {
69
+ switch self {
70
+ case .double(let value):
71
+ return value
72
+ case .int(let value):
73
+ return Double(value)
74
+ default:
75
+ return nil
76
+ }
77
+ }
78
+
79
+ public var boolValue: Bool? {
80
+ guard case .bool(let value) = self else { return nil }
81
+ return value
82
+ }
83
+
84
+ public var arrayValue: [DeckValue]? {
85
+ guard case .array(let value) = self else { return nil }
86
+ return value
87
+ }
88
+
89
+ public var objectValue: [String: DeckValue]? {
90
+ guard case .object(let value) = self else { return nil }
91
+ return value
92
+ }
93
+ }
@@ -0,0 +1,88 @@
1
+ import Foundation
2
+
3
+ // MARK: - Voice error model
4
+ //
5
+ // Shared across Mac (capture + execution) and iPad (relay + status).
6
+ // Stable raw string values so codes survive JSON, JSONL logs, and the bridge
7
+ // snapshot. See `docs/voice-error-model.md` for the design rationale.
8
+
9
+ public struct DeckVoiceError: Codable, Equatable, Identifiable, Sendable {
10
+ public var id: String
11
+ public var code: DeckVoiceErrorCode
12
+ public var severity: DeckErrorSeverity
13
+ public var recoverable: Bool
14
+ public var retry: DeckRetryHint?
15
+ public var source: DeckErrorSource
16
+ public var owner: String? // e.g. "Vox" for mic_busy
17
+ public var message: String // cockpit copy, human-readable
18
+ public var remediation: DeckRemediationAction?
19
+ public var occurredAt: Date
20
+ public var detail: String? // diagnostic-only, not displayed
21
+
22
+ public init(
23
+ id: String = UUID().uuidString,
24
+ code: DeckVoiceErrorCode,
25
+ severity: DeckErrorSeverity,
26
+ recoverable: Bool,
27
+ retry: DeckRetryHint? = nil,
28
+ source: DeckErrorSource,
29
+ owner: String? = nil,
30
+ message: String,
31
+ remediation: DeckRemediationAction? = nil,
32
+ occurredAt: Date = .now,
33
+ detail: String? = nil
34
+ ) {
35
+ self.id = id
36
+ self.code = code
37
+ self.severity = severity
38
+ self.recoverable = recoverable
39
+ self.retry = retry
40
+ self.source = source
41
+ self.owner = owner
42
+ self.message = message
43
+ self.remediation = remediation
44
+ self.occurredAt = occurredAt
45
+ self.detail = detail
46
+ }
47
+ }
48
+
49
+ public enum DeckVoiceErrorCode: String, Codable, CaseIterable, Sendable {
50
+ case voxUnreachable = "vox_unreachable"
51
+ case daemonUnreachable = "daemon_unreachable"
52
+ case network = "network"
53
+ case connectionLost = "connection_lost"
54
+ case micDenied = "mic_denied"
55
+ case accessibilityDenied = "accessibility_denied"
56
+ case micBusy = "mic_busy"
57
+ case noActiveTarget = "no_active_target"
58
+ case voxNotRunning = "vox_not_running"
59
+ case voxLoading = "vox_loading"
60
+ case intentUnresolved = "intent_unresolved"
61
+ case actionFailed = "action_failed"
62
+ case transcriptionFailed = "transcription_failed"
63
+ case emptyTranscript = "empty_transcript"
64
+ case languageUnsupported = "language_unsupported"
65
+ }
66
+
67
+ public enum DeckErrorSeverity: String, Codable, CaseIterable, Sendable {
68
+ case info, warning, error, blocked
69
+ }
70
+
71
+ public enum DeckRetryHint: String, Codable, CaseIterable, Sendable {
72
+ case silent // reconnect quietly, log only
73
+ case immediate // safe to auto-retry now
74
+ case afterLaunch = "after_launch" // retry after launching a dependency (e.g. Vox)
75
+ case userAction = "user_action" // user must do something first
76
+ }
77
+
78
+ public enum DeckErrorSource: String, Codable, CaseIterable, Sendable {
79
+ case mac, ipad, vox, daemon, intent, bridge
80
+ }
81
+
82
+ public enum DeckRemediationAction: Codable, Equatable, Sendable {
83
+ case openVox
84
+ case openSystemSettings(kind: String)
85
+ case retryVoice
86
+ case openDiagnostics
87
+ case chooseTarget
88
+ }
@@ -0,0 +1,286 @@
1
+ import XCTest
2
+ @testable import DeckKit
3
+
4
+ final class DeckKitTests: XCTestCase {
5
+ func testManifestRoundTripPreservesEmbeddedSecurity() throws {
6
+ let manifest = DeckManifest(
7
+ product: DeckProductIdentity(
8
+ id: "com.arach.lattices",
9
+ displayName: "Lattices Companion",
10
+ owner: "lattices"
11
+ ),
12
+ security: .embeddedDelegated(owner: "talkie"),
13
+ capabilities: [.voiceAgent, .layoutControl, .embeddedSecurityDelegation],
14
+ pages: [
15
+ DeckPage(
16
+ id: "voice",
17
+ title: "Voice",
18
+ iconSystemName: "mic.fill",
19
+ kind: .voice,
20
+ accentToken: "royal-blue"
21
+ )
22
+ ]
23
+ )
24
+
25
+ let data = try JSONEncoder().encode(manifest)
26
+ let decoded = try JSONDecoder().decode(DeckManifest.self, from: data)
27
+
28
+ XCTAssertEqual(decoded, manifest)
29
+ XCTAssertEqual(decoded.security.delegatedOwner, "talkie")
30
+ }
31
+
32
+ func testSecurityConvenienceProfilesMatchIntendedModes() {
33
+ let standalone = DeckSecurityConfiguration.standaloneBonjour()
34
+ XCTAssertEqual(standalone.mode, .standalone)
35
+ XCTAssertEqual(standalone.pairingStrategy, .bonjour)
36
+ XCTAssertTrue(standalone.requestSigningRequired)
37
+ XCTAssertTrue(standalone.payloadEncryptionRequired)
38
+ XCTAssertNil(standalone.delegatedOwner)
39
+
40
+ let embedded = DeckSecurityConfiguration.embeddedDelegated(owner: "talkie")
41
+ XCTAssertEqual(embedded.mode, .embedded)
42
+ XCTAssertEqual(embedded.pairingStrategy, .delegated)
43
+ XCTAssertTrue(embedded.payloadEncryptionRequired)
44
+ XCTAssertEqual(embedded.delegatedOwner, "talkie")
45
+ }
46
+
47
+ func testPairingPayloadRoundTripPreservesSecurityFlags() throws {
48
+ let response = DeckPairingResponse(
49
+ disposition: .approved,
50
+ bridgeName: "Lats Bridge",
51
+ bridgePublicKey: "bridge-public-key",
52
+ bridgeFingerprint: "ABCD-1234",
53
+ requestSigningRequired: true,
54
+ payloadEncryptionRequired: true,
55
+ grantedCapabilities: [
56
+ DeckBridgeCapability.deckRead,
57
+ DeckBridgeCapability.deckPerform,
58
+ ],
59
+ detail: "Trusted on the Mac."
60
+ )
61
+
62
+ let data = try JSONEncoder().encode(response)
63
+ let decoded = try JSONDecoder().decode(DeckPairingResponse.self, from: data)
64
+
65
+ XCTAssertEqual(decoded, response)
66
+ XCTAssertEqual(decoded.grantedCapabilities, [
67
+ DeckBridgeCapability.deckRead,
68
+ DeckBridgeCapability.deckPerform,
69
+ ])
70
+ }
71
+
72
+ func testPairingPayloadDecodesLegacyCapabilityDefaults() throws {
73
+ let responseJSON = """
74
+ {
75
+ "disposition": "approved",
76
+ "bridgeName": "Lats Bridge",
77
+ "bridgePublicKey": "bridge-public-key",
78
+ "bridgeFingerprint": "ABCD-1234",
79
+ "requestSigningRequired": true,
80
+ "payloadEncryptionRequired": true
81
+ }
82
+ """.data(using: .utf8)!
83
+
84
+ let decodedResponse = try JSONDecoder().decode(DeckPairingResponse.self, from: responseJSON)
85
+ XCTAssertEqual(decodedResponse.grantedCapabilities, DeckBridgeCapability.defaultCompanionCapabilities)
86
+
87
+ let requestJSON = """
88
+ {
89
+ "deviceID": "ipad-1",
90
+ "deviceName": "iPad",
91
+ "devicePublicKey": "device-public-key",
92
+ "platform": "iPadOS"
93
+ }
94
+ """.data(using: .utf8)!
95
+
96
+ let decodedRequest = try JSONDecoder().decode(DeckPairingRequest.self, from: requestJSON)
97
+ XCTAssertEqual(decodedRequest.requestedCapabilities, DeckBridgeCapability.defaultCompanionCapabilities)
98
+ }
99
+
100
+ func testRuntimeSnapshotRoundTripPreservesSwitcherAndHistory() throws {
101
+ let snapshot = DeckRuntimeSnapshot(
102
+ updatedAt: Date(timeIntervalSince1970: 1_713_700_000),
103
+ cockpit: DeckCockpitState(
104
+ title: "Command Deck",
105
+ detail: "Quick controls from your Mac-defined cockpit.",
106
+ pages: [
107
+ DeckCockpitPage(
108
+ id: "main",
109
+ title: "Main",
110
+ subtitle: "Core controls",
111
+ columns: 4,
112
+ tiles: [
113
+ DeckCockpitTile(
114
+ id: "main-0",
115
+ shortcutID: "voice-toggle",
116
+ title: "Voice",
117
+ subtitle: "Start listening",
118
+ iconSystemName: "mic.fill",
119
+ accentToken: "voice",
120
+ actionID: "voice.toggle",
121
+ isActive: true
122
+ )
123
+ ]
124
+ )
125
+ ]
126
+ ),
127
+ trackpad: DeckTrackpadState(
128
+ isEnabled: true,
129
+ isAvailable: true,
130
+ statusTitle: "Trackpad Ready",
131
+ statusDetail: "Use the surface to move the Mac pointer.",
132
+ pointerScale: 1.8,
133
+ scrollScale: 1.2,
134
+ supportsDragLock: true
135
+ ),
136
+ voice: DeckVoiceState(
137
+ phase: .reasoning,
138
+ transcript: "Arrange my review setup",
139
+ transcriptLines: [
140
+ DeckTranscriptLine(
141
+ id: "line-1",
142
+ createdAt: Date(timeIntervalSince1970: 1_713_700_001),
143
+ text: "Arrange my review setup",
144
+ isFinal: true,
145
+ confidence: 0.93,
146
+ source: "vox"
147
+ )
148
+ ],
149
+ responseSummary: "Preparing a code review layout.",
150
+ provider: "vox"
151
+ ),
152
+ desktop: DeckDesktopSummary(
153
+ activeLayerName: "review",
154
+ activeAppName: "Safari",
155
+ screenCount: 2,
156
+ visibleWindowCount: 6,
157
+ sessionCount: 3
158
+ ),
159
+ layout: DeckLayoutState(
160
+ screenName: "Built-in Retina Display",
161
+ frontmostWindow: DeckLayoutFocusWindow(
162
+ id: "window:42",
163
+ itemID: "window:42",
164
+ appName: "Safari",
165
+ title: "Pull request",
166
+ frame: DeckRect(x: 40, y: 80, w: 1440, h: 900),
167
+ normalizedFrame: DeckRect(x: 0.0, y: 0.0, w: 0.75, h: 1.0),
168
+ placement: "left"
169
+ ),
170
+ preview: DeckLayoutPreview(
171
+ aspectRatio: 1.6,
172
+ windows: [
173
+ DeckLayoutPreviewWindow(
174
+ id: "window:42",
175
+ itemID: "window:42",
176
+ title: "Pull request",
177
+ subtitle: "Safari",
178
+ normalizedFrame: DeckRect(x: 0.0, y: 0.0, w: 0.75, h: 1.0),
179
+ appCategory: "browser",
180
+ appCategoryTint: "blue",
181
+ isFrontmost: true
182
+ )
183
+ ]
184
+ )
185
+ ),
186
+ switcher: DeckSwitcherState(items: [
187
+ DeckSwitcherItem(
188
+ id: "app:safari",
189
+ title: "Safari",
190
+ subtitle: "Pull request",
191
+ iconToken: "safari",
192
+ kind: .application,
193
+ isFrontmost: true
194
+ ),
195
+ DeckSwitcherItem(
196
+ id: "session:frontend-a1b2c3",
197
+ title: "frontend-a1b2c3",
198
+ subtitle: "tmux session",
199
+ iconToken: "terminal",
200
+ kind: .session
201
+ )
202
+ ]),
203
+ telemetry: DeckSystemTelemetry(
204
+ sampledAt: Date(timeIntervalSince1970: 1_713_700_002),
205
+ cpuLoadPercent: 31,
206
+ memoryUsedPercent: 68,
207
+ gpuLoadPercent: 12,
208
+ thermalPressurePercent: 10,
209
+ thermalState: .nominal,
210
+ batteryPercent: 84,
211
+ isCharging: true,
212
+ powerSource: "AC Power",
213
+ windowCount: 6,
214
+ sessionCount: 3
215
+ ),
216
+ spaces: DeckSpacesState(
217
+ currentSpaceIndex: 2,
218
+ currentSpaceName: "code",
219
+ displays: [
220
+ DeckSpaceDisplay(
221
+ id: "main",
222
+ displayIndex: 0,
223
+ currentSpaceID: 20,
224
+ currentSpaceIndex: 2,
225
+ currentSpaceName: "code",
226
+ spaces: [
227
+ DeckSpace(id: 10, index: 1, name: "main", isCurrent: false),
228
+ DeckSpace(id: 20, index: 2, name: "code", isCurrent: true)
229
+ ]
230
+ )
231
+ ]
232
+ ),
233
+ cockpitMode: DeckCockpitModeState(
234
+ mode: .replay,
235
+ replayMessage: "Placed Safari left",
236
+ replayUndoActionID: "history.undoLast"
237
+ ),
238
+ activityLog: [
239
+ DeckActivityLogEntry(
240
+ id: "activity-1",
241
+ tag: "DECK",
242
+ tint: "blue",
243
+ text: "Placed Safari left"
244
+ )
245
+ ],
246
+ history: [
247
+ DeckHistoryEntry(
248
+ id: "history-1",
249
+ title: "Grid layout applied",
250
+ detail: "Distributed four visible windows.",
251
+ kind: .layout,
252
+ undoActionID: "undo-grid-layout"
253
+ )
254
+ ],
255
+ questions: [
256
+ DeckQuestionCard(
257
+ id: "question-1",
258
+ prompt: "Which monitor should hold the terminals?",
259
+ options: [
260
+ DeckQuestionOption(
261
+ id: "primary",
262
+ title: "Primary display",
263
+ actionID: "layout.place-terminals-primary"
264
+ )
265
+ ]
266
+ )
267
+ ]
268
+ )
269
+
270
+ let data = try JSONEncoder().encode(snapshot)
271
+ let decoded = try JSONDecoder().decode(DeckRuntimeSnapshot.self, from: data)
272
+
273
+ XCTAssertEqual(decoded, snapshot)
274
+ XCTAssertEqual(decoded.cockpit?.pages.first?.tiles.first?.shortcutID, "voice-toggle")
275
+ XCTAssertEqual(decoded.trackpad?.statusTitle, "Trackpad Ready")
276
+ XCTAssertEqual(decoded.voice?.provider, "vox")
277
+ XCTAssertEqual(decoded.voice?.transcriptLines?.first?.source, "vox")
278
+ XCTAssertEqual(decoded.layout?.frontmostWindow?.placement, "left")
279
+ XCTAssertEqual(decoded.layout?.preview?.windows.first?.appCategoryTint, "blue")
280
+ XCTAssertEqual(decoded.switcher?.items.count, 2)
281
+ XCTAssertEqual(decoded.telemetry?.thermalState, .nominal)
282
+ XCTAssertEqual(decoded.spaces?.currentSpaceName, "code")
283
+ XCTAssertEqual(decoded.cockpitMode?.mode, .replay)
284
+ XCTAssertEqual(decoded.activityLog?.first?.tag, "DECK")
285
+ }
286
+ }