diff --git a/app/assistant/direct-backend.ts b/app/assistant/direct-backend.ts new file mode 100644 index 00000000..f910b748 --- /dev/null +++ b/app/assistant/direct-backend.ts @@ -0,0 +1,141 @@ +import { + streamAnthropicMessage, + type AnthropicContentBlock, + type AnthropicMessage, + type AnthropicStreamHandle, + type AnthropicToolDefinition, +} from "../native/anthropic"; +import type { ToolRegistry } from "./tool-registry"; +import type { AssistantTurnCallbacks, AssistantTurnHandle } from "./types"; + +/** + * The on-phone agent loop: stream a reply, and while the model asks for tools, + * execute them through the registry and feed the results back until it stops. + * History lives in the AssistantSession; this backend appends the assistant + * and tool-result messages to the array it is handed. + */ + +/** Safety caps so a tool-thrashing model can't loop or run forever. */ +const MAX_ITERATIONS = 8; +const MAX_TURN_MS = 2 * 60 * 1000; + +export type DirectTurnOptions = { + apiKey: string; + model: string; + effort?: "low" | "medium" | "high"; + system: string; + /** Owned by the session; this loop appends assistant + tool_result messages. */ + messages: AnthropicMessage[]; + tools: AnthropicToolDefinition[]; + registry: ToolRegistry; + /** Map an API tool name (as the model calls it) back to its registry name. */ + resolveToolName: (apiName: string) => string; + callbacks: AssistantTurnCallbacks; +}; + +export class DirectAnthropicBackend { + runTurn(options: DirectTurnOptions): AssistantTurnHandle { + const startMs = Date.now(); + let cancelled = false; + let streamHandle: AnthropicStreamHandle | null = null; + + const finishError = (message: string) => { + if (cancelled) return; + cancelled = true; + options.callbacks.onError(message); + }; + + const runIteration = (iteration: number): void => { + if (cancelled) return; + if (iteration >= MAX_ITERATIONS) { + finishError("Assistant stopped: too many tool steps"); + return; + } + if (Date.now() - startMs > MAX_TURN_MS) { + finishError("Assistant stopped: turn took too long"); + return; + } + + streamHandle = streamAnthropicMessage({ + apiKey: options.apiKey, + model: options.model, + system: options.system, + effort: options.effort, + messages: options.messages, + tools: options.tools, + onTextDelta: (delta, textSoFar) => { + if (cancelled) return; + options.callbacks.onTextDelta(delta, textSoFar); + }, + onDone: (result) => { + streamHandle = null; + if (cancelled) return; + if (result.stopReason === "refusal") { + finishError("The assistant declined this request"); + return; + } + // Record what the model produced this iteration. + const assistantContent: AnthropicContentBlock[] = result.content.length + ? result.content + : [{ type: "text", text: result.text }]; + options.messages.push({ role: "assistant", content: assistantContent }); + + const toolUses = assistantContent.filter( + (block): block is Extract => + block.type === "tool_use", + ); + if (result.stopReason !== "tool_use" || toolUses.length === 0) { + options.callbacks.onTurnDone({ stopReason: result.stopReason }); + return; + } + void this.runToolCalls(toolUses, options) + .then((toolResults) => { + // Always record the results, even if cancelled mid-flight: an + // assistant tool_use with no matching tool_result would make the + // next turn's request invalid. Only the loop continuation is gated. + options.messages.push({ role: "user", content: toolResults }); + if (cancelled) return; + runIteration(iteration + 1); + }) + .catch((error) => { + finishError(`Tool execution failed: ${String((error as Error)?.message ?? error)}`); + }); + }, + onError: (message) => { + streamHandle = null; + finishError(message); + }, + }); + }; + + runIteration(0); + + return { + cancel: () => { + cancelled = true; + streamHandle?.cancel(); + streamHandle = null; + }, + }; + } + + private async runToolCalls( + toolUses: Array>, + options: DirectTurnOptions, + ): Promise { + const results: AnthropicContentBlock[] = []; + for (const toolUse of toolUses) { + const canonicalName = options.resolveToolName(toolUse.name); + options.callbacks.onToolActivity(canonicalName); + const result = await options.registry.callTool(canonicalName, toolUse.input); + const content = result.ok ? result.content ?? "" : result.error ?? "Tool error"; + results.push({ + type: "tool_result", + tool_use_id: toolUse.id, + content, + is_error: !result.ok, + }); + } + return results; + } +} diff --git a/app/assistant/session.ts b/app/assistant/session.ts new file mode 100644 index 00000000..02d935b4 --- /dev/null +++ b/app/assistant/session.ts @@ -0,0 +1,156 @@ +import { DEFAULT_LLM_MODEL, type AnthropicMessage, type AnthropicToolDefinition } from "../native/anthropic"; +import { DirectAnthropicBackend } from "./direct-backend"; +import { toolRegistry, type ToolRegistry } from "./tool-registry"; +import type { AssistantContext, AssistantTurnCallbacks, AssistantTurnHandle } from "./types"; + +/** + * One assistant conversation. Owns the message history and turn state and + * drives a backend (direct Anthropic loop for phase 1). The UI talks only to + * this surface, so swapping in the external-agent backend later doesn't touch + * AssistantLayer. + * + * Sessions are cheap and idle-expire (see isExpired): the shell starts a fresh + * one for a new wakeword and reuses the current one for a follow-up. + */ + +/** A new PTT after this much idle starts a fresh conversation. */ +const SESSION_IDLE_MS = 10 * 60 * 1000; + +/** Trim history from the head once it grows past this many messages. */ +const MAX_HISTORY_MESSAGES = 40; + +const SYSTEM_PROMPT_BASE = [ + "You are the voice assistant built into a pair of Even Realities G2 smart glasses.", + "Your reply is shown as text on a 576x288 monochrome heads-up display and may also be read aloud, so keep it short: 1-3 plain sentences, no markdown, no bullet lists unless the user explicitly asks for a list.", + "Prefer doing things with the tools you have over describing how the user could do them; when a tool can answer or act, use it.", + "If a tool fails or a capability is missing, say so briefly rather than inventing a result.", +].join(" "); + +export class AssistantSession { + private readonly backend = new DirectAnthropicBackend(); + private readonly messages: AnthropicMessage[] = []; + private turnHandle: AssistantTurnHandle | null = null; + private lastActivityMs = Date.now(); + // API-safe tool name -> canonical registry name. The Anthropic API only + // allows [a-zA-Z0-9_-] in tool names, so dotted registry names ("glasses. + // get_state") are sanitized for the request and mapped back on tool calls. + private readonly toolNameMap = new Map(); + + constructor( + private readonly apiKey: string, + private readonly registry: ToolRegistry = toolRegistry, + ) {} + + /** Whether this session has been idle long enough to retire. */ + isExpired(nowMs = Date.now()): boolean { + return nowMs - this.lastActivityMs > SESSION_IDLE_MS; + } + + isTurnActive(): boolean { + return this.turnHandle !== null; + } + + /** Begin a turn from a spoken utterance. Only one turn runs at a time. */ + sendUtterance(text: string, ctx: AssistantContext, callbacks: AssistantTurnCallbacks): void { + if (this.turnHandle) { + callbacks.onError("The assistant is still working on the previous request"); + return; + } + this.lastActivityMs = Date.now(); + this.messages.push({ role: "user", content: text }); + this.trimHistory(); + + const tools = this.buildToolDefinitions(); + const system = `${SYSTEM_PROMPT_BASE}\n\n${describeContext(ctx)}`; + + const finish = () => { + this.turnHandle = null; + this.lastActivityMs = Date.now(); + }; + + this.turnHandle = this.backend.runTurn({ + apiKey: this.apiKey, + model: DEFAULT_LLM_MODEL, + effort: "low", + system, + messages: this.messages, + tools, + registry: this.registry, + resolveToolName: (apiName) => this.toolNameMap.get(apiName) ?? apiName, + callbacks: { + onTextDelta: callbacks.onTextDelta, + onToolActivity: callbacks.onToolActivity, + onTurnDone: (result) => { + finish(); + callbacks.onTurnDone(result); + }, + onError: (message) => { + finish(); + callbacks.onError(message); + }, + }, + }); + } + + cancel(): void { + this.turnHandle?.cancel(); + this.turnHandle = null; + this.lastActivityMs = Date.now(); + } + + private buildToolDefinitions(): AnthropicToolDefinition[] { + this.toolNameMap.clear(); + return this.registry.listTools().map((spec) => { + const apiName = this.toApiToolName(spec.name); + this.toolNameMap.set(apiName, spec.name); + return { name: apiName, description: spec.description, input_schema: spec.inputSchema }; + }); + } + + /** Convert a canonical registry name to an Anthropic-legal tool name. */ + private toApiToolName(name: string): string { + let base = name.replace(/[^a-zA-Z0-9_-]/g, "_"); + // Disambiguate the rare case where two canonical names sanitize alike. + if (this.toolNameMap.has(base)) { + let i = 2; + while (this.toolNameMap.has(`${base}_${i}`)) i++; + base = `${base}_${i}`; + } + return base; + } + + private trimHistory(): void { + if (this.messages.length <= MAX_HISTORY_MESSAGES) return; + // Drop whole messages from the head. A leading orphan tool_result (whose + // tool_use we trimmed) would be rejected by the API, so skip past any + // tool_result-only user message left at the front. + const overflow = this.messages.length - MAX_HISTORY_MESSAGES; + this.messages.splice(0, overflow); + while (this.messages.length && startsWithToolResult(this.messages[0]!)) { + this.messages.shift(); + } + } +} + +function startsWithToolResult(message: AnthropicMessage): boolean { + return ( + Array.isArray(message.content) && + message.content.length > 0 && + message.content[0]!.type === "tool_result" + ); +} + +function describeContext(ctx: AssistantContext): string { + const parts = [`Current time: ${ctx.localTime}.`]; + parts.push(`The glasses display is currently ${ctx.screenOn ? "on" : "off"}.`); + if (ctx.foregroundApp) { + const title = ctx.foregroundTitle ? ` ("${ctx.foregroundTitle}")` : ""; + parts.push(`The foreground app is ${ctx.foregroundApp}${title}.`); + } else { + parts.push("No app is in the foreground (the launcher is showing)."); + } + if (ctx.headsetBattery !== null) { + parts.push(`Glasses battery: ${ctx.headsetBattery}%.`); + } + return `Context: ${parts.join(" ")}`; +} diff --git a/app/assistant/system-tools.ts b/app/assistant/system-tools.ts new file mode 100644 index 00000000..bc74f651 --- /dev/null +++ b/app/assistant/system-tools.ts @@ -0,0 +1,227 @@ +import { readUpcomingEvents, type CalendarEvent } from "../native/calendar"; +import { mediaControllerBridge } from "../native/media-controller"; +import { dismissNotification, readActiveNotifications } from "../native/notification-icons"; +import { shell } from "../ui/shell/shell"; +import { toolRegistry, type ToolRegistry, type ToolResult } from "./tool-registry"; + +/** + * Registers the always-available system tools into the registry. Called once at + * startup. These wrap shell state and the existing native bridges (calendar, + * media, notifications); nothing here needs an app window to be open. + */ + +const WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; +const MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + +let registered = false; + +export function registerSystemTools(registry: ToolRegistry = toolRegistry): void { + if (registered) return; + registered = true; + + // Keep a media listener warm so "what's playing" works without opening Music. + void mediaControllerBridge.start(); + + registry.registerSystemTool( + { + name: "glasses.get_state", + description: + "Get the current state of the glasses: display on/off, foreground app, headset battery, and the current local time.", + inputSchema: { type: "object", properties: {}, additionalProperties: false }, + proactive: true, + }, + () => ok(describeState()), + ); + + registry.registerSystemTool( + { + name: "glasses.show_alert", + description: + "Show a short text popup on the glasses display. Use for a brief notice the user should see; keep it to a sentence or two.", + inputSchema: { + type: "object", + properties: { text: { type: "string", description: "The message to display." } }, + required: ["text"], + additionalProperties: false, + }, + proactive: true, + }, + (args) => { + const text = String(args?.text ?? "").trim(); + if (!text) return err("show_alert requires non-empty text"); + shell.showAlert(text); + return ok("Displayed."); + }, + ); + + registry.registerSystemTool( + { + name: "calendar.list_events", + description: + "List the user's upcoming calendar events. Returns events from now forward, ordered by start time.", + inputSchema: { + type: "object", + properties: { + within_hours: { + type: "number", + description: "Only include events starting within this many hours (default 168 = one week).", + }, + max_events: { type: "number", description: "Maximum number of events to return (default 10)." }, + }, + additionalProperties: false, + }, + }, + (args) => { + const withinHours = clampNumber(args?.within_hours, 1, 24 * 60, 168); + const maxEvents = clampNumber(args?.max_events, 1, 50, 10); + const events = readUpcomingEvents(maxEvents, withinHours * 60 * 60 * 1000); + if (!events.length) return ok("No upcoming events in that window."); + return ok(events.map(formatEvent).join("\n")); + }, + ); + + registry.registerSystemTool( + { + name: "media.now_playing", + description: "What is currently playing (or paused) in the user's media app, if anything.", + inputSchema: { type: "object", properties: {}, additionalProperties: false }, + proactive: true, + }, + () => ok(describeNowPlaying()), + ); + + registry.registerSystemTool( + { + name: "media.play_pause", + description: "Toggle play/pause for the user's current media session.", + inputSchema: { type: "object", properties: {}, additionalProperties: false }, + }, + async () => { + const state = mediaControllerBridge.snapshot(); + if (!state.canPlayPause) return err("No media session can be controlled right now."); + await mediaControllerBridge.playPause(); + return ok("Toggled play/pause."); + }, + ); + + registry.registerSystemTool( + { + name: "media.next", + description: "Skip to the next track in the user's current media session.", + inputSchema: { type: "object", properties: {}, additionalProperties: false }, + }, + async () => { + const state = mediaControllerBridge.snapshot(); + if (!state.canSkipNext) return err("The current media session can't skip to the next track."); + await mediaControllerBridge.skipNext(); + return ok("Skipped to the next track."); + }, + ); + + registry.registerSystemTool( + { + name: "notifications.list", + description: "List the user's current Android notifications mirrored to the glasses.", + inputSchema: { + type: "object", + properties: { max: { type: "number", description: "Maximum notifications to return (default 10)." } }, + additionalProperties: false, + }, + }, + (args) => { + const max = clampNumber(args?.max, 1, 50, 10); + const notifications = readActiveNotifications(max); + if (!notifications.length) return ok("No current notifications."); + return ok(notifications.map(formatNotification).join("\n")); + }, + ); + + registry.registerSystemTool( + { + name: "notifications.dismiss", + description: + "Dismiss a notification by its key (as returned by notifications.list). Returns whether it was dismissed.", + inputSchema: { + type: "object", + properties: { key: { type: "string", description: "The notification key from notifications.list." } }, + required: ["key"], + additionalProperties: false, + }, + }, + (args) => { + const key = String(args?.key ?? "").trim(); + if (!key) return err("notifications.dismiss requires a key"); + return dismissNotification(key) ? ok("Dismissed.") : err("No notification with that key."); + }, + ); +} + +function describeState(): string { + const parts: string[] = []; + parts.push(`Display: ${shell.isScreenOn() ? "on" : "off"}.`); + const fg = shell.getForegroundApp(); + parts.push(fg ? `Foreground app: ${fg.appId} ("${fg.title}").` : "Foreground: launcher (no app open)."); + const battery = shell.getBatteryLevels(); + if (battery.headset !== null) { + const charging = battery.headsetCharging ? ", charging" : ""; + parts.push(`Headset battery: ${battery.headset}%${charging}.`); + } + parts.push(`Local time: ${formatDateTime(new Date())}.`); + return parts.join(" "); +} + +function describeNowPlaying(): string { + const state = mediaControllerBridge.snapshot(); + if (!state.accessEnabled) return "Notification access isn't granted, so media state is unavailable."; + if (state.playbackState === "playing" || state.playbackState === "paused") { + const verb = state.playbackState === "playing" ? "Playing" : "Paused"; + const title = state.title || "(unknown title)"; + const artist = state.artist ? ` by ${state.artist}` : ""; + const app = state.appName ? ` in ${state.appName}` : ""; + return `${verb}: ${title}${artist}${app}.`; + } + return "Nothing is currently playing."; +} + +function formatEvent(event: CalendarEvent): string { + const when = event.allDay ? `${formatDate(new Date(event.startMs))} (all day)` : formatDateTime(new Date(event.startMs)); + const location = event.location ? ` @ ${event.location}` : ""; + return `- ${event.title || "(untitled)"} — ${when}${location}`; +} + +function formatNotification(notification: { key: string; appName: string; title: string; text: string }): string { + const title = notification.title || "(no title)"; + const body = notification.text ? `: ${notification.text}` : ""; + return `- [${notification.appName}] ${title}${body} (key: ${notification.key})`; +} + +function formatDateTime(date: Date): string { + return `${formatDate(date)}, ${formatTime(date)}`; +} + +function formatDate(date: Date): string { + return `${WEEKDAYS[date.getDay()]} ${MONTHS[date.getMonth()]} ${date.getDate()}`; +} + +function formatTime(date: Date): string { + let hours = date.getHours(); + const minutes = date.getMinutes().toString().padStart(2, "0"); + const meridiem = hours >= 12 ? "PM" : "AM"; + hours = hours % 12; + if (hours === 0) hours = 12; + return `${hours}:${minutes} ${meridiem}`; +} + +function clampNumber(value: unknown, min: number, max: number, fallback: number): number { + const num = typeof value === "number" ? value : Number(value); + if (!Number.isFinite(num)) return fallback; + return Math.min(max, Math.max(min, Math.round(num))); +} + +function ok(content: string): ToolResult { + return { ok: true, content }; +} + +function err(error: string): ToolResult { + return { ok: false, error }; +} diff --git a/app/assistant/tool-registry.ts b/app/assistant/tool-registry.ts new file mode 100644 index 00000000..e39fa923 --- /dev/null +++ b/app/assistant/tool-registry.ts @@ -0,0 +1,190 @@ +/** + * The assistant's tool registry: the single place that knows which tools exist, + * whether each is currently callable, and how to invoke it. Both assistant + * backends (direct Anthropic loop, external agent bridge) list and call tools + * through here, so gating and timeouts are enforced in one spot rather than + * trusted to a model or a remote agent. + * + * Availability tiers (see notes/voice-assistant-design.md): + * - "always" system/shell tools; no app involved. + * - "installed" app tool live whenever the app is installed (no window + * needed) -- e.g. "start a 5 minute timer". + * - "open" app tool live while the app has a window open, foreground + * or backgrounded -- e.g. "next track". + * - "foreground" app tool live only while the app owns the foreground window + * -- e.g. "scroll down". + * + * Phase 1 only registers "always" tools; the tier machinery is here so the + * app-tool phases slot in without reshaping the registry. + */ + +export type ToolAvailability = "always" | "installed" | "open" | "foreground"; + +export type ToolSpec = { + /** Namespaced, e.g. "glasses.get_state" or "app.terminal.send_input". */ + name: string; + description: string; + /** JSON Schema for the tool's arguments. */ + inputSchema: object; + availability: ToolAvailability; + /** May be invoked outside an active voice turn (external mode proactive calls). */ + proactive?: boolean; + /** Round-trip cap; the registry rejects with a tool error past it. Default 10s. */ + timeoutMs?: number; +}; + +/** + * A tool's outcome. Flat (not a discriminated union) on purpose: this project + * builds with strictNullChecks off, so `ok: true|false` would widen to boolean + * and defeat union narrowing. Read `content` when ok, `error` when not. + */ +export type ToolResult = { + ok: boolean; + /** Text payload back to the model (when ok). */ + content?: string; + /** Error message back to the model (when not ok). */ + error?: string; +}; + +export type ToolHandler = (args: any) => Promise | ToolResult; + +export type ToolRegistration = { + spec: ToolSpec; + handler: ToolHandler; + /** + * Whether the tool is currently live. Absent means always live (the "always" + * tier). App-tool phases supply a predicate keyed on window/foreground state. + */ + isAvailable?: () => boolean; +}; + +export type ListToolsOptions = { + /** Only tools flagged proactive (for calls outside an active turn). */ + proactiveOnly?: boolean; +}; + +export type CallToolOptions = { + /** The call is happening outside an active voice turn; enforce proactive gating. */ + proactive?: boolean; +}; + +const DEFAULT_TOOL_TIMEOUT_MS = 10_000; + +export class ToolRegistry { + private readonly registrations = new Map(); + private readonly changeListeners = new Set<() => void>(); + + /** Register (or replace) a tool. Names are unique across all tiers. */ + register(registration: ToolRegistration): void { + const { name } = registration.spec; + this.registrations.set(name, registration); + this.fireToolsChanged(); + } + + /** Convenience for the always-live system tools. */ + registerSystemTool( + spec: Omit, + handler: ToolHandler, + ): void { + this.register({ spec: { ...spec, availability: "always" }, handler }); + } + + unregister(name: string): void { + if (this.registrations.delete(name)) { + this.fireToolsChanged(); + } + } + + /** Specs for the tools callable right now, given the availability tiers. */ + listTools(options: ListToolsOptions = {}): ToolSpec[] { + const specs: ToolSpec[] = []; + for (const registration of this.registrations.values()) { + if (!this.isLive(registration)) continue; + if (options.proactiveOnly && !registration.spec.proactive) continue; + specs.push(registration.spec); + } + return specs; + } + + /** + * Invoke a tool by name. Never throws: a missing/unavailable tool, a + * proactive-gating rejection, a handler exception, or a timeout all come back + * as `{ ok: false }` so the agent loop can surface them as tool errors. + */ + async callTool(name: string, args: unknown, options: CallToolOptions = {}): Promise { + const registration = this.registrations.get(name); + if (!registration) { + return { ok: false, error: `Unknown tool: ${name}` }; + } + if (!this.isLive(registration)) { + return { ok: false, error: `Tool ${name} is not currently available` }; + } + if (options.proactive && !registration.spec.proactive) { + return { ok: false, error: `Tool ${name} cannot be called outside a conversation` }; + } + const timeoutMs = registration.spec.timeoutMs ?? DEFAULT_TOOL_TIMEOUT_MS; + try { + return await this.withTimeout(registration.handler(args), timeoutMs, name); + } catch (error) { + return { ok: false, error: `Tool ${name} failed: ${describeError(error)}` }; + } + } + + /** Subscribe to add/remove/availability changes (drives MCP list_changed). */ + onToolsChanged(listener: () => void): () => void { + this.changeListeners.add(listener); + return () => this.changeListeners.delete(listener); + } + + /** App-tool phases call this after a foreground/window change re-gates tools. */ + fireToolsChanged(): void { + for (const listener of this.changeListeners) { + try { + listener(); + } catch (error) { + console.warn("onToolsChanged listener failed", error); + } + } + } + + private isLive(registration: ToolRegistration): boolean { + return registration.isAvailable ? registration.isAvailable() : true; + } + + private withTimeout( + result: Promise | ToolResult, + timeoutMs: number, + name: string, + ): Promise { + if (!(result instanceof Promise)) return Promise.resolve(result); + return new Promise((resolve) => { + let settled = false; + const timer = setTimeout(() => { + if (settled) return; + settled = true; + resolve({ ok: false, error: `Tool ${name} timed out after ${timeoutMs}ms` }); + }, timeoutMs); + result.then( + (value) => { + if (settled) return; + settled = true; + clearTimeout(timer); + resolve(value); + }, + (error) => { + if (settled) return; + settled = true; + clearTimeout(timer); + resolve({ ok: false, error: `Tool ${name} failed: ${describeError(error)}` }); + }, + ); + }); + } +} + +function describeError(error: unknown): string { + return String((error as Error)?.message ?? error); +} + +/** The process-wide registry; system tools register into it at startup. */ +export const toolRegistry = new ToolRegistry(); diff --git a/app/assistant/types.ts b/app/assistant/types.ts new file mode 100644 index 00000000..10e90551 --- /dev/null +++ b/app/assistant/types.ts @@ -0,0 +1,32 @@ +/** + * Shared assistant types. Kept backend-agnostic so the UI (AssistantLayer) + * talks to the same session surface whether the turn runs on the phone + * (direct Anthropic loop) or against the user's own agent (external bridge, + * later phases). + */ + +/** Situational grounding injected per turn (system prompt in direct mode). */ +export type AssistantContext = { + /** Foreground app id, or null when the sidebar/launcher is all that's up. */ + foregroundApp: string | null; + foregroundTitle: string | null; + screenOn: boolean; + /** Human-readable local time, e.g. "Thu Jul 24, 3:15 PM". */ + localTime: string; + /** Headset battery percent (0..100), or null if unknown. */ + headsetBattery: number | null; +}; + +export type AssistantTurnCallbacks = { + /** Streamed reply text (delta plus the full text so far). */ + onTextDelta: (delta: string, textSoFar: string) => void; + /** A tool is being invoked; label is display-ready, e.g. "calendar.list_events". */ + onToolActivity: (label: string) => void; + onTurnDone: (result: { stopReason: string | null }) => void; + onError: (message: string) => void; +}; + +/** A handle to an in-flight turn. */ +export type AssistantTurnHandle = { + cancel(): void; +}; diff --git a/app/g2/dashboard-controller.ts b/app/g2/dashboard-controller.ts index 64bf0247..b86ee575 100644 --- a/app/g2/dashboard-controller.ts +++ b/app/g2/dashboard-controller.ts @@ -25,6 +25,7 @@ import { beginRenderPass, endRenderPass } from "../util/render-freshness"; import { voiceControlBridge } from "../native/voice-control"; import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../graphics/image"; import { rawInputEventToInputEvent, shell, type ShellInputOutcome } from "../ui/shell/shell"; +import { registerSystemTools } from "../assistant/system-tools"; import { WorkerAppHost } from "../ui/shell/worker-window"; import { createLauncherWindow, LAUNCHER_SURFACE_ID } from "../ui/shell/launcher-app"; import { @@ -236,6 +237,9 @@ class DashboardController { playBuzzerSequence: (payload: Uint8Array) => this.playBuzzerSequence(payload), }; this.sharedActions = sharedActions; + // The always-available assistant tools (calendar, media, notifications, + // glasses state) register once at startup, independent of any connection. + registerSystemTools(); shell.configure({ actions: { ...sharedActions, diff --git a/app/g2/firmware/cfw-patches.ts b/app/g2/firmware/cfw-patches.ts index b890c3e3..0568e24c 100644 --- a/app/g2/firmware/cfw-patches.ts +++ b/app/g2/firmware/cfw-patches.ts @@ -1,5 +1,5 @@ // AUTO-GENERATED from g2flash/patches/cfw_patches.json — do not edit by hand. -// Regenerate by re-running the generator in the firmware onboarding change. +// Regenerate with scripts/update_deltas.sh. // Turns the stock G2 2.2.6.10 image into the Faceclaw custom firmware. export type FirmwarePatchOp = { @@ -19,7 +19,7 @@ export type FirmwarePatchSet = { export const CFW_PATCH_SET: FirmwarePatchSet = { "base": "g2_2.2.6.10.bin", "baseSha256": "f4dfb0b49ad3de3c2daf17f8a27a157c3dc98411d6a0d3ab2cfd0918f41b9afa", - "outputSha256": "162fa8aab6f41be5e314d51b56f3e8f3eb2143af93ee0518d1919d096701474d", + "outputSha256": "ba7e896e516d049e530d7aaed30e358b45f940e81a90f997a44465299151b452", "patches": [ { "offset": 1449549, @@ -42,85 +42,103 @@ export const CFW_PATCH_SET: FirmwarePatchSet = { { "offset": 1447919, "old": "7ef7fefd", - "new": "b8f28cfe", + "new": "b8f2f6fe", "desc": "bl snapshot_side @ 0x4db968" }, { "offset": 1448931, "old": "7ef704fc", - "new": "b8f292fc", + "new": "b8f2fcfc", "desc": "bl snapshot_side @ 0x4dbd5c" }, { "offset": 1165461, "old": "45f0cefd", - "new": "fdf23dfe", + "new": "fdf2a7fe", "desc": "bl image_deferred (deferred consumer -> FIFO restore + worker, both lenses)" }, { "offset": 1186287, "old": "d9f7d4ff", - "new": "f8f2d0fe", + "new": "f9f2b8fb", "desc": "bl settings_send_wrapper (append caps field 100)" }, + { + "offset": 1183983, + "old": "f4f75aff", + "new": "f9f2b6fd", + "desc": "bl settings_decode_wrapper (Faceclaw lease field 101)" + }, + { + "offset": 926945, + "old": "08f068fa", + "new": "38f3d9fa", + "desc": "bl faceclaw_display_start @ 0x45c65a (fail-open double-tap takeover)" + }, + { + "offset": 927137, + "old": "08f008fa", + "new": "38f379fa", + "desc": "bl faceclaw_display_start @ 0x45c71a (fail-open double-tap takeover)" + }, { "offset": 822553, "old": "28f003f8", - "new": "51f39dfd", + "new": "52f39dfa", "desc": "bl evenhub_longpress (replaces force-quit dialog)" }, { "offset": 823369, "old": "1cf09bfb", - "new": "51f321fc", + "new": "52f321f9", "desc": "bl ring_release (forward ring release-long-press)" }, { - "offset": 1474163, - "old": "34d1", - "new": "34e0", - "desc": "even_ai_display_ctrl: skip Even AI app START (wakeword -> phone)" + "offset": 1474137, + "old": "7fb50600", + "new": "b3f271b9", + "desc": "even_ai_display_ctrl entry -> conditional Faceclaw lease trampoline" }, { "offset": 4301227, "old": "", - "new": "02fb01f044f6d341c0f24701084700bf084644f61751c0f24701084770b500284ed001684ef65a62ccf2ff02914218bf70bd90f8081190f8095142f6c52c8d42c0f2500c2ad205eb8501014491f80d2191f80e4191f80ae191f80b3191f80c1142ea0424012c4ff0010298bf14466e1c054680f80961b9b164294eea032028bf6421012888bf024644f62060824228bf02460cf5e2731046984706e0002180f80811bde870406047e047d5f8040138b149f29942c0f244022146bde87040104770bd00bf2de9f04f85b043f6fc76c2f200063568804628466ff3960044f6d344b0f1005fc0f2470406d128684ef65a61ccf2ff0188423bd04ff4fe70a0470546a8b30020002100bf6a1868540431b1f5fe7f50709070d070f6d14ef65a60ccf2ff002860012085f8ce004ff0ff30a5f8e000a5f8e200a5f8e400a5f8e600a5f8e800a5f8ea00a5f8ec00a5f8ee00a5f8f000a5f8f200a5f8f400a5f8f600a5f8f800a5f8fa00a5f8fc00a5f8fe003560b8f1000f18bf002d07d14af26950c0f2450005b0bde8f04f0047d8f80cb0bbf1000ff2d0d8f820a0baf1000fedd0a94659f8040f00287bd0686900287ad0686a002879d0686b002878d0686c002877d0686d002876d0686e002875d0686f002874d0d5f88400002872d0d5f89400002870d0d5f8a40000286ed0d5f8b40000286cd0d5f8b00029690490d5f8a0002a6b0390d5f8900000260290d5f880002f6f0190286ad5f860e0d5f850c02b6c884238bf014638bf01268a423cbf114602268b423cbf194603268c453cbf614604268e453cbf714605268f423cbf39460626019888423cbf01460726029888423cbf01460826039888423cbf014609260498884238bf0146d5f8c00038bf0a26884238bf0b2609eb0610406804f1440137018847002049f80700012085f8df0016e0002614e0012612e0022610e003260ee004260ce005260ae0062608e0072606e0082604e0092602e00a2600e00b265046a04700283ff451af0af0030c5fea9a034ff0000219d00496a2eb830e431c0bf101066ff0030700bff119cc78da19d4700c79043714714c79547189790eeb070404349171f0d1049e3a1dbcf1000f10d01bf80230bcf1010f83540ad0531c1bf80370bcf1020fc75403d0911c1bf80120425409eb06114860d5f8c400320149f80280421cc1f808a0c5f8c420c8600ce738464146fff7aebe2de9f04f81b043f6fc79c2f20009d9f80050044628466ff3960044f6d34816460f46b0f1005fc0f2470806d128684ef65a61ccf2ff0188423dd04ff4fe70c0470546002800f09580002000216a1868540431b1f5fe7f50709070d070f6d14ef65a60ccf2ff002860012085f8ce004ff0ff30a5f8e000a5f8e200a5f8e400a5f8e600a5f8e800a5f8ea00a5f8ec00a5f8ee00a5f8f000a5f8f200a5f8f400a5f8f600a5f8f800a5f8fa00a5f8fc00a5f8fe00c9f8005005f1040b4ff0000a4ff0000900bf4ff0ff30002200234ff0ff3105e000bf6032c02a03f1060332d0af187e68a64204d13e6986423cbf194630467e69a64204d13e6a86423cbf591c30467e6aa64204d13e6b86423cbf991c30467e6ba64204d13e6c86423cbfd91c30467e6ca64204d13e6d86423cbf191d30467e6da642ced13f6e87423cbf591d3846c8e700bf002910d40beb01104768090182684bf801a02046394600f013f8814608f1440138468847ace7484601b0bde8f08f204639463246c9f8005001b0bde8f04fffe72de9f041a4b0064640f6bb4043f6fc78c0f24e0014460d46c2f200088047002002af0390384600f01bf90df10c0c3046294622460123cdf800c000f0bff90446384600f015ffd8f8001005460a466ff39602b2f1005f06d108684ef65a62ccf2ff0290423fd044f6d341c0f247014ff4fe708847d0b30146002000228b1888540432b2f5fe7f58709870d870f6d14ef65a60ccf2ff000860012081f8ce004ff0ff30a1f8e000a1f8e200a1f8e400a1f8e600a1f8e800a1f8ea00a1f8ec00a1f8ee00a1f8f000a1f8f200a1f8f400a1f8f600a1f8f800a1f8fa00a1f8fc00a1f8fe00c8f80010c1f8d05002e00020c8f80000204624b0bde8f08100bf09295ad1f0b502eb030c352756248cf8107037278cf804404e248cf8117036278cf8064043248cf812707a278cf8074046248cf8177072274ff0a20e8cf8084057248cf819706c2702f803e04ff0060e8cf809402f248cf81a7065278cf801e04ff0450e8cf80a4032248cf81b7000278cf803e08cf805e08cf80b4020244ff0690e6d2567268cf81c7019271c338cf80c408cf80de08cf80e508cf80f608cf813408cf814e08cf815508cf816608cf818408cf80270bde8f04045f6153cc0f2470c60474df63040c2f234000078042818bf704780b582b04af26b1e4ff0000cc0f24d0e0020002100220923cdf804c0cdf800c0f04702b080bd00bff0b583b04df63043c2f234031b784ff6e704042bc0f2450420d144f2d043c2f207031b680546184616460f46a04703463946324628468bb11b68e02b0ed14af26b160027c0f24d060020002100220a2301970097b047012003b0f0bd04f1160303b0bde8f0401847f0b581b041f204054cf65561cef20005ccf2ac51c5f8ac1f4ef6fc51cef200010a6843f6fc7642f080720a6055f8041cc2f2000641f0010145f8041c316807460a466ff39602b2f1005f06d108684ef65a62ccf2ff02904240d044f6d341c0f247014ff4fe708847002870d001460020002200bf8b1888540432b2f5fe7f58709870d870f6d14ef65a60ccf2ff000860012081f8ce004ff0ff30a1f8e000a1f8e200a1f8e400a1f8e600a1f8e800a1f8ea00a1f8ec00a1f8ee00a1f8f000a1f8f200a1f8f400a1f8f600a1f8f800a1f8fa00a1f8fc00a1f8fe003160d1f8d800b8bb44f6342245f6e464c2f20702cff6f8741368204600bf16689e420ed116689e420bd116689e4208d116689e4203d1002800f10400efd19e421ad02b6816681068b0420ed11068b0420bd11068b04208d11068b04203d1002c04f10404efd1b04206d02868c01ac1f8d80001e0002030602868386001b0f0bd00bf2de9f04fdbb0002918bf002a04d15bb0bde8f04f00f00cbe0c7804f07f07052f00f0e580072f4dd0422ff0d0ddf89091b0f84080b0f842a0092f00f04e81082f40f058810746022a4ff0ff30c0f0b382002b00f0b082c3460bf10100032303eb500020f0030000fb0af07630824200f23c814d78fdb188460226b01c904200f2348108eb060318f806605b7856ea032300f02b811e18964200f2278108eb0001384614461a460023cdf80090fff7a8ff2246013de1d13846594652464b4600f01dfe77e243f6fc74c2f20004236818466ff39600b0f1005f06d118684ef65a67ccf2ff07b84243d00e4644f6d341c0f247014ff4fe70154688470346a8b30020002100bf5a1858540431b1f5fe7f50709070d070f6d14ef65a60ccf2ff001860012083f8ce004ff0ff30a3f8e000a3f8e200a3f8e400a3f8e600a3f8e800a3f8ea00a3f8ec00a3f8ee00a3f8f000a3f8f200a3f8f400a3f8f600a3f8f800a3f8fa00a3f8fc00a3f8fe0031462a462360022a2cbf4978ff21002b00f01b8202294ff0000000f01a82012900f01082002940f011824ff0ff31c3f8dc00a3f8cc00c3f8c800a3f8e010a3f8e210a3f8e410a3f8e610a3f8e810a3f8ea10a3f8ec10a3f8ee10a3f8f010a3f8f210a3f8f410a3f8f610a3f8f810a3f8fa10a3f8fc10a3f8fe1083f800015bb0bde8f08f43f6fc76c2f20006022a2cbf91f801804ff0ff08346820466ff39600b0f1005f06d120684ef65a63ccf2ff03984245d00f4644f6d341c0f247014ff4fe7015468847002800f0ff800446002000212a4600bf631860540431b1f5fe7f58709870d870f6d14ef65a60ccf2ff002060012084f8ce004ff0ff303946a4f8e000a4f8e200a4f8e400a4f8e600a4f8e800a4f8ea00a4f8ec00a4f8ee00a4f8f000a4f8f200a4f8f400a4f8f600a4f8f800a4f8fa00a4f8fc00a4f8fe00346094f8080178b1d4f8040148b149f29943c0f2440340330d461646984732462946002084f808010123032a80f0b580c1e027064ff0210658bf1126b24280f0e2804ff0ff305bb0bde8f08f032afff48aaefe1f16f1070f7ff685ae00254e1ca2f1010c8df834518df835518df838518df83c518df83d518df83e518df83f518df840518df841518df842518df843518df844518df845518df846518df847518df848518df849518df84a518df84b518df84c518df84d518df84e518df84f518df850518df851518df852518df853518df860518df861518df862518df863518df864518df865518df866518df867518df868518df869518df86a518df86b51cde94d6c4ff2a136cff6ff767e4455964ff2a536cff6ff767e44062f5696579500f01482032f00f09681012fcdf824a040f03b82064608f10100032101eb5000099920f00300484344f6d34a00f1b605c0f2470a2846d04700283ff472af4ef68727c0f25b074df254620446cde9500507f13c054da8c0f278020f213823a847002800f069824da8b8477ae200233360002439462a46032a0dd3b8f1000f0ad18878082800f2b28042f6c521c0f2500196318847aae0052a1bd3b8f1010f18d18f78781e06284ff0000000f2a080cb78032b00f29c800a79002a00f0988042f6c520c0f2500000f59a7638461946b0478ce0b8f1020f40f0928042f6c520c0f25000804782e0002f01f101070ed54af26952c0f2450204461d460e4690472b4601462046022918bf06f11107864638797a7950ea02244ff0ff301ebfba79fe7952ea062b63d03a7b7e7b42ea062294425dd1ba7bfe7bcdf82c8042ea0622934555d138787a780b9d40ea0222a018a8424ff0ff304bd8be78f97846ea012c0beb0c01514543d8397a7e7a41ea062804eb0801a9423bd8b97afe7a41ea06270beb0701514533d8def80c0000283ff4c9aecdf820e056469a460b9b0996591ca3eb510303fb060049086346cdf80cb0cde90174cdf8008001f057fed9f800000f280ad809ebc0010130a1f80480cf800c81a1f80ab0c9f800000898baf1000f05d00b99099a86e5012083f8ce0000205bb0bde8f08f83f8ce005bb0bde8f08f072a31d3b8f1030f2ed18878cb780a7940ea03204d798e7901284ff0010498bf204644f62061884228bf084642f6c521c0f25001642a28bf642201f5e2731146984744f20450c2f2070000680028ced045ea062149f29942012988bf0c46c0f2440221469047c2e7032a4ff00000bfd3a8f10407b7fa87f77f093b40b8d0d01e4cf6cd42ccf6cc428b78a0fb0202b3eb920f88bf9308302b184628bf3020002b00f0458100eb800303f0030c03f4fe770023ce18f578e21882f80a513579043382f80b5175799f4282f80c51b67982f80d61eed1bcf1000f10d01944ca782344bcf1010f83f80a2108d00a79bcf1020f83f80b211cbf497983f80c1184f80801d4f8040149f29945c0f24405002184f8091170b94ff28b00cff6ff70a5f1e807784422460023b8470028c4f8040100f0d5810121a8475ae7270600f1bc80082afff4f0ad844601274ff0050e0724cdf824a0ce1996f802a04ff0ff30baf1000f3ff446af0c94f478002c3ff441afc34611f807804fea8a0505eb88075f453ff637af767864000b9404eb4607099ca7423ff62eaf01eb0e000c4611f80e1040782f4641ea002081b201200a920593cdf820c001f068ff00287ff419af0898c06800283ff4afad75000bf10101099b0c9e4a08abeb510101fb0301a0194d900a9805fb0211801b0b9c4fea4a034e9001eb48014da8009402f018f800283ff492add9f800000f280ad84fea880109ebc00201309180d58017815481c9f80000059800283ff4e4ae0898099a594663e40546002000211c4601f026ffe86800283ff471ad08f10102a8eb520101fb0a0152084da81346cdf800a001f0e7ff00283ff461add9f800000f280ad809ebc001002201304a60a1f80880a1f80aa0c9f80000002c3ff4b4ae2846414633e44ef68724c0f25b044df2546205930890856804f13c064da8c0f278020f213823b04740b34da8a04736e50c2afff434adcf78ce79b7427ff42fad0f790e7ab7427ff42aad4af26954c0f24504cdf824a0c24680461e460d461746a0473a46052729463346c446d046022808bf01274ff0090e0b2427e7099e022f06fb08f735d104f585724da80421cde9505790470128c8d1ddf848914da8a047b9457ff4fcaccbe00020a4f808015bb0bde8f08f0df59a7907f58572484604219047ddf8488105464846b847012d06d130462146424600f085f9054601e04ff0ff350af144012046884728465bb0bde8f08f4af26950c0f24500cdf82c808047b0f1020818bfb846a5eb0800013007950690002008eb07090c900df1340a04f5857000260a904ff480700a9a51904da80021cdf840a19047ddf840e1beeb0a0c2fd0aaeb0e0111f1040f39d900231cf0030226d09d19454507d34d4505d21af80310a5eb0804079d2955012a19d05d1cac19444507d34c4505d21af80510079da4eb08042955022a0bd09a1c9319434507d34b4505d21af80210a3eb0802079b99546644beeb0a0118bf01214e450c9a28bf01220c9235d2a0bb0029b3d131e006992cf003058c19002302e004339d42bdd0f218424507d34a4505d21af8031004eb030b0bf8011c511c414505d3494503d20aeb03014978e154911c414506d3494504d20aeb03018978e7187970d11c4145dbd34945d9d20aeb0301c978e2189170d3e74ef687214da8c0f25b0188470c98099eddf82c80079d00283ff42fac059800283ff490ad089829464246334602f0f6f888e542f6c5200025c0f2500084f80851804740e72de9f04141f2040843f6fc77cef20008c2f200070146d8f8004038680d6801466ff39601b1f1005f06d101684ef65a62ccf2ff0291423fd044f6d341c0f247014ff4fe708847002846d00021002200bf831881540432b2f5fe7f59709970d970f6d14ef65a61ccf2ff010160012180f8ce104ff0ff31a0f8e010a0f8e210a0f8e410a0f8e610a0f8e810a0f8ea10a0f8ec10a0f8ee10a0f8f010a0f8f210a0f8f410a0f8f610a0f8f810a0f8fa10a0f8fc10a0f8fe103860d0f8d81081b144f6d350c1f26200a1fb0001880901284ff0010088bf88094be000203860fa2047e044f6342245f6e466c2f20702cff6f8761368314617689f420ed117689f420bd117689f4208d117689f4203d1002901f10401efd19f422ad0d8f80030176800bf1168b9420ed11168b9420bd11168b94208d11168b94203d1002e06f10406efd1b94214d0d8f8001044f6d357ca1ac1f26207a2fb0776c0f8d820b00901284ff0010088bfb009994208bffa2000e0fa20611bb1fbf0f0bde8f08100bff0b583b0002958d0362a56d30b78422b53d14b784d2b50d10b7f4f7f43ea0723042b4ad18b7dcf7d0e7e43ea072343ea06434f7e8e7ccd7c53ea076346ea05270e7d4d7d47ea064747ea05641d4648bf5d42b0f84070002b4ff00003c8bf0123bc422ad1b0f84270bd4226d18f7ace7a91f80cc047ea06274e7b47ea0c4747ea0667974219d2621c032606eb5202866822f0030cca19cde901c30746304621462346009502f00cf83846314622462b4601f0d4ff002003b0f0bd4cf2af53c0f24d0303b0bde8f040184700bf2de9f04f9fb0d0f80c80b8f1000f00f0d88105460aa816460c460493fff7c4f8a868002e03950690cde9086400f08780601c4fea500aa4eb500000fb06f100fb068c601e079024f003004742069804f00309451c01eb0800a0f1020e002106e0099c089e01312544b142d64467d0002cf6d00798032805d20022b9f1000f27d1eee700bf6ff00302734600bf13f8020f00f0f00646ea1010ae18f0701878043200f00f0444ea00103071587800f0f00444ea10107071587800f00f0444ea0010bc180434b071e1d10432b9f1000fc7d001fb0ac65008305c099b069c00f00f0801fb03435feac27b08bf4fea101848ea0810b9f1010f9854b2d002f101084fea5800305c64464fea101cbbf1000f08bf00f00f0c4cea0c10a446b9f1020f03f808009dd0901c4208b25cbbf1000f02f00f0608bf160946ea06121a5490e743f6fc75c2f20005d5f8009040f2030848464ef65a6b6ff3960044f6d347cff68078ccf2ff0bb0f1005fc0f247070dd1d9f80000584509d199f8ce00002800f02481039e4ff0000a484643e04ff4fe70b847c0b30021002200bf831881540432b2f5fe7f59709970d970f6d1012180f8ce104ff0ff31039ec0f800b0a0f8e010a0f8e210a0f8e410a0f8e610a0f8e810a0f8ea10a0f8ec10a0f8ee10a0f8f010a0f8f210a0f8f410a0f8f610a0f8f810a0f8fa10a0f8fc10a0f8fe1028604ff0000a814606e00020039e28604ff0010a4ff0000900ea0801b1f1005f67d10168594564d190f8ce10ddf82480002940f0998090f8dc200021002a8df82c1000f05a820baa535c002b00f02d8253185f78002f00f003829f78002f00f00182df78002f00f0ff811f79002f00f0fd815f79002f00f0fb819f79002f00f0f981df79002f00f0f7811f7a002f00f0f5815f7a002f00f0f3819f7a002f00f0f181df7a002f00f0ef811f7b002f00f0ed815f7b002f00f0eb819f7b002f00f0e981df7b002f00f0e7811f7c002f00f0e5815f7c002f00f0e3819f7c002f00f0e181db7c002b00f0df8114315029abd1ffe14ff4fe70b847ddf8248090b300210022831881540432b2f5fe7f59709970d970f6d1012180f8ce104ff0ff31c0f800b0a0f8e010a0f8e210a0f8e410a0f8e610a0f8e810a0f8ea10a0f8ec10a0f8ee10a0f8f010a0f8f210a0f8f410a0f8f610a0f8f810a0f8fa10a0f8fc10a0f8fe1000e000202860089d069f45f20f1105fb08f40ba8c0f24701cde90b74884740f2196046f8240f708948f2816248ea0040b06048ea054056f8205c7060c0f2490228463146f4603761904740f25761c0f24401284688470aa8fff700fdbaf1000f08bfc9f8d4001fb0bde8f08fddf810a0daf8000000283ff4d5ae0af10400079006980023011f03380090a000cdf808900191059006e000bfdaf800000133834280f01781079800ebc30290880028f3d0d1880029f0d0b2f80080099f4745ebd9b2f802e07645e7d94044099ca0f1010901eb0e00a0f1010ca14528bfa4f10109b44528bfa6f1010cc14561d3a9eb0801481c10f00302454628d0069d012a04fb0e500cfb045710f8086008f101056fea060600f8086017f808606fea060607f8086013d0465d022a6fea060646557e5d6fea06067e5508f1020507d0425dd2434255785dc043785508f1030503292fd304fb0ef00cfb04f2019c09f101012718009810447a1916790439f64316714619f4780437e443f47054798d426fea04045471347900f104006fea0404347194796fea0404947174796fea04047471d4796fea0404d471b2796fea0202b271d9d10ef10100089e6045bff46eafaeeb0c01032232ea010135d0099c069a012900fb042010f808206fea020200f8082010f809206fea020200f809200ef1020021d0069a022900fb042010f808206fea020200f8082010f809206fea020200f809200ef103000ed0069900fb041010f80810c94300f8081010f80910c94300f809100ef10400aceb0e0102390329fff42caf099ec11caceb000506fb019c4f4606fb0189811c06fb017b06fb018e411c424606fb017806fb012406fb007106fb0027069800bfc65d059af643c655465c043d6fea06064654065d6fea0606065510f808606fea060600f8086010f80e606fea060600f80e6010f80b606fea060600f80b6010f809606fea060600f8096010f80c606fea060600f80c60089e1044d1d1e2e643f6fc75c2f200052868dde902964ef65a6b44f6d34740f203084ff0000accf2ff0bc0f24707cff68078dbe5013122e0023120e003311ee004311ce005311ae0063118e0073116e0083114e0093112e00a3110e00b310ee00c310ce00d310ae00e3108e00f3106e0103104e0113102e0123100e013314f2921d84ff0520353541dd00a4445234e29537018d04f234d29937014d052234c29d37010d044234b2913710cd045234a29537108d052234929937104d020234829d37140f01f8700218df87b10012190f8dd20002a70d000220bab9f5c002f4fd09f187e783eb3be783eb3fe783eb33e793eb37e793eb3be793eb3fe793eb33e7a3eb37e7a3eb3be7a3eb3fe7a3eb33e7b3eb37e7b3eb3be7b3eb3fe7b3eb33e7c3eb37e7c3eb3be7c3eb3ff7c3fb31432502ad2d13ce0013222e0023220e003321ee004321ce005321ae0063218e0073216e0083214e0093212e00a3210e00b320ee00c320ce00d320ae00e3208e00f3206e0103204e0113202e0123200e013324f2a15d84ff053079f5411d013444b274e2a5f700cd049274d2a9f7008d050274c2adf7004d020274b2a1f7140f0608100228df87b20013190f8de20002a6cd000210baa535c002b4fd053185f783fb39f783fb3df783fb31f793fb35f793fb39f793fb3df793fb31f7a3fb35f7a3fb39f7a3fb3df7a3fb31f7b3fb35f7b3fb39f7b3fb3df7b3fb31f7c3fb35f7c3fb39f7c3fb3db7c3bb314315029d2d138e0013122e0023120e003311ee004311ce005311ae0063118e0073116e0083114e0093112e00a3110e00b310ee00c310ce00d310ae00e3108e00f3106e0103104e0113102e0123100e013314f2911d84ff0440353540dd00a4455234e29537008d050234d29937004d020234c29d37040f0ec8000218df87b10012190f8df20002a4dd000210baa535c002b00f0bc8053185f78002f00f092809f78002f00f09080df78002f00f08e801f79002f00f08c805f79002f00f08a809f79002f00f08880df79002f00f086801f7a002f00f084805f7a002f00f082809f7a002f00f08080df7a002f7ed01f7b002f7dd05f7b002f7cd09f7b002f7bd0df7b002f7ad01f7c002f79d05f7c002f78d09f7c002f77d0db7c002b76d014315029b4d1d0e0002940f0d18000210baa535c002b00f0b88053185f78002f00f08e809f78002f00f08c80df78002f00f08a801f79002f00f088805f79002f00f086809f79002f00f08480df79002f00f082801f7a002f00f080805f7a002f7ed09f7a002f7dd0df7a002f7cd01f7b002f7bd05f7b002f7ad09f7b002f79d0df7b002f78d01f7c002f77d05f7c002f76d09f7c002f75d0db7c002b74d014315029b6d181e0013122e0023120e003311ee004311ce005311ae0063118e0073116e0083114e0093112e00a3110e00b310ee00c310ce00d310ae00e3108e00f3106e0103104e0113102e0123100e013314f295ad84ff05303535456d00a444e234e29537051d041234d2993704dd050234c29d37049d04f234b29137145d046234a29537141d02023492993713dd00021d1713de00021117113e700225a719fe6013122e0023120e003311ee004311ce005311ae0063118e0073116e0083114e0093112e00a3110e00b310ee00c310ce00d310ae00e3108e00f3106e0103104e0113102e0123100e013314f290dd84ff04f03535409d00a444b234e29537004d020234d29937040f00e8500218df87b1000220bafb95c00294fd0bb18597839b3997839b3d97839b3197939b3597939b3997939b3d97939b3197a39b3597a39b3997a39b3d97a39b3197b39b3597b39b3997b39b3d97b39b3197c39b3597c39b3997c39b3d97c39b31432502ad2d12ae0013222e0023220e003321ee004321ce005321ae0063218e0073216e0083214e0093212e00a3210e00b320ee00c320ce00d320ae00e3208e00f3206e0103204e0113202e0123200e013324f2a03d84ff07701b95403d100218df87b1002e0b91800224a70d0f8d0304ff0000817f80810002967d007eb0802517859b3917861b3d17869b3117971b3517979b3917981b3d17989b3117a91b3517a99b3917aa1b3d17aa9b3117bb1b3517bb9b3917bc1b3d17bc9b3117cd1b3517cd9b3917ce1b3d17ce9b308f11408b8f1500fced14ff0500837e008f1010834e008f1020831e008f103082ee008f104082be008f1050828e008f1060825e008f1070822e008f108081fe008f109081ce008f10a0819e008f10b0816e008f10c0813e008f10d0810e008f10e080de008f10f080ae008f1100807e008f1110804e008f1120801e008f1130801250a2b1ed364214ff47a7242f2107705eb85067600b3fbf6f40a2c11d305fb01f6b3fbf6f40a2c0bd305fb02f6b3fbf6f40a2c05d37d43b3fbf5f6092ee7d800e03546cde901a9c246b8f14f0f98bf4ff04f0acaf1000919eb080b55d0b3fbf5f70ba907f1300201f808204cf6cd41ccf6cc410a2da5fb016248d31bf1010643d007fb15364fead20eb6fbfefc0ba901eb080348f21f510cf13002c5f2eb115a70642da5fb014234d31bf102042cd00cfb1e665709b6fbf7f244f6d35102f13004c1f262019c70b5f57a7fa5fb011423d31bf1030118d002fb1761a20941f25976b1fbf2f7cdf2b716a5fb066407f13006de7007fb121342f2107108f104088d424fea5435a7d209e0d04607e008f1010804e008f1020801e008f10308099b00270df12c0b0bf808701bf80710002950d00beb0704617839b3a17839b3e17839b3217939b3617939b3a17939b3e17939b3217a39b3617a39b3a17a39b3e17a39b3217b39b3617b39b3a17b39b3e17b39b3217c39b3617c39b3a17c39b3e17c39b31437502fd0d13ae0013722e0023720e003371ee004371ce005371ae0063718e0073716e0083714e0093712e00a3710e00b370ee00c370ce00d370ae00e3708e00f3706e0103704e0113702e0123700e013374f2f13d84ff075010bf807100ed00beb070173224e2f4a7008d020224d2f8a7004d070224c2fca7040f0368300218df87b10d0f8d4004ff000091bf80910002967d00beb0904617859b3a17861b3e17869b3217971b3617979b3a17981b3e17989b3217a91b3617a99b3a17aa1b3e17aa9b3217bb1b3617bb9b3a17bc1b3e17bc9b3217cd1b3617cd9b3a17ce1b3e17ce9b309f11409b9f1500fced14ff0500937e009f1010934e009f1020931e009f103092ee009f104092be009f1050928e009f1060925e009f1070922e009f108091fe009f109091ce009f10a0919e009f10b0916e009f10c0913e009f10d0910e009f10e090de009f10f090ae009f1100907e009f1110904e009f1120901e009f1130901240a281fd364214ff47a7242f2107500bf04eb84077f00b0fbf7f60a2e11d304fb01f7b0fbf7f60a2e0bd304fb02f7b0fbf7f60a2e05d36c43b0fbf4f7092fe7d800e03c46cc46b9f14f0f98bf4ff04f0c089eccf1000842f2107e18eb090a51d0b0fbf4f10a2c01f130020bf809204cf6cd42ccf6cc42a4fb022547d31af1010240d001fb1406e908b6fbf1f548f21f5005f130020beb0907c5f2eb107a70642ca4fb000235d31af102002dd005fb11615509b1fbf5f6b4f57a7f06f13000b87044f6d350c1f26200a4fb000224d31af1030019d006fb1510910941f25975b0fbf1f2cdf2b715a4fb055602fb110074454fea5634089e02f1300509f10409fd70abd20ce0e1460ae0e14607e009f1010905e009f1020901e009f10309089e00220bf809201bf80200002850d00beb0200417839b3817839b3c17839b3017939b3417939b3817939b3c17939b3017a39b3417a39b3817a39b3c17a39b3017b39b3417b39b3817b39b3c17b39b3017c39b3417c39b3817c39b3c07c38b31432502ad0d132e0013222e0023220e003321ee004321ce005321ae0063218e0073216e0083214e0093212e00a3210e00b320ee00c320ce00d320ae00e3208e00f3206e0103204e0113202e0123200e013324f2a0bd84ff075000bf8020006d00beb020073214e2a417040f0ca8100208df87b009df82ca04ff00009baf1000f10d002200beb000111f8012c62b11bf8002062b14a784ab1897804300029f1d1023804e0002005e0013800e0013000eb4000400040eae070811c00f1010c01f0030e21f00300069947425818451c5800079001eb4300441c4ff0ff3108e000bf0798b8f10d0f05440444414600f0928001f10208b04543d2bcf1030f02d24ff0ff321fe04ff0ff30821c9a4200f1030205eb000638bf86f801909a4200f1040238bf86f802909a4200f1050038bf86f80390984207eb020038bf86f8049001301046e1d1089ebef1000f19d00698961c08fb03009e4238bf00f80690089ebef1010f0dd0d61c9e4238bf00f80690089ebef1020f04d004329a4238bf00f802900331b142acd2bcf1030f03d24ff0ff3220e000bf4ff0ff30821c9a4200f1030204eb000638bf86f801909a4200f1040238bf86f802909a4200f1050038bf86f80390984207eb020038bf86f8049001301046e1d1089ebef1000f3ff481af069801fb0300911c994238bf00f80190bef1010f3ff475afd11c994238bf00f80190bef1020f3ff46caf111d994238bf00f8019065e7baf1000f00f0ec800998069f554600eb4001830002240ba8ff2205970be000bf0498059f10f8015f0634002d07f10607059700f0d5800490a5f17f0010f15f0feed305eb450040f6ae55c0f200057d44ddf8148044f0010a04f1020e04f1030b04f1040c04f1050905eb8005042703e00337102f8844d3d0b81eb04238d24ff67c66e819cff6ff768057099eb44205d2b0f1ff3f02dc079e4644b270c0b2460605d5099eb24502d2079e4644f270860605d5099eb64502d2079e46443271c60605d5099eb34502d2079e46447271060705d5099eb44502d2079e4644b271089e400705d50998814502d207984044c271781eb04236d2e8196ff4c1768057099eb44205d2b0f1ff3fdcbf08eb0106b270c0b2460605d5099eb2453cbf08eb0106f270860605d5099eb6453cbf08eb01063271c60605d5099eb3453cbf08eb01067271060705d5099eb4453cbf08eb0106b271089e400705d5099881453cbf08eb0100c271b742bff483af4ff67e66e819cff6ff768057099eb44205d2b0f1ff3fdcbf08eb0306b270c0b2460605d5099eb2453cbf08eb0306f270860605d5099eb6453cbf08eb03063271c60605d5099eb3453cbf08eb03067271060705d5099eb4453cbf08eb0306b271089e40077ff54faf099881453cbf08eb0300c27147e7039eddf82480dde901a9fef726bf0021817035e600220a71c9e40021d170fff7f1ba00211172fff7e0b800bf2de9f04f8cb0159edde9177b8e4646ea02013943c90740f0c48000eb520500eb56044ff0ff304fea5708012100eb5700b8f1010f88bf7908079001f003000990c7f3410005906ff0010000eb570001906ff0020000eb5700009021f00301601c4f420390681c4ff0000a0a940b950290cdf8108006e000bf0af1010a159eda4500f0c981169854466fea0a01984288bf0beb01040b9de11801fb0e5925180a98964205fb0e0c35d9059c4146b4b10798012c19f800100cf8001001460ed00198022c19f800100cf80010014606d0009819f800100cf80010014600bf07980328cad300bf09eb010414f8016c0ceb010000f8016c14f8026c043900f8026c14f8036c00f8036c14f8044c00f8044ce9d1b2e700bf1798082802d2002126e000bf039801fb0ef605fb0ef1014402981c4600eb06086ff0030308eb0300c67801eb030b8bf80360067904338bf8046046798bf805608079fe1804368bf80600ebd1ddf860b0ddf81080191d2346099800283ff482af099c19f80100012c0cf801003ff47aaf481c099d19f80040022d0cf800403ff471af881c19f800100cf800106ae74ff6fc71394007f003080b91791e00240591cdf828800893cde906e006e0099cdde9070301345c4500f02481169de74321469d42099488bf0beb0701cf1807fb0e092944179f01fb0e0c4ff0000a042fc0f09d80ddf814b000bf50461599964288bf584600eb020500eb01064fea550019f800806ff0010080ea0a000af1010188bf39186ff0020080ea0a000af1020388bf3b186ff003008aea000e0af103004feac57588bf07eb0e0008f00f07002d4fea560508bf4fea18171cf80540f60704f00f0604f0f0043c4408bf46ea07148f180cf805407e08159d19f806602944ff0706f00f054fea510708bf35091cf80760c90706f00f0106f0f0062e4408bf41ea051699180cf807604f08159e19f807703344c90707f00f064fea530108bf3e091cf80170db0707f00f0307f0f007374408bf43ea06170cf801708118159e4b0819f803303044c90703f00f074fea500108bf1f091cf80130c00703f00f0003f0f0033b4408bf40ea07130b98179f0af1040a8245abf1040b0cf801307ff46cafddf818e0ddf860b0ddf82880b8f1000f3ff444af6fea0a005146964288bf3918881843083144c00719f803304fea51001cf8005003f00f0608bf1e0905f00f0305f0f0053544c90708bf43ea06150a99159eddf8288001290cf800503ff41eaf0af10101a7eb0a04964288bfa11e8b185d083144db0719f805504fea51031cf8030005f00f0608bf2e0900f00f0500f0f0003044c90708bf45ea0610ddf82880159eb8f1020f0cf803003ff4f7ae0af10200964288bfe01e81184b083044c90719f803304fea50011cf8016003f00f0508bf1d0906f00f0306f0f0062e44c00708bf43ea0516ddf828800cf80160159ed4e60cb0bde8f08f70b543f6fc76c2f2000632680c4611466ff39601b1f1005f054606d110684ef65a61ccf2ff01884240d044f6d341c0f247014ff4fe708847002800f08180024600200021531850540431b1f5fe7f58709870d870f6d14ef65a60ccf2ff001060012082f8ce004ff0ff30a2f8e000a2f8e200a2f8e400a2f8e600a2f8e800a2f8ea00a2f8ec00a2f8ee00a2f8f000a2f8f200a2f8f400a2f8f600a2f8f800a2f8fa00a2f8fc00a2f8fe0032600120002d82f8cc0047d0104630f8e01fa1423bd0b2f8e210a14237d0b2f8e410a14233d0b2f8e610a1422fd0b2f8e810a1422bd0b2f8ea10a14227d0b2f8ec10a14223d0b2f8ee10a1421fd0b2f8f010a1421bd0b2f8f210a14217d0b2f8f410a14213d0b2f8f610a1420fd0b2f8f810a1420bd0b2f8fa10a14207d0b2f8fc10a14203d0b2f8fe10a1420ad1012082f8de0070bd0020306070bd82f8cd00002070bd92f8cd1081b9b2f8c810611a0bb2b3f1ff3f06dd89b2022924bf012182f8dd1002e0012182f8dc10b2f8ca30002182f8cd109c42a2f8c84088bfa2f8ca4092f8001120f81140481c00f00f0082f80001002070bd00bf2de9f04fcdb04ef687289246c0f25b084df254621e460c4608f13c07c0f278020f2138230546b84718b12846c047002429e25698029570434000059001270da84ff4807108f585724ff000094ff000084ff0000b002355460b9404930a930696cdf820a00192029cc246b846e06021610746204600219047e168c91b079100f0e581ddf82ce00090002100240da84746d0460ae004940c9c002101234ff0030b079a0134944200f0d581002940f0e4810c94045dbbf1020fecd0bbf1010f00f09180bbf1000f40f0958004f00f000a900598210900f0a5808842c0f08780401a05900a9800eb00140001039015e000bf1cf809000a9a00f0f00010440cf8090009f1010901390127b14524bf4ff0000908f10108002900f08a8156984ff0000b80454ff0000338bf012380f0008108fb05ec002fdcd0cdf82480b846a6eb0907b7eb510f88bf4f0887b3b8080ceb090b1fd000260bf10102a6eb80006ff0030502eb050e043500eb050a1af104068ef803408ef804408ef805408ef80640efd1281d069e089dddf82ce017f0030204d10ce0002017f0030208d0012a0bf8004004d05844022a447018bf8470a1eb4701b94489b1b14510d21cf80900039a00f00f001043ddf824800cf80900013900270029a2d12be100bf00214746ddf8248092e700bfbcb10598a04226d201214ff0000b20e0ddf810a005985aea042a15d00c9c5045cdf810a080f0938001214ff0000b002318e10c9c002101234ff0020b3ee700214ff0010b012303e1002001214ff0000b04900023fce0001b05900a9800eb00110001099015e000bf1af809200a9802f0f00202430af8092009f10109013c0127b14524bf4ff0000908f10108002c00f0dc8056984ff0000b80454ff0000338bf012352d208fb05ea002fddd0bc46a6eb0907b7eb540f88bf67085fb3bd080aeb090b19d000200bf10102a0eb850e6ff0030500bf501904350eeb05060436c170017141718171f5d1069eddf82ce02a1d17f0030504d10de0002217f0030509d0012d0bf8021005d05a44022d517018bf917000bfa4eb4704b9447cb1b14511d21af80900099a00f00f001043089d0af80900013c0027002cabd186e0089d002467469de7089d67469ae7012180e0a0eb0a0005900a9800eb00110001099015e01cf809000a9a00f0f00010430cf8090009f10109aaf1010a0127b14524bf4ff0000908f10108baf1000f66d056984ff0000b80454ff0000338bf01235bd20b98002f08fb050cdbd0c646b846a6eb0907b7eb5a0f88bf4fea5a074fb3b8080ceb090b18d000240bf10102a4eb80006ff0030500bf5619043544190434f17031717171b171f6d1281d069e089d0c9c17f0030204d10ce0002017f0030208d0012a0bf8001004d05844022a417018bf8170aaeb470abaf1000fb94411d0b14511d21cf80900099a00f00f0010430cf80900aaf1010a0027f046baf1000fa6d10ce04ff0000a4746f04697e74ff0000b00210c9c0da832e6012102e04ff0000b0021ddf82ce00da829e64746d04602e000bf00987bb1012818d04ff0000458b90798019ab0fa80f040090da84ff480713ff4f8ad00e0002402984ef68721c0f25b01884720464db0bde8f08f059840ea0b00b0fa80f04409eee72de9f04182b003fb02f68846cde9001645f20f1107466846c0f247011c461546884740f2196047f8240f788948f2816245ea0040b86045ea044057f8204c7860c0f2490220463946fe60c7f81080904740f25761c0f244012046884702b0bde8f08100bf2de9f04f83b00c9e0292002e019000f08e80019823f00304471c029803f0030ac4f1000c01384ff00008009005e000bf08f10108b0450f4479d00e98c14600286fea080418bf06eb0409002bf0d0042b06d24ff0000bbaf1000f2ed1e8e700bf0d98b64609fb00f400986ff003050444607800f0f00242ea10107a19d0706078043500f00f0646ea0010107114f8020f00f0f00646ea10105071207800f00f0646ea00100ceb050604369071e0d105f1040b7646baf1000fbad002980d9a4fea5b0509fb0204019814f805e008fb01050ef00f025feacb7908bf4fea1e1242ea0212baf1010f05f80b20a1d00bf1010e4fea5e00205cb9f1000f4fea101208bf00f00f0242ea0210baf1020f05f80e008ed00bf102004208a25cb9f1000f02f00f0408bf140944ea04122a5480e703b0bde8f08f00000000000000000000000000002020202020002020000000505050000000000000000000005050f85050f85050000000002070a8a07028a8702000000048a85010202854480000000020505020689090680000002020200000000000000000000010204040404020100000000040201010101020400000000000005020f82050000000000000002020f82020000000000000000000000020204000000000000000f800000000000000000000000000202000000000080810102020404000000000708898a8c88888700000000020602020202020700000000070888808102040f8000000007088083008088870000000000818284888f8080800000000f88080f00808887000000000708080f08888887000000000f808081010202020000000007088887088888870000000007088888878080870000000000000202000002020000000000000202000002020400000000008102040201008000000000000f80000f8000000000000004020100810204000000000708888102000202000000000708898a8a89880780000000070888888f888888800000000f08888f0888888f000000000708880808080887000000000e0908888888890e000000000f88080f0808080f800000000f88080f0808080800000000070888080b888887000000000888888f888888888000000007020202020202070000000003810101010909060000000008890a0c0c0a090880000000080808080808080f80000000088d8a8a888888888000000008888c8a89888888800000000708888888888887000000000f0888888f080808000000000708888888888a87008000000f0888888f0a0908800000000708880700808887000000000f8202020202020200000000088888888888888700000000088888850505020200000000088888888a8a8d88800000000888850202050888800000000888850502020202000000000f8081020408080f8000000007040404040404070000000004040202010100808000000007010101010101070000000205088000000000000000000000000000000000000f80040200000000000000000000000000000700878888878000000008080f088888888f00000000000007088808088700000000008087888888888780000000000007088f8808078000000001820702020202020000000000000788888888878087000008080f08888888888000000202000602020202070000000080800180808080808483000004040485060605048000000006020202020202070000000000000f0a8a8a8a8a8000000000000f08888888888000000000000708888888870000000000000f088888888f0808000000000788888888878080800000000b8c0808080800000000000007880700808f00000000020207020202020180000000000008888888888780000000000008888505020200000000000008888a8a8a870000000000000885020205088000000000000888888888878087000000000f810204080f800000000182020402020201800000000202020202020202000000000601010081010106000000048a8900000000000000000", + "new": "02fb01f044f6d341c0f24701084700bf084644f61751c0f24701084770b500284ed001684ef65a62ccf2ff02914218bf70bd90f8081190f8095142f6c52c8d42c0f2500c2ad205eb8501014491f80d2191f80e4191f80ae191f80b3191f80c1142ea0424012c4ff0010298bf14466e1c054680f80961b9b164294eea032028bf6421012888bf024644f62060824228bf02460cf5e2731046984706e0002180f80811bde870406047e047d5f8040138b149f29942c0f244022146bde87040104770bd00bf2de9f04f83b043f6fc76c2f200063568824628466ff3960044f6d344b0f1005fc0f2470407d128684ef65a61ccf2ff01884200f0a4804ff40670a0470546002800f09c8000206ff021010022ab18a85443326f18b2f5067f01f1430158709870d870187158719871d871187258729872d872187358739873d873187458749874d874187558759875d875187658769876d876187758779877d87783f8200087f8430087f8440083f8230083f8240083f8250083f8260083f8270083f8280083f8290083f82a0083f82b0083f82c0083f82d0083f82e0083f82f0083f8300083f8310083f8320083f8330083f8340083f8350083f8360083f8370083f8380083f8390083f83a0083f83b0083f83c0083f83d0083f83e0083f83f0083f8400083f8410083f8420091d14ef65a60ccf2ff002860012085f8ce004ff0ff30a5f8e000a5f8e200a5f8e400a5f8e600a5f8e800a5f8ea00a5f8ec00a5f8ee00a5f8f000a5f8f200a5f8f400a5f8f600a5f8f800a5f8fa00a5f8fc00a5f8fe003560baf1000f18bf002d07d14af26950c0f2450003b0bde8f04f0047daf80cb0bbf1000ff2d0daf82080b8f1000fedd0a94659f8040f00287cd0686900287bd0686a00287ad0686b002879d0686c002878d0686d002877d0686e002876d0686f002875d0d5f88400002873d0d5f89400002871d0d5f8a40000286fd0d5f8b40000286dd0d5f8b00029690290d5f8a0002c6a0190d5f8900000260090286bd5f880e0d5f870c02b6e2f6d2a6c8c4238bf214638bf012688423cbf014602268a423cbf114603268f423cbf394604268b423cbf194605268c453cbf614606268e453cbf71460726009844f6d34488423cbf014608260198c0f2470488423cbf014609260298884238bf0146d5f8c00038bf0a26884238bf0b2609eb0610406804f1440137018847002049f80700012085f8df0016e0002614e0012612e0022610e003260ee004260ce005260ae0062608e0072606e0082604e0092602e00a2600e00b264046a04700283ff450af08f0030c5fea98034ff0000219d00296a2eb830e431c0bf101066ff0030700bff119cc78da19d4700c79043714714c79547189790eeb070404349171f0d1029e3a1dbcf1000f10d01bf80230bcf1010f83540ad0531c1bf80370bcf1020fc75403d0911c1bf80120425409eb06114860d5f8c400320149f802a0421cc1f80880c5f8c420c8600be738464146fff744be2de9f04f81b043f6fc79c2f20009d9f80050044628466ff3960044f6d34816460f46b0f1005fc0f2470807d128684ef65a61ccf2ff01884200f0a6804ff40670c0470546002800f0fc8000206ff02101002200bfab18a85443326f18b2f5067f01f1430158709870d870187158719871d871187258729872d872187358739873d873187458749874d874187558759875d875187658769876d876187758779877d87783f8200087f8430087f8440083f8230083f8240083f8250083f8260083f8270083f8280083f8290083f82a0083f82b0083f82c0083f82d0083f82e0083f82f0083f8300083f8310083f8320083f8330083f8340083f8350083f8360083f8370083f8380083f8390083f83a0083f83b0083f83c0083f83d0083f83e0083f83f0083f8400083f8410083f8420091d14ef65a60ccf2ff002860012085f8ce004ff0ff30a5f8e000a5f8e200a5f8e400a5f8e600a5f8e800a5f8ea00a5f8ec00a5f8ee00a5f8f000a5f8f200a5f8f400a5f8f600a5f8f800a5f8fa00a5f8fc00a5f8fe00c9f8005005f1040b4ff0000a4ff000094ff0ff30002200234ff0ff3105e000bf6032c02a03f1060332d0af187e68a64204d13e6986423cbf194630467e69a64204d13e6a86423cbf591c30467e6aa64204d13e6b86423cbf991c30467e6ba64204d13e6c86423cbfd91c30467e6ca64204d13e6d86423cbf191d30467e6da642ced13f6e87423cbf591d3846c8e700bf002910d40beb01104768090182684bf801a02046394600f013f8814608f1440138468847ace7484601b0bde8f08f204639463246c9f8005001b0bde8f04fffe72de9f041a4b0064640f6bb4043f6fc78c0f24e0014460d46c2f200088047002002af0390384600f049fd0df10c0c3046294622460123cdf800c000f055fe0446384601f07dfcd8f8001005460a466ff39602b2f1005f07d108684ef65a62ccf2ff02904200f0aa8044f6d341c0f247014ff406708847002800f0a380014600206ff02102002300bfcf18c85443338e18b3f5067f02f143027870b870f87038717871b871f87138727872b872f87238737873b873f87338747874b874f87438757875b875f87538767876b876f87638777877b877f87787f8200086f8430086f8440087f8230087f8240087f8250087f8260087f8270087f8280087f8290087f82a0087f82b0087f82c0087f82d0087f82e0087f82f0087f8300087f8310087f8320087f8330087f8340087f8350087f8360087f8370087f8380087f8390087f83a0087f83b0087f83c0087f83d0087f83e0087f83f0087f8400087f8410087f8420091d14ef65a60ccf2ff000860012081f8ce004ff0ff30a1f8e000a1f8e200a1f8e400a1f8e600a1f8e800a1f8ea00a1f8ec00a1f8ee00a1f8f000a1f8f200a1f8f400a1f8f600a1f8f800a1f8fa00a1f8fc00a1f8fe00c8f80010c1f8d05002e00020c8f80000204624b0bde8f08143f6fc70c2f20000016808466ff39600b0f1005f16d108684ef65a62ccf2ff0290420fd1d1f8fc0160b144f63422c2f207021268801a0028cebf01200020c1f8fc01704700207047f0b101684ef65a62ccf2ff02914218bf704790f8061299b110b544f62f344ff0000cc0f24604864680f806c20120002100220023aef804c2a446bde810406047704700bf2de9f04143f6fc77c2f200073f684ff000083c466ff39604b4f1005f07d13e684ef65a65ccf2ff05ae4208bfb84601280fd11c4615460f460646fff79bff2346044639462a463046002c18bfb8f1000f06d144f62f3cc0f2460cbde8f041604798f8060270b1d8f800020021002888f80612a8f804123ed049f2d941c0f24401884738e0b8f804020121013080b2012898bf0846a8f80402d8f8000249f2d944c0f2440488f8061268b94ff60370cff6ff70a4f594777844002142460023b847c8f8000240b1a047d8f80002a4f140024ff4c8719047c8b198f80602002808bfbde8f081d8f80002002188f80612a8f8041200b1a04744f62f3cc0f2460c0120002100220023bde8f04160474af26950c0f245008047012830d1082088f80702032088f80802102088f80902002088f80a02b22088f80b02062088f80c0288f80d024620b8f8041288f80e02432088f80f0201200f0a45f6153c08f2072288f8100288f8110288f81212c0f2470c09210d2388f81372bde8f0416047bde8f08170b50446d0f8000249f2b1360d46c0f2440668b94ff61d60cff6ff707844002122460023b0470028c4f8000208bf70bd06f594718847d4f8000206f1e8022946bde87040104700bf2de9f04f83b04768002f00f061828368002b00f05d8207eb03084ff0000b002500240fe0dde90021ddf808c0c6f800b020460ceb0a03002543451f464ff0000480f04682b94619f9013b03f07f06ae40002b44ea06040fd404f00703012b15dc03b3012b40f03482a8eb0903082bc0f02f8207f10903dee7c14580f02982182d05f107054f46ddd922e200bf022b3ad0052b40f01d82a8eb0903042bc0f018827b1dc8e7c14580f0138297f90130002b07f10203bfd5434580f00a8297f90230b3f1ff3f07f10303b5dc434580f0008297f90330b3f1ff3f07f10403abdc434580f0f68197f90430b3f1ff3f07f10503a1dc434580f0ec8197f90530002b00f1e781bb1d97e7c14580f0e28197f9013007f1020c002b03f07f0a3ed5c44580f0d78197f90250e14605f07f0307f1030cb5f1ff3f4aeac31601ddb2462de0c44580f0c68197f9033007f1040e03f07f05b3f1ff3f46ea853a02dde146f4461ce0c64580f0b58197f9043007f1050c03f07f06b3f1ff3f4aea465a01ddf1460ce0c44580f0a58197f90530002b00f1a08106374aea037ae146bc46a8eb0c039a4500f2968124f00703b3f54a7f7ff441afbaf1060ffff43daf9cf80030462b7ff438af99f80230432b7ff433af99f80330012b7ff42eaf43f6fc76c2f200063568cdf808c02b466ff39603b3f1005f07d12b684ef65a67ccf2ff07bb4200f0d380cde9002144f6d34104464ff40670c0f24701884700283ff405afdde90021054600236ff021072046b64600bfec1805f803b04333ee19b3f5067f07f1430784f801b084f802b084f803b084f804b084f805b084f806b084f807b084f808b084f809b084f80ab084f80bb084f80cb084f80db084f80eb084f80fb084f810b084f811b084f812b084f813b084f814b084f815b084f816b084f817b084f818b084f819b084f81ab084f81bb084f81cb084f81db084f81eb084f81fb084f820b086f843b086f844b084f823b084f824b084f825b084f826b084f827b084f828b084f829b084f82ab084f82bb084f82cb084f82db084f82eb084f82fb084f830b084f831b084f832b084f833b084f834b084f835b084f836b084f837b084f838b084f839b084f83ab084f83bb084f83cb084f83db084f83eb084f83fb084f840b084f841b084f842b07ff471af4ef65a63ccf2ff032b600123ddf808c085f8ce304ff0ff33a5f8e030a5f8e230a5f8e430a5f8e630a5f8e830a5f8ea30a5f8ec30a5f8ee30a5f8f030a5f8f230a5f8f430a5f8f630a5f8f830a5f8fa30a5f8fc30a5f8fe30cef8005099f80430022b2bdc012b61d0022b7ff43dae95f80632c5f8fcb1002b3ff436ae0446d5f8000289461746cdf804a085f806b2a5f804b220b149f2d941c0f24401884744f62f360120002100220023c0f24606b047dde901ac20463a46494615e699f8057099f80660032b47ea06263cd0042b7ff40bae019017460c46fff7c3fcddf808c00346019821463a46002b3ff4fdad95f80632002b3ff4f8adb5f80432b3427ff4f3add5f8003285f806b2002ba5f804b23ff4eaad49f2d9411846c0f244018847ddf808c0019821463a46dde544f63423c2f207031b6845f69077c0f201073b44c5f8fc31d0e5074614468946fff789fcddf808c00346494622463846002b3ff4c3ad95f80632002b3ff4bead284641f28831a5f80462fff77afdddf808c0494622463846b0e540f22113c0f2490303b0bde8f04f18477fb50646002806d1fff760fc002807d19de80f00064641f6d67cc0f24e0c60477fbd00bf092972d1f0b502eb030c562435278cf804404e248cf8107037278cf8064043248cf8117036278cf8074046248cf812707a278cf8084057248cf8177072274ff0a20e8cf809402f248cf819706c2702f803e04ff0060e8cf80a4033246d258cf81a708cf8217073278cf801e04ff0450e8cf80b4020248cf80e5067268cf8155077258cf8247000278cf803e08cf805e08cf80c404ff0690e8cf80f608cf813408cf816608cf8184065268cf81c408cf81d5061256b248cf82670232726338cf80de08cf814e08cf81b608cf81e508cf81f408cf820608cf822608cf823508cf825608cf80270bde8f04045f6153cc0f2470c60474df63040c2f234000078042818bf704780b582b04af26b1e4ff0000cc0f24d0e0020002100220923cdf804c0cdf800c0f04702b080bd00bff0b583b04df63043c2f234031b784ff6e704042bc0f2450420d144f2d043c2f207031b680546184616460f46a04703463946324628468bb11b68e02b0ed14af26b160027c0f24d060020002100220a2301970097b047012003b0f0bd04f1160303b0bde8f04018472de9f04141f204054cf65561cef20005ccf2ac51c5f8ac1f4ef6fc51cef200010a6843f6fc7642f080720a6055f8041cc2f2000641f0010145f8041c316880460a466ff39602b2f1005f07d108684ef65a62ccf2ff02904200f0a98044f6d341c0f247014ff406708847002800f0d780014600206ff02102002300bfcc18c85443338f18b3f5067f02f143026070a070e07020716071a071e07120726072a072e07220736073a073e07320746074a074e07420756075a075e07520766076a076e07620776077a077e07784f8200087f8430087f8440084f8230084f8240084f8250084f8260084f8270084f8280084f8290084f82a0084f82b0084f82c0084f82d0084f82e0084f82f0084f8300084f8310084f8320084f8330084f8340084f8350084f8360084f8370084f8380084f8390084f83a0084f83b0084f83c0084f83d0084f83e0084f83f0084f8400084f8410084f8420091d14ef65a60ccf2ff000860012081f8ce004ff0ff30a1f8e000a1f8e200a1f8e400a1f8e600a1f8e800a1f8ea00a1f8ec00a1f8ee00a1f8f000a1f8f200a1f8f400a1f8f600a1f8f800a1f8fa00a1f8fc00a1f8fe003160d1f8d800b0bb44f6342245f6e464c2f20702cff6f8741368204617689f420ed117689f420bd117689f4208d116689e4203d1002800f10400efd19e421ad02b6816681068b0420ed11068b0420bd11068b04208d11068b04203d1002c04f10404efd1b04206d02868c01ac1f8d80001e0002030602868c8f80000bde8f0812de9f04fdbb0002918bf002a04d15bb0bde8f04f00f04abf0c7804f07f07052f00f05181072f4dd0422ff0d0ddf89091b0f84080b0f842a0092f00f02282082f40f02c820746022a4ff0ff30c0f08483002b00f08183c3460bf10100032303eb500020f0030000fb0af07630824200f210824d78fdb188460226b01c904200f2088208eb060318f806605b7856ea032300f0ff811e18964200f2fb8108eb0001384614461a460023cdf80090fff7a8ff2246013de1d13846594652464b4600f05bff48e343f6fc78c2f20008d8f8003018466ff39600b0f1005f07d118684ef65a67ccf2ff07b84200f0ae800e4644f6d341c0f247014ff40670154688470346002800f09d8000206ff02101002200bf9f18985443325c18b2f5067f01f143017870b870f87038717871b871f87138727872b872f87238737873b873f87338747874b874f87438757875b875f87538767876b876f87638777877b877f87787f8200084f8430084f8440087f8230087f8240087f8250087f8260087f8270087f8280087f8290087f82a0087f82b0087f82c0087f82d0087f82e0087f82f0087f8300087f8310087f8320087f8330087f8340087f8350087f8360087f8370087f8380087f8390087f83a0087f83b0087f83c0087f83d0087f83e0087f83f0087f8400087f8410087f8420091d14ef65a60ccf2ff001860012083f8ce004ff0ff30a3f8e000a3f8e200a3f8e400a3f8e600a3f8e800a3f8ea00a3f8ec00a3f8ee00a3f8f000a3f8f200a3f8f400a3f8f600a3f8f800a3f8fa00a3f8fc00a3f8fe0031462a46c8f80030022a2cbf4978ff21002b00f0808202294ff0000000f07f82012900f07582002940f076824ff0ff31c3f8dc00a3f8cc00c3f8c800a3f8e010a3f8e210a3f8e410a3f8e610a3f8e810a3f8ea10a3f8ec10a3f8ee10a3f8f010a3f8f210a3f8f410a3f8f610a3f8f810a3f8fa10a3f8fc10a3f8fe1083f800015bb0bde8f08f43f6fc78c2f20008022a2cbf4d78ff25d8f8004020466ff39600b0f1005f07d120684ef65a63ccf2ff03984200f0ae80894644f6d341c0f247014ff4067016468847002800f06781044600206ff021010023324600bfe618e05443336718b3f5067f01f143017070b070f07030717071b071f07130727072b072f07230737073b073f07330747074b074f07430757075b075f07530767076b076f07630777077b077f07786f8200087f8430087f8440086f8230086f8240086f8250086f8260086f8270086f8280086f8290086f82a0086f82b0086f82c0086f82d0086f82e0086f82f0086f8300086f8310086f8320086f8330086f8340086f8350086f8360086f8370086f8380086f8390086f83a0086f83b0086f83c0086f83d0086f83e0086f83f0086f8400086f8410086f8420091d14ef65a60ccf2ff002060012084f8ce004ff0ff304946a4f8e000a4f8e200a4f8e400a4f8e600a4f8e800a4f8ea00a4f8ec00a4f8ee00a4f8f000a4f8f200a4f8f400a4f8f600a4f8f800a4f8fa00a4f8fc00a4f8fe00c8f8004094f8080178b1d4f8040148b149f29943c0f2440340330e46174698473a463146002084f808010123032a80f0b680c0e027064ff0210658bf1126b24280f0df804ff0ff305bb0bde8f08f032afff4b6adfe1f16f1070f7ff6b1ad00254e1ca2f1010c8df834518df835518df838518df83c518df83d518df83e518df83f518df840518df841518df842518df843518df844518df845518df846518df847518df848518df849518df84a518df84b518df84c518df84d518df84e518df84f518df850518df851518df852518df853518df860518df861518df862518df863518df864518df865518df866518df867518df868518df869518df86a518df86b51cde94d6c4ef22976cff6ff767e4455964ef22d76cff6ff767e44062f5696579500f01082032f00f09181012fcdf824a040f03882064608f10100032101eb5000099920f00300484344f6d34a00f1b605c0f2470a2846d04700283ff472af4ef68727c0f25b074df254620446cde9500507f13c054da8c0f278020f213823a847002800f066824da8b84777e20023c8f80030002449463246032a0bd355b98878082800f2b08042f6c521c0f2500196318847a8e0052a1ad3012d18d18f78781e06284ff0000000f29f80cb78032b00f29b800a79002a00f0978042f6c520c0f2500000f59a7638461946b0478be0022d40f0928042f6c520c0f25000804782e0002f01f101070ed54af26952c0f2450204460e461d4690472b4601462046022918bf06f11107864638797a7950ea02244ff0ff301ebfba79fe7952ea062b63d03a7b7e7b42ea062294425dd1ba7bfe7bcdf82c8042ea0622934555d138787a780b9d40ea0222a018a8424ff0ff304bd8be78f97846ea012c0beb0c01514543d8397a7e7a41ea062804eb0801a9423bd8b97afe7a41ea06270beb0701514533d8def80c0000283ff4ccaecdf820e056469a460b9b0996591ca3eb510303fb060049086346cdf80cb0cde90174cdf8008001f08affd9f800000f280ad809ebc0010130a1f80480cf800c81a1f80ab0c9f800000898baf1000f05d00b99099ab5e4012083f8ce0000205bb0bde8f08f83f8ce005bb0bde8f08f072a30d3032d2ed18878cb780a7940ea03204d798e7901284ff0010498bf204644f62061884228bf084642f6c521c0f25001642a28bf642201f5e2731146984744f20450c2f2070000680028cfd045ea062149f29942012988bf0c46c0f2440221469047c3e7032a4ff00000c0d32f1fb7fa87f77f093b40bad0d01e4cf6cd42ccf6cc428b78a0fb0202b3eb920f88bf9308302b184628bf3020002b00f0478100eb800303f0030c03f4fe770023ce18f578e21882f80a513579043382f80b5175799f4282f80c51b67982f80d61eed1bcf1000f10d01944ca782344bcf1010f83f80a2108d00a79bcf1020f83f80b211cbf497983f80c1184f80801d4f8040149f29945c0f24405002184f8091170b94ef21d40cff6ff70a5f1e807784422460023b8470028c4f8040100f0d8810121a8475ce7270600f1be80082afff4f5ad844601274ff0050e0724cdf824a0ce1996f802a04ff0ff30baf1000f3ff448af0c94f478002c3ff443afc34611f807804fea8a0505eb88075f453ff639af767864000b9404eb4607099ca7423ff630af01eb0e000c4611f80e1040782f4641ea002081b201200a920593cdf820c002f09df800287ff41baf0898c06800283ff4b4ad75000bf10101099b0c9e4a08abeb510101fb0301a0194d900a9805fb0211801b0b9c4fea4a034e9001eb48014da8009402f0bbf900283ff497add9f800000f280ad84fea880109ebc00201309180d58017815481c9f80000059800283ff4e6ae0898099a5946fff794bb0546002000211c4602f05af8e86800283ff475ad08f10102a8eb520101fb0a0152084da81346cdf800a002f089f900283ff465add9f800000f280ad809ebc001002201304a60a1f80880a1f80aa0c9f80000002c3ff4b5ae28464146fff763bb4ef68724c0f25b044df2546205930890856804f13c064da8c0f278020f213823b04740b34da8a04739e50c2afff437adcf78ce79b7427ff432ad0f790e7ab7427ff42dad4af26954c0f24504cdf824a0c24680460e461d461746a0473a4605272b463146c446d046022808bf01274ff0090e0b2425e7099e022f06fb08f735d104f585724da80421cde9505790470128c8d1ddf848914da8a047b9457ff4ffaccce00020a4f808015bb0bde8f08f0df59a7907f58572484604219047ddf8488105464846b847012d06d130462146424600f0f2f9054601e04ff0ff350af144012046884728465bb0bde8f08f4af26950c0f24500cdf82c808047b0f1020818bfb846a5eb0800013007950690002008eb07090c900df1340a04f5857000260a904ff480700a9a51904da80021cdf840a19047ddf840e1beeb0a0c2fd0aaeb0e0111f1040f39d900231cf0030226d09d19454507d34d4505d21af80310a5eb0804079d2955012a19d05d1cac19444507d34c4505d21af80510079da4eb08042955022a0bd09a1c9319434507d34b4505d21af80210a3eb0802079b99546644beeb0a0118bf01214e450c9a28bf01220c9236d2a8bb0029b3d132e006992cf003058c19002303e000bf04339d42bcd0f218424507d34a4505d21af8031004eb030b0bf8011c511c414505d3494503d20aeb03014978e154911c414506d3494504d20aeb03018978e7187970d11c4145dbd34945d9d20aeb0301c978e2189170d3e74ef687214da8c0f25b0188470c98099eddf82c80079d00283ff431ac059800283ff48fad089829464246334602f096fa87e542f6c5200025c0f2500084f8085180473fe72de9f04381b041f2040843f6fc77cef20008c2f200070146d8f8009038680d6801466ff39601b1f1005f07d101684ef65a62ccf2ff02914200f0a78044f6d341c0f247014ff406708847002800f0ad8000216ff021020023c618c15443338418b3f5067f02f143027170b170f17031717171b171f17131727172b172f17231737173b173f17331747174b174f17431757175b175f17531767176b176f17631777177b177f17786f8201084f8431084f8441086f8231086f8241086f8251086f8261086f8271086f8281086f8291086f82a1086f82b1086f82c1086f82d1086f82e1086f82f1086f8301086f8311086f8321086f8331086f8341086f8351086f8361086f8371086f8381086f8391086f83a1086f83b1086f83c1086f83d1086f83e1086f83f1086f8401086f8411086f8421091d14ef65a61ccf2ff010160012180f8ce104ff0ff31a0f8e010a0f8e210a0f8e410a0f8e610a0f8e810a0f8ea10a0f8ec10a0f8ee10a0f8f010a0f8f210a0f8f410a0f8f610a0f8f810a0f8fa10a0f8fc10a0f8fe103860d0f8d81081b144f6d350c1f26200a1fb0001880901284ff0010088bf88094ce000203860fa2048e044f6342245f6e466c2f20702cff6f8761368314600bf17689f420ed117689f420bd117689f4208d117689f4203d1002901f10401efd19f422ad0d8f80030176800bf1168b9420ed11168b9420bd11168b94208d11168b94203d1002e06f10406efd1b94214d0d8f8001044f6d357ca1ac1f26207a2fb0776c0f8d820b00901284ff0010088bfb009994208bffa2000e0fa20a9eb0501b1fbf0f001b0bde8f08300bff0b583b0002958d0362a56d30b78422b53d14b784d2b50d10b7f4f7f43ea0723042b4ad18b7dcf7d0e7e43ea072343ea06434f7e8e7ccd7c53ea076346ea05270e7d4d7d47ea064747ea05641d4648bf5d42b0f84070002b4ff00003c8bf0123bc422ad1b0f84270bd4226d18f7ace7a91f80cc047ea06274e7b47ea0c4747ea0667974219d2621c032606eb5202866822f0030cca19cde901c30746304621462346009502f040f93846314622462b4602f008f9002003b0f0bd4cf2af53c0f24d0303b0bde8f040184700bf2de9f04f9fb0c468002c01f0468305460aa816460f460493fef720ffa868002e03950690cde9086700f08780781c4fea500aa7eb500000fb06f100fb064c781e079027f003003a4607f0030947420698451c0819a0f1020e002106e0099a089e01311544b142d64467d0002af6d00798032805d20022b9f1000f27d1eee700bf6ff00302734600bf13f8020f00f0f00646ea1010ae18f0701878043200f00f0444ea00103071587800f0f00444ea10107071587800f00f0444ea0010bc180434b071e1d10432b9f1000fc7d001fb0ac65008305c099b069c00f00f0801fb03435feac27b08bf4fea101848ea0810b9f1010f9854b2d002f101084fea5800305c64464fea101cbbf1000f08bf00f00f0c4cea0c10a446b9f1020f03f808009dd0901c4208b25cbbf1000f02f00f0608bf160946ea06121a5490e743f6fc74c2f20004d4f80090032748464ef65a6b6ff3960044f6d345cff68077ccf2ff0bb0f1005fc0f247050ed1d9f8000058450ad199f8ce00002800f0ca81ddf80c804ff0000a4846aee04ff40670a847ddf80c80002800f0a180bc4600216ff021020023c718c15443338618b3f5067f02f143027970b970f97039717971b971f97139727972b972f97239737973b973f97339747974b974f97439757975b975f97539767976b976f97639777977b977f97787f8201086f8431086f8441087f8231087f8241087f8251087f8261087f8271087f8281087f8291087f82a1087f82b1087f82c1087f82d1087f82e1087f82f1087f8301087f8311087f8321087f8331087f8341087f8351087f8361087f8371087f8381087f8391087f83a1087f83b1087f83c1087f83d1087f83e1087f83f1087f8401087f8411087f8421091d1012180f8ce104ff0ff31089ec0f800b0a0f8e010a0f8e210a0f8e410a0f8e610a0f8e810a0f8ea10a0f8ec10a0f8ee10a0f8f010a0f8f210a0f8f410a0f8f610a0f8f810a0f8fa10a0f8fc10a0f8fe1020604ff0000a8146674605e0002020604ff0010a4ff0000900ea0701b1f1005f66d10168594563d190f8ce10099d002941f0998190f8dc200021002a8df82c1000f095820baa535c002b00f0688253185f78002f00f03e829f78002f00f03c82df78002f00f03a821f79002f00f038825f79002f00f036829f79002f00f03482df79002f00f032821f7a002f00f030825f7a002f00f02e829f7a002f00f02c82df7a002f00f02a821f7b002f00f028825f7b002f00f026829f7b002f00f02482df7b002f00f022821f7c002f00f020825f7c002f00f01e829f7c002f00f01c82db7c002b00f01a8214315029abd13ae24ff40670a847099d002800f09e8000216ff02102002300bfc718c15443338618b3f5067f02f143027970b970f97039717971b971f97139727972b972f97239737973b973f97339747974b974f97439757975b975f97539767976b976f97639777977b977f97787f8201086f8431086f8441087f8231087f8241087f8251087f8261087f8271087f8281087f8291087f82a1087f82b1087f82c1087f82d1087f82e1087f82f1087f8301087f8311087f8321087f8331087f8341087f8351087f8361087f8371087f8381087f8391087f83a1087f83b1087f83c1087f83d1087f83e1087f83f1087f8401087f8411087f8421091d10121089e80f8ce104ff0ff31c0f800b0a0f8e010a0f8e210a0f8e410a0f8e610a0f8e810a0f8ea10a0f8ec10a0f8ee10a0f8f010a0f8f210a0f8f410a0f8f610a0f8f810a0f8fa10a0f8fc10a0f8fe10206001f096b80020206001f092b8ddf810a0daf8000000283ff42fae0af10400079006980023011f033800900998cdf8089080000191059006e000bfdaf800000133834280f01781079800ebc30290880028f3d0d1880029f0d0b2f80080099f4745ebd9b2f802e07645e7d94044099da0f1010901eb0e00a0f1010ca94528bfa5f10109b44528bfa6f1010cc14561d3a9eb0801481c10f00302444628d0069c012a05fb0e400cfb054710f8086008f101046fea060600f8086017f808606fea060607f8086013d0065d022a6fea060606553e5d6fea06063e5508f1020407d0025dd2430255385dc043385508f1030403292fd305fb0ef00cfb05f2019d09f101012f18009810443a1916790439f64316710619f5780437ed43f57055798c426fea05055571357900f104006fea0505357195796fea0505957175796fea05057571d5796fea0505d571b2796fea0202b271d9d10ef10100089e6045bff46eafaeeb0c01032232ea010135d0099c069a012900fb042010f808206fea020200f8082010f809206fea020200f809200ef1020021d0069a022900fb042010f808206fea020200f8082010f809206fea020200f809200ef103000ed0069900fb041010f80810c94300f8081010f80910c94300f809100ef10400aceb0e0102390329fff42caf099ec11caceb000506fb019c4f4606fb0189811c06fb017b06fb018e411c424606fb017806fb012406fb007106fb0027069800bfc65d059af643c655465c043d6fea06064654065d6fea0606065510f808606fea060600f8086010f80e606fea060600f80e6010f80b606fea060600f80b6010f809606fea060600f8096010f80c606fea060600f80c60089e1044d1d1e2e643f6fc74c2f200042068dde902984ef65a6b44f6d34503274ff0000accf2ff0bc0f24705cff68077a1e5013122e0023120e003311ee004311ce005311ae0063118e0073116e0083114e0093112e00a3110e00b310ee00c310ce00d310ae00e3108e00f3106e0103104e0113102e0123100e013314f2921d84ff0520353541dd00a4445234e29537018d04f234d29937014d052234c29d37010d044234b2913710cd045234a29537108d052234929937104d020234829d37140f0428700218df87b10012190f8dd20002a70d000220bab9f5c002f4fd09f187e783eb3be783eb3fe783eb33e793eb37e793eb3be793eb3fe793eb33e7a3eb37e7a3eb3be7a3eb3fe7a3eb33e7b3eb37e7b3eb3be7b3eb3fe7b3eb33e7c3eb37e7c3eb3be7c3eb3ff7c3fb31432502ad2d13ce0013222e0023220e003321ee004321ce005321ae0063218e0073216e0083214e0093212e00a3210e00b320ee00c320ce00d320ae00e3208e00f3206e0103204e0113202e0123200e013324f2a15d84ff053079f5411d013444b274e2a5f700cd049274d2a9f7008d050274c2adf7004d020274b2a1f7140f0608100228df87b20013190f8de20002a6cd000210baa535c002b4fd053185f783fb39f783fb3df783fb31f793fb35f793fb39f793fb3df793fb31f7a3fb35f7a3fb39f7a3fb3df7a3fb31f7b3fb35f7b3fb39f7b3fb3df7b3fb31f7c3fb35f7c3fb39f7c3fb3db7c3bb314315029d2d138e0013122e0023120e003311ee004311ce005311ae0063118e0073116e0083114e0093112e00a3110e00b310ee00c310ce00d310ae00e3108e00f3106e0103104e0113102e0123100e013314f2911d84ff0440353540dd00a4455234e29537008d050234d29937004d020234c29d37040f0ec8000218df87b10012190f8df20002a4dd000210baa535c002b00f0bc8053185f78002f00f092809f78002f00f09080df78002f00f08e801f79002f00f08c805f79002f00f08a809f79002f00f08880df79002f00f086801f7a002f00f084805f7a002f00f082809f7a002f00f08080df7a002f7ed01f7b002f7dd05f7b002f7cd09f7b002f7bd0df7b002f7ad01f7c002f79d05f7c002f78d09f7c002f77d0db7c002b76d014315029b4d1d0e0002940f0d18000210baa535c002b00f0b88053185f78002f00f08e809f78002f00f08c80df78002f00f08a801f79002f00f088805f79002f00f086809f79002f00f08480df79002f00f082801f7a002f00f080805f7a002f7ed09f7a002f7dd0df7a002f7cd01f7b002f7bd05f7b002f7ad09f7b002f79d0df7b002f78d01f7c002f77d05f7c002f76d09f7c002f75d0db7c002b74d014315029b6d181e0013122e0023120e003311ee004311ce005311ae0063118e0073116e0083114e0093112e00a3110e00b310ee00c310ce00d310ae00e3108e00f3106e0103104e0113102e0123100e013314f295ad84ff05303535456d00a444e234e29537051d041234d2993704dd050234c29d37049d04f234b29137145d046234a29537141d02023492993713dd00021d1713de00021117113e700225a719fe6013122e0023120e003311ee004311ce005311ae0063118e0073116e0083114e0093112e00a3110e00b310ee00c310ce00d310ae00e3108e00f3106e0103104e0113102e0123100e013314f290dd84ff04f03535409d00a444b234e29537004d020234d29937040f0318500218df87b1000220baeb15c00294fd0b318597839b3997839b3d97839b3197939b3597939b3997939b3d97939b3197a39b3597a39b3997a39b3d97a39b3197b39b3597b39b3997b39b3d97b39b3197c39b3597c39b3997c39b3d97c39b31432502ad2d12ae0013222e0023220e003321ee004321ce005321ae0063218e0073216e0083214e0093212e00a3210e00b320ee00c320ce00d320ae00e3208e00f3206e0103204e0113202e0123200e013324f2a03d84ff07701b15403d100218df87b1002e0b11800224a70d0f8d0204ff0000816f80810002967d006eb0807797859b3b97861b3f97869b3397971b3797979b3b97981b3f97989b3397a91b3797a99b3b97aa1b3f97aa9b3397bb1b3797bb9b3b97bc1b3f97bc9b3397cd1b3797cd9b3b97ce1b3f97ce9b308f11408b8f1500fced14ff0500837e008f1010834e008f1020831e008f103082ee008f104082be008f1050828e008f1060825e008f1070822e008f108081fe008f109081ce008f10a0819e008f10b0816e008f10c0813e008f10d0810e008f10e080de008f10f080ae008f1100807e008f1110804e008f1120801e008f1130801270a2a1fd364214ff47a7642f2107500bf07eb87035b00b2fbf3f40a2c11d307fb01f3b2fbf3f40a2c0bd307fb06f3b2fbf3f40a2c05d36f43b2fbf7f3092be7d800e01f46cde901a9c246b8f14f0f98bf4ff04f0acaf100090bac19eb080b54d0b2fbf7f64cf6cd4106f13003ccf6cc4104f808300a2fa7fb01354ad31bf1010343d006fb17264fead50eb6fbfefc48f21f510cf1300304eb0802c5f2eb115370642fa7fb013437d31bf102032fd00cfb1e666409b6fbf4f544f6d35105f13003c1f262019370b7f57a7fa7fb011326d31bf103011bd005fb14619b0941f25975b1fbf3f6cdf2b715a7fb055406f13005d57006fb131242f2107108f104088f424fea54370baca8d20ce0d0460ae0d04607e008f1010805e008f1020801e008f103080bac002204f80820a15c00294fd0a318597839b3997839b3d97839b3197939b3597939b3997939b3d97939b3197a39b3597a39b3997a39b3d97a39b3197b39b3597b39b3997b39b3d97b39b3197c39b3597c39b3997c39b3d97c39b31432502ad2d138e0013222e0023220e003321ee004321ce005321ae0063218e0073216e0083214e0093212e00a3210e00b320ee00c320ce00d320ae00e3208e00f3206e0103204e0113202e0123200e013324f2a11d84ff07501a1540dd0a11873234e2a4b7008d020234d2a8b7004d070234c2acb7040f05b8300218df87b10d0f8d4204ff0000914f80910002967d004eb0903597859b3997861b3d97869b3197971b3597979b3997981b3d97989b3197a91b3597a99b3997aa1b3d97aa9b3197bb1b3597bb9b3997bc1b3d97bc9b3197cd1b3597cd9b3997ce1b3d97ce9b309f11409b9f1500fced14ff0500937e009f1010934e009f1020931e009f103092ee009f104092be009f1050928e009f1060925e009f1070922e009f108091fe009f109091ce009f10a0919e009f10b0916e009f10c0913e009f10d0910e009f10e090de009f10f090ae009f1100907e009f1110904e009f1120901e009f1130901230a2a1fd364214ff47a7442f2107500bf03eb83077f00b2fbf7f60a2e11d303fb01f7b2fbf7f60a2e0bd303fb04f7b2fbf7f60a2e05d36b43b2fbf3f7092fe7d800e03b46cc46b9f14f0f98bf4ff04f0c089eccf1000842f2107e18eb090750d0b2fbf3f10ba801f1300400f809404cf6cd40ccf6cc400a2ba3fb005445d37d1c3fd001fb1326e108b6fbf1f40ba800eb090248f21f5004f13005c5f2eb105570642ba3fb000533d3b81c2cd004fb11616c09b1fbf4f6b3f57a7f06f13000907044f6d350c1f26200a3fb000523d3f81c19d006fb1410a90941f25975b0fbf1f4cdf2b715a3fb055604f13005d57004fb110273454fea5633089e09f10409acd20ce0e1460ae0e14607e009f1010905e009f1020901e009f10309089e099f00220bad05f80920a85c00284fd0a818417839b3817839b3c17839b3017939b3417939b3817939b3c17939b3017a39b3417a39b3817a39b3c17a39b3017b39b3417b39b3817b39b3c17b39b3017c39b3417c39b3817c39b3c07c38b31432502ad2d130e0013222e0023220e003321ee004321ce005321ae0063218e0073216e0083214e0093212e00a3210e00b320ee00c320ce00d320ae00e3208e00f3206e0103204e0113202e0123200e013324f2a09d84ff07500a85405d0a81873214e2a417040f0f28100208df87b009df82cb00023bbf1000f0ed00220291811f8012c5ab12a5c62b14a784ab1897804300029f3d1023804e0002005e0013800e0013000eb4000400040eae070811c00f1010c01f0030e21f00300069945427818441c7800079001eb4700411c4ff0ff3908e000bf0798b8f10d0f04440144c14600f0878009f10208b0453dd2bcf1030f02d24ff0ff321be04ff0ff30821cba4200f1030204eb000638bf7370ba4200f1040238bfb370ba4200f1050038bff370b84205eb020038bf337101301046e5d1089ebef1000f17d00698961c08fb0700be4238bf8355089ebef1010f0cd0d61cbe4238bf8355089ebef1020f04d00432ba4238bf835400bf09f10309b145b1d2bcf1030f02d24ff0ff321be04ff0ff30821cba4200f1030201eb000638bf7370ba4200f1040238bfb370ba4200f1050038bff370b84205eb020038bf337101301046e5d1089ebef1000f3ff48baf0698961c09fb0700be4238bf8355089ebef1010f3ff47fafd61cbe4238bf8355089ebef1020f3ff476af0432ba4238bf835470e7bbf1000f00f0ed800998069a00eb4001830002240ba8ff2505920ce000bf0498059a10f801bf0634bbf1000f02f10602059200f0d6800490abf17f0010f15f0fedd340f6f862c0f200020beb4b007a44ddf814b044f0010804f1020e04f1030a04f1040c04f1050902eb8002042704e000bf0337102f8b44d1d0b81eb04238d24ff67c66d019cff6ff768057099eb44205d2b0f1ff3f02dc079e5e44b570c0b2460605d5099eb04502d2079e5e44f570860605d5099eb64502d2079e5e443571c60605d5099eb24502d2079e5e447571060705d5099eb44502d2079e5e44b571089e400705d50998814502d207985844c571781eb04236d2d0196ff4c1768057099eb44205d2b0f1ff3fdcbf0beb0106b570c0b2460605d5099eb0453cbf0beb0106f570860605d5099eb6453cbf0beb01063571c60605d5099eb2453cbf0beb01067571060705d5099eb4453cbf0beb0106b571089e400705d5099881453cbf0beb0100c571b742bff483af4ff67e66d019cff6ff768057099eb44205d2b0f1ff3fdcbf0beb0306b570c0b2460605d5099eb0453cbf0beb0306f570860605d5099eb6453cbf0beb03063571c60605d5099eb2453cbf0beb03067571060705d5099eb4453cbf0beb0306b571089e40077ff54faf099881453cbf0beb0300c57147e7ddf80c80099ddde901a9069f45f20f1106fb05f40ba8c0f24701cde90b74884740f2196048f8240fb8f80a0048f2816245ea0040c8f8080045ea064058f8205cc8f80400c0f2490228464146c8f80c40c8f81070904740f25761c0f24401284688470aa8fef728fbbaf1000f08bfc9f8d4001fb0bde8f08f002181700de600220a71fff7a4bc0021d170fff7ceba00211172fff7bdb800bf2de9f04f8cb0159edde9177b8e4646ea02013943c90740f0c48000eb520500eb56044ff0ff304fea5708012100eb5700b8f1010f88bf7908079001f003000990c7f3410005906ff0010000eb570001906ff0020000eb5700009021f00301601c4f420390681c4ff0000a0a940b950290cdf8108006e000bf0af1010a159eda4500f0c981169854466fea0a01984288bf0beb01040b9de11801fb0e5925180a98964205fb0e0c35d9059c4146b4b10798012c19f800100cf8001001460ed00198022c19f800100cf80010014606d0009819f800100cf80010014600bf07980328cad300bf09eb010414f8016c0ceb010000f8016c14f8026c043900f8026c14f8036c00f8036c14f8044c00f8044ce9d1b2e700bf1798082802d2002126e000bf039801fb0ef605fb0ef1014402981c4600eb06086ff0030308eb0300c67801eb030b8bf80360067904338bf8046046798bf805608079fe1804368bf80600ebd1ddf860b0ddf81080191d2346099800283ff482af099c19f80100012c0cf801003ff47aaf481c099d19f80040022d0cf800403ff471af881c19f800100cf800106ae74ff6fc71394007f003080b91791e00240591cdf828800893cde906e006e0099cdde9070301345c4500f02481169de74321469d42099488bf0beb0701cf1807fb0e092944179f01fb0e0c4ff0000a042fc0f09d80ddf814b000bf50461599964288bf584600eb020500eb01064fea550019f800806ff0010080ea0a000af1010188bf39186ff0020080ea0a000af1020388bf3b186ff003008aea000e0af103004feac57588bf07eb0e0008f00f07002d4fea560508bf4fea18171cf80540f60704f00f0604f0f0043c4408bf46ea07148f180cf805407e08159d19f806602944ff0706f00f054fea510708bf35091cf80760c90706f00f0106f0f0062e4408bf41ea051699180cf807604f08159e19f807703344c90707f00f064fea530108bf3e091cf80170db0707f00f0307f0f007374408bf43ea06170cf801708118159e4b0819f803303044c90703f00f074fea500108bf1f091cf80130c00703f00f0003f0f0033b4408bf40ea07130b98179f0af1040a8245abf1040b0cf801307ff46cafddf818e0ddf860b0ddf82880b8f1000f3ff444af6fea0a005146964288bf3918881843083144c00719f803304fea51001cf8005003f00f0608bf1e0905f00f0305f0f0053544c90708bf43ea06150a99159eddf8288001290cf800503ff41eaf0af10101a7eb0a04964288bfa11e8b185d083144db0719f805504fea51031cf8030005f00f0608bf2e0900f00f0500f0f0003044c90708bf45ea0610ddf82880159eb8f1020f0cf803003ff4f7ae0af10200964288bfe01e81184b083044c90719f803304fea50011cf8016003f00f0508bf1d0906f00f0306f0f0062e44c00708bf43ea0516ddf828800cf80160159ed4e60cb0bde8f08f2de9f04143f6fc76c2f200063268884611466ff39601b1f1005f054607d110684ef65a61ccf2ff01884200f0a88044f6d341c0f247014ff406708847002800f0e980024600206ff021010023d418d05443335718b3f5067f01f143016070a070e07020716071a071e07120726072a072e07220736073a073e07320746074a074e07420756075a075e07520766076a076e07620776077a077e07784f8200087f8430087f8440084f8230084f8240084f8250084f8260084f8270084f8280084f8290084f82a0084f82b0084f82c0084f82d0084f82e0084f82f0084f8300084f8310084f8320084f8330084f8340084f8350084f8360084f8370084f8380084f8390084f83a0084f83b0084f83c0084f83d0084f83e0084f83f0084f8400084f8410084f8420091d14ef65a60ccf2ff001060012082f8ce004ff0ff30a2f8e000a2f8e200a2f8e400a2f8e600a2f8e800a2f8ea00a2f8ec00a2f8ee00a2f8f000a2f8f200a2f8f400a2f8f600a2f8f800a2f8fa00a2f8fc00a2f8fe0032600120002d82f8cc0049d0104630f8e01f41453bd0b2f8e210414537d0b2f8e410414533d0b2f8e61041452fd0b2f8e81041452bd0b2f8ea10414527d0b2f8ec10414523d0b2f8ee1041451fd0b2f8f01041451bd0b2f8f210414517d0b2f8f410414513d0b2f8f61041450fd0b2f8f81041450bd0b2f8fa10414507d0b2f8fc10414503d0b2f8fe1041450dd1012082f8de00bde8f08100203060bde8f08182f8cd000020bde8f08192f8cd1089b9b2f8c810a8eb01010bb2b3f1ff3f06dd89b2022924bf012182f8dd1002e0012182f8dc10b2f8ca30002182f8cd109845a2f8c88088bfa2f8ca8092f8001120f81180481c00f00f0082f800010020bde8f08100bf2de9f04fcdb04ef687289246c0f25b084df254621e460c4608f13c07c0f278020f2138230546b84718b12846c047002429e25698029570434000059001270da84ff4807108f585724ff000094ff000084ff0000b002355460b9404930a930696cdf820a00192029cc246b846e06021610746204600219047e168c91b079100f0e581ddf82ce00090002100240da84746d0460ae004940c9c002101234ff0030b079a0134944200f0d581002940f0e4810c94045dbbf1020fecd0bbf1010f00f09180bbf1000f40f0958004f00f000a900598210900f0a5808842c0f08780401a05900a9800eb00140001039015e000bf1cf809000a9a00f0f00010440cf8090009f1010901390127b14524bf4ff0000908f10108002900f08a8156984ff0000b80454ff0000338bf012380f0008108fb05ec002fdcd0cdf82480b846a6eb0907b7eb510f88bf4f0887b3b8080ceb090b1fd000260bf10102a6eb80006ff0030502eb050e043500eb050a1af104068ef803408ef804408ef805408ef80640efd1281d069e089dddf82ce017f0030204d10ce0002017f0030208d0012a0bf8004004d05844022a447018bf8470a1eb4701b94489b1b14510d21cf80900039a00f00f001043ddf824800cf80900013900270029a2d12be100bf00214746ddf8248092e700bfbcb10598a04226d201214ff0000b20e0ddf810a005985aea042a15d00c9c5045cdf810a080f0938001214ff0000b002318e10c9c002101234ff0020b3ee700214ff0010b012303e1002001214ff0000b04900023fce0001b05900a9800eb00110001099015e000bf1af809200a9802f0f00202430af8092009f10109013c0127b14524bf4ff0000908f10108002c00f0dc8056984ff0000b80454ff0000338bf012352d208fb05ea002fddd0bc46a6eb0907b7eb540f88bf67085fb3bd080aeb090b19d000200bf10102a0eb850e6ff0030500bf501904350eeb05060436c170017141718171f5d1069eddf82ce02a1d17f0030504d10de0002217f0030509d0012d0bf8021005d05a44022d517018bf917000bfa4eb4704b9447cb1b14511d21af80900099a00f00f001043089d0af80900013c0027002cabd186e0089d002467469de7089d67469ae7012180e0a0eb0a0005900a9800eb00110001099015e01cf809000a9a00f0f00010430cf8090009f10109aaf1010a0127b14524bf4ff0000908f10108baf1000f66d056984ff0000b80454ff0000338bf01235bd20b98002f08fb050cdbd0c646b846a6eb0907b7eb5a0f88bf4fea5a074fb3b8080ceb090b18d000240bf10102a4eb80006ff0030500bf5619043544190434f17031717171b171f6d1281d069e089d0c9c17f0030204d10ce0002017f0030208d0012a0bf8001004d05844022a417018bf8170aaeb470abaf1000fb94411d0b14511d21cf80900099a00f00f0010430cf80900aaf1010a0027f046baf1000fa6d10ce04ff0000a4746f04697e74ff0000b00210c9c0da832e6012102e04ff0000b0021ddf82ce00da829e64746d04602e000bf00987bb1012818d04ff0000458b90798019ab0fa80f040090da84ff480713ff4f8ad00e0002402984ef68721c0f25b01884720464db0bde8f08f059840ea0b00b0fa80f04409eee72de9f04182b003fb02f68846cde9001645f20f1107466846c0f247011c461546884740f2196047f8240f788948f2816245ea0040b86045ea044057f8204c7860c0f2490220463946fe60c7f81080904740f25761c0f244012046884702b0bde8f08100bf2de9f04f83b00c9e0292002e019000f08e80019823f00304471c029803f0030ac4f1000c01384ff00008009005e000bf08f10108b0450f4479d00e98c14600286fea080418bf06eb0409002bf0d0042b06d24ff0000bbaf1000f2ed1e8e700bf0d98b64609fb00f400986ff003050444607800f0f00242ea10107a19d0706078043500f00f0646ea0010107114f8020f00f0f00646ea10105071207800f00f0646ea00100ceb050604369071e0d105f1040b7646baf1000fbad002980d9a4fea5b0509fb0204019814f805e008fb01050ef00f025feacb7908bf4fea1e1242ea0212baf1010f05f80b20a1d00bf1010e4fea5e00205cb9f1000f4fea101208bf00f00f0242ea0210baf1020f05f80e008ed00bf102004208a25cb9f1000f02f00f0408bf140944ea04122a5480e703b0bde8f08f00000000000000000000000000002020202020002020000000505050000000000000000000005050f85050f85050000000002070a8a07028a8702000000048a85010202854480000000020505020689090680000002020200000000000000000000010204040404020100000000040201010101020400000000000005020f82050000000000000002020f82020000000000000000000000020204000000000000000f800000000000000000000000000202000000000080810102020404000000000708898a8c88888700000000020602020202020700000000070888808102040f8000000007088083008088870000000000818284888f8080800000000f88080f00808887000000000708080f08888887000000000f808081010202020000000007088887088888870000000007088888878080870000000000000202000002020000000000000202000002020400000000008102040201008000000000000f80000f8000000000000004020100810204000000000708888102000202000000000708898a8a89880780000000070888888f888888800000000f08888f0888888f000000000708880808080887000000000e0908888888890e000000000f88080f0808080f800000000f88080f0808080800000000070888080b888887000000000888888f888888888000000007020202020202070000000003810101010909060000000008890a0c0c0a090880000000080808080808080f80000000088d8a8a888888888000000008888c8a89888888800000000708888888888887000000000f0888888f080808000000000708888888888a87008000000f0888888f0a0908800000000708880700808887000000000f8202020202020200000000088888888888888700000000088888850505020200000000088888888a8a8d88800000000888850202050888800000000888850502020202000000000f8081020408080f8000000007040404040404070000000004040202010100808000000007010101010101070000000205088000000000000000000000000000000000000f80040200000000000000000000000000000700878888878000000008080f088888888f00000000000007088808088700000000008087888888888780000000000007088f8808078000000001820702020202020000000000000788888888878087000008080f08888888888000000202000602020202070000000080800180808080808483000004040485060605048000000006020202020202070000000000000f0a8a8a8a8a8000000000000f08888888888000000000000708888888870000000000000f088888888f0808000000000788888888878080800000000b8c0808080800000000000007880700808f00000000020207020202020180000000000008888888888780000000000008888505020200000000000008888a8a8a870000000000000885020205088000000000000888888888878087000000000f810204080f800000000182020402020201800000000202020202020202000000000601010081010106000000048a8900000000000000000", "desc": "append injected blobs to main-app payload" }, { "offset": 777711, "old": "44c33500", - "new": "84fe3500", + "new": "380e3600", "desc": "main-app subheader payload size (ps)" }, { "offset": 152, "old": "c4c33500", - "new": "04ff3500", + "new": "b80e3600", "desc": "main-app TOC entry size (ps + 128)" }, { "offset": 777831, "old": "44c33504", - "new": "84fe3504", + "new": "380e3604", "desc": "main-app preamble length (low 24 bits)" }, { "offset": 777835, "old": "df8110c9", - "new": "6eddece4", + "new": "88ed0126", "desc": "[5] ota/s200_firmware_ota.bin preamble crc32" }, { "offset": 156, "old": "c1be0fb1", - "new": "ed6b6bbd", + "new": "f1e9f8d8", "desc": "[5] ota/s200_firmware_ota.bin component crc32c (TOC)" }, { "offset": 777715, "old": "c1be0fb1", - "new": "ed6b6bbd", + "new": "f1e9f8d8", "desc": "[5] ota/s200_firmware_ota.bin component crc32c (subheader)" } ] diff --git a/app/native/anthropic.ts b/app/native/anthropic.ts index 80fbf2a0..57aca55e 100644 --- a/app/native/anthropic.ts +++ b/app/native/anthropic.ts @@ -13,14 +13,34 @@ const ANTHROPIC_VERSION = "2023-06-01"; /** Default model for voice continuations (and a sensible general default). */ export const DEFAULT_LLM_MODEL = "claude-sonnet-5"; +/** + * A content block in an Anthropic message. Text-only flows (dictation refine) + * still pass a plain string for content; the assistant tool loop uses the + * block array to carry tool_use / tool_result alongside text. + */ +export type AnthropicContentBlock = + | { type: "text"; text: string } + | { type: "tool_use"; id: string; name: string; input: any } + | { type: "tool_result"; tool_use_id: string; content: string; is_error?: boolean }; + export type AnthropicMessage = { role: "user" | "assistant"; - content: string; + content: string | AnthropicContentBlock[]; +}; + +/** An Anthropic tool definition (input_schema is snake_case as the API wants). */ +export type AnthropicToolDefinition = { + name: string; + description: string; + input_schema: object; }; export type AnthropicStreamResult = { + /** Concatenated text of all text blocks. */ text: string; - /** e.g. "end_turn", "max_tokens", "refusal"; null if the stream never said. */ + /** The assembled assistant content blocks (text + any tool_use). */ + content: AnthropicContentBlock[]; + /** e.g. "end_turn", "tool_use", "max_tokens", "refusal"; null if never said. */ stopReason: string | null; }; @@ -29,6 +49,7 @@ export type AnthropicStreamOptions = { model?: string; system?: string; messages: AnthropicMessage[]; + tools?: AnthropicToolDefinition[]; maxTokens?: number; /** Thinking/latency tradeoff; voice flows want "low". Default: model default. */ effort?: "low" | "medium" | "high"; @@ -39,6 +60,11 @@ export type AnthropicStreamOptions = { onError: (message: string) => void; }; +/** Accumulator for one streamed content block before it is finalized. */ +type StreamingBlock = + | { type: "text"; text: string } + | { type: "tool_use"; id: string; name: string; inputJson: string }; + export type AnthropicStreamHandle = { cancel(): void; }; @@ -49,6 +75,8 @@ export function streamAnthropicMessage(options: AnthropicStreamOptions): Anthrop let settled = false; let text = ""; let stopReason: string | null = null; + // Content blocks, keyed by their SSE `index`, assembled as deltas arrive. + const blocks = new Map(); const fail = (message: string) => { if (settled) return; @@ -58,7 +86,7 @@ export function streamAnthropicMessage(options: AnthropicStreamOptions): Anthrop const done = () => { if (settled) return; settled = true; - options.onDone({ text, stopReason }); + options.onDone({ text, content: finalizeBlocks(blocks), stopReason }); }; if (!global.isAndroid) { @@ -78,6 +106,7 @@ export function streamAnthropicMessage(options: AnthropicStreamOptions): Anthrop messages: options.messages, }; if (options.system) body.system = options.system; + if (options.tools?.length) body.tools = options.tools; if (options.effort) body.output_config = { effort: options.effort }; const listener = new com.faceclaw.app.FaceclawSseListener({ @@ -86,13 +115,41 @@ export function streamAnthropicMessage(options: AnthropicStreamOptions): Anthrop const event = parseSseDataLine(String(line)); if (!event) return; switch (event.type) { - case "content_block_delta": + case "content_block_start": { + const index = Number(event.index); + const block = event.content_block; + if (block?.type === "tool_use") { + blocks.set(index, { + type: "tool_use", + id: String(block.id ?? ""), + name: String(block.name ?? ""), + inputJson: "", + }); + } else if (block?.type === "text") { + blocks.set(index, { type: "text", text: String(block.text ?? "") }); + } + return; + } + case "content_block_delta": { + const index = Number(event.index); if (event.delta?.type === "text_delta") { const delta = String(event.delta.text ?? ""); text += delta; + const existing = blocks.get(index); + if (existing?.type === "text") { + existing.text += delta; + } else { + blocks.set(index, { type: "text", text: delta }); + } options.onTextDelta?.(delta, text); + } else if (event.delta?.type === "input_json_delta") { + const existing = blocks.get(index); + if (existing?.type === "tool_use") { + existing.inputJson += String(event.delta.partial_json ?? ""); + } } return; + } case "message_delta": if (event.delta?.stop_reason) { stopReason = String(event.delta.stop_reason); @@ -105,7 +162,7 @@ export function streamAnthropicMessage(options: AnthropicStreamOptions): Anthrop fail(`Anthropic: ${String(event.error?.message ?? event.error?.type ?? "stream error")}`); return; default: - // message_start, content_block_start/stop, ping — nothing to do. + // message_start, content_block_stop, ping — nothing to do. return; } }, @@ -146,6 +203,30 @@ export function streamAnthropicMessage(options: AnthropicStreamOptions): Anthrop }; } +/** Assemble the streamed blocks (in index order) into final content blocks. */ +function finalizeBlocks(blocks: Map): AnthropicContentBlock[] { + const content: AnthropicContentBlock[] = []; + for (const index of Array.from(blocks.keys()).sort((a, b) => a - b)) { + const block = blocks.get(index)!; + if (block.type === "text") { + content.push({ type: "text", text: block.text }); + } else { + let input: any = {}; + const trimmed = block.inputJson.trim(); + if (trimmed) { + try { + input = JSON.parse(trimmed); + } catch { + // A tool_use whose JSON never completed (e.g. truncated stream); pass + // empty args and let the tool handler report what's missing. + } + } + content.push({ type: "tool_use", id: block.id, name: block.name, input }); + } + } + return content; +} + /** Parse one SSE line; returns the JSON payload of a data: line, else null. */ function parseSseDataLine(line: string): any | null { if (!line.startsWith("data:")) return null; diff --git a/app/ui/apps/assistant.ts b/app/ui/apps/assistant.ts new file mode 100644 index 00000000..f19f3f6f --- /dev/null +++ b/app/ui/apps/assistant.ts @@ -0,0 +1,190 @@ +import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../../graphics/image"; +import { getDefaultSmallFont, type BdfFont } from "../../graphics/bdffont"; +import { GESTURE_DOUBLE_CLICK } from "../gestures"; +import { drawSelectionHighlight } from "../menu"; +import { Layer, type DashboardInputEvent, type LayerActions, type LayerContext } from "../layers"; + +const DIALOG_X = 40; +const DIALOG_Y = 40; +const DIALOG_W = G2_LENS_WIDTH - 80; +const DIALOG_H = G2_LENS_HEIGHT - 80; +const TEXT_MAX_WIDTH = DIALOG_W - 32; +const MENU_ROW_H = 20; +const MENU_ROWS = 2; + +/** thinking: turn running; done/error: finished, showing the Follow-up/Done menu. */ +type AssistantPhase = "thinking" | "done" | "error"; + +export type AssistantLayerCallbacks = { + /** Record another utterance and continue this conversation. */ + onFollowUp: () => void; + /** Abort the in-flight turn (double-click while thinking). */ + onCancel: () => void; + /** The user closed the overlay (Done). */ + onClose: () => void; + /** The layer left the stack by any path (Done, or the screen sleeping). */ + onRemoved?: () => void; +}; + +/** + * The assistant overlay: streamed reply text with a status line for tool + * activity, and a Follow-up / Done menu once the turn ends. Double-click + * cancels an in-flight turn. The shell owns the AssistantSession and drives + * this layer's state through the on* methods as the turn streams. + */ +export class AssistantLayer implements Layer { + private phase: AssistantPhase = "thinking"; + private replyText = ""; + private status = "Thinking..."; + private menuIndex = 0; + + constructor( + private readonly actions: LayerActions, + private readonly callbacks: AssistantLayerCallbacks, + ) {} + + /** Shell: a new turn (initial utterance or follow-up) is starting. */ + startTurn(): void { + this.phase = "thinking"; + this.replyText = ""; + this.status = "Thinking..."; + this.menuIndex = 0; + this.actions.requestRender(); + } + + onTextDelta(_delta: string, textSoFar: string): void { + this.replyText = textSoFar; + if (this.phase === "thinking") this.status = "Thinking..."; + this.actions.requestRender(); + } + + onToolActivity(label: string): void { + if (this.phase === "thinking") this.status = `→ ${label}`; + this.actions.requestRender(); + } + + onTurnDone(): void { + this.phase = "done"; + this.status = this.replyText.trim() ? "" : "(no reply)"; + this.menuIndex = 0; + this.actions.requestRender(); + } + + onError(message: string): void { + this.phase = "error"; + this.status = message; + this.menuIndex = 0; + this.actions.requestRender(); + } + + paint(_ctx: LayerContext, paintBelow: () => GrayImage): GrayImage { + const font = getDefaultSmallFont(); + const image = paintBelow(); + + // Solid dialog box (fill 1, matching the voice dialog: opaque after 4bpp + // quantization, but not the color-key transparent 0). + image.fillRoundedRect(DIALOG_X, DIALOG_Y, DIALOG_W, DIALOG_H, 1, 10); + image.drawRoundedRect(DIALOG_X, DIALOG_Y, DIALOG_W, DIALOG_H, 90, 10); + + const left = DIALOG_X + 16; + image.drawText(font, left, DIALOG_Y + 12, this.phase === "thinking" ? "Assistant ●" : "Assistant", 220); + if (this.status) { + const statusValue = this.phase === "error" ? 200 : 130; + image.drawText(font, left, DIALOG_Y + 30, truncate(font, this.status, TEXT_MAX_WIDTH), statusValue); + } + + const inMenu = this.phase !== "thinking"; + const textBottom = inMenu ? DIALOG_Y + DIALOG_H - MENU_ROWS * MENU_ROW_H - 8 : DIALOG_Y + DIALOG_H - 8; + const textTop = DIALOG_Y + 56; + const maxLines = Math.max(1, ((textBottom - textTop) / 16) | 0); + + const wrapped = wrapText(font, this.replyText, TEXT_MAX_WIDTH); + // Keep the tail visible as text streams past the bottom. + const firstLine = Math.max(0, wrapped.length - maxLines); + for (let index = firstLine; index < wrapped.length; index++) { + image.drawText(font, left, textTop + (index - firstLine) * 16, wrapped[index]!, 235); + } + + if (inMenu) { + const rows = ["Follow-up", "Done"]; + const menuTop = DIALOG_Y + DIALOG_H - MENU_ROWS * MENU_ROW_H - 2; + for (let i = 0; i < rows.length; i++) { + const rowY = menuTop + i * MENU_ROW_H; + const selected = i === this.menuIndex; + if (selected) { + drawSelectionHighlight(image, left - 4, rowY - 2, DIALOG_W - 24, MENU_ROW_H - 2, true, 6); + } + image.drawText(font, left + 4, rowY + 2, rows[i]!, selected ? 255 : 200); + } + } else { + image.drawText(font, left, DIALOG_Y + DIALOG_H - 14, `${GESTURE_DOUBLE_CLICK} cancel`, 110); + } + return image; + } + + handleInput(event: DashboardInputEvent, _ctx: LayerContext): void { + if (this.phase === "thinking") { + if (event.type === "double-click") { + this.callbacks.onCancel(); + this.phase = "done"; + this.status = "Cancelled"; + this.menuIndex = 0; + this.actions.requestRender(); + } + return; + } + // done / error: the Follow-up / Done menu. + switch (event.type) { + case "scroll-up": + this.menuIndex = (this.menuIndex + MENU_ROWS - 1) % MENU_ROWS; + this.actions.requestRender(); + return; + case "scroll-down": + this.menuIndex = (this.menuIndex + 1) % MENU_ROWS; + this.actions.requestRender(); + return; + case "click": + if (this.menuIndex === 0) { + this.callbacks.onFollowUp(); + } else { + this.callbacks.onClose(); + } + return; + case "double-click": + this.callbacks.onClose(); + return; + default: + return; + } + } + + onRemoved(): void { + this.callbacks.onRemoved?.(); + } +} + +function wrapText(font: BdfFont, text: string, maxWidth: number): string[] { + const words = text.split(/\s+/).filter(Boolean); + const lines: string[] = []; + let line = ""; + for (const word of words) { + const candidate = line ? `${line} ${word}` : word; + if (line && font.measureText(candidate) > maxWidth) { + lines.push(line); + line = word; + } else { + line = candidate; + } + } + if (line) lines.push(line); + return lines.length ? lines : [""]; +} + +function truncate(font: BdfFont, text: string, maxWidth: number): string { + if (font.measureText(text) <= maxWidth) return text; + let out = text; + while (out.length > 1 && font.measureText(`${out}...`) > maxWidth) { + out = out.slice(0, -1); + } + return `${out}...`; +} diff --git a/app/ui/apps/voice-input.ts b/app/ui/apps/voice-input.ts index 22d695db..1c2c8f27 100644 --- a/app/ui/apps/voice-input.ts +++ b/app/ui/apps/voice-input.ts @@ -13,19 +13,47 @@ const DIALOG_W = G2_LENS_WIDTH - 80; const DIALOG_H = G2_LENS_HEIGHT - 80; const TEXT_MAX_WIDTH = DIALOG_W - 32; const MENU_ROW_H = 20; -const MENU_ROWS = 3; // After the mic stops, the provider's final transcript can trail in (cloud // commit round-trip); wait this long for it before refining with what we have. const FOLLOWUP_FINALIZE_TIMEOUT_MS = 1200; /** * The dialog's lifecycle. "capturing" is the first utterance (push-to-talk or - * click-to-finish); "menu" is the Send / Continue / Discard menu; "continuing" + * click-to-finish); "menu" is the send / Continue / Discard menu; "continuing" * records a follow-up utterance (always click-to-finish); "refining" streams * the LLM-merged text, then returns to "menu". */ type VoicePhase = "capturing" | "menu" | "continuing" | "refining"; +/** + * A destination the captured text can be sent to. The shell supplies these per + * entry point: "Send to Assistant" (hand off to the voice assistant) and/or + * "Type Into App" (deliver to the foreground window's text input). + */ +export type VoiceSendTarget = { + id: string; + label: string; + onSend: (text: string) => void; +}; + +export type VoiceInputLayerOptions = { + actions: LayerActions; + /** Post-removal cleanup (also fires when the screen turns off). */ + onClosed: () => void; + /** Pop this layer off the shell stack. */ + dismiss: () => void; + /** Ordered send destinations shown as the first menu rows. */ + sendTargets: VoiceSendTarget[]; + /** Which send target is highlighted by default (entry-point dependent). */ + defaultTargetIndex?: number; + /** A single click ends the utterance (opened from a menu, no held button). */ + finishOnClick?: boolean; + /** Wakeword flow: mic starts immediately and ends on detected silence. */ + handsFree?: boolean; + /** Skip the menu: on capture end, send straight to the default target. */ + autoSend?: boolean; +}; + /** * Push-to-talk voice dialog, drawn on top of whatever is already on screen. * The mic runs while the button is held (long-press); releasing it stops the @@ -58,17 +86,34 @@ export class VoiceInputLayer implements Layer { private followupFinalizeTimer: ReturnType | null = null; private refineHandle: AnthropicStreamHandle | null = null; private menuIndex = 0; + /** Auto-send (wakeword skip-confirmation) is waiting to fire. */ + private pendingAutoSend = false; + private autoSendTimer: ReturnType | null = null; private unsubscribeTranscript: (() => void) | null = null; private unsubscribeStatus: (() => void) | null = null; private unsubscribeSpeechEnd: (() => void) | null = null; - constructor( - private readonly actions: LayerActions, - private readonly onClosed: () => void, - private readonly onSend: (text: string) => void, - private readonly finishOnClick = false, - private readonly handsFree = false, - ) {} + private readonly actions: LayerActions; + private readonly onClosed: () => void; + private readonly dismiss: () => void; + private readonly sendTargets: VoiceSendTarget[]; + private readonly defaultTargetIndex: number; + private readonly finishOnClick: boolean; + private readonly handsFree: boolean; + private readonly autoSend: boolean; + + constructor(options: VoiceInputLayerOptions) { + this.actions = options.actions; + this.onClosed = options.onClosed; + this.dismiss = options.dismiss; + this.sendTargets = options.sendTargets; + this.finishOnClick = options.finishOnClick ?? false; + this.handsFree = options.handsFree ?? false; + this.autoSend = options.autoSend ?? false; + const defaultIndex = options.defaultTargetIndex ?? 0; + this.defaultTargetIndex = Math.min(Math.max(0, defaultIndex), Math.max(0, this.sendTargets.length - 1)); + this.menuIndex = this.defaultTargetIndex; + } startCapture(): void { if (this.capturing) return; @@ -113,13 +158,66 @@ export class VoiceInputLayer implements Layer { this.capturing = false; this.phase = "menu"; void this.actions.stopVoiceCapture(); - if (this.status.startsWith("Listening")) { + if (this.autoSend && this.sendTargets.length) { + // Skip-confirmation (wakeword): send to the default target as soon as the + // transcript finalizes, or after a short wait for the trailing final. + this.pendingAutoSend = true; + this.status = "Sending..."; + this.autoSendTimer = setTimeout(() => this.performAutoSend(), FOLLOWUP_FINALIZE_TIMEOUT_MS); + } else if (this.status.startsWith("Listening")) { this.status = "Send, continue, or discard?"; } this.actions.requestRender(); } - paint(ctx: LayerContext, paintBelow: () => GrayImage): GrayImage { + /** Fire the queued skip-confirmation send (or fall back to the menu). */ + private performAutoSend(): void { + if (this.autoSendTimer !== null) { + clearTimeout(this.autoSendTimer); + this.autoSendTimer = null; + } + if (!this.pendingAutoSend) return; + this.pendingAutoSend = false; + const text = this.displayText().trim(); + const target = this.sendTargets[this.defaultTargetIndex]; + if (text && target) { + this.dismiss(); + target.onSend(text); + } else { + // Nothing heard; fall back to the menu so the user can retry or discard. + this.status = "Send, continue, or discard?"; + this.actions.requestRender(); + } + } + + /** The menu rows: one per send target, then Continue, then Discard. */ + private menuRows(): Array<{ label: string; dim: boolean; onSelect: () => void }> { + const text = this.displayText().trim(); + const hasText = text.length > 0; + const hasLlmKey = anthropicApiKeySetting.get().trim().length > 0; + const rows: Array<{ label: string; dim: boolean; onSelect: () => void }> = []; + for (const target of this.sendTargets) { + rows.push({ + label: target.label, + dim: !hasText, + onSelect: () => { + this.dismiss(); + if (hasText) target.onSend(text); + }, + }); + } + rows.push({ + label: hasLlmKey ? "Continue" : "Continue (Needs LLM API key)", + dim: !hasLlmKey, + onSelect: () => { + if (hasLlmKey) this.startContinuation(); + }, + }); + rows.push({ label: "Discard", dim: false, onSelect: () => this.dismiss() }); + return rows; + } + + paint(_ctx: LayerContext, paintBelow: () => GrayImage): GrayImage { const font = getDefaultSmallFont(); const image = paintBelow(); @@ -133,9 +231,9 @@ export class VoiceInputLayer implements Layer { image.drawText(font, left, DIALOG_Y + 30, truncate(font, this.status, TEXT_MAX_WIDTH), 130); const inMenu = this.phase === "menu"; - const hasText = this.displayText().trim().length > 0; - // Leave room for the three-row menu when it is showing. - const textBottom = inMenu ? DIALOG_Y + DIALOG_H - MENU_ROWS * MENU_ROW_H - 8 : DIALOG_Y + DIALOG_H - 8; + const rows = inMenu ? this.menuRows() : []; + // Reserve space for the actual number of rows this menu has. + const textBottom = inMenu ? DIALOG_Y + DIALOG_H - rows.length * MENU_ROW_H - 8 : DIALOG_Y + DIALOG_H - 8; const textTop = DIALOG_Y + 56; const maxLines = Math.max(1, ((textBottom - textTop) / 16) | 0); @@ -147,14 +245,7 @@ export class VoiceInputLayer implements Layer { } if (inMenu) { - const hasLlmKey = anthropicApiKeySetting.get().trim().length > 0; - const rows: Array<{ label: string; dim: boolean }> = [ - // Dim "Send" when there is nothing to send. - { label: "Send", dim: !hasText }, - { label: hasLlmKey ? "Continue" : "Continue (Needs LLM API key)", dim: !hasLlmKey }, - { label: "Discard", dim: false }, - ]; - const menuTop = DIALOG_Y + DIALOG_H - MENU_ROWS * MENU_ROW_H - 2; + const menuTop = DIALOG_Y + DIALOG_H - rows.length * MENU_ROW_H - 2; for (let i = 0; i < rows.length; i++) { const rowY = menuTop + i * MENU_ROW_H; const selected = i === this.menuIndex; @@ -170,11 +261,11 @@ export class VoiceInputLayer implements Layer { return image; } - handleInput(event: DashboardInputEvent, ctx: LayerContext): void { + handleInput(event: DashboardInputEvent, _ctx: LayerContext): void { switch (this.phase) { case "capturing": if (event.type === "double-click") { - ctx.stack.pop(); + this.dismiss(); } else if (this.clickEndsCapture && event.type === "click") { this.endCapture(); } @@ -192,37 +283,29 @@ export class VoiceInputLayer implements Layer { } return; case "menu": - this.handleMenuInput(event, ctx); + this.handleMenuInput(event); return; } } - private handleMenuInput(event: DashboardInputEvent, ctx: LayerContext): void { + private handleMenuInput(event: DashboardInputEvent): void { + const rowCount = this.menuRows().length; switch (event.type) { case "scroll-up": - this.menuIndex = (this.menuIndex + MENU_ROWS - 1) % MENU_ROWS; + this.menuIndex = (this.menuIndex + rowCount - 1) % rowCount; this.actions.requestRender(); return; case "scroll-down": - this.menuIndex = (this.menuIndex + 1) % MENU_ROWS; + this.menuIndex = (this.menuIndex + 1) % rowCount; this.actions.requestRender(); return; - case "click": - if (this.menuIndex === 0) { - const text = this.displayText().trim(); - if (text) this.onSend(text); - ctx.stack.pop(); - } else if (this.menuIndex === 1) { - if (anthropicApiKeySetting.get().trim()) { - this.startContinuation(); - } - // No key: the row is disabled; the click does nothing. - } else { - ctx.stack.pop(); - } + case "click": { + const row = this.menuRows()[this.menuIndex]; + row?.onSelect(); return; + } case "double-click": - ctx.stack.pop(); + this.dismiss(); return; default: return; @@ -323,6 +406,11 @@ export class VoiceInputLayer implements Layer { clearTimeout(this.followupFinalizeTimer); this.followupFinalizeTimer = null; } + if (this.autoSendTimer !== null) { + clearTimeout(this.autoSendTimer); + this.autoSendTimer = null; + } + this.pendingAutoSend = false; this.refineHandle?.cancel(); this.refineHandle = null; if (this.capturing) { @@ -380,6 +468,12 @@ export class VoiceInputLayer implements Layer { this.beginRefine(); return; } + if (this.pendingAutoSend) { + // The utterance finalized; skip-confirmation can fire without waiting + // out the fallback timer. + this.performAutoSend(); + return; + } } else { this.liveText = event.text.trim(); } diff --git a/app/ui/dashboard-settings.ts b/app/ui/dashboard-settings.ts index 490592b1..53ad13b2 100644 --- a/app/ui/dashboard-settings.ts +++ b/app/ui/dashboard-settings.ts @@ -294,6 +294,13 @@ export const saveVoiceRecordingsSetting = new ConfigSettingBoolean({ defaultValue: false, }); +export const assistantSkipConfirmationSetting = new ConfigSettingBoolean({ + id: "assistant-skip-confirmation", + label: "Send to assistant without confirming", + storageKey: "assistant.skipConfirmationAfterWakeword", + defaultValue: false, +}); + export const elevenLabsApiKeySetting = new ConfigSettingString({ id: "elevenlabs-api-key", label: "ElevenLabs key", diff --git a/app/ui/dashboard/settings-menus.ts b/app/ui/dashboard/settings-menus.ts index 162edd46..e14fa5e0 100644 --- a/app/ui/dashboard/settings-menus.ts +++ b/app/ui/dashboard/settings-menus.ts @@ -3,6 +3,7 @@ import { getDashboardLogo } from "../../graphics/logo"; import { shell } from "../shell/shell"; import { anthropicApiKeySetting, + assistantSkipConfirmationSetting, batteryDisplayModeSetting, brightnessSetting, elevenLabsApiKeySetting, @@ -56,6 +57,9 @@ function settingsSections(): SettingsSection[] { items: [ enumSettingMenuItem(wakeWordActionSetting), enumSettingMenuItem(voiceProviderSetting), + // When on, a wakeword utterance goes straight to the assistant with no + // Send/Type menu step. + toggleSettingMenuItem(assistantSkipConfirmationSetting), ], }, { diff --git a/app/ui/shell/shell.ts b/app/ui/shell/shell.ts index f2507d1e..b128d532 100644 --- a/app/ui/shell/shell.ts +++ b/app/ui/shell/shell.ts @@ -1,11 +1,17 @@ import { G2_LENS_HEIGHT, G2_LENS_WIDTH, GrayImage } from "../../graphics/image"; +import { getDefaultSmallFont } from "../../graphics/bdffont"; import { EvenAIStatus, EventSourceType, OsEventTypeList } from "../../g2/events"; import type { RawInputEvent } from "../../native/faceclaw-communicator"; -import { DashboardInputEvent, LayerActions, LayerStack, noopLayerActions } from "../layers"; +import { DashboardInputEvent, Layer, LayerActions, LayerContext, LayerStack, noopLayerActions } from "../layers"; import { MenuLayer, type MenuItem } from "../menu"; -import { VoiceInputLayer } from "../apps/voice-input"; +import { VoiceInputLayer, type VoiceSendTarget } from "../apps/voice-input"; +import { AssistantLayer } from "../apps/assistant"; +import { AssistantSession } from "../../assistant/session"; +import type { AssistantContext } from "../../assistant/types"; import { SingleNotificationLayer } from "../notifications"; import { + anthropicApiKeySetting, + assistantSkipConfirmationSetting, batteryDisplayModeSetting, onAnySettingChanged, timeFormatSetting, @@ -99,6 +105,64 @@ class ShellOverlayMenuLayer extends MenuLayer { } } +/** How long a show_alert popup stays before auto-dismissing. */ +const ALERT_DISMISS_MS = 6000; +const ALERT_X = 40; +const ALERT_W = G2_LENS_WIDTH - 80; +const ALERT_Y = 96; +const ALERT_H = 96; + +/** + * A brief text popup on the shell surface (the assistant's show_alert tool and + * other short notices). Auto-dismisses after a few seconds; a click or + * double-click dismisses it early. + */ +class ShellAlertLayer implements Layer { + private timer: ReturnType | null = null; + + constructor(private readonly text: string, private readonly onDismiss: () => void) { + this.timer = setTimeout(() => { + this.timer = null; + this.onDismiss(); + }, ALERT_DISMISS_MS); + } + + paint(_ctx: LayerContext, paintBelow: () => GrayImage): GrayImage { + const image = paintBelow(); + const font = getDefaultSmallFont(); + image.fillRoundedRect(ALERT_X, ALERT_Y, ALERT_W, ALERT_H, 1, 10); + image.drawRoundedRect(ALERT_X, ALERT_Y, ALERT_W, ALERT_H, 90, 10); + image.drawText(font, ALERT_X + 16, ALERT_Y + 12, "Assistant", 200); + image.drawTextWrapped({ + font, + x: ALERT_X + 16, + y: ALERT_Y + 34, + width: ALERT_W - 32, + text: this.text, + value: 235, + }); + return image; + } + + handleInput(event: DashboardInputEvent, _ctx: LayerContext): void { + if (event.type === "click" || event.type === "double-click") { + this.clearTimer(); + this.onDismiss(); + } + } + + onRemoved(): void { + this.clearTimer(); + } + + private clearTimer(): void { + if (this.timer !== null) { + clearTimeout(this.timer); + this.timer = null; + } + } +} + class Shell { private windows: ShellWindow[] = []; private selectedIndex = 0; @@ -111,6 +175,8 @@ class Shell { // notification icons and the battery indicators. private readonly trayIcons = new Map(); private activeVoiceLayer: VoiceInputLayer | null = null; + private assistantSession: AssistantSession | null = null; + private assistantLayer: AssistantLayer | null = null; private escapeMenuTimer: ReturnType | null = null; private readonly actions: LayerActions = { ...noopActions }; private config: ShellConfig = { @@ -236,6 +302,21 @@ class Shell { return this.screenOn; } + /** Current headset battery levels (for the assistant's get_state tool). */ + getBatteryLevels(): ShellChromeState["battery"] { + return this.battery; + } + + /** + * The foreground app, or null when only the launcher is showing. The launcher + * is a pinned window but counts as "no app" for the assistant's context. + */ + getForegroundApp(): { appId: string; title: string } | null { + const window = this.foregroundWindow(); + if (!window || window.appId === "launcher") return null; + return { appId: window.appId, title: window.title }; + } + noteUserActivity(nowMs = Date.now()): void { this.lastInputAtMs = nowMs; } @@ -283,7 +364,10 @@ class Shell { // An open voice dialog suspends the timeout: a long dictation or refine // has no button presses, but the screen must stay on for it. Sliding // lastInputAtMs forward also restarts the full timeout when it closes. - if (this.activeVoiceLayer) { + // An in-flight assistant turn suspends it for the same reason (a tool loop + // can run for a while with no input); once the turn ends and the + // Follow-up/Done menu is showing, the normal idle timeout resumes. + if (this.activeVoiceLayer || this.assistantSession?.isTurnActive()) { this.lastInputAtMs = nowMs; return false; } @@ -358,7 +442,13 @@ class Shell { this.lastInputAtMs = Date.now(); const wokeScreen = !this.screenOn && this.wake("sidebar"); if (action === "voice-input" && !this.activeVoiceLayer) { - this.openVoiceDialog(false, true); + if (this.assistantLayer) { + // The assistant overlay is up; a wakeword continues that conversation. + this.startAssistantFollowUp(true); + } else { + // Wakeword defaults the highlight to Send to Assistant. + this.openVoiceDialog({ handsFree: true, defaultTarget: "assistant" }); + } } return { shell: wokeScreen || action === "voice-input", window: false }; } @@ -489,25 +579,77 @@ class Shell { next?.requestRender(); } - private openVoiceDialog(finishOnClick = false, handsFree = false): void { - const layer = new VoiceInputLayer( - this.config.actions, - () => { + private openVoiceDialog(options: { + finishOnClick?: boolean; + handsFree?: boolean; + defaultTarget: "assistant" | "app"; + }): void { + const targets = this.buildVoiceSendTargets(); + let defaultIndex = targets.findIndex((target) => target.id === options.defaultTarget); + if (defaultIndex < 0) defaultIndex = 0; + // Skip the menu only for a hands-free (wakeword) capture aimed at the + // assistant, when the user has opted into it. + const autoSend = + Boolean(options.handsFree) && + options.defaultTarget === "assistant" && + targets[defaultIndex]?.id === "assistant" && + assistantSkipConfirmationSetting.get(); + + const layer = new VoiceInputLayer({ + actions: this.config.actions, + onClosed: () => { if (this.activeVoiceLayer === layer) { this.activeVoiceLayer = null; // The idle countdown restarts in full once voice input ends. this.noteUserActivity(); } }, - (text) => this.sendTextToForegroundWindow(text), - finishOnClick, - handsFree, - ); + dismiss: () => { + this.stack.popIfTop((top) => top === layer); + }, + sendTargets: targets, + defaultTargetIndex: defaultIndex, + finishOnClick: options.finishOnClick ?? false, + handsFree: options.handsFree ?? false, + autoSend, + }); this.activeVoiceLayer = layer; this.stack.push(layer); layer.startCapture(); } + /** + * The send destinations offered by the voice dialog: the assistant (when an + * API key is configured) and/or typing into the foreground window (when it + * accepts text). Order fixes the menu row order. + */ + private buildVoiceSendTargets(): VoiceSendTarget[] { + const targets: VoiceSendTarget[] = []; + if (this.isAssistantAvailable()) { + targets.push({ + id: "assistant", + label: "Send to Assistant", + onSend: (text) => this.sendToAssistant(text), + }); + } + if (this.foregroundWindow()?.receiveTextInput) { + targets.push({ + id: "app", + label: "Type Into App", + onSend: (text) => this.sendTextToForegroundWindow(text), + }); + } + // Guarantee at least one destination so the dialog is never a dead end. + if (targets.length === 0) { + targets.push({ + id: "app", + label: "Type Into App", + onSend: (text) => this.sendTextToForegroundWindow(text), + }); + } + return targets; + } + /** Deliver a text string to the foreground window (e.g. finalized voice input). */ sendTextToForegroundWindow(text: string): void { this.foregroundWindow()?.receiveTextInput?.(text); @@ -521,9 +663,130 @@ class Shell { */ startVoiceInput(): void { if (!this.screenOn || this.activeVoiceLayer || !this.stack.isAtBase()) return; - // The transcript is aimed at the window whose menu requested it. + // The transcript is aimed at the window whose menu requested it; the menu + // entry point defaults the highlight to Type Into App. this.focus = "window"; - this.openVoiceDialog(true); + this.openVoiceDialog({ finishOnClick: true, defaultTarget: "app" }); + this.config.requestShellRender(); + } + + private isAssistantAvailable(): boolean { + return anthropicApiKeySetting.get().trim().length > 0; + } + + private ensureAssistantSession(): AssistantSession | null { + const apiKey = anthropicApiKeySetting.get().trim(); + if (!apiKey) return null; + if (!this.assistantSession || this.assistantSession.isExpired()) { + this.assistantSession = new AssistantSession(apiKey); + } + return this.assistantSession; + } + + private buildAssistantContext(): AssistantContext { + const foreground = this.getForegroundApp(); + return { + foregroundApp: foreground?.appId ?? null, + foregroundTitle: foreground?.title ?? null, + screenOn: this.screenOn, + localTime: formatAssistantTime(new Date()), + headsetBattery: this.battery.headset, + }; + } + + /** + * Start (or continue) an assistant conversation from a finalized utterance. + * Opens the assistant overlay if it isn't already up; a follow-up reuses the + * existing session and overlay. + */ + sendToAssistant(text: string): void { + const session = this.ensureAssistantSession(); + if (!session) { + this.showAlert("Set an Anthropic API key in Settings to use the assistant."); + return; + } + if (!this.screenOn) this.wake("sidebar"); + let layer = this.assistantLayer; + if (!layer) { + const created = new AssistantLayer(this.config.actions, { + onFollowUp: () => this.startAssistantFollowUp(), + onCancel: () => this.assistantSession?.cancel(), + onClose: () => this.closeAssistantLayer(), + onRemoved: () => { + // Removed by any path (Done, or the screen sleeping mid-conversation): + // stop the turn and drop the reference so a later query starts clean. + this.assistantSession?.cancel(); + if (this.assistantLayer === created) this.assistantLayer = null; + }, + }); + layer = created; + this.assistantLayer = created; + this.stack.push(created); + } + this.runAssistantTurn(session, layer, text); + this.config.requestShellRender(); + } + + private runAssistantTurn(session: AssistantSession, layer: AssistantLayer, text: string): void { + layer.startTurn(); + session.sendUtterance(text, this.buildAssistantContext(), { + onTextDelta: (delta, textSoFar) => layer.onTextDelta(delta, textSoFar), + onToolActivity: (label) => layer.onToolActivity(label), + onTurnDone: () => layer.onTurnDone(), + onError: (message) => layer.onError(message), + }); + } + + /** + * Record another utterance in the current assistant conversation. handsFree + * (from a wakeword over the overlay) starts the mic immediately; otherwise + * (the Follow-up menu button) a click ends the utterance. + */ + private startAssistantFollowUp(handsFree = false): void { + const layer = this.assistantLayer; + const session = this.assistantSession; + if (!layer || !session || this.activeVoiceLayer) return; + const voice = new VoiceInputLayer({ + actions: this.config.actions, + onClosed: () => { + if (this.activeVoiceLayer === voice) { + this.activeVoiceLayer = null; + this.noteUserActivity(); + } + }, + dismiss: () => { + this.stack.popIfTop((top) => top === voice); + }, + sendTargets: [ + { id: "assistant", label: "Send", onSend: (text) => this.runAssistantTurn(session, layer, text) }, + ], + finishOnClick: !handsFree, + handsFree, + autoSend: handsFree && assistantSkipConfirmationSetting.get(), + }); + this.activeVoiceLayer = voice; + this.stack.push(voice); + voice.startCapture(); + this.config.requestShellRender(); + } + + private closeAssistantLayer(): void { + // Popping fires the layer's onRemoved, which cancels the turn and clears + // this.assistantLayer. + const layer = this.assistantLayer; + if (layer) this.stack.popIfTop((top) => top === layer); + this.noteUserActivity(); + this.config.requestShellRender(); + } + + /** Show a brief text popup on the lenses (assistant show_alert / notices). */ + showAlert(text: string): void { + if (!this.screenOn) this.wake("sidebar"); + const layer = new ShellAlertLayer(text, () => { + this.stack.popIfTop((top) => top === layer); + this.config.requestShellRender(); + }); + this.stack.push(layer); this.config.requestShellRender(); } @@ -586,6 +849,20 @@ class Shell { export const shell = new Shell(); +const ASSISTANT_WEEKDAYS = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]; +const ASSISTANT_MONTHS = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]; + +/** Human-readable local time for the assistant's per-turn context. */ +function formatAssistantTime(date: Date): string { + let hours = date.getHours(); + const minutes = date.getMinutes().toString().padStart(2, "0"); + const meridiem = hours >= 12 ? "PM" : "AM"; + hours = hours % 12; + if (hours === 0) hours = 12; + const day = `${ASSISTANT_WEEKDAYS[date.getDay()]} ${ASSISTANT_MONTHS[date.getMonth()]} ${date.getDate()}`; + return `${day}, ${hours}:${minutes} ${meridiem}`; +} + export function rawInputEventToInputEvent(event: RawInputEvent): DashboardInputEvent { if (event.kind === "sys-event") { if (event.eventType === OsEventTypeList.CLICK_EVENT) { diff --git a/notes/voice-assistant-design.md b/notes/voice-assistant-design.md new file mode 100644 index 00000000..317e17ed --- /dev/null +++ b/notes/voice-assistant-design.md @@ -0,0 +1,422 @@ +# Voice Assistant Architecture + +Status: design draft, 2026-07-19; revised 2026-07-24 (tool availability +ontology, misc fixes). **Phase 1 is implemented** (see the Implementation plan +below); phases 2-4 are still design-only. + +## Goal + +A default voice assistant reachable from anywhere in the shell: hold the +button, speak, and the utterance goes to an agent that can answer in text on +the lenses and act on the glasses through tools. The agent is pluggable: + +- **Direct mode**: the phone runs the agent loop itself against the Anthropic + Messages API (tool-use loop, conversation state on-phone). +- **External mode**: the utterance is routed to the user's own long-running + agent (OpenClaw, Hermes, or anything similar running on their machine), and + that agent gets access to the glasses' tools while it works. + +Tools come from two sources, with four availability tiers (see "Tool +availability ontology" below): + +- **Glasses/system tools**: provided by the shell, always available (show + text, notifications, screen state, open app, ...). +- **App tools**: contributed by apps. Each app tool declares how much of the + app needs to exist for the tool to be live: merely **installed** ("start a + 5 minute timer" must not require the Timer app to be open), **open** + ("next track" needs a running Music window, foreground or not), or + **foreground** ("scroll down" only makes sense aimed at the foreground app). + +## What we already have + +- **PTT capture UI**: `VoiceInputLayer` (app/ui/apps/voice-input.ts) handles + push-to-talk, live transcripts, and a Send/Continue/Discard menu; `Shell` + opens it on long-press and delivers Send to the foreground window's + `receiveTextInput` (app/ui/shell/shell.ts). +- **Wakeword**: On-device classifier listens for the wakeword "Hey Even", + which sends a message to the phone which wakes the screen and starts voice + input. +- **STT**: `voiceControlBridge` with onboard Moonshine, Whisper, or ElevenLabs + cloud. +- **LLM client**: `streamAnthropicMessage` (app/native/anthropic.ts) — raw + SSE streaming over `FaceclawSseRequest`. Text-only today; no tool use. +- **Worker app protocol**: `WorkerAppMessage`/`WorkerAppReply` + (app/ui/shell/worker-window.ts) — small-JSON postMessage protocol between + shell and app workers; the natural place to add tool declarations. +- **Dial-out websocket precedent**: `G2MirrorClient` — JSON over a websocket + to a server on the user's machine (tailscale host/port/token settings). + The external-agent bridge should copy this shape. + +## Architecture overview + +``` + main isolate (shell) + ┌───────────────────────────────────────────────────────────┐ + │ Shell ──(PTT)──> VoiceInputLayer ──> AssistantSession │ + │ │ │ + │ AssistantLayer (overlay UI) <──streaming──┤ │ + │ │ │ + │ AssistantBackend │ + │ ┌────────┴─────────┐ │ + │ │ Direct │ External│ │ + │ └────┬────┴────┬────┘ │ + │ │ │ │ + │ ToolRegistry <────────────────────────┴─────────┘ │ + │ ├─ system tools (in-process handlers) │ + │ ├─ app "installed" tools (shell-side or launch-on-call) │ + │ └─ app "open"/"foreground" tools (proxied to app worker) │ + └──────────┬──────────────────────────────────────┬─────────┘ + │ postMessage │ + app worker (e.g. terminal) Anthropic API (SSE) + set-tools / tool-call / or agent bridge (WS) + tool-result on the user's machine +``` + +Everything assistant-side lives on the main isolate. Rationale: tool handlers +need shell state (window list, focus, notifications, settings), the agent +loop is I/O-bound not CPU-bound, and the overlay UI is a shell layer anyway. +If conversation rendering ever gets expensive it can move to a worker later +without changing the tool protocol, which is already async message passing. + +### Core pieces + +1. **`ToolRegistry`** (new, `app/assistant/tool-registry.ts`) + - Holds `ToolSpec`s and handlers; answers `listTools(scopeFilter)` and + `callTool(name, args) -> Promise`. + - Emits `onToolsChanged` (needed for MCP `tools/list_changed` in external + mode, and consulted at each turn boundary in direct mode). + +2. **`AssistantBackend`** (interface) with two implementations: + - `DirectAnthropicBackend`: tool-use loop over the Messages API. + - `ExternalAgentBackend`: websocket bridge to the user's agent. + +3. **`AssistantSession`**: one conversation. Owns history/turn state, + exposes `sendUtterance(text, ctx)`, `cancel()`, and streaming callbacks + (`onTextDelta`, `onToolActivity`, `onTurnDone`, `onError`). Both backends + implement the same session surface so the UI is backend-agnostic. + +4. **`AssistantLayer`**: shell overlay showing streamed reply text, a status + line for tool activity ("→ calendar.list_events"), and a small menu + (Follow-up / Done). Double-click cancels the in-flight turn. + +## Entry points and routing + +- **Wakeword** Saying "Hey Even" wakes the screen if necessary and opens the + dictation dialog. For one-off voice commands, this will be the main entry + point. +- **Context menu** The sidebar context menu and app context menu already have + a "Voice input" option, which opens the dictation dialog whose Send goes to + the foreground window. We'll split the Send option in this dialog into two + options, "Send to Assistant" and "Type Into App". If the entry point was via + context menu, "Type Into App" is highlighted by default; if the entry point + was the wakeword, "Send to Assistant" is highlighted by default instead. + (The capture UI is the existing `VoiceInputLayer` flow, with Send handing off + to `AssistantSession` and morphing into `AssistantLayer`). + +## Tool model + +```ts +type ToolAvailability = + | "always" // system tools; no app involved + | "installed" // app tool, live whenever the app is installed — + // the app need not have any window open + | "open" // app tool, live while the app has a window open, + // foreground or backgrounded + | "foreground"; // app tool, live only while the app owns the + // foreground window + +type ToolSpec = { + name: string; // namespaced: "glasses.show_notification", + // "app.terminal.send_input" + description: string; + inputSchema: object; // JSON Schema + availability: ToolAvailability; + /** May be invoked by the external agent outside an active voice turn. */ + proactive?: boolean; + timeoutMs?: number; // default 10s; registry enforces +}; + +type ToolResult = + | { ok: true; content: string } // text payload back to the model + | { ok: false; error: string }; +``` + +### Tool availability ontology + +Every tool sits in exactly one tier, and the tier answers two questions: *when +does the tool appear in `listTools()`*, and *who handles the call*. + +| Tier | Live when | Handler | Examples | +|---|---|---|---| +| `always` | always | shell, in-process | `glasses.get_state`, `notifications.list` | +| `installed` | app installed (launcher entry exists) | shell-side handler registered with the app entry, or launch-the-app-then-proxy | `timer.set` ("start a 5 minute timer" must work with no Timer window), `music.play` (cold-start playback) | +| `open` | app has ≥1 open window, foreground or not | app worker (or in-process window) via tool-call proxy | `music.next_track`, `terminal.send_input` | +| `foreground` | app owns the foreground window | app worker via tool-call proxy | `teleprompt.scroll_down`, anything meaning "act on what I'm looking at" | + +Mechanics per tier: + +- **`installed`** tools cannot be declared by the worker (it may not be + running), so they are declared statically alongside the app's launcher + registration. Two handler flavors: (a) a shell-side handler function + registered with the entry — right for tools that don't actually need the + app UI (timers, starting playback); (b) *launch-on-call*: the shell opens + the app (as if launched from the launcher), waits for its `set-tools` + declaration, then proxies the call. Start with (a) only; (b) adds a + launch-latency/timeout dance that no phase-1/2 tool needs. +- **`open`** and **`foreground`** tools are declared by the running app via + `set-tools` (worker apps) or direct registration (in-process windows). + The registry filters `foreground` tools by whether the declaring app owns + the current foreground window at list time and again at call time — + a `foreground` tool called after a foreground swap fails with a normal tool + error rather than acting on a window the user is no longer looking at. +- A tier is a *floor*, not a routing rule: an `installed` tool stays listed + while the app is open or foreground. If an app wants different behavior when + its window exists (e.g. `timer.set` also shows a countdown in the open + Timer window), the shell-side handler checks for the window itself. + +> **Flag:** with multiple windows per app (the worker protocol is +> per-window), tool names are namespaced per *app*, so two windows of one +> app declaring the same tool name would collide. Rule: `set-tools` +> replaces the app's toolset per window, and a call routes to the declaring +> window; if two windows declare the same name, last declaration wins and +> earlier ones are dropped with a logged warning. Revisit only if a real +> app needs per-window tools with the same name (none of the planned ones +> do). + +### System tools (initial set) + +| Tool | Notes | +|---|---| +| `glasses.show_alert` | short text popup on the lenses; proactive-capable | +| `glasses.list_windows` / `glasses.focus_window` / `glasses.open_app` | shell control | +| `glasses.get_state` | screen on/off, foreground app, battery levels, time | +| `glasses.read_screen` | text/description of the current foreground surface (start with window title + app-reported summary; pixel OCR is out of scope) | +| `calendar.list_events` | wraps FaceclawCalendarProvider | +| `media.play_pause` / `media.next` / `media.now_playing` | wraps FaceclawMediaController | +| `notifications.list` / `notifications.dismiss` | wraps notification listener | +| `timer.set` / `timer.cancel` | new, but trivial and high-value for an assistant | + +Keep the first release to ~8–12 tools; every tool costs prompt tokens and +model attention in direct mode. + +Note that `calendar.*`, `media.*`, and `timer.*` are conceptually +`installed`-tier app tools that happen to be implemented by in-process shell +code; listing them here just means the shell registers their handlers +directly. If any of them later becomes a real app, its tools move to the +app's launcher registration without the model-visible surface changing. + +### App tools + +Running apps declare `open`/`foreground` tools per window over the existing +worker protocol (`installed` tools are declared statically with the launcher +entry, per the ontology above): + +```ts +// WorkerAppReply additions (worker -> shell) +| { type: "set-tools"; windowId: string; tools: ToolSpec[] } // replaces the set +| { type: "tool-result"; callId: string; result: ToolResult } + +// WorkerAppMessage additions (shell -> worker) +| { type: "tool-call"; callId: string; windowId: string; name: string; args: unknown } +``` + +Registry rules: + +- Liveness follows the availability tier: `open` tools are removed when the + app's last window closes, `foreground` tools additionally drop out of + `listTools()` when the app loses the foreground. Either transition fires + `onToolsChanged`; in-flight calls to a closed window resolve as errors, + and calls to a `foreground` tool are re-checked at dispatch time. +- Names are auto-prefixed `app..` by the registry so apps can't + shadow system tools or each other. +- The shell enforces `timeoutMs` on the postMessage round-trip; a hung + worker yields a tool error, not a hung turn (same philosophy as input + handling — the shell must survive a stuck app). +- In-process shell apps (calendar, music, ...) register handlers directly + with the registry; the worker protocol is just the remote flavor of the + same registration. +- **Mid-turn availability changes** (foreground swap, window close): direct + mode re-lists tools at each loop iteration (tool set is per-API-call + anyway); external mode sends MCP `notifications/tools/list_changed`. A + call to a tool that just vanished returns a normal tool error the model + can react to. + +First app to wire up: the terminal — +`app.terminal.send_input` (type into the attached session; `open`, +proactive: false — "rerun the build" should work while the terminal is +backgrounded), `app.terminal.read_screen` (current grid contents; `open`), +`app.terminal.list_sessions` (`open`). This immediately enables "tell the +terminal to rerun the build" style commands and doubles as the reference +implementation — deliberately all `open`-tier; the first `foreground` tool +should come from an app where focus genuinely matters (teleprompt scrolling). + +## Direct mode: agent loop on the phone + +Extend `app/native/anthropic.ts`: + +1. **Streaming tool-use support**: handle `content_block_start` with + `tool_use`, accumulate `input_json_delta`, surface complete tool_use + blocks alongside text deltas. (Today the client only reads `text_delta`.) +2. **`runAgentTurn` loop** (new, `app/assistant/direct-backend.ts`): + messages + `tools` from the registry → stream → if `stop_reason == + "tool_use"`, execute each call via the registry, append `tool_result` + blocks, continue; until `end_turn`/`refusal` or a safety cap + (max 8 loop iterations, max ~2 min per turn). +3. **Session state**: history kept in memory per `AssistantSession`, + trimmed from the head past a token budget. Sessions idle-expire + (~10 min) so a new PTT starts fresh; "Follow-up" continues the session. +4. **System prompt**: glasses context — output renders on a 576×288 + monochrome HUD, so answer in 1–3 short sentences, no markdown, no lists + unless asked; prefer acting via tools over describing; current time, + foreground app, and screen state are injected per turn. +5. Model `claude-sonnet-5`, `effort: "low"` (same latency posture as the + dictation refiner). Model/effort become settings later if needed. + +## External mode: bridge to the user's agent + +### Topology + +The phone **dials out** (g2mirror pattern — phones don't accept inbound +connections reliably; tailscale host + port + token settings) to a small +**bridge server** co-located with the user's agent. One websocket, JSON +frames, three multiplexed channels: + +``` +{ v: 1, chan: "ctl" | "chat" | "mcp", ... } + +ctl: hello {deviceName, token, capabilities}, hello-ack, ping/pong, error +chat: utterance {turnId, text, ctx} (phone -> agent) + text-delta {turnId, text} (agent -> phone) + tool-activity {turnId, label} (agent -> phone, optional status) + turn-done {turnId, stopReason} / turn-error {turnId, message} + cancel {turnId} (phone -> agent) +mcp: { msg: } (bidirectional) +``` + +On the `mcp` channel the **phone is an MCP server** (MCP roles come from the +initialize handshake, not from who dialed). It serves `tools/list` from the +ToolRegistry, `tools/call` into it, and emits `tools/list_changed` on +foreground changes. This means the agent-side integration needs zero +Faceclaw-specific tool code — the glasses appear as a normal MCP server. + +### Agent-side adapters + +The bridge server is a small standalone package (`faceclaw-agent-bridge`, +sibling of g2mirror) with two faces: + +1. **MCP face**: re-exposes the phone's MCP channel as a localhost + streamable-HTTP MCP endpoint. The user registers + `http://localhost:/mcp` with their agent (OpenClaw, Hermes, Claude + Code, anything MCP-capable) exactly like any other MCP server. When the + phone is disconnected, `tools/list` returns empty rather than erroring. +2. **Chat face**: pluggable per-agent adapter that forwards `utterance` + frames into the agent and streams replies back: + - **OpenClaw**: a plugin that injects the utterance as an inbound message + on a dedicated "glasses" channel/session and relays the streamed reply. + - **Hermes**: equivalent module against its session API. + - **Fallback adapter**: spawn a configured CLI (e.g. `claude -p --resume`) + per turn — lowest-fidelity but makes the bridge useful with no plugin. + +Utterance `ctx` carries `{foregroundApp, screenOn, localTime}` so the remote +agent has the same situational grounding the direct loop gets in its system +prompt. + +### Proactive agent actions + +Because the MCP channel is live whenever the bridge is connected, the +external agent can call glasses tools **outside a voice turn** — e.g. push a +notification to the lenses when a long job finishes. Gating: + +- Only tools marked `proactive: true` are callable outside an active turn + (registry-enforced; enforced on the phone, never trusted to the bridge). + Availability tiers apply to proactive calls unchanged: a proactive + `installed` tool (e.g. `timer.set`) works anytime, while a proactive call + to an `open`/`foreground` tool whose app isn't in the right state gets the + same tool error a mid-turn call would. +- Master setting `assistant.allowProactive` (default on — it's a marquee + feature — but visible and easy to turn off). +- Proactive display actions are rate-limited (e.g. 6/min) and never turn + the screen on unless the user enabled that specifically. + +## Settings + +New "Assistant" section in dashboard settings: + +- `assistant.backend`: `anthropic` | `external` (default `anthropic` if an + API key is set, else `external` if a bridge host is set). +- `assistant.bridgeHost` / `assistant.bridgePort` / `assistant.bridgeToken` + (mirrors the terminal.* trio). +- `assistant.allowProactive`: boolean. +- `voice.skipConfirmationAfterWakeword`: Wakeword-triggered input sends to the + assistant immediately at the end of an utterance, rather than waiting for a + menu selection. +- Reuses existing `llm.anthropicApiKey` for direct mode. + +## Security notes + +- Bridge auth: bearer token in the `hello` frame, TLS optional because the + expected transport is tailscale (same stance as g2mirror); document that + plainly. +- The phone enforces all tool gating (proactive flags, rate limits, + timeouts). The bridge and agent are treated as honest-but-fallible. +- Tool results may contain private data (calendar, notifications); external + mode ships them to the user's own machine only — no third-party hop. In + direct mode they go to the Anthropic API like any other request content. +- App tools execute inside the app's worker with the app's existing + privileges; the registry adds no new capability beyond what the app could + already do. + +## Implementation plan + +**Phase 1 — direct assistant, system tools only.** ✅ Landed 2026-07-24 +(builds + typechecks; not yet hardware-tested). +ToolRegistry (`app/assistant/tool-registry.ts`) with the full availability-tier +model but only `always` tools wired; 8 system tools (`glasses.get_state`, +`glasses.show_alert`, `calendar.list_events`, `media.now_playing`/`play_pause`/ +`next`, `notifications.list`/`dismiss`) in `app/assistant/system-tools.ts`; +tool-use streaming in `anthropic.ts` (content-block assembly, `tools` param); +`DirectAnthropicBackend` + `AssistantSession`; `AssistantLayer` overlay +(`app/ui/apps/assistant.ts`); `VoiceInputLayer` reworked to route via a +`sendTargets` list ("Send to Assistant" / "Type Into App") with entry-point +default highlight and wakeword skip-confirmation auto-send; +`shell.showAlert` popup; `assistant.skipConfirmationAfterWakeword` setting. +*Deliverable: speak wakeword, ask "what's on my calendar", get an answer +on-lens.* + +**Phase 2 — app tools.** +Worker protocol extension (set-tools / tool-call / tool-result), +availability-tier filtering in the registry (`open` on window open/close, +`foreground` on foreground change), `installed`-tier registration on launcher +entries (shell-side handlers only; launch-on-call deferred), terminal app +tools as the reference. *Deliverable: "run the build again" typed into the +terminal even while it's backgrounded.* + +**Phase 3 — external bridge.** +Bridge wire protocol; ExternalAgentBackend (phone side, reusing the +FaceclawWebSocket plumbing); `faceclaw-agent-bridge` server with the MCP +face + fallback CLI chat adapter; settings; reconnect/offline behavior. +*Deliverable: utterances answered by the user's own agent, which can also +call glasses tools mid-task.* + +**Phase 4 — OpenClaw/Hermes adapters + proactive polish.** +Native chat adapters for both agents; proactive gating + rate limits; +`tools/list_changed` on foreground swap; session persistence across +reconnects. + +## Open questions (deferred, not blockers): + +- Continuous conversation: after a turn ends, listen for a follow-up + utterance without requiring the wakeword/PTT again? There are some UI + design questions here; maybe multi-turn conversations take the form of an + Assistant app. +- Launch-on-call for `installed`-tier tools that genuinely need the app UI + (open the app, await `set-tools`, proxy the call) — deferred until a tool + needs it. +- `glasses.read_screen` fidelity beyond app-reported summaries? We probably + don't want to do OCR, but we might do something like extending the draw-text + draw call with an on-by-default option that also appends the drawn text to + a string that gets submitted along with the frame. +- Whether assistant conversations should be reviewable in the phone UI + (transcript log) — probably yes, cheap once sessions are objects. The + natural UI home for this would be inside an Assistant app window. +