| 1281 | static bool parse_stream_options(const char **p, bool *include_usage) { |
| 1282 | json_ws(p); |
| 1283 | if (**p != '{') return json_skip_value(p); |
| 1284 | (*p)++; |
| 1285 | json_ws(p); |
| 1286 | while (**p && **p != '}') { |
| 1287 | char *key = NULL; |
| 1288 | if (!json_string(p, &key)) return false; |
| 1289 | json_ws(p); |
| 1290 | if (**p != ':') { |
| 1291 | free(key); |
| 1292 | return false; |
| 1293 | } |
| 1294 | (*p)++; |
| 1295 | if (!strcmp(key, "include_usage")) { |
| 1296 | if (!json_bool(p, include_usage)) { |
| 1297 | free(key); |
| 1298 | return false; |
| 1299 | } |
| 1300 | } else if (!json_skip_value(p)) { |
| 1301 | free(key); |
| 1302 | return false; |
| 1303 | } |
| 1304 | free(key); |
| 1305 | json_ws(p); |
| 1306 | if (**p == ',') (*p)++; |
| 1307 | json_ws(p); |
| 1308 | } |
| 1309 | if (**p != '}') return false; |
| 1310 | (*p)++; |
| 1311 | return true; |
| 1312 | } |
| 1313 | |
| 1314 | static bool parse_function_call(const char **p, tool_call *tc) { |
| 1315 | json_ws(p); |
| 1316 | if (**p != '{') return false; |
| 1317 | (*p)++; |
| 1318 | json_ws(p); |
| 1319 | while (**p && **p != '}') { |
| 1320 | char *key = NULL; |
| 1321 | if (!json_string(p, &key)) goto bad; |
| 1322 | json_ws(p); |
| 1323 | if (**p != ':') { |
| 1324 | free(key); |
| 1325 | goto bad; |
| 1326 | } |
| 1327 | (*p)++; |
| 1328 | if (!strcmp(key, "name")) { |
| 1329 | if (!json_string_replace(p, &tc->name)) { |
| 1330 | free(key); |
| 1331 | goto bad; |
| 1332 | } |
| 1333 | } else if (!strcmp(key, "arguments")) { |
| 1334 | json_ws(p); |
| 1335 | if (**p == '"') { |
| 1336 | if (!json_string_replace(p, &tc->arguments)) { |
| 1337 | free(key); |
| 1338 | goto bad; |
| 1339 | } |
| 1340 | } else if (!json_raw_value_replace(p, &tc->arguments)) { |
no test coverage detected