SPB Git

Repository Public License

CanonicalTools.swift 4.4 KB 68 lines swift

1// ORIX OS Automation2// File: Packages/ORIXWorkflowEngine/Tests/ORIXWorkflowEngineTests/CanonicalTools.swift3// Description: Test catalogue of the canonical tool identifiers of module-contracts.md, with permissive schemas (the real manifests live in the tool packages).4//5// Author: Simon-Pierre Boucher6// Contact: contact@spboucher.ai7import Foundation8import ORIXCore910enum CanonicalTools {11    private static let families: [(String, [String])] = [12        ("filesystem", ["list", "search", "read", "write", "mkdir", "copy", "move", "metadata", "checksum", "compare", "trash", "delete",13                        "archive", "unarchive", "waitForChange"]),14        ("shell", ["run", "script"]),15        ("git", ["status", "diff", "log", "branches", "commit", "createPatch", "push"]),16        ("http", ["request"]),17        ("documents", ["csvRead", "csvWrite", "jsonQuery", "pdfText", "pdfInfo", "renderPDF", "imageInfo", "imageConvert", "xlsxRead", "textStats"]),18        ("python", ["run", "envInfo"]),19        ("script", ["swift", "javascript"]),20        ("system", ["info", "processes", "diskUsage", "powerState", "networkState", "apps", "frontmost", "windows", "launchApp", "quitApp"]),21        ("clipboard", ["read", "write"]),22        ("notifications", ["post"]),23        ("applescript", ["run", "dictionary"]),24        ("jxa", ["run"]),25        ("accessibility", ["status", "tree", "find", "press", "setValue", "focus", "typeText", "waitFor"]),26        ("screen", ["capture", "ocr", "compare"]),27        ("browser", ["open", "read", "fill", "click", "waitFor", "screenshot", "download", "close"]),28    ]2930    static let identifiers: [String] = families.flatMap { family, actions in actions.map { "\(family).\($0)" } }3132    private static let reads: Set<String> = [33        "filesystem.list", "filesystem.search", "filesystem.read", "filesystem.metadata", "filesystem.checksum", "filesystem.compare",34        "filesystem.waitForChange", "git.status", "git.diff", "git.log", "git.branches", "documents.csvRead", "documents.jsonQuery",35        "documents.pdfText", "documents.pdfInfo", "documents.imageInfo", "documents.xlsxRead", "documents.textStats", "python.envInfo",36        "system.info", "system.processes", "system.diskUsage", "system.powerState", "system.networkState", "system.apps", "system.frontmost",37        "system.windows", "clipboard.read", "applescript.dictionary", "accessibility.status", "accessibility.tree", "accessibility.find",38        "accessibility.waitFor", "screen.ocr", "screen.compare", "browser.read", "browser.waitFor",39    ]40    private static let reversibleWrites: Set<String> = [41        "filesystem.write", "filesystem.mkdir", "filesystem.copy", "filesystem.move", "filesystem.trash", "filesystem.archive",42        "filesystem.unarchive", "documents.csvWrite", "documents.renderPDF", "documents.imageConvert", "git.commit", "git.createPatch",43        "clipboard.write", "notifications.post", "screen.capture", "browser.screenshot", "browser.close",44    ]45    private static let dryRunnable: Set<String> = [46        "filesystem.write", "filesystem.mkdir", "filesystem.copy", "filesystem.move", "filesystem.trash", "filesystem.delete",47        "filesystem.archive", "filesystem.unarchive",48    ]49    private static let external: Set<String> = ["http.request", "git.push", "browser.open", "browser.fill", "browser.click", "browser.download"]5051    static func manifests() -> [ToolManifest] {52        identifiers.map { id in53            let family = String(id.split(separator: ".")[0])54            let sideEffect: SideEffect55            let tier: ApprovalTier56            if reads.contains(id) { sideEffect = .read; tier = .readOnly }57            else if id == "filesystem.delete" { sideEffect = .destructive; tier = .highRisk }58            else if reversibleWrites.contains(id) { sideEffect = .write; tier = .reversibleWrite }59            else if external.contains(id) { sideEffect = .external; tier = .consequential }60            else { sideEffect = .write; tier = .consequential }61            return ToolManifest(identifier: id, name: id, summary: "Canonical tool \(id) (test catalogue entry).", family: family,62                                inputSchema: .object([:], additional: true), sideEffect: sideEffect, defaultTier: tier,63                                supportsDryRun: dryRunnable.contains(id),64                                idempotent: reads.contains(id) || id == "filesystem.mkdir" || id == "browser.close")65        }66    }67}68
Files main
Menu

Theme