Repository Public
1// =============================================================================2// SP BOUCHER | SOFTWARE & RESEARCH3// ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING4// =============================================================================5//6// PROJECT METADATA7// -----------------------------------------------------------------------------8// Project : Claude Remote / Codex Remote9// File : Packages/ClaudeRemoteKit/Tests/ModelsTests/DecodingTests.swift10// Module : ModelsTests11// Repository : https://git.spboucher.ai/claude-remote-apple12// Project Website : https://claude.spboucher.ai13// Created : 2026-11-2914// Last Modified : 2026-11-2915//16// =============================================================================17// AUTHOR & PROFESSIONAL AFFILIATION18// =============================================================================19//20// Author : Simon-Pierre Boucher21// Position : Professor of Finance22// Institution : Université du Québec en Outaouais (UQO)23// Department : Département des sciences administratives24// Organization : SP Boucher25//26// Website : https://spboucher.ai27// Git : https://git.spboucher.ai28//29// =============================================================================30// OFFICIAL CONTACT DIRECTORY31// =============================================================================32//33// General : info@spboucher.ai34// Professional : contact@spboucher.ai35// Direct : simon@spboucher.ai36// Research : research@spboucher.ai37// Development : dev@spboucher.ai38// Support : support@spboucher.ai39// Security/Admin : admin@spboucher.ai40// Notifications : notifications@spboucher.ai41//42// Preferred Contact: support@spboucher.ai43//44// =============================================================================45// COPYRIGHT & INTELLECTUAL PROPERTY46// =============================================================================47//48// Copyright (c) 202649// Simon-Pierre Boucher50//51// All rights reserved where applicable.52//53// This file is governed by the applicable project license,54// copyright notices, institutional agreements and relevant law.55//56// Unless expressly authorized by the applicable license or57// rights holder, copying, redistribution, sublicensing,58// publication and commercial exploitation are not permitted.59//60// Existing third-party rights and notices remain unaffected.61//62// =============================================================================63// CONFIDENTIALITY & SECURITY64// =============================================================================65//66// Classification : Public67// Distribution : Public repository; use is governed by the project license68// Security Contact : admin@spboucher.ai69//70// Access to this source does not independently grant permission71// to redistribute or disclose confidential materials.72//73// Do not embed credentials, private keys, access tokens,74// certificates or confidential personal information.75//76// =============================================================================77// LICENSE & MAINTENANCE78// =============================================================================79//80// License : None specified (no license file in this repository)81// Maintainer : Simon-Pierre Boucher82// Technical Contact: dev@spboucher.ai83//84// =============================================================================85// END OF SP BOUCHER SOURCE HEADER86// =============================================================================8788import ClaudeRemoteModels89import ClaudeRemoteTestSupport90import Foundation91import Testing9293@Suite("DTO decoding from realistic server JSON")94struct DecodingTests {95 func decode<T: Decodable>(_ json: String, as type: T.Type = T.self) throws -> T { try CRJSON.decode(T.self, from: json) }9697 @Test func authStatus() throws {98 let anon: AuthStatus = try decode(Fixtures.authStatusAnonymous)99 #expect(!anon.authenticated && anon.user == nil && anon.branding?.agent == .claude && anon.sessionExpiresAt == nil)100 let me: AuthStatus = try decode(Fixtures.authStatusSignedIn)101 #expect(me.authenticated && me.user?.username == "admin" && me.methods.passkeys == 2 && me.methods.totp)102 #expect(me.branding == Branding(agent: .codex, productName: "Codex Remote", agentName: "Codex"))103 #expect(me.sessionExpiresAt == CRJSON.parseDate("2026-12-20T02:25:00.000Z"))104 // Older servers omit branding.105 let old: AuthStatus = try decode(#"{"setupRequired":true,"authenticated":false,"user":null,"methods":{"password":true,"passkeys":0,"totp":false},"csrfToken":null,"sessionExpiresAt":null}"#)106 #expect(old.setupRequired && old.branding == nil)107 }108109 @Test func nativeSessionAndLogin() throws {110 let done: NativeLoginResponse = try decode(Fixtures.loginResponse())111 #expect(done.next == .done && done.session.secondFactor && done.session.token == Fixtures.token && done.methods == SecondFactorMethods(totp: true, passkeys: 1))112 #expect(done.session.tokenExpiresAt < done.session.expiresAt)113 for (raw, expected) in [("totp", LoginNext.totp), ("passkey", .passkey), ("enroll_second_factor", .enrollSecondFactor), ("webauthn2", .unknown("webauthn2"))] {114 let r: NativeLoginResponse = try decode(Fixtures.loginResponse(next: raw))115 #expect(r.next == expected && !r.session.secondFactor)116 }117 // `totp` / `passkey/verify` answers carry no `methods`.118 let step: NativeLoginResponse = try decode(#"{"next":"done","session":\#(Fixtures.nativeSession())}"#)119 #expect(step.methods == nil)120 let challenge: NativeRefreshChallenge = try decode(#"{"challenge":"q83vEjRWeJCrze8SNFZ4kA","expiresAt":"2026-11-20T02:26:00.000Z"}"#)121 #expect(challenge.challenge == "q83vEjRWeJCrze8SNFZ4kA")122 let step2: LoginStep = try decode(#"{"ok":true,"next":"done"}"#)123 #expect(step2.ok && step2.retryAfterSec == nil)124 }125126 @Test func devicesIncludingNativeAndUnknownKinds() throws {127 let devices: [Device] = try decode(Fixtures.devices)128 #expect(devices.map(\.kind) == [.passkey, .session, .native, .unknown("watch")])129 #expect(devices[2].platform == .ios && devices[2].pushEnabled == true && devices[2].current && devices[2].appVersion == "1.0.0")130 #expect(devices[0].platform == nil && devices[1].userAgent != nil && devices[3].lastUsedAt == nil)131 }132133 @Test func passkeyOptions() throws {134 let second: NativePasskeyOptionsResponse = try decode(Fixtures.passkeyRequestOptions)135 #expect(second.challengeToken == nil && second.options.allowCredentials?.count == 1 && second.options.rpId == "claude.spboucher.ai")136 #expect(Base64URL.decode(second.options.challenge) == Data("test-challenge-0123456789abcdef".utf8))137 let discoverable: NativePasskeyOptionsResponse = try decode(Fixtures.passkeyDiscoverableOptions)138 #expect(discoverable.challengeToken?.hasPrefix("pct_") == true && discoverable.options.allowCredentials?.isEmpty == true)139 let creation: PasskeyCreationOptions = try decode(Fixtures.passkeyCreationOptions)140 #expect(creation.rp.id == "claude.spboucher.ai" && creation.user.name == "admin" && creation.excludeCredentials?.count == 1)141 }142143 @Test func projects() throws {144 let p: Project = try decode(Fixtures.project)145 #expect(p.displayPath == "workspace/claude-remote" && p.gitDirty == true && p.tags == ["swift", "ts"] && p.activeSessions == 2)146 #expect(p.settings["defaultKind"] == "claude" && p.settings["nested"]?["a"]?.arrayValue?.count == 4)147 let minimal: Project = try decode(Fixtures.projectMinimal)148 #expect(minimal.displayPath == "workspace" && minimal.gitDirty == nil && minimal.lastActivityAt == nil)149 #expect(minimal.createdAt == CRJSON.parseDate("2026-11-12T09:00:00.000Z")) // no fractional seconds150 let roots: [WorkspaceRoot] = try decode(#"[{"label":"workspace"},{"label":"scratch"}]"#)151 #expect(roots.map(\.id) == ["workspace", "scratch"])152 }153154 @Test func sessionsInEveryState() throws {155 for (raw, state) in SessionState.known.map({ ($0.1, $0.0) }) {156 let s: TerminalSession = try decode(Fixtures.session(state: raw))157 #expect(s.state == state && s.kind == .agent && s.projectName == "claude-remote" && s.pid == 48213)158 }159 let waiting: TerminalSession = try decode(Fixtures.session(state: "WAITING_FOR_INPUT"))160 #expect(waiting.waitingReason == "Claude needs your permission" && waiting.conversationId != nil)161 let future: TerminalSession = try decode(Fixtures.session(state: "HIBERNATING", kind: "notebook"))162 #expect(future.state == .unknown("HIBERNATING") && future.kind == .unknown("notebook") && !future.state.isLive)163 let stopped: TerminalSession = try decode(Fixtures.sessionStopped)164 #expect(stopped.kind == .shell && stopped.exitCode == 130 && stopped.archived && stopped.projectId == nil && stopped.endedAt != nil)165 let conversations: [AgentConversation] = try decode(Fixtures.conversations)166 #expect(conversations.first?.messageCount == 42)167 let snap: SessionSnapshot = try decode(#"{"text":"$ ls\nREADME.md\n"}"#)168 #expect(snap.text.contains("README"))169 }170171 @Test func files() throws {172 let entries: [FileEntry] = try decode(Fixtures.fileEntries)173 #expect(entries.map(\.type) == [.dir, .file, .file, .symlink, .unknown("fifo")])174 #expect(entries[0].isDirectory && entries[1].binary == false && entries[2].size == 4_294_967_296 && entries[0].binary == nil)175 #expect(abs(entries[1].modifiedAt.timeIntervalSince1970 - 1_795_000_123.456) < 0.01)176 let content: FileContent = try decode(Fixtures.fileContent)177 #expect(content.content == "# Hello\n\nworld\n" && content.sha256.count == 64 && content.encoding == "utf8")178 let hits: [SearchHit] = try decode(Fixtures.searchHits)179 #expect(hits[0].line == 12 && hits[1].line == nil && hits[1].preview == nil)180 let git: GitStatus = try decode(Fixtures.gitStatus)181 #expect(git.isRepo && git.branch == "main" && git.ahead == 1 && git.files[1].index == "?")182 let diff: GitDiff = try decode(#"{"diff":"--- a/x\n+++ b/x\n","truncated":false}"#)183 #expect(!diff.truncated)184 }185186 @Test func tasksInEveryState() throws {187 for (raw, state) in TaskState.known.map({ ($0.1, $0.0) }) {188 let t: AgentTask = try decode(Fixtures.task(state: raw))189 #expect(t.state == state && t.artifacts.count == 1 && t.logBytes == 18234 && t.maxRssMb == 512.25)190 }191 let failed: AgentTask = try decode(Fixtures.task(state: "FAILED"))192 #expect(failed.exitCode == 1 && failed.canRetry)193 let running: AgentTask = try decode(Fixtures.task(state: "RUNNING", idempotent: false))194 #expect(!running.canRetry && running.state.canCancel && running.timeoutSec == 3600)195 }196197 @Test func cluster() throws {198 let overview: ClusterOverview = try decode(Fixtures.clusterOverview)199 #expect(overview.source == .agentd && overview.health == .degraded && overview.nodes.count == 2 && overview.totals.cores == 401)200 #expect(overview.aggregate?.gpuPct == nil && overview.aggregate?.memPct == 40.1 && overview.incidents?.warning == 1 && overview.agentVersion == "3.1.2")201 #expect(overview.edges.map(\.kind) == [.tunnel, .lan, .unknown("quantum")])202 let host = overview.nodes[0]203 #expect(host.isHost && host.kind == .mac && host.cpuCores == 18 && host.appStats?.up == 2 && host.thermal == "nominal")204 #expect(abs((host.memPct ?? 0) - 48.83) < 0.01)205 let legacy = overview.nodes[1]206 #expect(legacy.kind == .unknown("gateway") && legacy.health == .unknownHealth && legacy.stale && legacy.gpuPct == nil && legacy.appStats == nil && legacy.memPct == nil)207 let none: ClusterOverview = try decode(Fixtures.clusterOverviewNone)208 #expect(none.source == .none && none.aggregate == nil && none.apps == nil && none.collectedAt == nil)209 let apps: ClusterApps = try decode(Fixtures.clusterApps)210 #expect(apps.apps[0].state == .up && apps.apps[1].state == .unknown("unknown") && apps.apps[0].deployedAt == "2026-11-17T12:00:00Z" && apps.summary.degraded == 1)211 let incidents: [ClusterIncident] = try decode(Fixtures.clusterIncidents)212 #expect(incidents.map(\.severity) == [.warning, .unknown("fatal")] && incidents[1].since == nil)213 let trend: ClusterTrend = try decode(Fixtures.clusterTrend)214 #expect(trend.points.count == 2 && trend.points[1].netInKbs == nil)215 let detail: ClusterNodeDetail = try decode(Fixtures.clusterNodeDetail)216 #expect(detail.node.id == "M5M36" && detail.history.count == 2 && !detail.history[1].online)217 let metrics: ClusterMetrics = try decode(Fixtures.clusterMetrics)218 #expect(metrics.series["M5M36"]?.count == 1 && metrics.series["m4mm"]?.isEmpty == true)219 let models: [LocalModel] = try decode(Fixtures.localModels)220 #expect(models[0].health == .online && models[0].tokensPerSec == 61.3 && models[1].health == .unknownHealth)221 let test: LocalModelTest = try decode(Fixtures.modelTest)222 #expect(test.ok && test.error == nil)223 }224225 @Test func skillsAndMcp() throws {226 let skills: [SkillInfo] = try decode(Fixtures.skills)227 #expect(skills.map(\.kind) == [.skill, .command, .unknown("hook")] && skills.map(\.source) == [.user, .project, .unknown("marketplace")])228 #expect(skills[0].updateAvailable == nil && skills[1].updateAvailable == false && Set(skills.map(\.id)).count == 3)229 let servers: [McpServerInfo] = try decode(Fixtures.mcpServers)230 #expect(servers.map(\.status) == [.connected, .needsAuth, .notChecked] && servers.map(\.transport) == [.stdio, .http, .sse])231 #expect(servers[0].envKeys == ["CLUSTER_TOKEN"] && servers[2].scope == .local)232 let registry: SkillRegistrySearch = try decode(#"{"connected":false,"results":[]}"#)233 #expect(!registry.connected)234 }235236 @Test func systemStatusAndAudit() throws {237 let status: SystemStatus = try decode(Fixtures.systemStatus)238 #expect(status.version == "1.4.0" && status.components[1].health == .degraded && status.host.load.count == 3 && status.counts.liveSessions == 3)239 #expect(status.agentCLI.authenticated == true && status.agentCLI.agent == nil) // absent ⇒ claude240 let codex: SystemStatus = try decode(Fixtures.systemStatusCodex)241 #expect(codex.agentCLI.agent == .codex && codex.agentCLI.version == nil && codex.host.cpuPct == nil)242 let audit: [AuditEvent] = try decode(Fixtures.audit)243 #expect(audit[0].ok && audit[1].detail["op"] == "delete" && audit[1].detail["n"]?.intValue == 3 && audit[1].target == nil)244 let health: ServerHealth = try decode(#"{"ok":true,"version":"1.4.0","agent":"codex"}"#)245 #expect(health.agent == .codex)246 }247248 @Test func notificationsOfEveryKind() throws {249 for (raw, kind) in NotificationKind.known.map({ ($0.1, $0.0) }) {250 let n: ServerNotification = try decode(Fixtures.notification(kind: raw))251 #expect(n.kind == kind && n.isUnread)252 }253 let read: ServerNotification = try decode(Fixtures.notification(kind: "billing.alert", read: true, link: nil))254 #expect(read.kind == .unknown("billing.alert") && !read.isUnread && read.link == nil)255 let result: NotificationsReadResult = try decode(#"{"ok":true,"updated":3}"#)256 #expect(result.updated == 3)257 }258259 @Test func settingsDefaultsAndRoundTrip() throws {260 let s: UserSettings = try decode(Fixtures.settings)261 #expect(s.theme == .system && s.defaultLayout == .terminalFiles && s.notifications.push && s.layout["right"]?["open"] == true && s.mobileToolbar.count == 14)262 // A server from before the native contract: no `push`, and a partially stored object.263 let old: UserSettings = try decode(#"{"theme":"dark","notifications":{"inApp":false,"webPush":true,"detail":"titles"}}"#)264 #expect(old.theme == .dark && old.notifications.push && !old.notifications.inApp && old.notifications.detail == .titles)265 #expect(old.terminalFont == "JetBrains Mono" && old.scrollback == 5000 && old.mobileToolbar == UserSettings.defaultMobileToolbar)266 // Unknown enum values survive a save.267 var future: UserSettings = try decode(#"{"theme":"sepia","defaultLayout":"terminal+browser","terminalTheme":"solarized"}"#)268 future.terminalFontSize = 99 // clamped on encode269 let saved = try JSONDecoder().decode(JSONValue.self, from: CRJSON.encode(future))270 #expect(saved["theme"] == "sepia" && saved["defaultLayout"] == "terminal+browser" && saved["terminalTheme"] == "solarized")271 #expect(saved["terminalFontSize"]?.intValue == 28 && saved["defaultProjectId"] == .null && saved["notifications"]?["push"] == true)272 #expect(try decode(String(decoding: CRJSON.encode(s), as: UTF8.self), as: UserSettings.self) == s)273 }274275 @Test func summary() throws {276 let s: NativeSummary = try decode(Fixtures.summary)277 #expect(s.agent == .claude && s.sessions.waiting == 1 && s.tasks.failed24h == 2 && s.cluster?.health == .degraded && s.notificationsUnread == 4)278 let none: NativeSummary = try decode(Fixtures.summaryNoCluster)279 #expect(none.cluster == nil && none.agent == .codex)280 let push: PushRegistrationResult = try decode(#"{"ok":true,"configured":false}"#)281 #expect(!push.configured)282 }283284 @Test func errorEnvelope() throws {285 let e: APIErrorBody = try decode(#"{"error":{"code":"invalid_request","message":"invalid request","details":[{"path":"cols","message":"Too small"}]}}"#)286 #expect(e.error.code == "invalid_request" && e.error.details?.arrayValue?.first?["path"] == "cols")287 let bare: APIErrorBody = try decode(#"{"error":{"code":"not_found","message":"not found"}}"#)288 #expect(bare.error.details == nil)289 }290291 @Test func wireMessages() throws {292 #expect(TermServerMessage(text: #"{"t":"ready","sessionId":"abc","cols":120,"rows":32}"#) == .ready(sessionId: "abc", cols: 120, rows: 32))293 #expect(TermServerMessage(text: #"{"t":"pong","n":7}"#) == .pong(n: 7))294 #expect(TermServerMessage(text: #"{"t":"exit","code":null}"#) == .exit(code: nil))295 #expect(TermServerMessage(text: #"{"t":"exit","code":137}"#) == .exit(code: 137))296 #expect(TermServerMessage(text: #"{"t":"error","code":"not_found","message":"unknown session"}"#) == .error(code: "not_found", message: "unknown session"))297 #expect(TermServerMessage(text: #"{"t":"title","value":"x"}"#) == .unknown(type: "title"))298 #expect(TermServerMessage(text: "not json") == nil)299 let resize = try JSONDecoder().decode(JSONValue.self, from: Data(TermClientMessage.resize(cols: 100, rows: 30).text.utf8))300 #expect(resize == ["t": "resize", "cols": 100, "rows": 30])301 let ping = try JSONDecoder().decode(JSONValue.self, from: Data(TermClientMessage.ping(n: 3).text.utf8))302 #expect(ping == ["t": "ping", "n": 3])303 #expect(TerminalLimits.clamp(cols: 5, rows: 1000) == (20, 200))304 #expect(WSCloseCode(rawValue: 4410) == .sessionEnded && WSCloseCode.allCases.count == 6)305 }306307 @Test func serverEvents() throws {308 #expect(ServerEvent(text: #"{"type":"hello","serverTime":"2026-11-20T02:25:00.000Z"}"#) == .hello(serverTime: CRJSON.parseDate("2026-11-20T02:25:00.000Z")!))309 guard case .sessionUpdated(let s) = ServerEvent(text: #"{"type":"session.updated","session":\#(Fixtures.session(state: "DETACHED"))}"#) else { Issue.record("session.updated"); return }310 #expect(s.state == .detached)311 #expect(ServerEvent(text: #"{"type":"session.removed","id":"abc"}"#) == .sessionRemoved(id: "abc"))312 guard case .taskUpdated(let t) = ServerEvent(text: #"{"type":"task.updated","task":\#(Fixtures.task(state: "SUCCEEDED"))}"#) else { Issue.record("task.updated"); return }313 #expect(t.state == .succeeded)314 guard case .notification(let n) = ServerEvent(text: #"{"type":"notification","notification":\#(Fixtures.notification())}"#) else { Issue.record("notification"); return }315 #expect(n.kind == .sessionWaiting)316 #expect(ServerEvent(text: #"{"type":"auth.expired"}"#) == .authExpired)317 #expect(ServerEvent(text: #"{"type":"cluster.updated","x":1}"#) == .unknown(type: "cluster.updated"))318 #expect(ServerEvent(text: #"{"type":"session.updated","session":{"id":1}}"#) == nil) // malformed payloads are dropped, not fatal319 }320321 @Test func requestBodies() throws {322 func json<T: Encodable>(_ v: T) throws -> JSONValue { try JSONDecoder().decode(JSONValue.self, from: CRJSON.encode(v)) }323 #expect(try json(CreateSession()) == ["projectId": nil, "kind": "claude", "cwd": "", "cols": 120, "rows": 32])324 #expect(try json(CreateSession(projectId: "p", kind: .shell, title: "t", resumeConversationId: nil, continueLast: true, cols: 9999, rows: 1))325 == ["projectId": "p", "kind": "shell", "title": "t", "cwd": "", "continueLast": true, "cols": 500, "rows": 5])326 #expect(try json(UpdateSession(pinned: true)) == ["pinned": true])327 #expect(try json(FsOp.delete(path: "a/b")) == ["op": "delete", "path": "a/b", "confirm": true])328 #expect(try json(FsOp.rename(from: "a", to: "b")) == ["op": "rename", "from": "a", "to": "b"])329 #expect(try json(FsOp.mkdir(path: "d")) == ["op": "mkdir", "path": "d"])330 #expect(try json(WriteFile(path: "x", content: "y", baseSha256: "abc")) == ["path": "x", "content": "y", "baseSha256": "abc"])331 #expect(try json(CreateTask(title: "t", command: "c")) == ["projectId": nil, "title": "t", "command": "c", "host": "local", "cwd": "", "timeoutSec": nil, "idempotent": false, "artifactGlobs": []])332 #expect(try json(SkillOp.disable(name: "s", kind: .command)) == ["op": "disable", "name": "s", "kind": "command", "scope": "user"])333 #expect(try json(SkillOp.install(projectId: "p", path: "skills/x")) == ["op": "install", "projectId": "p", "path": "skills/x", "replace": false])334 #expect(try json(SkillOp.installFromRegistry(name: "x")) == ["op": "install-registry", "name": "x"])335 #expect(try json(PushRegistration(deviceToken: Data([0x0a, 0xff, 0x01]), environment: .sandbox, topic: "ai.spboucher.clauderemote.dev"))336 == ["apnsToken": "0aff01", "environment": "sandbox", "topic": "ai.spboucher.clauderemote.dev"])337 let device = NativeDevice(installId: "i", name: String(repeating: "n", count: 200), platform: .ipados, model: "iPad16,3", appVersion: "1.0", publicKey: "BASE64")338 #expect(device.name.count == 80)339 #expect(try json(NativeLoginRequest(username: "u", password: "p", device: device))["totp"] == nil)340 #expect(AddMcpServer.isValidName("my_server-1") && !AddMcpServer.isValidName("-rf") && !AddMcpServer.isValidName(""))341 }342343 @Test func agentProfiles() {344 #expect(AgentProfile.claude.baseURL.absoluteString == "https://claude.spboucher.ai" && AgentProfile.codex.relyingPartyID == "codex.spboucher.ai")345 #expect(AgentProfile.claude.urlScheme == "clauderemote" && AgentProfile.codex.urlScheme == "codexremote")346 #expect(AgentProfile.claude.pushTopic(debug: true) == "ai.spboucher.clauderemote.dev" && AgentProfile.codex.bundleIdentifier == "ai.spboucher.codexremote")347 #expect(AgentProfile.claude.associatedDomains == ["webcredentials:claude.spboucher.ai", "applinks:claude.spboucher.ai"])348 #expect(AgentProfile.codex.capabilities.mcpTransports == [.stdio, .http] && !AgentProfile.codex.capabilities.promptSubmitHook)349 #expect(AgentProfile.profile(owning: URL(string: "codexremote://tasks/")!)?.id == .codex)350 #expect(AgentProfile.profile(owning: URL(string: "https://claude.spboucher.ai/terminal/?s=1")!)?.id == .claude)351 #expect(AgentProfile.profile(owning: URL(string: "https://example.com/")!) == nil)352 #expect(AgentProfile.claude.isConversationID("5f2c1c1e-0d4b-4c57-9a55-3a1f8f3f2b10") && !AgentProfile.claude.isConversationID("--dangerously-skip"))353 #expect(!AgentProfile.codex.isConversationID("my-session-name") && AgentProfile.codex.isConversationID("019A5F2C-1C1E-7D4B-8C57-3A1F8F3F2B10"))354 #expect(AgentProfile.claude.with(baseURL: URL(string: "http://localhost:8625")!).relyingPartyID == "localhost")355 #expect(HexColor(0xFFFFFF).contrast(with: HexColor(0x000000)) > 20.9 && HexColor(0x5151E8).hexString == "#5151E8")356 }357358 @Test func base64URLAndDates() {359 #expect(Base64URL.encode(Data([0xfb, 0xff, 0xfe])) == "-__-" && Base64URL.decode("-__-") == Data([0xfb, 0xff, 0xfe]))360 #expect(Base64URL.decode("YQ") == Data("a".utf8) && Base64URL.decode("!!") == nil)361 let d = CRJSON.parseDate("2026-11-20T02:25:00.123Z")!362 #expect(CRJSON.formatDate(d) == "2026-11-20T02:25:00.123Z" && CRJSON.parseDate("nope") == nil)363 }364}365