| 428 | * LLM discovers available actions by reading meta.yaml via file tools. |
| 429 | */ |
| 430 | export function getAppActionToolDefinition(): { |
| 431 | type: 'function'; |
| 432 | function: { |
| 433 | name: string; |
| 434 | description: string; |
| 435 | parameters: { type: 'object'; properties: Record<string, unknown>; required: string[] }; |
| 436 | }; |
| 437 | } { |
| 438 | return { |
| 439 | type: 'function', |
| 440 | function: { |
| 441 | name: 'app_action', |
| 442 | description: |
| 443 | "Trigger an action on an app. Read the app's meta.yaml first to discover available action types and their parameters. " + |
| 444 | 'OS-level actions (OPEN_APP, CLOSE_APP, SET_WALLPAPER) MUST use app_name="os".', |
| 445 | parameters: { |
| 446 | type: 'object', |
| 447 | properties: { |
| 448 | app_name: { |
| 449 | type: 'string', |
| 450 | description: 'The appName of the target app (from list_apps)', |
| 451 | }, |
| 452 | action_type: { |
| 453 | type: 'string', |
| 454 | description: 'The action type to trigger (e.g. REFRESH_TRACKS, SYNC_STATE, OPEN_APP)', |
| 455 | }, |
| 456 | params: { |
| 457 | type: 'string', |
| 458 | description: 'JSON string of action parameters, e.g. \'{"trackId":"123"}\'', |
| 459 | }, |
| 460 | }, |
| 461 | required: ['app_name', 'action_type'], |
| 462 | }, |
| 463 | }, |
| 464 | }; |
| 465 | } |
| 466 | |
| 467 | /** |
| 468 | * Execute the generic app_action tool call. |