Cotton code
251 lines · 12.7 KB · JSONRaw
{  "format_version": 1,  "id": "connection",  "list_route": "/connections",  "scope": "personal",  "setup": true,  "name": "Connection",  "plural": "Connections",  "picture": {"photo":"photo:6f71af975b7008c22e7935375de86239ca3a81c4b7f77b1717b7ff9fa5f40cc7","object":"tool-connections"},  "builtin": true,  "engine": "connections",  "screen_family": "connections",  "columns": [    { "key": "kind", "name": "Kind", "type": "choice", "choices": ["WhatsApp", "Google", "Mail", "Calendar", "Cloudflare", "Code host", "MCP server", "This Mac", "Browser", "Tailscale"], "choices_from": "kind_choices", "required": true },    { "key": "kind_choices", "name": "Connectable kinds", "type": "choice", "choices": ["WhatsApp", "Google", "Mail", "Calendar", "Cloudflare", "Code host", "MCP server", "Tailscale"], "multiple": true, "readonly": true },    { "key": "name", "name": "Name", "type": "text", "required": true },    { "key": "reaches", "name": "Address", "type": "text" },    { "key": "site", "name": "Site", "type": "text", "readonly": true, "shown_when": { "column": "kind", "values": ["Browser"] } },    { "key": "account", "name": "Account", "type": "text", "readonly": true, "shown_when": { "column": "kind", "values": ["Browser"] } },    { "key": "browser_facts", "name": "Reading", "type": "text", "readonly": true, "shown_when": { "column": "kind", "values": ["Browser"] } },    { "key": "state", "name": "State", "type": "choice", "choices": ["Reading", "Paused", "Needs sign-in", "Needs sign-in on your Mac", "Failed"], "readonly": true },    { "key": "last_read_at", "name": "Last read", "type": "date", "readonly": true, "format": "ago", "units": { "one": "read {n}", "other": "read {n}" } },    { "key": "brought", "name": "Brought", "type": "text", "readonly": true },    { "key": "progress", "name": "Import", "type": "text", "readonly": true, "shown_when": { "column": "kind", "values": ["This Mac"] } },    { "key": "last_error", "name": "What went wrong", "type": "longtext", "readonly": true, "shown_when": { "column": "state", "values": ["Failed", "Needs sign-in"] } },    { "key": "tools", "name": "Tools", "type": "text", "readonly": true, "shown_when": { "column": "kind", "values": ["MCP server"] } },    { "key": "status", "name": "Status", "type": "text", "readonly": true, "shown_when": { "column": "kind", "values": ["Google", "Code host"] } },    { "key": "detail", "name": "Detail", "type": "longtext", "readonly": true, "shown_when": { "column": "kind", "values": ["Google", "Code host"] } },    { "key": "gmail", "name": "Gmail", "type": "bool", "shown_when": { "column": "kind", "values": ["Google"] } },    { "key": "gmail_bin", "name": "Deleting here also deletes in Gmail", "type": "bool", "shown_when": { "column": "kind", "values": ["Google"] } },    { "key": "statuses", "name": "Statuses", "type": "bool", "shown_when": { "column": "kind", "values": ["WhatsApp"] } },    { "key": "token", "name": "Token", "type": "text", "secret": true, "shown_when": { "column": "kind", "values": ["Code host", "Cloudflare"] } },    { "key": "registrar_token", "name": "Registering token", "type": "text", "secret": true, "placeholder": "Only to register or hand over a domain", "shown_when": { "column": "kind", "values": ["Cloudflare"] } },    { "key": "password", "name": "App password", "type": "text", "secret": true, "placeholder": "From the provider's security settings", "shown_when": { "column": "kind", "values": ["Mail", "Calendar"] } },    { "key": "client_id", "name": "OAuth client ID", "type": "text", "placeholder": "From the Tailscale admin console, Settings › OAuth clients", "shown_when": { "column": "kind", "values": ["Tailscale"] } },    { "key": "client_secret", "name": "OAuth client secret", "type": "text", "secret": true, "shown_when": { "column": "kind", "values": ["Tailscale"] } },    { "key": "server", "name": "Server", "type": "text", "placeholder": "Only for a provider Cotton does not know", "shown_when": { "column": "kind", "values": ["Mail", "Calendar"] } },    { "key": "hold", "name": "Held in Cotton", "type": "bool", "shown_when": { "column": "kind", "values": ["Code host"] } },    { "key": "held", "name": "Held", "type": "text", "readonly": true, "shown_when": { "column": "kind", "values": ["Code host"] } }  ],  "title": "name",  "date": "last_read_at",  "project": null,  "order": null,  "slip": { "title": "name", "subtitle": "reaches", "trailing": "state", "photo": null, "toggle": null, "caption": { "columns": ["progress", "state", "last_error", "status", "held"] } },  "tile": { "face": "slip-list" },  "empty": { "title": "Cotton reads nothing from outside yet", "message": "Connect… to read WhatsApp, Google, mail, a calendar, a code host or an MCP server." },  "page": [    { "heading": null, "columns": ["kind", "name", "reaches", "state"] },    { "heading": "Reading", "columns": ["progress", "last_read_at", "brought", "tools", "last_error", "status", "detail"] },    { "heading": "Settings", "columns": ["gmail", "gmail_bin", "statuses", "token", "registrar_token", "password", "client_id", "client_secret", "server", "hold", "held"] }  ],  "instructions": "A connection is something Cotton keeps reading from outside and bringing into this database: a WhatsApp number, a Google account, a mailbox, a calendar, Cloudflare, a code host, an MCP server, or the household's Tailscale tailnet. Each says what it reaches, whether it is reading, paused, waiting for a sign-in or failed, when it last read, and what went wrong in words. The list's act is Connect…, which asks the kind; a mailbox or a calendar connects by its address and an app password made in the provider's security settings (Server only for a provider Cotton does not know: a mail host, or a calendar's https address), and a Gmail calendar connects through Google instead, because Google's calendar takes only its own sign-in; Cloudflare connects by an API token the person makes in Cloudflare's dashboard — one that only reads is enough — and the domains that account holds are listed in the Domains tool, with nothing changed at Cloudflare; a second, Registering token — one that may register domains and make API tokens — is asked for only if domains are to be registered or handed over from Cotton, is opened only by those two acts on a domain's page, and is never the one the reading uses; a Tailscale tailnet connects by its name (Address, like tail1234.ts.net) and an OAuth client made in the Tailscale admin console, sealed in the vault as one login, and is optional: with it every device reaches the serving Mac over the tailnet when the home network does not, before the relay, and with none every device reaches it as before; its menu's Import a file brings in a file (contacts, a chat export, a recording, a password export), and the runs past imports made are listed under the connections. A connection's page reads it now, pauses or resumes it, and disconnects it — what it already brought stays. A site read through the browser on the serving Mac signs in again there: its page's Sign in again opens the site on that Mac's screen. A Google account's Deleting here also deletes in Gmail is off unless switched on: off, mail put in the bin here stays in Gmail where it was, while reading, starring and archiving still reach Gmail; on, it goes to Gmail's bin too. A WhatsApp number's Statuses switch, off, passes its statuses over — none is kept and no picture is fetched — while its messages are read as ever; its Release status videos lets go the pictures and videos of its past statuses that nobody kept, leaving each status and its caption. A Mac's iPhone backup row, once Cotton has read the backup to its end, offers Delete the backup: that Mac deletes the backup it read (the owner's whole phone, unencrypted) and its todo is done; Cotton keeps its own copy of every message and file. The serving Mac does the reading; who reads Cotton is the Assistants tool.",  "create": { "label": "Connect…", "path": "/connections/new" },  "menu": [{ "label": "Import a file", "path": "/imports/new" }],  "lists": [{ "heading": "Past imports", "list": { "table": "import", "empty": "Nothing imported yet." } }],  "add": false,  "delete": false,  "commands": [    {      "id": "read_now",      "label": "Read now",      "object": "retry",      "kind": "update",      "method": "connections.readNowByKind",      "bindings": {        "id": "$id"      },      "when": {        "state": {          "not": "Paused"        }      },      "receipt": "Asked {name} to read now"    },    {      "id": "pause","object":"muted",      "label": "Pause",      "kind": "update",      "method": "connections.pause",      "bindings": {        "id": "$id"      },      "when": {        "state": {          "not": "Paused"        }      },      "receipt": "Paused {name}",      "undo": "resume",      "does": "puts-away"    },    {      "id": "resume",      "label": "Resume",      "object": "retry",      "kind": "update",      "method": "connections.resume",      "bindings": {        "id": "$id"      },      "when": {        "state": "Paused"      },      "receipt": "Resumed {name}",      "undo": "pause"    },    {      "id": "sign_in_browser",      "label": "Sign in on your Mac",      "object": "open",      "kind": "update",      "method": "connections.signInBrowser",      "bindings": {        "id": "$id"      },      "when": {        "kind": "Browser",        "state": {          "not": [            "Reading",            "Paused"          ]        }      },      "receipt": "Waiting for sign-in on your Mac"    },    {      "id": "release_statuses","object":"junk",      "label": "Release videos",      "kind": "update",      "method": "connections.releaseStatuses",      "bindings": {        "id": "$id"      },      "when": {        "kind": "WhatsApp"      },      "destructive": true,      "confirm": "The pictures and videos of this number’s past statuses leave this database, except the ones you kept. Each status stays, with its caption.",      "receipt": "Released status videos",      "does": "destroys"    },    {      "id": "delete_backup","object":"bin",      "label": "Delete backup",      "kind": "update",      "method": "connections.deleteBackup",      "bindings": {        "id": "$id"      },      "when": {        "kind": "This Mac"      },      "destructive": true,      "confirm": "The iPhone backup this Mac finished reading is deleted from its disk — it is your whole phone, unencrypted. Cotton keeps its own copy of every message and file it read from it.",      "receipt": "Asked the Mac to delete the backup",      "does": "destroys"    },    {      "id": "disconnect",      "label": "Disconnect",      "object": "link",      "kind": "update",      "method": "connections.disconnectByKind",      "bindings": {        "id": "$id"      },      "destructive": true,      "confirm": "Cotton stops reading it, and a Google account’s sign-in or a code host’s token is put away with it. What it already brought stays.",      "receipt": "Disconnected {name}",      "does": "destroys"    }  ],  "parts": {    "shape": "sheet",    "head": {      "facts": [        "kind",        "reaches",        "token",        "last_read_at",        "site",        "account",        "browser_facts"      ],      "state": "state"    },    "links": [],    "body": "last_error",    "lists": [      {        "table": "repository",        "match": {          "column": "host",          "parent": "reaches"        },        "heading": "Repositories",        "main_act": "hold"      }    ],    "acts": {      "main": "sign_in_browser",      "more": [        "read_now",        "pause",        "resume",        "release_statuses",        "delete_backup"      ],      "away": "disconnect"    },    "cards": [      {"column": "kind"},      {"column": "reaches"},      {"column": "token"},      {"column": "last_read_at"},      {"column": "site"},      {"column": "account"}    ],    "strip": [      {"column": "browser_facts"},      {"column": "state"},      {"column": "last_error"},      {"column": "progress"},      {"column": "brought"},      {"column": "tools"},      {"column": "status"},      {"column": "detail"},      {"column": "gmail"},      {"column": "gmail_bin", "label": "Gmail bin too"},      {"column": "statuses"},      {"column": "registrar_token"},      {"column": "password"},      {"column": "client_id"},      {"column": "client_secret"},      {"column": "server"},      {"column": "hold"},      {"column": "held"}    ]  },  "tool": {    "name": "Connections",    "key": "connections",    "icon": "plug",    "card_stock": "grey",    "route": "/connections"  ,"purpose":"The sources Cotton reads from."},  "tables": []}