// YOUR CLAUDE (the owner, 20 Nov 2026: connecting Claude is // the grant), a card on Account after Open access (Android's // `AssistantsPart.kt`): the promise, each connection of your Claude, and // every sealed table with how it stands (On, Ask each time, Off). Its fan // holds each table (a tap deals its three settings), Remove, and Connect // Claude. Connect Claude and turning on a table left off on the card go // behind the phone's lock; the rest do not. // // Every word is the core's (`assistant.screen`); this file decides nothing // about what the grant is. import CottonFaces import CottonKit import CottonValues import Foundation /// Account's Your Claude card, as `assistant.screen` answers it. struct YourClaude: Equatable, Sendable { struct Choice: Equatable, Sendable { let access: String let label: String let on: Bool } struct Table: Equatable, Sendable { let table: String let label: String let needsLock: Bool let choices: [Choice] /// How it stands now, in the core's words. var said: String { choices.first(where: \.on)?.label ?? "" } } /// One group a person knows (Comms' Chats, Mail, Photos, Calls, Contacts, /// Files: the kit's `reads`), its tables set together; `mixed` where they /// stand apart, with no choice on. struct Group: Equatable, Sendable { let id: String let label: String let line: String let access: String let needsLock: Bool let choices: [Choice] } /// How your Claude may read now: `standing`, `timed`, `asks`, `nothing`, /// `waiting` or `none`, said for the page and for You's row. struct Reading: Equatable, Sendable { struct Act: Equatable, Sendable { /// `ask_all` (Ask each time instead) or `stop` (Stop now). let id: String let label: String } let state: String let row: String let connected: String? let title: String? let line: String? let act: Act? let note: String? let disconnect: String? } let heading: String let promise: String let connections: [String] let none: String? let mayRead: String let tables: [Table] /// Connect Claude, offered only while no Claude is connected (the core leaves it out once one is). let connect: String? let remove: String? /// The kit's groups (none for an app whose kit names none: it keeps `tables`). let groups: [Group] let reading: Reading? /// The card, or nil while the core answers none (signed out, no personal copy). init?(_ answer: JSONValue?) { guard let answer, let heading = answer.text("heading") else { return nil } self.heading = heading promise = answer.text("promise") ?? "" connections = answer.list("connections").compactMap { $0.text("said") } none = answer.text("none") mayRead = answer.text("mayRead") ?? "" tables = answer.list("tables").compactMap { t in guard let table = t.text("table") else { return nil } let choices = t.list("choices").compactMap { c in c.text("access").map { Choice(access: $0, label: c.text("label") ?? $0, on: c.flag("on")) } } return Table(table: table, label: t.text("label") ?? table, needsLock: t.flag("needsLock"), choices: choices) } connect = answer.text("connect") remove = answer.text("remove") groups = answer.list("groups").compactMap { g in guard let id = g.text("id") else { return nil } let choices = g.list("choices").compactMap { c in c.text("access").map { Choice(access: $0, label: c.text("label") ?? $0, on: c.flag("on")) } } return Group(id: id, label: g.text("label") ?? id, line: g.text("line") ?? "", access: g.text("access") ?? "", needsLock: g.flag("needsLock"), choices: choices) } reading = answer["reading"].flatMap { r in r.text("state").map { state in Reading(state: state, row: r.text("row") ?? "", connected: r.text("connected"), title: r.text("title"), line: r.text("line"), act: r["act"].flatMap { a in a.text("id").map { Reading.Act(id: $0, label: a.text("label") ?? "") } }, note: r.text("note"), disconnect: r.text("disconnect")) } } } /// The card on the plain face: the heading and the promise, each /// connection, then each table with how it stands. var drawn: DeckCard { var facts: [RecordValue] = connections.map { .object(["label": .text(""), "said": .text($0)]) } if let none { facts.append(.object(["label": .text(""), "said": .text(none)])) } facts += tables.map { .object(["label": .text($0.label), "said": .text($0.said)]) } return DeckCard(face: "plain", corner: nil, pressing: false, pace: nil, plate: nil, fields: [ "title": .text(heading), "subtitle": .text(promise), "facts": .list(facts), ]) } struct Scope: Encodable, Sendable { let table: String let access: String } struct SignedScope: Encodable, Sendable { let table: String let access: String let privateKey: String } struct Signed: Encodable, Sendable { let privateKey: String } /// A group's tables set together (`assistant.scope {group, access}`). struct GroupScope: Encodable, Sendable { let group: String let access: String } /// Widening a group, behind the phone's lock. struct SignedGroupScope: Encodable, Sendable { let group: String let access: String let privateKey: String } }