Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.
Rust acpagent-client-protocolai-agentsai-assistantclaudeclaude-codecodexcoding-agentscursorgeminigemini-cligrok-bot-alternativeiosiphonelinuxmacosmcpopen-sourcerustself-hosted
iPhone account page: big profile photo, accounts as faces, Google button with its mark, and a choice of connection route (Auto, Direct over Wi-Fi/Tailscale, or Cloudflare)
leepokai919cc9bc0c70
diff --git a/apps/ios/Resources/Assets.xcassets/google.imageset/Contents.json b/apps/ios/Resources/Assets.xcassets/google.imageset/Contents.jsonnew file mode 100644index 00000000..56369403--- /dev/null+++ b/apps/ios/Resources/Assets.xcassets/google.imageset/Contents.json@@ -0,0 +1,5 @@+{+ "images" : [ { "filename" : "google.svg", "idiom" : "universal" } ],+ "info" : { "author" : "xcode", "version" : 1 },+ "properties" : { "preserves-vector-representation" : true, "template-rendering-intent" : "original" }+}diff --git a/apps/ios/Resources/Assets.xcassets/google.imageset/google.svg b/apps/ios/Resources/Assets.xcassets/google.imageset/google.svgnew file mode 100644index 00000000..afd6b4f6--- /dev/null+++ b/apps/ios/Resources/Assets.xcassets/google.imageset/google.svg@@ -0,0 +1 @@+<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48"><path fill="#EA4335" d="M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"/><path fill="#4285F4" d="M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"/><path fill="#FBBC05" d="M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"/><path fill="#34A853" d="M24 48c6.48 0 11.93-2.13 15.89-5.81l-7.73-6c-2.15 1.45-4.92 2.3-8.16 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"/></svg>diff --git a/apps/ios/Views/AccountSwitcherView.swift b/apps/ios/Views/AccountSwitcherView.swiftindex e2f8a69c..7ef38d4e 100644--- a/apps/ios/Views/AccountSwitcherView.swift+++ b/apps/ios/Views/AccountSwitcherView.swift@@ -8,7 +8,7 @@ struct AccountSwitcherButton: View {var body: some View {Button { account.showSwitcher = true } label: {HStack(spacing: 4) {- AccountAvatar(url: account.avatarURL, size: 30)+ AccountAvatar(url: account.avatarURL, email: account.email, size: 30)Image(systemName: "chevron.down").font(.system(size: 10, weight: .semibold)).foregroundStyle(Palette.secondary)@@ -19,95 +19,52 @@ struct AccountSwitcherButton: View {}}+/// Who you're signed in as, the other accounts on this iPhone, and the way to the computers.struct AccountSwitcherView: View {@Environment(AppStore.self) private var app@Environment(AccountSession.self) private var account+ @Environment(AccountStore.self) private var accounts@State private var showSettings = false+ @State private var confirmSignOut = false+ @State private var route = ConnectionRoute.currentvar body: some View {CardForm {- CardSection("Accounts") {- if account.accounts.isEmpty {- Label("Local pairing", systemImage: "person.crop.circle")- .foregroundStyle(Palette.secondary)- }- ForEach(account.accounts) { item in- Button {- Task { await account.switchAccount(item) }- } label: {- HStack(spacing: 12) {- AccountAvatar(url: item.avatarURL, size: 34)- Text(item.email)- .lineLimit(1)- .foregroundStyle(Palette.text)- Spacer(minLength: 8)- if item.id == account.userID {- Image(systemName: "checkmark")- .foregroundStyle(Palette.text)- .accessibilityLabel("Current account")- }- }- .contentShape(Rectangle())- }- .buttonStyle(.plain)- .disabled(account.isBusy)- }- if !account.isSignedIn || account.supportsMultipleAccounts {- Button {- Task { await account.signIn() }- } label: {- Label(account.isSignedIn ? "Add Google account" : "Continue with Google", systemImage: "person.crop.circle.badge.plus")- .foregroundStyle(Palette.text)- .frame(maxWidth: .infinity, alignment: .leading)- .contentShape(Rectangle())- }- .buttonStyle(.plain)- .disabled(account.isBusy || !account.isConfigured)- }+ profile+ .frame(maxWidth: .infinity)+ .padding(.vertical, 8)++ if account.isSignedIn, account.supportsMultipleAccounts || account.accounts.count > 1 {+ switcher+ }++ CardSection("Connection") {+ RoutePicker(selection: Binding(get: { route }, set: { setRoute($0) }))}- CardSection(footer: "Computers are kept separately for each account on this iPhone. Signed in, you also see the computers added to your account.") {+ CardSection {Button { showSettings = true } label: {- HStack {- Label("Computers & settings", systemImage: "desktopcomputer").foregroundStyle(Palette.text)- Spacer(minLength: 8)- Image(systemName: "chevron.right").font(.caption.weight(.semibold)).foregroundStyle(Palette.tertiary)- }- .contentShape(Rectangle())+ RowLabel("Computers", systemImage: "desktopcomputer", chevron: true)}.buttonStyle(.plain)- }-- if account.isSignedIn {- CardSection(footer: "Signing out removes this account's computers and keys from this iPhone."- + (account.supportsMultipleAccounts ? "" : " Sign out to use a different Google account.")) {- Button {- Task { await app.signOut() }- } label: {- Text("Sign out of this account")- .foregroundStyle(Palette.danger)- .frame(maxWidth: .infinity, alignment: .leading)- .contentShape(Rectangle())+ if account.isSignedIn {+ Button { confirmSignOut = true } label: {+ RowLabel("Sign out", systemImage: "rectangle.portrait.and.arrow.right", tint: Palette.danger)}.buttonStyle(.plain).disabled(account.isBusy)}}- if !account.isConfigured {- CardSection {- Text("Account sign-in isn't configured in this build. Pairing with a code works without it.")- .foregroundStyle(Palette.secondary)- }- }if let message = account.errorMessage {- CardSection {- Text(message).foregroundStyle(Palette.danger)- }+ Label(message, systemImage: "exclamationmark.triangle.fill")+ .font(.footnote)+ .foregroundStyle(Palette.danger)+ .transition(.opacity)}}.safeAreaInset(edge: .top, spacing: 0) {- ModalHeader("Accounts") {+ ModalHeader("Account") {if account.isBusy {ThinkingOrb(state: .connecting, size: 20).accessibilityHidden(false).accessibilityLabel("Signing in")@@ -117,22 +74,220 @@ struct AccountSwitcherView: View {.background(Palette.background).animation(Motion.fade, value: account.isBusy)}+ .animation(Motion.layout, value: account.userID)+ .animation(Motion.fade, value: account.errorMessage).hidesSystemNavigationBar().navigationDestination(isPresented: $showSettings) { SettingsView(pushed: true) }+ .codyncDialog("Sign out of \(account.email ?? "this account")?", isPresented: $confirmSignOut,+ message: "This iPhone forgets the account's computers. Your bots stay on them.") {+ [DialogAction("Sign out", destructive: true) { Task { await app.signOut() } }]+ }+ }++ /// Saved for this iPhone; every computer reconnects over the new route right away.+ private func setRoute(_ new: ConnectionRoute) {+ withAnimation(Motion.morph) { route = new }+ ConnectionRoute.current = new+ for computer in accounts.computers { accounts.store(for: computer.id)?.restartStream() }+ }++ /// The big picture: your face and address when signed in, the Google button when not.+ @ViewBuilder private var profile: some View {+ if account.isSignedIn {+ VStack(spacing: 10) {+ AccountAvatar(url: account.avatarURL, email: account.email, size: 76)+ .overlay(alignment: .bottomTrailing) {+ Image("google")+ .resizable()+ .frame(width: 16, height: 16)+ .padding(5)+ .background(Palette.background, in: Circle())+ .offset(x: 2, y: 2)+ .accessibilityHidden(true)+ }+ Text(account.email ?? "")+ .font(.subheadline.weight(.medium))+ .foregroundStyle(Palette.text)+ .lineLimit(1)+ .truncationMode(.middle)+ }+ .transition(.opacity.combined(with: .scale(scale: 0.96)))+ } else {+ VStack(spacing: 16) {+ ZStack {+ Circle().fill(Palette.bubbleAgent).frame(width: 76, height: 76)+ Image(systemName: "person.fill")+ .font(.system(size: 32))+ .foregroundStyle(Palette.tertiary)+ }+ .accessibilityHidden(true)+ if account.isConfigured {+ GoogleSignInButton()+ } else {+ Label("QR pairing only in this build", systemImage: "qrcode")+ .font(.footnote)+ .foregroundStyle(Palette.secondary)+ }+ }+ .transition(.opacity.combined(with: .scale(scale: 0.96)))+ }+ }++ /// Every account on this iPhone as a face; tap one to switch, + to add another.+ private var switcher: some View {+ ScrollView(.horizontal, showsIndicators: false) {+ HStack(spacing: 14) {+ ForEach(account.accounts) { item in+ let current = item.id == account.userID+ Button { Task { await account.switchAccount(item) } } label: {+ AccountAvatar(url: item.avatarURL, email: item.email, size: 44)+ .padding(3)+ .overlay(Circle().strokeBorder(current ? Palette.accent : .clear, lineWidth: 2))+ }+ .buttonStyle(PressScale())+ .disabled(account.isBusy || current)+ .accessibilityLabel(item.email)+ .accessibilityAddTraits(current ? .isSelected : [])+ }+ if account.supportsMultipleAccounts {+ Button { Task { await account.signIn() } } label: {+ Image(systemName: "plus")+ .font(.system(size: 18, weight: .medium))+ .foregroundStyle(Palette.secondary)+ .frame(width: 50, height: 50)+ .background(Palette.bubbleAgent, in: Circle())+ }+ .buttonStyle(PressScale())+ .disabled(account.isBusy)+ .accessibilityLabel("Add Google account")+ }+ }+ .padding(.horizontal, 4)+ .frame(maxWidth: .infinity)+ }+ .scrollBounceBehavior(.basedOnSize)}}-private struct AccountAvatar: View {+/// Three routes as icons; one line under them says what the chosen one does.+private struct RoutePicker: View {+ @Binding var selection: ConnectionRoute++ private func info(_ route: ConnectionRoute) -> (icon: String, title: String, detail: String) {+ switch route {+ case .automatic: ("wand.and.sparkles", "Auto", "Wi-Fi or Tailscale when it answers, Cloudflare otherwise.")+ case .direct: ("point.3.connected.trianglepath.dotted", "Direct", "Wi-Fi and Tailscale only. Nothing goes through the cloud.")+ case .relay: ("cloud", "Cloudflare", "Always through the encrypted relay, from anywhere.")+ }+ }++ var body: some View {+ VStack(alignment: .leading, spacing: 12) {+ HStack(spacing: 8) {+ ForEach(ConnectionRoute.allCases, id: \.self) { route in+ let item = info(route)+ let on = route == selection+ Button { selection = route } label: {+ VStack(spacing: 6) {+ Image(systemName: item.icon).font(.system(size: 20))+ Text(item.title).font(.caption.weight(.medium))+ }+ .foregroundStyle(on ? Palette.onAccent : Palette.secondary)+ .frame(maxWidth: .infinity, minHeight: 64)+ .background(on ? Palette.accentFill : Palette.background, in: RoundedRectangle(cornerRadius: 14, style: .continuous))+ .contentShape(Rectangle())+ }+ .buttonStyle(PressScale())+ .accessibilityLabel(item.title)+ .accessibilityHint(item.detail)+ .accessibilityAddTraits(on ? .isSelected : [])+ }+ }+ Text(info(selection).detail)+ .font(.caption)+ .foregroundStyle(Palette.secondary)+ .contentTransition(.opacity)+ }+ }+}++/// Google's mark plus the one line it needs; used wherever sign-in is offered.+struct GoogleSignInButton: View {+ @Environment(AccountSession.self) private var account++ var body: some View {+ Button { Task { await account.signIn() } } label: {+ ZStack {+ HStack(spacing: 10) {+ Image("google").resizable().frame(width: 20, height: 20)+ Text("Continue with Google")+ }+ .opacity(account.isBusy ? 0 : 1)+ if account.isBusy { Spinner(size: 18) }+ }+ .font(.headline)+ .frame(maxWidth: .infinity, minHeight: 50)+ }+ .buttonStyle(.secondary)+ .disabled(account.isBusy)+ .animation(Motion.fade, value: account.isBusy)+ }+}++/// An icon and a short name, with a chevron when it leads somewhere.+private struct RowLabel: View {+ let title: String+ let systemImage: String+ var tint: Color = Palette.text+ var chevron = false++ init(_ title: String, systemImage: String, tint: Color = Palette.text, chevron: Bool = false) {+ self.title = title+ self.systemImage = systemImage+ self.tint = tint+ self.chevron = chevron+ }++ var body: some View {+ HStack(spacing: 12) {+ Image(systemName: systemImage)+ .font(.system(size: 17))+ .frame(width: 26)+ Text(title)+ Spacer(minLength: 8)+ if chevron {+ Image(systemName: "chevron.right").font(.caption.weight(.semibold)).foregroundStyle(Palette.tertiary)+ }+ }+ .foregroundStyle(tint)+ .contentShape(Rectangle())+ }+}++/// The account's photo; its first letter on a tinted circle until (or unless) the photo loads.+struct AccountAvatar: View {let url: URL?+ var email: String?let size: CGFloatvar body: some View {- AsyncImage(url: url) { image in- image.resizable().scaledToFill()- } placeholder: {- Image(systemName: "person.crop.circle.fill")- .resizable()- .foregroundStyle(Palette.secondary)+ AsyncImage(url: url) { phase in+ if let image = phase.image {+ image.resizable().scaledToFill()+ } else {+ ZStack {+ Circle().fill(Palette.bubbleUser)+ if let letter = email?.first {+ Text(String(letter).uppercased())+ .font(.system(size: size * 0.42, weight: .semibold))+ .foregroundStyle(Palette.text)+ } else {+ Image(systemName: "person.fill")+ .font(.system(size: size * 0.42))+ .foregroundStyle(Palette.tertiary)+ }+ }+ }}.frame(width: size, height: size).clipShape(Circle())diff --git a/apps/ios/Views/WelcomeView.swift b/apps/ios/Views/WelcomeView.swiftindex 5acf0512..e5babf8d 100644--- a/apps/ios/Views/WelcomeView.swift+++ b/apps/ios/Views/WelcomeView.swift@@ -41,20 +41,7 @@ struct WelcomeView: View {}.buttonStyle(.primary)// Signed in, the computers on the account show up without scanning a code.- if account.isConfigured {- Button { Task { await account.signIn() } } label: {- ZStack {- Label("Continue with Google", systemImage: "person.crop.circle")- .opacity(account.isBusy ? 0 : 1)- if account.isBusy { Spinner(size: 18) }- }- .font(.headline)- .frame(maxWidth: .infinity, minHeight: 50)- }- .buttonStyle(.secondary)- .disabled(account.isBusy)- .animation(Motion.fade, value: account.isBusy)- }+ if account.isConfigured { GoogleSignInButton() }if let message = account.errorMessage {Text(message).font(.footnote).foregroundStyle(Palette.danger).transition(.opacity)diff --git a/kit/Sources/CodyncKit/Client/ChannelTransport.swift b/kit/Sources/CodyncKit/Client/ChannelTransport.swiftindex c2c95c21..9044b0e4 100644--- a/kit/Sources/CodyncKit/Client/ChannelTransport.swift+++ b/kit/Sources/CodyncKit/Client/ChannelTransport.swift@@ -5,6 +5,23 @@ import osprivate let log = Logger(subsystem: "com.pokai.Codync", category: "Channel")+/// How this device reaches its computers; the user picks it, every channel reads it on each attempt.+public enum ConnectionRoute: String, CaseIterable, Sendable {+ /// Direct (Wi-Fi, Tailscale) when it answers within 1.5 s, otherwise the Cloudflare relay.+ case automatic+ /// Wi-Fi and Tailscale only: nothing goes through the cloud.+ case direct+ /// Always the Cloudflare relay, even at home.+ case relay++ private static let key = "connectionRoute"++ public static var current: ConnectionRoute {+ get { UserDefaults(suiteName: SharedStore.appGroup)?.string(forKey: key).flatMap(Self.init(rawValue:)) ?? .automatic }+ set { UserDefaults(suiteName: SharedStore.appGroup)?.set(newValue.rawValue, forKey: key) }+ }+}+/// The end-to-end encrypted channel to one computer (§6, §7): direct WebSocket on the LAN when it/// answers within 1.5 s, otherwise the cloud relay. Inner RPC multiplexes calls and streams over/// one channel; the relay adds presence and the offline mailbox. Reconnects by itself until `shutdown()`.@@ -261,7 +278,9 @@ public actor ChannelTransport: RemoteTransport {}private func attempt() async -> Outcome {- let directURLs = computer.urls.compactMap(Self.channelURL)+ let route = ConnectionRoute.current+ // Relay only still goes direct for a computer that has no relay.+ let directURLs = route == .relay && computer.cloud != nil ? [] : computer.urls.compactMap(Self.channelURL)if !directURLs.isEmpty {switch await raceDirect(directURLs) {case let .connected(socket, keys): return await serve(socket, route: .direct, keys: keys)@@ -280,7 +299,7 @@ public actor ChannelTransport: RemoteTransport {case .none: break}}- guard let cloud = computer.cloud else { return .retry(HostError.unreachable.localizedDescription) }+ guard let cloud = computer.cloud, route != .direct else { return .retry(HostError.unreachable.localizedDescription) }let socket: any ChannelSocketdo {socket = try await dial(.relay(relayRequest(cloud)))