Open-source, local-first AI agent team for your desktop: multi-agent group chats, computer use, browser, MCP, routines and approvals. macOS, Windows, Linux + Android. Built on pi.
TypeScript agentai-agentai-agentsai-assistantandroidautomationchatgptcoding-agentcomputer-usedesktop-appelectronllmlocal-firstmcpmulti-agentollamaopenaiprivacyself-hostedtypescript
// Keep the published RPC schemas covered by the existing contract fixtures.
import { DEFAULT_EXECUTION_LIMITS } from "@pibot/protocol-base";
import { describe, expect, it } from "vitest";
import type { z } from "zod";
import type {
EventPayloads,
HostParams,
HostResults,
MethodParams,
MethodResults,
} from "../src/aggregate/api.ts";
import {
AgentErrorCodeSchema,
ApiSchema,
BotSchema,
CustomModelSchema,
CustomProviderSchema,
EventEnvelopeSchema,
Events,
HostMethods,
IdSchema,
MessageSchema,
Methods,
ModelInfoSchema,
ProviderSchema,
RunnerFileRequestSchema,
SafeSecretSchema,
SequenceSchema,
SettingsSchema,
ThinkingLevelSchema,
WebUrlSchema,
} from "../src/aggregate/api.ts";
import {
browserEventCases,
browserExtensionEventCases,
browserExtensionHostCases,
browserExtensionMethodCases,
browserMethodCases,
browserViewHostCases,
} from "./fixtures/browser.ts";
import { builtinMethodCases, roleCatalogMethodCases } from "./fixtures/builtin.ts";
import {
computerEventCases,
computerHostGuardCases,
computerMethodCases,
} from "./fixtures/computer.ts";
import {
connectorAppMethodCases,
connectorEventCases,
connectorHostCases,
connectorMethodCases,
} from "./fixtures/connectors.ts";
import {
credentialEventCases,
credentialHostCases,
credentialMethodCases,
} from "./fixtures/credentials.ts";
import { executionEventCases, executionMethodCases } from "./fixtures/execution.ts";
import { groupEventCases, groupMethodCases } from "./fixtures/groups.ts";
import { knowledgeEventCases, knowledgeMethodCases } from "./fixtures/knowledge.ts";
import { remoteEventCases, remoteMethodCases } from "./fixtures/remote.ts";
import { skillEventCases, skillMethodCases, teachHostCases } from "./fixtures/skills.ts";
import { workspaceMethodCases } from "./fixtures/workspace.ts";
const id = "00000000-0000-4000-8000-000000000001";
const computerToken = "A".repeat(43);
const date = "2026-10-09T00:00:00.000Z";
const image = { type: "image", data: "iVBORw0KGgo=", mimeType: "image/png" } as const;
const executionTask = {
id,
botId: id,
conversationId: id,
parentTaskId: null,
rootRunId: id,
parentRunId: id,
runId: id,
title: "Inspect source",
status: "queued" as const,
version: 1,
createdAt: date,
updatedAt: date,
result: null,
resultTruncated: false,
needsVerification: false,
};
const executionBudget = {
rootRunId: id,
limits: DEFAULT_EXECUTION_LIMITS,
activeMillis: 0,
tools: 0,
requests: 0,
childTasks: 0,
activeChildren: 0,
maxDepth: 0,
observedTokens: 0,
knownCostUsd: 0,
unknownUsageRequests: 0,
unknownCostRequests: 0,
exhaustedReason: null,
version: 1,
};
const browserDiagnostics = {
documentId: id,
supported: true,
oldestSeq: 1,
nextSeq: 0,
dropped: false,
entries: [],
};
const browserElement = {
documentId: id,
ref: "e1",
tag: "button",
secret: false,
frameSupported: true,
bounds: null,
styles: [],
};
const backgroundCommand = {
id,
botId: id,
conversationId: id,
groupId: null,
runId: id,
toolCallId: "call_1",
command: "python3 -m http.server 8010 --bind 127.0.0.1",
status: "running" as const,
stopReason: null,
exitCode: null,
ports: [8010],
portsVisible: true,
startedAt: date,
endedAt: null,
};
const settings = {
language: "system",
theme: "system",
onboardingCompleted: false,
openAtLogin: true,
showTrayIcon: true,
closeToTrayHintShown: false,
defaultModel: { provider: "openai", id: "test-model", thinkingLevel: "medium" },
} as const;
const provider = {
id: "openai",
name: "OpenAI",
group: "common",
auth: "apiKey",
modelCount: 1,
configured: true,
keyHint: "1234",
envVarName: "OPENAI_API_KEY",
envDetected: true,
available: true,
} as const;
const model = {
provider: "openai",
id: "model",
name: "Model",
contextWindow: 1000,
input: ["text", "image"] as ("text" | "image")[],
reasoning: true,
maxTokens: 100,
thinkingLevels: ["off", "low", "medium", "high"] as z.infer<typeof ThinkingLevelSchema>[],
cost: { input: 1, output: 2, cacheRead: 0, cacheWrite: 0 },
};
const bot = {
id,
name: "Pi",
isMain: true,
category: "chat",
avatarShape: "blob",
avatarColor: "orange",
avatarEyes: "marks",
modelProvider: null,
modelId: null,
thinkingLevel: "medium",
systemPrompt: "Hello",
createdAt: date,
updatedAt: date,
} as const;
const message = {
id,
conversationId: id,
role: "assistant",
content: "Hello",
status: "done",
runId: id,
errorCode: null,
usage: { input: 1 },
createdAt: date,
updatedAt: date,
} as const;
const custom = {
name: "Local",
baseUrl: "http://127.0.0.1:11434/v1",
api: "openai-completions" as const,
apiKey: "fake-key",
headers: { "X-Example": "value" },
compat: { supportsDeveloperRole: false },
models: [
{
id: "model",
name: "Model",
contextWindow: 1000,
maxTokens: 100,
input: ["text"] as "text"[],
reasoning: false,
},
],
};
const envelope = {
jsonrpc: "2.0",
method: "chat.delta",
params: { seq: 1, payload: { runId: id, messageId: id, text: "Hi" } },
} as const;
type Cases<P, R> = {
[K in keyof P & keyof R]: {
params: P[K];
result: R[K];
badParams: unknown;
badResult: unknown;
};
};
const workplace: MethodResults["workplaces.list"] = {
home: "/bot/home",
folders: [],
currentId: "home",
};
const permissions: MethodResults["permissions.get"] = {
levels: {
connector: "ask",
agent_delegation: "ask",
run_command: "ask",
computer: "never",
read_file: "always",
list_dir: "always",
write_file: "ask",
read_ai_config: "never",
read_messages: "never",
send_out: "never",
web: "ask",
},
network: { allowAll: true, domains: [] },
isolation: { available: true },
pathEntries: [],
sshHosts: { win: { enabled: true, identity: "id_ed25519" } },
};
const approval: MethodResults["approvals.pending"][number] = {
id,
botId: id,
runId: id,
messageId: id,
toolCallId: "call-1",
category: "run_command",
risk: "normal",
title: "Run command",
command: "ls",
facts: [{ kind: "program", value: "ls" }],
canRemember: true,
expiresAt: date,
isolation: { available: true },
status: "pending",
remembered: false,
createdAt: date,
resolvedAt: null,
};
const conversation = {
id,
kind: "dm",
botId: id,
piSessionFile: null,
title: "",
groupId: null,
threadOf: null,
archivedAt: null,
createdAt: date,
updatedAt: date,
} as const;
const memory = {
category: null,
id,
botId: id,
text: "Remember",
sourceMessageId: null,
createdAt: date,
updatedAt: date,
} as const;
const proposal = {
category: "work",
id,
botId: id,
text: "Remember",
messageId: id,
action: "add",
memoryId: null,
resolvedMemoryId: null,
status: "pending",
createdAt: date,
} as const;
const group = {
id,
name: "Team",
coordinatorBotId: id,
announcement: "",
autoRoundLimit: 4,
externalAgentStepContext: true,
paused: false,
workplace: { kind: "coordinator" },
members: [
{ botId: id, position: 0, joinedAt: date },
{ botId: "00000000-0000-4000-8000-000000000002", position: 1, joinedAt: date },
],
conversationId: id,
createdAt: date,
updatedAt: date,
} satisfies MethodResults["groups.get"];
const task = {
id,
groupId: id,
threadConversationId: id,
assigneeBotId: id,
title: "Task",
instructions: "Do it",
status: "open",
summary: null,
createdByBotId: id,
createdAt: date,
finishedAt: null,
} as const;
const sidebarEntry = {
conversationKey: `dm:${id}`,
pinnedAt: null,
groupId: null,
hiddenAt: null,
unread: false,
lastReadAt: null,
};
const sidebarGroup = { id, name: "Team", position: 0, collapsed: false, createdAt: date };
const team = {
format: "pibot-team",
version: 1,
bots: [
{
ref: "one",
category: "chat",
name: "Bot",
description: "Research",
systemPrompt: "Help",
avatarShape: "blob",
avatarColor: "violet",
avatarEyes: "marks",
model: null,
thinkingLevel: "medium",
permissionOverrides: {},
},
],
groups: [],
} satisfies MethodResults["teams.preview"]["template"];
const authState = { providerId: "anthropic", state: "connected" } as const;
const routineDraft = {
botId: id,
name: "晨报",
instructions: "Summarize",
triggers: [{ kind: "cron", expr: "30 8 * * *", timezone: "Asia/Shanghai" }],
} as const;
const routine = {
...routineDraft,
triggers: [{ id, routineId: id, config: routineDraft.triggers[0], state: {}, createdAt: date }],
workplace: { kind: "bot" },
preauth: [],
notify: "always",
maxDurationMin: 30,
carryLastResult: true,
output: { enabled: true, folder: null, period: "auto" },
workflow: null,
missedPolicy: null,
enabled: true,
id,
pausedReason: null,
lastScheduledAt: null,
topicConversationId: id,
createdAt: date,
updatedAt: date,
deletedAt: null,
version: 1,
} as const;
const routineRun = {
id,
routineId: id,
botId: id,
triggerId: null,
reason: "manual",
scheduledFor: date,
queuedAt: date,
queueExpiresAt: date,
maxDurationMin: 30,
startedAt: null,
finishedAt: null,
status: "scheduled",
runId: null,
conversationId: null,
triggerMessageId: null,
errorCode: null,
summary: null,
allowedOps: [],
activeMs: 0,
waitingMs: 0,
activeSince: null,
waitingSince: null,
waitExpiresAt: null,
createdAt: date,
} as const;
const routineProposal = {
id,
botId: id,
messageId: id,
payload: { draft: {}, missingFields: [], blockedPreauth: [] },
status: "open",
resolvedRoutineId: null,
dedupeKey: "tool:1",
createdAt: date,
resolvedAt: null,
} as const;
const routineSettings = {
missedPolicy: "catchup",
keepAwake: "on_ac",
pauseWhenAway: true,
} as const;
const routineCounts = { enabled: 1, awayPaused: 0, scheduled: 0, running: 0, waiting: 0 };
const backgroundState = {
state: "ready",
startedAt: date,
uptimeMs: 1000,
restartCount: 0,
at: date,
} as const;
const importStatus = {
importId: id,
source: "fixture",
state: "running",
topics: 0,
messages: 0,
reason: null,
} as const;
const methodCases = {
"import.detect": {
params: { source: "fixture" },
result: { available: true },
badParams: {},
badResult: {},
},
"import.preview": { params: { source: "fixture" }, result: null, badParams: {}, badResult: {} },
"import.start": {
params: { importId: id, botId: id },
result: importStatus,
badParams: {},
badResult: {},
},
"import.status": { params: { importId: id }, result: importStatus, badParams: {}, badResult: {} },
"import.cancel": { params: { importId: id }, result: importStatus, badParams: {}, badResult: {} },
"import.undo": {
params: { importId: id },
result: { ...importStatus, state: "undone" },
badParams: {},
badResult: {},
},
"acp.state": {
params: {},
result: { connected: false },
badParams: { unexpected: true },
badResult: { connected: true },
},
"acp.disconnect": {
params: {},
result: { ok: true },
badParams: { actor: "acp" },
badResult: { ok: false },
},
"memory.sortIntoPlace": {
params: { ownerInitiated: true, runId: id },
result: { status: "done", moves: 0, processed: 0, total: 0 },
badParams: { ownerInitiated: false },
badResult: { status: "done", moves: -1, processed: 0, total: 0 },
},
"memory.cancelSortIntoPlace": {
params: { runId: id },
result: { ok: true },
badParams: {},
badResult: { ok: false },
},
"memory.pickImport": {
params: {},
result: null,
badParams: { path: "/tmp/unauthorized" },
badResult: 42,
},
"memory.catalog": {
params: {},
result: [{ scope: "user", ownerId: "user", name: "user", archived: false }],
badParams: { after: 12 },
badResult: [{ scope: "user" }],
},
"memory.browse": {
params: { scope: "user", ownerId: "user", state: "all" },
result: {
items: [memory],
proposals: [],
undoable: [],
undoNext: null,
revision: 1,
activeCount: 1,
archivedCount: 0,
unusedCount: 0,
needsOrganization: false,
},
badParams: { scope: "user", ownerId: "user", state: "unknown" },
badResult: { items: [] },
},
"memory.details": {
params: { scope: "user", ownerId: "user", id },
result: { sources: [], history: [] },
badParams: { scope: "user", ownerId: "user", id, before: -1 },
badResult: { sources: [], history: [{ text: "invalid" }] },
},
"memory.manage": {
params: {
scope: "user",
ownerId: "user",
confirmed: true,
change: { action: "import", text: "Remember", category: null },
},
result: { status: "added", memory },
badParams: { scope: "user", ownerId: "user", confirmed: false, change: { action: "clear" } },
badResult: { status: "unknown" },
},
"botHooks.get": {
params: { botId: id },
result: {
botId: id,
config: { formatOnWrite: false, formatCommand: "", notifyOnCompletion: false },
},
badParams: { botId: "invalid" },
badResult: { botId: id },
},
"botHooks.set": {
params: {
botId: id,
config: { formatOnWrite: true, formatCommand: "pnpm format", notifyOnCompletion: false },
},
result: {
botId: id,
config: { formatOnWrite: true, formatCommand: "pnpm format", notifyOnCompletion: false },
},
badParams: {
botId: id,
config: { formatOnWrite: true, formatCommand: "", notifyOnCompletion: false },
},
badResult: {
botId: id,
config: { formatOnWrite: false, formatCommand: "", notifyOnCompletion: "yes" },
},
},
...remoteMethodCases,
"preview.read": {
params: { requestId: id, attachmentId: id, messageId: id },
result: { kind: "code", revision: "a".repeat(64), data: "", text: "" },
badParams: {},
badResult: {},
},
"preview.cancel": { params: { requestId: id }, result: null, badParams: {}, badResult: {} },
"preview.open": {
params: { attachmentId: id, messageId: id },
result: null,
badParams: {},
badResult: {},
},
"office.preview": {
params: { requestId: id, attachmentId: id, messageId: id },
result: {
format: "docx",
revision: "a".repeat(64),
content: { kind: "docx", blocks: [] },
warnings: [],
truncated: false,
total: 0,
},
badParams: {},
badResult: {},
},
"office.apps": {
params: { format: "xlsx" },
result: { apps: [], defaultAvailable: false },
badParams: { format: "exe" },
badResult: {},
},
"office.open": {
params: { attachmentId: id, messageId: id },
result: null,
badParams: { attachmentId: id, path: "/private" },
badResult: {},
},
"office.renderStep": {
params: { runId: id, messageId: id, toolCallId: "call-1" },
result: null,
badParams: { runId: id, messageId: id, toolCallId: "" },
badResult: {},
},
"office.renderSnapshot": {
params: { runId: id, messageId: id, toolCallId: "call-1", page: 2 },
result: { kind: "image", revision: "a".repeat(64), data: "AAAA" },
badParams: { runId: id, messageId: id, toolCallId: "call-1", page: 0 },
badResult: {},
},
"office.cancel": { params: { requestId: id }, result: null, badParams: {}, badResult: {} },
// Required entries for the existing exhaustive RPC table; no new test body.
"messages.selection": {
params: { conversationId: id, messageIds: [id] },
result: {
hash: "a".repeat(64),
count: 1,
preview: "hello",
defaultBotIds: [id],
attachmentCount: 0,
},
badParams: { conversationId: id, messageIds: [] },
badResult: { hash: "bad" },
},
"messages.transfer": {
params: {
conversationId: id,
messageIds: [id],
requestId: id,
selectionHash: "a".repeat(64),
destination: { kind: "bot", botId: id },
},
result: { requestId: id, state: "done", botId: id, conversationId: id, userMessageId: id },
badParams: { requestId: id },
badResult: { requestId: id, state: "done" },
},
"messages.transferStatus": {
params: { requestId: id },
result: null,
badParams: { requestId: "bad" },
badResult: { requestId: id, state: "unknown" },
},
"messages.translate": {
params: { conversationId: id, messageId: id, language: "zh" },
result: { text: "你好", language: "zh" },
badParams: { conversationId: id, messageId: id, language: "fr" },
badResult: { text: 1, language: "zh" },
},
"messages.handoff": {
params: { conversationId: id, messageIds: [id], language: "en" },
result: { text: "Goal", sourceCount: 1, limited: false },
badParams: { conversationId: id, messageIds: [] },
badResult: { text: "Goal", sourceCount: 151, limited: false },
},
...groupMethodCases,
...executionMethodCases,
...workspaceMethodCases,
...connectorMethodCases,
...connectorAppMethodCases,
...knowledgeMethodCases,
"execution.budget.get": {
params: { botId: id, conversationId: id },
result: executionBudget,
badParams: { botId: id },
badResult: { ...executionBudget, requests: -1 },
},
"browser.debug": {
params: { botId: id, conversationId: id },
result: browserDiagnostics,
badParams: { botId: id },
badResult: { ...browserDiagnostics, entries: null },
},
"browser.inspectPoint": {
params: { botId: id, conversationId: id, tabId: "t1", documentId: id, frameSeq: 1, x: 1, y: 1 },
result: browserElement,
badParams: { botId: id, conversationId: id, tabId: "t1", documentId: id, x: 1, y: 1 },
badResult: { ...browserElement, ref: "invalid" },
},
...computerMethodCases,
...browserMethodCases,
...browserExtensionMethodCases,
...skillMethodCases,
...credentialMethodCases,
"secrets.list": {
params: {},
result: { items: [] },
badParams: { limit: 0 },
badResult: { items: [{ value: "forbidden" }] },
},
"secrets.set": {
params: { name: "TOKEN", value: "fixture-value" },
result: {
secret: {
name: "TOKEN",
description: "",
assignment: { kind: "all" },
hasValue: true,
revision: 1,
createdAt: date,
updatedAt: date,
lastUsedAt: null,
},
},
badParams: { name: "invalid-name" },
badResult: { secret: {} },
},
"secrets.delete": {
params: { name: "TOKEN", expectedRevision: 1 },
result: { ok: true },
badParams: { name: "TOKEN" },
badResult: { ok: false },
},
...builtinMethodCases,
...roleCatalogMethodCases,
"externalAgents.detect": {
params: {},
result: {
isolation: "sandbox",
agents: [
{
agentId: "codex",
installed: true,
program: "/usr/local/bin/codex",
version: "codex 1",
adapter: { version: "2.6.0", bytes: 1, installed: true },
confirmedUnisolated: false,
},
],
},
badParams: { scan: true },
badResult: { isolation: "maybe", agents: [] },
},
"externalAgents.prewarm": {
params: { botId: id, conversationId: id },
result: { started: true },
badParams: { botId: id },
badResult: { started: "yes" },
},
"externalAgents.checkStatus": {
params: { botId: id, force: true },
result: { kind: "login_required" as const, checkedAt: date, command: "cursor-agent login" },
badParams: { botId: id, force: "yes" },
badResult: { kind: "expired", checkedAt: date, command: null },
},
"externalAgents.status": {
params: { botId: id },
result: { kind: "unknown" as const, checkedAt: null, command: null },
badParams: {},
badResult: { kind: "quota" },
},
"externalAgents.list": {
params: {},
result: {
bots: [
{
botId: id,
name: "Codex",
agentId: "codex",
custom: null,
adapterVersion: "2.6.0",
confirmedUnisolated: false,
},
],
},
badParams: { all: true },
badResult: { bots: [{ botId: "bad" }] },
},
"externalAgents.installAdapter": {
params: { agentId: "codex" },
result: { version: "2.6.0" },
badParams: { agentId: "codex2" },
badResult: {},
},
"externalAgents.removeAdapter": {
params: { agentId: "claude" },
result: { removed: true },
badParams: {},
badResult: { removed: "yes" },
},
"externalAgents.confirmUnisolated": {
params: { agentId: "cursor", confirmed: true },
result: { confirmed: true },
badParams: { agentId: "cursor", confirmed: false },
badResult: {},
},
"externalAgents.revokeUnisolated": {
params: { agentId: "custom", botId: id },
result: { revoked: true },
badParams: { agentId: "custom", botId: "bad" },
badResult: {},
},
"externalAgents.createBot": {
params: { agentId: "opencode" },
result: { botId: id },
badParams: {
agentId: "custom",
custom: { name: "x", command: "a\nb", args: [], readWrite: [], network: [] },
},
badResult: { botId: "bad" },
},
"externalAgents.setMemorySharing": {
params: { botId: id, enabled: true },
result: { enabled: true },
badParams: { botId: id, enabled: "yes" },
badResult: { enabled: "yes" },
},
"externalAgents.bot": {
params: { botId: id },
result: {
bot: {
botId: id,
name: "Codex",
agentId: "codex",
custom: null,
adapterVersion: "2.6.0",
confirmedUnisolated: false,
},
isolation: "sandbox",
detected: {
agentId: "codex",
installed: true,
program: "/usr/local/bin/codex",
version: "codex 1",
adapter: { version: "2.6.0", bytes: 1, installed: true },
confirmedUnisolated: false,
},
allowances: {
readWrite: ["~/.codex"],
readOnly: [],
network: ["api.openai.com"],
unixSockets: [],
},
},
badParams: { botId: "bad" },
badResult: { bot: null },
},
"externalAgents.sessionOptions": {
params: { botId: id, conversationId: id },
result: {
mode: { current: "auto", options: [{ id: "auto", name: "Auto" }] },
model: null,
settings: [],
commands: [],
refusedModel: null,
notices: [],
},
badParams: { botId: "bad" },
badResult: { mode: null },
},
"externalAgents.setOption": {
params: { botId: id, conversationId: id, kind: "mode", value: "auto" },
result: {
mode: { current: "auto", options: [{ id: "auto", name: "Auto" }] },
model: null,
settings: [],
commands: [],
refusedModel: null,
},
badParams: { botId: id, conversationId: id, kind: "effort", value: "x" },
badResult: { model: null },
},
"images.reuse": {
params: { botId: id, conversationId: id, sourceRunId: id, action: "save" },
result: { runId: id, assistantMessageId: id, conversationId: id },
badParams: {
botId: id,
conversationId: id,
sourceRunId: id,
action: "generate",
targetPath: "/tmp",
},
badResult: { runId: "bad", assistantMessageId: id, conversationId: id },
},
"models.images": {
params: { availableOnly: true, mode: "image-to-image", limit: 50 },
result: [
{
provider: "fake",
id: "paint",
name: "Paint",
modes: ["image-to-image"],
output: ["image"],
configured: true,
source: "custom",
recipient: "image.example.com",
},
],
badParams: { mode: "video", limit: 201 },
badResult: [{ provider: "fake", id: "paint" }],
},
"routines.resolveOnceTime": {
params: { localTime: "2026-11-01T01:30", timezone: "America/New_York" },
result: { status: "ambiguous", at: null, candidates: [] },
badParams: { localTime: "bad", timezone: "UTC" },
badResult: { status: "resolved", at: "bad", candidates: [] },
},
"routines.pickFolder": {
params: undefined,
result: "/fixture",
badParams: { path: "/arbitrary" },
badResult: "relative",
},
"routines.triggerSources": {
params: { botId: id },
result: {
connections: [{ connectorId: id, name: "GitHub", checks: ["github.assigned_issues"] }],
calendars: [],
blocked: [],
},
badParams: {},
badResult: { connections: [{ connectorId: id, name: "GitHub", checks: ["unknown"] }] },
},
"routines.calendarList": {
params: { botId: id, connectorId: id },
result: { items: [{ id: "cal-1", title: "Work" }] },
badParams: { botId: id },
badResult: { items: [{ id: "", title: "Work" }] },
},
"routines.rows": {
params: { ids: [id] },
result: {
at: date,
pausedUntil: null,
rows: [{ routineId: id, nextAt: date, active: null, lastResult: null, attentionCount: 0 }],
},
badParams: { ids: [] },
badResult: {},
},
"routines.planned": {
params: { date: "2026-10-09", timezone: "Asia/Shanghai" },
result: { from: date, to: date, asOf: date, points: [], nextCursor: null },
badParams: { date: "bad", timezone: "Asia/Shanghai" },
badResult: {},
},
"routines.summary": {
params: undefined,
result: {
counts: routineCounts,
next: null,
pausedUntil: null,
background: backgroundState,
at: date,
},
badParams: { limit: 10 },
badResult: {},
},
"groups.folders.setPrimary": {
params: { groupId: id, folderId: null },
result: group,
badParams: { groupId: id, folderId: "bad" },
badResult: {},
},
"routines.validateCron": {
params: { expr: "*/5 * * * *", timezone: "UTC" },
result: { minimumMinutes: 5, issue: null },
badParams: {},
badResult: {},
},
"routines.list": {
params: {},
result: [{ ...routine, triggers: [...routine.triggers], preauth: [] }],
badParams: { limit: 201 },
badResult: [{}],
},
"routines.get": {
params: { id },
result: { ...routine, triggers: [...routine.triggers], preauth: [] },
badParams: {},
badResult: {},
},
"routines.create": {
params: { ...routineDraft, triggers: [...routineDraft.triggers] },
result: { ...routine, triggers: [...routine.triggers], preauth: [] },
badParams: { ...routineDraft, name: "" },
badResult: {},
},
"routines.update": {
params: { id, patch: { name: "新名字" }, expectedVersion: 1 },
result: { ...routine, triggers: [...routine.triggers], preauth: [] },
badParams: { id, patch: {}, expectedVersion: 1 },
badResult: {},
},
"routines.delete": {
params: { id },
result: { ok: true },
badParams: {},
badResult: { ok: false },
},
"routines.setEnabled": {
params: { id, enabled: false },
result: { ...routine, triggers: [...routine.triggers], preauth: [] },
badParams: { id },
badResult: {},
},
"routines.runNow": { params: { id }, result: { runId: id }, badParams: {}, badResult: {} },
"routines.trialRun": {
params: { ...routineDraft, triggers: [...routineDraft.triggers] },
result: { runId: id },
badParams: { ...routineDraft, triggers: [] },
badResult: {},
},
"routines.trialResult": {
params: { runId: id },
result: { ...routineRun, allowedOps: [], reason: "trial", routineId: null },
badParams: {},
badResult: {},
},
"routines.runLedger": {
params: { id },
result: {
routineRunId: id,
occurrenceId: id,
attempts: [id],
periodKey: null,
outputFolder: null,
outputSkipped: "disabled",
inputs: [],
outputs: [],
sends: [],
},
badParams: {},
badResult: {},
},
"routines.resumeRun": {
params: { id },
result: { runId: id },
badParams: {},
badResult: {},
},
"routines.runs": {
params: { id, limit: 50 },
result: [{ ...routineRun, allowedOps: [] }],
badParams: { id, limit: 201 },
badResult: [{}],
},
"routines.history": {
params: { limit: 200, from: date },
result: [{ ...routineRun, allowedOps: [], taskName: null, taskDeleted: false, bot: null }],
badParams: { limit: 201 },
badResult: [{}],
},
"routines.settings.get": {
params: undefined,
result: routineSettings,
badParams: { extra: true },
badResult: { keepAwake: "auto" },
},
"routines.settings.set": {
params: { keepAwake: "never" },
result: routineSettings,
badParams: { missedPolicy: "bad" },
badResult: { keepAwake: "bad" },
},
"routines.proposals": {
params: {},
result: [{ ...routineProposal, payload: { draft: {}, missingFields: [], blockedPreauth: [] } }],
badParams: { limit: 0 },
badResult: [{}],
},
"routines.proposal.resolve": {
params: { proposalId: id, accept: false },
result: {
proposal: {
...routineProposal,
payload: { draft: {}, missingFields: [], blockedPreauth: [] },
},
routine: null,
},
badParams: { proposalId: id },
badResult: {},
},
"routines.preauth.list": { params: {}, result: [], badParams: { limit: 201 }, badResult: [{}] },
"routines.preauth.revoke": {
params: { id },
result: { ok: true },
badParams: {},
badResult: { ok: false },
},
"routines.pauseAll": {
params: { until: date },
result: { ok: true },
badParams: { until: "tomorrow" },
badResult: { ok: false },
},
"routines.resumeAll": {
params: undefined,
result: { ok: true },
badParams: { extra: true },
badResult: { ok: false },
},
"routines.resumeAway": {
params: {},
result: { ok: true },
badParams: { ids: ["bad"] },
badResult: { ok: false },
},
"routines.missed.resolve": {
params: { runId: id, action: "skip" },
result: { ...routineRun, allowedOps: [] },
badParams: { runId: id, action: "bad" },
badResult: {},
},
"routines.timeline": {
params: { date: "2026-10-09", timezone: "Asia/Shanghai", source: "power" },
result: {
source: "power",
events: [{ id, kind: "start", at: date }],
context: { state: "unknown", event: null },
},
badParams: { date: "2026-10-09", timezone: "Bad/Zone", source: "power" },
badResult: { source: "power", events: [{}] },
},
"providers.selectAuth": {
params: { providerId: "anthropic", auth: "oauth" },
result: { ok: true },
badParams: {},
badResult: { ok: false },
},
"providers.loginStep": {
params: { providerId: "anthropic" },
result: null,
badParams: {},
badResult: {},
},
"providers.loginInput": {
params: { providerId: "anthropic", promptId: id, value: "synthetic" },
result: { ok: true },
badParams: {},
badResult: { ok: false },
},
"sidebar.groups.list": {
params: {},
result: [sidebarGroup],
badParams: { unexpected: true },
badResult: [{ id }],
},
"providers.getConfig": {
params: { providerId: "cloudflare-workers-ai" },
result: {
providerId: "cloudflare-workers-ai",
accountId: "account",
},
badParams: {},
badResult: { providerId: "cloudflare-ai-gateway", accountId: "account" },
},
"bots.create": {
params: { description: "Research" },
result: bot,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"bots.duplicate": {
params: { botId: id },
result: bot,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"bots.archived": {
params: {},
result: [bot],
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"bots.restore": {
params: { botId: id },
result: bot,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"bots.archive": {
params: { botId: id },
result: { ok: true },
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"bots.delete": {
params: { botId: id, confirmed: true },
result: { ok: true },
badParams: { botId: id, confirmed: false },
badResult: { unexpected: true },
},
"bots.profile": {
params: { botId: id },
result: {
bot,
memories: [memory],
proposals: [proposal],
permissionOverrides: {},
undoable: [{ ...proposal, status: "accepted", resolvedMemoryId: memory.id }],
},
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"topics.list": {
params: { botId: id, query: "Topic" },
result: [{ ...conversation, messageCount: 2, isCurrent: true }],
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"topics.archive": {
params: { botId: id, topicId: id },
result: { ok: true },
badParams: { botId: id },
badResult: { ok: false },
},
"topics.restore": {
params: { botId: id, topicId: id },
result: conversation,
badParams: { botId: id },
badResult: { unexpected: true },
},
"topics.create": {
params: { botId: id },
result: conversation,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"topics.rename": {
params: { botId: id, topicId: id, title: "Renamed" },
result: { ...conversation, title: "Renamed" },
badParams: { botId: id, topicId: id, title: " " },
badResult: { unexpected: true },
},
"topics.workplace.get": {
params: { botId: id, topicId: id },
result: {
topicId: id,
folderId: null,
revision: 0,
busy: false,
workplace: { home: "/tmp/home", folders: [], currentId: "home" },
},
badParams: { unexpected: true },
badResult: { unexpected: true },
},
// An ACP client continues an existing topic.
"topics.acp.attach": {
params: { botId: id, topicId: id, cwd: "/tmp/work" },
result: { topicId: id },
badParams: { botId: id, topicId: id },
badResult: { unexpected: true },
},
"topics.workplace.set": {
params: { botId: id, topicId: id, folderId: "home" },
result: {
topicId: id,
folderId: "home",
revision: 1,
busy: false,
workplace: { home: "/tmp/home", folders: [], currentId: "home" },
},
badParams: { botId: id, topicId: id, folderId: "invalid" },
badResult: { unexpected: true },
},
// Topic workplace fixtures.
"topics.workplace.update": {
params: { botId: id, topicId: id, selection: { primary: "home", readonly: [id] } },
result: {
topicId: id,
folderId: "home",
revision: 2,
busy: false,
readonly: [id],
workplace: { home: "/tmp/home", folders: [], currentId: "home" },
},
badParams: { botId: id, topicId: id, selection: { primary: id, readonly: [id] } },
badResult: { unexpected: true },
},
"topics.workplace.initial": {
params: { botId: id },
result: {
selection: { primary: "home", readonly: [] },
workplace: { home: "/tmp/home", folders: [], currentId: "home" },
},
badParams: { botId: id, topicId: id },
badResult: { selection: { primary: "bad", readonly: [] } },
},
"topics.switch": {
params: { botId: id, topicId: id },
result: conversation,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"groups.create": {
params: { name: "Team", botIds: group.members.map((m) => m.botId) },
result: group,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"groups.update": {
params: { groupId: id, paused: true },
result: group,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"groups.addMember": {
params: { groupId: id, botId: id },
result: group,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"groups.removeMember": {
params: { groupId: id, botId: id },
result: group,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"groups.archive": { params: { groupId: id }, result: group, badParams: {}, badResult: {} },
"groups.restore": { params: { groupId: id }, result: group, badParams: {}, badResult: {} },
"groups.plan.current": { params: { groupId: id }, result: null, badParams: {}, badResult: {} },
"groups.list": {
params: {},
result: [group],
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"groups.topics.list": { params: { groupId: id }, result: [], badParams: {}, badResult: [{}] },
"groups.topics.create": { params: { groupId: id }, result: group, badParams: {}, badResult: {} },
"groups.topics.archive": {
params: { groupId: id, topicId: id },
result: group,
badParams: {},
badResult: {},
},
"groups.topics.rename": {
params: { groupId: id, topicId: id, title: "Renamed" },
result: {
id,
botId: null,
groupId: id,
kind: "group",
piSessionFile: null,
title: "Renamed",
createdAt: date,
updatedAt: date,
archivedAt: null,
folders: [],
primaryFolderId: null,
workspaceRevision: 0,
},
badParams: {},
badResult: {},
},
"groups.topics.restore": {
params: { groupId: id, topicId: id },
result: {
id,
botId: null,
groupId: id,
kind: "group",
piSessionFile: null,
title: "Topic",
createdAt: date,
updatedAt: date,
archivedAt: null,
folders: [],
primaryFolderId: null,
workspaceRevision: 0,
},
badParams: {},
badResult: {},
},
"groups.topics.switch": {
params: { groupId: id, topicId: id },
result: group,
badParams: {},
badResult: {},
},
"groups.topics.pickFolder": {
params: { groupId: id },
result: null,
badParams: {},
badResult: {},
},
"groups.topics.history": {
params: { groupId: id, topicId: id },
result: [],
badParams: {},
badResult: [{}],
},
"groups.get": {
params: { groupId: id },
result: group,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"groups.files.list": {
params: { groupId: id, requestId: id },
result: {
entries: [{ name: "existing.txt", path: "existing.txt", kind: "file" }],
rootToken: "token",
truncated: false,
},
badParams: { groupId: id, requestId: id, path: "../outside" },
badResult: { unexpected: true },
},
"groups.files.open": {
params: { groupId: id, requestId: id, path: "existing.txt", rootToken: "token" },
result: { ok: true },
badParams: { groupId: id, requestId: id, path: "/outside", rootToken: "token" },
badResult: { unexpected: true },
},
"groups.files.preview": {
params: { groupId: id, requestId: id, path: "file.md", rootToken: "token" },
result: { kind: "markdown", revision: "a".repeat(64), data: "", text: "preview" },
badParams: { groupId: id, requestId: id, path: "../outside", rootToken: "token" },
badResult: { unexpected: true },
},
"groups.files.cancel": {
params: { groupId: id, requestId: id },
result: { ok: true },
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"groups.delete": {
params: { groupId: id, confirmed: true },
result: { ok: true },
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"groups.state": {
params: { groupId: id },
result: { cycleId: null, rounds: 0, limited: false },
badParams: { groupId: "bad" },
badResult: { unexpected: true },
},
"chat.compact": {
params: { botId: id, conversationId: id, requestId: id, fork: false },
result: { conversationId: id, mechanical: false },
badParams: { botId: id, conversationId: id, fork: false },
badResult: { conversationId: "bad", mechanical: false },
},
"chat.compact.cancel": {
params: { botId: id, conversationId: id, requestId: id },
result: { ok: true },
badParams: { botId: id },
badResult: { ok: false },
},
"chat.contextHint": {
params: {
botId: id,
conversationId: id,
dismiss: true,
modelProvider: "openrouter",
modelId: "example/model",
},
result: { show: false },
badParams: { botId: id },
badResult: { show: "yes" },
},
"chat.runs": {
params: { botId: id },
result: [],
badParams: {},
badResult: { unexpected: true },
},
"groups.tasks": {
params: { groupId: id },
result: [task],
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"groups.folders.used": {
params: { groupId: id },
result: { folders: [{ id, name: "site" }] },
badParams: { groupId: id, path: "/not-accepted" },
badResult: { folders: [{ id: "invalid" }] },
},
"groups.folders.reveal": {
params: { groupId: id },
result: { ok: true },
badParams: { groupId: id, path: "/not-accepted" },
badResult: { ok: false },
},
"groups.folders.add": {
params: { groupId: id },
result: group,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"groups.folders.remove": {
params: { groupId: id, folderId: id },
result: group,
badParams: { folderId: "bad" },
badResult: { unexpected: true },
},
"chat.retryPreview": {
params: { botId: id, conversationId: id, messageId: id },
result: { hash: "a".repeat(64), fileCount: 0, restoreFiles: true },
badParams: {},
badResult: {},
},
"chat.retryFromMessage": {
params: {
botId: id,
conversationId: id,
messageId: id,
requestId: id,
hash: "a".repeat(64),
confirmed: true,
},
result: { requestId: id, state: "done", botId: id, conversationId: id },
badParams: {},
badResult: {},
},
"chat.retryStatus": {
params: { botId: id, conversationId: id, messageId: id, requestId: id },
result: null,
badParams: {},
badResult: {},
},
"chat.retryDraft": {
params: { botId: id, conversationId: id },
result: { text: "draft", attachments: [] },
badParams: {},
badResult: {},
},
"runs.retry": {
params: {
source: "group",
botId: id,
conversationId: id,
failedRunId: id,
groupId: id,
taskId: id,
},
result: { runId: id, threadId: id },
badParams: { source: "group", botId: id, conversationId: id, failedRunId: id },
badResult: { runId: id, threadId: null },
},
"runs.resume": {
params: { botId: id, conversationId: id, runId: id },
result: { runId: id },
badParams: { botId: id, conversationId: id },
badResult: { runId: "" },
},
"runs.receipt": {
params: { runId: id },
result: (() => {
const none = { total: 0, items: [], others: 0 };
return {
version: 1,
runId: id,
messageId: id,
botId: id,
conversationId: id,
groupId: null,
source: "chat",
outcome: "done",
reasonCode: null,
startedAt: null,
finishedAt: null,
inputs: {
files: none,
web: none,
searches: none,
connectors: none,
phone: none,
messages: 0,
browser: 0,
},
outputs: { files: [], filesTotal: 0, added: 0, removed: 0, attachments: 0, images: 0 },
approvals: { asked: 0, allowed: 0, denied: 0, unanswered: 0, automatic: 0 },
actions: { commands: 0, failedCommands: 0, sentDrafts: 0, delegated: 0, blocked: 0 },
cost: null,
model: null,
childTasks: { total: 0, done: 0, failed: 0, running: 0 },
evidence: { commands: 0, screenshots: 0, reviews: 0 },
unverified: { items: [], total: 0, failedCheck: null, openTodos: 0, todoTotal: 0 },
} as const;
})(),
badParams: {},
badResult: { version: 2 },
},
"runs.cleanup": {
params: { olderThanDays: 30, confirmed: true },
result: { runs: 2, events: 8, executions: 1, sessionFiles: 1, resultFiles: 1 },
badParams: { olderThanDays: 0, confirmed: true },
badResult: { runs: -1, events: 0, executions: 0, sessionFiles: 0, resultFiles: 0 },
},
"runs.events": {
params: { runId: id, afterSeq: 0, limit: 50 },
result: {
events: [
{
seq: 1,
runId: id,
conversationId: id,
kind: "run.sealed",
at: date,
outcome: { status: "done", stopReason: "stop", errorCode: null },
},
],
nextSeq: 1,
settled: true,
},
badParams: { runId: "bad", afterSeq: -1 },
badResult: { events: [], nextSeq: -1 },
},
"groups.tasks.summary": {
params: { groupId: id, messageIds: [id] },
result: { openCount: 0, closedCount: 0, batches: [], collaborations: [] },
badParams: { origin: "other" },
badResult: { openCount: -1 },
},
"groups.execution.tasks": {
params: { groupId: id },
result: { items: [], nextBefore: null },
badParams: {},
badResult: [{}],
},
"groups.tasks.worktree.integrate": {
params: {
groupId: id,
taskId: id,
requestId: id,
expectedVersion: 1,
expectedTargetHead: "a".repeat(40),
expectedWorktreeHead: "b".repeat(40),
},
result: workspaceMethodCases["worktrees.integrate"].result,
badParams: {},
badResult: {},
},
"groups.tasks.worktree.remove": {
params: { groupId: id, taskId: id, requestId: id, expectedVersion: 1 },
result: workspaceMethodCases["worktrees.remove"].result,
badParams: {},
badResult: {},
},
"groups.tasks.history": {
params: { groupId: id, taskId: id },
result: { messages: [], nextBefore: null },
badParams: {},
badResult: [],
},
"groups.tasks.execution": {
params: { groupId: id, taskId: id },
result: { items: [], nextBefore: null, checkpoint: null, resultMessageId: null },
badParams: {},
badResult: [{}],
},
"groups.tasks.resolve": {
params: { groupId: id, taskId: id, status: "done", summary: "已完成", confirmed: true },
result: task,
badParams: { groupId: id, taskId: id, status: "done", summary: "已完成", confirmed: false },
badResult: { unexpected: true },
},
"groups.workflow.resolve": {
params: {
groupId: id,
workflowRunId: id,
stepId: "research",
action: "retry",
confirmed: true,
},
result: { ok: true },
badParams: {
groupId: id,
workflowRunId: id,
stepId: "research",
action: "retry",
confirmed: false,
},
badResult: { ok: false },
},
"groups.memory.list": {
params: { groupId: id },
result: { memories: [memory], proposals: [proposal] },
badParams: { groupId: 1 },
badResult: {},
},
"groups.memory.save": {
params: { groupId: id, text: "Group note", category: null },
result: memory,
badParams: { groupId: id, text: "" },
badResult: {},
},
"groups.memory.remove": {
params: { groupId: id, id, confirmed: true },
result: { ok: true },
badParams: { groupId: id, id },
badResult: { ok: false },
},
"groups.memory.resolve": {
params: { groupId: id, proposalId: id, accept: true },
result: { proposal, memory },
badParams: { groupId: id },
badResult: {},
},
"memory.list": {
params: { botId: id },
result: [memory],
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"memory.status": {
params: { botId: id },
result: { activeCount: 1, archivedCount: 0, unusedCount: 0, needsOrganization: false },
badParams: {},
badResult: { activeCount: -1 },
},
"memory.project": {
params: { path: "/Users/me/project" },
result: { projectId: null },
badParams: { path: "" },
badResult: { projectId: 1 },
},
"memory.summary": {
params: { scope: "user", ownerId: "user" },
result: { activeCount: 1, archivedCount: 0, unusedCount: 0, needsOrganization: false },
badParams: { botId: id },
badResult: { activeCount: -1 },
},
"memory.update": {
params: { botId: id, id, category: "how_to" },
result: memory,
badParams: { botId: id, id },
badResult: { unexpected: true },
},
"memory.remove": {
params: { botId: id, id },
result: { ok: true },
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"memory.clear": {
params: { botId: id },
result: { ok: true },
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"memory.resolve": {
params: { proposalId: id, accept: true },
result: { proposal, memory },
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"personalTodos.create": {
params: { requestId: id, title: "Item", dueAt: null },
result: {
id,
title: "Item",
dueAt: null,
status: "open",
sourceBotId: null,
sourceConversationId: null,
createdAt: date,
updatedAt: date,
},
badParams: { requestId: id, title: "" },
badResult: {},
},
"personalTodos.update": {
params: { id, title: "Item", dueAt: null },
result: {
id,
title: "Item",
dueAt: null,
status: "open",
sourceBotId: null,
sourceConversationId: null,
createdAt: date,
updatedAt: date,
},
badParams: { id, title: "" },
badResult: {},
},
"personalTodos.delete": {
params: { id, confirmed: true },
result: null,
badParams: { id, confirmed: false },
badResult: {},
},
"personalTodos.list": {
params: {},
result: [],
badParams: { limit: 0 },
badResult: [{ unexpected: true }],
},
"personalTodos.undatedCount": { params: undefined, result: 0, badParams: {}, badResult: -1 },
"personalTodos.counts": {
params: undefined,
result: { open: 2, done: 9 },
badParams: {},
badResult: { open: -1, done: 0 },
},
"personalTodos.setStatus": {
params: { id, status: "done" },
result: {
id,
title: "Item",
dueAt: null,
status: "done",
sourceBotId: null,
sourceConversationId: null,
createdAt: date,
updatedAt: date,
},
badParams: { id, status: "unknown" },
badResult: { unexpected: true },
},
"inbox.list": {
params: { kind: "memory" },
result: [
{
kind: "memory",
cursor: `${date}|memory|${id}`,
proposal,
conversationId: id,
conversationKind: "dm",
},
],
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"inbox.counts": {
params: undefined,
result: { approval: 2, memory: 1, provider: 0 },
badParams: { unexpected: true },
badResult: { approval: -1, memory: 1, provider: 0 },
},
"inbox.dismissBackgroundTask": {
params: { task: "memory_extraction", subject: "bot-1", reasonCode: "no_model" },
result: { ok: true },
badParams: { task: "nope", subject: "bot-1", reasonCode: "no_model" },
badResult: { ok: false },
},
"sidebar.list": {
params: {},
result: { entries: [sidebarEntry], groups: [sidebarGroup] },
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"sidebar.update": {
params: { conversationKey: sidebarEntry.conversationKey, unread: true },
result: sidebarEntry,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"sidebar.open": {
params: { conversationKey: sidebarEntry.conversationKey },
result: sidebarEntry,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"sidebar.read": {
params: { conversationKey: sidebarEntry.conversationKey },
result: sidebarEntry,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"sidebar.groups.create": {
params: { name: "Team" },
result: sidebarGroup,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"sidebar.groups.update": {
params: { id, name: "Team" },
result: sidebarGroup,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"sidebar.groups.remove": {
params: { id },
result: { ok: true },
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"search.query": {
params: { query: "Pi" },
result: { bots: [bot], groups: [group], messages: [message] },
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"providers.setCredentials": {
params: {
providerId: "azure",
endpoint: "https://example.com",
apiVersion: "2025-04-01-preview",
deployments: { model: "deployment" },
apiKey: "synthetic-key",
},
result: { ok: true },
badParams: {
providerId: "cloudflare-ai-gateway",
accountId: "account",
apiToken: "synthetic-token",
},
badResult: { unexpected: true },
},
"providers.authState": {
params: { providerId: "anthropic" },
result: authState,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"providers.login": {
params: { providerId: "anthropic", riskAcknowledged: true },
result: authState,
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"providers.logout": {
params: { providerId: "anthropic" },
result: { ok: true },
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"providers.cancelLogin": {
params: { providerId: "anthropic" },
result: { ok: true },
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"search.getConfig": {
params: {},
result: { provider: "duckduckgo", configured: true, disclosed: false },
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"search.setConfig": {
params: { provider: "keyless" },
result: { provider: "keyless", configured: true, disclosed: false },
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"search.disclose": {
params: { provider: "searxng", expectedEndpoint: "http://127.0.0.1:8888" },
result: { ok: true },
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"search.removeConfig": {
params: {},
result: { ok: true },
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"teams.export": {
params: { botIds: [id] },
result: { saved: true },
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"teams.previewSkillSource": {
params: {
botId: id,
source: {
host: "github.com",
repository: "example/repo",
ref: "main",
subpath: "skills/example",
url: "https://github.com/example/repo/tree/main/skills/example",
},
contentHash: "a".repeat(64),
},
result: {
previewId: id,
botId: id,
document: { name: "Example", description: "Example", body: "Example", params: [] },
source: "zip",
sourceName: "example",
files: [{ path: "SKILL.md", bytes: 7, text: true, script: false }],
totalBytes: 7,
skipped: 0,
expiresAt: date,
},
badParams: {
botId: id,
source: { host: "github.com", url: "https://user:[email protected]/example/repo" },
contentHash: "a".repeat(64),
},
badResult: {},
},
"teams.preview": {
params: { file: "/tmp/team.pibot" },
result: {
previewId: id,
template: team,
models: [
{ ref: "one", preferred: null, resolved: null, available: false, thinkingLevel: "off" },
],
expiresAt: date,
},
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"teams.import": {
params: { previewId: id },
result: {
botIds: [id],
groupIds: [],
sidebarGroupId: id,
skippedSkills: [{ botId: id, name: "Weekly report" }],
},
badParams: { unexpected: true },
badResult: { unexpected: true },
},
"teams.pickFile": { params: undefined, result: null, badParams: { file: "x" }, badResult: 5 },
"teams.cancel": {
params: {},
result: { ok: true },
badParams: { previewId: "bad" },
badResult: {},
},
"chat.externalImageStatus": {
params: { botId: id, messageId: id, url: "https://example.com/image.png" },
result: { allowed: true },
badParams: { botId: id, messageId: id, url: "data:image/png;base64,abc" },
badResult: { allowed: "yes" },
},
"chat.loadExternalImage": {
params: {
botId: id,
messageId: id,
url: "https://example.com/image.png",
requestId: id,
confirmed: true,
},
result: { status: "loaded", image },
badParams: {
botId: id,
messageId: id,
url: "https://a:[email protected]/img",
requestId: id,
confirmed: true,
},
badResult: { status: "loaded", image: { ...image, mimeType: "text/plain" } },
},
"chat.cancelExternalImage": {
params: { requestId: id },
result: { ok: true },
badParams: { requestId: "bad" },
badResult: { ok: false },
},
"chat.attachment": {
params: { id },
result: image,
badParams: { id: "bad" },
badResult: { ...image, mimeType: "text/plain" },
},
"chat.attachmentPreview": {
params: { id },
result: image,
badParams: { id: "bad" },
badResult: { ...image, mimeType: "text/plain" },
},
"chat.revealOverflow": {
params: { messageId: id },
result: { ok: true },
badParams: { messageId: "invalid" },
badResult: { ok: false },
},
"chat.revealAttachment": {
params: { id, messageId: id },
result: { ok: true },
badParams: { id, messageId: "invalid" },
badResult: { ok: false },
},
"chat.openAttachment": {
params: { id },
result: { ok: true },
badParams: { path: "/untrusted" },
badResult: { ok: false },
},
"workplaces.list": {
params: { botId: id },
result: workplace,
badParams: { botId: "bad" },
badResult: { ...workplace, currentId: "bad" },
},
"workplaces.add": {
params: { botId: id },
result: workplace,
badParams: { botId: id, path: "/untrusted" },
badResult: { ...workplace, folders: ["bad"] },
},
"workplaces.remove": {
params: { botId: id, folderId: id },
result: workplace,
badParams: { botId: id, folderId: "home" },
badResult: { ...workplace, home: null },
},
"workplaces.setCurrent": {
params: { botId: id, folderId: "home" },
result: workplace,
badParams: { botId: id, folderId: "bad" },
badResult: { ...workplace, currentId: 1 },
},
"workplaces.pick": {
params: { botId: id, create: true },
result: { folder: { id, path: "/work/site", name: "site", lastUsedAt: date } },
badParams: { botId: id, path: "/untrusted" },
badResult: { folder: { id, path: "" } },
},
"remote.workplaceMove.resolve": {
params: { noticeId: id, accept: true },
result: { ok: true },
badParams: { noticeId: id },
badResult: { ok: false },
},
"workplaces.browse": {
params: { location: `runner:${"a".repeat(64)}`, path: "C:\\Users" },
result: {
platform: "win32",
path: "C:\\Users",
parent: "C:\\",
top: false,
folders: [{ name: "me", path: "C:\\Users\\me" }],
truncated: false,
},
badParams: { location: "local" },
badResult: {
platform: "win32",
path: "",
parent: null,
top: false,
folders: [],
truncated: false,
},
},
"workplaces.reveal": {
params: { botId: id, folderId: "home" },
result: { ok: true },
badParams: { botId: id, folderId: "home", path: "/not-accepted" },
badResult: { ok: false },
},
"workplaces.used": {
params: { botId: id },
result: {
folders: [
{
id,
name: "site",
path: "/work/site",
association: "user",
lastUsedAt: date,
topics: [{ id, title: "Fix the home page" }],
topicCount: 1,
routineCount: 0,
},
],
},
badParams: { botId: "bad" },
badResult: { folders: [{ id, name: "site" }] },
},
"workplaces.forget": {
params: { botId: id, folderId: id },
result: { ok: true, inUse: 2 },
badParams: { botId: id, folderId: "home" },
badResult: { ok: true, inUse: -1 },
},
"approvals.resolve": {
params: { id, decision: "allow", remember: false },
result: { ok: true },
badParams: { id, decision: "skip", remember: false },
badResult: { ok: false },
},
"approvals.addWritableFolder": {
params: { id },
result: { added: true },
badParams: { id, path: "/tmp/untrusted" },
badResult: { added: "true" },
},
"approvals.pending": {
params: {},
result: [approval],
badParams: { botId: "bad" },
badResult: [{ ...approval, status: "unknown" }],
},
"permissions.get": {
params: undefined,
result: permissions,
badParams: { secret: true },
badResult: { ...permissions, levels: {} },
},
"permissions.paths.discover": {
params: { source: "process" },
result: { paths: ["/usr/bin"], source: "process" },
badParams: { source: "terminal", command: "arbitrary" },
badResult: { paths: "invalid", source: "terminal" },
},
"permissions.set": {
params: { levels: { web: "ask" }, network: { allowAll: false } },
result: permissions,
badParams: { isolation: { available: true } },
badResult: { ...permissions, network: { allowAll: "yes", domains: [] } },
},
"permissions.allowBlockedWebsite": {
params: { noticeId: id, scope: "bot" },
result: permissions,
badParams: { noticeId: "bad", scope: "unknown" },
badResult: { ...permissions, network: { allowAll: "yes", domains: [] } },
},
"permissions.sshHosts.list": {
params: undefined,
result: {
hosts: [
{ alias: "win", status: "needs_key", enabled: false, hasKey: false },
{
alias: "build-server",
status: "ready",
enabled: true,
hasKey: true,
identity: "id_ed25519",
},
{ alias: "orb", status: "unsupported", reason: "proxy", enabled: false, hasKey: false },
],
identities: ["id_ed25519", "id_rsa"],
},
badParams: { host: "win" },
badResult: {
hosts: [{ alias: "-win", status: "needs_key", enabled: false, hasKey: false }],
identities: [],
},
},
"grants.list": {
params: { botId: id },
result: [
{
id,
botId: id,
category: "web",
scope: { kind: "domain", domain: "example.com" },
createdAt: date,
revokedAt: null,
},
],
badParams: { limit: 201 },
badResult: [
{
id,
botId: id,
category: "web",
scope: { kind: "folder", path: "/tmp" },
createdAt: date,
revokedAt: null,
},
],
},
"grants.revoke": {
params: { id },
result: { ok: true },
badParams: { id: "bad" },
badResult: { ok: false },
},
"audit.counts": { params: {}, result: [], badParams: { botId: "bad" }, badResult: [{}] },
"routines.history.count": { params: {}, result: 0, badParams: { from: "bad" }, badResult: -1 },
"audit.list": {
params: { kind: "policy.denied", limit: 200 },
result: [
{
id,
at: date,
botId: id,
kind: "policy.denied",
summary: "Denied",
detail: {
reason: "sudo",
reasonCode: "privilege_escalation_denied",
toolName: "run_command",
target: "sudo",
botName: "Pi",
},
runId: null,
},
{
id,
at: date,
botId: id,
kind: "collaboration.queued",
summary: "Queued",
detail: {
taskTitle: "Introduce yourself",
targetBotName: "Writer",
collaborationAction: "assign",
botRole: "coordinator",
internal: false,
},
runId: null,
},
{
id,
at: date,
botId: id,
kind: "oauth.changed",
summary: "Legacy",
detail: { authEvent: "oauth.connected", providerName: "ChatGPT" },
runId: null,
},
],
badParams: { limit: 201 },
badResult: [
{ id, at: date, botId: id, kind: "unknown", summary: "Denied", detail: {}, runId: null },
],
},
"diagnostics.snapshot": {
params: undefined,
result: {
schemaVersion: 1,
capturedAt: date,
connections: [],
connectionsTruncated: false,
permissions: {
accessibility: { state: "unknown", nativeStatus: null, observedAt: null },
screenRecording: { state: "unknown", nativeStatus: null, observedAt: null },
contacts: { state: "unknown", nativeStatus: null, observedAt: null },
calendar: { state: "unknown", nativeStatus: null, observedAt: null },
},
runs: [],
tools: [],
},
badParams: { includeMessages: true },
badResult: { schemaVersion: 1, messages: [] },
},
"runs.readLog": {
params: { runId: id, toolCallId: "call_1", offset: 0, limit: 262144 },
result: { text: "日志", offset: 0, nextOffset: null, totalBytes: 6, truncated: false },
badParams: { runId: id, limit: 262145 },
badResult: { text: "", offset: 0, nextOffset: -1, totalBytes: 0, truncated: false },
},
"runs.revealLog": {
params: { runId: id, toolCallId: "call_1" },
result: { ok: true },
badParams: { path: "/tmp/log" },
badResult: { ok: false },
},
"runs.openLog": {
params: { runId: id, toolCallId: "call_1" },
result: { ok: true },
badParams: { path: "/tmp/log" },
badResult: { ok: false },
},
"files.open": {
params: { botId: id, path: "/bot/home/note.md" },
result: { ok: true },
badParams: { botId: id, path: "" },
badResult: { ok: false },
},
"app.openFeedback": {
params: {
repository: "example/pibot",
title: "Feedback",
description: "Synthetic description",
confirmed: true,
},
result: null,
badParams: { confirmed: false },
badResult: {},
},
"app.openLink": {
params: { url: "https://pibot.space" },
result: null,
badParams: { url: "file:///tmp/a" },
badResult: "bad",
},
"app.dependencies": {
params: undefined,
result: [],
badParams: { unexpected: true },
badResult: null,
},
"app.checkUpdates": {
params: undefined,
result: { status: "not_ready", currentVersion: "0.0.1" },
badParams: { unexpected: true },
badResult: { status: "available" },
},
"app.about": {
params: undefined,
result: { version: "0.0.5", phoneCompat: 1 },
badParams: { extra: true },
badResult: { version: "0.0.5", phoneCompat: 1.5 },
},
"app.getInfo": {
params: undefined,
result: { version: "0.0.0", platform: "darwin", dataDir: "data", piVersion: "1.0" },
badParams: { extra: true },
badResult: { version: "1", platform: "android", dataDir: "data", piVersion: "1" },
},
"network.getConfig": {
params: {},
result: { enabled: false, address: null, hasCredentials: false },
badParams: { extra: true },
badResult: {
enabled: true,
address: "http://user:[email protected]:7890",
hasCredentials: true,
},
},
"network.setConfig": {
params: { enabled: true, address: "http://127.0.0.1:7890" },
result: { enabled: true, address: "http://127.0.0.1:7890/", hasCredentials: false },
badParams: { enabled: true, address: "socks5://127.0.0.1:7890" },
badResult: {
enabled: true,
address: "https://user:[email protected]",
hasCredentials: true,
},
},
"network.test": {
params: undefined,
result: { ok: true, reason: "connected", address: "http://127.0.0.1:7890/" },
badParams: { url: "http://private/" },
badResult: { ok: true, reason: "secret" },
},
"settings.get": {
params: {},
result: settings,
badParams: [],
badResult: { ...settings, language: "fr" },
},
"settings.set": {
params: {
language: "en",
theme: "dark",
defaultModel: settings.defaultModel,
initializeMainBot: true,
},
result: settings,
badParams: { defaultModel: { provider: "openai", id: "test-model", thinkingLevel: "extreme" } },
badResult: { ...settings, openAtLogin: 1 },
},
"providers.list": {
params: undefined,
result: [provider],
badParams: { apiKey: "secret" },
badResult: [{ ...provider, apiKey: "secret" }],
},
"providers.setApiKey": {
params: { providerId: "openai", apiKey: "fake-key" },
result: { ok: true },
badParams: { providerId: "openai", apiKey: "!command" },
badResult: { ok: false },
},
"providers.importFromEnv": {
params: { providerId: "openai" },
result: { ok: true },
badParams: { providerId: 1 },
badResult: { ok: "true" },
},
"providers.remove": {
params: { providerId: "openai" },
result: { ok: true },
badParams: { providerId: "" },
badResult: {},
},
"providers.test": {
params: { providerId: "openai" },
result: { ok: false, error: "auth_failed" },
badParams: {},
badResult: { ok: false, error: "unknown" },
},
"customProviders.fetchModels": {
params: {
baseUrl: custom.baseUrl,
api: custom.api,
apiKey: custom.apiKey,
headers: custom.headers,
},
result: { models: [{ id: "model" }] },
badParams: { baseUrl: "file:///tmp/model", api: custom.api },
badResult: { models: [{ id: 1 }] },
},
"customProviders.fetchSavedModels": {
params: { providerId: "local" },
result: { models: [{ id: "model" }] },
badParams: { providerId: "" },
badResult: { models: [{ id: "" }] },
},
"customProviders.get": {
params: { providerId: "local" },
result: {
id: "local",
name: custom.name,
baseUrl: custom.baseUrl,
api: custom.api,
models: custom.models,
hasApiKey: true,
headerNames: ["X-Test"],
},
badParams: {},
// Secrets must never fit the editable view.
badResult: {
id: "local",
name: custom.name,
baseUrl: custom.baseUrl,
api: custom.api,
models: custom.models,
hasApiKey: true,
headerNames: [],
apiKey: custom.apiKey,
},
},
"customProviders.upsert": {
params: custom,
result: { id: "local" },
badParams: { ...custom, models: [{ id: "model", contextWindow: -1 }] },
badResult: { id: "" },
},
"customProviders.resolveModels": {
params: { models: [{ id: "openai/gpt-5" }] },
result: {
models: [
{
id: "openai/gpt-5",
capabilities: {
reasoning: true,
input: ["text", "image"],
contextWindow: 400000,
maxTokens: 128000,
thinkingLevels: ["off", "low", "medium", "high"],
inferredFrom: { provider: "openai", id: "gpt-5" },
},
},
],
},
badParams: { models: [{ id: "", reasoning: "yes" }] },
badResult: {
models: [{ id: "model", capabilities: { reasoning: true, thinkingLevels: ["unknown"] } }],
},
},
"chat.recovery": {
params: { botId: id, conversationId: id, runId: id },
result: {
run: { id, status: "aborted", errorCode: null, finishedAt: null },
task: null,
session: { state: "missing", entryCount: 0, checkpoint: null },
fileCheckpoint: null,
continuation: "unavailable",
},
badParams: { botId: "bad" },
badResult: { continuation: "ready" },
},
"models.refresh": {
params: { providerId: "openrouter" },
result: { providerId: "openrouter", count: 500, updatedAt: "2026-10-18T00:00:00.000Z" },
badParams: { providerId: "other" },
badResult: { providerId: "openrouter", count: 0, updatedAt: "2026-10-18T00:00:00.000Z" },
},
"models.list": {
params: { availableOnly: true },
result: [model],
badParams: { availableOnly: 1 },
badResult: [{ ...model, cost: { input: -1, output: 2, cacheRead: 0, cacheWrite: 0 } }],
},
"models.health": {
params: { models: [{ provider: model.provider, id: model.id }] },
result: ["auth_failed"],
badParams: { models: Array(3).fill({ provider: model.provider, id: model.id }) },
badResult: ["unknown_reason"],
},
"bots.list": {
params: undefined,
result: [bot],
badParams: null,
badResult: [{ ...bot, id: "pi" }],
},
"bots.update": {
params: { botId: id, modelProvider: "openai", modelId: "model", thinkingLevel: "high" },
result: bot,
badParams: { botId: id, thinkingLevel: "maximum" },
badResult: { ...bot, createdAt: "yesterday" },
},
"chat.history": {
params: { botId: id, before: id, limit: 50 },
result: [{ ...message, taskResult: { taskId: id, threadId: id } }],
badParams: { botId: id, limit: 0 },
badResult: [{ ...message, taskResult: { taskId: id, threadId: "invalid" } }],
},
"chat.send": {
params: { botId: id, newTopic: true, text: "你好" },
result: { userMessageId: id, assistantMessageId: id, runId: id },
badParams: { botId: id, topicId: id, newTopic: true, text: "你好" },
badResult: { userMessageId: id, assistantMessageId: id, runId: "bad" },
},
"chat.abort": {
params: { runId: id },
result: { ok: true },
badParams: { runId: "bad" },
badResult: { ok: false },
},
"chat.append": {
params: { botId: id, topicId: id, runId: id, requestId: id, mode: "steer", text: "补充" },
result: {
...message,
role: "user",
usage: { chatAddition: { requestId: id, mode: "steer", state: "queued" } },
},
badParams: { botId: id, topicId: id, runId: id, requestId: id, mode: "parallel", text: "补充" },
badResult: { ...message, id: "bad" },
},
// Changes sidebar fixtures (required by the exhaustive method table).
"changes.reveal": {
params: { runId: id, path: "/tmp/output.txt" },
result: { ok: true },
badParams: { path: "/tmp/output.txt", allowedRoots: ["/tmp"] },
badResult: { ok: false },
},
"changes.status": {
params: { conversationKey: `dm:${id}`, topicId: id, limit: 500 },
result: {
root: { id: "home", name: "home", path: "/tmp/home", role: "primary" },
roots: [],
git: { state: "none", reason: "not_repo" },
author: null,
files: [],
total: 0,
nextCursor: null,
overflow: false,
totals: null,
statsPending: false,
},
badParams: { conversationKey: `group:${id}`, topicId: id },
badResult: { root: null },
},
"changes.diff": {
params: { conversationKey: `dm:${id}`, path: "a.ts", scope: "uncommitted" },
result: {
path: "a.ts",
binary: false,
tooLarge: false,
unavailable: null,
added: 1,
removed: 0,
hunks: [],
},
badParams: { conversationKey: `dm:${id}`, path: "a.ts", scope: "commit" },
badResult: { path: "a.ts" },
},
"changes.turn": {
params: { runId: id },
result: { runId: null, botId: null, root: null, files: [], total: 0, truncated: false },
badParams: { runId: "bad" },
badResult: { runId: "bad" },
},
"changes.log": {
params: { conversationKey: `dm:${id}`, limit: 50 },
result: { commits: [], hasMore: false },
badParams: { conversationKey: `dm:${id}`, limit: 51 },
badResult: { commits: [] },
},
// Required fixtures for the existing exhaustive method table; no new test body.
"changes.refs": {
params: { conversationKey: `dm:${id}`, kind: "branch" },
result: { refs: [], next: null, writable: true },
badParams: { conversationKey: `dm:${id}`, kind: "remote" },
badResult: { refs: [] },
},
"changes.remotes": {
params: { conversationKey: `dm:${id}` },
result: { head: "0".repeat(40), branch: "main", upstream: null, remotes: [], writable: true },
badParams: {},
badResult: {},
},
"changes.sync": {
params: {
conversationKey: `dm:${id}`,
action: "push",
remote: "origin",
remoteBranch: "main",
head: "0".repeat(40),
branch: "main",
},
result: { ok: true },
badParams: { conversationKey: `dm:${id}`, action: "forcePush" },
badResult: { ok: false },
},
"changes.refWrite": {
params: {
conversationKey: `dm:${id}`,
action: "createBranch",
name: "feature/local",
head: "0".repeat(40),
branch: "main",
commit: "0".repeat(40),
},
result: { ok: true },
badParams: { conversationKey: `dm:${id}`, action: "createBranch", name: "-x" },
badResult: { ok: false },
},
"changes.discard": {
params: { conversationKey: `dm:${id}`, path: "a.ts" },
result: { ok: true },
badParams: { conversationKey: `dm:${id}`, path: "" },
badResult: { ok: false },
},
// One object of a Word / Excel / PowerPoint file, named by the diff that listed it.
"changes.discardOffice": {
params: {
conversationKey: `dm:${id}`,
path: "slides/a.pptx",
scope: "uncommitted",
item: "slide:2/shape:3",
digest: "a".repeat(64),
},
result: { ok: true },
badParams: {
conversationKey: `dm:${id}`,
path: "slides/a.pptx",
item: "slide:2/shape:3",
digest: "nope",
},
badResult: { ok: false },
},
"changes.commit": {
params: { conversationKey: `dm:${id}`, paths: ["a.ts"], message: "Fix" },
result: { commit: "0".repeat(40) },
badParams: { conversationKey: `dm:${id}`, paths: [], message: "Fix" },
badResult: { commit: "HEAD" },
},
"changes.draftMessage": {
params: { conversationKey: `dm:${id}`, paths: ["a.ts"] },
result: { message: "fix: correct the generated commit message" },
badParams: { conversationKey: `dm:${id}`, paths: [] },
badResult: {},
},
"changes.watch": {
params: { conversationKey: `group:${id}`, on: true },
result: { ok: true },
badParams: { conversationKey: `group:${id}` },
badResult: { ok: false },
},
// Changes line-range fixtures.
"changes.lines": {
params: { conversationKey: `dm:${id}`, path: "a.ts", scope: "uncommitted", from: 4, count: 20 },
result: { lines: ["const a = 1;"], total: 30 },
badParams: { conversationKey: `dm:${id}`, path: "a.ts", scope: "turn", from: 1, count: 1 },
badResult: { lines: [] },
},
"changes.image": {
params: { conversationKey: `dm:${id}`, path: "a.png", scope: "uncommitted", side: "after" },
result: { state: "missing" },
badParams: { conversationKey: `dm:${id}`, path: "a.png", scope: "uncommitted", side: "x" },
badResult: { state: "ok" },
},
"changes.reviews": {
params: { conversationKey: `dm:${id}` },
result: { runId: null, freshness: "unavailable", findings: [] },
badParams: { conversationKey: `group:${id}`, topicId: id },
badResult: { findings: [] },
},
"changes.reviewStart": {
params: { conversationKey: `dm:${id}` },
result: { runIds: [id] },
badParams: { conversationKey: `group:${id}`, topicId: id },
badResult: { runIds: [1] },
},
"changes.gitStatus": {
params: {},
result: { state: "available", version: "2.39.5" },
badParams: { force: true },
badResult: { state: "absent" },
},
"changes.gitInstall": {
params: {},
result: {
state: "installing",
installer: "package",
command: "dnf install -y git",
manualCommand: "sudo dnf install -y git",
},
badParams: { manager: "dnf" },
badResult: { state: "failed", reason: "unknown" },
},
"changes.reviewers": {
params: { conversationKey: `dm:${id}` },
result: {
authorId: id,
reviewerId: id,
defaultId: null,
recommendedId: id,
builtinMissing: true,
bots: [],
},
badParams: { conversationKey: "dm" },
badResult: { authorId: id },
},
"changes.reviewerSet": {
params: { conversationKey: `dm:${id}`, botId: id },
result: { ok: true },
badParams: { conversationKey: `dm:${id}` },
badResult: { ok: false },
},
"changes.reviewUpdate": {
params: { conversationKey: `dm:${id}`, ids: [id], state: "dismissed" },
result: { ok: true },
badParams: { conversationKey: `dm:${id}`, ids: [], state: "dismissed" },
badResult: { ok: false },
},
"chat.notices": {
params: { conversationId: id, limit: 50 },
result: [
{
id,
conversationId: id,
botId: id,
kind: "browser_handback" as const,
durationMs: 120000,
domains: ["data.stats.gov.cn"],
createdAt: date,
},
],
badParams: { limit: 50 },
badResult: [{ id, conversationId: id, botId: id, kind: "browser_handback", domains: [] }],
},
"groups.append": {
params: {
groupId: id,
conversationId: id,
botId: id,
runId: id,
requestId: id,
mode: "followUp",
text: "补充",
},
result: {
...message,
role: "user",
usage: { chatAddition: { requestId: id, mode: "followUp", state: "queued" } },
},
badParams: {
groupId: id,
conversationId: id,
botId: id,
runId: id,
requestId: id,
mode: "parallel",
text: "补充",
},
badResult: { ...message, id: "bad" },
},
"groups.appendStatus": {
params: { groupId: id, conversationId: id, botId: id, requestId: id },
result: { state: "absent", message: null },
badParams: { groupId: id, conversationId: id, botId: id, requestId: "bad" },
badResult: { state: "accepted", message: null },
},
"chat.appendMode": {
params: { botId: id, topicId: id, requestId: id, mode: "followUp" },
result: {
...message,
role: "user",
usage: { chatAddition: { requestId: id, mode: "followUp", state: "queued" } },
},
badParams: { botId: id, topicId: id, requestId: id, mode: "later" },
badResult: { ...message, id: "bad" },
},
"groups.appendMode": {
params: { groupId: id, conversationId: id, requestId: id, mode: "steer" },
result: {
...message,
role: "user",
usage: { chatAddition: { requestId: id, mode: "steer", state: "queued" } },
},
badParams: { groupId: id, conversationId: id, botId: id, requestId: id, mode: "steer" },
badResult: { ...message, id: "bad" },
},
"chat.appendStatus": {
params: { botId: id, topicId: id, requestId: id },
result: { state: "absent", message: null },
badParams: { botId: id, topicId: id, requestId: "bad" },
badResult: { state: "accepted", message: null },
},
"events.resume": {
params: { afterSeq: 0 },
result: [envelope],
badParams: { afterSeq: -1 },
badResult: [{ ...envelope, params: { ...envelope.params, seq: 0 } }],
},
"local.detectOllama": {
params: undefined,
result: { running: true, baseUrl: custom.baseUrl, models: [{ id: "model" }] },
badParams: { timeout: 100 },
badResult: { running: "yes", baseUrl: custom.baseUrl, models: [] },
},
"conversations.yolo.get": {
params: { conversationId: id },
result: { conversationId: id, enabled: false, enabledAt: null, isolation: { available: true } },
badParams: { botId: id },
badResult: {
conversationId: id,
enabled: "yes",
enabledAt: null,
isolation: { available: true },
},
},
"execution.get": {
params: { botId: id, conversationId: id },
result: {
botId: id,
conversationId: id,
mode: "execute",
limits: DEFAULT_EXECUTION_LIMITS,
version: 0,
updatedAt: null,
},
badParams: { botId: id },
badResult: {
botId: id,
conversationId: id,
mode: "other",
limits: DEFAULT_EXECUTION_LIMITS,
version: 0,
updatedAt: null,
},
},
"execution.tasks.list": {
params: { botId: id, conversationId: id },
result: { items: [executionTask], nextBefore: null },
badParams: { botId: id },
badResult: { items: [], nextBefore: "bad" },
},
"execution.tasks.get": {
params: { botId: id, conversationId: id, taskId: id },
result: { task: executionTask, budget: executionBudget, checkpoint: null },
badParams: { botId: id, conversationId: id },
badResult: { task: executionTask, budget: null, checkpoint: null },
},
"execution.tasks.history": {
params: { botId: id, conversationId: id, taskId: id },
result: { messages: [], nextBefore: null },
badParams: { botId: id, conversationId: id, taskId: id, limit: 51 },
badResult: { messages: [], nextBefore: "bad" },
},
"execution.tasks.message": {
params: {
botId: id,
conversationId: id,
taskId: id,
requestId: id,
message: "Check cancellation",
},
result: { task: executionTask, delivery: "queued" },
badParams: { botId: id, conversationId: id, taskId: id, message: "Check" },
badResult: { task: executionTask, delivery: "sent" },
},
"execution.tasks.cancel": {
params: { botId: id, conversationId: id, taskId: id },
result: { task: executionTask, delivery: "stopping" },
badParams: { botId: id, conversationId: id },
badResult: { task: executionTask, delivery: "cancelled" },
},
"execution.set": {
params: { botId: id, conversationId: id, expectedVersion: 0, mode: "plan" },
result: {
botId: id,
conversationId: id,
mode: "plan",
limits: DEFAULT_EXECUTION_LIMITS,
version: 1,
updatedAt: date,
},
badParams: { botId: id, conversationId: id, mode: "plan" },
badResult: {
botId: id,
conversationId: id,
mode: "plan",
limits: DEFAULT_EXECUTION_LIMITS,
version: -1,
updatedAt: date,
},
},
"execution.question.dismiss": {
params: { messageId: id },
result: { ok: true },
badParams: { messageId: "invalid" },
badResult: { ok: false },
},
"execution.question.answer": {
params: { messageId: id, reply: { optionId: "continue" } },
result: { ok: true },
badParams: { messageId: id, reply: {} },
badResult: { ok: false },
},
"execution.todo.get": {
params: { botId: id, conversationId: id },
result: { botId: id, conversationId: id, goal: "", items: [], version: 0, updatedAt: null },
badParams: { conversationId: id },
badResult: { botId: id, conversationId: id, goal: "", items: [], version: -1, updatedAt: null },
},
"execution.todo.set": {
params: {
botId: id,
conversationId: id,
expectedVersion: 0,
goal: "Research",
items: [{ id, title: "Read", status: "pending" }],
},
result: {
botId: id,
conversationId: id,
goal: "Research",
items: [{ id, title: "Read", status: "pending" }],
version: 1,
updatedAt: date,
},
badParams: {
botId: id,
conversationId: id,
expectedVersion: 0,
goal: "",
items: [{ id, title: "", status: "pending" }],
},
badResult: {
botId: id,
conversationId: id,
goal: "",
items: [{ id, title: "Read", status: "other" }],
version: 1,
updatedAt: date,
},
},
"conversations.yolo.enableOnWindows": {
params: { conversationId: id, acknowledged: true },
result: { conversationId: id, enabled: true, enabledAt: date, isolation: { available: false } },
badParams: { conversationId: id, acknowledged: false },
badResult: { conversationId: id, enabled: true, enabledAt: date },
},
"conversations.yolo.set": {
params: { conversationId: id, enabled: true },
result: { conversationId: id, enabled: true, enabledAt: date, isolation: { available: false } },
badParams: { conversationId: id },
badResult: { conversationId: id, enabled: true, enabledAt: date },
},
"foregroundCommands.get": {
params: { botId: id, runId: id, toolCallId: "call" },
result: null,
badParams: { botId: id },
badResult: { active: true },
},
"foregroundCommands.promote": {
params: { botId: id, runId: id, toolCallId: "call" },
result: { ok: true },
badParams: { runId: id },
badResult: { ok: false },
},
"backgroundCommands.list": {
params: { botId: id, limit: 20 },
result: [backgroundCommand],
badParams: { botId: id, limit: 51 },
badResult: [{ ...backgroundCommand, ports: [70000] }],
},
"backgroundCommands.page": {
params: { state: "ended", botId: id, before: id, limit: 50 },
result: [{ ...backgroundCommand, place: { kind: "topic", title: "Notes", groupName: null } }],
badParams: { state: "all" },
badResult: [{ ...backgroundCommand, place: { kind: "dm", title: "", groupName: null } }],
},
"backgroundCommands.stop": {
params: { botId: id, id },
result: { ...backgroundCommand, status: "stopped", stopReason: "user", endedAt: date },
badParams: { botId: id },
badResult: { ...backgroundCommand, stopReason: "killed" },
},
"backgroundCommands.continue": {
params: { botId: id, id },
result: { ...backgroundCommand, continuation: "automatic" },
badParams: { botId: id },
badResult: { ...backgroundCommand, continuation: "unexpected" },
},
"backgroundCommands.output": {
params: { botId: id, id },
result: { text: "redacted output" },
badParams: { id },
badResult: { text: 42 },
},
"backgroundCommands.open": {
params: { botId: id, id, port: 8010 },
result: { ok: true },
badParams: { botId: id, id, port: 0 },
badResult: { ok: false },
},
"autoCheck.get": {
params: { botId: id },
result: { botId: id, enabled: true, rounds: 2, stored: true },
badParams: {},
badResult: { botId: id, enabled: true, rounds: 4, stored: true },
},
"autoCheck.set": {
params: { botId: id, rounds: 3 },
result: { botId: id, enabled: false, rounds: 3, stored: false },
badParams: { botId: id },
badResult: { botId: id, enabled: false },
},
"autoCheck.folder.get": {
params: { botId: id, conversationId: id },
result: {
botId: id,
conversationId: id,
folder: { name: "app", path: "/work/app", home: false },
commands: ["npm test"],
},
badParams: { botId: id },
badResult: { botId: id, conversationId: id, folder: null, commands: ["a\nb"] },
},
"autoCheck.folder.set": {
params: { botId: id, conversationId: id, commands: null },
result: { botId: id, conversationId: id, folder: null, commands: [] },
badParams: { botId: id, conversationId: id, commands: ["1", "2", "3", "4"] },
badResult: { botId: id, conversationId: id, folder: null },
},
"autoCheck.conversation.set": {
params: { conversationId: id, enabled: false },
result: { conversationId: id, enabled: false },
badParams: { conversationId: id },
badResult: { conversationId: id },
},
"autoCheck.proposal.resolve": {
params: { noticeId: id, accept: true, commands: ["pnpm test"] },
result: {
id,
conversationId: id,
botId: id,
kind: "auto_check_proposal",
runId: id,
status: "accepted",
commands: ["pnpm test"],
folderName: "app",
createdAt: date,
},
badParams: { noticeId: id },
badResult: { id, kind: "auto_check_proposal", status: "open" },
},
"drafts.status": {
params: { approvalId: id, conversationId: id },
result: { status: "discarded" },
badParams: { approvalId: id },
badResult: { status: "not_a_status" },
},
"drafts.get": {
params: { approvalId: id, conversationId: id },
result: {
...{
approvalId: id,
botId: id,
conversationId: id,
draft: {
identity: "user",
target: "fixture",
connectorId: id,
tool: "send",
revision: 1,
catalogVersion: 1,
contentDigest: "a".repeat(64),
contentLength: 4,
editable: true,
canRememberTarget: false,
},
edited: false,
status: "pending",
createdAt: date,
expiresAt: date,
resolvedAt: null,
},
content: "body",
},
badParams: { approvalId: id },
badResult: {},
},
"drafts.list": {
params: { limit: 50 },
result: [
{
approvalId: id,
botId: id,
conversationId: id,
draft: {
identity: "user",
target: "fixture",
connectorId: id,
tool: "send",
revision: 1,
catalogVersion: 1,
contentDigest: "a".repeat(64),
contentLength: 4,
editable: true,
canRememberTarget: false,
},
edited: false,
status: "pending",
createdAt: date,
expiresAt: date,
resolvedAt: null,
},
],
badParams: { limit: 201 },
badResult: [{}],
},
"drafts.resolve": {
params: { approvalId: id, action: "send", content: "body" },
result: { ok: true, status: "sent" },
badParams: { approvalId: id, action: "send", target: "different" },
badResult: { ok: false, status: "sent" },
},
"runtime.health.get": {
params: undefined,
result: { healthy: true, reason: null, botIds: [] },
badParams: { unexpected: true },
// healthy=false requires a reason; that pairing is the contract the UI switches on.
badResult: { healthy: false, reason: null, botIds: [] },
},
"continuations.list": {
params: { limit: 50 },
result: { items: [{ conversationId: id, count: 1 }], nextAfter: null },
badParams: { limit: 0 },
badResult: { items: [{ conversationId: id, count: -1 }], nextAfter: null },
},
"continuations.resume": {
params: { conversationId: id, confirmed: true },
result: { resumed: 1, dropped: 0, kept: 0, busy: 0 },
badParams: { conversationId: id, confirmed: false },
badResult: { resumed: 1, dropped: 0 },
},
"continuations.discard": {
params: { conversationId: id },
result: { discarded: 1 },
badParams: {},
badResult: { discarded: -1 },
},
"capabilities.list": {
params: { botId: id, groupId: id },
result: {
items: [
{
id: "files.read",
impl: "builtin",
source: "default",
available: [{ impl: "builtin", ready: true }],
},
],
},
badParams: { botId: "not-an-id" },
badResult: { items: [{ id: "files.read", impl: "connector:github" }] },
},
"capabilities.set": {
params: { scope: "global", capabilityId: "web.fetch", impl: null },
result: null,
badParams: { scope: "global", scopeId: id, capabilityId: "web.fetch", impl: "builtin" },
badResult: {},
},
"runtime.forceRelease": {
// A release must always state that running output may be lost.
params: { botId: id, confirmed: true },
result: { healthy: true, reason: null, botIds: [] },
badParams: { botId: id, confirmed: false },
badResult: { healthy: false, reason: null, botIds: [] },
},
"runtime.commands.get": {
params: undefined,
result: { paused: null },
badParams: { unexpected: true },
badResult: { paused: "unknown" },
},
"runtime.commands.recheck": {
params: undefined,
result: { paused: "stuck" },
badParams: { unexpected: true },
badResult: {},
},
} satisfies Cases<MethodParams, MethodResults>;
const hostCases = {
"host.office.render": {
params: { format: "pptx", data: "AAAA", pages: [1] },
result: [],
badParams: { format: "pptx", data: "AAAA", pages: [1, 1] },
badResult: [{ page: 1, width: 0, height: 1, data: "AAAA" }],
},
"host.officeApps": {
params: { format: "pptx" },
result: { apps: [], defaultAvailable: false },
badParams: { format: "exe" },
badResult: {},
},
"host.officeOpen": {
params: {
botId: id,
file: "/tmp/report.docx",
allowedRoots: ["/tmp"],
appId: "com.microsoft.Word",
},
result: null,
badParams: { file: "/tmp/report.docx" },
badResult: {},
},
"host.browser.network": {
params: { botId: id, runId: id },
result: { documentId: id, oldestSeq: 1, nextSeq: 0, dropped: false, entries: [], storage: [] },
badParams: { botId: id, limit: 51 },
badResult: {},
},
"host.browser.request": {
params: { botId: id, origin: "https://example.com", url: "/api", method: "GET" },
result: {
seq: 0,
method: "GET",
url: "https://example.com/api",
status: 200,
resourceType: "Fetch",
durationMs: 1,
requestHeaders: {},
responseHeaders: {},
},
badParams: { botId: id, method: "TRACE" },
badResult: {},
},
"host.browser.secret": {
params: {
botId: id,
origin: "https://example.com",
kind: "handle",
name: "Authorization",
handle: "«secret:h00000000000000000000000000000001»",
documentId: id,
},
result: {
handle: "«secret:h00000000000000000000000000000001»",
kind: "network",
site: "https://example.com",
name: "Authorization",
length: 9,
},
badParams: { botId: id, kind: "script" },
badResult: {},
},
"host.browser.secretUses": {
params: {
botId: id,
uses: [
{
handle: "«secret:h00000000000000000000000000000001»",
destination: "env TOKEN for command X",
},
],
},
result: {
uses: [
{
handle: "«secret:h00000000000000000000000000000001»",
tab: "t1",
documentId: id,
kind: "network",
site: "https://example.com",
name: "Authorization",
length: 9,
destination: "env TOKEN for command X",
},
],
},
badParams: { botId: id, uses: [] },
badResult: {},
},
"host.browser.consumeSecrets": {
params: {
botId: id,
uses: [
{
handle: "«secret:h00000000000000000000000000000001»",
tab: "t1",
documentId: id,
kind: "network",
site: "https://example.com",
name: "Authorization",
length: 9,
destination: "env TOKEN for command X",
},
],
},
result: {
values: [{ handle: "«secret:h00000000000000000000000000000001»", value: "synthetic" }],
},
badParams: { botId: id, uses: [] },
badResult: {},
},
"host.browser.diagnostics": {
params: { botId: id, runId: id },
result: browserDiagnostics,
badParams: { botId: id, limit: 51 },
badResult: { ...browserDiagnostics, entries: null },
},
"host.browser.inspect": {
params: { botId: id, runId: id, ref: "e1" },
result: browserElement,
badParams: { botId: id, ref: "x" },
badResult: { ...browserElement, tag: null },
},
"host.browser.view.debug": {
params: { botId: id },
result: browserDiagnostics,
badParams: { botId: id, after: -1 },
badResult: { ...browserDiagnostics, supported: null },
},
"host.browser.view.inspectPoint": {
params: { botId: id, tab: "t1", documentId: id, frameSeq: 1, x: 1, y: 1 },
result: browserElement,
badParams: { botId: id, tab: "t1", documentId: id, frameSeq: 1, x: -1, y: 1 },
badResult: { ...browserElement, bounds: false },
},
"host.backgroundState": {
params: undefined,
result: backgroundState,
badParams: { restart: true },
badResult: {},
},
"host.keepAwake": {
params: { mode: "on_ac", reason: "running", leaseId: id, leaseMs: 60000 },
result: { status: "requested", leaseId: id, expiresAt: date },
badParams: { mode: "on_ac", reason: "running", leaseId: id, leaseMs: 1800001 },
badResult: {},
},
"tray.update": {
params: { next: null, running: [], counts: routineCounts, pausedUntil: null },
result: null,
badParams: {},
badResult: {},
},
"host.teams.read": {
params: { file: "/tmp/team.pibot" },
result: "{}",
badParams: {},
badResult: 5,
},
"host.teams.cancel": { params: undefined, result: null, badParams: { file: "x" }, badResult: 5 },
"host.teams.pickFile": {
params: {},
result: "/tmp/team.pibot",
badParams: { file: "x" },
badResult: 5,
},
"host.teams.save": {
params: { template: team },
result: { saved: true },
badParams: { template: { ...team, version: 4 } },
badResult: { saved: 5 },
},
"host.pickFolder": {
params: undefined,
result: "/folder",
badParams: { path: "/untrusted" },
badResult: { path: "/folder" },
},
// "Nothing found" must stay a valid answer, so the empty shape is the fixture.
"host.knowledge.detect": {
params: undefined,
result: {
obsidian: { installed: true, vaults: [{ name: "Vault", path: "/Users/me/Vault" }] },
notion: { installed: false },
},
badParams: { path: "/Users/me/Vault" },
badResult: { obsidian: { installed: true }, notion: { installed: false } },
},
// Only verified identities travel; an href or a path from the renderer is not a param.
"host.knowledge.openNote": {
params: {
requestId: "00000000-0000-4000-8000-000000000001",
sourceId: "00000000-0000-4000-8000-000000000002",
vault: { path: "/Users/me/Vault", device: "1", inode: "2" },
note: { relativePath: "Notes/Plan.md", device: "1", inode: "3" },
},
result: { opened: true as const },
badParams: {
requestId: "00000000-0000-4000-8000-000000000001",
sourceId: "00000000-0000-4000-8000-000000000002",
vault: { path: "/Users/me/Vault", device: "1", inode: "2" },
note: { relativePath: "Notes/Plan.md", device: "1", inode: "3" },
url: "obsidian://open?vault=Vault&file=Notes%2FPlan",
},
badResult: { opened: "yes" },
},
"host.knowledge.confirmOpen": {
params: { requestId: "00000000-0000-4000-8000-000000000001" },
result: null,
badParams: {},
badResult: { ok: true },
},
"host.pickFile": {
params: { defaultPath: "/folder" },
result: "/folder/input.txt",
badParams: { defaultPath: "relative" },
badResult: { path: "/folder/input.txt" },
},
"host.skills.pickFile": {
params: undefined,
result: "/skills/SKILL.md",
badParams: { path: "/untrusted" },
badResult: "relative/SKILL.md",
},
"host.notify": {
params: { title: "Approval", body: "Please review", botId: id, tab: "permissions" },
result: { shown: false, reason: "foreground" },
badParams: { title: "Approval", body: "Please review", botId: "bad" },
badResult: { shown: "yes" },
},
"host.openPath": {
params: { path: "/folder/file.txt", allowedRoots: ["/folder"] },
result: null,
badParams: { path: "/folder/file.txt", allowedRoots: [] },
badResult: { ok: true },
},
"host.revealPath": {
params: { path: "/folder/file.txt", allowedRoots: ["/folder"] },
result: null,
badParams: { path: "/folder/file.txt", allowedRoots: [] },
badResult: { ok: true },
},
"host.attachments.image": {
params: image,
result: { image, width: 1, height: 1 },
badParams: { ...image, data: "!invalid" },
badResult: { image, width: 0, height: 1 },
},
"host.attachments.pdf": {
params: { data: "JVBERi0xLjQ=", pages: 1 },
result: { images: [image], totalPages: 1 },
badParams: { data: "JVBERi0xLjQ=", pages: 11 },
badResult: { images: [], totalPages: 1 },
},
"host.attachments.thumbnail": {
params: { botId: id, file: `${id}.png` },
result: image,
badParams: { botId: id, file: "../image.png" },
badResult: { ok: true },
},
"host.attachments.stepThumbnail": {
params: { botId: id, file: `${id}.jpg` },
result: image,
badParams: { botId: id, file: "../image.jpg" },
badResult: { ok: true },
},
"host.attachments.changeThumbnail": {
params: { botId: id, file: `${id}.gif` },
result: image,
badParams: { botId: id, file: `${id}.svg` },
badResult: { ok: true },
},
"host.attachments.open": {
params: { botId: id, file: `${id}.pdf` },
result: null,
badParams: { botId: id, file: "../file.pdf" },
badResult: { ok: true },
},
"host.secrets.isAvailable": {
params: undefined,
result: true,
badParams: { extra: 1 },
badResult: "true",
},
"host.secrets.encrypt": {
params: { plain: "fake-key" },
result: new Uint8Array([1, 2]),
badParams: { plain: "!command" },
badResult: [1, 2],
},
"host.secrets.decrypt": {
params: { cipher: new Uint8Array([1, 2]) },
result: "fake-key",
badParams: { cipher: [1, 2] },
badResult: 123,
},
"host.env.detect": {
params: {},
result: ["OPENAI_API_KEY"],
badParams: { values: true },
badResult: [{ name: "OPENAI_API_KEY", value: "secret" }],
},
"host.env.read": {
params: { name: "OPENAI_API_KEY" },
result: "fake-key",
badParams: { name: "" },
badResult: 123,
},
"host.updates.proxy": {
params: { url: "http://127.0.0.1:7890/" },
result: null,
badParams: { url: "ftp://example.com" },
badResult: {},
},
"host.openExternal": {
params: { url: "https://example.com" },
result: null,
badParams: { url: "javascript:alert(1)" },
badResult: true,
},
"host.setLoginItem": {
params: { openAtLogin: true },
result: null,
badParams: { openAtLogin: 1 },
badResult: {},
},
...browserHostCases(),
...browserViewHostCases(),
...browserExtensionHostCases,
...teachHostCases(),
...computerHostGuardCases,
...credentialHostCases,
...connectorHostCases,
// Operating the computer (minimal fixtures required by the per-method coverage check).
"host.computer.status": {
params: undefined,
result: {
platform: "darwin",
available: true,
permissions: {
accessibility: "granted",
screenRecording: "denied",
automation: "ask_per_app",
},
features: {
backgroundClick: true,
backgroundDrag: false,
backgroundKeys: true,
displayScreenshot: true,
},
},
badParams: { token: computerToken },
badResult: { platform: "darwin", available: true },
},
"host.computer.openSystemSettings": {
params: { pane: "accessibility" },
result: null,
badParams: { pane: "general" },
badResult: {},
},
"host.computer.grants.set": {
params: {
token: computerToken,
botId: id,
runId: id,
apps: [{ id: "com.apple.iWork.Keynote", name: "Keynote" }],
expiresAt: "2026-10-14T00:30:00.000Z",
allowCoordinates: false,
foregroundAsk: true,
},
result: null,
badParams: { token: "short", botId: id, runId: id, apps: [], expiresAt: "soon" },
badResult: { ok: true },
},
"host.computer.grants.revoke": {
params: { runId: id },
result: { revoked: 1 },
badParams: { runId: id, botId: id },
badResult: { revoked: -1 },
},
"host.computer.resolveAppName": {
params: { name: "Calculator" },
result: { id: "com.apple.calculator" },
badParams: { name: "" },
badResult: { id: 42 },
},
"host.computer.installedApps": {
params: { limit: 500 },
result: {
supported: true,
apps: [{ id: "com.tencent.xinWeChat", name: "WeChat", category: "chat" }],
truncated: false,
},
badParams: { limit: 5000 },
badResult: { supported: true, apps: [{ id: "x", name: "y", category: "game" }] },
},
"host.computer.listApps": {
params: { token: computerToken },
result: {
ok: true,
apps: [
{ id: "com.apple.iWork.Keynote", name: "Keynote", pid: 42, active: false, blocked: false },
],
},
badParams: {},
badResult: { ok: true },
},
"host.computer.frontmostApp": {
params: { token: computerToken },
result: { ok: false, code: "grant_expired" },
badParams: { token: 1 },
badResult: { ok: false, code: "nope" },
},
"host.computer.screenshot": {
params: { token: computerToken, app: "Keynote", maxEdge: 1280 },
result: {
ok: true,
screenshotId: "abcdefgh1234",
image: { type: "image", data: "AAAA", mimeType: "image/jpeg" },
width: 1280,
height: 800,
scope: "window",
masked: 0,
},
badParams: { token: computerToken, maxEdge: 10 },
badResult: { ok: true, screenshotId: "x" },
},
"host.computer.uiTree": {
params: { token: computerToken, app: "Keynote", depth: 8 },
result: {
ok: true,
window: { id: "123", title: "Deck" },
elements: [
{ id: "s0000002a:1", role: "AXSecureTextField", secure: true, actions: [], depth: 1 },
],
truncated: false,
},
badParams: { token: computerToken },
badResult: { ok: true, elements: [] },
},
"host.computer.uiAction": {
params: { token: computerToken, app: "Keynote", elementId: "s0000002a:1", action: "press" },
result: { ok: true, effect: "unverified" },
badParams: { token: computerToken, app: "Keynote", elementId: "s0000002a:1", action: "drag" },
badResult: { ok: true, effect: "maybe" },
},
"host.computer.pointer": {
params: {
token: computerToken,
app: "Keynote",
screenshotId: "abcdefgh1234",
kind: "click",
x: 10,
y: 20,
delivery: "auto",
},
result: { ok: false, code: "needs_foreground", detail: "target_occluded" },
badParams: {
token: computerToken,
app: "Keynote",
kind: "click",
x: 1,
y: 2,
delivery: "auto",
},
badResult: { ok: true, delivery: "teleport" },
},
"host.computer.keys": {
params: { token: computerToken, app: "Keynote", combo: ["cmd", "s"], delivery: "auto" },
result: { ok: false, code: "secure_field" },
badParams: { token: computerToken, app: "Keynote", delivery: "now" },
badResult: { ok: true },
},
"host.computer.open": {
params: { token: computerToken, target: { kind: "app", name: "Keynote" } },
result: { ok: true },
badParams: { token: computerToken, target: { kind: "file", path: "relative.txt" } },
badResult: { ok: true, command: { argv: [] } },
},
"host.computer.userActivity": {
params: { token: computerToken },
result: { ok: true, idleSeconds: 3.5, locked: false },
badParams: { token: computerToken, extra: true },
badResult: { ok: true, idleSeconds: -1, locked: false },
},
// The remote control's own keep-awake lease on the private host channel.
"host.remote.keepAwake": {
params: { enabled: true },
result: "requested",
badParams: { enabled: "yes" },
badResult: "always",
},
} satisfies Cases<HostParams, HostResults>;
// Fixtures only so the existing "every method has a fixture" check covers host.browser.*.
function browserHostCases() {
const page = { tab: "t1", url: "https://example.com/", title: "E", loading: false, blocked: [] };
const badPage = { ...page, tab: "x" };
const ref = { botId: id, ref: "e1" };
const tabs = { tabs: [{ tab: "t1", url: "https://example.com/", title: "E", active: true }] };
const rules = {
allowList: null,
sites: "all" as const,
submitSites: ["example.com"],
proxy: null,
readRoots: ["/work"],
downloadsDir: "/work/downloads",
};
const pageCase = <P>(params: P, badParams: unknown) => ({
params,
result: page,
badParams,
badResult: badPage,
});
return {
"host.browser.configure": {
params: { botId: id, rules },
result: null,
badParams: { botId: id, rules: { ...rules, readRoots: ["relative"] } },
badResult: {},
},
"host.browser.open": pageCase({ botId: id, url: "https://example.com" }, { botId: id }),
"host.browser.snapshot": {
params: { botId: id },
result: { page, tree: "- link [ref=e1]", text: "", truncated: false, refs: 1 },
badParams: { botId: id, maxChars: 1 },
badResult: { page },
},
"host.browser.readTemporary": {
params: {
botId: id,
runId: id,
operationId: id,
url: "https://example.com",
maxChars: 60000,
},
result: { page, text: "body", truncated: false },
badParams: { botId: id },
badResult: { page },
},
"host.browser.cancelTemporary": {
params: { botId: id, runId: id, operationId: id },
result: null,
badParams: { botId: id },
badResult: {},
},
"host.browser.click": pageCase(ref, { ...ref, ref: "1" }),
"host.browser.type": pageCase({ ...ref, text: "a" }, ref),
"host.browser.select": pageCase({ ...ref, value: "a" }, ref),
"host.browser.upload": pageCase({ ...ref, paths: ["/work/a.txt"] }, { ...ref, paths: [] }),
"host.browser.scroll": pageCase(
{ botId: id, direction: "down" as const },
{ botId: id, direction: "in" },
),
"host.browser.back": pageCase({ botId: id }, { botId: "x" }),
"host.browser.tabs": { params: { botId: id }, result: tabs, badParams: {}, badResult: {} },
"host.browser.close": {
params: { botId: id, tab: "t1" },
result: tabs,
badParams: { botId: id },
badResult: { tabs: [{}] },
},
"host.browser.screenshot": {
params: { botId: id, fullPage: true },
result: { image: { ...image, mimeType: "image/jpeg" as const }, width: 1, height: 1 },
badParams: { botId: id, fullPage: 1 },
badResult: { image, width: 0, height: 1 },
},
"host.browser.wait": {
params: { botId: id, for: "text" as const, value: "Done" },
result: { page, matched: true },
badParams: { botId: id, for: "idle" },
badResult: { page },
},
"host.browser.downloads": {
params: { botId: id },
result: { downloads: [] },
badParams: {},
badResult: { downloads: [{}] },
},
"host.browser.release": { params: { botId: id }, result: null, badParams: {}, badResult: 1 },
"host.browser.sleeping": {
params: { botId: id },
result: { url: "https://example.com/" },
badParams: {},
badResult: { url: 1 },
},
"host.browser.status": {
params: undefined,
result: { bots: [{ botId: id, tabs: 1, busy: false }] },
badParams: { botId: id },
badResult: {},
},
"host.browser.record.start": {
params: { botId: id },
result: null,
badParams: {},
badResult: 1,
},
"host.browser.record.stop": {
params: { botId: id },
result: { events: [{ kind: "click" as const, tab: "t1", at: 1 }] },
badParams: {},
badResult: { events: [{ kind: "type", tab: "t1", at: 1 }] },
},
};
}
const eventCases = {
"import.progress": { payload: importStatus, bad: {} },
"acp.changed": { payload: { connected: false }, bad: { connected: true } },
"botHooks.changed": { payload: { botId: id }, bad: { botId: "invalid" } },
...remoteEventCases,
...groupEventCases,
...executionEventCases,
...connectorEventCases,
...knowledgeEventCases,
...computerEventCases,
...browserEventCases,
...browserExtensionEventCases,
...skillEventCases,
...credentialEventCases,
"secrets.changed": {
payload: { action: "removed", name: "TOKEN", revision: 2, meta: null },
bad: { action: "removed", name: "TOKEN", revision: 0, meta: null },
},
"routines.changed": { payload: { id }, bad: { unexpected: true } },
"routine.run": {
payload: {
routineId: id,
routineRunId: id,
runId: null,
botId: id,
status: "scheduled",
conversationId: null,
messageId: null,
},
bad: { routineId: id, status: "done" },
},
"power.state": {
payload: {
state: "awake",
supply: "unknown",
keepAwake: "off",
at: date,
},
bad: { state: "asleep" },
},
"chat.status": {
payload: { botId: id, conversationId: id, runId: id, state: "running" },
bad: { botId: id, state: "invalid" },
},
"chat.activity": {
payload: {
botId: id,
conversationId: id,
runId: id,
messageId: id,
phase: "preparing_tool",
tool: "write_file",
characters: 3200,
},
bad: {
botId: id,
conversationId: id,
runId: id,
messageId: id,
phase: "preparing_tool",
tool: "write_file",
characters: -1,
},
},
"continuations.pending": {
payload: { conversationId: id, count: 0 },
bad: { conversationId: id, count: -1 },
},
"runtime.health": {
payload: { healthy: false, reason: "run_drain_failed", botIds: [id] },
bad: { healthy: false, reason: "unknown", botIds: [] },
},
"runtime.commands": { payload: { paused: "retrying" }, bad: { paused: "paused" } },
"runtime.activeRuns": { payload: { count: 1 }, bad: { count: -1 } },
"bots.changed": { payload: { botId: id, reason: "created" }, bad: { unexpected: true } },
"groups.changed": { payload: { groupId: id, reason: "created" }, bad: { unexpected: true } },
"group.task": { payload: { task }, bad: { unexpected: true } },
"group.paused": {
payload: { groupId: id, reason: "limit", rounds: 4, limit: 4 },
bad: { unexpected: true },
},
"groups.resources.changed": {
payload: { groupId: id, kind: "memory" },
bad: { groupId: id, kind: "other" },
},
"memory.sortProgress": { payload: { processed: 0, total: 0, moves: 0 }, bad: { processed: -1 } },
"memory.changed": {
payload: { botId: id, reason: "added", memoryId: id },
bad: { unexpected: true },
},
"inbox.changed": { payload: {}, bad: { unexpected: true } },
"sidebar.changed": {
payload: { conversationKey: sidebarEntry.conversationKey },
bad: { unexpected: true },
},
"providers.loginState": { payload: authState, bad: { unexpected: true } },
"providers.loginStep": {
payload: { providerId: "anthropic", promptId: id, kind: "browser" },
bad: { unexpected: true },
},
"approval.requested": { payload: approval, bad: { ...approval, canRemember: "yes" } },
"approval.resolved": {
payload: { id, status: "allowed", remembered: true },
bad: { id, status: "pending", remembered: false },
},
"chat.tool": {
payload: {
runId: id,
messageId: id,
toolCallId: "call-1",
phase: "start",
tool: "run_command",
summary: "ls",
},
bad: {
runId: id,
messageId: id,
toolCallId: "call-1",
phase: "unknown",
tool: "run_command",
summary: "ls",
},
},
"permissions.changed": {
payload: permissions,
bad: { ...permissions, isolation: { available: "yes" } },
},
"chat.delta": { payload: envelope.params.payload, bad: { ...envelope.params.payload, text: 1 } },
"chat.message": {
payload: { botId: id, conversationId: id, runId: id, messageId: id, message },
bad: {
botId: id,
conversationId: id,
runId: id,
messageId: id,
message: { ...message, id: "bad" },
},
},
"chat.attachments": {
payload: { botId: id, runId: id, messageId: id, attachments: [] },
bad: { botId: id, runId: id, messageId: id, attachments: [{ id: "bad" }] },
},
"chat.done": {
payload: { runId: id, messageId: id, stopReason: "stop", usage: { input: 1 } },
bad: { runId: id, messageId: id, stopReason: false },
},
"chat.error": {
payload: { runId: id, messageId: id, code: "network", message: "Offline" },
bad: { runId: id, messageId: id, code: "oops", message: "Offline" },
},
"changes.changed": { payload: { runId: id, reason: "turn" }, bad: { reason: "poll" } },
"chat.notice": {
payload: {
id,
conversationId: id,
botId: id,
kind: "browser_handback" as const,
durationMs: 120000,
domains: ["data.stats.gov.cn"],
createdAt: date,
},
bad: { id, conversationId: id, botId: id, kind: "browser_handback", domains: ["a b"] },
},
"network.changed": {
payload: { enabled: true, address: "http://127.0.0.1:7890/", hasCredentials: false },
bad: { enabled: true, address: "http://user:[email protected]:7890/", hasCredentials: true },
},
"settings.changed": { payload: settings, bad: { ...settings, theme: "blue" } },
"providers.changed": { payload: {}, bad: { apiKey: "secret" } },
"ui.navigate": { payload: { botId: id, tab: "permissions" }, bad: { botId: id, tab: "shell" } },
"brain.status": { payload: { state: "ready" }, bad: { state: "running" } },
"conversations.yolo.changed": {
payload: { conversationId: id, enabled: true, enabledAt: date },
bad: { conversationId: id, enabled: true },
},
"execution.changed": {
payload: {
botId: id,
conversationId: id,
mode: "plan",
limits: DEFAULT_EXECUTION_LIMITS,
version: 1,
updatedAt: date,
},
bad: {
botId: id,
conversationId: id,
mode: "plan",
limits: DEFAULT_EXECUTION_LIMITS,
version: -1,
updatedAt: date,
},
},
"execution.task.changed": { payload: executionTask, bad: { ...executionTask, version: -1 } },
"execution.budget.changed": {
payload: executionBudget,
bad: { ...executionBudget, requests: -1 },
},
"execution.question.answered": {
payload: { botId: id, conversationIds: [id] },
bad: { botId: id, conversationIds: [] },
},
"execution.todo.changed": {
payload: {
botId: id,
conversationId: id,
goal: "Research",
items: [],
version: 1,
updatedAt: date,
},
bad: {
botId: id,
conversationId: id,
goal: "Research",
items: [],
version: -1,
updatedAt: date,
},
},
"foregroundCommands.changed": {
payload: { botId: id, runId: id, toolCallId: "call", active: true, available: true },
bad: { botId: id, runId: id, toolCallId: "call", active: "yes", available: true },
},
"backgroundCommands.changed": {
payload: backgroundCommand,
bad: { ...backgroundCommand, command: "x".repeat(501) },
},
"autoCheck.changed": {
payload: { botId: id, reason: "folder" },
bad: { botId: id, reason: "rounds" },
},
"capabilities.changed": {
payload: { scope: "bot", scopeId: id, capabilityId: "files.read" },
bad: { scope: "bot", scopeId: id, capabilityId: "unknown" },
},
"drafts.changed": {
payload: { approvalId: id, conversationId: id, status: "pending" },
bad: { approvalId: id, status: "pending" },
},
"externalAgents.detected": {
payload: { isolation: "sandbox", agents: [] },
bad: { isolation: "maybe", agents: [] },
},
"externalAgents.optionsChanged": {
payload: { botId: id, conversationId: id },
bad: { conversationId: id },
},
"externalAgents.statusChanged": {
payload: { botId: id, status: { kind: "quota" as const, checkedAt: date, command: null } },
bad: { botId: id, status: { kind: "quota" } },
},
} satisfies { [K in keyof EventPayloads]: { payload: EventPayloads[K]; bad: unknown } };
for (const [label, schemas, cases] of [
["Methods", Methods, methodCases],
["HostMethods", HostMethods, hostCases],
] as const) {
describe(label, () => {
it("has a fixture for every method", () =>
expect(Object.keys(cases).sort()).toEqual(Object.keys(schemas).sort()));
for (const [key, fixture] of Object.entries(cases)) {
const schema = (schemas as Record<string, { params: z.ZodType; result: z.ZodType }>)[key];
if (!schema) throw new Error(`Missing schema ${key}`);
it(`${key}: valid params`, () =>
expect(schema.params.safeParse(fixture.params).success).toBe(true));
it(`${key}: invalid params`, () =>
expect(schema.params.safeParse(fixture.badParams).success).toBe(false));
it(`${key}: valid result`, () =>
expect(schema.result.safeParse(fixture.result).success).toBe(true));
it(`${key}: invalid result`, () =>
expect(schema.result.safeParse(fixture.badResult).success).toBe(false));
}
});
}
describe("Events", () => {
it("has a fixture for every event", () =>
expect(Object.keys(eventCases).sort()).toEqual(Object.keys(Events).sort()));
for (const key of Object.keys(Events) as (keyof typeof Events)[]) {
it(`${key}: valid payload and envelope`, () => {
expect(Events[key].safeParse(eventCases[key].payload).success).toBe(true);
expect(
EventEnvelopeSchema.safeParse({
jsonrpc: "2.0",
method: key,
params: { seq: 1, payload: eventCases[key].payload },
}).success,
).toBe(true);
});
it(`${key}: invalid payload and envelope`, () => {
expect(Events[key].safeParse(eventCases[key].bad).success).toBe(false);
expect(
EventEnvelopeSchema.safeParse({
jsonrpc: "2.0",
method: key,
params: { seq: 1, payload: eventCases[key].bad },
}).success,
).toBe(false);
});
}
});
describe("shared schemas and boundary cases", () => {
const shared: [string, z.ZodType, unknown, unknown][] = [
["Id", IdSchema, id, "bad"],
["Sequence", SequenceSchema, 0, 1.5],
["AgentErrorCode", AgentErrorCodeSchema, "internal", "oops"],
["ThinkingLevel", ThinkingLevelSchema, "medium", "maximum"],
["Settings", SettingsSchema, settings, { ...settings, unknown: true }],
["SafeSecret", SafeSecretSchema, "fake-key", "!command"],
["WebUrl", WebUrlSchema, custom.baseUrl, "file:///tmp/model"],
["Api", ApiSchema, custom.api, "unknown"],
["CustomModel", CustomModelSchema, custom.models[0], { id: "model", maxTokens: 0 }],
["CustomProvider", CustomProviderSchema, custom, { ...custom, headers: { key: "!command" } }],
["Provider", ProviderSchema, provider, { ...provider, group: "unknown" }],
["ModelInfo", ModelInfoSchema, model, { ...model, input: ["audio"] }],
["Bot", BotSchema, bot, { ...bot, thinkingLevel: "maximum" }],
["Message", MessageSchema, message, { ...message, errorCode: "unknown" }],
["EventEnvelope", EventEnvelopeSchema, envelope, { ...envelope, method: "unknown" }],
// Runner file operations travel as one strict request; an unexpected field (the
// brain-side `authorizePath` callback) must never pass the wire.
[
"RunnerFileRequest",
RunnerFileRequestSchema,
{
operation: "searchText",
input: { cwd: "/work", writeRoots: ["/work"], path: "/work", query: "needle" },
},
{
operation: "searchText",
input: {
cwd: "/work",
writeRoots: ["/work"],
path: "/work",
query: "needle",
authorizePath: true,
},
},
],
];
it.each(shared)("%s accepts valid and rejects invalid", (_label, schema, valid, invalid) => {
expect(schema.safeParse(valid).success).toBe(true);
expect(schema.safeParse(invalid).success).toBe(false);
});
it.each(["", " fake-key", "fake-key ", "fake\nkey", "fake\rkey", "!command"])(
"rejects unsafe secret %j",
(value) => {
expect(SafeSecretSchema.safeParse(value).success).toBe(false);
expect(
Methods["customProviders.upsert"].params.safeParse({ ...custom, apiKey: value }).success,
).toBe(false);
},
);
it.each(["!command", "value\r\nX-Injected: true"])("rejects unsafe header %j", (value) => {
expect(
Methods["customProviders.fetchModels"].params.safeParse({
baseUrl: custom.baseUrl,
api: custom.api,
headers: { test: value },
}).success,
).toBe(false);
});
it("supports optional fields, empty lists, null fields and all specified enums", () => {
expect(HostMethods["host.env.read"].result.safeParse(null).success).toBe(true);
expect(Methods["providers.test"].result.safeParse({ ok: true, modelCount: 1 }).success).toBe(
true,
);
expect(Methods["models.list"].params.safeParse({}).success).toBe(true);
expect(
Methods["local.detectOllama"].result.safeParse({
running: false,
baseUrl: custom.baseUrl,
models: [],
}).success,
).toBe(true);
for (const code of AgentErrorCodeSchema.options)
expect(
Events["chat.error"].safeParse({ runId: id, messageId: id, code, message: "Error" })
.success,
).toBe(true);
for (const platform of ["darwin", "win32", "linux"])
expect(
Methods["app.getInfo"].result.safeParse({ ...methodCases["app.getInfo"].result, platform })
.success,
).toBe(true);
expect(SequenceSchema.safeParse(Number.MAX_SAFE_INTEGER + 1).success).toBe(false);
expect(
EventEnvelopeSchema.safeParse({ ...envelope, params: { ...envelope.params, seq: -1 } })
.success,
).toBe(false);
expect(
EventEnvelopeSchema.safeParse({ ...envelope, params: { ...envelope.params, payload: {} } })
.success,
).toBe(false);
});
});