#!/bin/bash # Fix all app files to use the correct pattern for file in src/apps/*.ts; do echo "Processing $file..." # Skip if already has registerAccountHealthApp (already fixed) if grep -q "registerAccountHealthApp" "$file"; then continue fi # Skip if doesn't have the old pattern if ! grep -q "export function register(server: any, client: any)" "$file"; then continue fi # Add ToolRegistry import if not present if ! grep -q "import type { ToolRegistry }" "$file"; then sed -i '' '1a\ import type { ToolRegistry } from "../server.js"; ' "$file" fi # Fix function signature and add client sed -i '' 's/export function register(server: any, client: any): void {/export function register(registry: ToolRegistry): void {\ const client = registry.getClient();\ /g' "$file" # Fix server.tool( to registry.registerTool({ sed -i '' 's/server\.tool(/registry.registerTool({/g' "$file" echo "Fixed $file" done echo "Done!"