import {GIVE_APP_CONTROL_OF_TOOL_RESPONSE} from "@mentra/sdk"
export class TodoAppServer extends AppServer {
protected async onToolCall(toolCall: ToolCall): Promise<string | undefined> {
const {toolId, activeSession} = toolCall
// Handle different tool calls
switch (toolId) {
case "get_todos": {
const todoList = userTodos
.map(todo => `- ${todo.completed ? "✓" : "○"} ${todo.text}${todo.dueDate ? ` (due ${todo.dueDate})` : ""}`)
.join("\n")
if (activeSession) {
// if the user is currently using the app, display the todo list in the app directly
activeSession.layouts.showTextWall(todoList)
return GIVE_APP_CONTROL_OF_TOOL_RESPONSE
} else {
// if the user is not currently using the app, return the todo list to Mira for Mira to relay
return `Your todo list:\n${todoList}`
}
}
}
}
}