-
Notifications
You must be signed in to change notification settings - Fork 77
Create VellumAssistantShared library and restructure for iOS support #1821
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
3e0057d
Create VellumAssistantShared library target for code reuse
ashleeradka 2c302c3
Restructure directory layout for multi-platform support
ashleeradka 5ab4b1c
Address PR feedback: fix Resources directory and port overflow
ashleeradka f2aad9e
Resolve merge conflicts with main
ashleeradka 0d392fc
Add missing public initializers and properties
ashleeradka b672007
Merge main into ios/shared-library-foundation
ashleeradka 49b9aca
Fix access control and iOS compatibility issues in shared IPC layer
ashleeradka 91d776d
Complete public API consistency and add platform safety guards
ashleeradka bd4985c
Fix SendError visibility and clarify VellumAssistantLib platform rest…
ashleeradka bc4ae95
Fix platform coverage consistency and remove fragile Resources workar…
ashleeradka 9231d63
Fix @MainActor deinit data race in DaemonClient
ashleeradka 610fe14
Fix build script clean paths and revise deinit approach
ashleeradka 082e1e2
Add explicit Network framework linking to VellumAssistantShared
ashleeradka d66bc04
Merge main into ios/shared-library-foundation
ashleeradka 46d67f3
Add clients/ directory README for code organization documentation
ashleeradka 8fc0fce
Add imageData field to ToolResultMessage for protocol completeness
ashleeradka e3092be
Add missing public initializers to IPC message types
ashleeradka File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| .build/ | ||
| build/ | ||
| dist/ | ||
| .swiftpm/ | ||
| *.xcuserdata | ||
| xcuserdata/ | ||
| DerivedData/ | ||
| .dev/ | ||
| .DS_Store | ||
| context.md | ||
| Local.xcconfig | ||
| daemon-bin/ |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,153 @@ | ||
| # Clients Directory | ||
|
|
||
| This directory contains native client applications for the Vellum Assistant, organized for code reuse between platforms. | ||
|
|
||
| ## Structure | ||
|
|
||
| ``` | ||
| clients/ | ||
| ├── Package.swift # Multi-platform Swift Package Manager manifest | ||
| ├── shared/ # VellumAssistantShared - cross-platform code | ||
| │ ├── IPC/ # Daemon communication (both macOS and iOS) | ||
| │ └── App/ # Shared app utilities | ||
| ├── macos/ # macOS-specific code | ||
| │ ├── vellum-assistant/ # VellumAssistantLib - macOS app logic | ||
| │ ├── vellum-assistant-app/ # Executable entry point | ||
| │ ├── build.sh # Build script (wraps SPM → .app → codesign) | ||
| │ └── CLAUDE.md # Development guide for Claude Code | ||
| └── ios/ # (Future) iOS-specific code | ||
| └── vellum-assistant-ios/ # iOS app (planned in PR 4-6) | ||
| ``` | ||
|
|
||
| ## Targets | ||
|
|
||
| ### VellumAssistantShared (Library) | ||
| **Platforms**: macOS 14+, iOS 17+ | ||
| **Purpose**: Platform-agnostic code shared between macOS and iOS apps | ||
|
|
||
| **Contains**: | ||
| - **IPC layer** (`DaemonClient`, `IPCMessages`) - Network communication with daemon | ||
| - macOS: Unix domain socket (`~/.vellum/vellum.sock`) | ||
| - iOS: TCP connection (configurable hostname:port) | ||
| - **Shared utilities** (signing, configuration) | ||
|
|
||
| **Dependencies**: None (only system frameworks: Network) | ||
|
|
||
| ### VellumAssistantLib (Library) | ||
| **Platforms**: macOS 14+ only | ||
| **Purpose**: macOS application logic | ||
|
|
||
| **Contains**: | ||
| - UI (AppKit views, panels, overlays) | ||
| - Computer-use features (accessibility, screen capture, input injection) | ||
| - macOS-specific integrations (menu bar, hotkeys, voice input) | ||
|
|
||
| **Dependencies**: VellumAssistantShared, HotKey, Sparkle | ||
| **Frameworks**: AppKit, ScreenCaptureKit, ApplicationServices, Vision, Speech | ||
|
|
||
| **⚠️ iOS apps should NOT depend on this target** - it links macOS-only frameworks. | ||
|
|
||
| ### vellum-assistant (Executable) | ||
| **Platforms**: macOS 14+ | ||
| **Purpose**: Thin entry point for macOS app | ||
|
|
||
| **Contains**: Just `@main` app delegate setup | ||
| **Dependencies**: VellumAssistantLib | ||
|
|
||
| ## Building | ||
|
|
||
| ### macOS App | ||
| ```bash | ||
| cd clients/macos | ||
| ./build.sh # Build debug .app | ||
| ./build.sh run # Build + launch | ||
| ./build.sh release # Build release | ||
| ./build.sh test # Run tests | ||
| ./build.sh clean # Remove artifacts | ||
| ``` | ||
|
|
||
| The build script: | ||
| 1. Runs `swift build` from `clients/macos/` (SPM finds `../Package.swift` automatically) | ||
| 2. Packages binary into `dist/Vellum.app` bundle | ||
| 3. Codesigns with ad-hoc signature (or release identity) | ||
|
|
||
| ### iOS App (Future) | ||
| Planned for PR 4-6 of the iOS rollout. Will depend only on VellumAssistantShared. | ||
|
|
||
| ## Code Reuse Strategy | ||
|
|
||
| **~45-50% code reuse** between macOS and iOS achieved through: | ||
|
|
||
| 1. **Shared IPC layer** - Both platforms communicate with daemon (different transport) | ||
| 2. **Shared design system** (PR 2) - Tokens and components with conditional compilation | ||
| 3. **Shared ViewModels** (PR 3) - ChatViewModel, message models work on both platforms | ||
|
|
||
| **Platform-specific**: | ||
| - **UI frameworks**: AppKit (macOS) vs UIKit (iOS) | ||
| - **Computer-use**: AXUIElement + CGEvent (macOS only, sandboxing prevents on iOS) | ||
| - **Screen recording**: ScreenCaptureKit (macOS) vs ReplayKit (iOS) | ||
| - **App lifecycle**: NSStatusItem (macOS) vs UIScene (iOS) | ||
|
|
||
| ## Migration from Single-Platform | ||
|
|
||
| This structure was introduced in PR #1821 (iOS shared library foundation). Before this: | ||
| - `clients/macos/Package.swift` - Single-platform package | ||
| - `clients/macos/vellum-assistant/IPC/` - macOS-only IPC code | ||
|
|
||
| After migration: | ||
| - `clients/Package.swift` - Multi-platform package | ||
| - `clients/shared/IPC/` - Cross-platform IPC code | ||
| - All 25+ IPC message types have `public` access and explicit `public init()` | ||
|
|
||
| ## Development | ||
|
|
||
| ### Adding Shared Code | ||
| 1. Place platform-agnostic code in `clients/shared/` | ||
| 2. Mark all types as `public` (cross-module access) | ||
| 3. Add explicit `public init()` to all structs (memberwise inits are internal) | ||
| 4. Use `#if os(macOS)` / `#elseif os(iOS)` for platform-specific code | ||
|
|
||
| ### Adding macOS-Only Code | ||
| 1. Place in `clients/macos/vellum-assistant/` | ||
| 2. Import `VellumAssistantShared` for access to IPC types | ||
| 3. Can use AppKit, ScreenCaptureKit, etc. freely | ||
|
|
||
| ### Adding iOS Code (Future) | ||
| 1. Place in `clients/ios/vellum-assistant-ios/` | ||
| 2. Import `VellumAssistantShared` for IPC, design tokens, ViewModels | ||
| 3. DO NOT import `VellumAssistantLib` (macOS-only) | ||
|
|
||
| ## Known Limitations | ||
|
|
||
| ### iOS TCP Connection | ||
| - Currently plaintext (no TLS) | ||
| - Safe for localhost development only | ||
| - TLS layer tracked for PR 11 (Daemon authentication) | ||
|
|
||
| ### iOS Signing Operations | ||
| - iOS clients log errors when daemon sends signing requests | ||
| - Cannot send error responses (protocol limitation) | ||
| - Daemon should detect iOS clients and avoid sending these messages | ||
|
|
||
| ### iOS Localhost Default | ||
| - iOS defaults to `localhost:8765` in UserDefaults | ||
| - Real device usage requires configuring daemon hostname | ||
| - PR 6 (iOS settings/onboarding) will provide UI for configuration | ||
|
|
||
| ## Documentation | ||
|
|
||
| - **macOS development**: See `clients/macos/CLAUDE.md` | ||
| - **PR #1821**: [iOS shared library foundation](https://github.com/vellum-ai/vellum-assistant/pull/1821) | ||
| - **iOS rollout plan**: See `.private/plans/sharded-mapping-shannon.md` (13 PRs) | ||
|
|
||
| ## Testing | ||
|
|
||
| ```bash | ||
| cd clients/macos | ||
| ./build.sh test # All SPM tests (both shared and macOS-specific) | ||
| ``` | ||
|
|
||
| Tests use mock implementations of protocols for dependency injection: | ||
| - `DaemonClientProtocol` → `MockDaemonClient` | ||
| - `AccessibilityTreeProviding` → `MockAccessibilityTree` | ||
| - `ScreenCaptureProviding` → `MockScreenCapture` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import Foundation | ||
| import VellumAssistantShared | ||
| import AppKit | ||
| import Combine | ||
| import UserNotifications | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import AppKit | ||
| import VellumAssistantShared | ||
| import Combine | ||
| import CoreText | ||
| import HotKey | ||
|
|
||
1 change: 1 addition & 0 deletions
1
clients/macos/vellum-assistant/ComputerUse/RecipeExecutor.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import Foundation | ||
| import VellumAssistantShared | ||
| import os | ||
|
|
||
| private let log = Logger( | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import Foundation | ||
| import VellumAssistantShared | ||
| import CoreGraphics | ||
| import AppKit | ||
| import os | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,6 @@ | ||
| import AppKit | ||
| import Foundation | ||
| import VellumAssistantShared | ||
|
|
||
| enum ChatRole: String { | ||
| case user | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import SwiftUI | ||
| import VellumAssistantShared | ||
| import UniformTypeIdentifiers | ||
|
|
||
| struct ChatView: View { | ||
|
|
||
1 change: 1 addition & 0 deletions
1
clients/macos/vellum-assistant/Features/Chat/ChatViewModel.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import Foundation | ||
| import VellumAssistantShared | ||
| import os | ||
| import UniformTypeIdentifiers | ||
| import AppKit | ||
|
|
||
1 change: 1 addition & 0 deletions
1
clients/macos/vellum-assistant/Features/Chat/InlineWidgets/InlineCardWidget.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
clients/macos/vellum-assistant/Features/Chat/InlineWidgets/InlineFallbackChip.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
clients/macos/vellum-assistant/Features/Chat/InlineWidgets/InlineListWidget.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
clients/macos/vellum-assistant/Features/Chat/InlineWidgets/InlineSurfaceRouter.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
clients/macos/vellum-assistant/Features/Chat/InlineWidgets/InlineTableWidget.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
clients/macos/vellum-assistant/Features/Chat/InlineWidgets/InlineWeatherWidget.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import SwiftUI | ||
| import VellumAssistantShared | ||
|
|
||
| // MARK: - Data Model | ||
|
|
||
|
|
||
1 change: 1 addition & 0 deletions
1
clients/macos/vellum-assistant/Features/Chat/ToolCallChip.swift
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| import SwiftUI | ||
| import VellumAssistantShared | ||
|
|
||
| struct ToolCallChip: View { | ||
| let toolCall: ToolCallData | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.