// SPDX-License-Identifier: GPL-3.0-or-later #import static NSDictionary *MCPGuestKeySchema(BOOL includeProbe) { NSString *alphabet = @" 0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"; NSMutableArray *values = [NSMutableArray array]; for (NSUInteger i = 0; i < alphabet.length; ++i) [values addObject:[alphabet substringWithRange:NSMakeRange(i, 1)]]; if (includeProbe) [values addObject:@"PRINT 7\n"]; return @{@"type": @"string", @"enum": values}; } static NSArray *MCPGuestTools(BOOL interactive) { NSDictionary *identifier = @{@"type": @"string", @"minLength": @1, @"maxLength": @64}; NSDictionary *keys = interactive ? MCPGuestKeySchema(YES) : @{@"type": @"string", @"enum": @[@"0",@"1",@"2",@"3",@"4",@"5",@"6",@"7",@"8",@"9",@"PRINT 7\n"]}; NSDictionary *(^tool)(NSString *, NSString *, NSDictionary *, BOOL) = ^NSDictionary *(NSString *name, NSString *description, NSDictionary *properties, BOOL readOnly) { return @{@"name":name, @"description":description, @"annotations":@{@"readOnlyHint":@(readOnly), @"openWorldHint":@NO}, @"inputSchema":@{@"type":@"object", @"properties":properties, @"additionalProperties":@NO, @"required":[properties.allKeys sortedArrayUsingSelector:@selector(compare:)]}}; }; return @[tool(@"get_run", @"Inspect the run started by the user for this reviewed BASIC revision.", @{@"document_id":identifier, @"revision":@{@"type":@"integer", @"minimum":@0}}, YES), tool(@"read_screen_text", @"Observe this run's guest text, frame, display signal and sampled RGB text backgrounds.", @{@"run_id":identifier}, YES), tool(@"send_keys", interactive ? @"Send one ASCII letter, digit or space to the running BASIC program, or PRINT 7\n at the BASIC prompt. Use a fresh request_id per key and reuse it on retry. Up to 64 keys per run." : @"Send a single menu digit, or a fixed PRINT 7 command after BASIC returns. Reuse request_id when retrying.", @{@"run_id":identifier, @"request_id":identifier, @"keys":keys}, NO)]; }