diff --git a/.memory/bot-chat-activity.md b/.memory/bot-chat-activity.md index 791e6b63cf..8f550a7bdc 100644 --- a/.memory/bot-chat-activity.md +++ b/.memory/bot-chat-activity.md @@ -104,5 +104,6 @@ If `main` has moved past 29, change every `30` D introduced to the next free rev ### Bots across Macs (2026-11-24) - PR 1 (#895, desktop only): paired Mac's Bot rows show the feed's avatar, Needs you over Thinking over stop status, never the description; `ChatSidebar` owns `usePeerHostSidebar` so feeds stay live on the Bots page; remote Bot chat only treats 404/403 as gone. - PR 2 (Remote revision 66, provisional; re-claim at merge): host-feed Bot rows (`HostFeedBot` in openapi.json, `parseAidenRemoteHostFeedBot`) carry an optional one-line `preview` (140 characters, no control or format characters) and always come from `BotLiveProjection.summary` (`inboxSignals` was removed). New peer binary operation `botAvatar` (`GET /bots/{botId}/avatar/{assetRevision}`) fetches photo avatars for the row and chat title. Unread dots for remote Bots are a per-device record in local storage (`renderer/lib/remote-bot-seen.ts`, key `aiden-agent.remote-bots-seen.v1`, record version 2). Every time in it is the host's, never this Mac's clock: a per-host baseline (the newest `lastReplyAt` when this Mac first lists that host's Bots, so existing replies start read) and per-Bot seen times. A reply counts as seen only once the remote chat's session view shows it (`remoteBotShownReplyAt`), not when its row is selected. The host baseline is taken only from a listing whose every row is `summarized: true` (proof of revision 66, and no Bot whose summary read failed is left out; `summarized` marks every row whose summary the host read, so a host whose Bots are all still empty gets baseline 0 and their first reply shows a dot), since an older host sends `lastReplyAt` only for open feeds. Host feed Bot signals are cached per Bot (`createHostFeedBotSignalsCache` in `aiden-remote-host-feed.ts`) and invalidated by that Bot's `bots:changed` / `bots:attention`; `onBroadcast` forwards only the `botId` of a `bots:*` payload. -- Still to come: PR 3 (plan, access-request and memory cards in remote Bot chats, load older), PR 4 (phones show Needs you), PR 5 (headless server sends the same Bot signals). +- PR 3 (desktop only, no revision): the desktop asks for `bot:cards`, `bot:access-requests` and `bot:plans` (each `own_call`, only when the host lists them) and answers them through new peer ops `botRespondRoutineProposal`, `botAnswerAccessRequest`, `botRespondPlan`. `remote-bot-session.ts` maps plan/access frames onto `snapshot.plan`/`accessRequest` (plan items get place ids; `revision` is a hash of what the card shows, so re-reading the same plan keeps the card mounted) and memory/routine entries onto local rows. `RemoteBotChatView` puts access and pending plan cards in the Needs-you slot, an active plan in the body, echoes sends at once (shared `BotPendingSend` helpers from bot-chat-pane) and shows a re-pair hint group for old pairings (`remoteBotGroups`). Host: `AidenRemoteBotService.list()` leaves out (and logs by id) a Bot whose summary fails the contract instead of failing the whole list (and the host feed); a transient summary read error fails the list so clients keep their last rows. +- Still to come: PR 3b (load older, remove a queued message, every waiting approval; next revision), PR 4 (phones show Needs you), PR 5 (headless server sends the same Bot signals). Not planned yet: a model picker for a remote Bot with a model problem (no remote route sets a Bot's model). diff --git a/docs/aiden-on-the-go-remote-access.md b/docs/aiden-on-the-go-remote-access.md index a1dfd092a4..f2700cd70b 100644 --- a/docs/aiden-on-the-go-remote-access.md +++ b/docs/aiden-on-the-go-remote-access.md @@ -69,7 +69,7 @@ Pairing a computer gives it full control of this computer's chats: it can read t - **Visuals.** A visual the other computer pictured shows as that picture. A native visual it did not picture (any `render_ui` visual from `aiden serve`) shows as its text, line by line, where its tool call ran, with **Copy as text** and nothing inside to tap or change. An HTML visual (`render_artifact`) the other computer did not picture, for example because `aiden serve` found no Chrome, shows nothing here; the reply's text still says what it held. - **Not here.** Read-aloud is not offered for a remote chat. - **New chats.** On a new chat, choose the computer in the composer's machine picker, then one of its workspaces and models. Attachments upload to that computer. Pictures in a format the other computer does not take (WebP, GIF, BMP) are converted first, to PNG (or JPEG when that is what fits), and shrunk step by step until each is within 8 MB and the message's attachments together are within 16 MB. An animated GIF sends its first frame. HEIC photos can't be sent to another computer yet: the composer asks you to export one as a JPEG first. A picture this Mac cannot open is not sent either, and the composer says to save it as a PNG or JPEG. When the other computer runs contract revision 50 or newer, pictures go as their own bytes instead of base64 text, about a quarter less to send. -- **Bots.** Paired computers' Bots appear in the Bots area below this Mac's own, under "On ", with the avatar they have there: its shape and colour, or its photo. A row stays current on any page, including the Bots pages. Like this Mac's own rows, it shows **Needs you** and "Waiting for you" while the Bot waits on an approval, question, hand-off or issue there, "Thinking…" while a turn runs (only while that computer is online), otherwise why it stopped (Paused, Interrupted, Needs an AI model), and otherwise its last message. A reply that arrives after this Mac first lists the Bot, and that its chat here hasn't shown yet, shows an unread dot. The last message and the dot need that computer on contract revision 66; with an older one the line stays empty. A Bot's description is never shown as its line; search still matches it. Opening one row leaves the others clickable. The open chat's title shows the Bot's avatar or photo. A chat that loses its connection reconnects on its own; it says the Bot is gone only when that computer answers that the Bot was deleted or this Mac may no longer read it, and a message sent while it reconnects shows as soon as that computer has it. Opening one shows the same single conversation its own computer, phones and Telegram show: the Bot runs there, and this Mac sends messages, Stop, Resume, Dismiss, question answers and tool approvals to it. A tool that only its own computer may allow (Computer Use) can only be denied from here. Connect cards ask the Bot's computer to finish the connection there. When the app is already connected on that computer but the Bot's Custom access leaves it out, the card still reads **Finish on **, and that opens the Bot's chat there, where its card's **Connect** adds the app to that Bot. Phones work the same way with **Finish on your Mac**. If that computer runs an older Aiden, update it; an older Mac sending to a newer computer's Bot is told to update. When the Bot's computer offers hand-offs (contract revision 37), a step the Bot hands back ("Your turn: …") can be answered from here too, in two steps: **Take control** first (it opens the page the step names, if any), then **I'm done** (with a note typed in the composer if you like), **Skip**, or **Open again** for that page. A step on the Bot's own screen over there puts **Finish on ** first, which brings it forward on that computer, then offers **Skip** and **I'm done**. A sign-in in the Bot's own browser there also starts with **Finish on **; it is answered on that computer, so here it then offers **Skip** alone. Images the Bot shares appear in its chat as pictures, read from the Bot's computer while its chat is connected (contract revision 45). The chat's **···** menu offers **Pause Bot** and **Resume Bot**, and a paused Bot shows a Resume card and holds the composer until it is resumed. Custom Bots can also ask for a folder or temporary whole-Mac file access. Current iOS and Android clients can answer those cards. A Mac viewing a paired computer’s Bot sees a notice to answer on that computer; it does not grant access itself. See [Bot access requests](bot-access-requests.md). The Assistant stays on its own computer. +- **Bots.** Paired computers' Bots appear in the Bots area below this Mac's own, under "On ", with the avatar they have there: its shape and colour, or its photo. A row stays current on any page, including the Bots pages. Like this Mac's own rows, it shows **Needs you** and "Waiting for you" while the Bot waits on an approval, question, hand-off or issue there, "Thinking…" while a turn runs (only while that computer is online), otherwise why it stopped (Paused, Interrupted, Needs an AI model), and otherwise its last message. A reply that arrives after this Mac first lists the Bot, and that its chat here hasn't shown yet, shows an unread dot. The last message and the dot need that computer on contract revision 66; with an older one the line stays empty. A Bot's description is never shown as its line; search still matches it. Opening one row leaves the others clickable. A computer paired before Bots could be shared (it never gave this Mac Bot access) shows "To use 's Bots here, pair this Mac with it again." under its name instead of an empty list. A Bot that computer cannot describe (an edit time before its creation time after a clock change, a name longer than today's limit) is left out of its list rather than emptying the list for every device. The open chat's title shows the Bot's avatar or photo. A chat that loses its connection reconnects on its own; it says the Bot is gone only when that computer answers that the Bot was deleted or this Mac may no longer read it, and a message you send shows in the chat at once, before that computer has it (it goes away again if that computer refuses it, and the draft stays in the composer). Opening one shows the same single conversation its own computer, phones and Telegram show: the Bot runs there, and this Mac sends messages, Stop, Resume, Dismiss, question answers and tool approvals to it. A tool that only its own computer may allow (Computer Use) can only be denied from here. Connect cards ask the Bot's computer to finish the connection there. When the app is already connected on that computer but the Bot's Custom access leaves it out, the card still reads **Finish on **, and that opens the Bot's chat there, where its card's **Connect** adds the app to that Bot. Phones work the same way with **Finish on your Mac**. If that computer runs an older Aiden, update it; an older Mac sending to a newer computer's Bot is told to update. When the Bot's computer offers hand-offs (contract revision 37), a step the Bot hands back ("Your turn: …") can be answered from here too, in two steps: **Take control** first (it opens the page the step names, if any), then **I'm done** (with a note typed in the composer if you like), **Skip**, or **Open again** for that page. A step on the Bot's own screen over there puts **Finish on ** first, which brings it forward on that computer, then offers **Skip** and **I'm done**. A sign-in in the Bot's own browser there also starts with **Finish on **; it is answered on that computer, so here it then offers **Skip** alone. Images the Bot shares appear in its chat as pictures, read from the Bot's computer while its chat is connected (contract revision 45). The chat's **···** menu offers **Pause Bot** and **Resume Bot**, and a paused Bot shows a Resume card and holds the composer until it is resumed. Custom Bots can also ask for a folder or temporary whole-Mac file access, and propose a plan before a long task. Current iOS and Android clients answer those cards, and so does a Mac: the same access card (**Allow once**, **Always for this folder**, **Not now**) and plan card (**Allow once**, **Not now**, then **Stop plan** while it runs) appear in the paired computer's Bot chat under **Needs you**, and the answer goes to that computer, which grants the access there. A computer too old to send them shows a notice to answer there instead. A routine the Bot suggests can be added or turned down from here, and the routine is made on the Bot's computer; a "Memory updated" line says to open the memory there. See [Bot access requests](bot-access-requests.md). The Assistant stays on its own computer. - **Not available remotely.** Terminal, the Environment browser, computer use and open-in-editor work only on the computer you are sitting at. ### Offline and identity changes diff --git a/docs/aiden-remote-api-v1.md b/docs/aiden-remote-api-v1.md index d41e0174be..14f7e49cb3 100644 --- a/docs/aiden-remote-api-v1.md +++ b/docs/aiden-remote-api-v1.md @@ -53,8 +53,8 @@ Initial capability IDs: | `bot:settings-changes` | Opt-in, provisional revision 61. Delivers `settings_change` Bot session entries (held `update_bot` cards and applied-change receipts) and opens their answer route with `bot:read` and `bot:write`. Desktop hosts only. | | `bot:suggestions` | Opt-in, provisional revision 61. Delivers `skill_proposal`, `lesson` and `memory_tidy` Bot session entries and opens their answer and Undo routes with `bot:read` and `bot:write`. Desktop hosts only. | | `bot:templates` | Opt-in, provisional revision 61. Adds each template's `version`, `instructions`, `sample` and `existingBotId` to `GET /bot-presets`, the version check on `POST /bots/from-preset`, and one-field `POST /bots`. Desktop hosts only. | -| `bot:plans` | Opt-in, contract revision 56. Delivers the public plan snapshot and frame, and opens the plan response route with `bot:read` and `bot:write`. Offered only by a wired desktop host. Phones negotiate it separately when advertised in `serverCapabilities`; no pairing grant, global feature token, CLI hosting or paired-Mac plan card. | -| `bot:access-requests` | Opt-in, contract revision 55. Delivers public access cards and opens their answer route with `bot:read` and `bot:write`. Alongside `bot:issues`, delivers access issues, counts and alerts. Offered only by a wired desktop host; no feature token or CLI hosting. Phones negotiate in a separate capability update; paired desktops use legacy notice lines. | +| `bot:plans` | Opt-in, contract revision 56. Delivers the public plan snapshot and frame, and opens the plan response route with `bot:read` and `bot:write`. Offered only by a wired desktop host. Phones and paired desktops negotiate it separately when advertised in `serverCapabilities`; no pairing grant, global feature token or CLI hosting. | +| `bot:access-requests` | Opt-in, contract revision 55. Delivers public access cards and opens their answer route with `bot:read` and `bot:write`. Alongside `bot:issues`, delivers access issues, counts and alerts. Offered only by a wired desktop host; no feature token or CLI hosting. Phones and paired desktops negotiate it in a separate capability update; a device without it gets the notice line. | | `bot:messaging` | Opt-in, no authority by itself, contract revision 54. Delivers per-Bot `botMessaging`, list `messaging`, and `kind: "message"` notification items. Opens `PUT /bots/messaging`, which also needs `bot:write`. Negotiable through `POST /device/capabilities` only when listed in `serverCapabilities`; no feature token and never issued by pairing. | | `bot:handoffs` | Opt-in, no authority of its own (contract revision 37). Delivers the Bot session `handoff` field and frame, the `paused` session state, Bot `paused` flags and the `bot_paused` error code, and opens the hand-off answer, open-on-Mac and pause routes, which still need `bot:read` and `bot:write`. Negotiable post-pairing by any device type through `POST /device/capabilities` while the host lists it in `serverCapabilities` (`404 not_found` on a host without the routes), never issued by pairing. There is no `/server` feature token for it. See "Bot hand-offs and pause, revision 37". | | `bot:handoff-notes` | Opt-in, no authority of its own (contract revision 40). Delivers `takesNote: false` on a hand-off card that takes no note, to a device that also holds `bot:handoffs`. Offered and negotiable exactly when `bot:handoffs` is, never issued by pairing. A host before revision 40 refuses the name, so devices ask for it only when the host lists it. | @@ -325,7 +325,7 @@ Mobile-triggered setup may download only the fixed, hash-pinned URL compiled int These routes were frozen as contract in Phase 1 and implemented in Phase 4 through main-owned application and authority services: authenticated Bot identity, access, chat creation, favorite order, notice acknowledgement, bounded inbox projection, managed-home files, and canonical avatars. Each Bot operation carries `x-aiden-capabilities`; every listed capability is required conjunctively. `x-aiden-capability` remains the primary legacy annotation, not an alternative grant. A Bot mutation therefore always requires both `bot:read` and `bot:write`, plus the ordinary `chat:*` or `files:*` grant when it reuses those resource classes. -- `GET /bots`: at most 256 bounded summaries, matching the authoritative Bot-store ceiling, plus the fixed maximum and authoritative revisioned favorite order. `includeArchived=true` is explicit. Summaries never contain instructions, every summary has `updatedAt >= createdAt`, and favorite IDs never refer to archived Bots even when archived summaries are included. +- `GET /bots`: at most 256 bounded summaries, matching the authoritative Bot-store ceiling, plus the fixed maximum and authoritative revisioned favorite order. `includeArchived=true` is explicit. Summaries never contain instructions, every summary has `updatedAt >= createdAt`, and favorite IDs never refer to archived Bots even when archived summaries are included. A Bot whose stored fields don't fit the contract (a clock that went back between creating and editing it, a name from an older limit) is left out of the list and the host logs it by id; a Bot whose summary can't be read right now (its session state, say) fails the whole request instead, because clients keep the Bots they last listed after a failed read but drop any Bot a successful list leaves out. - `POST /bots`: exact `BotCreateRequest` (`purpose` and `instructions` optional from revision 61 for a `bot:templates` holder; see one-field create), including one required Full/Custom `access` update tied to the current catalog revision, device-scoped `Idempotency-Key`, and authoritative `BotDetail` response. Identity and initial access are created atomically. Any provider/model pair selected by the request or resolved by the Mac for creation must be currently available; unavailable selections fail closed without fallback. - `GET /bots/{botId}`: authenticated detail with editable guidance, a safe access view, the Bot's optional current audience-safe provider/model selection, and its optional `visionModelSelection`. The latter is a separately bound image-inspection companion; private runtime identities never cross this boundary. - `PATCH /bots/{botId}`: exact non-empty `BotIdentityPatch` plus `If-Match`. @@ -333,7 +333,7 @@ These routes were frozen as contract in Phase 1 and implemented in Phase 4 throu - `POST /bots/{botId}/restore`: `If-Match` plus `Idempotency-Key`, returning the restored authoritative detail. - `GET /bot-favorites` and `PATCH /bot-favorites`: at most 20 unique, non-archived Bot IDs; update is whole-list replacement under `If-Match`, so membership and order change atomically. A replacement may omit archived Bots and may still edit unrelated active favorites, but adding an archived Bot returns `bot_archived`. No successful favorites response retains an archived Bot ID. - `GET /bot-conversations?cursor=…&query=…&botId=…&limit=…`: newest-first stable pages of at most 50 items, with a 200-scalar search query and 128-scalar cursor. Search is confined to Bot name/purpose, conversation title, and the bounded previews actually projected by the Mac. Every item has `updatedAt >= createdAt`. `canRespondToApproval: true` is valid only while `activityState` is `waiting_for_approval`; a waiting row may still be non-respondable when the paired device lacks authority. -- `POST /bots/{botId}/chats`: open-or-create the Bot's one persistent chat. The frozen v1 response remains `201` and the operation identifier remains `createBotChat` for compatibility with shipped clients, even when the existing chat is returned. When it already exists, the Mac returns it unchanged and ignores creation-only provider/model input. When absent, an empty body inherits the Bot provider/model; otherwise one exact providerId/modelId pair is required, plus `Idempotency-Key`. Partial pairs never fall back. The creation pair must be currently available; an unavailable selection fails closed without fallback. The Mac injects the authoritative `botId` and hidden managed-home workspace; neither identifier is accepted in the body, and every successful response includes that authoritative `botId`. Concurrent calls and retries converge on the same chat. Legacy duplicate chats remain readable for recovery, but only the deterministic canonical chat is writable or projected in the Bot inbox. From 0.60.0, while a host serves `bot-durable-session-v1`, `POST /chats/{chatId}/turns` on a Bot's chat answers `400 invalid_request` ("Update Aiden on this device to chat with this Bot…") and appends nothing: the Bot's conversation is its durable session, and a workspace-chat turn would run outside it. Paired desktops open a host's Bot through `GET /bots/{botId}/session`, its `/session/events` stream and the session routes, as phones do, and negotiate `bot:activity` when the host announces `bot-activity-v1` (they do not take `bot:cards`). A desktop that misses that answer (the host was briefly unreachable) asks again on its next reconnect; a refusal is final. Desktops offer Queue and Steer only while they hold `bot:activity`, because without it the host sends them no `queued` list. A desktop reads a newer host's session as far as it understands it, as phones do: an unknown session state reads as `unavailable`, an entry it cannot parse is left out, and a stream event it cannot parse makes it read `GET /bots/{botId}/session` again instead of dropping the stream. After a clean `closed` event it reopens the stream at once (up to twice in a row, then with backoff). `BotSession` and `BotMessageReceipt` compose the state fields from `BotSessionStateFields` and close with `unevaluatedProperties: false`; `BotSessionState` alone stays closed for Resume, Dismiss and Stop. A host error's own `message`, when short and printable, is what a paired desktop shows for a refused request. +- `POST /bots/{botId}/chats`: open-or-create the Bot's one persistent chat. The frozen v1 response remains `201` and the operation identifier remains `createBotChat` for compatibility with shipped clients, even when the existing chat is returned. When it already exists, the Mac returns it unchanged and ignores creation-only provider/model input. When absent, an empty body inherits the Bot provider/model; otherwise one exact providerId/modelId pair is required, plus `Idempotency-Key`. Partial pairs never fall back. The creation pair must be currently available; an unavailable selection fails closed without fallback. The Mac injects the authoritative `botId` and hidden managed-home workspace; neither identifier is accepted in the body, and every successful response includes that authoritative `botId`. Concurrent calls and retries converge on the same chat. Legacy duplicate chats remain readable for recovery, but only the deterministic canonical chat is writable or projected in the Bot inbox. From 0.60.0, while a host serves `bot-durable-session-v1`, `POST /chats/{chatId}/turns` on a Bot's chat answers `400 invalid_request` ("Update Aiden on this device to chat with this Bot…") and appends nothing: the Bot's conversation is its durable session, and a workspace-chat turn would run outside it. Paired desktops open a host's Bot through `GET /bots/{botId}/session`, its `/session/events` stream and the session routes, as phones do, and negotiate `bot:activity` when the host announces `bot-activity-v1`. Since the Bots-across-Macs work of 2026-11 they also ask for `bot:cards`, `bot:access-requests` and `bot:plans`, each in a call of its own and only when the host lists it in `serverCapabilities`, and answer those cards through `/routine-proposals/{proposalId}/respond`, `/access-requests/{waitId}/answer` and `/plans/{planId}/respond`. They do not take `bot:issues`, `bot:allowed` or the revision-61 Bot UX opt-ins. A desktop that misses that answer (the host was briefly unreachable) asks again on its next reconnect; a refusal is final. Desktops offer Queue and Steer only while they hold `bot:activity`, because without it the host sends them no `queued` list. A desktop reads a newer host's session as far as it understands it, as phones do: an unknown session state reads as `unavailable`, an entry it cannot parse is left out, and a stream event it cannot parse makes it read `GET /bots/{botId}/session` again instead of dropping the stream. After a clean `closed` event it reopens the stream at once (up to twice in a row, then with backoff). `BotSession` and `BotMessageReceipt` compose the state fields from `BotSessionStateFields` and close with `unevaluatedProperties: false`; `BotSessionState` alone stays closed for Resume, Dismiss and Stop. A host error's own `message`, when short and printable, is what a paired desktop shows for a refused request. - `GET /bot-capabilities?botId=…`: safe revisioned provider/model, image-input capability, file-scope, shell, connection/MCP, skill, and other-capability catalog plus the full notice status. The optional, exact `botId` selects an authenticated existing Bot so its saved unavailable choices can remain visible; omitting it returns the generic creation catalog. Unknown, duplicate, malformed, empty, and overlong query values fail closed. `supportsImages` is explicit and unknown capability fails closed. The response never returns display copy that the client could mistake for authority. - The catalog’s additive `skillsEnabled` boolean defaults to `true` when omitted. When `false`, skill inventory discovery and incarnation reconciliation pause; target-Bot catalogs may retain that Bot’s authenticated saved skill IDs as unavailable choices. Clients may preserve or remove those saved choices during unrelated edits, but must not offer unavailable unselected skills as new choices. The Mac enforces exact saved ownership and per-chat narrowing, withholds skills from all runtime contexts, and restores unchanged selections when the global gate reopens. Invalid provided values fail decoding. - `PATCH /bots/{botId}/capabilities`: `If-Match` Full/Custom update with the exact current `catalogRevision`. Full requires `confirmedForeground: true` and may carry one exact provider/model pair; omitting both preserves the saved choice for compatibility with older clients, while supplying only one is invalid. Custom contains exactly one currently available provider/model pair plus only exact positive opaque selections from that catalog. Optional `visionModel` uses three-state semantics: omitted preserves the companion, `null` clears it, and an exact provider/model object sets it only when the catalog marks that model image-capable. A supplied pair becomes revisioned durable authority, changing either primary or companion fences active turns, and the canonical persistent chat mirrors only the primary model. An unavailable model remains visibly blocked and is never replaced by fallback. Moving a Full Bot to Custom from a device never widens it: when Full had Web search off, the Mac drops the Web search grant from the new selection whatever the device sent, since the catalog carries no capability kind for a device to tell it apart. @@ -1276,7 +1276,7 @@ The canonical fixture adds `botMessagingDetail`, `botMessagingPatch`, `botMessag ## Bot access requests, revision 55 (`bot:access-requests`) -The desktop host offers `bot:access-requests` in `serverCapabilities` only while the public request bridge and answer service are wired. Phones negotiate `{ "accepts": ["bot:access-requests"] }` in its own `POST /device/capabilities`, only when announced. Ignore 400 and 404 for that call; authentication failures retain the normal pairing behavior. Confirm the grant on the refreshed `/server`. This revision adds no feature token. The serve-only CLI does not host `request_access` or advertise this capability. Paired desktops remain a legacy audience. +The desktop host offers `bot:access-requests` in `serverCapabilities` only while the public request bridge and answer service are wired. Phones negotiate `{ "accepts": ["bot:access-requests"] }` in its own `POST /device/capabilities`, only when announced. Ignore 400 and 404 for that call; authentication failures retain the normal pairing behavior. Confirm the grant on the refreshed `/server`. This revision adds no feature token. The serve-only CLI does not host `request_access` or advertise this capability. Paired desktops negotiate it the same way, in a call of its own, from the Bots-across-Macs work of 2026-11; an older desktop still gets the notice line. Holders receive optional nullable session `accessRequest` and SSE `access_request` with `{ "accessRequest": card | null }`. A revision-55 public card has only `{ waitId, target, label, place?, why, choices }`. Revision 57 adds optional `approvalCount` only for devices holding both `bot:access-requests` and `bot:allowed`, on a folder offering Always; it is an integer from 3 through 20. Other devices keep the exact old shape. `waitId` matches `^[A-Za-z0-9-]{1,64}$`; target is `folder` or `whole_mac`. Label is nonblank and at most 120 characters, why is nonblank and at most 400, and optional place is folder-only, at most 512 characters, starting with `~/` or `/`. Text contains no control characters. Place is display text, never authority or an API identifier. Whole Mac has label `your whole Mac` and no place. Choices are exactly `["not_now", "once"]` or, for a persistable folder, `["not_now", "always", "once"]`, in that order. Whole Mac never offers Always. Authorization, canonical root identity, run ids, tool call ids and logical request ids never cross. diff --git a/docs/bot-access-requests.md b/docs/bot-access-requests.md index cf00d70681..ee06b34d4c 100644 --- a/docs/bot-access-requests.md +++ b/docs/bot-access-requests.md @@ -40,7 +40,7 @@ A persistable folder issue can offer **Allow this folder**. That saves access fo ## Phones and other hosts -Supported iOS and Android clients can answer access cards and folder issues on the paired desktop. The host remains responsible for validating the original card and granting access. An older phone or paired desktop gets a line telling you to answer on the Mac. Access issues and their alerts are shown only to clients that support them; hidden access issues do not increase older clients’ issue counts. +Supported iOS and Android clients can answer access cards and folder issues on the paired desktop, and a paired Mac can answer access cards in the host Bot's chat. The host remains responsible for validating the original card and granting access. An older phone or paired desktop gets a line telling you to answer on the Mac. Access issues and their alerts are shown only to clients that support them; hidden access issues do not increase older clients’ issue counts. A folder approved for a Bot does not appear in the phone's file browser or its list of shared folders. Other Custom Bots may list it as an available choice in their access settings, but they receive no grant until you select it for them. Approving the same folder explicitly for phone browsing makes it a normal shared folder. You can also approve a containing folder for phones; the Bot keeps its original narrower selection. diff --git a/docs/bot-routines.md b/docs/bot-routines.md index b249dbd576..42b6d8311c 100644 --- a/docs/bot-routines.md +++ b/docs/bot-routines.md @@ -59,7 +59,7 @@ The standalone CLI records failure kinds but does not yet retry, pause routines, ## Proactive without being pushy - **Quiet hours and a daily limit.** Each Bot's **Advanced → Notifications** has **When it finishes or needs input** (off sets the daily cap to 0; on puts back the earlier cap, default 5) and a **Quiet hours** row: quiet hours (default 10:00 PM to 7:00 AM, in the Mac's time zone) and a cap on proactive notifications a day (0 to 20). During quiet hours, routine results, suggestions and "Needs you" cards wait, and what waited normally arrives as one digest per Bot when quiet hours end. When delayed-delivery history is full, one result may arrive separately before the remaining digest. If Aiden missed the morning release and opens during another quiet period, it waits for that period to end before notifying the Mac, Telegram or a phone. Simultaneous results share the same daily budget. Past the cap, results stay in the chat and one note says more are there. "Needs you" cards skip the cap, and so does a card's one 4-hour reminder. Replies to the person's own messages are never held. -- **Learning from Not now.** A suggested routine shows **Not now** and **Add** and settles to one line ("Added Morning brief · Every day at 8:00 AM" or "Not added: Morning brief"). After Not now on that device, the line offers an optional **Why not?** link with four reasons (Not useful, Wrong time, Already have this, Something else); the reason is recorded once. The Bot's `routines list` reports recent answers. After three declines in the last five suggestions it stops suggesting for a week, and a routine with the same name declined in the last 30 days is refused unless you asked for it again. Asking does not end the week off; you can still add a routine yourself. A follow-up on a promise always gets its card, and one that expires unanswered never counts as a decline. +- **Learning from Not now.** A suggested routine shows **Not now** and **Add** and settles to one line ("Added Morning brief · Every day at 8:00 AM" or "Not added: Morning brief"). After Not now on that device, the line offers an optional **Why not?** link with four reasons (Not useful, Wrong time, Already have this, Something else); the reason is recorded once. A Mac answering a paired computer's Bot offers no **Why not?**, because that computer's route records only the answer. The Bot's `routines list` reports recent answers. After three declines in the last five suggestions it stops suggesting for a week, and a routine with the same name declined in the last 30 days is refused unless you asked for it again. Asking does not end the week off; you can still add a routine yourself. A follow-up on a promise always gets its card, and one that expires unanswered never counts as a decline. - **One suggestion at a time.** A Bot's own routine, skill and lesson suggestions share one budget: at most three shown in any 24 hours per Bot. Past it the Bot is told to stop suggesting for today; you can still add one yourself. A routine you asked for and a follow-up on a promise never count. Only one suggestion shows in full in a chat; an earlier one still waiting folds to "Waiting: … · Show". - **Follow-ups on promises.** When the Bot promised to follow up on a date (between tomorrow and 60 days ahead), the memory review notes it and the Bot suggests a one-time routine for that day (9:00 AM unless a time was promised). At most two suggestions wait at a time; the next follows when one is answered. The Bot can revise a card you haven't answered: the old card reads "… · replaced by a newer suggestion" and doesn't count as a decline. A revised follow-up expires on the revised card's day, and one revised into a repeating schedule or a trigger stays until you answer it. A scheduled card shows the time zone it runs in. A promise past its date expires. - **When something happens.** The Routines tab's When something happens group adds routines that run when files change in a folder inside the Bot's folder (changes are collected for 30 seconds, up to 50 paths), or when the routine's own link is called on this Mac's network or Tailscale while Aiden On The Go is on. The link is shown once. Files the routine's run writes with its file tools don't fire it again while they are still exactly as the Bot left them, so a Bot writing into its watched folder doesn't wake itself; a file someone else drops in, edits or deletes during the run (including one the Bot just wrote) is held and fires the routine once the run ends (after 5 seconds, so late folder notices are sorted too). Files written by a shell command are not told apart and can fire the routine again. A folder that is missing, outside the Bot's folder, or can't be watched raises a card for that routine only; the other routines keep watching. Quitting stops a running event routine and waits up to 3 seconds for it to be recorded as uncertain; its event runs again on the next start. Each routine runs at most once every 5 minutes and 24 times a day; an event that arrives early waits and the newest one wins. What happened reaches the Bot as data, never as instructions. The Bot can also suggest one of these with the same suggestion card (Not now / Add); when you add a link routine on this Mac, the card shows Copy link once (a link routine added from a phone shows **New link** on the Mac's card). The Bot never sees the link. File and link routines are managed on the desktop; phones show and answer their suggestion cards. Connected-app watches use the separate all-device management described below. diff --git a/docs/bot-rules.md b/docs/bot-rules.md index bc3a0f6f54..05c4b3c1bb 100644 --- a/docs/bot-rules.md +++ b/docs/bot-rules.md @@ -103,9 +103,10 @@ held independently. Direct calls and each nested call in a codemode script use the same coverage, limits and final checks. A script cannot use one covered call to authorize the -rest of its calls. The CLI host does not offer plan tools or coverage, and a -desktop viewing another desktop's Bot does not show plan cards. Such a viewer -can still show Waiting for you; answer on the host desktop or a supported phone. +rest of its calls. The CLI host does not offer plan tools or coverage. A +desktop viewing another desktop's Bot shows its plan card and sends the answer +to the host desktop, as a supported phone does; one paired with an older host +shows Waiting for you, and the plan is answered on the host desktop. ## Routines and the approval mode (Settings → Approvals) diff --git a/main/services/aiden-remote-bots.test.ts b/main/services/aiden-remote-bots.test.ts index ea92064a69..2421055cae 100644 --- a/main/services/aiden-remote-bots.test.ts +++ b/main/services/aiden-remote-bots.test.ts @@ -101,6 +101,7 @@ function fixture( messaging?: AidenRemoteBotServiceOptions["messaging"]; sessionStates?: AidenRemoteBotServiceOptions["sessionStates"]; issues?: AidenRemoteBotServiceOptions["issues"]; + log?: AidenRemoteBotServiceOptions["log"]; capabilityCatalog?: ( audienceId: string, botId?: string, @@ -327,6 +328,45 @@ test("a Bot summary carries issueCount only while it holds open issues, and an u assert.equal((await app.service.summaryOf("bot_1")).issueCount, 2); }); +test("one Bot the Remote contract can't carry is left out of the list, and the others still reach every device", async () => { + // A clock that went back between creating and editing a Bot, and a name from before today's limit. + const logged: string[] = []; + const app = fixture([ + bot("bot_1"), + bot("bot_2", { createdAt: 5_000, updatedAt: 4_000 }), + bot("bot_3", { name: `Secret ${"N".repeat(200)}` }), + bot("bot_4"), + ], { log: (message) => logged.push(message) }); + const list = parseAidenRemoteBotList(await app.service.list()); + assert.deepEqual(list.bots.map(({ id }) => id), ["bot_1", "bot_4"]); + assert.equal(logged.length, 2, "each Bot left out is logged once"); + assert.ok(logged.some((line) => line.includes("bot_2")) && logged.some((line) => line.includes("bot_3"))); + assert.ok(logged.every((line) => !line.includes("Secret")), "the log names the Bot by id, never by its fields"); +}); + +test("a Bot whose summary can't be read right now fails the list rather than leaving that Bot out", async () => { + // A phone or paired Mac drops any Bot a successful list leaves out, but keeps + // the Bots it last listed when the list fails, so a passing read error must + // never look like a deleted Bot. + let failing = true; + const logged: string[] = []; + const app = fixture([bot("bot_1"), bot("bot_2"), bot("bot_3")], { + log: (message) => logged.push(message), + sessionStates: async (ids) => { + // The batch misses bot_2, whose own read then fails while the store is busy. + if (ids.length === 1 && ids[0] === "bot_2" && failing) { + throw Object.assign(new Error("resource busy"), { code: "EBUSY" }); + } + return new Map(ids.filter((id) => ids.length === 1 || id !== "bot_2").map((id) => [id, "idle"] as const)); + }, + }); + await assert.rejects(app.service.list(), /resource busy/u); + assert.deepEqual(logged, [], "a read failure is not a contract problem"); + failing = false; + const list = parseAidenRemoteBotList(await app.service.list()); + assert.deepEqual(list.bots.map(({ id }) => id), ["bot_1", "bot_2", "bot_3"]); +}); + test("Remote Bot inbox and avatar adapter stay device-scoped, mutation-gated, and idempotent", async () => { const avatarCalls: string[] = []; let asset: { diff --git a/main/services/aiden-remote-bots.ts b/main/services/aiden-remote-bots.ts index 5ea927e48b..4ba71e27b6 100644 --- a/main/services/aiden-remote-bots.ts +++ b/main/services/aiden-remote-bots.ts @@ -299,6 +299,11 @@ export interface AidenRemoteBotServiceOptions { persistIdempotency?: (snapshot: AidenIdempotencySnapshot) => Promise; notifyBotsChanged?: (botId?: string) => void; notifyChatsChanged?: (chatId?: string) => void; + /** + * A fixed diagnostic line and its error, for a Bot left out of the list + * because its stored fields don't fit the contract. Never chat content. + */ + log?: (message: string, error: unknown) => void; } export class AidenRemoteBotService { @@ -446,18 +451,27 @@ export class AidenRemoteBotService { } } - private async summary( + /** What a summary reads from the host; a failure here is the host's, not the Bot's. */ + private async summaryInputs( bot: BotDefinition, projectedHealth?: AidenRemoteBotHealth, projectedSession?: AidenRemoteBotSessionStateKind, - ): Promise { + ): Promise> { const health = projectedHealth ?? await this.options.health?.(bot.id) ?? "ready"; const sessionState = projectedSession ?? (await this.options.sessionStates?.([bot.id]))?.get(bot.id); const issueCount = this.options.issues ? await this.options.issues.openCount(bot.id).catch(() => 0) : undefined; - return projectAidenRemoteBotSummary(bot, await this.avatar(bot), health, sessionState, issueCount); + return [bot, await this.avatar(bot), health, sessionState, issueCount]; + } + + private async summary( + bot: BotDefinition, + projectedHealth?: AidenRemoteBotHealth, + projectedSession?: AidenRemoteBotSessionStateKind, + ): Promise { + return projectAidenRemoteBotSummary(...await this.summaryInputs(bot, projectedHealth, projectedSession)); } /** The public summary of one live Bot (presets, list rows). */ @@ -500,8 +514,21 @@ export class AidenRemoteBotService { this.options.healthBatch?.(ids), this.options.sessionStates?.(ids), ]); - const summaries = await mapBounded(bots, 8, (bot) => - this.summary(bot, health?.get(bot.id) ?? "ready", sessions?.get(bot.id))); + // One Bot the contract can't carry (a clock that went back, a name from an + // older limit) is left out, so it never empties every device's Bot list. + // A read that fails (its session state, say) fails the whole list instead: + // phones and paired Macs keep the Bots they last listed after a failed + // read, but drop any Bot a successful list leaves out. + const summaries = (await mapBounded(bots, 8, async (bot) => { + const inputs = await this.summaryInputs(bot, health?.get(bot.id) ?? "ready", sessions?.get(bot.id)); + try { + return projectAidenRemoteBotSummary(...inputs); + } catch (error) { + this.options.log?.(`Bot ${bot.id} is left out of the Bot list: its stored fields don't fit the contract.`, error); + return null; + } + })) + .filter((summary): summary is AidenRemoteBotSummary => summary !== null); return parseAidenRemoteBotList({ bots: summaries, maxBots: MAX_BOTS, ...(this.options.messaging ? {messaging: {enabled: await this.options.messaging.enabled()}} : {}) }); } diff --git a/main/services/aiden-remote-service-main.ts b/main/services/aiden-remote-service-main.ts index 808f7ed8ac..10fb6eaf77 100644 --- a/main/services/aiden-remote-service-main.ts +++ b/main/services/aiden-remote-service-main.ts @@ -906,6 +906,7 @@ async function createRuntime(): Promise { const bots = botsSupported ? new AidenRemoteBotService({ application: botApplicationService, chatStore, + log: (message, error) => logger.warn("aiden-remote", message, error), avatar: createMainBotAvatarApplicationAdapter(instanceId), inbox: { list: (deviceId, input) => diff --git a/main/services/peer-bot-session-compat.ts b/main/services/peer-bot-session-compat.ts index c84cc2a1fb..94b9ce210f 100644 --- a/main/services/peer-bot-session-compat.ts +++ b/main/services/peer-bot-session-compat.ts @@ -9,8 +9,10 @@ import { AIDEN_REMOTE_BOT_SESSION_BLOCKED_REASONS, AIDEN_REMOTE_BOT_SESSION_STATES, AIDEN_REMOTE_PROTOCOL_VERSION, + parseAidenRemoteBotAccessRequest, parseAidenRemoteBotApproval, parseAidenRemoteBotHandoff, + parseAidenRemoteBotPlan, parseAidenRemoteBotQuestion, parseAidenRemoteBotSessionActivity, parseAidenRemoteBotSessionEntry, @@ -34,6 +36,8 @@ const SESSION_KEYS = [ "activity", "queued", "handoff", + "accessRequest", + "plan", ] as const; function isRecord(value: unknown): value is Record { @@ -80,6 +84,13 @@ export function peerBotSessionCompat(value: unknown): unknown { if (has(session, "handoff") && session.handoff !== null && !parses(parseAidenRemoteBotHandoff, session.handoff)) { session.handoff = null; } + // A folder request or plan card this client cannot read is answered on the host. + for (const [key, parse] of [ + ["accessRequest", parseAidenRemoteBotAccessRequest], + ["plan", parseAidenRemoteBotPlan], + ] as const) { + if (has(session, key) && session[key] !== null && !parses(parse, session[key])) session[key] = null; + } if ( has(session, "activity") && session.activity !== null && diff --git a/main/services/peer-host-registry.test.ts b/main/services/peer-host-registry.test.ts index 56cbcac733..11f94254b2 100644 --- a/main/services/peer-host-registry.test.ts +++ b/main/services/peer-host-registry.test.ts @@ -550,7 +550,7 @@ test("a Mac opts into a host's Bot activity frames only when the host serves the { capabilities: ["chat:read", "bot:read", "bot:write"], features, - serverCapabilities: ["chat:read", "bot:read", "bot:write", "bot:cards", "bot:activity"], + serverCapabilities: ["chat:read", "bot:read", "bot:write", "bot:activity"], }, (input) => (input.path === "/device/capabilities" ? { capabilities: ["chat:read", "bot:read", "bot:write", "bot:activity"] } : { ok: true }), ); @@ -585,7 +585,7 @@ test("a Mac asks for a host's Bot hand-offs in a call of its own, after the rest grants: stored()[0]!.capabilities, }; }; - const lists = ["chat:read", "bot:read", "bot:write", "bot:cards", "bot:activity", "bot:handoffs"]; + const lists = ["chat:read", "bot:read", "bot:write", "bot:activity", "bot:handoffs"]; const both = await negotiate(lists); assert.deepEqual(both.bodies, [{ accepts: ["bot:activity"] }, { accepts: ["bot:handoffs"] }]); assert.ok(both.grants.includes("bot:activity") && both.grants.includes("bot:handoffs")); @@ -612,6 +612,18 @@ test("a Mac asks for a host's Bot hand-offs in a call of its own, after the rest assert.deepEqual(images.bodies, [{ accepts: ["bot:activity"] }, { accepts: ["bot:handoffs"] }, { accepts: ["bot:images"] }]); assert.ok(images.grants.includes("bot:images")); + // The cards a Bot waits on or offers: each asked for alone, so a host that refuses one still grants the others. + const cards = await negotiate([...lists, "bot:cards", "bot:access-requests", "bot:plans"], (accepts) => accepts.includes("bot:access-requests")); + assert.deepEqual(cards.bodies, [ + { accepts: ["bot:activity"] }, + { accepts: ["bot:handoffs"] }, + { accepts: ["bot:cards"] }, + { accepts: ["bot:access-requests"] }, + { accepts: ["bot:plans"] }, + ]); + assert.ok(cards.grants.includes("bot:cards") && cards.grants.includes("bot:plans")); + assert.equal(cards.grants.includes("bot:access-requests"), false); + // Revision 50: attachments:raw has no feature token at all; a host that lists it is asked alone, last. const raw = await negotiate([...lists, "attachments:raw"]); assert.deepEqual(raw.bodies, [{ accepts: ["bot:activity"] }, { accepts: ["bot:handoffs"] }, { accepts: ["attachments:raw"] }]); diff --git a/main/services/peer-host-registry.ts b/main/services/peer-host-registry.ts index d87d1e42c6..beb16755d3 100644 --- a/main/services/peer-host-registry.ts +++ b/main/services/peer-host-registry.ts @@ -142,6 +142,10 @@ export interface PeerClient { * 43) when a step is on the Bot's own screen there. `bot:images` (revision 45) * sends a Bot's shared images as entries whose bytes this Mac reads on demand, * instead of the line that tells the person to open the chat on the host. + * `bot:cards` (revision 27), `bot:access-requests` (revision 55) and + * `bot:plans` (revision 56) send the routine suggestions and memory lines, + * folder access cards and plans this Mac answers, instead of the host's + * "open it on that Mac" notice. */ const NEGOTIATED_GRANTS: ReadonlyArray = [ ["tasks:read", AIDEN_REMOTE_CHAT_TASKS_FEATURE], @@ -156,6 +160,10 @@ const NEGOTIATED_GRANTS: ReadonlyArray @@ -146,6 +155,12 @@ test("expanded peer mutations demand a client-minted key and reject malformed pa { operation: "botAnswerHandoff", resourceId: "bot_1", itemId: "wait-1", idempotencyKey: KEY }, { operation: "botHandoffOpenOnMac", resourceId: "bot_1", itemId: "wait-1", idempotencyKey: KEY, body: { url: "https://x" } }, { operation: "botPause", resourceId: "bot_1", idempotencyKey: KEY, body: { by: "mac" } }, + { operation: "botRespondPlan", resourceId: "bot_1", itemId: "plan/1", idempotencyKey: KEY, body: { decision: "approve" } }, + { operation: "botRespondPlan", resourceId: "bot_1", itemId: "plan-1", idempotencyKey: KEY, body: { decision: "always" } }, + { operation: "botAnswerAccessRequest", resourceId: "bot_1", itemId: "wait-1", idempotencyKey: KEY, body: { choice: "forever" } }, + { operation: "botAnswerAccessRequest", resourceId: "bot_1", itemId: "wait-1", idempotencyKey: KEY, body: { choice: "once", path: "/" } }, + { operation: "botRespondRoutineProposal", resourceId: "bot_1", itemId: "not-a-proposal", idempotencyKey: KEY, body: { decision: "accept" } }, + { operation: "botRespondRoutineProposal", resourceId: "bot_1", itemId: "4b1f8a52-7f0e-4b8e-9d55-3f2c1a6b7e10", idempotencyKey: KEY, body: { decision: "accept", reason: "other" } }, { operation: "runCancel", resourceId: "../../server", idempotencyKey: KEY }, { operation: "bots", url: "https://elsewhere" }, { operation: "removeAttachment", resourceId: "chat_1", itemId: "att_short" }, @@ -437,6 +452,20 @@ test("the host's real Bot session, send receipt and controls pass this Mac's con }; assert.deepEqual([paused.state, paused.handoff], [handoffs.pausedSession.state, handoffs.pausedSession.handoff]); assert.equal(paused.state, "paused"); + // A folder request and a plan reach the paired Mac on a plain read too, not only on the stream. + const asking = (await peerOperationResult({ operation: "botSession", resourceId: "bot_1" }, contract.botAccessRequests.session)) as { + accessRequest?: unknown; + }; + assert.deepEqual(asking.accessRequest, contract.botAccessRequests.session.accessRequest); + const planning = (await peerOperationResult({ operation: "botSession", resourceId: "bot_1" }, contract.botPlans.session)) as { + plan?: unknown; + }; + assert.deepEqual(planning.plan, contract.botPlans.session.plan); + const unreadable = (await peerOperationResult({ operation: "botSession", resourceId: "bot_1" }, { + ...contract.botPlans.session, + plan: { ...contract.botPlans.session.plan, status: "reconsidering" }, + })) as { plan?: unknown }; + assert.equal(unreadable.plan, null, "a plan this Mac can't read is left for the host"); assert.deepEqual( await peerOperationResult({ operation: "botSend", resourceId: "bot_1" }, fixtures.botSessionSend!.response), fixtures.botSessionSend!.response, @@ -536,3 +565,23 @@ test("an unknown Inbox placement falls back without rejecting the paired host's assert.equal(result.summaries[0]?.inboxSortAt, undefined); await assert.rejects(async () => peerOperationResult({ operation: "summaries" }, { summaries: [{ ...row, unread: "yes" }] })); }); + +test("plan, access-card and routine-suggestion answers send what the host's routes take, and read their receipts", async () => { + const plan = contract.botPlans.respond; + const access = contract.botAccessRequests.answer; + const routine = contract.botRoutineProposalRespond; + assert.deepEqual( + peerOperationRequest({ operation: "botRespondPlan", resourceId: "bot_1", itemId: plan.response.planId, idempotencyKey: KEY, body: plan.request }).body, + plan.request, + ); + assert.deepEqual(await peerOperationResult({ operation: "botRespondPlan" }, plan.response), plan.response); + assert.deepEqual( + peerOperationRequest({ operation: "botAnswerAccessRequest", resourceId: "bot_1", itemId: "wait-1", idempotencyKey: KEY, body: access.request }).body, + access.request, + ); + assert.deepEqual(await peerOperationResult({ operation: "botAnswerAccessRequest" }, access.response), access.response); + assert.deepEqual(await peerOperationResult({ operation: "botRespondRoutineProposal" }, routine.response), routine.response); + // A receipt the contract doesn't allow never reaches the chat. + await assert.rejects(peerOperationResult({ operation: "botRespondPlan" }, { ...plan.response, status: "pending" })); + await assert.rejects(peerOperationResult({ operation: "botAnswerAccessRequest" }, { answered: false })); +}); diff --git a/main/services/peer-operation.ts b/main/services/peer-operation.ts index e8bc11aa00..4738a32761 100644 --- a/main/services/peer-operation.ts +++ b/main/services/peer-operation.ts @@ -16,12 +16,19 @@ import { AIDEN_REMOTE_CONTEXT_MODEL_ID, AIDEN_REMOTE_MAX_ENCODED_ATTACHMENT_NAME, encodeAidenRemoteAttachmentName, + parseAidenRemoteBotAccessAnswerReceipt, + parseAidenRemoteBotAccessAnswerRequest, parseAidenRemoteBotConnectionRequestReceipt, parseAidenRemoteBotHandoffAnswerReceipt, parseAidenRemoteBotHandoffAnswerRequest, parseAidenRemoteBotHandoffOpenOnMacReceipt, parseAidenRemoteBotMessageReceipt, + parseAidenRemoteBotPlanRespondReceipt, + parseAidenRemoteBotPlanRespondRequest, parseAidenRemoteBotQuestionAnswerReceipt, + parseAidenRemoteBotRoutineProposalId, + parseAidenRemoteBotRoutineProposalRespondRequest, + parseAidenRemoteBotRoutineProposalRespondResult, parseAidenRemoteBotSession, parseAidenRemoteBotSessionStateView, parseAidenRemoteChatContextPressure, @@ -91,6 +98,9 @@ export const PEER_BOT_SESSION_MUTATIONS: ReadonlySet = new Set([ "botAnswerHandoff", "botPause", "botUnpause", + "botRespondPlan", + "botAnswerAccessRequest", + "botRespondRoutineProposal", ]); /** A fork names one message to cut at and, optionally, a summary of what followed. */ @@ -184,6 +194,9 @@ export async function peerOperationResult( if (name === "botAnswerHandoff") return parseAidenRemoteBotHandoffAnswerReceipt(value); if (name === "botHandoffOpenOnMac") return parseAidenRemoteBotHandoffOpenOnMacReceipt(value); if (name === "botConnectionRequest") return parseAidenRemoteBotConnectionRequestReceipt(value); + if (name === "botRespondPlan") return parseAidenRemoteBotPlanRespondReceipt(value); + if (name === "botAnswerAccessRequest") return parseAidenRemoteBotAccessAnswerReceipt(value); + if (name === "botRespondRoutineProposal") return parseAidenRemoteBotRoutineProposalRespondResult(value); return value; } @@ -559,6 +572,25 @@ export function peerOperationRequest( method = "POST"; needsKey = true; break; + case "botRespondPlan": + path = `/bots/${id()}/plans/${pattern(input.itemId, BOT_WAIT_ID)}/respond`; + method = "POST"; + needsKey = true; + // Only `{ decision }` with a known decision reaches the host. + body = parseAidenRemoteBotPlanRespondRequest(input.body); + break; + case "botAnswerAccessRequest": + path = `/bots/${id()}/access-requests/${pattern(input.itemId, BOT_WAIT_ID)}/answer`; + method = "POST"; + needsKey = true; + body = parseAidenRemoteBotAccessAnswerRequest(input.body); + break; + case "botRespondRoutineProposal": + path = `/bots/${id()}/routine-proposals/${parseAidenRemoteBotRoutineProposalId(input.itemId)}/respond`; + method = "POST"; + needsKey = true; + body = parseAidenRemoteBotRoutineProposalRespondRequest(input.body); + break; case "uploadBotAttachment": // Not keyed, like a chat upload: an unused staged upload expires on the host. path = `/bots/${id()}/attachments`; diff --git a/main/services/peer-response.ts b/main/services/peer-response.ts index cbc99f6496..5bb92af34f 100644 --- a/main/services/peer-response.ts +++ b/main/services/peer-response.ts @@ -64,6 +64,9 @@ const operationIds: Record = { botPause: "pauseBot", botUnpause: "unpauseBot", botConnectionRequest: "requestBotConnection", + botRespondPlan: "respondBotPlan", + botAnswerAccessRequest: "answerBotAccessRequest", + botRespondRoutineProposal: "respondBotRoutineProposal", uploadBotAttachment: "uploadBotAttachment", removeBotAttachment: "removeBotAttachment", }; diff --git a/packages/cli/src/remote-bots.ts b/packages/cli/src/remote-bots.ts index 2ae3cf90ee..1d3e5bd5f3 100644 --- a/packages/cli/src/remote-bots.ts +++ b/packages/cli/src/remote-bots.ts @@ -24,6 +24,7 @@ export function createCliRemoteBots(agentDir: string, instanceId: string, runtim }, } : undefined; const bots = new AidenRemoteBotService({ ...(messaging ? { messaging } : {}), avatar: createCliBotAvatars(agentDir, instanceId), application: runtime.application, ...(runtime.durable ? { deleteBot: runtime.durable.runtime.deleteBot, sessionStates: async (ids: readonly string[]) => new Map(await Promise.all(ids.map(async (id) => [id, projectBotSessionState(await runtime.durable!.runtime.state(id)).state] as const))) } : {}), chatStore: daemon.chatStore, idempotency, persistIdempotency, + log: (message, error) => { process.stderr.write(`aiden: ${message} (${error instanceof Error ? error.message : "unknown error"})\n`); }, inbox: { list: (deviceId, input) => createBotInboxProjectionService({ listBots: () => runtime.application.list(), listChatMetadata: () => daemon.chatStore.list(), projectBatch: async (request) => mergeBotInboxActivityPreviews(request, await chatApi.streams.projectChatActivities(deviceId, request.map(({ chatId }) => chatId))), diff --git a/renderer/components/bots/routine-proposal-card.tsx b/renderer/components/bots/routine-proposal-card.tsx index 48980dcdc0..5bbab304ba 100644 --- a/renderer/components/bots/routine-proposal-card.tsx +++ b/renderer/components/bots/routine-proposal-card.tsx @@ -48,6 +48,7 @@ export function RoutineProposalCard({ supersededBy, onRespond, onNewLink, + declineReasons = true, }: { proposal: Pick; status: BotRoutineProposalStatus; @@ -62,6 +63,8 @@ export function RoutineProposalCard({ ): Promise; /** A new link for an added link routine; the old one stops working. */ onNewLink?(routineId: string): Promise; + /** After Not now, offer "Why not?". Off where the reason would not be recorded (a paired Mac's Bot). */ + declineReasons?: boolean; }) { const { platform } = useAppCapabilities(); // After Not now here, "Why not?" offers the reasons once; choosing one records it. @@ -188,7 +191,7 @@ export function RoutineProposalCard({ adding={busy === "accept"} onAdd={() => void respond("accept")} onNotNow={() => { - void respond("dismiss").then((taken) => taken && setWhyNot("offered")); + void respond("dismiss").then((taken) => taken && declineReasons && setWhyNot("offered")); }} >

