Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Phone push: list a phone's bot channels in the answer, so the phone knows the computer takes them
AdityaUmalee9f9eb5d5477
diff --git a/docs/phone-push.md b/docs/phone-push.mdindex ad0bd29667..bafaff8bd7 100644--- a/docs/phone-push.md+++ b/docs/phone-push.md@@ -359,7 +359,10 @@ in order (all done; kept as the record and for a new environment):The server never names a bot the phone did not list, because Android showsa push for a missing channel under "Miscellaneous". A Cloud home leaves thefield out, since its Admin's copy of the send schema does not take it yet,- so its phones keep the shared `bot_messages` channel.+ so its phones keep the shared `bot_messages` channel. The answer's `device`+ lists the registered `botChannels` (empty when none) on a computer that+ takes the field; an older one answers without it, and the phone then leaves+ the list out, since that computer refuses fields it does not know.- The categories (Allow and Deny on an approval, Answer on a question) are theones the app registers today.diff --git a/packages/phone-protocol/src/phone-push.ts b/packages/phone-protocol/src/phone-push.tsindex 5f88143c68..871567e43f 100644--- a/packages/phone-protocol/src/phone-push.ts+++ b/packages/phone-protocol/src/phone-push.ts@@ -66,6 +66,9 @@ export interface PublicPushDevice {environment: ApnsEnvironment;pairing?: string;kinds: PushKind[];+ /** FCM only: the bots registered with a channel of their own. A computer that takes `botChannels` always lists it+ * (maybe empty), so a phone sends its list only to one that answers with it. */+ botChannels?: string[];updatedAt: number;}diff --git a/server/phone-push.test.ts b/server/phone-push.test.tsindex 674d566953..8cce4d70e0 100644--- a/server/phone-push.test.ts+++ b/server/phone-push.test.ts@@ -255,7 +255,7 @@ describe("registering a phone", () => {describe("offering a notify frame", () => {it("tells the relay a bot's push may use the bot's own Android channel, only for bots the phone made one for", async () => {const { push, relay } = harness();- await push.register(OTHER, { platform: "fcm", token: FCM, botChannels: ["bot_1", "bot_1"] });+ expect((await push.register(OTHER, { platform: "fcm", token: FCM, botChannels: ["bot_1", "bot_1"] })).device?.botChannels).toEqual(["bot_1"]);push.offer({ notification: notification({ kind: "done", threadId: "th_a" }), seq: 1 }, everyone);push.offer({ notification: notification({ kind: "done", botId: "bot_2", botName: "Atlas", threadId: "th_b" }), seq: 2 }, everyone);await push.flush();@@ -263,7 +263,7 @@ describe("offering a notify frame", () => {[expect.objectContaining({ botId: "bot_1" }), true],[expect.objectContaining({ botId: "bot_2" }), undefined],]);- await push.register(OTHER, { platform: "fcm", token: FCM });+ expect((await push.register(OTHER, { platform: "fcm", token: FCM })).device?.botChannels).toEqual([]);push.offer({ notification: notification({ kind: "done", threadId: "th_c" }), seq: 3 }, everyone);await push.flush();expect(relay.sends().at(-1)?.body).not.toHaveProperty("botChannel");diff --git a/server/phone-push.ts b/server/phone-push.tsindex 6d4437cde4..a79322c36c 100644--- a/server/phone-push.ts+++ b/server/phone-push.ts@@ -241,7 +241,7 @@ export class PhonePush {private publicDevice(key: string): PublicPushDevice | null {const device = this.devices.find((candidate) => candidate.key === key);if (!device) return null;- return { platform: device.platform, environment: device.environment, ...(device.pairing ? { pairing: device.pairing } : {}), kinds: [...device.kinds], updatedAt: device.updatedAt };+ return { platform: device.platform, environment: device.environment, ...(device.pairing ? { pairing: device.pairing } : {}), kinds: [...device.kinds], ...(device.platform === "fcm" ? { botChannels: [...(device.botChannels ?? [])] } : {}), updatedAt: device.updatedAt };}/** The device token a phone registered, for the Live Activity and ongoing-notification pushes that share its relay. */