| 87 | // ============ Tool Definitions ============ |
| 88 | |
| 89 | export function getFileToolDefinitions(): Array<{ |
| 90 | type: 'function'; |
| 91 | function: { |
| 92 | name: string; |
| 93 | description: string; |
| 94 | parameters: { |
| 95 | type: 'object'; |
| 96 | properties: Record<string, unknown>; |
| 97 | required: string[]; |
| 98 | }; |
| 99 | }; |
| 100 | }> { |
| 101 | return [ |
| 102 | { |
| 103 | type: 'function', |
| 104 | function: { |
| 105 | name: 'file_read', |
| 106 | description: |
| 107 | 'Read a file from storage. Returns the file content. Path is relative to workspace root, e.g. "apps/{appName}/data/state.json"', |
| 108 | parameters: { |
| 109 | type: 'object', |
| 110 | properties: { |
| 111 | file_path: { |
| 112 | type: 'string', |
| 113 | description: 'File path relative to workspace root', |
| 114 | }, |
| 115 | }, |
| 116 | required: ['file_path'], |
| 117 | }, |
| 118 | }, |
| 119 | }, |
| 120 | { |
| 121 | type: 'function', |
| 122 | function: { |
| 123 | name: 'file_write', |
| 124 | description: |
| 125 | 'Write content to a file in storage. Creates parent directories automatically. Path is relative to workspace root, e.g. "apps/{appName}/data/state.json"', |
| 126 | parameters: { |
| 127 | type: 'object', |
| 128 | properties: { |
| 129 | file_path: { |
| 130 | type: 'string', |
| 131 | description: 'File path relative to workspace root', |
| 132 | }, |
| 133 | content: { |
| 134 | type: 'string', |
| 135 | description: 'File content to write (string or JSON string)', |
| 136 | }, |
| 137 | }, |
| 138 | required: ['file_path', 'content'], |
| 139 | }, |
| 140 | }, |
| 141 | }, |
| 142 | { |
| 143 | type: 'function', |
| 144 | function: { |
| 145 | name: 'file_list', |
| 146 | description: |