{`${proposal.name} · ${when}`}

diff --git a/renderer/components/remote-bots-section.tsx b/renderer/components/remote-bots-section.tsx index e39b20ff16..1947e16006 100644 --- a/renderer/components/remote-bots-section.tsx +++ b/renderer/components/remote-bots-section.tsx @@ -41,11 +41,16 @@ export function remoteBotLine(bot: RemoteBotChoice): RemoteBotLine | null { return null; } -/** The paired Macs' Bots that match the sidebar's search; a Mac with none is left out. */ +/** + * The paired Macs' Bots that match the sidebar's search; a Mac with none is + * left out. A Mac that lists no Bots only for a reason (an old pairing) shows + * that reason until the person searches. + */ export function remoteBotGroupsMatching(groups: readonly RemoteBotGroup[], query: string): RemoteBotGroup[] { + const searching = query.trim().length > 0; return groups .map(({ host, bots }) => ({ host, bots: bots.filter((bot) => matchesSearch([bot.name, bot.purpose ?? ""], query)) })) - .filter((group) => group.bots.length > 0); + .filter((group) => group.bots.length > 0 || (!searching && group.host.disabledReason !== undefined)); } /** @@ -96,7 +101,7 @@ export function RemoteBotsSection({ {host.disabledReason} ) : null} -
    + {bots.length === 0 ? null :
      {bots.map((bot) => { const key = `${host.id}/${bot.id}`; const current = selected === key; @@ -112,7 +117,7 @@ export function RemoteBotsSection({ /> ); })} -
    +
} ))} diff --git a/renderer/lib/hosts/new-chat-targets.test.ts b/renderer/lib/hosts/new-chat-targets.test.ts index fc8d6b4c58..0e713c57fe 100644 --- a/renderer/lib/hosts/new-chat-targets.test.ts +++ b/renderer/lib/hosts/new-chat-targets.test.ts @@ -194,6 +194,33 @@ test("Bots are grouped by host, without hosts that have none", () => { assert.equal(groups[1]?.host.disabledReason, "Spare hasn't allowed this Mac to start Bot chats."); }); +test("a Mac paired before it could use another Mac's Bots is told to pair again, instead of seeing nothing", () => { + const durable = (id: string, name: string, capabilities: string[]): PeerHostView => ({ + ...view(id, name, capabilities), + features: ["bot-durable-session-v1"], + }); + const groups = remoteBotGroups( + [ + durable("host-b", "Studio", CHAT_GRANTS), + // Paired with Bot access, and simply has no Bots. + durable("host-c", "Laptop", [...CHAT_GRANTS, "bot:read", "bot:write"]), + // Too old to share Bots at all: nothing to pair again for. + view("host-d", "Spare", CHAT_GRANTS), + ], + [connected("host-b"), connected("host-c"), connected("host-d")], + new Map([ + ["host-b", feed("host-b", {})], + ["host-c", feed("host-c", {})], + ["host-d", feed("host-d", {})], + ]), + "darwin", + ); + assert.deepEqual( + groups.map((group) => [group.host.id, group.host.disabledReason, group.bots]), + [["host-b", "To use Studio's Bots here, pair this Mac with it again.", []]], + ); +}); + test("a remote Bot keeps its avatar and says it needs the person, as its own Mac does", () => { const botGrants = [...CHAT_GRANTS, "bot:read", "bot:write"]; const avatar = { version: 1, shape: "hex", color: "rose" }; diff --git a/renderer/lib/hosts/new-chat-targets.ts b/renderer/lib/hosts/new-chat-targets.ts index 57ec9bf689..5ff125c4bb 100644 --- a/renderer/lib/hosts/new-chat-targets.ts +++ b/renderer/lib/hosts/new-chat-targets.ts @@ -200,8 +200,18 @@ export function remoteBotGroups( ...(row.summarized === true ? { summarized: true as const } : {}), }; }); - if (bots.length === 0) continue; - const disabledReason = unavailableReason(host, byId.get(host.id), "botChats", "start Bot chats", platform); + const view = byId.get(host.id); + if (bots.length === 0) { + // A pairing made before this Mac could use another Mac's Bots holds no + // Bot grants (they are fixed at pairing), so the feed lists none. + if (view && view.features.includes("bot-durable-session-v1") && !view.capabilities.includes("bot:read")) + groups.push({ + host: { ...host, disabledReason: `To use ${host.label}'s Bots here, pair this ${localComputerNoun(platform)} with it again.` }, + bots: [], + }); + continue; + } + const disabledReason = unavailableReason(host, view, "botChats", "start Bot chats", platform); groups.push({ host: disabledReason ? { ...host, disabledReason } : host, bots }); } return groups; diff --git a/renderer/lib/hosts/remote-bot-session.test.ts b/renderer/lib/hosts/remote-bot-session.test.ts index c7032ace09..e76014b2fd 100644 --- a/renderer/lib/hosts/remote-bot-session.test.ts +++ b/renderer/lib/hosts/remote-bot-session.test.ts @@ -15,6 +15,7 @@ import { applyRemoteBotSessionEvent, hostServesBotHandoffs, hostSharesBotSessions, + remoteBotPlanView, remoteBotSessionView, type RemoteBotSessionView, } from "./remote-bot-session"; @@ -361,22 +362,63 @@ test("a burst of unreadable frames during a read becomes one follow-up read, and follower.stop(); }); -test("paired desktops advance access request frames without exposing a phone card", () => { +test("a host's access card reaches this Mac's chat as the card it answers by wait id, and a cleared frame takes it away", () => { const card = { waitId: "access-55", target: "folder" as const, label: "Reports", place: "~/Reports", why: "Summarize reports.", choices: ["not_now", "once"] as Array<"not_now" | "once"> }; const view = remoteBotSessionView(session({ accessRequest: card })); - assert.equal(view.snapshot.accessRequest, undefined); - const next = applyRemoteBotSessionEvent(view, event(5, { type: "access_request", payload: { accessRequest: card } })); - assert.equal(next?.snapshot.seq, 5); - assert.equal(next?.snapshot.accessRequest, undefined); - assert.deepEqual(next?.snapshot.entries, view.snapshot.entries); + assert.deepEqual(view.snapshot.accessRequest, { + botId: "bot_1", waitId: "access-55", toolCallId: "access-55", target: "folder", label: "Reports", place: "~/Reports", + why: "Summarize reports.", choices: ["not_now", "once"], + }); + const cleared = applyRemoteBotSessionEvent(view, event(5, { type: "access_request", payload: { accessRequest: null } })); + assert.equal(cleared?.snapshot.seq, 5); + assert.equal(cleared?.snapshot.accessRequest, null); + assert.deepEqual(cleared?.snapshot.entries, view.snapshot.entries); }); -test("paired desktops advance plan frames without exposing a phone plan card", () => { +test("a host's plan reaches this Mac's chat as the plan card, and every change to it is a new revision", () => { + const plan = parseAidenRemoteBotSession(contract.botPlans.session).plan!; const before = remoteBotSessionView(session()); - const frame = event(5, { type: "plan", payload: { plan: parseAidenRemoteBotSession(contract.botPlans.session).plan! } }); - const after = applyRemoteBotSessionEvent(before, frame); - assert.ok(after); - assert.equal(after.snapshot.seq, 5); - assert.deepEqual(after.snapshot, { ...before.snapshot, seq: 5 }); - assert.equal(Object.prototype.hasOwnProperty.call(after.snapshot, "plan"), false); + assert.equal(before.snapshot.plan, null); + const after = applyRemoteBotSessionEvent(before, event(5, { type: "plan", payload: { plan } })); + const shown = after?.snapshot.plan; + assert.ok(shown); + assert.equal(shown.planId, plan.planId); + assert.equal(shown.botId, "bot_1"); + assert.equal(shown.status, plan.status); + assert.deepEqual(shown.steps, plan.steps); + assert.deepEqual(shown.items.map(({ line, details }) => ({ line, details })), plan.items.map(({ line, details }) => ({ line, details }))); + assert.equal(new Set(shown.items.map(({ id }) => id)).size, plan.items.length, "each item has its own key"); + // Reading the session again (a reload, a reconnect) shows the same card, so + // it keeps its revision, its key, and with them its busy and error state. + const reread = remoteBotSessionView(session({ seq: 9, plan })); + assert.equal(reread.snapshot.plan?.revision, shown.revision); + const again = applyRemoteBotSessionEvent(after!, event(6, { type: "plan", payload: { plan: { ...plan, status: "active" } } })); + assert.notEqual(again?.snapshot.plan?.revision, shown.revision); + const stepDone = { ...plan, steps: plan.steps.map((step, index) => (index === 0 ? { ...step, status: "done" as const } : step)) }; + assert.notEqual(remoteBotPlanView("bot_1", stepDone).revision, shown.revision, "a step finishing is a change too"); + assert.equal(applyRemoteBotSessionEvent(again!, event(7, { type: "plan", payload: { plan: null } }))?.snapshot.plan, null); +}); + +test("a host's memory line and routine suggestion become this Mac's own transcript rows", () => { + const view = remoteBotSessionView( + session({ + entries: [ + { type: "memory_update", id: "mem-1", createdAt: "2026-11-24T08:00:00.000Z" }, + { + type: "routine_proposal", id: "rp-1", proposalId: "4b1f8a52-7f0e-4b8e-9d55-3f2c1a6b7e10", name: "Morning brief", + prompt: "Summarize my day.", label: "Weekdays at 8:00 AM", status: "accepted", routineId: "routine-9", + }, + ], + }), + ); + const [memory, routine] = view.snapshot.entries; + assert.equal(memory?.type, "memory_update"); + assert.equal(memory?.at, Date.parse("2026-11-24T08:00:00.000Z")); + assert.ok(routine?.type === "routine_proposal"); + assert.equal(routine.status, "accepted"); + assert.equal(routine.routineId, "routine-9"); + assert.deepEqual( + { proposalId: routine.proposal.proposalId, name: routine.proposal.name, label: routine.proposal.label }, + { proposalId: "4b1f8a52-7f0e-4b8e-9d55-3f2c1a6b7e10", name: "Morning brief", label: "Weekdays at 8:00 AM" }, + ); }); diff --git a/renderer/lib/hosts/remote-bot-session.ts b/renderer/lib/hosts/remote-bot-session.ts index 8a3efeb4f0..d6f6b1f1a0 100644 --- a/renderer/lib/hosts/remote-bot-session.ts +++ b/renderer/lib/hosts/remote-bot-session.ts @@ -4,11 +4,16 @@ // transcript rows, cards and composer draw it. import { BOT_ACTIVITY_PHASES, type BotActivityPhase } from "../../shared/bot-activity"; +import type { BotPendingAccessRequest } from "../../shared/bot-access-requests"; import type { BotLiveSnapshot, BotQueuedMessage, BotSessionState, BotTranscriptEntry } from "../../shared/bot-live"; +import type { BotPlanView } from "../../shared/bot-plans"; +import type { BotRoutineProposalEntryData } from "../../shared/bot-routine-proposals"; import type { PeerHostView } from "../../shared/peer-host"; import type { + AidenRemoteBotAccessRequest, AidenRemoteBotApproval, AidenRemoteBotHandoff, + AidenRemoteBotPlan, AidenRemoteBotQueuedMessage, AidenRemoteBotSession, AidenRemoteBotSessionActivity, @@ -92,10 +97,23 @@ export function remoteBotTranscriptEntry(entry: AidenRemoteBotSessionEntry): Bot // (`useRemoteBotImages`); empty `data` marks an image not read yet. case "shared_image": return { id: entry.id, type: "shared_image", name: entry.name, mimeType: entry.mimeType, size: entry.size, data: "" }; - // Cards this Mac does not opt into (`bot:cards`, and the revision-61 - // `bot:settings-changes` and `bot:suggestions`); the host never sends them here. + // Revision 27 (`bot:cards`): the host names neither what changed nor why, so the line only says so. case "memory_update": + return withTime({ id: entry.id, type: "memory_update" as const, targets: [], source: "turn" as const }, entry.createdAt); case "routine_proposal": + return withTime( + { + id: entry.id, + type: "routine_proposal" as const, + // The host's own label already says when it runs; its schedule and timezone stay on the host. + proposal: { proposalId: entry.proposalId, name: entry.name, prompt: entry.prompt, label: entry.label } as BotRoutineProposalEntryData, + status: entry.status, + ...(entry.routineId ? { routineId: entry.routineId } : {}), + }, + entry.createdAt, + ); + // Cards this Mac does not opt into (the revision-61 `bot:settings-changes` + // and `bot:suggestions`); the host never sends them here. case "settings_change": case "skill_proposal": case "lesson": @@ -151,6 +169,73 @@ function queued(value: readonly AidenRemoteBotQueuedMessage[] | undefined): BotQ })); } +/** + * A plan's revision from what the card shows: the same plan read again (a + * reload, a reconnect) keeps it, so the card keeps its busy and error state, + * and any change gives a new one, so the updated card replaces the old. + */ +function remoteBotPlanRevision(plan: AidenRemoteBotPlan): number { + const shown = JSON.stringify([ + plan.planId, plan.status, plan.title, plan.why, + plan.steps.map((step) => [step.text, step.status]), + plan.items.map((item) => [item.line, item.details, item.used ?? null, item.max ?? null]), + plan.expiresAt ?? null, plan.from ?? null, + ]); + // FNV-1a, 32-bit. + let hash = 0x811c9dc5; + for (let index = 0; index < shown.length; index++) { + hash ^= shown.charCodeAt(index); + hash = Math.imul(hash, 0x01000193); + } + return hash >>> 0; +} + +/** + * Revision 56 (`bot:plans`): the host's plan as the plan card draws it. Its + * items carry no ids, so their place stands in; `revision` follows what the + * card shows (`remoteBotPlanRevision`), not the frame that carried it. + */ +export function remoteBotPlanView(botId: string, plan: AidenRemoteBotPlan): BotPlanView { + const revision = remoteBotPlanRevision(plan); + const expiresAt = time(plan.expiresAt); + return { + planId: plan.planId, + botId, + status: plan.status, + title: plan.title, + why: plan.why, + steps: plan.steps.map((step) => ({ text: step.text, status: step.status })), + items: plan.items.map((item, index) => ({ + id: `item-${index}`, + line: item.line, + details: [...item.details], + ...(item.used !== undefined ? { used: item.used } : {}), + ...(item.max !== undefined ? { max: item.max } : {}), + })), + ...(expiresAt !== undefined ? { expiresAt } : {}), + revision, + ...(plan.from !== undefined ? { from: plan.from } : {}), + }; +} + +/** + * Revision 55 (`bot:access-requests`): the folder or whole-computer access + * the Bot is waiting on. The host keeps the tool call; `waitId` answers it. + */ +export function remoteBotAccessRequest(botId: string, request: AidenRemoteBotAccessRequest): BotPendingAccessRequest { + return { + botId, + waitId: request.waitId, + toolCallId: request.waitId, + target: request.target, + label: request.label, + ...(request.place !== undefined ? { place: request.place } : {}), + why: request.why, + choices: [...request.choices], + ...(request.approvalCount !== undefined ? { approvalCount: request.approvalCount } : {}), + }; +} + function entries(value: readonly AidenRemoteBotSessionEntry[]): BotTranscriptEntry[] { return value.map(remoteBotTranscriptEntry).filter((entry): entry is BotTranscriptEntry => entry !== null); } @@ -174,6 +259,8 @@ export function remoteBotSessionView(session: AidenRemoteBotSession): RemoteBotS : null, activity: activity(session.activity), queued: queued(session.queued), + accessRequest: session.accessRequest ? remoteBotAccessRequest(session.botId, session.accessRequest) : null, + plan: session.plan ? remoteBotPlanView(session.botId, session.plan) : null, }, approval: session.approval, handoff: session.handoff ?? null, @@ -233,10 +320,13 @@ export function applyRemoteBotSessionEvent( return next({}); case "handoff": return { ...next({}), handoff: event.payload.handoff }; + // Only sent to a Mac holding `bot:plans` or `bot:access-requests`; others read the host's notice line. case "plan": + return next({ plan: event.payload.plan ? remoteBotPlanView(snapshot.botId, event.payload.plan) : null }); case "access_request": - // Paired desktops remain a legacy audience and use the host notice line. - return next({}); + return next({ + accessRequest: event.payload.accessRequest ? remoteBotAccessRequest(snapshot.botId, event.payload.accessRequest) : null, + }); case "issues": // Contract revision 42: Bot issue cards are a phone surface in this // revision; the Mac reads the same cards from its own Bot transcript. diff --git a/renderer/main/bots/bot-chat-pane.tsx b/renderer/main/bots/bot-chat-pane.tsx index 017a81946d..43cadacbda 100644 --- a/renderer/main/bots/bot-chat-pane.tsx +++ b/renderer/main/bots/bot-chat-pane.tsx @@ -498,7 +498,7 @@ function BotQueuedBubble({ * when the projected entry (or the queued message) with the same words * arrives, or when the send fails. */ -function BotPendingSendBubble({ +export function BotPendingSendBubble({ send, morphFrom, onMorphEnd, @@ -635,7 +635,7 @@ function useSendMorph( } /** A send shown before main answers; `seen` names what was already on screen when it was made. */ -interface BotPendingSend { +export interface BotPendingSend { requestId: string; text: string; /** Entry ids and queued submission ids present when the echo was made; a new one with the same text settles it. */ @@ -649,7 +649,7 @@ interface BotPendingSend { } /** The ids of everything a snapshot shows that a pending send could settle into. */ -function botVisibleSendIds(snapshot: BotLiveSnapshot): Set { +export function botVisibleSendIds(snapshot: BotLiveSnapshot): Set { const ids = new Set(); for (const entry of snapshot.entries) if (entry.type === "user") ids.add(entry.id); for (const message of snapshot.queued ?? []) ids.add(`queued:${message.submissionId}`); @@ -661,7 +661,7 @@ function botVisibleSendIds(snapshot: BotLiveSnapshot): Set { * entry, or a queued message, with the same text that was not there when the * echo was made. Keyed by request id; the value is the arrival's id. */ -function matchBotPendingSends(pending: readonly BotPendingSend[], snapshot: BotLiveSnapshot): Map { +export function matchBotPendingSends(pending: readonly BotPendingSend[], snapshot: BotLiveSnapshot): Map { const matches = new Map(); if (pending.length === 0) return matches; const arrivals = [ @@ -701,7 +701,7 @@ export function settleBotPendingSends( } /** How long an acknowledged send stays as an echo when its entry never shows (a hidden input, a routine). */ -const PENDING_SEND_SETTLE_MS = 4000; +export const PENDING_SEND_SETTLE_MS = 4000; export function TranscriptEntries({ name, @@ -724,6 +724,7 @@ export function TranscriptEntries({ onRunRoutine, onRespondToProposal, onNewRoutineLink, + proposalDeclineReasons = true, onRespondToSkill, onRespondToLesson, onUndoLearning, @@ -760,6 +761,8 @@ export function TranscriptEntries({ ): Promise; /** A new link for a link routine a card added; the old one stops working. */ onNewRoutineLink?(routineId: string): Promise; + /** Whether a routine suggestion's Not now offers "Why not?"; off where the reason can't be recorded. */ + proposalDeclineReasons?: boolean; /** One action on a "Needs you" issue card. */ /** Undo on a "Settings updated" receipt; resolves to its settled status. */ onUndoSettings?(changeId: string): Promise; @@ -937,6 +940,7 @@ export function TranscriptEntries({ {...(row.supersededBy ? { supersededBy: row.supersededBy } : {})} onRespond={(decision, reason) => onRespondToProposal(row.proposal.proposalId, decision, reason)} {...(onNewRoutineLink ? { onNewLink: onNewRoutineLink } : {})} + declineReasons={proposalDeclineReasons} /> ) : null); case "lesson_proposal": diff --git a/renderer/main/remote-bot-chat-view.test.tsx b/renderer/main/remote-bot-chat-view.test.tsx index c3cab6856f..b7ff467b70 100644 --- a/renderer/main/remote-bot-chat-view.test.tsx +++ b/renderer/main/remote-bot-chat-view.test.tsx @@ -1,7 +1,7 @@ import { emitBotTestNotification, installBotTestIpc } from "./bots/test-dom"; import assert from "node:assert/strict"; import { afterEach, test } from "node:test"; -import { act, cleanup, fireEvent, screen, waitFor } from "@testing-library/react"; +import { act, cleanup, fireEvent, screen, waitFor, within } from "@testing-library/react"; import { createBotTestQueryClient, mountWithBotRouter } from "./bots/test-providers"; import { hostQueryKeys } from "../lib/hosts/host-query-keys"; import { detectedKeyboardPlatform } from "../shared/keybindings"; @@ -577,6 +577,202 @@ test("a shared image whose bytes cannot be read from the other computer says wha assert.ok(!screen.queryByRole("img", { name: "dentist-map.png" }), "no image drawn"); }); +const CARDS_HOST: PeerHostView = { + ...HOST, + capabilities: [...HOST.capabilities, "bot:cards", "bot:access-requests", "bot:plans"], +}; + +const TRIP_PLAN = { + planId: "plan-1", + status: "pending", + title: "Book the Lisbon trip", + why: "You asked for flights and a hotel.", + steps: [ + { text: "Find flights", status: "pending" }, + { text: "Hold a hotel", status: "pending" }, + ], + items: [{ line: "Gmail · send (up to 3)", details: ["Send email"], used: 0, max: 3 }], +}; + +const DOCS_ACCESS = { + waitId: "wait-docs", + target: "folder", + label: "Documents", + place: "~/Documents", + why: "To read your passport scan.", + choices: ["once", "always", "not_now"], +}; + +async function mountCards(session: Record, answers: Partial unknown>> = {}) { + return mount(CARDS_HOST, { + "remote:peerCall": (_hostId, raw) => { + const operation = raw as PeerOperation; + if (operation.operation === "botSession") return { ok: true, value: session }; + const answer = answers[operation.operation]; + return answer ? answer(operation) : { ok: false, error: { code: "failed", message: `unexpected ${operation.operation}` } }; + }, + }); +} + +test("a Bot on another computer waiting on a folder and a plan shows both cards here, and each answers there by its own id", async () => { + const { peerCalls } = await mountCards( + { ...SESSION, state: "running", accessRequest: DOCS_ACCESS, plan: TRIP_PLAN }, + { + botAnswerAccessRequest: () => ({ ok: true, value: { answered: true } }), + botRespondPlan: (operation) => ({ ok: true, value: { planId: operation.itemId, status: "active" } }), + }, + ); + // Two things wait, one card at a time; the composer can't skip past the plan. + assert.ok(await screen.findByText("1 of 2")); + assert.ok(screen.getByText("Answer the plan under Needs you, then send a message.")); + fireEvent.click(await screen.findByRole("button", { name: "Allow once" })); + await waitFor(() => { + const answer = peerCalls().find((call) => call.operation === "botAnswerAccessRequest"); + assert.equal(answer?.itemId, "wait-docs"); + assert.deepEqual(answer?.body, { choice: "once" }); + }); + // Answered: the plan is what's left. + assert.ok(await screen.findByText("Approve this plan?")); + assert.ok(screen.getByText("Book the Lisbon trip")); + fireEvent.click(screen.getByRole("button", { name: "Allow once" })); + await waitFor(() => { + const answer = peerCalls().find((call) => call.operation === "botRespondPlan"); + assert.equal(answer?.resourceId, "bot_1"); + assert.equal(answer?.itemId, "plan-1"); + assert.deepEqual(answer?.body, { decision: "approve" }); + }); + await waitFor(() => assert.equal(screen.queryByText("Approve this plan?"), null)); + + // The host's next frame carries the approved plan: its checklist shows in the chat, with Stop. + await act(async () => { + emitBotTestNotification("remote:peer-bot-session", event(4, "access_request", { accessRequest: null })); + emitBotTestNotification("remote:peer-bot-session", event(5, "plan", { plan: { ...TRIP_PLAN, status: "active" } })); + }); + fireEvent.click(await screen.findByRole("button", { name: "Stop plan" })); + await waitFor(() => + assert.deepEqual(peerCalls().filter((call) => call.operation === "botRespondPlan").map((call) => call.body), [ + { decision: "approve" }, + { decision: "stop" }, + ]), + ); +}); + +test("a plan already answered on the other computer says so on the card instead of failing quietly", async () => { + await mountCards( + { ...SESSION, plan: TRIP_PLAN }, + { + botRespondPlan: () => ({ + ok: false, + error: { code: "request_failed", remoteCode: "plan_expired", message: "This plan is no longer waiting." }, + }), + }, + ); + fireEvent.click(await screen.findByRole("button", { name: "Allow once" })); + assert.ok(await screen.findByText("This plan is no longer waiting.")); +}); + +test("a routine a Bot on another computer suggested is added there, and a memory line says where to open it", async () => { + const { peerCalls } = await mountCards( + { + ...SESSION, + entries: [ + ...SESSION.entries, + { type: "memory_update", id: "mem-1" }, + { + type: "routine_proposal", + id: "rp-entry", + proposalId: "4b1f8a52-7f0e-4b8e-9d55-3f2c1a6b7e10", + name: "Morning brief", + prompt: "Summarize my day.", + label: "Weekdays at 8:00 AM", + status: "pending", + }, + ], + }, + { + botRespondRoutineProposal: () => ({ ok: true, value: { status: "accepted", routineId: "routine-9" } }), + }, + ); + const card = await screen.findByRole("group", { name: "Routine suggestion: Morning brief" }); + assert.ok(card.textContent?.includes("Weekdays at 8:00 AM")); + fireEvent.click(within(card).getByRole("button", { name: /^Add/u })); + await waitFor(() => { + const answer = peerCalls().find((call) => call.operation === "botRespondRoutineProposal"); + assert.equal(answer?.itemId, "4b1f8a52-7f0e-4b8e-9d55-3f2c1a6b7e10"); + assert.deepEqual(answer?.body, { decision: "accept" }); + }); + assert.ok(screen.getByText("Memory updated")); +}); + +test("Not now on a routine a Bot on another computer suggested doesn't ask why, since that computer can't record a reason", async () => { + const { peerCalls } = await mountCards( + { + ...SESSION, + entries: [ + ...SESSION.entries, + { + type: "routine_proposal", + id: "rp-entry", + proposalId: "4b1f8a52-7f0e-4b8e-9d55-3f2c1a6b7e10", + name: "Morning brief", + prompt: "Summarize my day.", + label: "Weekdays at 8:00 AM", + status: "pending", + }, + ], + }, + { botRespondRoutineProposal: () => ({ ok: true, value: { status: "dismissed" } }) }, + ); + const card = await screen.findByRole("group", { name: "Routine suggestion: Morning brief" }); + fireEvent.click(within(card).getByRole("button", { name: /^Not now/u })); + assert.ok(await screen.findByText("Not added: Morning brief")); + assert.deepEqual(peerCalls().filter((call) => call.operation === "botRespondRoutineProposal").map((call) => call.body), [ + { decision: "dismiss" }, + ]); + assert.equal(screen.queryByRole("button", { name: /^Why not/u }), null); + assert.equal(screen.queryByText(/Noted, thanks/u), null); +}); + +test("a message sent to a Bot on another computer shows at once, before that computer has it", async () => { + let acknowledge: (value: unknown) => void = () => undefined; + await mount(HOST, { + "remote:peerCall": (_hostId, raw) => { + const operation = raw as PeerOperation; + if (operation.operation === "botSession") return { ok: true, value: SESSION }; + if (operation.operation === "botSend") return new Promise((resolve) => (acknowledge = resolve)); + return { ok: false, error: { code: "failed", message: `unexpected ${operation.operation}` } }; + }, + }); + const box = await screen.findByPlaceholderText("Ask Planner"); + fireEvent.change(box, { target: { value: "Move the dentist to Friday" } }); + fireEvent.click(await screen.findByRole("button", { name: "Send message" })); + assert.ok(await screen.findByText("Move the dentist to Friday")); + // The host's entry takes its place: the words show once. + await act(async () => { + acknowledge({ ok: true, value: { submissionId: "s1", deduped: false, state: "running", interrupted: false } }); + emitBotTestNotification( + "remote:peer-bot-session", + event(4, "entry", { entry: { type: "message", id: "m3", role: "user", text: "Move the dentist to Friday" } }), + ); + }); + await waitFor(() => assert.equal(screen.getAllByText("Move the dentist to Friday").length, 1)); +}); + +test("a send the other computer refuses takes its echo away and keeps the draft", async () => { + await mount(HOST, { + "remote:peerCall": (_hostId, raw) => { + const operation = raw as PeerOperation; + if (operation.operation === "botSession") return { ok: true, value: SESSION }; + return { ok: false, error: { code: "failed", message: "Studio is busy." } }; + }, + }); + const box = (await screen.findByPlaceholderText("Ask Planner")) as HTMLTextAreaElement; + fireEvent.change(box, { target: { value: "Move the dentist to Friday" } }); + fireEvent.click(await screen.findByRole("button", { name: "Send message" })); + await waitFor(() => assert.equal(box.value, "Move the dentist to Friday")); + await waitFor(() => assert.equal(document.querySelector("[data-bot-pending-send]"), null)); +}); + test("a paired Mac's Bot's dot clears only once its chat shows the new reply", async () => { const before = Date.parse("2026-11-24T08:00:00.000Z"); const replyAt = "2026-11-24T09:00:00.000Z"; diff --git a/renderer/main/remote-bot-chat-view.tsx b/renderer/main/remote-bot-chat-view.tsx index 980f79828e..4df7933b2b 100644 --- a/renderer/main/remote-bot-chat-view.tsx +++ b/renderer/main/remote-bot-chat-view.tsx @@ -10,7 +10,9 @@ import { useNavigate } from "@tanstack/react-router"; import { Ellipsis, Pause, Play, Square } from "lucide-react"; import { BotAvatar as BotAvatarMark } from "../components/bot-avatar"; import { AskUserQuestionComposer } from "../components/ask-user-question-composer"; +import { AccessRequestCard } from "../components/bots/access-request-card"; import { HandoffCard, handoffNoNoteComposerText } from "../components/bots/handoff-card"; +import { PlanCard } from "../components/bots/plan-card"; import { handoffTakenKey, useHandoffTaken } from "../components/bots/handoff-taken"; import { NeedsYouAnnouncer, NeedsYouFocusScope, NeedsYouHeader, needsYouSlotState, type NeedsYouItem } from "../components/bots/needs-you-slot"; import { Composer } from "../components/composer"; @@ -41,12 +43,26 @@ import { DEFAULT_BOT_AVATAR, botChatActivityOnDevice, isBotAvatar, showsBotToolA import { useAppearancePreference } from "../lib/use-appearance-preference"; import { useBots } from "../lib/queries"; import { BOT_HANDOFF_NOTE_MAX_CHARS, botHandoffTakesNote, type BotHandoffOutcome } from "../shared/bot-handoffs"; +import type { BotAccessChoice, BotPendingAccessRequest } from "../shared/bot-access-requests"; import type { BotPendingQuestion } from "../shared/bot-live"; +import type { BotPlanDecision, BotPlanView } from "../shared/bot-plans"; +import type { BotRoutineProposalDecision, BotRoutineProposalRespondResult } from "../shared/bot-routine-proposals"; import { localComputerNoun } from "../shared/computer-noun"; import { mintPeerIdempotencyKey, type PeerHostFeedSnapshot, type PeerHostView, type PeerOperationOutcome } from "../shared/peer-host"; import type { PeerOperation } from "../shared/peer-operation"; import type { AidenRemoteBotApproval, AidenRemoteBotHandoff } from "../../main/services/aiden-remote-protocol"; -import { BotApprovalCard, BotInterruptedCard, TranscriptEntries, questionPrompt } from "./bots/bot-chat-pane"; +import { + BotApprovalCard, + BotInterruptedCard, + BotPendingSendBubble, + PENDING_SEND_SETTLE_MS, + TranscriptEntries, + botVisibleSendIds, + matchBotPendingSends, + questionPrompt, + settleBotPendingSends, + type BotPendingSend, +} from "./bots/bot-chat-pane"; import { ApprovalStatusLine } from "../components/chat-approval-card"; import { useApprovalStatusLine } from "../lib/use-approval-status-line"; import { BOT_CHAT_COMPOSER_SURFACES } from "./bots/bot-chat-mode"; @@ -98,7 +114,7 @@ function photoIdentity(images: readonly Attachment[]): (readonly [string, string return images.map((image) => [image.name, image.mimeType, image.data ?? ""] as const); } -type BusyOperation = "paused" | "answer" | "handoff" | "pause" | "retry" | "connect"; +type BusyOperation = "paused" | "answer" | "handoff" | "pause" | "retry" | "connect" | "access"; /** * The chat's operations in flight, each counted on its own, so one finishing @@ -162,6 +178,9 @@ export function RemoteBotChatView({ hostId, botId }: { hostId: string; botId: st // id: the host's frame (or a fresh snapshot) for it is a new prompt, and it shows. const [settledQuestion, setSettledQuestion] = React.useState(null); const [settledApproval, setSettledApproval] = React.useState(null); + // The access card and plan this Mac answered, hidden the same way until the host's view moves on. + const [settledAccess, setSettledAccess] = React.useState(null); + const [settledPlan, setSettledPlan] = React.useState(null); const approvalStatus = useApprovalStatusLine(`${hostId}:${botId}`); const [statusLayout, setStatusLayout] = React.useState(""); // A send whose acknowledgement was lost keeps its key and staged photos, so @@ -184,6 +203,15 @@ export function RemoteBotChatView({ hostId, botId }: { hostId: string; botId: st const view = live.view; const snapshot = view?.snapshot ?? null; + // What the person just sent shows at once, before the host has it, as in a local Bot chat. + const [pendingSends, setPendingSends] = React.useState([]); + React.useEffect(() => { + if (!snapshot) return; + setPendingSends((current) => { + const next = settleBotPendingSends(current, snapshot); + return next.length === current.length ? current : next; + }); + }, [snapshot]); // Revision 45 (`bot:images`): shared images draw once their bytes are read from the host. // Images are read only while the host's stream is up; a read cut off by a drop is asked again once it is back. const entries = useRemoteBotImages(hostId, botId, snapshot?.entries, live.stream === "streaming"); @@ -252,10 +280,13 @@ export function RemoteBotChatView({ hostId, botId }: { hostId: string; botId: st state?.kind, view?.approval?.waitId, view?.handoff?.waitId, + snapshot?.accessRequest?.waitId, + snapshot?.plan?.revision, isPaused, snapshot?.question?.waitId, snapshot?.activity?.phase, snapshot?.queued.length ?? 0, + pendingSends.length, statusLayout, ]} showScrollToBottomButton @@ -353,10 +384,29 @@ export function RemoteBotChatView({ hostId, botId }: { hostId: string; botId: st const activityPhase = snapshot.activity?.phase; const replyStreaming = running && (snapshot.partial?.trim().length ?? 0) > 0 && (activityPhase === "writing" || activityPhase === "thinking"); - const statusActivity = snapshot.activity && !replyStreaming ? snapshot.activity : null; const question = snapshot.question && snapshot.question !== settledQuestion ? snapshot.question : null; const approval = view.approval && view.approval !== settledApproval ? view.approval : null; const handoff = view.handoff && view.handoff !== settledHandoff ? view.handoff : null; + // Revisions 55 and 56: only a host that granted `bot:access-requests` or `bot:plans` sends these. + const accessRequest = snapshot.accessRequest && snapshot.accessRequest !== settledAccess ? snapshot.accessRequest : null; + const plan = snapshot.plan && snapshot.plan !== settledPlan ? snapshot.plan : null; + const pendingPlan = plan?.status === "pending"; + // An echo leaves in the same frame its entry shows. + const sendArrivals = matchBotPendingSends(pendingSends, snapshot); + const shownSends = pendingSends.filter((send) => !sendArrivals.has(send.requestId)); + // A message just sent says "Getting ready" at once, before the host's state catches up. + const startingTurn = !running && !question && !handoff && !pendingPlan ? shownSends.find((send) => !send.queued) : undefined; + const statusActivity = + snapshot.activity && !replyStreaming + ? snapshot.activity + : startingTurn + ? { phase: "preparing" as const, startedAt: startingTurn.at } + : null; + // A host that doesn't send pauses here reads one as unavailable; its list row still says why. + const unavailableText = + row?.sessionState === "paused" + ? `${name} is paused on ${hostName}. Resume it there to send messages.` + : `${name} can’t take messages on ${hostName} right now.`; // A sign-in happens in the Bot's own browser on its Mac: typing here can't finish it. const signInElsewhere = handoff?.kind === "sign_in"; // A password-or-code card is answered on the card alone: whatever is typed here would reach the Bot. @@ -375,6 +425,17 @@ export function RemoteBotChatView({ hostId, botId }: { hostId: string; botId: st } const fullText = `${text}${attachmentText(attachments)}`; const identity = photoIdentity(images); + const echoId = mintPeerIdempotencyKey(); + const echo: BotPendingSend = { + requestId: echoId, + text: fullText, + seen: snapshot ? botVisibleSendIds(snapshot) : new Set(), + at: Date.now(), + queued: running && whenBusy === "followUp" && steerAndQueue, + accepted: false, + }; + setPendingSends((current) => [...current, echo]); + const dropEcho = () => setPendingSends((current) => current.filter((send) => send.requestId !== echoId)); // The same draft sent again replays the unsettled request as it was, even // if the Bot has started running since and the composer now queues it. const retry = unsettledSend.current && sameSend(unsettledSend.current, fullText, identity) ? unsettledSend.current : null; @@ -394,7 +455,10 @@ export function RemoteBotChatView({ hostId, botId }: { hostId: string; botId: st body: { name: image.name, mimeType: image.mimeType, kind: "image", data: image.data }, }, "Aiden couldn’t send that photo.", - ); + ).catch((error: unknown) => { + dropEcho(); + throw error; + }); const id = (uploaded.value as { id?: unknown } | null)?.id; if (typeof id === "string") attachmentIds.push(id); } @@ -407,9 +471,13 @@ export function RemoteBotChatView({ hostId, botId }: { hostId: string; botId: st } try { await call({ operation: "botSend", resourceId: botId, idempotencyKey: key, body }, `Aiden couldn’t send to ${name}.`); + // The host has it: its entry replaces the echo, or the echo goes shortly if none shows. + setPendingSends((current) => current.map((send) => (send.requestId === echoId ? { ...send, accepted: true } : send))); + setTimeout(dropEcho, PENDING_SEND_SETTLE_MS); // While the stream reconnects, read the session so the sent message shows now, as Pause does. if (live.stream !== "streaming") live.reload(); } catch (error) { + dropEcho(); if ((error as { code?: unknown }).code === "outcome_unknown") { unsettledSend.current = { text: fullText, photos: identity, key, body }; } @@ -562,6 +630,68 @@ export function RemoteBotChatView({ hostId, botId }: { hostId: string; botId: st } }); + /** A plan's answer; a throw keeps the card's buttons and shows why on it. */ + const respondPlan = async (pending: BotPlanView, decision: BotPlanDecision) => { + const outcome = await peerHostsApi.call(hostId, { + operation: "botRespondPlan", + resourceId: botId, + itemId: pending.planId, + idempotencyKey: mintPeerIdempotencyKey(), + body: { decision }, + }); + if (outcome.ok) { + if (decision !== "stop") setSettledPlan(pending); + if (live.stream !== "streaming") live.reload(); + return; + } + if (outcome.error.remoteCode === "plan_expired") { + if (live.stream !== "streaming") live.reload(); + throw new Error(outcome.error.message || "That plan was already answered or closed."); + } + throw new Error( + outcome.error.code === "outcome_unknown" + ? `${hostName} may not have received that. Check the chat before trying again.` + : outcome.error.message || "Aiden couldn’t send that answer.", + ); + }; + + /** Once, Always or Not now on an access card, through the host's own route. */ + const answerAccess = (pending: BotPendingAccessRequest, choice: BotAccessChoice) => + run("access", async () => { + const outcome = await peerHostsApi.call(hostId, { + operation: "botAnswerAccessRequest", + resourceId: botId, + itemId: pending.waitId, + idempotencyKey: mintPeerIdempotencyKey(), + body: { choice }, + }); + if (outcome.ok || outcome.error.remoteCode === "access_request_expired") { + // Answered here, or already answered on the host or another device: it stays gone. + setSettledAccess(pending); + if (!outcome.ok) toast.info("That card was already answered or closed."); + if (live.stream !== "streaming") live.reload(); + return; + } + toast.error( + outcome.error.code === "outcome_unknown" + ? `${hostName} may not have received that. Check the chat before trying again.` + : outcome.error.message || "Aiden couldn’t send that answer.", + ); + }); + + /** Add or Not now on a routine the Bot suggested; the routine is made on the host. */ + const respondToProposal = async ( + proposalId: string, + decision: BotRoutineProposalDecision, + ): Promise => { + const outcome = await call( + { operation: "botRespondRoutineProposal", resourceId: botId, itemId: proposalId, idempotencyKey: mintPeerIdempotencyKey(), body: { decision } }, + "Aiden couldn’t send that answer.", + ); + const result = outcome.value as { status: "accepted" | "dismissed"; routineId?: string }; + return { status: result.status, ...(result.routineId ? { routineId: result.routineId } : {}) }; + }; + const retry = (text: string) => run("retry", () => send(text, []).catch(() => undefined)); const reply = (text: string) => { @@ -644,6 +774,29 @@ export function RemoteBotChatView({ hostId, botId }: { hostId: string; botId: st ), }); } + if (accessRequest) { + slotItems.push({ + key: `access:${accessRequest.waitId}`, + kind: "access", + render: () => ( + void answerAccess(accessRequest, choice)} + /> + ), + }); + } + if (plan && pendingPlan) { + slotItems.push({ + key: `plan:${plan.planId}:${plan.revision}`, + kind: "plan", + render: () => respondPlan(plan, decision)} />, + }); + } if (question) slotItems.push({ key: `question:${question.waitId}`, kind: "question" }); const slot = needsYouSlotState(slotItems, needsYouChoice, setNeedsYouChoice); const askingQuestion = question !== null && slot.current?.kind === "question"; @@ -684,9 +837,13 @@ export function RemoteBotChatView({ hostId, botId }: { hostId: string; botId: st ) : ( 0} @@ -752,11 +909,22 @@ export function RemoteBotChatView({ hostId, botId }: { hostId: string; botId: st onReply={reply} // The failed turn's id comes first; the host only needs its words. onRetry={(_failedId, text) => void retry(text)} + onRespondToProposal={respondToProposal} + // Revision 27 takes only the decision, so a reason would not be recorded there. + proposalDeclineReasons={false} + onOpenMemory={() => toast.info(`Open ${name}’s memory on ${hostName}.`)} /> + {shownSends.map((send) => ( + undefined} onReply={reply} /> + ))} {statusActivity ? ( ) : null} + {/* A plan the person approved: its checklist, and Stop. */} + {plan && !pendingPlan ? ( + respondPlan(plan, decision)} /> + ) : null} {isPaused ? void setPaused(false)} /> : null} {state?.kind === "interrupted" ? ( { + const groups = [{ host: { ...laptop, disabledReason: "To use Laptop's Bots here, pair this Mac with it again." }, bots: [] }]; + const shown = (query: string) => + renderSection(); + const view = dom(shown("")); + assert.match(view.text, /On Laptop/u); + assert.match(view.text, /pair this Mac with it again/u); + assert.equal(shown("planner"), ""); +}); diff --git a/renderer/shared/peer-operation.ts b/renderer/shared/peer-operation.ts index 0367735139..363023bfab 100644 --- a/renderer/shared/peer-operation.ts +++ b/renderer/shared/peer-operation.ts @@ -72,6 +72,12 @@ export type PeerWriteOperation = /** Contract revision 37: lift the person's pause (`DELETE /bots/{botId}/pause`). */ | "botUnpause" | "botConnectionRequest" + /** Contract revision 56 (`bot:plans`): approve, Not now or Stop a plan; `itemId` is its `planId`. */ + | "botRespondPlan" + /** Contract revision 55 (`bot:access-requests`): answer an access card; `itemId` is its `waitId`. */ + | "botAnswerAccessRequest" + /** Contract revision 27 (`bot:cards`): accept or dismiss a suggested routine; `itemId` is its `proposalId`. */ + | "botRespondRoutineProposal" | "uploadBotAttachment" /** `itemId` is the staged attachment. */ | "removeBotAttachment";