Sync source edition with VCC Plus 3.7.0 build 63

This commit is contained in:
Brian Holman committed 2026-11-14 01:43:46 -07:00
1 parent c652a5276d
commit b2ecec4d87
86 files changed
+10519 -472

No files matched your search

@@ -85,6 +85,29 @@ static NSArray<NSDictionary *> *MCPBuildDiagnosticTools() {
@"annotations":@{@"readOnlyHint":@YES,@"openWorldHint":@NO}}];
}
static NSArray<NSDictionary *> *MCPPlaytestVideoTools() {
NSDictionary *identifier = @{ @"type":@"string", @"minLength":@1, @"maxLength":@64 };
NSDictionary *(^tool)(NSString *, NSString *, NSDictionary *, NSArray *, BOOL) =
^NSDictionary *(NSString *name, NSString *description, NSDictionary *fields, NSArray *required, BOOL readOnly) {
return @{ @"name":name, @"description":description,
@"inputSchema":@{ @"type":@"object", @"properties":fields, @"required":required, @"additionalProperties":@NO },
@"annotations":@{ @"readOnlyHint":@(readOnly), @"openWorldHint":@NO } };
};
return @[
tool(@"start_playtest_video", @"Start a bounded MP4 recording of an owned disposable playtest's actual CoCo picture and optional generated CoCo audio. Does not advance execution: use ordinary playtest_input afterward. No microphone, Mac windows, personal emulator audio or capture UI cues are recorded. Maximum 3600 emulated fields (60 seconds), 64 MiB per clip, four clips and 256 MiB retained per run. Reuse an identical request_id on retry. Recordings end at their field/size limit with explicit truncation status; stop and retrieve the completed clip before restarting.",
@{ @"run_id":identifier, @"request_id":identifier, @"include_audio":@{ @"type":@"boolean", @"default":@YES },
@"max_fields":@{ @"type":@"integer", @"minimum":@1, @"maximum":@3600, @"default":@1800 } },
@[@"run_id", @"request_id"], NO),
tool(@"stop_playtest_video", @"Finish the current owned playtest recording without advancing the guest. Returns completed MP4 identity, byte count, SHA-256, actual field interval and truncation status. Retrying the identical request_id returns the same receipt. Remains available when ordinary mutation requests are exhausted; working files are retained if finalization fails.",
@{ @"run_id":identifier, @"request_id":identifier }, @[@"run_id", @"request_id"], NO),
tool(@"read_playtest_video", @"Read a completed MP4 belonging to this owned playtest in bounded base64 chunks. Assemble the chunks in offset order and verify the complete byte_count and SHA-256 from the receipt. Accepts only a clip_id returned by this run, never a host file path. Does not advance or change the guest.",
@{ @"run_id":identifier, @"clip_id":identifier,
@"offset":@{ @"type":@"integer", @"minimum":@0, @"maximum":@67108864, @"default":@0 },
@"limit":@{ @"type":@"integer", @"minimum":@1, @"maximum":@65536, @"default":@65536 } },
@[@"run_id", @"clip_id"], YES)
];
}
static NSArray<NSDictionary *> *MCPPlaytestAudioTools() {
return @[@{@"name":@"capture_playtest_audio", @"description":@"Advance an owned disposable guest for 1 to 120 emulated fields and return its direct audio as PCM16 stereo WAV. Leaves the guest paused; verified stops can shorten the interval. Uses no microphone or personal emulator audio. Reuse request_id on retry to return the same clip without execution. Maximum 16 clips and 4 MiB retained WAV per run across boots; a maximum-clip allowance must remain before capture. Receipts include actual field interval, boot/run/artifact identity, sample count and SHA-256.",
@"inputSchema":@{@"type":@"object", @"properties":@{
+22 -1
View File
@@ -114,7 +114,7 @@ NSDictionary *hostCall(NSDictionary *grant, bool loopback, NSString *tool, NSDic
Descriptor peer(socket(address->sa_family, SOCK_STREAM, 0));
const bool playtestCall = [@[@"start_playtest", @"playtest_input", @"playtest_debug", @"capture_playtest",
@"restart_playtest", @"stop_playtest", @"get_debug_snapshot", @"capture_playtest_graphics",
@"exchange_playtest_media"] containsObject:tool];
@"exchange_playtest_media", @"start_playtest_video", @"stop_playtest_video"] containsObject:tool];
const auto deadline = Clock::now() + std::chrono::seconds(playtestCall ? 55 : 5);
if (peer.fd < 0 || fcntl(peer.fd, F_SETFL, O_NONBLOCK) < 0) return @{@"error":@"host_unavailable"};
if (connect(peer.fd, address, address->sa_len) != 0) {
@@ -381,6 +381,23 @@ NSDictionary *handle(id message, NSDictionary *grant, bool loopback, NSArray *to
}
NSMutableDictionary *data = [reply[@"result"] mutableCopy];
NSMutableArray *content = [NSMutableArray array];
if ([name isEqual:@"read_playtest_video"]) {
NSString *encoded = data[@"video_chunk_base64"], *hash = data[@"sha256"];
if (!string(encoded) || encoded.length > 87384 || !string(hash) || hash.length != 64 ||
[hash rangeOfCharacterFromSet:[[NSCharacterSet characterSetWithCharactersInString:@"0123456789abcdef"] invertedSet]].location != NSNotFound ||
![data[@"mime_type"] isEqual:@"video/mp4"] || ![data[@"clip_id"] isEqual:args[@"clip_id"]] ||
!integer(data[@"offset"]) || !integer(data[@"next_offset"]) || !integer(data[@"byte_count"]) ||
![data[@"eof"] isKindOfClass:NSNumber.class] || CFGetTypeID((__bridge CFTypeRef)data[@"eof"]) != CFBooleanGetTypeID())
return toolError(rid, @"invalid_playtest_video");
NSData *chunk = [[NSData alloc] initWithBase64EncodedString:encoded options:0];
const long long offset = [data[@"offset"] longLongValue], next = [data[@"next_offset"] longLongValue], total = [data[@"byte_count"] longLongValue];
const long long requestedOffset = args[@"offset"] ? [args[@"offset"] longLongValue] : 0;
const NSUInteger limit = args[@"limit"] ? [args[@"limit"] unsignedIntegerValue] : 65536;
if (!chunk || chunk.length > limit || chunk.length > 65536 || offset != requestedOffset || offset < 0 ||
total < 1 || total > 67108864 || offset > total || next != offset + (long long)chunk.length || next > total ||
[data[@"eof"] boolValue] != (next == total) || (!chunk.length && next < total))
return toolError(rid, @"invalid_playtest_video");
}
if ([name isEqual:@"capture_playtest_audio"]) {
NSString *encoded = data[@"audio_wav_base64"];
if (!string(encoded) || !object(data[@"audio"])) return toolError(rid, @"invalid_playtest_audio");
@@ -492,6 +509,10 @@ int main(int argc, char **argv) {
if ([grant[@"kind"] isEqual:@"cmoc"] && toolset >= 7 &&
[grant[@"playtest"] isEqual:@YES] && [grant[@"playtestAudio"] isEqual:@YES])
tools = [tools arrayByAddingObjectsFromArray:MCPPlaytestAudioTools()];
if ([grant[@"kind"] isEqual:@"cmoc"] && toolset >= 12 &&
[grant[@"playtest"] isEqual:@YES] && CFGetTypeID((__bridge CFTypeRef)grant[@"playtest"]) == CFBooleanGetTypeID() &&
[grant[@"playtestVideo"] isEqual:@YES] && CFGetTypeID((__bridge CFTypeRef)grant[@"playtestVideo"]) == CFBooleanGetTypeID())
tools = [tools arrayByAddingObjectsFromArray:MCPPlaytestVideoTools()];
if ([grant[@"kind"] isEqual:@"cmoc"] && toolset >= 10 && [grant[@"playtest"] isEqual:@YES] &&
CFGetTypeID((__bridge CFTypeRef)grant[@"playtest"]) == CFBooleanGetTypeID() &&
[grant[@"playtestCallContext"] isEqual:@YES] &&
+52
View File
@@ -93,6 +93,8 @@ def check(helper):
result = {"result": active["playtest_graphics"]}
if request["tool"] == "capture_playtest_audio" and "playtest_audio" in active:
result = {"result": active["playtest_audio"]}
if request["tool"] in ("start_playtest_video", "stop_playtest_video", "read_playtest_video") and "playtest_video" in active:
result = {"result": active["playtest_video"]}
if request["tool"] == "get_build_log" and "build_log" in active:
result = {"result": active["build_log"]}
if request["tool"] == "get_debug_snapshot" and "debug_snapshot" in active:
@@ -788,6 +790,56 @@ def check(helper):
assert refused["isError"] and not any(x["type"] == "audio" for x in refused["content"])
del active["playtest_audio"]
video_tools = {"start_playtest_video", "stop_playtest_video", "read_playtest_video"}
for kind, toolset, play, video in (("cmoc", 11, True, True), ("assembly", 12, True, True),
("cmoc", 12, False, True), ("cmoc", 12, 1, True),
("cmoc", 12, True, False), ("cmoc", 12, True, 1),
("cmoc", 12, True, "yes"), ("cmoc", 12, True, True)):
write_grant(kind=kind, toolset=toolset, playtest=play, playtestVideo=video, token=active["token"])
with Client(helper, grant_file) as c:
c.handshake("2025-11-25")
catalog = {t["name"]: t for t in c.request("tools/list")["result"]["tools"]}
enabled = kind == "cmoc" and toolset >= 12 and play is True and video is True
assert video_tools.intersection(catalog) == (video_tools if enabled else set())
if not enabled:
continue
assert catalog["start_playtest_video"]["annotations"]["readOnlyHint"] is False
assert catalog["stop_playtest_video"]["annotations"]["readOnlyHint"] is False
assert catalog["read_playtest_video"]["annotations"]["readOnlyHint"] is True
for tool in video_tools:
assert catalog[tool]["inputSchema"]["additionalProperties"] is False
active["playtest_video"] = {"run_id":"owned", "video_recording":{"status":"recording"}}
for args in ({"run_id":"owned", "request_id":"begin"},
{"run_id":"owned", "request_id":"begin", "include_audio":False, "max_fields":3600}):
assert c.call("start_playtest_video", **args)["result"]["structuredContent"] == active["playtest_video"]
assert c.call("stop_playtest_video", run_id="owned", request_id="end")["result"]["structuredContent"] == active["playtest_video"]
count = len(active["requests"])
for update in ({"max_fields":0}, {"max_fields":3601}, {"max_fields":True}, {"max_fields":1.5},
{"include_audio":1}, {"include_audio":"yes"}, {"path":"/tmp/private"}):
args = {"run_id":"owned", "request_id":"bad", **update}
assert c.call("start_playtest_video", **args)["result"]["isError"], update
assert c.call("stop_playtest_video",run_id="owned",request_id="bad",path="/tmp/private")["result"]["isError"]
for update in ({"offset":-1}, {"offset":True}, {"offset":67108865}, {"limit":0},
{"limit":65537}, {"limit":True}, {"path":"/tmp/private"}):
assert c.call("read_playtest_video",run_id="owned",clip_id="clip",**update)["result"]["isError"], update
assert count == len(active["requests"]), "Invalid video requests must never reach the host"
payload = b"\x00\x00\x00\x18ftypmp42" + bytes(range(256)) * 255
chunk = dict(run_id="owned", clip_id="clip", video_chunk_base64=base64.b64encode(payload).decode(),
offset=0,next_offset=len(payload),byte_count=len(payload),eof=True,
sha256=hashlib.sha256(payload).hexdigest(),mime_type="video/mp4")
active["playtest_video"] = chunk
result = c.call("read_playtest_video",run_id="owned",clip_id="clip")["result"]
assert result["structuredContent"] == chunk
assert json.loads(result["content"][0]["text"]) == chunk
for update in ({"video_chunk_base64":"!"}, {"next_offset":len(payload)+1}, {"byte_count":67108865},
{"offset":1}, {"eof":False}, {"sha256":"x"*64}, {"clip_id":"foreign"},
{"mime_type":"audio/wav"}, {"video_chunk_base64":"", "next_offset":0}):
active["playtest_video"] = {**chunk, **update}
assert c.call("read_playtest_video",run_id="owned",clip_id="clip")["result"]["isError"], update
active["playtest_video"] = {**chunk, "video_chunk_base64":"", "offset":len(payload), "next_offset":len(payload)}
assert c.call("read_playtest_video",run_id="owned",clip_id="clip",offset=len(payload))["result"]["structuredContent"]["eof"] is True
del active["playtest_video"]
write_grant(version=2, kind="archive", token=active["token"], canPropose=True, toolset=3)
with Client(helper, grant_file) as c:
c.handshake("2025-11-25")