The best way to control Claude Code, Codex and more from any computer or phone
| 1 | import * as Schema from "effect/Schema"; |
| 2 | import { TrimmedNonEmptyString } from "./baseSchemas.ts"; |
| 3 | import { BrowserProfileId } from "./browserProfile.ts"; |
| 4 | |
| 5 | const BROWSER_IMPORT_SOURCE_IDS = [ |
| 6 | "chrome", |
| 7 | "edge", |
| 8 | "brave", |
| 9 | "vivaldi", |
| 10 | "opera", |
| 11 | "arc", |
| 12 | "helium", |
| 13 | "firefox", |
| 14 | "zen", |
| 15 | "safari", |
| 16 | ] as const; |
| 17 | |
| 18 | export const BrowserImportSourceId = Schema.Literals(BROWSER_IMPORT_SOURCE_IDS); |
| 19 | export type BrowserImportSourceId = typeof BrowserImportSourceId.Type; |
| 20 | |
| 21 | export const BrowserImportUnavailableReason = Schema.Literals([ |
| 22 | "notInstalled", |
| 23 | "needsKeychainApproval", |
| 24 | "keychainItemMissing", |
| 25 | "needsFullDiskAccess", |
| 26 | "browserRunning", |
| 27 | "unsupportedPlatform", |
| 28 | ]); |
| 29 | export type BrowserImportUnavailableReason = typeof BrowserImportUnavailableReason.Type; |
| 30 | |
| 31 | export const BrowserImportFailureReason = Schema.Literals([ |
| 32 | ...BrowserImportUnavailableReason.literals, |
| 33 | "keychainUnavailable", |
| 34 | "unknownSource", |
| 35 | "unknownSourceProfile", |
| 36 | "sessionUnavailable", |
| 37 | "profileNotSaved", |
| 38 | "profileLimitReached", |
| 39 | "readFailed", |
| 40 | ]); |
| 41 | export type BrowserImportFailureReason = typeof BrowserImportFailureReason.Type; |
| 42 | |
| 43 | export const BrowserImportSourceProfile = Schema.Struct({ |
| 44 | directory: TrimmedNonEmptyString, |
| 45 | name: TrimmedNonEmptyString, |
| 46 | cookieCount: Schema.optional(Schema.Int), |
| 47 | }); |
| 48 | export type BrowserImportSourceProfile = typeof BrowserImportSourceProfile.Type; |
| 49 | |
| 50 | export const BrowserImportSource = Schema.Struct({ |
| 51 | id: BrowserImportSourceId, |
| 52 | name: TrimmedNonEmptyString, |
| 53 | profiles: Schema.Array(BrowserImportSourceProfile), |
| 54 | unavailable: Schema.optional(BrowserImportUnavailableReason), |
| 55 | }); |
| 56 | export type BrowserImportSource = typeof BrowserImportSource.Type; |
| 57 | |
| 58 | export const BrowserImportInput = Schema.Struct({ |
| 59 | sourceId: BrowserImportSourceId, |
| 60 | sourceProfileDirectory: TrimmedNonEmptyString, |
| 61 | targetProfileId: BrowserProfileId, |
| 62 | }); |
| 63 | export type BrowserImportInput = typeof BrowserImportInput.Type; |
| 64 | |
| 65 | export const DesktopPreviewImportCookiesInputSchema = Schema.Struct({ |
| 66 | environmentId: TrimmedNonEmptyString, |
| 67 | sourceId: BrowserImportSourceId, |
| 68 | sourceProfileDirectory: TrimmedNonEmptyString, |
| 69 | targetProfileId: BrowserProfileId, |
| 70 | }); |
| 71 | |
| 72 | export const BrowserImportResult = Schema.Struct({ |
| 73 | imported: Schema.Int, |
| 74 | skipped: Schema.Int, |
| 75 | skippedDomains: Schema.Array(Schema.String), |
| 76 | }); |
| 77 | export type BrowserImportResult = typeof BrowserImportResult.Type; |
| 78 | |
| 79 | const BROWSER_IMPORT_UNAVAILABLE_COPY: Readonly<Record<BrowserImportUnavailableReason, string>> = { |
| 80 | notInstalled: "Not installed on this machine.", |
| 81 | needsKeychainApproval: "Needs Keychain access to read its cookies.", |
| 82 | keychainItemMissing: |
| 83 | "No encryption key in your Keychain. Sign in to that browser once, then retry.", |
| 84 | needsFullDiskAccess: |
| 85 | "Give T3 Code Full Disk Access in System Settings → Privacy & Security, then retry.", |
| 86 | browserRunning: "Quit the browser first so its cookie database can be read.", |
| 87 | unsupportedPlatform: "Importing from this browser isn't possible on this platform.", |
| 88 | }; |
| 89 | |
| 90 | export const BROWSER_IMPORT_FAILURE_COPY: Readonly<Record<BrowserImportFailureReason, string>> = { |
| 91 | ...BROWSER_IMPORT_UNAVAILABLE_COPY, |
| 92 | keychainUnavailable: |
| 93 | "The system keyring could not be accessed. Make sure your desktop keyring is running and unlocked, then retry.", |
| 94 | unknownSource: "That browser is no longer available to import from.", |
| 95 | unknownSourceProfile: "That browser profile no longer exists.", |
| 96 | sessionUnavailable: "The target profile could not be opened.", |
| 97 | profileNotSaved: "The cookies were imported, but the new profile couldn't be saved. Try again.", |
| 98 | profileLimitReached: |
| 99 | "You've reached the profile limit. Delete a profile or import into an existing one.", |
| 100 | readFailed: "The browser's cookie database could not be read.", |
| 101 | }; |