Skip to content

Open-source Grok Bot alternative with a virtual machine that bots can use

Type the search, model list, session, and bot, room and task answers in packages/phone-protocol (#5904)

Milind Sonia69f31ef5c09
diff --git a/packages/phone-protocol/src/responses.ts b/packages/phone-protocol/src/responses.ts
index 51f8973e55..8890bd2d5d 100644
--- a/packages/phone-protocol/src/responses.ts
+++ b/packages/phone-protocol/src/responses.ts
@@ -1,6 +1,6 @@
import type { EnvironmentDescriptor } from "./environment.ts";
import type { CompanionEndpoint, PairingE2EDescriptor } from "./pairing-link.ts";
-import type { BotQueuedMessages, ComputerHelpRef, WireBot, WireGroup, WireMessage } from "./wire.ts";
+import type { BotQueuedMessages, ComputerHelpRef, GroupTask, WireBot, WireGroup, WireMessage, WireTask } from "./wire.ts";
/** The encrypted-link descriptor a paired phone is sent. `routes: "local"` restricts it to Wi-Fi and Tailscale; absent
* means any route. */
@@ -83,3 +83,142 @@ export interface BotsResponse<Message = WireMessage> {
/** By bot id. */
computerControl: Record<string, WireComputerControl>;
}
+
+/** One match in GET /api/search, in a bot's conversation (`botId`) or a room's (`groupId`). */
+export interface SearchHit {
+ threadId: string;
+ messageId: string;
+ at: number;
+ role: string;
+ kind: string;
+ snippet: string;
+ /** Where the match starts in `snippet`, and how long it is, in UTF-16 code units. */
+ matchStart: number;
+ matchLength: number;
+ from?: string;
+ botId?: string;
+ groupId?: string;
+ /** The bot's or room's name. */
+ name: string;
+ /** The conversation's title. */
+ task?: string;
+ /** False for a message on a branch the conversation has left. */
+ onActivePath: boolean;
+}
+
+/** GET /api/search?q=…[&threadId=…][&limit=1–100]. */
+export interface SearchResponse {
+ hits: SearchHit[];
+}
+
+/** One model an engine offers. */
+export interface WireModelOption {
+ id: string;
+ label: string;
+ custom?: boolean;
+ provider?: string;
+}
+
+/** One AI engine set up on the server, as GET /api/instances lists it: the fields a phone reads. Each entry carries more
+ * that only the desktop's settings use. */
+export interface WireInstance {
+ instanceId: string;
+ driverKind: string;
+ displayName: string;
+ readOnly?: boolean;
+ snapshot: {
+ state: "available" | "unavailable";
+ /** Why it can't be used, in plain words. */
+ reason?: string;
+ authenticated?: boolean;
+ };
+ models: { default: string; options: WireModelOption[] };
+ capabilities?: { images?: boolean; effortLevels?: readonly string[] };
+ access?: "subscription" | "custom" | "api";
+}
+
+/** GET /api/instances. */
+export interface InstancesResponse {
+ instances: WireInstance[];
+}
+
+/** GET /api/auth/session for a caller on this computer with no session. */
+export interface LoopbackSessionResponse {
+ kind: "loopback";
+ scopes: ReadonlyArray<"admin" | "client">;
+ environmentId: string;
+ trust?: "service";
+}
+
+/** GET /api/auth/session for a signed-in session, a paired phone's included. Optional fields are absent, never false. */
+export interface SignedInSessionResponse {
+ kind: "session";
+ id: string;
+ label: string;
+ scopes: ReadonlyArray<"admin" | "client">;
+ expiresAt: number;
+ via: "bearer" | "cookie" | "ticket";
+ environmentId: string;
+ email?: string;
+ owner?: string;
+ hosted?: true;
+ cloudHome?: true;
+ /** How a team member signs in again, on a team Cloud. */
+ teamSignIn?: string;
+ /** The person owns this server outright. */
+ own?: true;
+ /** What the owner's desktop lends this server by default; only with `own`. */
+ lending?: Readonly<Record<string, boolean>>;
+ team?: { id: string; name: string; role: "owner" | "admin" | "member" } | null;
+ /** Conversations this person opened, on a team or as a guest on a personal Cloud. */
+ openedThreads?: string[];
+ cloudGuest?: true;
+ /** Whose reactions are this person's, where several people share the workspace. */
+ reactor?: string;
+}
+
+/** GET /api/auth/session. */
+export type AuthSessionResponse = LoopbackSessionResponse | SignedInSessionResponse;
+
+/** POST /api/bots (201): the new bot with its first conversation. */
+export interface BotCreateResponse<Message = WireMessage> {
+ bot: WireBot & { messages: Message[]; activeLeafId: string | null };
+ /** It was made but something after that didn't take; each in plain words. */
+ warnings?: string[];
+ /** Made asleep: the plan's awake limit is reached. */
+ paused?: true;
+}
+
+/** PATCH /api/bots/:id. */
+export interface BotUpdateResponse {
+ bot: WireBot;
+ /** In plain words, when the change left something behind (a server computer it moved off). */
+ notice?: string;
+}
+
+/** POST /api/groups (201): the new room, with no messages yet. */
+export interface RoomCreateResponse<Message = WireMessage> {
+ group: WireGroup & { messages: Message[] };
+}
+
+/** PATCH /api/groups/:id and PATCH /api/groups/:id/setup. */
+export interface RoomUpdateResponse {
+ group: WireGroup;
+}
+
+/** POST /api/bots/:id/tasks (201) and its fork, and PATCH /api/bots/:id/tasks/:threadId. */
+export interface TaskResponse {
+ bot: WireBot;
+ task: WireTask;
+}
+
+/** POST /api/groups/:id/tasks (201) and its fork. */
+export interface RoomTaskCreateResponse {
+ group: WireGroup;
+ task: GroupTask;
+}
+
+/** PATCH /api/groups/:id/tasks/:threadId. */
+export interface RoomTaskUpdateResponse {
+ task: GroupTask;
+}
diff --git a/packages/phone-protocol/src/wire.ts b/packages/phone-protocol/src/wire.ts
index f1c1a0823b..0c297c35ec 100644
--- a/packages/phone-protocol/src/wire.ts
+++ b/packages/phone-protocol/src/wire.ts
@@ -41,7 +41,7 @@ export const SHARED_CHAT_TITLE = "Shared chat";
export type { LiveCallRecord, LiveCallState, LiveCallStatus, LiveClient, LiveElevenLabsSession, LiveElevenLabsTransport, LiveEndReason, LiveFishRelayCommand, LiveFishRelayEvent, LiveFishSessionToken, LiveFishTransport, LiveGeminiSession, LiveGeminiTransport, LiveKeySource, LiveProvider, LiveSettings } from "./live-call-wire.ts";
export type { ForkOrigin, TaskClosedBy, TaskOpenedBy } from "./task-provenance.ts";
-export type { AuthPairResponse, BotsResponse, CompanionE2EDescriptor, CompanionEndpointsSnapshot, PairedDevice, PairedSession, PairResponse, WireComputerControl, WireMessagePage } from "./responses.ts";
+export type { AuthPairResponse, AuthSessionResponse, BotCreateResponse, BotsResponse, BotUpdateResponse, CompanionE2EDescriptor, CompanionEndpointsSnapshot, InstancesResponse, LoopbackSessionResponse, PairedDevice, PairedSession, PairResponse, RoomCreateResponse, RoomTaskCreateResponse, RoomTaskUpdateResponse, RoomUpdateResponse, SearchHit, SearchResponse, SignedInSessionResponse, TaskResponse, WireComputerControl, WireInstance, WireMessagePage, WireModelOption } from "./responses.ts";
/** Reasoning-effort levels, ascending: a union of what any engine accepts;
* each driver declares the subset its CLI will take. */
diff --git a/scripts/sync-phone-protocol.test.mjs b/scripts/sync-phone-protocol.test.mjs
index e0f68acf8c..17939e1c29 100644
--- a/scripts/sync-phone-protocol.test.mjs
+++ b/scripts/sync-phone-protocol.test.mjs
@@ -44,7 +44,10 @@ describe("sync-phone-protocol", () => {
expect(readFileSync(join(out, "SOURCE"), "utf8")).toBe(`${head}\n`);
const sources = git("ls-tree", "-r", "--name-only", "HEAD", "--", "packages/phone-protocol/src").split("\n")
.filter((path) => !path.endsWith(".test.ts"));
- for (const name of ["wire", "app-rpc", "cursor-face-data", "failed-turn", "mention-boundary", "upload-limits"]) {
+ for (const name of [
+ "wire", "responses", "pairing-code", "app-rpc", "cursor-face-data", "failed-turn", "mention-boundary", "upload-limits",
+ "markdown-plain-paths", "bot-limit", "codex-usage-limit", "cloud-hints", "waits",
+ ]) {
expect(sources).toContain(`packages/phone-protocol/src/${name}.ts`);
}
expect(Object.keys(tree(out)).sort()).toEqual([
diff --git a/server/index.ts b/server/index.ts
index 8c8c4d6ae2..66f476b4b3 100644
--- a/server/index.ts
+++ b/server/index.ts
@@ -107,7 +107,7 @@ import { createDataRoutes } from "./data/routes.ts";
import { DataSheetRegistry } from "./data/sheet.ts";
import { DataFailure } from "./data/types.ts";
import { TeamComputers, teamComputerOwner, type TeamComputerRecord } from "./team-computers.ts";
-import { isEffortLevel, type AuthPairResponse, type CardAnswerer, type PairResponse, type ResolvedSender, type ServerFrame, type SignInRequestCardData, type WireBot, type WireGroup, type WireTask } from "../shared/wire.ts";
+import { isEffortLevel, type AuthPairResponse, type CardAnswerer, type LoopbackSessionResponse, type SignedInSessionResponse, type PairResponse, type ResolvedSender, type ServerFrame, type SignInRequestCardData, type WireBot, type WireGroup, type WireTask } from "../shared/wire.ts";
import { isPersistentQuestionCard, shouldSettleRequestCard } from "../shared/ask-question.ts";
import { parseToolScope } from "../shared/tool-scope.ts";
import type { TeamComputersPayload } from "../shared/team-computer.ts";
@@ -12701,7 +12701,7 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {
res,
200,
auth.kind === "loopback"
- ? { kind: "loopback", scopes: auth.scopes, environmentId: ENVIRONMENT_ID, ...(auth.trust ? { trust: auth.trust } : {}) }
+ ? { kind: "loopback", scopes: auth.scopes, environmentId: ENVIRONMENT_ID, ...(auth.trust ? { trust: auth.trust } : {}) } satisfies LoopbackSessionResponse
: {
kind: "session",
id: auth.session.id,
@@ -12716,7 +12716,7 @@ const handleRequest = async (req: IncomingMessage, res: ServerResponse) => {
...(CLOUD_HOME ? { cloudHome: true } : {}), ...teamSignInFor(CLOUD_HOME, auth.session), ...(ownHome.owner(auth) ? { own: true, ...(ownerLends() ? { lending: OWNER_LENDING } : {}) } : {}), ...(teamHost.sessionInfo(auth.session) ? { team: teamHost.sessionInfo(auth.session), openedThreads: threadStarters.threadsOf(actorKey(auth), 2_000).filter((threadId) => !conversationShares.get(threadId)) } : {}),
...(CLOUD_PERSONAL && !cloudOwnerSession(auth) ? { cloudGuest: true, openedThreads: threadStarters.threadsOf(actorKey(auth), 2_000) } : {}),
...(reactorFor(auth).by !== "user" ? { reactor: reactorFor(auth).by } : {}),
- },
+ } satisfies SignedInSessionResponse,
);
}
if (method === "POST" && path === "/api/auth/stream-ticket") {
diff --git a/server/routes/bot-patch.ts b/server/routes/bot-patch.ts
index 75d25b80f5..251109f568 100644
--- a/server/routes/bot-patch.ts
+++ b/server/routes/bot-patch.ts
@@ -5,7 +5,7 @@ import { normalizeConnectorScopes } from "../../shared/connector-scopes.ts";
import { normalizeOutboundPolicy } from "../../shared/outbound.ts";
import { normalizePhoneApps } from "../../shared/phone-apps.ts";
import { parseToolScope, toolScopeWidens } from "../../shared/tool-scope.ts";
-import { isMausColor, MAUS_COLOR_NAMES, type WireBot, type WireGroup } from "../../shared/wire.ts";
+import { isMausColor, MAUS_COLOR_NAMES, type BotUpdateResponse, type WireBot, type WireGroup } from "../../shared/wire.ts";
import { checkBrowserProfileChange, settleBrowserChange } from "../bot-browser-profile.ts";
import { validateBotCwd } from "../bot-cwd.ts";
import { parseBotProfilePatch } from "../bot-profile.ts";
@@ -135,7 +135,7 @@ export function createBotPatchRoutes(deps: BotPatchRouteDeps): RouteHandler {
if (defaultBotRefused) return json(res, 400, { error: defaultBotRefused });
if (existingBot && typeof body.unread === "boolean" && deps.shownThread && deps.personMarkThread?.(auth, deps.shownThread(auth, existingBot), body.unread)) {
delete body.unread;
- if (!Object.keys(body).length) return json(res, 200, { bot: wireBot(existingBot) });
+ if (!Object.keys(body).length) return json(res, 200, { bot: wireBot(existingBot) } satisfies BotUpdateResponse);
}
const rawSelection = (body as Record<string, unknown>).modelSelection;
if (body.threadId !== undefined && rawSelection === undefined) {
@@ -715,7 +715,7 @@ export function createBotPatchRoutes(deps: BotPatchRouteDeps): RouteHandler {
audienceChanged();
}
return json(res, 200, { bot: wireBot(store.bot(bot.id)!),
- ...(vpsLeftOn ? { notice: vpsLeftBehindNotice("Moved", vpsLeftOn, vps.vpsContainerName(bot.id)) } : {}) });
+ ...(vpsLeftOn ? { notice: vpsLeftBehindNotice("Moved", vpsLeftOn, vps.vpsContainerName(bot.id)) } : {}) } satisfies BotUpdateResponse);
}
return PASS;
};
diff --git a/server/routes/bots-create.ts b/server/routes/bots-create.ts
index d074ef13f7..8d1c89bbee 100644
--- a/server/routes/bots-create.ts
+++ b/server/routes/bots-create.ts
@@ -1,4 +1,4 @@
-import type { WireBot } from "../../shared/wire.ts";
+import type { BotCreateResponse, WireBot } from "../../shared/wire.ts";
import { freshLook } from "../bot-look.ts";
import { validateBotCwd } from "../bot-cwd.ts";
import { parseBotProfilePatch } from "../bot-profile.ts";
@@ -270,7 +270,7 @@ export function createBotCreateRoutes(deps: BotCreateRouteDeps): RouteHandler {
messages: store.messagesFor(bot.threadId),
activeLeafId: store.activeLeaf(bot.threadId),
},
- });
+ } satisfies BotCreateResponse<ReturnType<typeof store.messagesFor>[number]>);
}
return PASS;
};
diff --git a/server/routes/channels.ts b/server/routes/channels.ts
index 7b49f0c4fb..41709f1879 100644
--- a/server/routes/channels.ts
+++ b/server/routes/channels.ts
@@ -1,6 +1,6 @@
import { z } from "zod";
import { routeRunOwners, type Actor, type RouteRunOwners } from "../host/run-owner.ts";
-import type { ResolvedSender, WireGroup } from "../../shared/wire.ts";
+import type { ResolvedSender, RoomTaskCreateResponse, RoomTaskUpdateResponse, RoomUpdateResponse, WireGroup } from "../../shared/wire.ts";
import { admit } from "../admission.ts";
import {
cancelChannelMessage,
@@ -161,7 +161,7 @@ export function createChannelRoutes(deps: ChannelRouteDeps): RouteHandler {
const task = store.forkGroupTask(group.id, m[2], messageId);
if (!task) return json(res, 404, { error: "no such completed message in this conversation" });
if (auth.kind === "session") threadStarters.set(task.threadId, actorKey(auth));
- return json(res, 201, { group: own(groupWithThread(store.group(group.id)!)), task });
+ return json(res, 201, { group: own(groupWithThread(store.group(group.id)!)), task } satisfies RoomTaskCreateResponse);
}
m = path.match(/^\/api\/groups\/([\w-]+)\/tasks$/);
@@ -182,7 +182,7 @@ export function createChannelRoutes(deps: ChannelRouteDeps): RouteHandler {
if (!task) return json(res, 500, { error: "couldn't create that task" });
// Who opened it decides who may answer its cards on a shared workspace.
if (auth.kind === "session") threadStarters.set(task.threadId, actorKey(auth));
- return json(res, 201, { group: own(groupWithThread(store.group(group.id)!)), task });
+ return json(res, 201, { group: own(groupWithThread(store.group(group.id)!)), task } satisfies RoomTaskCreateResponse);
}
m = path.match(/^\/api\/groups\/([\w-]+)\/tasks\/delete$/);
@@ -269,7 +269,7 @@ export function createChannelRoutes(deps: ChannelRouteDeps): RouteHandler {
};
const task = Object.keys(patch).length ? store.patchGroupTask(group.id, m[2], patch) : existing;
if (!task) return json(res, 404, { error: "no such channel task" });
- return json(res, 200, { task });
+ return json(res, 200, { task } satisfies RoomTaskUpdateResponse);
}
if (m && method === "DELETE") {
const group = store.group(m[1]);
@@ -298,10 +298,10 @@ export function createChannelRoutes(deps: ChannelRouteDeps): RouteHandler {
if (deps.personMarkRoom && auth.kind === "session" && renamed && typeof body?.unread === "boolean") {
const { unread, ...shared } = body;
const group = Object.keys(shared).length ? updateChannel(m[1], shared) : renamed;
- return json(res, 200, { group: deps.personMarkRoom(auth, group, unread) ?? own(publicGroupState(group)) });
+ return json(res, 200, { group: deps.personMarkRoom(auth, group, unread) ?? own(publicGroupState(group)) } satisfies RoomUpdateResponse);
}
const group = updateChannel(m[1], body);
- return json(res, 200, { group: own(publicGroupState(group)) });
+ return json(res, 200, { group: own(publicGroupState(group)) } satisfies RoomUpdateResponse);
}
m = path.match(/^\/api\/groups\/([\w-]+)\/read$/);
if (m && method === "POST") {
diff --git a/server/routes/groups.ts b/server/routes/groups.ts
index 803aacb920..d3bb955f1b 100644
--- a/server/routes/groups.ts
+++ b/server/routes/groups.ts
@@ -1,4 +1,4 @@
-import type { WireGroup } from "../../shared/wire.ts";
+import type { RoomCreateResponse, RoomUpdateResponse, WireGroup } from "../../shared/wire.ts";
import { validateBotCwd } from "../bot-cwd.ts";
import type { VisibleSet } from "../bot-visibility.ts";
import type { RequestAuth } from "../request-auth.ts";
@@ -55,7 +55,7 @@ export function createGroupRoutes(deps: GroupRouteDeps): RouteHandler {
const group = createChannel(body);
// On a Cloud home whoever opens a room names it (cloudThreadRefusal).
if (CLOUD_HOME && auth.kind === "session") threadStarters.set(group.threadId, actorKey(auth));
- return json(res, 201, { group: { ...own(publicGroupState(group)), messages: [] } });
+ return json(res, 201, { group: { ...own(publicGroupState(group)), messages: [] } } satisfies RoomCreateResponse);
}
m = path.match(/^\/api\/groups\/([\w-]+)\/setup$/);
if (m && method === "PATCH") {
@@ -67,7 +67,7 @@ export function createGroupRoutes(deps: GroupRouteDeps): RouteHandler {
return json(res, 400, { error: "action must be complete or skip" });
}
if (group.setupCompletedAt != null || group.setupSkippedAt != null) {
- return json(res, 200, { group: own(publicGroupState(group)) });
+ return json(res, 200, { group: own(publicGroupState(group)) } satisfies RoomUpdateResponse);
}
if (store.messagesFor(group.threadId).length > 0) {
return json(res, 409, { error: "room setup must be finished before the first message" });
@@ -90,7 +90,7 @@ export function createGroupRoutes(deps: GroupRouteDeps): RouteHandler {
}
const updated = store.patchGroup(m[1], patch);
if (!updated) return json(res, 404, { error: "no such room" });
- return json(res, 200, { group: own(publicGroupState(updated)) });
+ return json(res, 200, { group: own(publicGroupState(updated)) } satisfies RoomUpdateResponse);
}
return PASS;
};
diff --git a/server/routes/tasks.ts b/server/routes/tasks.ts
index 58cfc61e21..56ed5d6e8b 100644
--- a/server/routes/tasks.ts
+++ b/server/routes/tasks.ts
@@ -1,6 +1,6 @@
import { approvalModeFor, approvalModeWidens, isApprovalMode, type ApprovalMode } from "../../shared/approval-mode.ts";
import { threadLinkUrl } from "../../shared/thread-link.ts";
-import type { WireBot, WireTask } from "../../shared/wire.ts";
+import type { TaskResponse, WireBot, WireTask } from "../../shared/wire.ts";
import { validateBotCwd } from "../bot-cwd.ts";
import type { ModelSelection, ProviderInstance } from "../contracts.ts";
import type { Coordinator } from "../coordinator.ts";
@@ -176,7 +176,7 @@ export function createTaskRoutes(deps: TaskRouteDeps): RouteHandler & { deleteTa
const task = store.forkTask(bot.id, m[2], messageId);
if (!task) return json(res, 404, { error: "no such completed message in this conversation" });
if (auth.kind === "session") threadStarters.set(task.threadId, actorKey(auth));
- return json(res, 201, { bot: publicBot(store.bot(bot.id)!), task: wireTask(task, store.bot(bot.id)!.modelSelection) });
+ return json(res, 201, { bot: publicBot(store.bot(bot.id)!), task: wireTask(task, store.bot(bot.id)!.modelSelection) } satisfies TaskResponse);
}
m = path.match(/^\/api\/bots\/([\w-]+)\/tasks$/);
@@ -216,7 +216,7 @@ export function createTaskRoutes(deps: TaskRouteDeps): RouteHandler & { deleteTa
const task = store.createTask(bot.id, typeof body.title === "string" ? body.title : undefined, body.select !== false, body.projectId, undefined, body.approvalMode, undefined, cwd,
auth.kind === "session" ? (created) => threadStarters.set(created.threadId, actorKey(auth)) : undefined);
if (!task) return json(res, 500, { error: "couldn't create that task" });
- return json(res, 201, { bot: publicBot(store.bot(bot.id)!), task: wireTask(task, store.bot(bot.id)!.modelSelection) });
+ return json(res, 201, { bot: publicBot(store.bot(bot.id)!), task: wireTask(task, store.bot(bot.id)!.modelSelection) } satisfies TaskResponse);
}
m = path.match(/^\/api\/bots\/([\w-]+)\/tasks\/delete$/);
if (m && method === "POST") {
@@ -321,7 +321,7 @@ export function createTaskRoutes(deps: TaskRouteDeps): RouteHandler & { deleteTa
}
const task = store.refreshTaskPermissions(profile.id, m[2]);
if (!task) return json(res, 404, { error: "no such task" });
- return json(res, 200, { task: wireTask(task, store.bot(profile.id)!.modelSelection), bot: publicBot(store.bot(profile.id)!) });
+ return json(res, 200, { task: wireTask(task, store.bot(profile.id)!.modelSelection), bot: publicBot(store.bot(profile.id)!) } satisfies TaskResponse);
}
const patch: Parameters<typeof store.patchTask>[2] = {};
if (body.projectId !== undefined) {
@@ -406,7 +406,7 @@ export function createTaskRoutes(deps: TaskRouteDeps): RouteHandler & { deleteTa
? store.switchTaskModel(m[1], m[2], patch.modelSelection, body.updateBotDefault === true, body.resetApprovalToAsk === true,
{ ...patch, ...hostedModels?.resetTask(current.modelSelection, patch.modelSelection) })!
: store.patchTask(m[1], m[2], patch)!;
- return json(res, 200, { task: wireTask(task, store.bot(m[1])!.modelSelection), bot: publicBot(store.bot(m[1])!) });
+ return json(res, 200, { task: wireTask(task, store.bot(m[1])!.modelSelection), bot: publicBot(store.bot(m[1])!) } satisfies TaskResponse);
}
if (m && method === "DELETE") {
const bot = store.bot(m[1]);
diff --git a/server/routes/threads.ts b/server/routes/threads.ts
index a962f2a187..8b66c218e6 100644
--- a/server/routes/threads.ts
+++ b/server/routes/threads.ts
@@ -1,7 +1,7 @@
import { userError } from "../user-errors.ts";
import { basename, join } from "node:path";
-import type { BotsResponse, WireBot, WireGroup } from "../../shared/wire.ts";
+import type { BotsResponse, SearchResponse, WireBot, WireGroup } from "../../shared/wire.ts";
import { NO_SUCH_BOT } from "../../shared/bot-read.ts";
import {
ATTACHMENTS_DIR, attachmentStorageUsage, clearAttachments, deleteAttachment, extensionForMime, FILE_MAX_BYTES, IMAGE_MAX_BYTES,
@@ -535,7 +535,7 @@ export function createThreadRoutes(deps: ThreadRouteDeps): RouteHandler {
return null;
})
.filter((hit): hit is NonNullable<typeof hit> => hit !== null);
- return json(res, 200, { hits });
+ return json(res, 200, { hits } satisfies SearchResponse);
}
m = path.match(/^\/api\/threads\/([\w-]+)\/export$/);
diff --git a/src/state/phone-protocol-types.test.ts b/src/state/phone-protocol-types.test.ts
new file mode 100644
index 0000000000..e6f484404e
--- /dev/null
+++ b/src/state/phone-protocol-types.test.ts
@@ -0,0 +1,10 @@
+import { describe, expectTypeOf, it } from "vitest";
+
+import type { WireInstance } from "../../packages/phone-protocol/src/responses.ts";
+import type { InstanceInfo } from "./store";
+
+describe("the phone protocol's model list", () => {
+ it("is a subset of what the desktop reads from GET /api/instances", () => {
+ expectTypeOf<InstanceInfo>().toExtend<WireInstance>();
+ });
+});