Sync VCC Plus 3.7.1 build 67 source

Refresh reviewed MCP output export, four-drive owned playtests, bounded BASIC readiness, and pinned CMOC 0.1.101 source/patches. Preserve independent source-edition identity, empty libraries, notices and privacy boundaries.

Validated 74 export/privacy checks, pinned dependency sources, and an independent unsigned universal Release build. A subsequent documentation-only correction removes an excluded qualification link; all build inputs remain identical.
This commit is contained in:
Brian Holman committed 2026-11-17 08:42:27 -07:00
1 parent 4abc194001
commit 5534005799
54 files changed
+2950 -435

No files matched your search

+162 -15
View File
@@ -94,7 +94,7 @@ struct MCPProjectRefreshRecord {
let next = offset + bounded.items.count
return (bounded.items, next < entries.count ? next : nil, bounded.truncated)
}
static let safeTools: Set<String> = ["get_capabilities", "get_machine_status", "get_build", "get_build_log", "get_project_refresh", "read_project_inputs", "refresh_project", "read_project_file", "get_proposal"]
static let safeTools: Set<String> = ["get_capabilities", "get_machine_status", "get_build", "get_build_log", "get_project_refresh", "read_project_inputs", "refresh_project", "read_project_file", "get_proposal", "export_build_outputs", "get_build_export"]
}
/// The grant binds reviewed drafts and build artifacts to one selected project.
@@ -152,9 +152,42 @@ final class MCPCMOC: ObservableObject {
private var approvedRecipeID: String?
@Published var allowProjectMakefile = false
@Published var allowPlaytests = false
@Published var allowBuildExport = false
@Published fileprivate private(set) var exportFolderName: String?
private var selectedExportDirectory: URL?
fileprivate var buildExporter: MCPBuildExporter?
private var exportSources: [String: (revision: Int, configuration: String, source: MCPBuildExporter.Source)] = [:]
private struct ExportRecord {
let identity: String
let base: [String: Any]
var status = "exporting"
var delivery: MCPBuildExporter.Delivery?
var reason: String?
var fields: [String: Any] {
var value = base
value["status"] = status; value["busy"] = status == "exporting"
if let delivery {
value["delivery_directory"] = delivery.directory
let artifactID = UUID(uuidString: base["artifact_id"] as? String ?? "")!
value["outputs"] = delivery.products.map { product -> [String: Any] in
var fields = product.fields(artifactID: artifactID)
fields["relative_filename"] = delivery.directory + "/" + product.relativePath
return fields
}
}
if let reason { value["error"] = reason }
return value
}
}
private var exportRecords: [String: ExportRecord] = [:]
private var exportRequests: [String: String] = [:]
private var exportWork: Task<Void, Never>?
private var exporting = false
private var exportReservedBytes = 0
fileprivate private(set) var playtestsApproved = false
private var callContextApproved = false
private var playtestMediaApproved = false
private var playtestMultiDriveApproved = false
#if DEBUG
private var regressionPlaytestHelper: URL?
private var regressionStarterKit: StarterKit?
@@ -376,9 +409,11 @@ final class MCPCMOC: ObservableObject {
#if DEBUG
func exportCallContextRegression(_ model: CMOCDevelopmentModel, at destination: URL, playtests: Bool = true,
helperURL: URL? = nil, roms: URL? = nil) async throws {
helperURL: URL? = nil, roms: URL? = nil, exportFolder: URL? = nil) async throws {
allowProjectMakefile = true
allowPlaytests = playtests
allowBuildExport = exportFolder != nil; selectedExportDirectory = exportFolder
exportFolderName = exportFolder?.lastPathComponent
try await grant(model, at: destination)
regressionPlaytestHelper = helperURL
regressionStarterKit = roms.map { StarterKit(directory: $0) }
@@ -401,7 +436,7 @@ final class MCPCMOC: ObservableObject {
private func sanitized(_ text: String) -> String {
var result = text
for root in [scratch, model?.project?.directory].compactMap({ $0 }) {
for root in [scratch, model?.project?.directory, selectedExportDirectory].compactMap({ $0 }) {
result = result.replacingOccurrences(of: root.path, with: "<project>")
}
return String(result.prefix(2000))
@@ -588,6 +623,8 @@ final class MCPCMOC: ObservableObject {
presentationIsCurrent: (@MainActor () -> Bool)? = nil) async throws {
let id = model.assistantProjectID, ticket = UUID(), secret = UUID().uuidString + UUID().uuidString
let approvedPlaytests = allowPlaytests
let approvedExport = allowBuildExport, approvedExportDirectory = selectedExportDirectory
if approvedExport && approvedExportDirectory == nil { throw problem("Choose a delivery folder before sharing build export access.") }
let cleanup = revoke()
session = ticket
pendingModel = model
@@ -597,6 +634,7 @@ final class MCPCMOC: ObservableObject {
guard let project = model.project else { throw problem("project_unavailable") }
let scope = try MCPCMOCProject(project: project, files: model.files.map(\.relativePath), customMake: allowProjectMakefile)
let captured = try await capture(model, scope: scope, updatedScope: true, expandedSupport: true)
let exporter = try await Task.detached { try approvedExport ? MCPBuildExporter(destination: approvedExportDirectory!) : nil }.value
guard session == ticket, model.assistantProjectID == id, presentationIsCurrent?() != false else { throw problem("stale_revision") }
let dir = FileManager.default.temporaryDirectory.appendingPathComponent("vcc-c-project-" + UUID().uuidString)
let handler: MCPTransport.Handler = { [weak self] data in
@@ -607,7 +645,7 @@ final class MCPCMOC: ObservableObject {
try FileManager.default.createDirectory(at: dir, withIntermediateDirectories: false, attributes: [.posixPermissions: 0o700])
do {
let server = try MCPTransport(handler: handler)
let bytes = try JSONSerialization.data(withJSONObject: ["token": secret, "kind": "cmoc", "toolset": 12, "playtestVideo": approvedPlaytests, "playtestMedia": approvedPlaytests, "playtestCallContext": approvedPlaytests, "projectRefresh": true, "projectDiagnostics": true, "playtestAudio": approvedPlaytests, "playtestProcessors": approvedPlaytests, "playtestJoysticks": approvedPlaytests, "customMake": scope.customMake, "playtest": approvedPlaytests, "canPropose": true,
let bytes = try JSONSerialization.data(withJSONObject: ["token": secret, "kind": "cmoc", "toolset": 13, "buildExport": approvedExport, "playtestMultiDrive": approvedPlaytests, "playtestVideo": approvedPlaytests, "playtestMedia": approvedPlaytests, "playtestCallContext": approvedPlaytests, "projectRefresh": true, "projectDiagnostics": true, "playtestAudio": approvedPlaytests, "playtestProcessors": approvedPlaytests, "playtestJoysticks": approvedPlaytests, "customMake": scope.customMake, "playtest": approvedPlaytests, "canPropose": true,
"socket": server.unixPath, "port": Int(server.port), "version": 1])
return (server, try MCPGrantFile(create: destination, data: bytes))
} catch { try? FileManager.default.removeItem(at: dir); throw error }
@@ -616,12 +654,14 @@ final class MCPCMOC: ObservableObject {
Task.detached { server.stop(); file.remove(); try? FileManager.default.removeItem(at: dir) }
throw problem("stale_revision")
}
self.buildExporter = exporter
self.server = server; self.file = file; token = secret; projectID = id; self.model = model
scratch = dir; service = CMOCBuildService(toolchain: model.service.toolchain, buildRoot: dir.appendingPathComponent("Builds"))
snapshot = captured.live; diskSnapshot = captured.disk; workspaceEpoch = captured.epoch; makeSnapshot = captured.make; approvedInputs = captured.manifest; revision = 0
self.playtestsApproved = approvedPlaytests
self.callContextApproved = approvedPlaytests
self.playtestMediaApproved = approvedPlaytests
self.playtestMultiDriveApproved = approvedPlaytests
self.scope = captured.scope; templateDirectives = captured.directives; approvedRecipeID = captured.make?.recipeID
active = true; status = "Connected to " + (model.project?.directory.lastPathComponent ?? "Hello Disk")
}
@@ -629,8 +669,11 @@ final class MCPCMOC: ObservableObject {
@discardableResult func revoke() -> Task<Void, Never> {
let playtestCleanup = playtest?.invalidate()
let old = server, grant = file, dir = scratch, work = buildTask, guest = runTask
buildExporter?.invalidate(); buildExporter = nil
let exportTask = exportWork; exportTask?.cancel(); exportWork = nil
exportRecords.removeAll(); exportRequests.removeAll(); exportSources.removeAll(); exporting = false; exportReservedBytes = 0
session = UUID(); token = ""; projectID = nil; active = false; model = nil; pendingModel = nil
callContextApproved = false; playtestMediaApproved = false
callContextApproved = false; playtestMediaApproved = false; playtestMultiDriveApproved = false
#if DEBUG
regressionPlaytestHelper = nil; regressionStarterKit = nil
#endif
@@ -649,7 +692,7 @@ final class MCPCMOC: ObservableObject {
await startupCleanup?.value
await playtestCleanup?.value
old?.stop(); grant?.remove()
await work?.value; await guest?.value
await work?.value; await guest?.value; await exportTask?.value
if let dir { try? FileManager.default.removeItem(at: dir) }
}
}
@@ -698,7 +741,7 @@ final class MCPCMOC: ObservableObject {
if let latestRefreshID, let record = refreshRecords[latestRefreshID] { fields["refresh"] = projectRefreshFields(record) }
result = fields
case "get_capabilities" where args.isEmpty:
result = ["tools": Self.tools + (callContextApproved ? ["get_call_context"] : []) + (playtestMediaApproved ? ["list_playtest_media", "exchange_playtest_media"] : []) + (playtestsApproved ? ["list_playtest_disks", "start_playtest", "playtest_input", "get_playtest_input", "playtest_debug", "capture_playtest", "capture_playtest_graphics", "capture_playtest_audio", "start_playtest_video", "stop_playtest_video", "read_playtest_video", "restart_playtest", "stop_playtest"] : []), "playtest_media_exchange": playtestMediaApproved, "playtest_media_drive": "FD0", "playtest_media_maximum_disks": 9, "playtest_media_maximum_disk_bytes": 512 * 1024, "call_context": callContextApproved, "call_context_maximum_stack_bytes": 64, "input_diagnostics": true, "playtest_joystick_input": playtestsApproved, "playtest_joystick_interfaces": playtestsApproved ? ["standard"] : [], "playtest_joystick_axis_min": 0, "playtest_joystick_axis_max": 16383, "playtest_joystick_axis_center": 8191, "owned_playtests": playtestsApproved, "async_playtest_start": playtestsApproved, "retained_playtest_disks": playtestsApproved, "period_key": playtestsApproved, "graphics_buffer_capture": playtestsApproved, "custom_gime_canvases": playtestsApproved, "source_only_debugging": playtestsApproved, "verified_flat_debugging": playtestsApproved, "video_capture": playtestsApproved, "video_capture_maximum_fields": 3600, "video_capture_maximum_clips": 4, "video_capture_maximum_bytes": 64 * 1024 * 1024, "video_capture_retained_maximum_bytes": 256 * 1024 * 1024, "video_capture_chunk_maximum_bytes": 65536, "video_capture_guest_only": true, "video_capture_optional_audio": true, "video_capture_ui_cues": false, "audio_capture": playtestsApproved, "audio_capture_maximum_fields": 120, "audio_capture_maximum_clips": 16, "audio_capture_maximum_bytes": 4 * 1024 * 1024, "build_diagnostics": true, "project_refresh": true, "input_status": refreshProblem ?? "approved", "changed_input_paths": Array(observedInputChanges.prefix(128)).map(\.path), "changed_input_paths_total": observedInputChanges.count, "changed_input_paths_truncated": observedInputChanges.count > 128, "kind": "cmoc", "app": "VCC Plus OSS",
result = ["tools": Self.tools + (buildExporter != nil ? ["export_build_outputs", "get_build_export"] : []) + (callContextApproved ? ["get_call_context"] : []) + (playtestMediaApproved ? ["list_playtest_media", "exchange_playtest_media"] : []) + (playtestsApproved ? ["list_playtest_disks", "start_playtest", "playtest_input", "get_playtest_input", "playtest_debug", "capture_playtest", "capture_playtest_graphics", "capture_playtest_audio", "start_playtest_video", "stop_playtest_video", "read_playtest_video", "restart_playtest", "stop_playtest"] : []), "build_output_export": buildExporter != nil, "export_destinations": buildExporter.map { [["destination_id": $0.destinationID, "kind": "approved_folder"]] } ?? [], "export_maximum_files": MCPBuildExporter.maximumFiles, "export_maximum_file_bytes": CMOCProject.maximumFileBytes, "export_maximum_set_bytes": MCPBuildExporter.maximumSetBytes, "export_maximum_session_bytes": MCPBuildExporter.maximumSessionBytes, "export_maximum_requests": MCPBuildExporter.maximumRequests, "playtest_media_exchange": playtestMediaApproved, "playtest_media_drive": "FD0", "playtest_media_drives": playtestMultiDriveApproved ? [0, 1, 2, 3] : [0], "playtest_media_version": playtestMultiDriveApproved ? 2 : 1, "playtest_media_write_protection": playtestMultiDriveApproved, "playtest_media_maximum_disks": 9, "playtest_media_maximum_disk_bytes": 512 * 1024, "call_context": callContextApproved, "call_context_maximum_stack_bytes": 64, "input_diagnostics": true, "playtest_joystick_input": playtestsApproved, "playtest_joystick_interfaces": playtestsApproved ? ["standard"] : [], "playtest_joystick_axis_min": 0, "playtest_joystick_axis_max": 16383, "playtest_joystick_axis_center": 8191, "owned_playtests": playtestsApproved, "async_playtest_start": playtestsApproved, "retained_playtest_disks": playtestsApproved, "period_key": playtestsApproved, "graphics_buffer_capture": playtestsApproved, "custom_gime_canvases": playtestsApproved, "source_only_debugging": playtestsApproved, "verified_flat_debugging": playtestsApproved, "video_capture": playtestsApproved, "video_capture_maximum_fields": 3600, "video_capture_maximum_clips": 4, "video_capture_maximum_bytes": 64 * 1024 * 1024, "video_capture_retained_maximum_bytes": 256 * 1024 * 1024, "video_capture_chunk_maximum_bytes": 65536, "video_capture_guest_only": true, "video_capture_optional_audio": true, "video_capture_ui_cues": false, "audio_capture": playtestsApproved, "audio_capture_maximum_fields": 120, "audio_capture_maximum_clips": 16, "audio_capture_maximum_bytes": 4 * 1024 * 1024, "build_diagnostics": true, "project_refresh": true, "input_status": refreshProblem ?? "approved", "changed_input_paths": Array(observedInputChanges.prefix(128)).map(\.path), "changed_input_paths_total": observedInputChanges.count, "changed_input_paths_truncated": observedInputChanges.count > 128, "kind": "cmoc", "app": "VCC Plus OSS",
"mutation_request_limit": MCPPlaytest.mutationRequestLimit, "stop_retention_exempt": true,
"playtest_processors": playtestsApproved ? ["MC6809", "HD6309"] : [],
"playtest_default_processor": "MC6809", "playtest_processor_selection": playtestsApproved,
@@ -722,6 +765,12 @@ final class MCPCMOC: ObservableObject {
facts["run_requirement"] = playtestsApproved ? "Owned playtests may cold-boot a copy of the current artifact disk or a selected retained test disk in an isolated 512 KB MC6809 or HD6309 worker. MC6809 is the default; the guest controls HD6309 execution mode. Debug evidence stays bound to the current artifact and is checked against runtime bytes." : "Start in VCC Plus; source debugging requires a verified map matching the delivered binary."
return pack(["result": facts])
}
case "export_build_outputs":
result = try await exportBuildOutputs(args, projectID: id, owner: owner)
case "get_build_export":
guard args.count == 2, args["project_id"] as? String == id, buildExporter != nil,
let exportID = args["export_id"] as? String, let record = exportRecords[exportID] else { throw problem("unknown_export") }
result = record.fields
case "get_machine_status" where args.isEmpty:
let observed = await model.machine.mcpReadinessSnapshot()
let tools = CMOCBuildService.requiredExecutables + ["mcpp"] +
@@ -1098,6 +1147,7 @@ final class MCPCMOC: ObservableObject {
var origin = "verified_artifact"
var originArtifactID: String? = artifact.id.uuidString
var originArtifactDiskSHA256: String? = expectedDisk
var selectedWriteProtected: Bool?
if let retainedID, let retainedSHA {
start.updatePhase("reading_retained_disk")
let saved = try await MCPPlaytestDiskStore.load(directory: storage.directory, id: retainedID,
@@ -1105,12 +1155,13 @@ final class MCPCMOC: ObservableObject {
selectedDisk = saved.data; origin = saved.record.provenance.origin
originArtifactID = saved.record.provenance.originArtifactID
originArtifactDiskSHA256 = saved.record.provenance.originArtifactDiskSHA256
selectedWriteProtected = saved.record.provenance.writeProtected
}
guard current() else { throw problem("stale_run") }
let provenance = MCPPlaytestDiskStore.Provenance(projectKey: storage.key, artifactID: artifact.id.uuidString,
artifactDiskSHA256: expectedDisk, parentDiskID: retainedID, origin: origin,
originArtifactID: originArtifactID, originArtifactDiskSHA256: originArtifactDiskSHA256,
mediaKey: playtestMediaApproved ? "primary" : nil, mediaBaseSHA256: playtestMediaApproved ? expectedDisk : nil)
mediaKey: playtestMediaApproved ? "primary" : nil, mediaBaseSHA256: playtestMediaApproved ? expectedDisk : nil, writeProtected: selectedWriteProtected)
var media: [MCPPlaytestMedium]?
if playtestMediaApproved {
var selected = try await artifactMedia(artifact, projectKey: storage.key, primaryData: payload.2)
@@ -1128,7 +1179,7 @@ final class MCPCMOC: ObservableObject {
let origin = MCPPlaytestDiskStore.Provenance(projectKey: storage.key, artifactID: artifact.id.uuidString,
artifactDiskSHA256: expectedDisk, parentDiskID: diskID, origin: prior.origin,
originArtifactID: prior.originArtifactID, originArtifactDiskSHA256: prior.originArtifactDiskSHA256,
mediaKey: item.key, mediaBaseSHA256: item.baseSHA256)
mediaKey: item.key, mediaBaseSHA256: item.baseSHA256, writeProtected: prior.writeProtected)
selected[index] = MCPPlaytestMedium(id: item.id, name: item.name, key: item.key,
baseSHA256: item.baseSHA256, data: copy.data, provenance: origin)
}
@@ -1151,7 +1202,7 @@ final class MCPCMOC: ObservableObject {
bootCommands: scope.configuration.launchCommands.joined(separator: "\n") + "\n",
projectID: projectID!.uuidString, revision: revision, artifactID: artifact.id.uuidString, modules: modules, stopAt: stop, stopModule: stopModule, flatGuards: flatGuards, cpu: processor.workerCPU, helperURL: helperURL,
retentionDirectory: storage.directory, diskProvenance: provenance, resumedDiskID: retainedID,
graphicsBuffers: graphicsBuffers, runID: start.runID, media: media)
graphicsBuffers: graphicsBuffers, runID: start.runID, media: media, multiDrive: playtestMultiDriveApproved)
guard current() else { await owned.invalidate().value; throw problem("stale_run") }
playtest = owned
start.updatePhase("capturing_initial_state")
@@ -1387,6 +1438,63 @@ final class MCPCMOC: ObservableObject {
return Int(exactly: n)
}
private func exportBuildOutputs(_ arguments: [String: Any], projectID: String, owner: UUID) async throws -> [String: Any] {
guard arguments.count == 7, Set(arguments.keys) == ["project_id", "build_id", "artifact_id", "revision", "destination_id", "output_ids", "request_id"],
arguments["project_id"] as? String == projectID, let exporter = buildExporter,
arguments["destination_id"] as? String == exporter.destinationID,
let buildID = arguments["build_id"] as? String, builds[buildID]?["status"] as? String == "succeeded", let source = exportSources[buildID],
arguments["artifact_id"] as? String == source.source.artifactID.uuidString,
int(arguments["revision"]) == source.revision,
let outputs = arguments["output_ids"] as? [String], !outputs.isEmpty,
outputs.count <= MCPBuildExporter.maximumFiles, Set(outputs).count == outputs.count,
outputs.allSatisfy({ $0.utf8.count == 64 && $0.utf8.allSatisfy { (48...57).contains($0) || (97...102).contains($0) } }),
let request = arguments["request_id"] as? String, (1...128).contains(request.utf8.count) else { throw problem("invalid_export_selection") }
let catalog = Dictionary(uniqueKeysWithValues: source.source.products.map { ($0.identifier(artifactID: source.source.artifactID), $0) })
let selected = try outputs.sorted().map { id -> CMOCBuildOutputProduct in
guard let product = catalog[id] else { throw problem("undeclared_export_output") }; return product
}
let identityData = try JSONSerialization.data(withJSONObject: ["build_id": buildID, "artifact_id": source.source.artifactID.uuidString,
"revision": source.revision, "destination_id": exporter.destinationID, "outputs": outputs.sorted()], options: [.sortedKeys])
let identity = CMOCProject.sha256(identityData)
if let exportID = exportRequests[request], let record = exportRecords[exportID] {
guard record.identity == identity else { throw problem("request_id_conflict") }
if let delivery = record.delivery {
guard !exporting else { throw problem("export_busy_or_limit") }
exporting = true
defer { if session == owner { exporting = false } }
let work = Task.detached { try exporter.verify(delivery) }
try await withTaskCancellationHandler(operation: { try await work.value }, onCancel: { work.cancel() })
guard session == owner, active, buildExporter === exporter else { throw problem("access_denied") }
}
return record.fields
}
let count = selected.reduce(0) { $0 + $1.byteCount }
guard !exporting, exportRecords.count < MCPBuildExporter.maximumRequests,
count <= MCPBuildExporter.maximumSetBytes,
exportReservedBytes <= MCPBuildExporter.maximumSessionBytes - count else { throw problem("export_busy_or_limit") }
let exportID = UUID().uuidString
let name = "VCC-" + source.source.artifactID.uuidString + "-" + String(CMOCProject.sha256(Data(request.utf8)).prefix(16))
let record = ExportRecord(identity: identity, base: ["project_id": projectID, "build_id": buildID,
"artifact_id": source.source.artifactID.uuidString, "revision": source.revision, "configuration": source.configuration,
"destination_id": exporter.destinationID, "request_id": request, "export_id": exportID, "poll_tool": "get_build_export"])
exportRequests[request] = exportID; exportRecords[exportID] = record
exportReservedBytes += count; exporting = true
exportWork = Task {
let work = Task.detached { try exporter.export(source: source.source, products: selected, setName: name) }
do {
let delivery = try await withTaskCancellationHandler(operation: { try await work.value }, onCancel: { work.cancel() })
guard active, session == owner, buildExporter === exporter else { return }
exportRecords[exportID]?.delivery = delivery; exportRecords[exportID]?.status = "completed"
} catch {
guard active, session == owner, buildExporter === exporter else { return }
exportRecords[exportID]?.status = error is CancellationError ? "cancelled" : "failed"
exportRecords[exportID]?.reason = sanitized(error.localizedDescription)
}
if session == owner { exporting = false; exportWork = nil }
}
return record.fields
}
private func buildRecord(_ id: String) -> [String: Any]? {
guard var record = builds[id] else { return nil }
if record["revision"] as? Int != revision || refreshProblem != nil { record["status"] = "stale" }
@@ -1445,6 +1553,12 @@ final class MCPCMOC: ObservableObject {
}.value
guard session == owner, revision == expected, refreshProblem == nil, readyArtifact?.value.id == artifact.id else { throw problem("stale_revision") }
result["source_debugging"] = evidence
result["exportable_outputs"] = artifact.exportProducts.map { $0.fields(artifactID: artifact.id) }
if buildExporter != nil {
let source = try await Task.detached { try MCPBuildExporter.Source(artifact) }.value
guard session == owner, active else { throw problem("access_denied") }
exportSources[id] = (expected, artifact.configurationName, source)
}
result["playtest_disk_products"] = artifact.playtestDiskProducts.map {
["media_id": MCPPlaytestMedium.identifier(artifactID: artifact.id.uuidString, key: "disk:" + $0.relativePath),
"path": $0.relativePath, "bytes": $0.byteCount, "sha256": $0.sha256] as [String: Any]
@@ -1712,11 +1826,31 @@ final class MCPCMOC: ObservableObject {
view: MCPCMOCConsent(host: self, model: model))
consentPanel = w; consentModel = model; w.makeKeyAndOrderFront(nil)
}
fileprivate func chooseExportDirectory(_ model: CMOCDevelopmentModel) {
guard let owner = consentPanel, consentModel === model, !active, owner.isVisible, owner.attachedSheet == nil else { return }
let project = model.assistantProjectID, generation = session
let picker = NSOpenPanel(); picker.canChooseDirectories = true; picker.canChooseFiles = false
picker.allowsMultipleSelection = false; picker.canCreateDirectories = true
picker.title = "Choose Build Delivery Folder"; picker.prompt = "Approve Folder"
picker.message = "Allow this connection to create new build-delivery sets here. Existing files are never replaced."
picker.beginSheetModal(for: owner) { [weak self, weak owner, weak model] response in
Task { @MainActor in
guard let self, let owner, let model, self.consentPanel === owner, self.consentModel === model,
owner.isVisible, !self.active, self.session == generation, model.assistantProjectID == project,
response == .OK, let url = picker.url else { return }
do {
_ = try await Task.detached { try MCPBuildExporter(destination: url) }.value
guard self.session == generation, !self.active, self.consentModel === model else { return }
self.selectedExportDirectory = url; self.exportFolderName = url.lastPathComponent
} catch { self.status = "Could not approve that delivery folder. " + error.localizedDescription }
}
}
}
fileprivate func exportGrant(_ model: CMOCDevelopmentModel) {
guard let owner = consentPanel, consentModel === model, owner.isVisible,
!owner.isMiniaturized, owner.attachedSheet == nil else { return }
let project = model.assistantProjectID, generation = session
let approvedMake = allowProjectMakefile, approvedPlaytests = allowPlaytests
let approvedMake = allowProjectMakefile, approvedPlaytests = allowPlaytests, approvedExport = allowBuildExport, approvedFolder = selectedExportDirectory
let picker = NSSavePanel(); picker.title = "Share C Project for Reviewed Changes"
picker.message = "Choose a new private connection file for the local assistant."
picker.nameFieldStringValue = "VCC Plus OSS C Connection.json"
@@ -1726,7 +1860,8 @@ final class MCPCMOC: ObservableObject {
@MainActor func currentPresentation() -> Bool {
self.consentPanel === owner && self.consentModel === model && owner.isVisible &&
!owner.isMiniaturized && model.assistantProjectID == project &&
self.allowProjectMakefile == approvedMake && self.allowPlaytests == approvedPlaytests
self.allowProjectMakefile == approvedMake && self.allowPlaytests == approvedPlaytests &&
self.allowBuildExport == approvedExport && self.selectedExportDirectory == approvedFolder
}
guard currentPresentation(), self.session == generation else { return }
defer { if currentPresentation() { owner.makeKeyAndOrderFront(nil) } }
@@ -1872,11 +2007,22 @@ private struct MCPCMOCConsent: View {
if !host.active {
Toggle("Allow Disposable Playtests", isOn: $host.allowPlaytests)
if host.allowPlaytests {
Text("Allow the assistant to launch this project's built disk or resume a retained test disk in a separate 512 KB 6809 or 6309 CoCo, hold key combinations and standard joystick axes and buttons, read input diagnostics, capture its screen, declared graphics buffers and guest audio, record bounded MP4 gameplay clips with optional CoCo audio, inspect verified program stops and shared data, read up to 64 bytes at the paused test guest’s stack pointer with caller and argument interpretations only when verified, and restart its own writable test disks. Reviewed additional disk products can be inserted or ejected in the paused, idle test drive without a reset or advancing time; each private writable copy is retained. The guest controls 6309 execution mode. Audio capture advances the test guest. Mac windows, microphone and capture feedback cues are excluded. Retained originals and your current CoCo and media are preserved. Access ends when this connection or build changes.").font(.callout)
Text("Allow the assistant to launch this project's built disk or resume a retained test disk in a separate 512 KB 6809 or 6309 CoCo, hold key combinations and standard joystick axes and buttons, read input diagnostics, capture its screen, declared graphics buffers and guest audio, record bounded MP4 gameplay clips with optional CoCo audio, inspect verified program stops and shared data, read up to 64 bytes at the paused test guest’s stack pointer with caller and argument interpretations only when verified, and restart its own writable test disks. Reviewed additional disk products can be inserted or ejected in any of four paused test drives while the shared controller is idle without a reset or advancing time; each private writable copy is retained. The guest controls 6309 execution mode. Audio capture advances the test guest. Mac windows, microphone and capture feedback cues are excluded. Retained originals and your current CoCo and media are preserved. Access ends when this connection or build changes.").font(.callout)
}
if host.allowPlaytests, let media = model.project?.configuration.playtestDisks, !media.isEmpty {
Text("Additional playtest disks: " + media.joined(separator: ", ")).font(.callout).textSelection(.enabled)
}
Toggle("Allow Build Output Export", isOn: $host.allowBuildExport)
if host.allowBuildExport {
Text("Allow delivery of this connection's declared build products to one folder you approve. Each delivery creates a new set with verified original hashes; existing files are never replaced. Older successful builds remain selectable until access is revoked.").font(.callout)
HStack {
Button("Choose Delivery Folder…") { host.chooseExportDirectory(model) }
Text(host.exportFolderName ?? "No delivery folder selected").font(.callout)
}
if let paths = model.project?.configuration.exportOutputs, !paths.isEmpty {
Text("Additional delivery outputs: " + paths.joined(separator: ", ")).font(.callout).textSelection(.enabled)
}
}
Toggle("Use Project Makefile", isOn: $host.allowProjectMakefile)
if host.allowProjectMakefile {
Text("Allow builds using this project's existing Makefile and declared configurations. Make recipes and compiler inputs can execute local commands, just as Build does. Recipe or support-file changes require native review through project refresh.").font(.callout)
@@ -1892,7 +2038,8 @@ private struct MCPCMOCConsent: View {
}
Text("The assistant's model provider may receive the shared files and diagnostics.").font(.callout)
if host.active {
if host.playtestsApproved { Text("Disposable playtests and bounded read-only call context are enabled for this connection. Each test uses a separate CoCo and its own disk copies. Paused-drive media exchange is available for this connection's reviewed disk products.").font(.callout) }
if host.buildExporter != nil { Text("Build output export is enabled for the approved delivery folder. Revoke access to end this permission.").font(.callout) }
if host.playtestsApproved { Text("Disposable playtests and bounded read-only call context are enabled for this connection. Each test uses a separate CoCo and its own disk copies. Drive-targeted FD0–FD3 media exchange and insert-time write protection are available for this connection's reviewed disk products.").font(.callout) }
if let url = host.grantURL {
MCPChatGPTSetup(grantURL: url, firstPrompt: "Identify my shared VCC Plus C project and read its entry source. Describe its target and what the CoCo program does.")
}
@@ -1903,7 +2050,7 @@ private struct MCPCMOCConsent: View {
Button("Run C Build…") { Task { await host.run(selectedRun) } }.disabled(selectedRun == nil || host.running || host.building)
}
}
} else { Button("Save Private Connection…") { host.exportGrant(model) } }
} else { Button("Save Private Connection…") { host.exportGrant(model) }.disabled(host.allowBuildExport && host.exportFolderName == nil) }
if !host.runStatus.isEmpty { Text(host.runStatus).font(.callout).textSelection(.enabled) }
Text(host.status).font(.callout).textSelection(.enabled)
}.padding(18).frame(maxWidth: .infinity, alignment: .leading)