klaudius 0.17.1 → 0.17.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,17 +1,17 @@
1
- import{a as y,e as ee}from"./chunk-SZ4KCTSL.js";import{useEffect as ta,useMemo as oa,useRef as Q,useState as M}from"react";import{Box as v,Text as E,useApp as ia,useInput as sa}from"ink";var ae={gmail:{label:"Gmail",smtpHost:"smtp.gmail.com",smtpPort:587,imapHost:"imap.gmail.com",imapPort:993,sentFolder:"[Gmail]/Sent Mail",inboxFolder:"INBOX",appPasswordHelp:`Generate at https://myaccount.google.com/apppasswords
1
+ import{a as y,e as ae}from"./chunk-SZ4KCTSL.js";import{useEffect as la,useMemo as ua,useRef as ee,useState as M}from"react";import{Box as v,Text as E,useApp as ca,useInput as da}from"ink";var ne={gmail:{label:"Gmail",smtpHost:"smtp.gmail.com",smtpPort:587,imapHost:"imap.gmail.com",imapPort:993,sentFolder:"[Gmail]/Sent Mail",inboxFolder:"INBOX",appPasswordHelp:`Generate at https://myaccount.google.com/apppasswords
2
2
  (2-step verification must be enabled on your Google account first;
3
3
  Google won't accept your normal account password from third-party apps).`},outlook:{label:"Outlook / Office 365",smtpHost:"smtp-mail.outlook.com",smtpPort:587,imapHost:"outlook.office365.com",imapPort:993,sentFolder:"Sent Items",inboxFolder:"INBOX",appPasswordHelp:`Generate at https://account.microsoft.com/security \u2192 Advanced security options \u2192 App passwords
4
4
  (2-step verification must be enabled first).`},ionos:{label:"IONOS",smtpHost:"smtp.ionos.co.uk",smtpPort:587,imapHost:"imap.ionos.co.uk",imapPort:993,sentFolder:"Sent Items",inboxFolder:"INBOX",appPasswordHelp:`Use your normal IONOS mailbox password.
5
5
  (IONOS doesn't require app passwords for IMAP/SMTP unless you've enabled 2FA.)`},fastmail:{label:"Fastmail",smtpHost:"smtp.fastmail.com",smtpPort:587,imapHost:"imap.fastmail.com",imapPort:993,sentFolder:"Sent",inboxFolder:"INBOX",appPasswordHelp:`Generate at https://app.fastmail.com/settings/security/integrations
6
6
  (Fastmail requires app passwords for IMAP/SMTP regardless of 2FA setting.)`},zoho:{label:"Zoho Mail",smtpHost:"smtp.zoho.com",smtpPort:587,imapHost:"imap.zoho.com",imapPort:993,sentFolder:"Sent",inboxFolder:"INBOX",appPasswordHelp:`Generate at https://accounts.zoho.com/u/h#security/app_passwords
7
- (Zoho requires app passwords for IMAP/SMTP \u2014 your normal account password won't work.)`}},ne=`Use the app-specific password your provider issues for SMTP/IMAP
7
+ (Zoho requires app passwords for IMAP/SMTP \u2014 your normal account password won't work.)`}},te=`Use the app-specific password your provider issues for SMTP/IMAP
8
8
  (check their security settings \u2014 most providers require a generated password
9
- rather than your normal account password).`;var Pe=[{country:"the United Kingdom",code:"GB",language:"English",langCode:"en",aliases:["uk","united kingdom","great britain","britain","england","scotland","wales","northern ireland"]},{country:"Ireland",code:"IE",language:"English",langCode:"en"},{country:"France",code:"FR",language:"French",langCode:"fr"},{country:"Germany",code:"DE",language:"German",langCode:"de",aliases:["deutschland"]},{country:"Austria",code:"AT",language:"German",langCode:"de",aliases:["\xF6sterreich","osterreich"]},{country:"Switzerland",code:"CH",language:"German",langCode:"de",aliases:["schweiz","suisse","svizzera"]},{country:"Liechtenstein",code:"LI",language:"German",langCode:"de"},{country:"Luxembourg",code:"LU",language:"French",langCode:"fr",aliases:["l\xEBtzebuerg"]},{country:"the Netherlands",code:"NL",language:"Dutch",langCode:"nl",aliases:["netherlands","holland","nederland"]},{country:"Belgium",code:"BE",language:"Dutch",langCode:"nl",aliases:["belgi\xEB","belgique"]},{country:"Monaco",code:"MC",language:"French",langCode:"fr"},{country:"Andorra",code:"AD",language:"Catalan",langCode:"ca"},{country:"Italy",code:"IT",language:"Italian",langCode:"it",aliases:["italia"]},{country:"Spain",code:"ES",language:"Spanish",langCode:"es",aliases:["espa\xF1a","espana"]},{country:"Portugal",code:"PT",language:"Portuguese",langCode:"pt"},{country:"Malta",code:"MT",language:"English",langCode:"en"},{country:"San Marino",code:"SM",language:"Italian",langCode:"it"},{country:"Vatican City",code:"VA",language:"Italian",langCode:"it",aliases:["the vatican","holy see"]},{country:"Sweden",code:"SE",language:"Swedish",langCode:"sv",aliases:["sverige"]},{country:"Norway",code:"NO",language:"Norwegian",langCode:"no",aliases:["norge"]},{country:"Denmark",code:"DK",language:"Danish",langCode:"da",aliases:["danmark"]},{country:"Finland",code:"FI",language:"Finnish",langCode:"fi",aliases:["suomi"]},{country:"Iceland",code:"IS",language:"Icelandic",langCode:"is",aliases:["\xEDsland"]},{country:"Poland",code:"PL",language:"Polish",langCode:"pl",aliases:["polska"]},{country:"Czech Republic",code:"CZ",language:"Czech",langCode:"cs",aliases:["czechia","\u010Desko"]},{country:"Slovakia",code:"SK",language:"Slovak",langCode:"sk",aliases:["slovensko"]},{country:"Hungary",code:"HU",language:"Hungarian",langCode:"hu",aliases:["magyarorsz\xE1g"]},{country:"Slovenia",code:"SI",language:"Slovenian",langCode:"sl",aliases:["slovenija"]},{country:"Croatia",code:"HR",language:"Croatian",langCode:"hr",aliases:["hrvatska"]},{country:"Bosnia and Herzegovina",code:"BA",language:"Bosnian",langCode:"bs",aliases:["bosnia"]},{country:"Serbia",code:"RS",language:"Serbian",langCode:"sr",aliases:["srbija"]},{country:"Montenegro",code:"ME",language:"Montenegrin",langCode:"sr",aliases:["crna gora"]},{country:"Kosovo",code:"XK",language:"Albanian",langCode:"sq"},{country:"North Macedonia",code:"MK",language:"Macedonian",langCode:"mk",aliases:["macedonia"]},{country:"Albania",code:"AL",language:"Albanian",langCode:"sq",aliases:["shqip\xEBria"]},{country:"Bulgaria",code:"BG",language:"Bulgarian",langCode:"bg"},{country:"Romania",code:"RO",language:"Romanian",langCode:"ro",aliases:["rom\xE2nia"]},{country:"Moldova",code:"MD",language:"Romanian",langCode:"ro"},{country:"Greece",code:"GR",language:"Greek",langCode:"el",aliases:["\u03B5\u03BB\u03BB\u03AC\u03B4\u03B1"]},{country:"Cyprus",code:"CY",language:"Greek",langCode:"el"},{country:"Russia",code:"RU",language:"Russian",langCode:"ru",aliases:["\u0440\u043E\u0441\u0441\u0438\u044F"]},{country:"Ukraine",code:"UA",language:"Ukrainian",langCode:"uk",aliases:["\u0443\u043A\u0440\u0430\u0457\u043D\u0430"]},{country:"Belarus",code:"BY",language:"Belarusian",langCode:"be"},{country:"Estonia",code:"EE",language:"Estonian",langCode:"et",aliases:["eesti"]},{country:"Latvia",code:"LV",language:"Latvian",langCode:"lv",aliases:["latvija"]},{country:"Lithuania",code:"LT",language:"Lithuanian",langCode:"lt",aliases:["lietuva"]},{country:"Turkey",code:"TR",language:"Turkish",langCode:"tr",aliases:["t\xFCrkiye","turkiye"]},{country:"Armenia",code:"AM",language:"Armenian",langCode:"hy"},{country:"Azerbaijan",code:"AZ",language:"Azerbaijani",langCode:"az",aliases:["az\u0259rbaycan"]},{country:"Georgia",code:"GE",language:"Georgian",langCode:"ka",aliases:["\u10E1\u10D0\u10E5\u10D0\u10E0\u10D7\u10D5\u10D4\u10DA\u10DD"]},{country:"Israel",code:"IL",language:"Hebrew",langCode:"he"},{country:"Palestine",code:"PS",language:"Arabic",langCode:"ar"},{country:"Lebanon",code:"LB",language:"Arabic",langCode:"ar"},{country:"Syria",code:"SY",language:"Arabic",langCode:"ar"},{country:"Jordan",code:"JO",language:"Arabic",langCode:"ar"},{country:"Iraq",code:"IQ",language:"Arabic",langCode:"ar"},{country:"Iran",code:"IR",language:"Persian",langCode:"fa",aliases:["islamic republic of iran"]},{country:"Saudi Arabia",code:"SA",language:"Arabic",langCode:"ar"},{country:"Yemen",code:"YE",language:"Arabic",langCode:"ar"},{country:"Oman",code:"OM",language:"Arabic",langCode:"ar"},{country:"the United Arab Emirates",code:"AE",language:"English",langCode:"en",aliases:["uae","united arab emirates","dubai","abu dhabi"]},{country:"Qatar",code:"QA",language:"Arabic",langCode:"ar"},{country:"Bahrain",code:"BH",language:"Arabic",langCode:"ar"},{country:"Kuwait",code:"KW",language:"Arabic",langCode:"ar"},{country:"Kazakhstan",code:"KZ",language:"Kazakh",langCode:"kk"},{country:"Uzbekistan",code:"UZ",language:"Uzbek",langCode:"uz"},{country:"Kyrgyzstan",code:"KG",language:"Kyrgyz",langCode:"ky"},{country:"Turkmenistan",code:"TM",language:"Turkmen",langCode:"tk"},{country:"Tajikistan",code:"TJ",language:"Tajik",langCode:"tg"},{country:"Afghanistan",code:"AF",language:"Persian",langCode:"fa"},{country:"India",code:"IN",language:"English",langCode:"en"},{country:"Pakistan",code:"PK",language:"English",langCode:"en"},{country:"Bangladesh",code:"BD",language:"Bengali",langCode:"bn"},{country:"Sri Lanka",code:"LK",language:"English",langCode:"en"},{country:"Nepal",code:"NP",language:"Nepali",langCode:"ne"},{country:"Bhutan",code:"BT",language:"English",langCode:"en"},{country:"the Maldives",code:"MV",language:"English",langCode:"en",aliases:["maldives"]},{country:"China",code:"CN",language:"Chinese",langCode:"zh",aliases:["\u4E2D\u56FD","people's republic of china","prc"]},{country:"Hong Kong",code:"HK",language:"English",langCode:"en",aliases:["hk"]},{country:"Macao",code:"MO",language:"Chinese",langCode:"zh",aliases:["macau"]},{country:"Taiwan",code:"TW",language:"Chinese",langCode:"zh",aliases:["\u53F0\u7063","republic of china"]},{country:"Japan",code:"JP",language:"Japanese",langCode:"ja",aliases:["\u65E5\u672C"]},{country:"South Korea",code:"KR",language:"Korean",langCode:"ko",aliases:["korea","republic of korea"]},{country:"North Korea",code:"KP",language:"Korean",langCode:"ko",aliases:["dprk"]},{country:"Mongolia",code:"MN",language:"Mongolian",langCode:"mn"},{country:"Thailand",code:"TH",language:"Thai",langCode:"th"},{country:"Vietnam",code:"VN",language:"Vietnamese",langCode:"vi",aliases:["viet nam"]},{country:"Cambodia",code:"KH",language:"Khmer",langCode:"km"},{country:"Laos",code:"LA",language:"Lao",langCode:"lo"},{country:"Myanmar",code:"MM",language:"Burmese",langCode:"my",aliases:["burma"]},{country:"Malaysia",code:"MY",language:"Malay",langCode:"ms"},{country:"Singapore",code:"SG",language:"English",langCode:"en"},{country:"Brunei",code:"BN",language:"Malay",langCode:"ms",aliases:["brunei darussalam"]},{country:"Indonesia",code:"ID",language:"Indonesian",langCode:"id"},{country:"the Philippines",code:"PH",language:"English",langCode:"en",aliases:["philippines"]},{country:"Timor-Leste",code:"TL",language:"Portuguese",langCode:"pt",aliases:["east timor"]},{country:"the United States",code:"US",language:"English",langCode:"en",aliases:["us","usa","united states","united states of america","america","states"]},{country:"Canada",code:"CA",language:"English",langCode:"en"},{country:"Mexico",code:"MX",language:"Spanish",langCode:"es",aliases:["m\xE9xico"]},{country:"Guatemala",code:"GT",language:"Spanish",langCode:"es"},{country:"Belize",code:"BZ",language:"English",langCode:"en"},{country:"El Salvador",code:"SV",language:"Spanish",langCode:"es"},{country:"Honduras",code:"HN",language:"Spanish",langCode:"es"},{country:"Nicaragua",code:"NI",language:"Spanish",langCode:"es"},{country:"Costa Rica",code:"CR",language:"Spanish",langCode:"es"},{country:"Panama",code:"PA",language:"Spanish",langCode:"es",aliases:["panam\xE1"]},{country:"Cuba",code:"CU",language:"Spanish",langCode:"es"},{country:"the Dominican Republic",code:"DO",language:"Spanish",langCode:"es",aliases:["dominican republic"]},{country:"Haiti",code:"HT",language:"French",langCode:"fr"},{country:"Jamaica",code:"JM",language:"English",langCode:"en"},{country:"the Bahamas",code:"BS",language:"English",langCode:"en",aliases:["bahamas"]},{country:"Trinidad and Tobago",code:"TT",language:"English",langCode:"en"},{country:"Barbados",code:"BB",language:"English",langCode:"en"},{country:"Saint Lucia",code:"LC",language:"English",langCode:"en"},{country:"Saint Vincent and the Grenadines",code:"VC",language:"English",langCode:"en"},{country:"Grenada",code:"GD",language:"English",langCode:"en"},{country:"Dominica",code:"DM",language:"English",langCode:"en"},{country:"Saint Kitts and Nevis",code:"KN",language:"English",langCode:"en"},{country:"Antigua and Barbuda",code:"AG",language:"English",langCode:"en"},{country:"Puerto Rico",code:"PR",language:"Spanish",langCode:"es"},{country:"Brazil",code:"BR",language:"Portuguese",langCode:"pt",aliases:["brasil"]},{country:"Argentina",code:"AR",language:"Spanish",langCode:"es"},{country:"Colombia",code:"CO",language:"Spanish",langCode:"es"},{country:"Chile",code:"CL",language:"Spanish",langCode:"es"},{country:"Peru",code:"PE",language:"Spanish",langCode:"es",aliases:["per\xFA"]},{country:"Venezuela",code:"VE",language:"Spanish",langCode:"es"},{country:"Ecuador",code:"EC",language:"Spanish",langCode:"es"},{country:"Bolivia",code:"BO",language:"Spanish",langCode:"es"},{country:"Paraguay",code:"PY",language:"Spanish",langCode:"es"},{country:"Uruguay",code:"UY",language:"Spanish",langCode:"es"},{country:"Guyana",code:"GY",language:"English",langCode:"en"},{country:"Suriname",code:"SR",language:"Dutch",langCode:"nl"},{country:"Australia",code:"AU",language:"English",langCode:"en",aliases:["aus","oz"]},{country:"New Zealand",code:"NZ",language:"English",langCode:"en",aliases:["nz","aotearoa"]},{country:"Fiji",code:"FJ",language:"English",langCode:"en"},{country:"Papua New Guinea",code:"PG",language:"English",langCode:"en",aliases:["png"]},{country:"Samoa",code:"WS",language:"English",langCode:"en"},{country:"Tonga",code:"TO",language:"English",langCode:"en"},{country:"Vanuatu",code:"VU",language:"English",langCode:"en"},{country:"Solomon Islands",code:"SB",language:"English",langCode:"en"},{country:"Kiribati",code:"KI",language:"English",langCode:"en"},{country:"Tuvalu",code:"TV",language:"English",langCode:"en"},{country:"Nauru",code:"NR",language:"English",langCode:"en"},{country:"Palau",code:"PW",language:"English",langCode:"en"},{country:"the Marshall Islands",code:"MH",language:"English",langCode:"en",aliases:["marshall islands"]},{country:"Micronesia",code:"FM",language:"English",langCode:"en",aliases:["federated states of micronesia"]},{country:"Egypt",code:"EG",language:"Arabic",langCode:"ar"},{country:"Libya",code:"LY",language:"Arabic",langCode:"ar"},{country:"Tunisia",code:"TN",language:"Arabic",langCode:"ar"},{country:"Algeria",code:"DZ",language:"Arabic",langCode:"ar"},{country:"Morocco",code:"MA",language:"Arabic",langCode:"ar",aliases:["maroc"]},{country:"Sudan",code:"SD",language:"Arabic",langCode:"ar"},{country:"South Sudan",code:"SS",language:"English",langCode:"en"},{country:"Mauritania",code:"MR",language:"Arabic",langCode:"ar"},{country:"Nigeria",code:"NG",language:"English",langCode:"en"},{country:"Ghana",code:"GH",language:"English",langCode:"en"},{country:"Senegal",code:"SN",language:"French",langCode:"fr",aliases:["s\xE9n\xE9gal"]},{country:"C\xF4te d'Ivoire",code:"CI",language:"French",langCode:"fr",aliases:["ivory coast"]},{country:"Mali",code:"ML",language:"French",langCode:"fr"},{country:"Burkina Faso",code:"BF",language:"French",langCode:"fr"},{country:"Niger",code:"NE",language:"French",langCode:"fr"},{country:"Guinea",code:"GN",language:"French",langCode:"fr",aliases:["guin\xE9e"]},{country:"Guinea-Bissau",code:"GW",language:"Portuguese",langCode:"pt"},{country:"Sierra Leone",code:"SL",language:"English",langCode:"en"},{country:"Liberia",code:"LR",language:"English",langCode:"en"},{country:"the Gambia",code:"GM",language:"English",langCode:"en",aliases:["gambia"]},{country:"Cabo Verde",code:"CV",language:"Portuguese",langCode:"pt",aliases:["cape verde"]},{country:"Togo",code:"TG",language:"French",langCode:"fr"},{country:"Benin",code:"BJ",language:"French",langCode:"fr",aliases:["b\xE9nin"]},{country:"Cameroon",code:"CM",language:"French",langCode:"fr",aliases:["cameroun"]},{country:"the Central African Republic",code:"CF",language:"French",langCode:"fr",aliases:["central african republic","car"]},{country:"Chad",code:"TD",language:"French",langCode:"fr",aliases:["tchad"]},{country:"Equatorial Guinea",code:"GQ",language:"Spanish",langCode:"es"},{country:"Gabon",code:"GA",language:"French",langCode:"fr"},{country:"the Republic of the Congo",code:"CG",language:"French",langCode:"fr",aliases:["congo","republic of the congo","congo-brazzaville"]},{country:"the Democratic Republic of the Congo",code:"CD",language:"French",langCode:"fr",aliases:["dr congo","drc","democratic republic of the congo","congo-kinshasa","zaire"]},{country:"S\xE3o Tom\xE9 and Pr\xEDncipe",code:"ST",language:"Portuguese",langCode:"pt",aliases:["sao tome and principe","sao tome"]},{country:"Ethiopia",code:"ET",language:"Amharic",langCode:"am"},{country:"Eritrea",code:"ER",language:"Tigrinya",langCode:"ti"},{country:"Djibouti",code:"DJ",language:"French",langCode:"fr"},{country:"Somalia",code:"SO",language:"Somali",langCode:"so"},{country:"Kenya",code:"KE",language:"English",langCode:"en"},{country:"Uganda",code:"UG",language:"English",langCode:"en"},{country:"Tanzania",code:"TZ",language:"English",langCode:"en",aliases:["united republic of tanzania"]},{country:"Rwanda",code:"RW",language:"English",langCode:"en"},{country:"Burundi",code:"BI",language:"French",langCode:"fr"},{country:"Madagascar",code:"MG",language:"French",langCode:"fr"},{country:"Mauritius",code:"MU",language:"English",langCode:"en"},{country:"the Seychelles",code:"SC",language:"English",langCode:"en",aliases:["seychelles"]},{country:"Comoros",code:"KM",language:"French",langCode:"fr"},{country:"South Africa",code:"ZA",language:"English",langCode:"en",aliases:["sa"]},{country:"Namibia",code:"NA",language:"English",langCode:"en"},{country:"Botswana",code:"BW",language:"English",langCode:"en"},{country:"Zimbabwe",code:"ZW",language:"English",langCode:"en"},{country:"Zambia",code:"ZM",language:"English",langCode:"en"},{country:"Malawi",code:"MW",language:"English",langCode:"en"},{country:"Mozambique",code:"MZ",language:"Portuguese",langCode:"pt",aliases:["mo\xE7ambique"]},{country:"Angola",code:"AO",language:"Portuguese",langCode:"pt"},{country:"Lesotho",code:"LS",language:"English",langCode:"en"},{country:"Eswatini",code:"SZ",language:"English",langCode:"en",aliases:["swaziland"]}],Ae=[{language:"English",code:"en"},{language:"Italian",code:"it",aliases:["italiano"]},{language:"Spanish",code:"es",aliases:["espa\xF1ol","espanol","castellano"]},{language:"French",code:"fr",aliases:["fran\xE7ais","francais"]},{language:"German",code:"de",aliases:["deutsch"]},{language:"Portuguese",code:"pt",aliases:["portugu\xEAs","portugues"]},{language:"Dutch",code:"nl",aliases:["nederlands","flemish"]},{language:"Swedish",code:"sv",aliases:["svenska"]},{language:"Norwegian",code:"no",aliases:["norsk"]},{language:"Danish",code:"da",aliases:["dansk"]},{language:"Icelandic",code:"is",aliases:["\xEDslenska"]},{language:"Catalan",code:"ca",aliases:["catal\xE0"]},{language:"Romanian",code:"ro",aliases:["rom\xE2n\u0103","romana"]},{language:"Polish",code:"pl",aliases:["polski"]},{language:"Czech",code:"cs",aliases:["\u010De\u0161tina","cestina"]},{language:"Slovak",code:"sk",aliases:["sloven\u010Dina"]},{language:"Slovenian",code:"sl",aliases:["sloven\u0161\u010Dina"]},{language:"Croatian",code:"hr",aliases:["hrvatski"]},{language:"Bosnian",code:"bs",aliases:["bosanski"]},{language:"Serbian",code:"sr",aliases:["\u0441\u0440\u043F\u0441\u043A\u0438"]},{language:"Montenegrin",code:"sr",aliases:["crnogorski"]},{language:"Macedonian",code:"mk",aliases:["\u043C\u0430\u043A\u0435\u0434\u043E\u043D\u0441\u043A\u0438"]},{language:"Bulgarian",code:"bg",aliases:["\u0431\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438"]},{language:"Russian",code:"ru",aliases:["\u0440\u0443\u0441\u0441\u043A\u0438\u0439"]},{language:"Ukrainian",code:"uk",aliases:["\u0443\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"]},{language:"Belarusian",code:"be",aliases:["\u0431\u0435\u043B\u0430\u0440\u0443\u0441\u043A\u0430\u044F"]},{language:"Latvian",code:"lv",aliases:["latvie\u0161u"]},{language:"Lithuanian",code:"lt",aliases:["lietuvi\u0173"]},{language:"Greek",code:"el",aliases:["\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC","ellinik\xE1"]},{language:"Albanian",code:"sq",aliases:["shqip"]},{language:"Armenian",code:"hy",aliases:["\u0570\u0561\u0575\u0565\u0580\u0565\u0576"]},{language:"Persian",code:"fa",aliases:["farsi","dari","\u0641\u0627\u0631\u0633\u06CC"]},{language:"Hindi",code:"hi",aliases:["\u0939\u093F\u0928\u094D\u0926\u0940"]},{language:"Urdu",code:"ur",aliases:["\u0627\u0631\u062F\u0648"]},{language:"Bengali",code:"bn",aliases:["bangla","\u09AC\u09BE\u0982\u09B2\u09BE"]},{language:"Nepali",code:"ne",aliases:["\u0928\u0947\u092A\u093E\u0932\u0940"]},{language:"Sinhala",code:"si",aliases:["\u0DC3\u0DD2\u0D82\u0DC4\u0DBD","sinhalese"]},{language:"Finnish",code:"fi",aliases:["suomi"]},{language:"Estonian",code:"et",aliases:["eesti"]},{language:"Hungarian",code:"hu",aliases:["magyar"]},{language:"Turkish",code:"tr",aliases:["t\xFCrk\xE7e","turkce"]},{language:"Azerbaijani",code:"az",aliases:["az\u0259rbaycan dili","azeri"]},{language:"Kazakh",code:"kk",aliases:["\u049B\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"]},{language:"Uzbek",code:"uz",aliases:["o'zbek"]},{language:"Kyrgyz",code:"ky",aliases:["\u043A\u044B\u0440\u0433\u044B\u0437\u0447\u0430"]},{language:"Turkmen",code:"tk",aliases:["t\xFCrkmen\xE7e"]},{language:"Arabic",code:"ar",aliases:["\u0627\u0644\u0639\u0631\u0628\u064A\u0629"]},{language:"Hebrew",code:"he",aliases:["\u05E2\u05D1\u05E8\u05D9\u05EA","ivrit"]},{language:"Amharic",code:"am",aliases:["\u12A0\u121B\u122D\u129B"]},{language:"Tigrinya",code:"ti",aliases:["\u1275\u130D\u122D\u129B"]},{language:"Chinese",code:"zh",aliases:["mandarin","\u4E2D\u6587","\u6C49\u8BED","putonghua"]},{language:"Japanese",code:"ja",aliases:["\u65E5\u672C\u8A9E","nihongo"]},{language:"Korean",code:"ko",aliases:["\uD55C\uAD6D\uC5B4"]},{language:"Thai",code:"th",aliases:["\u0E44\u0E17\u0E22"]},{language:"Vietnamese",code:"vi",aliases:["ti\u1EBFng vi\u1EC7t"]},{language:"Khmer",code:"km",aliases:["\u1781\u17D2\u1798\u17C2\u179A","cambodian"]},{language:"Lao",code:"lo",aliases:["\u0EA5\u0EB2\u0EA7"]},{language:"Burmese",code:"my",aliases:["\u1019\u103C\u1014\u103A\u1019\u102C","myanmar"]},{language:"Dzongkha",code:"dz",aliases:["\u0F62\u0FAB\u0F7C\u0F44\u0F0B\u0F41"]},{language:"Mongolian",code:"mn",aliases:["\u043C\u043E\u043D\u0433\u043E\u043B"]},{language:"Georgian",code:"ka",aliases:["\u10E5\u10D0\u10E0\u10D7\u10E3\u10DA\u10D8"]},{language:"Tajik",code:"tg",aliases:["\u0442\u043E\u04B7\u0438\u043A\u04E3"]},{language:"Malay",code:"ms",aliases:["bahasa malaysia","bahasa melayu"]},{language:"Indonesian",code:"id",aliases:["bahasa indonesia"]},{language:"Filipino",code:"fil",aliases:["tagalog","pilipino"]},{language:"Swahili",code:"sw",aliases:["kiswahili"]},{language:"Somali",code:"so",aliases:["af soomaali"]},{language:"Yoruba",code:"yo",aliases:["yor\xF9b\xE1"]},{language:"Hausa",code:"ha",aliases:["harshen hausa"]},{language:"Zulu",code:"zu",aliases:["isizulu"]},{language:"Afrikaans",code:"af"}];function O(e){return e.trim().toLowerCase()}function te(e){if(!e)return;let a=O(e);for(let t of Pe)if(O(t.country)===a||t.aliases?.some(n=>O(n)===a))return t}function oe(e){if(!e)return;let a=O(e);for(let t of Ae)if(O(t.language)===a||t.aliases?.some(n=>O(n)===a))return t}var L=class extends Error{constructor(){super("user pressed back"),this.name="BackSignal"}},D=class extends Error{constructor(){super("user cancelled"),this.name="CancelSignal"}},Ie="Include the country code with a + (e.g. +12025550123 for US, +447123456789 for UK)",ie=e=>/^\+\d{8,15}$/.test(e)?void 0:Ie,Te=e=>/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e)?void 0:"Enter a valid email",B=e=>a=>a.trim().length===0?`${e} is required`:void 0,Ee="one-off, no monthly fees",se="per month";function U(e){if(!e)return!0;let a=e.trim();if(a==="")return!0;let t=a.replace(/[^\d.]/g,"");if(t==="")return/^\s*free\s*$/i.test(a);let n=parseFloat(t);return!isNaN(n)&&n===0}var xe={id:"ai-agent",title:"AI coding agent",isApplicable:()=>!0,execute:async(e,{prompt:a,info:t})=>(t({title:"Which AI coding agent do you use?",body:`Klaudius works with two AI coding agents in your terminal \u2014 Claude Code
9
+ rather than your normal account password).`;var Ae=[{country:"the United Kingdom",code:"GB",language:"English",langCode:"en",aliases:["uk","united kingdom","great britain","britain","england","scotland","wales","northern ireland"]},{country:"Ireland",code:"IE",language:"English",langCode:"en"},{country:"France",code:"FR",language:"French",langCode:"fr"},{country:"Germany",code:"DE",language:"German",langCode:"de",aliases:["deutschland"]},{country:"Austria",code:"AT",language:"German",langCode:"de",aliases:["\xF6sterreich","osterreich"]},{country:"Switzerland",code:"CH",language:"German",langCode:"de",aliases:["schweiz","suisse","svizzera"]},{country:"Liechtenstein",code:"LI",language:"German",langCode:"de"},{country:"Luxembourg",code:"LU",language:"French",langCode:"fr",aliases:["l\xEBtzebuerg"]},{country:"the Netherlands",code:"NL",language:"Dutch",langCode:"nl",aliases:["netherlands","holland","nederland"]},{country:"Belgium",code:"BE",language:"Dutch",langCode:"nl",aliases:["belgi\xEB","belgique"]},{country:"Monaco",code:"MC",language:"French",langCode:"fr"},{country:"Andorra",code:"AD",language:"Catalan",langCode:"ca"},{country:"Italy",code:"IT",language:"Italian",langCode:"it",aliases:["italia"]},{country:"Spain",code:"ES",language:"Spanish",langCode:"es",aliases:["espa\xF1a","espana"]},{country:"Portugal",code:"PT",language:"Portuguese",langCode:"pt"},{country:"Malta",code:"MT",language:"English",langCode:"en"},{country:"San Marino",code:"SM",language:"Italian",langCode:"it"},{country:"Vatican City",code:"VA",language:"Italian",langCode:"it",aliases:["the vatican","holy see"]},{country:"Sweden",code:"SE",language:"Swedish",langCode:"sv",aliases:["sverige"]},{country:"Norway",code:"NO",language:"Norwegian",langCode:"no",aliases:["norge"]},{country:"Denmark",code:"DK",language:"Danish",langCode:"da",aliases:["danmark"]},{country:"Finland",code:"FI",language:"Finnish",langCode:"fi",aliases:["suomi"]},{country:"Iceland",code:"IS",language:"Icelandic",langCode:"is",aliases:["\xEDsland"]},{country:"Poland",code:"PL",language:"Polish",langCode:"pl",aliases:["polska"]},{country:"Czech Republic",code:"CZ",language:"Czech",langCode:"cs",aliases:["czechia","\u010Desko"]},{country:"Slovakia",code:"SK",language:"Slovak",langCode:"sk",aliases:["slovensko"]},{country:"Hungary",code:"HU",language:"Hungarian",langCode:"hu",aliases:["magyarorsz\xE1g"]},{country:"Slovenia",code:"SI",language:"Slovenian",langCode:"sl",aliases:["slovenija"]},{country:"Croatia",code:"HR",language:"Croatian",langCode:"hr",aliases:["hrvatska"]},{country:"Bosnia and Herzegovina",code:"BA",language:"Bosnian",langCode:"bs",aliases:["bosnia"]},{country:"Serbia",code:"RS",language:"Serbian",langCode:"sr",aliases:["srbija"]},{country:"Montenegro",code:"ME",language:"Montenegrin",langCode:"sr",aliases:["crna gora"]},{country:"Kosovo",code:"XK",language:"Albanian",langCode:"sq"},{country:"North Macedonia",code:"MK",language:"Macedonian",langCode:"mk",aliases:["macedonia"]},{country:"Albania",code:"AL",language:"Albanian",langCode:"sq",aliases:["shqip\xEBria"]},{country:"Bulgaria",code:"BG",language:"Bulgarian",langCode:"bg"},{country:"Romania",code:"RO",language:"Romanian",langCode:"ro",aliases:["rom\xE2nia"]},{country:"Moldova",code:"MD",language:"Romanian",langCode:"ro"},{country:"Greece",code:"GR",language:"Greek",langCode:"el",aliases:["\u03B5\u03BB\u03BB\u03AC\u03B4\u03B1"]},{country:"Cyprus",code:"CY",language:"Greek",langCode:"el"},{country:"Russia",code:"RU",language:"Russian",langCode:"ru",aliases:["\u0440\u043E\u0441\u0441\u0438\u044F"]},{country:"Ukraine",code:"UA",language:"Ukrainian",langCode:"uk",aliases:["\u0443\u043A\u0440\u0430\u0457\u043D\u0430"]},{country:"Belarus",code:"BY",language:"Belarusian",langCode:"be"},{country:"Estonia",code:"EE",language:"Estonian",langCode:"et",aliases:["eesti"]},{country:"Latvia",code:"LV",language:"Latvian",langCode:"lv",aliases:["latvija"]},{country:"Lithuania",code:"LT",language:"Lithuanian",langCode:"lt",aliases:["lietuva"]},{country:"Turkey",code:"TR",language:"Turkish",langCode:"tr",aliases:["t\xFCrkiye","turkiye"]},{country:"Armenia",code:"AM",language:"Armenian",langCode:"hy"},{country:"Azerbaijan",code:"AZ",language:"Azerbaijani",langCode:"az",aliases:["az\u0259rbaycan"]},{country:"Georgia",code:"GE",language:"Georgian",langCode:"ka",aliases:["\u10E1\u10D0\u10E5\u10D0\u10E0\u10D7\u10D5\u10D4\u10DA\u10DD"]},{country:"Israel",code:"IL",language:"Hebrew",langCode:"he"},{country:"Palestine",code:"PS",language:"Arabic",langCode:"ar"},{country:"Lebanon",code:"LB",language:"Arabic",langCode:"ar"},{country:"Syria",code:"SY",language:"Arabic",langCode:"ar"},{country:"Jordan",code:"JO",language:"Arabic",langCode:"ar"},{country:"Iraq",code:"IQ",language:"Arabic",langCode:"ar"},{country:"Iran",code:"IR",language:"Persian",langCode:"fa",aliases:["islamic republic of iran"]},{country:"Saudi Arabia",code:"SA",language:"Arabic",langCode:"ar"},{country:"Yemen",code:"YE",language:"Arabic",langCode:"ar"},{country:"Oman",code:"OM",language:"Arabic",langCode:"ar"},{country:"the United Arab Emirates",code:"AE",language:"English",langCode:"en",aliases:["uae","united arab emirates","dubai","abu dhabi"]},{country:"Qatar",code:"QA",language:"Arabic",langCode:"ar"},{country:"Bahrain",code:"BH",language:"Arabic",langCode:"ar"},{country:"Kuwait",code:"KW",language:"Arabic",langCode:"ar"},{country:"Kazakhstan",code:"KZ",language:"Kazakh",langCode:"kk"},{country:"Uzbekistan",code:"UZ",language:"Uzbek",langCode:"uz"},{country:"Kyrgyzstan",code:"KG",language:"Kyrgyz",langCode:"ky"},{country:"Turkmenistan",code:"TM",language:"Turkmen",langCode:"tk"},{country:"Tajikistan",code:"TJ",language:"Tajik",langCode:"tg"},{country:"Afghanistan",code:"AF",language:"Persian",langCode:"fa"},{country:"India",code:"IN",language:"English",langCode:"en"},{country:"Pakistan",code:"PK",language:"English",langCode:"en"},{country:"Bangladesh",code:"BD",language:"Bengali",langCode:"bn"},{country:"Sri Lanka",code:"LK",language:"English",langCode:"en"},{country:"Nepal",code:"NP",language:"Nepali",langCode:"ne"},{country:"Bhutan",code:"BT",language:"English",langCode:"en"},{country:"the Maldives",code:"MV",language:"English",langCode:"en",aliases:["maldives"]},{country:"China",code:"CN",language:"Chinese",langCode:"zh",aliases:["\u4E2D\u56FD","people's republic of china","prc"]},{country:"Hong Kong",code:"HK",language:"English",langCode:"en",aliases:["hk"]},{country:"Macao",code:"MO",language:"Chinese",langCode:"zh",aliases:["macau"]},{country:"Taiwan",code:"TW",language:"Chinese",langCode:"zh",aliases:["\u53F0\u7063","republic of china"]},{country:"Japan",code:"JP",language:"Japanese",langCode:"ja",aliases:["\u65E5\u672C"]},{country:"South Korea",code:"KR",language:"Korean",langCode:"ko",aliases:["korea","republic of korea"]},{country:"North Korea",code:"KP",language:"Korean",langCode:"ko",aliases:["dprk"]},{country:"Mongolia",code:"MN",language:"Mongolian",langCode:"mn"},{country:"Thailand",code:"TH",language:"Thai",langCode:"th"},{country:"Vietnam",code:"VN",language:"Vietnamese",langCode:"vi",aliases:["viet nam"]},{country:"Cambodia",code:"KH",language:"Khmer",langCode:"km"},{country:"Laos",code:"LA",language:"Lao",langCode:"lo"},{country:"Myanmar",code:"MM",language:"Burmese",langCode:"my",aliases:["burma"]},{country:"Malaysia",code:"MY",language:"Malay",langCode:"ms"},{country:"Singapore",code:"SG",language:"English",langCode:"en"},{country:"Brunei",code:"BN",language:"Malay",langCode:"ms",aliases:["brunei darussalam"]},{country:"Indonesia",code:"ID",language:"Indonesian",langCode:"id"},{country:"the Philippines",code:"PH",language:"English",langCode:"en",aliases:["philippines"]},{country:"Timor-Leste",code:"TL",language:"Portuguese",langCode:"pt",aliases:["east timor"]},{country:"the United States",code:"US",language:"English",langCode:"en",aliases:["us","usa","united states","united states of america","america","states"]},{country:"Canada",code:"CA",language:"English",langCode:"en"},{country:"Mexico",code:"MX",language:"Spanish",langCode:"es",aliases:["m\xE9xico"]},{country:"Guatemala",code:"GT",language:"Spanish",langCode:"es"},{country:"Belize",code:"BZ",language:"English",langCode:"en"},{country:"El Salvador",code:"SV",language:"Spanish",langCode:"es"},{country:"Honduras",code:"HN",language:"Spanish",langCode:"es"},{country:"Nicaragua",code:"NI",language:"Spanish",langCode:"es"},{country:"Costa Rica",code:"CR",language:"Spanish",langCode:"es"},{country:"Panama",code:"PA",language:"Spanish",langCode:"es",aliases:["panam\xE1"]},{country:"Cuba",code:"CU",language:"Spanish",langCode:"es"},{country:"the Dominican Republic",code:"DO",language:"Spanish",langCode:"es",aliases:["dominican republic"]},{country:"Haiti",code:"HT",language:"French",langCode:"fr"},{country:"Jamaica",code:"JM",language:"English",langCode:"en"},{country:"the Bahamas",code:"BS",language:"English",langCode:"en",aliases:["bahamas"]},{country:"Trinidad and Tobago",code:"TT",language:"English",langCode:"en"},{country:"Barbados",code:"BB",language:"English",langCode:"en"},{country:"Saint Lucia",code:"LC",language:"English",langCode:"en"},{country:"Saint Vincent and the Grenadines",code:"VC",language:"English",langCode:"en"},{country:"Grenada",code:"GD",language:"English",langCode:"en"},{country:"Dominica",code:"DM",language:"English",langCode:"en"},{country:"Saint Kitts and Nevis",code:"KN",language:"English",langCode:"en"},{country:"Antigua and Barbuda",code:"AG",language:"English",langCode:"en"},{country:"Puerto Rico",code:"PR",language:"Spanish",langCode:"es"},{country:"Brazil",code:"BR",language:"Portuguese",langCode:"pt",aliases:["brasil"]},{country:"Argentina",code:"AR",language:"Spanish",langCode:"es"},{country:"Colombia",code:"CO",language:"Spanish",langCode:"es"},{country:"Chile",code:"CL",language:"Spanish",langCode:"es"},{country:"Peru",code:"PE",language:"Spanish",langCode:"es",aliases:["per\xFA"]},{country:"Venezuela",code:"VE",language:"Spanish",langCode:"es"},{country:"Ecuador",code:"EC",language:"Spanish",langCode:"es"},{country:"Bolivia",code:"BO",language:"Spanish",langCode:"es"},{country:"Paraguay",code:"PY",language:"Spanish",langCode:"es"},{country:"Uruguay",code:"UY",language:"Spanish",langCode:"es"},{country:"Guyana",code:"GY",language:"English",langCode:"en"},{country:"Suriname",code:"SR",language:"Dutch",langCode:"nl"},{country:"Australia",code:"AU",language:"English",langCode:"en",aliases:["aus","oz"]},{country:"New Zealand",code:"NZ",language:"English",langCode:"en",aliases:["nz","aotearoa"]},{country:"Fiji",code:"FJ",language:"English",langCode:"en"},{country:"Papua New Guinea",code:"PG",language:"English",langCode:"en",aliases:["png"]},{country:"Samoa",code:"WS",language:"English",langCode:"en"},{country:"Tonga",code:"TO",language:"English",langCode:"en"},{country:"Vanuatu",code:"VU",language:"English",langCode:"en"},{country:"Solomon Islands",code:"SB",language:"English",langCode:"en"},{country:"Kiribati",code:"KI",language:"English",langCode:"en"},{country:"Tuvalu",code:"TV",language:"English",langCode:"en"},{country:"Nauru",code:"NR",language:"English",langCode:"en"},{country:"Palau",code:"PW",language:"English",langCode:"en"},{country:"the Marshall Islands",code:"MH",language:"English",langCode:"en",aliases:["marshall islands"]},{country:"Micronesia",code:"FM",language:"English",langCode:"en",aliases:["federated states of micronesia"]},{country:"Egypt",code:"EG",language:"Arabic",langCode:"ar"},{country:"Libya",code:"LY",language:"Arabic",langCode:"ar"},{country:"Tunisia",code:"TN",language:"Arabic",langCode:"ar"},{country:"Algeria",code:"DZ",language:"Arabic",langCode:"ar"},{country:"Morocco",code:"MA",language:"Arabic",langCode:"ar",aliases:["maroc"]},{country:"Sudan",code:"SD",language:"Arabic",langCode:"ar"},{country:"South Sudan",code:"SS",language:"English",langCode:"en"},{country:"Mauritania",code:"MR",language:"Arabic",langCode:"ar"},{country:"Nigeria",code:"NG",language:"English",langCode:"en"},{country:"Ghana",code:"GH",language:"English",langCode:"en"},{country:"Senegal",code:"SN",language:"French",langCode:"fr",aliases:["s\xE9n\xE9gal"]},{country:"C\xF4te d'Ivoire",code:"CI",language:"French",langCode:"fr",aliases:["ivory coast"]},{country:"Mali",code:"ML",language:"French",langCode:"fr"},{country:"Burkina Faso",code:"BF",language:"French",langCode:"fr"},{country:"Niger",code:"NE",language:"French",langCode:"fr"},{country:"Guinea",code:"GN",language:"French",langCode:"fr",aliases:["guin\xE9e"]},{country:"Guinea-Bissau",code:"GW",language:"Portuguese",langCode:"pt"},{country:"Sierra Leone",code:"SL",language:"English",langCode:"en"},{country:"Liberia",code:"LR",language:"English",langCode:"en"},{country:"the Gambia",code:"GM",language:"English",langCode:"en",aliases:["gambia"]},{country:"Cabo Verde",code:"CV",language:"Portuguese",langCode:"pt",aliases:["cape verde"]},{country:"Togo",code:"TG",language:"French",langCode:"fr"},{country:"Benin",code:"BJ",language:"French",langCode:"fr",aliases:["b\xE9nin"]},{country:"Cameroon",code:"CM",language:"French",langCode:"fr",aliases:["cameroun"]},{country:"the Central African Republic",code:"CF",language:"French",langCode:"fr",aliases:["central african republic","car"]},{country:"Chad",code:"TD",language:"French",langCode:"fr",aliases:["tchad"]},{country:"Equatorial Guinea",code:"GQ",language:"Spanish",langCode:"es"},{country:"Gabon",code:"GA",language:"French",langCode:"fr"},{country:"the Republic of the Congo",code:"CG",language:"French",langCode:"fr",aliases:["congo","republic of the congo","congo-brazzaville"]},{country:"the Democratic Republic of the Congo",code:"CD",language:"French",langCode:"fr",aliases:["dr congo","drc","democratic republic of the congo","congo-kinshasa","zaire"]},{country:"S\xE3o Tom\xE9 and Pr\xEDncipe",code:"ST",language:"Portuguese",langCode:"pt",aliases:["sao tome and principe","sao tome"]},{country:"Ethiopia",code:"ET",language:"Amharic",langCode:"am"},{country:"Eritrea",code:"ER",language:"Tigrinya",langCode:"ti"},{country:"Djibouti",code:"DJ",language:"French",langCode:"fr"},{country:"Somalia",code:"SO",language:"Somali",langCode:"so"},{country:"Kenya",code:"KE",language:"English",langCode:"en"},{country:"Uganda",code:"UG",language:"English",langCode:"en"},{country:"Tanzania",code:"TZ",language:"English",langCode:"en",aliases:["united republic of tanzania"]},{country:"Rwanda",code:"RW",language:"English",langCode:"en"},{country:"Burundi",code:"BI",language:"French",langCode:"fr"},{country:"Madagascar",code:"MG",language:"French",langCode:"fr"},{country:"Mauritius",code:"MU",language:"English",langCode:"en"},{country:"the Seychelles",code:"SC",language:"English",langCode:"en",aliases:["seychelles"]},{country:"Comoros",code:"KM",language:"French",langCode:"fr"},{country:"South Africa",code:"ZA",language:"English",langCode:"en",aliases:["sa"]},{country:"Namibia",code:"NA",language:"English",langCode:"en"},{country:"Botswana",code:"BW",language:"English",langCode:"en"},{country:"Zimbabwe",code:"ZW",language:"English",langCode:"en"},{country:"Zambia",code:"ZM",language:"English",langCode:"en"},{country:"Malawi",code:"MW",language:"English",langCode:"en"},{country:"Mozambique",code:"MZ",language:"Portuguese",langCode:"pt",aliases:["mo\xE7ambique"]},{country:"Angola",code:"AO",language:"Portuguese",langCode:"pt"},{country:"Lesotho",code:"LS",language:"English",langCode:"en"},{country:"Eswatini",code:"SZ",language:"English",langCode:"en",aliases:["swaziland"]}],Ie=[{language:"English",code:"en"},{language:"Italian",code:"it",aliases:["italiano"]},{language:"Spanish",code:"es",aliases:["espa\xF1ol","espanol","castellano"]},{language:"French",code:"fr",aliases:["fran\xE7ais","francais"]},{language:"German",code:"de",aliases:["deutsch"]},{language:"Portuguese",code:"pt",aliases:["portugu\xEAs","portugues"]},{language:"Dutch",code:"nl",aliases:["nederlands","flemish"]},{language:"Swedish",code:"sv",aliases:["svenska"]},{language:"Norwegian",code:"no",aliases:["norsk"]},{language:"Danish",code:"da",aliases:["dansk"]},{language:"Icelandic",code:"is",aliases:["\xEDslenska"]},{language:"Catalan",code:"ca",aliases:["catal\xE0"]},{language:"Romanian",code:"ro",aliases:["rom\xE2n\u0103","romana"]},{language:"Polish",code:"pl",aliases:["polski"]},{language:"Czech",code:"cs",aliases:["\u010De\u0161tina","cestina"]},{language:"Slovak",code:"sk",aliases:["sloven\u010Dina"]},{language:"Slovenian",code:"sl",aliases:["sloven\u0161\u010Dina"]},{language:"Croatian",code:"hr",aliases:["hrvatski"]},{language:"Bosnian",code:"bs",aliases:["bosanski"]},{language:"Serbian",code:"sr",aliases:["\u0441\u0440\u043F\u0441\u043A\u0438"]},{language:"Montenegrin",code:"sr",aliases:["crnogorski"]},{language:"Macedonian",code:"mk",aliases:["\u043C\u0430\u043A\u0435\u0434\u043E\u043D\u0441\u043A\u0438"]},{language:"Bulgarian",code:"bg",aliases:["\u0431\u044A\u043B\u0433\u0430\u0440\u0441\u043A\u0438"]},{language:"Russian",code:"ru",aliases:["\u0440\u0443\u0441\u0441\u043A\u0438\u0439"]},{language:"Ukrainian",code:"uk",aliases:["\u0443\u043A\u0440\u0430\u0457\u043D\u0441\u044C\u043A\u0430"]},{language:"Belarusian",code:"be",aliases:["\u0431\u0435\u043B\u0430\u0440\u0443\u0441\u043A\u0430\u044F"]},{language:"Latvian",code:"lv",aliases:["latvie\u0161u"]},{language:"Lithuanian",code:"lt",aliases:["lietuvi\u0173"]},{language:"Greek",code:"el",aliases:["\u03B5\u03BB\u03BB\u03B7\u03BD\u03B9\u03BA\u03AC","ellinik\xE1"]},{language:"Albanian",code:"sq",aliases:["shqip"]},{language:"Armenian",code:"hy",aliases:["\u0570\u0561\u0575\u0565\u0580\u0565\u0576"]},{language:"Persian",code:"fa",aliases:["farsi","dari","\u0641\u0627\u0631\u0633\u06CC"]},{language:"Hindi",code:"hi",aliases:["\u0939\u093F\u0928\u094D\u0926\u0940"]},{language:"Urdu",code:"ur",aliases:["\u0627\u0631\u062F\u0648"]},{language:"Bengali",code:"bn",aliases:["bangla","\u09AC\u09BE\u0982\u09B2\u09BE"]},{language:"Nepali",code:"ne",aliases:["\u0928\u0947\u092A\u093E\u0932\u0940"]},{language:"Sinhala",code:"si",aliases:["\u0DC3\u0DD2\u0D82\u0DC4\u0DBD","sinhalese"]},{language:"Finnish",code:"fi",aliases:["suomi"]},{language:"Estonian",code:"et",aliases:["eesti"]},{language:"Hungarian",code:"hu",aliases:["magyar"]},{language:"Turkish",code:"tr",aliases:["t\xFCrk\xE7e","turkce"]},{language:"Azerbaijani",code:"az",aliases:["az\u0259rbaycan dili","azeri"]},{language:"Kazakh",code:"kk",aliases:["\u049B\u0430\u0437\u0430\u049B \u0442\u0456\u043B\u0456"]},{language:"Uzbek",code:"uz",aliases:["o'zbek"]},{language:"Kyrgyz",code:"ky",aliases:["\u043A\u044B\u0440\u0433\u044B\u0437\u0447\u0430"]},{language:"Turkmen",code:"tk",aliases:["t\xFCrkmen\xE7e"]},{language:"Arabic",code:"ar",aliases:["\u0627\u0644\u0639\u0631\u0628\u064A\u0629"]},{language:"Hebrew",code:"he",aliases:["\u05E2\u05D1\u05E8\u05D9\u05EA","ivrit"]},{language:"Amharic",code:"am",aliases:["\u12A0\u121B\u122D\u129B"]},{language:"Tigrinya",code:"ti",aliases:["\u1275\u130D\u122D\u129B"]},{language:"Chinese",code:"zh",aliases:["mandarin","\u4E2D\u6587","\u6C49\u8BED","putonghua"]},{language:"Japanese",code:"ja",aliases:["\u65E5\u672C\u8A9E","nihongo"]},{language:"Korean",code:"ko",aliases:["\uD55C\uAD6D\uC5B4"]},{language:"Thai",code:"th",aliases:["\u0E44\u0E17\u0E22"]},{language:"Vietnamese",code:"vi",aliases:["ti\u1EBFng vi\u1EC7t"]},{language:"Khmer",code:"km",aliases:["\u1781\u17D2\u1798\u17C2\u179A","cambodian"]},{language:"Lao",code:"lo",aliases:["\u0EA5\u0EB2\u0EA7"]},{language:"Burmese",code:"my",aliases:["\u1019\u103C\u1014\u103A\u1019\u102C","myanmar"]},{language:"Dzongkha",code:"dz",aliases:["\u0F62\u0FAB\u0F7C\u0F44\u0F0B\u0F41"]},{language:"Mongolian",code:"mn",aliases:["\u043C\u043E\u043D\u0433\u043E\u043B"]},{language:"Georgian",code:"ka",aliases:["\u10E5\u10D0\u10E0\u10D7\u10E3\u10DA\u10D8"]},{language:"Tajik",code:"tg",aliases:["\u0442\u043E\u04B7\u0438\u043A\u04E3"]},{language:"Malay",code:"ms",aliases:["bahasa malaysia","bahasa melayu"]},{language:"Indonesian",code:"id",aliases:["bahasa indonesia"]},{language:"Filipino",code:"fil",aliases:["tagalog","pilipino"]},{language:"Swahili",code:"sw",aliases:["kiswahili"]},{language:"Somali",code:"so",aliases:["af soomaali"]},{language:"Yoruba",code:"yo",aliases:["yor\xF9b\xE1"]},{language:"Hausa",code:"ha",aliases:["harshen hausa"]},{language:"Zulu",code:"zu",aliases:["isizulu"]},{language:"Afrikaans",code:"af"}];function O(e){return e.trim().toLowerCase()}function oe(e){if(!e)return;let a=O(e);for(let t of Ae)if(O(t.country)===a||t.aliases?.some(n=>O(n)===a))return t}function ie(e){if(!e)return;let a=O(e);for(let t of Ie)if(O(t.language)===a||t.aliases?.some(n=>O(n)===a))return t}var L=class extends Error{constructor(){super("user pressed back"),this.name="BackSignal"}},U=class extends Error{constructor(){super("user cancelled"),this.name="CancelSignal"}},Te="Include the country code with a + (e.g. +12025550123 for US, +447123456789 for UK)",se=e=>/^\+\d{8,15}$/.test(e)?void 0:Te,Ee=e=>/^[^@\s]+@[^@\s]+\.[^@\s]+$/.test(e)?void 0:"Enter a valid email",R=e=>a=>a.trim().length===0?`${e} is required`:void 0,xe=/[\u2022\u2023\u2024\u2027\u00B7\u2219\u22C5\u25CF\u25CB\u25AA\u25AB\u204E\u2217\uFE61\u25E6\u2218]/,Me="That looks like the masked \u2022\u2022\u2022\u2022\u2022 value your screen shows, not the token itself. Click the reveal/copy icon next to it and paste the real value (letters and numbers).",j=e=>xe.test(e)?Me:void 0,Ne=e=>a=>j(a)??(a.trim().length===0?`${e} is required`:void 0),Oe=e=>{let a=e.replace(/\s+/g,"");return a.length===0?"Personal access token is required":j(a)??(/^sbp_[A-Za-z0-9._~+\/=-]{20,}$/.test(a)?void 0:"Doesn't look like a valid token \u2014 it should be 'sbp_' followed by letters and numbers.")},Be="one-off, no monthly fees",re="per month";function D(e){if(!e)return!0;let a=e.trim();if(a==="")return!0;let t=a.replace(/[^\d.]/g,"");if(t==="")return/^\s*free\s*$/i.test(a);let n=parseFloat(t);return!isNaN(n)&&n===0}var Ke={id:"ai-agent",title:"AI coding agent",isApplicable:()=>!0,execute:async(e,{prompt:a,info:t})=>(t({title:"Which AI coding agent do you use?",body:`Klaudius works with two AI coding agents in your terminal \u2014 Claude Code
10
10
  (Anthropic) or Codex (OpenAI). Pick whichever you already pay for.
11
11
 
12
12
  This choice only changes which agent runs the pipeline. Everything else \u2014
13
13
  the businesses found, the websites built, the outreach sent \u2014 is identical
14
- either way. You can switch later by re-running init in a fresh folder.`}),{aiAgent:await a({type:"select",message:"Which AI coding agent will drive Klaudius?",initialValue:e.aiAgent??"claude-code",options:[{value:"claude-code",label:"Claude Code (Anthropic)"},{value:"codex",label:"Codex (OpenAI)"}]})})},Me={id:"location",title:"Location & language",isApplicable:()=>!0,execute:async(e,{prompt:a,info:t})=>{t({title:"Which country are you finding businesses in?",body:`Klaudius searches for businesses in this country, writes outreach in
14
+ either way. You can switch later by re-running init in a fresh folder.`}),{aiAgent:await a({type:"select",message:"Which AI coding agent will drive Klaudius?",initialValue:e.aiAgent??"claude-code",options:[{value:"claude-code",label:"Claude Code (Anthropic)"},{value:"codex",label:"Codex (OpenAI)"}]})})},Re={id:"location",title:"Location & language",isApplicable:()=>!0,execute:async(e,{prompt:a,info:t})=>{t({title:"Which country are you finding businesses in?",body:`Klaudius searches for businesses in this country, writes outreach in
15
15
  this country's language, and builds sites in this country's language.
16
16
  This is the country your customers are in \u2014 not necessarily where
17
17
  you live.
@@ -22,12 +22,12 @@ businesses, pick United Kingdom here.
22
22
  You can run the pipeline against more than one country from the same
23
23
  install (\`/find Barcelona\` from a UK install works fine), but
24
24
  starting with one market makes it easier to learn that market's
25
- outreach rhythm.`});let n="__other__",s=[{value:"the United Kingdom",label:"United Kingdom"},{value:"the United States",label:"United States"},{value:"Italy",label:"Italy"},{value:"Spain",label:"Spain"},{value:"France",label:"France"},{value:"Germany",label:"Germany"},{value:"Ireland",label:"Ireland"},{value:"the Netherlands",label:"Netherlands"},{value:"Belgium",label:"Belgium"},{value:"Portugal",label:"Portugal"},{value:"Switzerland",label:"Switzerland"},{value:"Austria",label:"Austria"},{value:"Canada",label:"Canada"},{value:"Australia",label:"Australia"},{value:"New Zealand",label:"New Zealand"},{value:"Mexico",label:"Mexico"},{value:"Brazil",label:"Brazil"},{value:"Sweden",label:"Sweden"},{value:"Poland",label:"Poland"},{value:n,label:"Other (type it in)"}],i=e.country??"",o=s.some(b=>b.value===i),u=await a({type:"select",message:"Which country's businesses will Klaudius search for?",initialValue:o?i:i?n:"the United Kingdom",options:s}),l;u===n?l=await a({type:"text",message:"Type the country name (any common form is fine)",placeholder:"e.g. South Africa, Greece, Brazil",initialValue:o?"":i,validate:b=>b.trim().length===0?"Country is required":void 0,note:{title:"Free-form country",body:`We'll match what you type against our country lookup (covers all
25
+ outreach rhythm.`});let n="__other__",s=[{value:"the United Kingdom",label:"United Kingdom"},{value:"the United States",label:"United States"},{value:"Italy",label:"Italy"},{value:"Spain",label:"Spain"},{value:"France",label:"France"},{value:"Germany",label:"Germany"},{value:"Ireland",label:"Ireland"},{value:"the Netherlands",label:"Netherlands"},{value:"Belgium",label:"Belgium"},{value:"Portugal",label:"Portugal"},{value:"Switzerland",label:"Switzerland"},{value:"Austria",label:"Austria"},{value:"Canada",label:"Canada"},{value:"Australia",label:"Australia"},{value:"New Zealand",label:"New Zealand"},{value:"Mexico",label:"Mexico"},{value:"Brazil",label:"Brazil"},{value:"Sweden",label:"Sweden"},{value:"Poland",label:"Poland"},{value:n,label:"Other (type it in)"}],i=e.country??"",o=s.some(C=>C.value===i),u=await a({type:"select",message:"Which country's businesses will Klaudius search for?",initialValue:o?i:i?n:"the United Kingdom",options:s}),l;u===n?l=await a({type:"text",message:"Type the country name (any common form is fine)",placeholder:"e.g. South Africa, Greece, Brazil",initialValue:o?"":i,validate:C=>C.trim().length===0?"Country is required":void 0,note:{title:"Free-form country",body:`We'll match what you type against our country lookup (covers all
26
26
  ISO 3166 sovereign states + common territories like Hong Kong and
27
27
  Puerto Rico). If we don't recognise the name, we'll ask you to type
28
28
  the 2-letter ISO country code directly on the next prompt \u2014 the
29
29
  same code Google Places uses for region biasing. Aliases like 'uk',
30
- 'usa', 'italia', 'maroc' all match.`}}):l=u;let r=te(l),d;r?d=r.code:d=(await a({type:"text",message:`What's the 2-letter ISO country code for ${l}?`,placeholder:"e.g. ID for Indonesia, ZA for South Africa, JO for Jordan",initialValue:e.countryCode??"",validate:b=>{let N=b.trim().toUpperCase();if(!/^[A-Z]{2}$/.test(N))return"Must be exactly 2 letters (ISO 3166-1 alpha-2 format)"},note:{title:`ISO code for ${l}`,body:`We didn't recognise "${l}" in our country lookup, so we need the
30
+ 'usa', 'italia', 'maroc' all match.`}}):l=u;let r=oe(l),d;r?d=r.code:d=(await a({type:"text",message:`What's the 2-letter ISO country code for ${l}?`,placeholder:"e.g. ID for Indonesia, ZA for South Africa, JO for Jordan",initialValue:e.countryCode??"",validate:C=>{let N=C.trim().toUpperCase();if(!/^[A-Z]{2}$/.test(N))return"Must be exactly 2 letters (ISO 3166-1 alpha-2 format)"},note:{title:`ISO code for ${l}`,body:`We didn't recognise "${l}" in our country lookup, so we need the
31
31
  2-letter ISO 3166-1 alpha-2 code directly. Google Places uses this
32
32
  for region biasing on every search.
33
33
 
@@ -36,14 +36,14 @@ Full list: https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2
36
36
  Quick reference for less common markets:
37
37
  Indonesia \u2192 ID Vietnam \u2192 VN Thailand \u2192 TH Egypt \u2192 EG
38
38
  Kenya \u2192 KE Nigeria \u2192 NG Pakistan \u2192 PK Iran \u2192 IR
39
- Saudi Arabia \u2192 SA Russia \u2192 RU Ukraine \u2192 UA Israel \u2192 IL`}})).trim().toUpperCase();let w=e.language??r?.language??"English",f=await a({type:"text",message:"What language should outreach + websites be written in?",placeholder:"e.g. Italian, Spanish, English",initialValue:w,validate:b=>b.trim().length===0?"Language is required":void 0,note:{title:"Outreach + website language",body:r?`Defaulting to ${w} (the usual operator-facing language
39
+ Saudi Arabia \u2192 SA Russia \u2192 RU Ukraine \u2192 UA Israel \u2192 IL`}})).trim().toUpperCase();let f=e.language??r?.language??"English",b=await a({type:"text",message:"What language should outreach + websites be written in?",placeholder:"e.g. Italian, Spanish, English",initialValue:f,validate:C=>C.trim().length===0?"Language is required":void 0,note:{title:"Outreach + website language",body:r?`Defaulting to ${f} (the usual operator-facing language
40
40
  for ${l}). Edit this if you'd rather write in something else \u2014
41
41
  e.g. an English-speaking operator running on Spain might pick "Spanish"
42
42
  to localise everything, or might pick "English" to keep their own voice.
43
43
  Klaudius will use this language for every outreach message it sends and
44
44
  every website it builds.`:`Pick the language you want every outreach message and every built
45
45
  website to be written in. If we don't recognise the language name
46
- we'll ask for the ISO language code on the next prompt.`}}),A=oe(f),I;return A?I=A.code:I=(await a({type:"text",message:`What's the ISO language code for ${f}?`,placeholder:"e.g. id for Indonesian, sw for Swahili, fil for Filipino",initialValue:e.languageCode??"",validate:b=>{let N=b.trim().toLowerCase();if(!/^[a-z]{2,3}$/.test(N))return"Must be 2 or 3 lowercase letters (ISO 639-1 or BCP 47 code)"},note:{title:`ISO code for ${f}`,body:`We didn't recognise "${f}" in our language lookup, so we need
46
+ we'll ask for the ISO language code on the next prompt.`}}),A=ie(b),I;return A?I=A.code:I=(await a({type:"text",message:`What's the ISO language code for ${b}?`,placeholder:"e.g. id for Indonesian, sw for Swahili, fil for Filipino",initialValue:e.languageCode??"",validate:C=>{let N=C.trim().toLowerCase();if(!/^[a-z]{2,3}$/.test(N))return"Must be 2 or 3 lowercase letters (ISO 639-1 or BCP 47 code)"},note:{title:`ISO code for ${b}`,body:`We didn't recognise "${b}" in our language lookup, so we need
47
47
  the ISO language code directly. Google Places uses this for response
48
48
  language, and it becomes the <html lang="..."> value on every built
49
49
  site.
@@ -51,17 +51,17 @@ site.
51
51
  Most languages have a 2-letter ISO 639-1 code. A few (Filipino \u2192
52
52
  "fil") use the 3-letter ISO 639-3 / BCP 47 code instead.
53
53
 
54
- Full list: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes`}})).trim().toLowerCase(),{country:r?r.country:l.trim(),countryCode:d,language:A?A.language:f.trim(),languageCode:I}}},Ne={id:"pricing",title:"Pricing",isApplicable:()=>!0,execute:async(e,{prompt:a})=>{let t=e.pricingTerms===se,n=t?"":e.pricing??"$999",s=e.pricingMonthly??(t?e.pricing??"":""),i=await a({type:"text",message:"What's the upfront fee you'll charge clients per site?",placeholder:"e.g. $999, \xA3799, \u20AC899 \u2014 or 0 for monthly-only billing",initialValue:n,note:{title:"Upfront fee",body:`The one-time amount charged when a client signs up. Type 0 (or
54
+ Full list: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes`}})).trim().toLowerCase(),{country:r?r.country:l.trim(),countryCode:d,language:A?A.language:b.trim(),languageCode:I}}},Le={id:"pricing",title:"Pricing",isApplicable:()=>!0,execute:async(e,{prompt:a})=>{let t=e.pricingTerms===re,n=t?"":e.pricing??"$999",s=e.pricingMonthly??(t?e.pricing??"":""),i=await a({type:"text",message:"What's the upfront fee you'll charge clients per site?",placeholder:"e.g. $999, \xA3799, \u20AC899 \u2014 or 0 for monthly-only billing",initialValue:n,note:{title:"Upfront fee",body:`The one-time amount charged when a client signs up. Type 0 (or
55
55
  leave blank) if you only want to charge a monthly fee. You can
56
56
  also add a recurring monthly fee on the next prompt \u2014 combining
57
57
  the two is fine (e.g. $499 upfront + $49/month).
58
58
 
59
59
  Use the currency that matches your clients' region. Klaudius
60
- uses this string verbatim throughout outreach.`}}),o=await a({type:"text",message:"What's the monthly fee? (optional \u2014 leave blank for one-off only)",placeholder:"e.g. $49, \xA339, \u20AC45 \u2014 or blank for none",initialValue:s,validate:w=>{if(U(i)&&U(w))return"Set an upfront fee, a monthly fee, or both \u2014 they can't both be zero."},note:{title:"Monthly fee (optional)",body:`Leave blank to charge a one-off fee only. Fill it in to charge
60
+ uses this string verbatim throughout outreach.`}}),o=await a({type:"text",message:"What's the monthly fee? (optional \u2014 leave blank for one-off only)",placeholder:"e.g. $49, \xA339, \u20AC45 \u2014 or blank for none",initialValue:s,validate:f=>{if(D(i)&&D(f))return"Set an upfront fee, a monthly fee, or both \u2014 they can't both be zero."},note:{title:"Monthly fee (optional)",body:`Leave blank to charge a one-off fee only. Fill it in to charge
61
61
  a recurring monthly fee \u2014 either on its own (if upfront was 0)
62
- or alongside the upfront fee.`}}),c=U(i),u=U(o),l,r,d;return c&&!u?(l=o.trim(),r=se,d=o.trim()):!c&&u?(l=i.trim(),r=Ee,d=void 0):(l=i.trim(),r=`upfront, then ${o.trim()}/month`,d=o.trim()),{pricing:l,pricingTerms:r,pricingMonthly:d}}},Oe={id:"outreach-enabled",title:"Automated outreach",isApplicable:()=>!0,execute:async(e,{prompt:a})=>({outreachEnabled:await a({type:"confirm",message:"Use Klaudius's automated outreach features?",initialValue:e.outreachEnabled??!0,note:{title:"Automated outreach features",body:`After finding candidates and building websites for them, Klaudius can
62
+ or alongside the upfront fee.`}}),c=D(i),u=D(o),l,r,d;return c&&!u?(l=o.trim(),r=re,d=o.trim()):!c&&u?(l=i.trim(),r=Be,d=void 0):(l=i.trim(),r=`upfront, then ${o.trim()}/month`,d=o.trim()),{pricing:l,pricingTerms:r,pricingMonthly:d}}},Fe={id:"outreach-enabled",title:"Automated outreach",isApplicable:()=>!0,execute:async(e,{prompt:a})=>({outreachEnabled:await a({type:"confirm",message:"Use Klaudius's automated outreach features?",initialValue:e.outreachEnabled??!0,note:{title:"Automated outreach features",body:`After finding candidates and building websites for them, Klaudius can
63
63
  run outreach to them automatically (email, SMS, or WhatsApp).
64
- If you'd rather handle outreach manually, you can skip this here.`}})})},Be={id:"operator-name",title:"Sign-off name",isApplicable:e=>e.outreachEnabled===!0,execute:async(e,{prompt:a})=>({name:await a({type:"text",message:"What name should sign off your outreach messages?",placeholder:"e.g. Mike Smith \u2014 or your business name if you'd rather",initialValue:e.name??e.emailFromName??"",validate:B("Name"),note:{title:"Sign-off name",body:`Klaudius signs off every outreach message and follow-up with this
64
+ If you'd rather handle outreach manually, you can skip this here.`}})})},Ge={id:"operator-name",title:"Sign-off name",isApplicable:e=>e.outreachEnabled===!0,execute:async(e,{prompt:a})=>({name:await a({type:"text",message:"What name should sign off your outreach messages?",placeholder:"e.g. Mike Smith \u2014 or your business name if you'd rather",initialValue:e.name??e.emailFromName??"",validate:R("Name"),note:{title:"Sign-off name",body:`Klaudius signs off every outreach message and follow-up with this
65
65
  name \u2014 e.g. "Cordiali saluti, Marco" in Italian, "Best, Mike" in
66
66
  English. Use your first name, your full name, or your business name \u2014
67
67
  whatever you want clients to see as the sender.
@@ -69,7 +69,7 @@ whatever you want clients to see as the sender.
69
69
  Klaudius composes the actual sign-off line at message time, picking
70
70
  natural phrasing for your language. If you'd rather pin an exact
71
71
  sign-off string instead, ask Klaudius to set it up for you once the
72
- wizard's done.`}}),signature:e.signature})},Ke={id:"channels",title:"Outreach channels & priority",isApplicable:e=>e.outreachEnabled===!0,execute:async(e,{prompt:a,info:t})=>{t({title:"Outreach channels & priority",body:`Different businesses have different contact methods publicly available \u2014 some
72
+ wizard's done.`}}),signature:e.signature})},ze={id:"channels",title:"Outreach channels & priority",isApplicable:e=>e.outreachEnabled===!0,execute:async(e,{prompt:a,info:t})=>{t({title:"Outreach channels & priority",body:`Different businesses have different contact methods publicly available \u2014 some
73
73
  list only an email, others only a phone number, others use WhatsApp as their
74
74
  primary channel. Klaudius lets you opt into multiple channels so it can reach
75
75
  more candidates, and you set a priority order for when a candidate has
@@ -83,9 +83,9 @@ candidate \u2014 so opting into multiple channels also gives you fallback covera
83
83
  when one channel doesn't work.
84
84
 
85
85
  You'll be asked to pick your first-choice channel now, then optionally a
86
- second and third. The order matters: it's the order Klaudius tries.`});let n={email:"Email",sms:"SMS (iMessage or Twilio, configured next)",whatsapp:"WhatsApp (Baileys / phone-linked device)"},s=["email","sms","whatsapp"],i=e.outreachPriority??[],o=[],c=await a({type:"select",message:"Which channel should Klaudius try FIRST for each candidate?",initialValue:i[0]??"email",options:s.map(u=>({value:u,label:n[u]}))});for(o.push(c);o.length<s.length;){let u=s.filter(f=>!o.includes(f)),l=o.length===1?"second":"third",r=o[o.length-1],d=n[r].replace(/\s*\(.*\)$/,"").toLowerCase(),w=await a({type:"select",message:`Should Klaudius use another channel as ${l} priority (for candidates where ${d} isn't viable or fails)?`,initialValue:i[o.length]??"no",options:[...u.map(f=>({value:f,label:`Yes \u2014 also use ${n[f]}`})),{value:"no",label:"No, that's all"}]});if(w==="no")break;o.push(w)}return{outreachChannels:o,outreachPriority:o}}},Re={id:"email",title:"Email setup",isApplicable:e=>e.outreachChannels?.includes("email")===!0,execute:async(e,{prompt:a,info:t})=>{t({title:"Email setup",body:`Klaudius needs an email account to send outreach FROM. This is the
86
+ second and third. The order matters: it's the order Klaudius tries.`});let n={email:"Email",sms:"SMS (iMessage or Twilio, configured next)",whatsapp:"WhatsApp (Baileys / phone-linked device)"},s=["email","sms","whatsapp"],i=e.outreachPriority??[],o=[],c=await a({type:"select",message:"Which channel should Klaudius try FIRST for each candidate?",initialValue:i[0]??"email",options:s.map(u=>({value:u,label:n[u]}))});for(o.push(c);o.length<s.length;){let u=s.filter(b=>!o.includes(b)),l=o.length===1?"second":"third",r=o[o.length-1],d=n[r].replace(/\s*\(.*\)$/,"").toLowerCase(),f=await a({type:"select",message:`Should Klaudius use another channel as ${l} priority (for candidates where ${d} isn't viable or fails)?`,initialValue:i[o.length]??"no",options:[...u.map(b=>({value:b,label:`Yes \u2014 also use ${n[b]}`})),{value:"no",label:"No, that's all"}]});if(f==="no")break;o.push(f)}return{outreachChannels:o,outreachPriority:o}}},Ve={id:"email",title:"Email setup",isApplicable:e=>e.outreachChannels?.includes("email")===!0,execute:async(e,{prompt:a,info:t})=>{t({title:"Email setup",body:`Klaudius needs an email account to send outreach FROM. This is the
87
87
  address candidates will see as the sender. Use a domain you control
88
- (your own, your business's) \u2014 not your personal address.`});let n=await a({type:"select",message:"Who hosts the email account you'll send outreach from?",initialValue:e.emailProvider??"gmail",options:[{value:"gmail",label:"Gmail"},{value:"fastmail",label:"Fastmail"},{value:"outlook",label:"Outlook / Office 365"},{value:"zoho",label:"Zoho Mail"},{value:"ionos",label:"IONOS"},{value:"custom",label:"Custom / other (enter SMTP/IMAP details manually)"}]}),s=n!=="custom"?ae[n]:void 0,i=await a({type:"text",message:"Email address to send outreach from",placeholder:"you@yourbusiness.com",initialValue:e.emailAddress??"",validate:Te}),o=s?.appPasswordHelp??ne,c=await a({type:"password",message:"Paste the app password",initialValue:e.emailPassword??"",validate:B("App password"),note:{title:"App password",body:`An app password is a separate, single-purpose password that your
88
+ (your own, your business's) \u2014 not your personal address.`});let n=await a({type:"select",message:"Who hosts the email account you'll send outreach from?",initialValue:e.emailProvider??"gmail",options:[{value:"gmail",label:"Gmail"},{value:"fastmail",label:"Fastmail"},{value:"outlook",label:"Outlook / Office 365"},{value:"zoho",label:"Zoho Mail"},{value:"ionos",label:"IONOS"},{value:"custom",label:"Custom / other (enter SMTP/IMAP details manually)"}]}),s=n!=="custom"?ne[n]:void 0,i=await a({type:"text",message:"Email address to send outreach from",placeholder:"you@yourbusiness.com",initialValue:e.emailAddress??"",validate:Ee}),o=s?.appPasswordHelp??te,c=await a({type:"password",message:"Paste the app password",initialValue:e.emailPassword??"",validate:R("App password"),note:{title:"App password",body:`An app password is a separate, single-purpose password that your
89
89
  email provider issues for third-party apps like Klaudius. It is NOT
90
90
  your normal account login password.
91
91
 
@@ -93,7 +93,7 @@ your normal account login password.
93
93
 
94
94
  Once generated, it's stored locally in this project's .env file.
95
95
  It is never sent to Klaudius's servers \u2014 only to your email
96
- provider when sending outreach.`}}),u,l,r,d,w,f;if(n==="custom"){u=await a({type:"text",message:"SMTP host (the server Klaudius connects to for sending)",placeholder:"e.g. smtp.yourprovider.com",initialValue:e.emailSmtpHost??"",validate:B("SMTP host")});let A=await a({type:"text",message:"SMTP port (usually 587 for STARTTLS or 465 for SSL)",initialValue:String(e.emailSmtpPort??587),validate:b=>/^\d+$/.test(b)?void 0:"Must be a number"});l=parseInt(A,10),r=await a({type:"text",message:"IMAP host (the server Klaudius connects to for reading replies)",placeholder:"e.g. imap.yourprovider.com",initialValue:e.emailImapHost??"",validate:B("IMAP host")});let I=await a({type:"text",message:"IMAP port (usually 993 for SSL)",initialValue:String(e.emailImapPort??993),validate:b=>/^\d+$/.test(b)?void 0:"Must be a number"});d=parseInt(I,10),w=await a({type:"text",message:"Sent folder name (so SMTP-sent messages also appear in your email client's Sent folder)",placeholder:'e.g. "Sent", "Sent Items"',initialValue:e.emailSentFolder??"Sent"}),f=await a({type:"text",message:"Inbox folder name (almost always INBOX)",initialValue:e.emailInboxFolder??"INBOX"})}else u=s.smtpHost,l=s.smtpPort,r=s.imapHost,d=s.imapPort,w=s.sentFolder,f=s.inboxFolder;return{emailProvider:n,emailAddress:i,emailPassword:c,emailFromName:e.name,emailSmtpHost:u,emailSmtpPort:l,emailImapHost:r,emailImapPort:d,emailSentFolder:w,emailInboxFolder:f}}},Le={id:"sms",title:"SMS setup",isApplicable:e=>e.outreachChannels?.includes("sms")===!0,execute:async(e,{prompt:a,info:t})=>{t({title:"SMS setup",body:`Klaudius can send SMS one of two ways:
96
+ provider when sending outreach.`}}),u,l,r,d,f,b;if(n==="custom"){u=await a({type:"text",message:"SMTP host (the server Klaudius connects to for sending)",placeholder:"e.g. smtp.yourprovider.com",initialValue:e.emailSmtpHost??"",validate:R("SMTP host")});let A=await a({type:"text",message:"SMTP port (usually 587 for STARTTLS or 465 for SSL)",initialValue:String(e.emailSmtpPort??587),validate:C=>/^\d+$/.test(C)?void 0:"Must be a number"});l=parseInt(A,10),r=await a({type:"text",message:"IMAP host (the server Klaudius connects to for reading replies)",placeholder:"e.g. imap.yourprovider.com",initialValue:e.emailImapHost??"",validate:R("IMAP host")});let I=await a({type:"text",message:"IMAP port (usually 993 for SSL)",initialValue:String(e.emailImapPort??993),validate:C=>/^\d+$/.test(C)?void 0:"Must be a number"});d=parseInt(I,10),f=await a({type:"text",message:"Sent folder name (so SMTP-sent messages also appear in your email client's Sent folder)",placeholder:'e.g. "Sent", "Sent Items"',initialValue:e.emailSentFolder??"Sent"}),b=await a({type:"text",message:"Inbox folder name (almost always INBOX)",initialValue:e.emailInboxFolder??"INBOX"})}else u=s.smtpHost,l=s.smtpPort,r=s.imapHost,d=s.imapPort,f=s.sentFolder,b=s.inboxFolder;return{emailProvider:n,emailAddress:i,emailPassword:c,emailFromName:e.name,emailSmtpHost:u,emailSmtpPort:l,emailImapHost:r,emailImapPort:d,emailSentFolder:f,emailInboxFolder:b}}},De={id:"sms",title:"SMS setup",isApplicable:e=>e.outreachChannels?.includes("sms")===!0,execute:async(e,{prompt:a,info:t})=>{t({title:"SMS setup",body:`Klaudius can send SMS one of two ways:
97
97
 
98
98
  \u2022 macOS iMessage \u2014 free, uses Messages.app on your Mac.
99
99
  Reaches other Apple users as iMessage for free. To reach
@@ -109,7 +109,7 @@ provider when sending outreach.`}}),u,l,r,d,w,f;if(n==="custom"){u=await a({type
109
109
 
110
110
  \u2022 Twilio \u2014 cross-platform, ~$0.01 per SMS. Sender is a phone
111
111
  number you buy from Twilio. Works on any OS, reaches any
112
- phone, no iPhone required. Recommended for consistent delivery.`});let n=await a({type:"select",message:"Which SMS provider?",initialValue:e.smsProvider??(process.platform==="darwin"?"imessage":"twilio"),options:[{value:"imessage",label:"macOS iMessage (free, Mac only)"},{value:"twilio",label:"Twilio (cross-platform, paid per-message \u2014 recommended)"}]}),s=await a({type:"text",message:"Your mobile number (used as a safe target for test sends so Klaudius doesn't accidentally message real candidates while you're testing)",placeholder:"+12025550123",initialValue:e.testPhone??"",validate:ie}),i={smsProvider:n,testPhone:s};return n==="twilio"&&(i.twilioAccountSid=await a({type:"text",message:"Twilio Account SID (starts with AC...)",initialValue:e.twilioAccountSid??"",validate:o=>/^AC[a-zA-Z0-9]+$/.test(o)?void 0:"Should start with 'AC'"}),i.twilioAuthToken=await a({type:"password",message:"Twilio Auth Token",initialValue:e.twilioAuthToken??"",validate:B("Twilio Auth Token")}),i.twilioPhoneNumber=await a({type:"text",message:"Twilio phone number (the number outreach will be sent FROM)",placeholder:"+15551234567",initialValue:e.twilioPhoneNumber??"",validate:ie})),i}},Fe={id:"whatsapp",title:"WhatsApp setup",isApplicable:e=>e.outreachPriority?.includes("whatsapp")===!0,execute:async(e,{prompt:a,info:t})=>{t({title:"WhatsApp setup",body:`Klaudius connects to WhatsApp as a linked device on your phone \u2014 same way
112
+ phone, no iPhone required. Recommended for consistent delivery.`});let n=await a({type:"select",message:"Which SMS provider?",initialValue:e.smsProvider??(process.platform==="darwin"?"imessage":"twilio"),options:[{value:"imessage",label:"macOS iMessage (free, Mac only)"},{value:"twilio",label:"Twilio (cross-platform, paid per-message \u2014 recommended)"}]}),s=await a({type:"text",message:"Your mobile number (used as a safe target for test sends so Klaudius doesn't accidentally message real candidates while you're testing)",placeholder:"+12025550123",initialValue:e.testPhone??"",validate:se}),i={smsProvider:n,testPhone:s};return n==="twilio"&&(i.twilioAccountSid=await a({type:"text",message:"Twilio Account SID (starts with AC...)",initialValue:e.twilioAccountSid??"",validate:o=>/^AC[a-zA-Z0-9]+$/.test(o)?void 0:"Should start with 'AC'"}),i.twilioAuthToken=await a({type:"password",message:"Twilio Auth Token",initialValue:e.twilioAuthToken??"",validate:Ne("Twilio Auth Token")}),i.twilioPhoneNumber=await a({type:"text",message:"Twilio phone number (the number outreach will be sent FROM)",placeholder:"+15551234567",initialValue:e.twilioPhoneNumber??"",validate:se})),i}},Ue={id:"whatsapp",title:"WhatsApp setup",isApplicable:e=>e.outreachPriority?.includes("whatsapp")===!0,execute:async(e,{prompt:a,info:t})=>{t({title:"WhatsApp setup",body:`Klaudius connects to WhatsApp as a linked device on your phone \u2014 same way
113
113
  WhatsApp Web works. Setup is a one-time QR scan from the WhatsApp app on
114
114
  the phone whose number you want to use. Klaudius will guide you through
115
115
  that AFTER this wizard, once npm dependencies are installed.
@@ -127,7 +127,7 @@ number unless you're comfortable with that.
127
127
 
128
128
  You'll be asked how many accounts to link and a short label for each
129
129
  (used only locally \u2014 appears in logs, in the .env file, and in this
130
- project's per-account directory under ~/.klaudius/whatsapp/).`});let n=await a({type:"select",message:"How many WhatsApp numbers do you want to link?",initialValue:String(e.whatsappAccounts?.length??1),options:[{value:"1",label:"1 number (recommended starting point)"},{value:"2",label:"2 numbers (spread load across two)"},{value:"3",label:"3 numbers"},{value:"4",label:"4 numbers"},{value:"5",label:"5 numbers (maximum)"}]}),s=parseInt(n,10),i=["primary","secondary","tertiary","quaternary","quinary"],o=[];for(let c=0;c<s;c++){let u=await a({type:"text",message:s===1?"Label for this WhatsApp account (used only locally \u2014 'primary' is fine)":`Label for WhatsApp account ${c+1} of ${s} (e.g. 'primary', 'uk-1', 'us-east')`,initialValue:e.whatsappAccounts?.[c]??i[c],validate:l=>{let r=l.trim();if(!r)return"Required";if(r.length>30)return"Too long (max 30 characters)";if(r.startsWith("-")||r.endsWith("-"))return"Can't start or end with a hyphen";if(!/^[A-Za-z0-9_-]+$/.test(r))return"Letters, digits, underscore, hyphen only (no spaces)";if(o.includes(r))return"Duplicate label"}});o.push(u.trim())}return{whatsappAccounts:o}}},Ge={id:"deploy-provider",title:"Deployment host",isApplicable:()=>!0,execute:async(e,{prompt:a,info:t})=>(t({title:"Where should Klaudius deploy the websites it builds?",body:`Every client site Klaudius builds is a static website, so it deploys
130
+ project's per-account directory under ~/.klaudius/whatsapp/).`});let n=await a({type:"select",message:"How many WhatsApp numbers do you want to link?",initialValue:String(e.whatsappAccounts?.length??1),options:[{value:"1",label:"1 number (recommended starting point)"},{value:"2",label:"2 numbers (spread load across two)"},{value:"3",label:"3 numbers"},{value:"4",label:"4 numbers"},{value:"5",label:"5 numbers (maximum)"}]}),s=parseInt(n,10),i=["primary","secondary","tertiary","quaternary","quinary"],o=[];for(let c=0;c<s;c++){let u=await a({type:"text",message:s===1?"Label for this WhatsApp account (used only locally \u2014 'primary' is fine)":`Label for WhatsApp account ${c+1} of ${s} (e.g. 'primary', 'uk-1', 'us-east')`,initialValue:e.whatsappAccounts?.[c]??i[c],validate:l=>{let r=l.trim();if(!r)return"Required";if(r.length>30)return"Too long (max 30 characters)";if(r.startsWith("-")||r.endsWith("-"))return"Can't start or end with a hyphen";if(!/^[A-Za-z0-9_-]+$/.test(r))return"Letters, digits, underscore, hyphen only (no spaces)";if(o.includes(r))return"Duplicate label"}});o.push(u.trim())}return{whatsappAccounts:o}}},He={id:"deploy-provider",title:"Deployment host",isApplicable:()=>!0,execute:async(e,{prompt:a,info:t})=>(t({title:"Where should Klaudius deploy the websites it builds?",body:`Every client site Klaudius builds is a static website, so it deploys
131
131
  cleanly to any of the hosts below \u2014 pick whichever you'd rather have
132
132
  an account with. All have a free tier that's plenty to get started.
133
133
 
@@ -138,7 +138,7 @@ an account with. All have a free tier that's plenty to get started.
138
138
 
139
139
  This only changes where sites are hosted and which credential you set
140
140
  up next. Everything else \u2014 how sites are found, built, and pitched \u2014
141
- is identical.`}),{deployProvider:await a({type:"select",message:"Which host should Klaudius deploy client sites to?",initialValue:e.deployProvider??"vercel",options:[{value:"vercel",label:"Vercel (default)"},{value:"cloudflare",label:"Cloudflare Pages"},{value:"netlify",label:"Netlify"}]})})},ze={id:"vercel",title:"Vercel deployment",isApplicable:e=>(e.deployProvider??"vercel")==="vercel",execute:async(e,{prompt:a})=>({vercelToken:await a({type:"password",message:"Paste your Vercel API token",initialValue:e.vercelToken??"",validate:n=>n.trim().length===0?"Required \u2014 without this Klaudius can't deploy generated sites":void 0,note:{title:"Vercel deployment",body:`Klaudius deploys every generated client site to Vercel. We use a
141
+ is identical.`}),{deployProvider:await a({type:"select",message:"Which host should Klaudius deploy client sites to?",initialValue:e.deployProvider??"vercel",options:[{value:"vercel",label:"Vercel (default)"},{value:"cloudflare",label:"Cloudflare Pages"},{value:"netlify",label:"Netlify"}]})})},We={id:"vercel",title:"Vercel deployment",isApplicable:e=>(e.deployProvider??"vercel")==="vercel",execute:async(e,{prompt:a})=>({vercelToken:await a({type:"password",message:"Paste your Vercel API token",initialValue:e.vercelToken??"",validate:n=>n.trim().length===0?"Required \u2014 without this Klaudius can't deploy generated sites":void 0,note:{title:"Vercel deployment",body:`Klaudius deploys every generated client site to Vercel. We use a
142
142
  Vercel API token to do this without an interactive login.
143
143
 
144
144
  How to get one (one-time, ~30 seconds):
@@ -161,7 +161,7 @@ STUCK? Open Claude (or any LLM) in another tab/app and paste:
161
161
  "I need to create a personal Vercel API token for the
162
162
  Klaudius CLI tool. Walk me through generating one at
163
163
  vercel.com/account/tokens, including which scope and
164
- expiration to choose."`}})})},Ve={id:"cloudflare",title:"Cloudflare deployment",isApplicable:e=>e.deployProvider==="cloudflare",execute:async(e,{prompt:a})=>{let t=await a({type:"password",message:"Paste your Cloudflare API token",initialValue:e.cloudflareApiToken??"",validate:s=>s.trim().length===0?"Required \u2014 without this Klaudius can't deploy generated sites":void 0,note:{title:"Cloudflare API token",body:`Klaudius deploys every generated client site to Cloudflare Pages
164
+ expiration to choose."`}})})},_e={id:"cloudflare",title:"Cloudflare deployment",isApplicable:e=>e.deployProvider==="cloudflare",execute:async(e,{prompt:a})=>{let t=await a({type:"password",message:"Paste your Cloudflare API token",initialValue:e.cloudflareApiToken??"",validate:s=>s.trim().length===0?"Required \u2014 without this Klaudius can't deploy generated sites":void 0,note:{title:"Cloudflare API token",body:`Klaudius deploys every generated client site to Cloudflare Pages
165
165
  using \`wrangler\`. It authenticates with an API token (no interactive
166
166
  login), so no browser step at deploy time.
167
167
 
@@ -198,7 +198,7 @@ Where to find it:
198
198
  the account's Workers & Pages overview page under 'Account ID'
199
199
 
200
200
  Without it, wrangler shows an interactive account picker that would
201
- stall an unattended pipeline run, so Klaudius requires it up front.`}});return{cloudflareApiToken:t,cloudflareAccountId:n.trim()}}},Ue={id:"netlify",title:"Netlify deployment",isApplicable:e=>e.deployProvider==="netlify",execute:async(e,{prompt:a})=>({netlifyAuthToken:await a({type:"password",message:"Paste your Netlify access token",initialValue:e.netlifyAuthToken??"",validate:n=>n.trim().length===0?"Required \u2014 without this Klaudius can't deploy generated sites":void 0,note:{title:"Netlify access token",body:`Klaudius deploys every generated client site to Netlify using the
201
+ stall an unattended pipeline run, so Klaudius requires it up front.`}});return{cloudflareApiToken:t,cloudflareAccountId:n.trim()}}},$e={id:"netlify",title:"Netlify deployment",isApplicable:e=>e.deployProvider==="netlify",execute:async(e,{prompt:a})=>({netlifyAuthToken:await a({type:"password",message:"Paste your Netlify access token",initialValue:e.netlifyAuthToken??"",validate:n=>n.trim().length===0?"Required \u2014 without this Klaudius can't deploy generated sites":void 0,note:{title:"Netlify access token",body:`Klaudius deploys every generated client site to Netlify using the
202
202
  Netlify CLI. It authenticates with a personal access token (no
203
203
  interactive login), so there's no browser step at deploy time.
204
204
 
@@ -221,7 +221,7 @@ STUCK? Open Claude (or any LLM) in another tab/app and paste:
221
221
  "I need to create a personal access token for the Klaudius CLI
222
222
  tool in Netlify. Walk me through generating one at
223
223
  app.netlify.com/user/applications, including which expiry to
224
- choose."`}})})},De={id:"supabase",title:"Supabase",isApplicable:()=>!0,execute:async(e,{prompt:a,info:t})=>{t({title:"Supabase setup",body:`Supabase is your CRM. It's where Klaudius records every business it
224
+ choose."`}})})},je={id:"supabase",title:"Supabase",isApplicable:()=>!0,execute:async(e,{prompt:a,info:t})=>{t({title:"Supabase setup",body:`Supabase is your CRM. It's where Klaudius records every business it
225
225
  finds, where each one sits in your funnel (gathered \u2192 built \u2192 deployed
226
226
  \u2192 outreach sent \u2192 responded), and the follow-up state for every lead.
227
227
  You can browse it at any time from the Supabase dashboard, or ask
@@ -259,7 +259,7 @@ in another tab/app and paste this prompt verbatim:
259
259
  Settings \u2192 Data API \u2192 'API URL'
260
260
 
261
261
  It looks like https://xxxx.supabase.co. Click to copy and paste
262
- below.`}})).trim().replace(/\/rest\/v1\/?$/i,"").replace(/\/$/,""),i=s.match(/^https:\/\/([a-z0-9]+)\.supabase\.co/i)?.[1]??"",c=(await a({type:"password",message:"Paste the Supabase secret key (sb_secret_\u2026)",initialValue:e.supabaseServiceKey??"",validate:r=>{let d=r.trim();if(d.length<20)return"Looks too short";if(d.startsWith("sb_publishable_"))return"That's the publishable key. Klaudius needs the 'sb_secret_\u2026' key on the same page (different row, below the publishable one).";if(!d.startsWith("sb_secret_")&&!d.startsWith("eyJ"))return"Doesn't look like a Supabase secret key. Expected 'sb_secret_\u2026' (or a legacy JWT starting with 'eyJ\u2026' on older projects)."},note:{title:"Secret key",body:`Open this exact page:
262
+ below.`}})).trim().replace(/\/rest\/v1\/?$/i,"").replace(/\/$/,""),i=s.match(/^https:\/\/([a-z0-9]+)\.supabase\.co/i)?.[1]??"",c=(await a({type:"password",message:"Paste the Supabase secret key (sb_secret_\u2026)",initialValue:e.supabaseServiceKey??"",validate:r=>{let d=r.trim(),f=j(d);if(f)return f;if(d.length<20)return"Looks too short";if(d.startsWith("sb_publishable_"))return"That's the publishable key. Klaudius needs the 'sb_secret_\u2026' key on the same page (different row, below the publishable one).";if(!d.startsWith("sb_secret_")&&!d.startsWith("eyJ"))return"Doesn't look like a Supabase secret key. Expected 'sb_secret_\u2026' (or a legacy JWT starting with 'eyJ\u2026' on older projects)."},note:{title:"Secret key",body:`Open this exact page:
263
263
  https://supabase.com/dashboard/project/${i}/settings/api-keys
264
264
 
265
265
  Under 'Secret keys', find the row whose value starts with
@@ -271,7 +271,7 @@ are client-side keys with no write permissions).
271
271
  Don't confuse this page with 'Edge Functions \u2192 Secrets' in the
272
272
  left sidebar \u2014 that's an unrelated feature (env vars for Edge
273
273
  Functions). The page you want is Settings (gear icon, bottom
274
- of the left sidebar) \u2192 API Keys.`}})).replace(/\s+/g,""),l=(await a({type:"password",message:"Paste the Supabase personal access token",initialValue:e.supabasePat??"",validate:r=>r.trim().startsWith("sbp_")?void 0:"Should start with 'sbp_'",note:{title:"Personal access token",body:`This is a separate credential from the secret key above \u2014 it's an
274
+ of the left sidebar) \u2192 API Keys.`}})).replace(/\s+/g,""),l=(await a({type:"password",message:"Paste the Supabase personal access token",initialValue:e.supabasePat??"",validate:Oe,note:{title:"Personal access token",body:`This is a separate credential from the secret key above \u2014 it's an
275
275
  ACCOUNT-wide token (not project-scoped) used by the Supabase MCP and
276
276
  by Klaudius's schema migration.
277
277
 
@@ -281,7 +281,7 @@ Open this exact page:
281
281
  Click 'Generate new token', name it 'Klaudius', and set the
282
282
  expiration to 'Never' (recommended \u2014 saves you having to rotate
283
283
  it later). Copy the value (starts with 'sbp_') and paste it
284
- below.`}})).replace(/\s+/g,"");return{supabaseUrl:s,supabaseServiceKey:c,supabasePat:l,supabaseProjectRef:i}}},He={id:"google-places",title:"Google Places API",isApplicable:()=>!0,execute:async(e,{prompt:a})=>({googlePlacesApiKey:await a({type:"password",message:"Paste your Google Places API key",placeholder:"AIzaSy\u2026",initialValue:e.googlePlacesApiKey??"",validate:n=>n.trim().length===0?"Required \u2014 without this Klaudius can't find candidates":void 0,note:{title:"Google Places API key",body:`Klaudius's /find skill queries Google's Places API to discover businesses
284
+ below.`}})).replace(/\s+/g,"");return{supabaseUrl:s,supabaseServiceKey:c,supabasePat:l,supabaseProjectRef:i}}},qe={id:"google-places",title:"Google Places API",isApplicable:()=>!0,execute:async(e,{prompt:a})=>({googlePlacesApiKey:await a({type:"password",message:"Paste your Google Places API key",placeholder:"AIzaSy\u2026",initialValue:e.googlePlacesApiKey??"",validate:n=>n.trim().length===0?"Required \u2014 without this Klaudius can't find candidates":void 0,note:{title:"Google Places API key",body:`Klaudius's /find skill queries Google's Places API to discover businesses
285
285
  without websites in your target region. Without a key, the pipeline has
286
286
  no source of leads \u2014 so this is required.
287
287
 
@@ -317,13 +317,13 @@ STUCK? Open Claude (or any LLM) in another tab/app and paste this prompt:
317
317
  "I need a Google Places API (New) key for a CLI tool called
318
318
  Klaudius. Walk me through claiming the $300 Google Cloud free trial
319
319
  and getting the API key Google auto-generates after enabling
320
- Places API (New), including any signup gotchas."`}})})},We={id:"telegram",title:"Telegram (optional)",isApplicable:()=>!0,clearOnSkip:["telegramBotToken","telegramChatId"],execute:async(e,{prompt:a})=>{if(!await a({type:"confirm",message:"Set up Telegram notifications? (sends a ping when outreach lands)",initialValue:!!e.telegramBotToken,note:{title:"Telegram notifications (optional)",body:`Klaudius can ping a Telegram chat when outreach is sent or when a
320
+ Places API (New), including any signup gotchas."`}})})},Ye={id:"telegram",title:"Telegram (optional)",isApplicable:()=>!0,clearOnSkip:["telegramBotToken","telegramChatId"],execute:async(e,{prompt:a})=>{if(!await a({type:"confirm",message:"Set up Telegram notifications? (sends a ping when outreach lands)",initialValue:!!e.telegramBotToken,note:{title:"Telegram notifications (optional)",body:`Klaudius can ping a Telegram chat when outreach is sent or when a
321
321
  candidate replies. This is OPTIONAL \u2014 skip it if you'd rather check
322
322
  the Supabase dashboard manually.
323
323
 
324
324
  If you say yes, you'll need a Telegram bot token (created via
325
325
  @BotFather, ~30 seconds) and your chat ID (your own user ID, for
326
- personal pings). The next two prompts walk you through both.`}}))return{telegramBotToken:void 0,telegramChatId:void 0};let n=await a({type:"password",message:"Paste your Telegram bot token",initialValue:e.telegramBotToken??"",validate:B("Bot token"),note:{title:"Bot token",body:`Telegram lets you create personal bots in ~30 seconds. Klaudius
326
+ personal pings). The next two prompts walk you through both.`}}))return{telegramBotToken:void 0,telegramChatId:void 0};let n=await a({type:"password",message:"Paste your Telegram bot token",initialValue:e.telegramBotToken??"",validate:R("Bot token"),note:{title:"Bot token",body:`Telegram lets you create personal bots in ~30 seconds. Klaudius
327
327
  uses a bot to send you private notifications.
328
328
 
329
329
  How to create one:
@@ -354,5 +354,5 @@ any messages your bot has received. To make that work:
354
354
  If the chat starts with a 'Start' button, tap that first,
355
355
  THEN send 'hi'. /start alone doesn't always show up.
356
356
  3. Press Enter below \u2014 Klaudius will detect the chat ID for
357
- you.`}});let r=await ee({botToken:n});if(r.ok&&r.chatId)s=r.chatId;else if(r.reason==="no_messages")o="No messages from you to your bot have been picked up yet.",c="no_messages";else if(r.reason==="network")o=r.message??"Could not reach Telegram.",c="network";else throw new Error(`Telegram chat ID auto-detect failed: ${r.message??"unknown error"}`)}return{telegramBotToken:n,telegramChatId:s}}},x=[xe,Me,Ne,Oe,Be,Ke,Re,Le,Fe,Ge,ze,Ve,Ue,De,He,We];import{Box as re,Text as _e}from"ink";import{jsx as le,jsxs as qe}from"react/jsx-runtime";var $e={pending:"\u25CB",current:"\u25C9",done:"\u2713",skipped:"\xB7"},je={pending:void 0,current:"cyan",done:"green",skipped:void 0};function ue({items:e}){return le(re,{flexDirection:"column",width:28,flexShrink:0,children:e.map(a=>{let t=a.status==="skipped"||a.status==="pending";return le(re,{children:qe(_e,{color:je[a.status],bold:a.status==="current",dimColor:t&&a.status!=="current",children:[$e[a.status]," ",a.title]})},a.id)})})}import{useEffect as Ye,useState as ce}from"react";import{Box as j,Text as H,useInput as Ze}from"ink";import Je from"ink-text-input";import{jsx as F,jsxs as q}from"react/jsx-runtime";function de({spec:e,masked:a,onSubmit:t,onBack:n}){let[s,i]=ce(typeof e.initialValue=="string"?e.initialValue:""),[o,c]=ce(null);Ye(()=>(y("TextPromptUI:mount",{masked:a,message:e.message.slice(0,60),initial:typeof e.initialValue=="string"?e.initialValue.slice(0,30):null}),()=>{y("TextPromptUI:unmount")}),[a,e.message,e.initialValue]),Ze((l,r)=>{y("TextPromptUI:useInput fired",{input:l,ctrl:r.ctrl,escape:r.escape,return:r.return}),r.escape&&n()});let u=l=>{y("TextPromptUI:handleSubmit",{raw:l.slice(0,30)});let r=l;if(e.validate){let d=e.validate(r);if(d){y("TextPromptUI:validate failed",{err:d}),c(d);return}}c(null),t(r)};return q(j,{flexDirection:"column",children:[q(H,{children:[F(H,{color:"cyan",children:"?"})," ",e.message]}),q(j,{children:[F(H,{color:"green",children:"\u203A "}),F(Je,{value:s,onChange:i,onSubmit:u,placeholder:e.placeholder,mask:a?"\u2022":void 0})]}),o&&F(j,{marginTop:0,children:F(H,{color:"red",children:o})})]})}import{useState as Xe}from"react";import{Box as ge,Text as Y,useInput as Qe}from"ink";import{jsx as pe,jsxs as Z}from"react/jsx-runtime";function he({spec:e,onSubmit:a,onBack:t}){let n=e.options??[],s=typeof e.initialValue=="string"?Math.max(0,n.findIndex(c=>c.value===e.initialValue)):0,[i,o]=Xe(s===-1?0:s);return Qe((c,u)=>{if(u.escape)t();else if(u.upArrow)o(l=>(l-1+n.length)%n.length);else if(u.downArrow)o(l=>(l+1)%n.length);else if(u.return){let l=n[i];l&&a(l.value)}}),Z(ge,{flexDirection:"column",children:[Z(Y,{children:[pe(Y,{color:"cyan",children:"?"})," ",e.message]}),pe(ge,{flexDirection:"column",marginTop:0,children:n.map((c,u)=>{let l=u===i;return Z(Y,{color:l?"cyan":void 0,bold:l,children:[l?"\u25CF ":"\u25CB ",c.label]},c.value)})})]})}import{useState as ea}from"react";import{Box as me,Text as G,useInput as aa}from"ink";import{jsx as ye,jsxs as z}from"react/jsx-runtime";function fe({spec:e,onSubmit:a,onBack:t}){let[n,s]=ea(typeof e.initialValue=="boolean"?e.initialValue:!0);return aa((i,o)=>{o.escape?t():o.leftArrow||o.rightArrow?s(c=>!c):i==="y"||i==="Y"?s(!0):i==="n"||i==="N"?s(!1):o.return&&a(n)}),z(me,{flexDirection:"column",children:[z(G,{children:[ye(G,{color:"cyan",children:"?"})," ",e.message]}),z(me,{marginTop:0,children:[z(G,{color:n?"cyan":void 0,bold:n,children:[n?"\u25CF ":"\u25CB ","Yes"]}),ye(G,{children:" "}),z(G,{color:n?void 0:"cyan",bold:!n,children:[n?"\u25CB ":"\u25CF ","No"]})]})]})}import{Box as be,Text as Ce}from"ink";import{jsx as J,jsxs as na}from"react/jsx-runtime";function X({title:e,body:a}){let t=a.split(`
358
- `);return na(be,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,children:[J(Ce,{color:"cyan",bold:!0,children:e}),J(be,{flexDirection:"column",marginTop:0,children:t.map((n,s)=>J(Ce,{dimColor:!1,children:n.length===0?" ":n},s))})]})}import{jsx as p,jsxs as V}from"react/jsx-runtime";function qa({defaults:e,onComplete:a,onlySection:t,banner:n}){let{exit:s}=ia(),i=Q({...e}),o=Q(new Map),[,c]=M(0),u=()=>c(h=>h+1),[l,r]=M(null),[d,w]=M(null),[f,A]=M([]),[I,b]=M(null),[N,we]=M(!1),[W,Se]=M({current:0,total:0}),K=()=>{let h=o.current;for(let C of x){let $=C.isApplicable(i.current),g=h.get(C.id);$?t&&C.id!==t?g!=="current"&&h.set(C.id,"done"):(g==="skipped"||!g)&&h.set(C.id,"pending"):h.set(C.id,"skipped")}};o.current.size===0&&K();let _=Q(!1);ta(()=>{if(y("WizardApp:useEffect fired",{startedAlready:_.current}),_.current){y("WizardApp:useEffect returning early (startedRef true)");return}_.current=!0,y("WizardApp:orchestrator starting");let h=0,C=g=>{let P=++h;return y("orchestrator:promptFn called",{id:P,type:g.type,message:g.message.slice(0,60)}),b(null),new Promise((S,m)=>{w({id:P,spec:g,resolve:T=>{y("orchestrator:prompt resolved",{id:P,type:g.type,value:typeof T=="string"?T.slice(0,30):T}),S(T)},reject:T=>{y("orchestrator:prompt rejected",{id:P,reason:T.message}),m(T)}})})},$=g=>{A(P=>[...P,g])};return(async()=>{try{let g=t?x.filter(m=>m.id===t):x,P=()=>g.filter(m=>m.isApplicable(i.current)).length,S=0;for(;S<g.length;){let m=g[S];if(!m.isApplicable(i.current)){o.current.set(m.id,"skipped"),S++,K(),u();continue}A([]);for(let k of x)k.id===m.id?o.current.set(k.id,"current"):o.current.get(k.id)==="current"&&o.current.set(k.id,"pending");r(m.id);let T=g.slice(0,S+1).filter(k=>k.isApplicable(i.current)).length;Se({current:T,total:P()}),u();try{let k=await m.execute(i.current,{prompt:C,info:$});i.current={...i.current,...k},o.current.set(m.id,"done"),K(),S++}catch(k){if(k instanceof L){if(t&&m.clearOnSkip){for(let ve of m.clearOnSkip)i.current[ve]=void 0;o.current.set(m.id,"skipped"),K(),S++;continue}if(t)continue;o.current.set(m.id,"pending");let R=S-1;for(;R>=0&&!g[R].isApplicable(i.current);)R--;R<0||(S=R,o.current.set(g[S].id,"pending")),K(),u();continue}throw k}}y("orchestrator:all sections done, calling onComplete + exit"),we(!0),w(null),r(null),u(),await new Promise(m=>setTimeout(m,200)),a(i.current),s()}catch(g){y("orchestrator:caught error",{name:g?.name,message:g?.message}),g instanceof D&&(s(),process.exit(0));let P=g instanceof Error?g.message:String(g);b(`Setup error: ${P}`),u()}})(),()=>{y("WizardApp:useEffect cleanup ran (component unmounting)")}},[s,a]),sa((h,C)=>{y("WizardApp:useInput fired",{input:h,ctrl:C.ctrl,escape:C.escape,return:C.return}),C.ctrl&&h==="c"&&(y("WizardApp:Ctrl+C \u2192 exiting"),s(),process.exit(0))});let ke=oa(()=>x.map(h=>({id:h.id,title:h.title,status:o.current.get(h.id)??"pending"})),[l,N,I]);return V(v,{flexDirection:"column",paddingY:1,children:[V(v,{marginBottom:1,children:[p(E,{bold:!0,color:"cyan",children:"Klaudius setup"}),p(E,{dimColor:!0,children:" \xB7 "}),p(E,{dimColor:!0,children:W.total>0?`Step ${W.current} of ${W.total}`:"Loading\u2026"})]}),V(v,{children:[p(ue,{items:ke}),V(v,{flexDirection:"column",flexGrow:1,marginLeft:2,children:[n&&V(v,{marginBottom:1,borderStyle:"round",borderColor:"red",paddingX:1,flexDirection:"column",children:[p(E,{color:"red",bold:!0,children:"\u26A0 Heads up"}),p(E,{children:n})]}),!t&&l!==null&&l!=="ai-agent"&&p(v,{marginBottom:1,children:p(E,{color:"green",children:"Nothing here is permanent, you can customize any of this later."})}),f.map((h,C)=>p(v,{marginBottom:1,children:p(X,{title:h.title,body:h.body})},C)),d?.spec.note&&p(v,{marginBottom:1,children:p(X,{title:d.spec.note.title,body:d.spec.note.body})}),d&&la(d),I&&p(v,{marginTop:1,children:p(E,{color:"red",children:I})}),N&&p(v,{marginTop:1,children:p(E,{color:"green",bold:!0,children:"\u2713 Setup complete. Continuing\u2026"})})]})]}),p(v,{marginTop:1,children:p(E,{dimColor:!0,children:ra(t,l)})})]})}function ra(e,a){if(e){let t=x.find(n=>n.id===a);return t?.clearOnSkip&&t.clearOnSkip.length>0?"\u21B5 confirm esc skip this section ctrl-c cancel":"\u21B5 confirm ctrl-c cancel"}return"\u21B5 confirm esc back to previous section ctrl-c cancel"}function la(e){let a=n=>e.resolve(n),t=()=>e.reject(new L);switch(e.spec.type){case"text":case"password":return p(de,{spec:e.spec,masked:e.spec.type==="password",onSubmit:a,onBack:t},e.id);case"select":return p(he,{spec:e.spec,onSubmit:a,onBack:t},e.id);case"confirm":return p(fe,{spec:e.spec,onSubmit:a,onBack:t},e.id)}}export{qa as WizardApp};
357
+ you.`}});let r=await ae({botToken:n});if(r.ok&&r.chatId)s=r.chatId;else if(r.reason==="no_messages")o="No messages from you to your bot have been picked up yet.",c="no_messages";else if(r.reason==="network")o=r.message??"Could not reach Telegram.",c="network";else throw new Error(`Telegram chat ID auto-detect failed: ${r.message??"unknown error"}`)}return{telegramBotToken:n,telegramChatId:s}}},x=[Ke,Re,Le,Fe,Ge,ze,Ve,De,Ue,He,We,_e,$e,je,qe,Ye];import{Box as le,Text as Ze}from"ink";import{jsx as ue,jsxs as Qe}from"react/jsx-runtime";var Je={pending:"\u25CB",current:"\u25C9",done:"\u2713",skipped:"\xB7"},Xe={pending:void 0,current:"cyan",done:"green",skipped:void 0};function ce({items:e}){return ue(le,{flexDirection:"column",width:28,flexShrink:0,children:e.map(a=>{let t=a.status==="skipped"||a.status==="pending";return ue(le,{children:Qe(Ze,{color:Xe[a.status],bold:a.status==="current",dimColor:t&&a.status!=="current",children:[Je[a.status]," ",a.title]})},a.id)})})}import{useEffect as ea,useState as de}from"react";import{Box as q,Text as H,useInput as aa}from"ink";import na from"ink-text-input";import{jsx as F,jsxs as Y}from"react/jsx-runtime";function ge({spec:e,masked:a,onSubmit:t,onBack:n}){let[s,i]=de(typeof e.initialValue=="string"?e.initialValue:""),[o,c]=de(null);ea(()=>(y("TextPromptUI:mount",{masked:a,message:e.message.slice(0,60),initial:typeof e.initialValue=="string"?e.initialValue.slice(0,30):null}),()=>{y("TextPromptUI:unmount")}),[a,e.message,e.initialValue]),aa((l,r)=>{y("TextPromptUI:useInput fired",{input:l,ctrl:r.ctrl,escape:r.escape,return:r.return}),r.escape&&n()});let u=l=>{y("TextPromptUI:handleSubmit",{raw:l.slice(0,30)});let r=l;if(e.validate){let d=e.validate(r);if(d){y("TextPromptUI:validate failed",{err:d}),c(d);return}}c(null),t(r)};return Y(q,{flexDirection:"column",children:[Y(H,{children:[F(H,{color:"cyan",children:"?"})," ",e.message]}),Y(q,{children:[F(H,{color:"green",children:"\u203A "}),F(na,{value:s,onChange:i,onSubmit:u,placeholder:e.placeholder,mask:a?"\u2022":void 0})]}),o&&F(q,{marginTop:0,children:F(H,{color:"red",children:o})})]})}import{useState as ta}from"react";import{Box as pe,Text as Z,useInput as oa}from"ink";import{jsx as he,jsxs as J}from"react/jsx-runtime";function me({spec:e,onSubmit:a,onBack:t}){let n=e.options??[],s=typeof e.initialValue=="string"?Math.max(0,n.findIndex(c=>c.value===e.initialValue)):0,[i,o]=ta(s===-1?0:s);return oa((c,u)=>{if(u.escape)t();else if(u.upArrow)o(l=>(l-1+n.length)%n.length);else if(u.downArrow)o(l=>(l+1)%n.length);else if(u.return){let l=n[i];l&&a(l.value)}}),J(pe,{flexDirection:"column",children:[J(Z,{children:[he(Z,{color:"cyan",children:"?"})," ",e.message]}),he(pe,{flexDirection:"column",marginTop:0,children:n.map((c,u)=>{let l=u===i;return J(Z,{color:l?"cyan":void 0,bold:l,children:[l?"\u25CF ":"\u25CB ",c.label]},c.value)})})]})}import{useState as ia}from"react";import{Box as ye,Text as G,useInput as sa}from"ink";import{jsx as fe,jsxs as z}from"react/jsx-runtime";function be({spec:e,onSubmit:a,onBack:t}){let[n,s]=ia(typeof e.initialValue=="boolean"?e.initialValue:!0);return sa((i,o)=>{o.escape?t():o.leftArrow||o.rightArrow?s(c=>!c):i==="y"||i==="Y"?s(!0):i==="n"||i==="N"?s(!1):o.return&&a(n)}),z(ye,{flexDirection:"column",children:[z(G,{children:[fe(G,{color:"cyan",children:"?"})," ",e.message]}),z(ye,{marginTop:0,children:[z(G,{color:n?"cyan":void 0,bold:n,children:[n?"\u25CF ":"\u25CB ","Yes"]}),fe(G,{children:" "}),z(G,{color:n?void 0:"cyan",bold:!n,children:[n?"\u25CB ":"\u25CF ","No"]})]})]})}import{Box as Ce,Text as we}from"ink";import{jsx as X,jsxs as ra}from"react/jsx-runtime";function Q({title:e,body:a}){let t=a.split(`
358
+ `);return ra(Ce,{flexDirection:"column",borderStyle:"round",borderColor:"gray",paddingX:1,children:[X(we,{color:"cyan",bold:!0,children:e}),X(Ce,{flexDirection:"column",marginTop:0,children:t.map((n,s)=>X(we,{dimColor:!1,children:n.length===0?" ":n},s))})]})}import{jsx as p,jsxs as V}from"react/jsx-runtime";function Qa({defaults:e,onComplete:a,onlySection:t,banner:n}){let{exit:s}=ca(),i=ee({...e}),o=ee(new Map),[,c]=M(0),u=()=>c(h=>h+1),[l,r]=M(null),[d,f]=M(null),[b,A]=M([]),[I,C]=M(null),[N,Se]=M(!1),[W,ke]=M({current:0,total:0}),B=()=>{let h=o.current;for(let w of x){let $=w.isApplicable(i.current),g=h.get(w.id);$?t&&w.id!==t?g!=="current"&&h.set(w.id,"done"):(g==="skipped"||!g)&&h.set(w.id,"pending"):h.set(w.id,"skipped")}};o.current.size===0&&B();let _=ee(!1);la(()=>{if(y("WizardApp:useEffect fired",{startedAlready:_.current}),_.current){y("WizardApp:useEffect returning early (startedRef true)");return}_.current=!0,y("WizardApp:orchestrator starting");let h=0,w=g=>{let P=++h;return y("orchestrator:promptFn called",{id:P,type:g.type,message:g.message.slice(0,60)}),C(null),new Promise((S,m)=>{f({id:P,spec:g,resolve:T=>{y("orchestrator:prompt resolved",{id:P,type:g.type,value:typeof T=="string"?T.slice(0,30):T}),S(T)},reject:T=>{y("orchestrator:prompt rejected",{id:P,reason:T.message}),m(T)}})})},$=g=>{A(P=>[...P,g])};return(async()=>{try{let g=t?x.filter(m=>m.id===t):x,P=()=>g.filter(m=>m.isApplicable(i.current)).length,S=0;for(;S<g.length;){let m=g[S];if(!m.isApplicable(i.current)){o.current.set(m.id,"skipped"),S++,B(),u();continue}A([]);for(let k of x)k.id===m.id?o.current.set(k.id,"current"):o.current.get(k.id)==="current"&&o.current.set(k.id,"pending");r(m.id);let T=g.slice(0,S+1).filter(k=>k.isApplicable(i.current)).length;ke({current:T,total:P()}),u();try{let k=await m.execute(i.current,{prompt:w,info:$});i.current={...i.current,...k},o.current.set(m.id,"done"),B(),S++}catch(k){if(k instanceof L){if(t&&m.clearOnSkip){for(let Pe of m.clearOnSkip)i.current[Pe]=void 0;o.current.set(m.id,"skipped"),B(),S++;continue}if(t)continue;o.current.set(m.id,"pending");let K=S-1;for(;K>=0&&!g[K].isApplicable(i.current);)K--;K<0||(S=K,o.current.set(g[S].id,"pending")),B(),u();continue}throw k}}y("orchestrator:all sections done, calling onComplete + exit"),Se(!0),f(null),r(null),u(),await new Promise(m=>setTimeout(m,200)),a(i.current),s()}catch(g){y("orchestrator:caught error",{name:g?.name,message:g?.message}),g instanceof U&&(s(),process.exit(0));let P=g instanceof Error?g.message:String(g);C(`Setup error: ${P}`),u()}})(),()=>{y("WizardApp:useEffect cleanup ran (component unmounting)")}},[s,a]),da((h,w)=>{y("WizardApp:useInput fired",{input:h,ctrl:w.ctrl,escape:w.escape,return:w.return}),w.ctrl&&h==="c"&&(y("WizardApp:Ctrl+C \u2192 exiting"),s(),process.exit(0))});let ve=ua(()=>x.map(h=>({id:h.id,title:h.title,status:o.current.get(h.id)??"pending"})),[l,N,I]);return V(v,{flexDirection:"column",paddingY:1,children:[V(v,{marginBottom:1,children:[p(E,{bold:!0,color:"cyan",children:"Klaudius setup"}),p(E,{dimColor:!0,children:" \xB7 "}),p(E,{dimColor:!0,children:W.total>0?`Step ${W.current} of ${W.total}`:"Loading\u2026"})]}),V(v,{children:[p(ce,{items:ve}),V(v,{flexDirection:"column",flexGrow:1,marginLeft:2,children:[n&&V(v,{marginBottom:1,borderStyle:"round",borderColor:"red",paddingX:1,flexDirection:"column",children:[p(E,{color:"red",bold:!0,children:"\u26A0 Heads up"}),p(E,{children:n})]}),!t&&l!==null&&l!=="ai-agent"&&p(v,{marginBottom:1,children:p(E,{color:"green",children:"Nothing here is permanent, you can customize any of this later."})}),b.map((h,w)=>p(v,{marginBottom:1,children:p(Q,{title:h.title,body:h.body})},w)),d?.spec.note&&p(v,{marginBottom:1,children:p(Q,{title:d.spec.note.title,body:d.spec.note.body})}),d&&pa(d),I&&p(v,{marginTop:1,children:p(E,{color:"red",children:I})}),N&&p(v,{marginTop:1,children:p(E,{color:"green",bold:!0,children:"\u2713 Setup complete. Continuing\u2026"})})]})]}),p(v,{marginTop:1,children:p(E,{dimColor:!0,children:ga(t,l)})})]})}function ga(e,a){if(e){let t=x.find(n=>n.id===a);return t?.clearOnSkip&&t.clearOnSkip.length>0?"\u21B5 confirm esc skip this section ctrl-c cancel":"\u21B5 confirm ctrl-c cancel"}return"\u21B5 confirm esc back to previous section ctrl-c cancel"}function pa(e){let a=n=>e.resolve(n),t=()=>e.reject(new L);switch(e.spec.type){case"text":case"password":return p(ge,{spec:e.spec,masked:e.spec.type==="password",onSubmit:a,onBack:t},e.id);case"select":return p(me,{spec:e.spec,onSubmit:a,onBack:t},e.id);case"confirm":return p(be,{spec:e.spec,onSubmit:a,onBack:t},e.id)}}export{Qa as WizardApp};
package/dist/bin.js CHANGED
@@ -1,79 +1,79 @@
1
1
  #!/usr/bin/env node
2
- import{a as Q,b as je,c as Ke,d as P,f as He,g as Fe}from"./chunk-SZ4KCTSL.js";import{a as le,b as Ve,c as Ge,d as ce,e as Be,i as Ye}from"./chunk-ZTT5HVYU.js";import{Command as hs}from"commander";import{spawn as Vt}from"child_process";import _ from"picocolors";function G(){let e=process.version,n=/^v(\d+)\.(\d+)\.(\d+)/.exec(e);if(!n)return{ok:!1,message:`Could not parse the Node.js version string ("${e}"). Klaudius requires Node.js 22.15 or newer \u2014 install from https://nodejs.org/.`};let o=parseInt(n[1],10),t=parseInt(n[2],10),i=parseInt(n[3],10),a=`${o}.${t}.${i}`;return o<22||o===22&&t<15?{ok:!1,version:a,major:o,minor:t,message:`Your installed Node.js is ${a}. Klaudius requires Node.js 22.15 or newer (the dependency installer relies on the --use-system-ca flag, which was added in 22.15 to handle Windows machines where antivirus or corporate-proxy software MITMs HTTPS). Install a newer Node.js from https://nodejs.org/ \u2014 after installing, close every Terminal window, open a new one, then re-run klaudius.`}:{ok:!0,version:a,major:o,minor:t}}import{spawn as jt}from"child_process";var oe=3,de=10,Kt=[["python3"],["python"],["py","-3"]];async function Te(){for(let e of Kt){let n=await Ft(e[0],[...e.slice(1),"--version"]),o=(n.stdout+n.stderr).trim();if(/Python was not found/i.test(o)||n.code!==0)continue;let t=/Python\s+(\d+)\.(\d+)(?:\.(\d+))?/.exec(o);if(!t)continue;let i=parseInt(t[1],10),a=parseInt(t[2],10),l=t[3]?`${i}.${a}.${t[3]}`:`${i}.${a}`;return{command:[...e],version:l,major:i,minor:a}}return null}async function Z(){let e=Ht(),n=await Te();if(!n){let l=process.platform==="win32"?` On Windows the \`python3\` / \`python\` commands are often the Microsoft Store placeholder, not a real interpreter \u2014 install from ${e} (tick "Add python.exe to PATH"), or disable the alias under Settings \u2192 Apps \u2192 Advanced app settings \u2192 App execution aliases.`:"";return{ok:!1,message:`Python ${oe}.${de}+ is not installed (or not on PATH). Install it from ${e}.`+l}}let{command:o,version:t,major:i,minor:a}=n;return i<oe||i===oe&&a<de?{ok:!1,version:t,major:i,minor:a,command:o,message:`Your installed Python is ${t}. Klaudius needs Python ${oe}.${de} or newer (the pipeline depends on packages that only ship wheels for ${oe}.${de}+). Install a newer Python from ${e} \u2014 it lives alongside your existing Python, nothing breaks. After installing, close every Terminal window, open a new one, then re-run klaudius.`}:{ok:!0,version:t,major:i,minor:a,command:o}}function Ht(){switch(process.platform){case"win32":return"https://www.python.org/downloads/windows/";case"darwin":return"https://www.python.org/downloads/macos/";default:return"https://www.python.org/downloads/"}}function Ft(e,n){return new Promise(o=>{let t=jt(e,n,{stdio:["ignore","pipe","pipe"],shell:!1}),i="",a="";t.stdout?.on("data",l=>{i+=l.toString()}),t.stderr?.on("data",l=>{a+=l.toString()}),t.on("close",l=>o({code:l??1,stdout:i,stderr:a})),t.on("error",()=>o({code:1,stdout:i,stderr:a}))})}var We=(process.env.KLAUDIUS_API_URL??"https://klaudius.dev").replace(/\/$/,"");async function ze(e={}){console.log(_.bold(`Klaudius preflight \u2014 checking your machine\u2026
3
- `));let n=[];n.push(Gt());let o=await Z();n.push(Bt(o)),n.push(await Yt(o.command)),n.push(await Wt()),n.push(await zt());for(let i of n){let a=i.status==="ok"?_.green("\u2713"):_.red("\u2717");console.log(` ${a} ${i.name}${i.detail?_.dim(` \u2014 ${i.detail}`):""}`),i.nextAction&&console.log(` ${_.dim("\u2192")} ${_.cyan(i.nextAction)}`)}console.log();let t=n.filter(i=>i.status==="fail");if(t.length===0){qt();return}console.log(_.red(_.bold(`${t.length} check${t.length===1?"":"s"} failed \u2014 fix the \u2192 items above, then re-run \`npx klaudius@latest preflight\`.`))),console.log(),console.log(_.dim(" AI assistant: install or upgrade whatever's marked \u2717 above for the")),console.log(_.dim(" user, then re-run `npx klaudius@latest preflight` until every check passes.")),console.log(),process.exitCode=1}function Gt(){let e=G();return e.ok?{name:"Node.js \u2265 22.15",status:"ok",detail:e.version}:{name:"Node.js \u2265 22.15",status:"fail",detail:e.version??"not detected",nextAction:"Install Node.js 22.15+ from https://nodejs.org/ \u2014 then open a NEW terminal before re-running."}}function Bt(e){return e.ok?{name:"Python \u2265 3.10",status:"ok",detail:e.version}:{name:"Python \u2265 3.10",status:"fail",detail:e.version??"not found",nextAction:e.message??"Install Python 3.10+ from https://www.python.org/downloads/"}}async function Yt(e){let n=e??["python3"],o=await _e(n[0],[...n.slice(1),"-m","pip","--version"]);return o.code===0?{name:"pip available",status:"ok",detail:(o.stdout||o.stderr).trim().split(`
4
- `)[0]||"ok"}:{name:"pip available",status:"fail",detail:`${n.join(" ")} -m pip not runnable`,nextAction:`Add pip to your Python: \`${n.join(" ")} -m ensurepip --upgrade\` (or reinstall Python from python.org, which bundles pip).`}}async function Wt(){let e=process.platform==="win32",n=await _e("npm",["--version"],e);return n.code!==0?{name:"npm / npx available",status:"fail",detail:"npm not found",nextAction:"npm ships with Node.js \u2014 reinstall Node from https://nodejs.org/."}:(await _e("npx",["--version"],e)).code!==0?{name:"npm / npx available",status:"fail",detail:`npm ${n.stdout.trim()} ok, npx missing`,nextAction:"npx ships with npm 5.2+ \u2014 reinstall Node from https://nodejs.org/."}:{name:"npm / npx available",status:"ok",detail:`npm ${n.stdout.trim()}`}}async function zt(){try{return await fetch(We,{method:"HEAD",signal:AbortSignal.timeout(8e3)}),{name:"klaudius.dev reachable",status:"ok",detail:We}}catch(e){return{name:"klaudius.dev reachable",status:"fail",detail:e.name==="TimeoutError"?"timed out":"could not connect",nextAction:"Check your internet connection, VPN, or firewall \u2014 init needs klaudius.dev to validate your license and download the template."}}}function qt(){console.log(_.green(_.bold("All checks passed \u2014 your machine is ready."))),console.log(),console.log(_.bold("NEXT STEP \u2014 this one is for you to run, not the AI assistant:")),console.log(" It's an interactive wizard (it asks for your license key and passwords),"),console.log(" so the assistant can't fill it in. Open a NEW terminal tab and run:"),console.log(),console.log(` ${_.cyan("npx klaudius@latest init my-agency")}`),console.log(),console.log(_.dim(" AI assistant: stop here. Do not run init yourself \u2014 tell the user to")),console.log(_.dim(" run it in a new terminal.")),console.log()}function _e(e,n,o=!1){return new Promise(t=>{let i=Vt(e,n,{stdio:["ignore","pipe","pipe"],shell:o}),a="",l="";i.stdout?.on("data",c=>{a+=c.toString()}),i.stderr?.on("data",c=>{l+=c.toString()}),i.on("close",c=>t({code:c??1,stdout:a,stderr:l})),i.on("error",()=>t({code:1,stdout:a,stderr:l}))})}import{mkdir as ve,readdir as vn,readFile as kt,stat as wt,writeFile as xe}from"fs/promises";import{spawnSync as Et}from"child_process";import{resolve as On,isAbsolute as Nn,join as q,normalize as $n}from"path";import*as k from"@clack/prompts";import u from"picocolors";import Xt from"react";import{render as Jt}from"ink";async function I(e={},n={}){if(!process.stdin.isTTY)throw new Error("Klaudius's interactive wizard requires a terminal (TTY). Run `npx klaudius@latest init` directly from your terminal \u2014 not through a pipe, file redirect, or non-interactive shell context.");let{WizardApp:o}=await import("./WizardApp-62FPSYYP.js"),t=null;Q("runWizard:start",{onlySection:n.onlySection,hasDefaults:Object.keys(e).length>0}),Ke(),await new Promise(a=>setImmediate(a)),await new Promise(a=>setTimeout(a,0)),Q("runWizard:event loop drained, mounting Ink");let i=Jt(Xt.createElement(o,{defaults:e,onlySection:n.onlySection,banner:n.banner,onComplete:a=>{Q("runWizard:onComplete called",{keys:Object.keys(a).length}),t=a}}),{stdout:process.stdout,stderr:process.stderr,stdin:process.stdin,exitOnCtrlC:!1});if(Q("runWizard:render returned, awaiting exit"),await i.waitUntilExit(),Q("runWizard:waitUntilExit resolved",{resultIsNull:t===null}),!t)throw new Error(`Wizard exited without completing. Diagnostic log: ${je}
5
- Please share that file so we can trace what happened.`);return t}var Ce="claude-code";function qe(e){if(e==="claude-code"||e==="codex")return e}var Ie="vercel";function Xe(e){if(e==="vercel"||e==="cloudflare"||e==="netlify")return e}function ue(e){let n=[],o=i=>{n.push(""),n.push("# "+"=".repeat(60)),n.push(`# ${i}`),n.push("# "+"=".repeat(60)),n.push("")},t=(i,a)=>{if(a==null||a===""){n.push(`# ${i}=`);return}let l=String(a);if(/[\s"'`$\\#&|<>;()*?\[\]{}!~]/.test(l)){let c=l.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\$/g,"\\$").replace(/`/g,"\\`");n.push(`${i}="${c}"`)}else n.push(`${i}=${l}`)};return n.push("# Klaudius configuration"),n.push("# Generated by `npx klaudius init`. Edit freely."),n.push("# NEVER commit this file. .gitignore already excludes it."),o("Klaudius licence"),t("KLAUDIUS_LICENSE_KEY",e.licenseKey),o("AI coding agent"),t("AI_AGENT",e.aiAgent??Ce),o("Operating country and language"),t("OPERATOR_COUNTRY",e.country),t("OPERATOR_COUNTRY_CODE",e.countryCode),t("OPERATOR_LANGUAGE",e.language),t("OPERATOR_LANGUAGE_CODE",e.languageCode),o("Pricing"),t("PRICING",e.pricing),t("PRICING_TERMS",e.pricingTerms),t("PRICING_MONTHLY",e.pricingMonthly),o("Automated outreach features"),t("OUTREACH_ENABLED",e.outreachEnabled?"true":"false"),t("OPERATOR_NAME",e.name),t("SIGNATURE",e.signature),t("OUTREACH_CHANNELS",e.outreachChannels?.join(",")),t("OUTREACH_PRIORITY",e.outreachPriority?.join(",")),o("Email outreach"),t("EMAIL_ADDRESS",e.emailAddress),t("EMAIL_PASSWORD",e.emailPassword),t("EMAIL_FROM_NAME",e.emailFromName),t("EMAIL_SMTP_HOST",e.emailSmtpHost),t("EMAIL_SMTP_PORT",e.emailSmtpPort),t("EMAIL_IMAP_HOST",e.emailImapHost),t("EMAIL_IMAP_PORT",e.emailImapPort),t("EMAIL_SENT_FOLDER",e.emailSentFolder),t("EMAIL_INBOX_FOLDER",e.emailInboxFolder),o("SMS outreach"),t("SMS_PROVIDER",e.smsProvider),t("TEST_PHONE",e.testPhone),t("TWILIO_ACCOUNT_SID",e.twilioAccountSid),t("TWILIO_AUTH_TOKEN",e.twilioAuthToken),t("TWILIO_PHONE_NUMBER",e.twilioPhoneNumber),o("WhatsApp outreach"),t("WHATSAPP_ACCOUNTS",e.whatsappAccounts?.join(",")),o("Supabase (pipeline state)"),t("SUPABASE_URL",e.supabaseUrl),t("SUPABASE_SERVICE_KEY",e.supabaseServiceKey),t("SUPABASE_PAT",e.supabasePat),t("SUPABASE_PROJECT_REF",e.supabaseProjectRef),o("Deployment"),t("DEPLOY_PROVIDER",e.deployProvider??Ie),t("VERCEL_TOKEN",e.vercelToken),t("VERCEL_SCOPE",e.vercelScope??""),t("CLOUDFLARE_API_TOKEN",e.cloudflareApiToken),t("CLOUDFLARE_ACCOUNT_ID",e.cloudflareAccountId),t("NETLIFY_AUTH_TOKEN",e.netlifyAuthToken),t("NETLIFY_ACCOUNT_SLUG",e.netlifyAccountSlug??""),o("Search APIs"),t("GOOGLE_PLACES_API_KEY",e.googlePlacesApiKey),t("SERPAPI_KEY",e.serpapiKey),o("Telegram notifications (optional)"),t("TELEGRAM_BOT_TOKEN",e.telegramBotToken),t("TELEGRAM_CHAT_ID",e.telegramChatId),o("Rate limiting (sensible defaults)"),t("REQUESTS_PER_MINUTE",10),t("REQUEST_DELAY",2),n.join(`
2
+ import{a as Q,b as Ke,c as He,d as P,f as Fe,g as Ve}from"./chunk-SZ4KCTSL.js";import{a as ce,b as Ge,c as Be,d as de,e as Ye,i as We}from"./chunk-ZTT5HVYU.js";import{Command as hs}from"commander";import{spawn as ze}from"child_process";import _ from"picocolors";function G(){let e=process.version,n=/^v(\d+)\.(\d+)\.(\d+)/.exec(e);if(!n)return{ok:!1,message:`Could not parse the Node.js version string ("${e}"). Klaudius requires Node.js 22.15 or newer \u2014 install from https://nodejs.org/.`};let s=parseInt(n[1],10),t=parseInt(n[2],10),i=parseInt(n[3],10),a=`${s}.${t}.${i}`;return s<22||s===22&&t<15?{ok:!1,version:a,major:s,minor:t,message:`Your installed Node.js is ${a}. Klaudius requires Node.js 22.15 or newer (the dependency installer relies on the --use-system-ca flag, which was added in 22.15 to handle Windows machines where antivirus or corporate-proxy software MITMs HTTPS). Install a newer Node.js from https://nodejs.org/ \u2014 after installing, close every Terminal window, open a new one, then re-run klaudius.`}:{ok:!0,version:a,major:s,minor:t}}import{spawn as Ht}from"child_process";var oe=3,ue=10,Ft=[["python3"],["python"],["py","-3"]];async function ie(){for(let e of Ft){let n=await Gt(e[0],[...e.slice(1),"--version"]),s=(n.stdout+n.stderr).trim();if(/Python was not found/i.test(s)||n.code!==0)continue;let t=/Python\s+(\d+)\.(\d+)(?:\.(\d+))?/.exec(s);if(!t)continue;let i=parseInt(t[1],10),a=parseInt(t[2],10),l=t[3]?`${i}.${a}.${t[3]}`:`${i}.${a}`;return{command:[...e],version:l,major:i,minor:a}}return null}async function Z(){let e=Vt(),n=await ie();if(!n){let l=process.platform==="win32"?` On Windows the \`python3\` / \`python\` commands are often the Microsoft Store placeholder, not a real interpreter \u2014 install from ${e} (tick "Add python.exe to PATH"), or disable the alias under Settings \u2192 Apps \u2192 Advanced app settings \u2192 App execution aliases.`:"";return{ok:!1,message:`Python ${oe}.${ue}+ is not installed (or not on PATH). Install it from ${e}.`+l}}let{command:s,version:t,major:i,minor:a}=n;return i<oe||i===oe&&a<ue?{ok:!1,version:t,major:i,minor:a,command:s,message:`Your installed Python is ${t}. Klaudius needs Python ${oe}.${ue} or newer (the pipeline depends on packages that only ship wheels for ${oe}.${ue}+). Install a newer Python from ${e} \u2014 it lives alongside your existing Python, nothing breaks. After installing, close every Terminal window, open a new one, then re-run klaudius.`}:{ok:!0,version:t,major:i,minor:a,command:s}}function Vt(){switch(process.platform){case"win32":return"https://www.python.org/downloads/windows/";case"darwin":return"https://www.python.org/downloads/macos/";default:return"https://www.python.org/downloads/"}}function Gt(e,n){return new Promise(s=>{let t=Ht(e,n,{stdio:["ignore","pipe","pipe"],shell:!1}),i="",a="";t.stdout?.on("data",l=>{i+=l.toString()}),t.stderr?.on("data",l=>{a+=l.toString()}),t.on("close",l=>s({code:l??1,stdout:i,stderr:a})),t.on("error",()=>s({code:1,stdout:i,stderr:a}))})}var qe=(process.env.KLAUDIUS_API_URL??"https://klaudius.dev").replace(/\/$/,"");async function Xe(e={}){console.log(_.bold(`Klaudius preflight \u2014 checking your machine\u2026
3
+ `));let n=[];n.push(Bt());let s=await Z();n.push(Yt(s)),n.push(await Wt(s.command)),n.push(await zt()),n.push(await qt());for(let i of n){let a=i.status==="ok"?_.green("\u2713"):_.red("\u2717");console.log(` ${a} ${i.name}${i.detail?_.dim(` \u2014 ${i.detail}`):""}`),i.nextAction&&console.log(` ${_.dim("\u2192")} ${_.cyan(i.nextAction)}`)}console.log();let t=n.filter(i=>i.status==="fail");if(t.length===0){Xt();return}console.log(_.red(_.bold(`${t.length} check${t.length===1?"":"s"} failed \u2014 fix the \u2192 items above, then re-run \`npx klaudius@latest preflight\`.`))),console.log(),console.log(_.dim(" AI assistant: install or upgrade whatever's marked \u2717 above for the")),console.log(_.dim(" user, then re-run `npx klaudius@latest preflight` until every check passes.")),console.log(),process.exitCode=1}function Bt(){let e=G();return e.ok?{name:"Node.js \u2265 22.15",status:"ok",detail:e.version}:{name:"Node.js \u2265 22.15",status:"fail",detail:e.version??"not detected",nextAction:"Install Node.js 22.15+ from https://nodejs.org/ \u2014 then open a NEW terminal before re-running."}}function Yt(e){return e.ok?{name:"Python \u2265 3.10",status:"ok",detail:e.version}:{name:"Python \u2265 3.10",status:"fail",detail:e.version??"not found",nextAction:e.message??"Install Python 3.10+ from https://www.python.org/downloads/"}}async function Wt(e){let n=e??["python3"],s=await _e(n[0],[...n.slice(1),"-m","pip","--version"]);return s.code===0?{name:"pip available",status:"ok",detail:(s.stdout||s.stderr).trim().split(`
4
+ `)[0]||"ok"}:{name:"pip available",status:"fail",detail:`${n.join(" ")} -m pip not runnable`,nextAction:`Add pip to your Python: \`${n.join(" ")} -m ensurepip --upgrade\` (or reinstall Python from python.org, which bundles pip).`}}async function zt(){let e=process.platform==="win32",n=await _e("npm",["--version"],e);return n.code!==0?{name:"npm / npx available",status:"fail",detail:"npm not found",nextAction:"npm ships with Node.js \u2014 reinstall Node from https://nodejs.org/."}:(await _e("npx",["--version"],e)).code!==0?{name:"npm / npx available",status:"fail",detail:`npm ${n.stdout.trim()} ok, npx missing`,nextAction:"npx ships with npm 5.2+ \u2014 reinstall Node from https://nodejs.org/."}:{name:"npm / npx available",status:"ok",detail:`npm ${n.stdout.trim()}`}}async function qt(){try{return await fetch(qe,{method:"HEAD",signal:AbortSignal.timeout(8e3)}),{name:"klaudius.dev reachable",status:"ok",detail:qe}}catch(e){return{name:"klaudius.dev reachable",status:"fail",detail:e.name==="TimeoutError"?"timed out":"could not connect",nextAction:"Check your internet connection, VPN, or firewall \u2014 init needs klaudius.dev to validate your license and download the template."}}}function Xt(){console.log(_.green(_.bold("All checks passed \u2014 your machine is ready."))),console.log(),console.log(_.bold("NEXT STEP \u2014 this one is for you to run, not the AI assistant:")),console.log(" It's an interactive wizard (it asks for your license key and passwords),"),console.log(" so the assistant can't fill it in. Open a NEW terminal tab and run:"),console.log(),console.log(` ${_.cyan("npx klaudius@latest init my-agency")}`),console.log(),console.log(_.dim(" AI assistant: stop here. Do not run init yourself \u2014 tell the user to")),console.log(_.dim(" run it in a new terminal.")),console.log()}function _e(e,n,s=!1){return new Promise(t=>{let i=s?ze([e,...n].join(" "),{stdio:["ignore","pipe","pipe"],shell:!0}):ze(e,n,{stdio:["ignore","pipe","pipe"],shell:!1}),a="",l="";i.stdout?.on("data",c=>{a+=c.toString()}),i.stderr?.on("data",c=>{l+=c.toString()}),i.on("close",c=>t({code:c??1,stdout:a,stderr:l})),i.on("error",()=>t({code:1,stdout:a,stderr:l}))})}import{mkdir as Oe,readdir as On,readFile as wt,stat as At,writeFile as ve}from"fs/promises";import{spawnSync as Pt}from"child_process";import{resolve as Nn,isAbsolute as $n,join as q,normalize as Ln}from"path";import*as k from"@clack/prompts";import u from"picocolors";import Jt from"react";import{render as Qt}from"ink";async function I(e={},n={}){if(!process.stdin.isTTY)throw new Error("Klaudius's interactive wizard requires a terminal (TTY). Run `npx klaudius@latest init` directly from your terminal \u2014 not through a pipe, file redirect, or non-interactive shell context.");let{WizardApp:s}=await import("./WizardApp-LW4VIMPN.js"),t=null;Q("runWizard:start",{onlySection:n.onlySection,hasDefaults:Object.keys(e).length>0}),He(),await new Promise(a=>setImmediate(a)),await new Promise(a=>setTimeout(a,0)),Q("runWizard:event loop drained, mounting Ink");let i=Qt(Jt.createElement(s,{defaults:e,onlySection:n.onlySection,banner:n.banner,onComplete:a=>{Q("runWizard:onComplete called",{keys:Object.keys(a).length}),t=a}}),{stdout:process.stdout,stderr:process.stderr,stdin:process.stdin,exitOnCtrlC:!1});if(Q("runWizard:render returned, awaiting exit"),await i.waitUntilExit(),Q("runWizard:waitUntilExit resolved",{resultIsNull:t===null}),!t)throw new Error(`Wizard exited without completing. Diagnostic log: ${Ke}
5
+ Please share that file so we can trace what happened.`);return t}var Ce="claude-code";function Je(e){if(e==="claude-code"||e==="codex")return e}var Ie="vercel";function Qe(e){if(e==="vercel"||e==="cloudflare"||e==="netlify")return e}function pe(e){let n=[],s=i=>{n.push(""),n.push("# "+"=".repeat(60)),n.push(`# ${i}`),n.push("# "+"=".repeat(60)),n.push("")},t=(i,a)=>{if(a==null||a===""){n.push(`# ${i}=`);return}let l=String(a);if(/[\s"'`$\\#&|<>;()*?\[\]{}!~]/.test(l)){let c=l.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\$/g,"\\$").replace(/`/g,"\\`");n.push(`${i}="${c}"`)}else n.push(`${i}=${l}`)};return n.push("# Klaudius configuration"),n.push("# Generated by `npx klaudius init`. Edit freely."),n.push("# NEVER commit this file. .gitignore already excludes it."),s("Klaudius licence"),t("KLAUDIUS_LICENSE_KEY",e.licenseKey),s("AI coding agent"),t("AI_AGENT",e.aiAgent??Ce),s("Operating country and language"),t("OPERATOR_COUNTRY",e.country),t("OPERATOR_COUNTRY_CODE",e.countryCode),t("OPERATOR_LANGUAGE",e.language),t("OPERATOR_LANGUAGE_CODE",e.languageCode),s("Pricing"),t("PRICING",e.pricing),t("PRICING_TERMS",e.pricingTerms),t("PRICING_MONTHLY",e.pricingMonthly),s("Automated outreach features"),t("OUTREACH_ENABLED",e.outreachEnabled?"true":"false"),t("OPERATOR_NAME",e.name),t("SIGNATURE",e.signature),t("OUTREACH_CHANNELS",e.outreachChannels?.join(",")),t("OUTREACH_PRIORITY",e.outreachPriority?.join(",")),s("Email outreach"),t("EMAIL_ADDRESS",e.emailAddress),t("EMAIL_PASSWORD",e.emailPassword),t("EMAIL_FROM_NAME",e.emailFromName),t("EMAIL_SMTP_HOST",e.emailSmtpHost),t("EMAIL_SMTP_PORT",e.emailSmtpPort),t("EMAIL_IMAP_HOST",e.emailImapHost),t("EMAIL_IMAP_PORT",e.emailImapPort),t("EMAIL_SENT_FOLDER",e.emailSentFolder),t("EMAIL_INBOX_FOLDER",e.emailInboxFolder),s("SMS outreach"),t("SMS_PROVIDER",e.smsProvider),t("TEST_PHONE",e.testPhone),t("TWILIO_ACCOUNT_SID",e.twilioAccountSid),t("TWILIO_AUTH_TOKEN",e.twilioAuthToken),t("TWILIO_PHONE_NUMBER",e.twilioPhoneNumber),s("WhatsApp outreach"),t("WHATSAPP_ACCOUNTS",e.whatsappAccounts?.join(",")),s("Supabase (pipeline state)"),t("SUPABASE_URL",e.supabaseUrl),t("SUPABASE_SERVICE_KEY",e.supabaseServiceKey),t("SUPABASE_PAT",e.supabasePat),t("SUPABASE_PROJECT_REF",e.supabaseProjectRef),s("Deployment"),t("DEPLOY_PROVIDER",e.deployProvider??Ie),t("VERCEL_TOKEN",e.vercelToken),t("VERCEL_SCOPE",e.vercelScope??""),t("CLOUDFLARE_API_TOKEN",e.cloudflareApiToken),t("CLOUDFLARE_ACCOUNT_ID",e.cloudflareAccountId),t("NETLIFY_AUTH_TOKEN",e.netlifyAuthToken),t("NETLIFY_ACCOUNT_SLUG",e.netlifyAccountSlug??""),s("Search APIs"),t("GOOGLE_PLACES_API_KEY",e.googlePlacesApiKey),t("SERPAPI_KEY",e.serpapiKey),s("Telegram notifications (optional)"),t("TELEGRAM_BOT_TOKEN",e.telegramBotToken),t("TELEGRAM_CHAT_ID",e.telegramChatId),s("Rate limiting (sensible defaults)"),t("REQUESTS_PER_MINUTE",10),t("REQUEST_DELAY",2),n.join(`
6
6
  `)+`
7
- `}function pe(e){let n={mcpServers:{supabase:{command:"npx",args:["-y","@supabase/mcp-server-supabase@latest",`--project-ref=${e.supabaseProjectRef}`],env:{SUPABASE_ACCESS_TOKEN:e.supabasePat,NODE_OPTIONS:"--use-system-ca"}}}};return JSON.stringify(n,null,2)+`
8
- `}function fe(e){let n=e.supabaseProjectRef,o=Qt(e.supabasePat);return["# Codex MCP config \u2014 generated by `npx klaudius init` / `configure`.","# Edit freely. NEVER commit this file \u2014 .gitignore already excludes it.","# See `.codex/config.toml.example` for the documented format.","","[mcp_servers.supabase]",'command = "npx"',`args = ["-y", "@supabase/mcp-server-supabase@latest", "--project-ref=${n}"]`,`env = { SUPABASE_ACCESS_TOKEN = "${o}", NODE_OPTIONS = "--use-system-ca" }`,""].join(`
9
- `)}function Qt(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}var Je=[{key:"AI_AGENT",value:"claude-code",comment:"Which AI coding agent drives this install. Pre-codex installs were Claude Code by default \u2014 this records that explicitly so `update` re-fetches the matching template tarball and `doctor` checks the right CLI."},{key:"PRICING_TERMS",value:"one-off, no monthly fees",comment:"Phrasing slotted next to ${PRICING} in outreach copy. See template/CLAUDE.md."},{key:"VERCEL_SCOPE",value:"",comment:"Vercel team slug. Leave blank unless `vercel link` errors about scope (post-2024 multi-team Vercel accounts)."},{key:"DEPLOY_PROVIDER",value:"vercel",comment:"Where the deploy skill ships client sites: 'vercel', 'cloudflare', or 'netlify'. Pre-Cloudflare installs deployed to Vercel, so this records that explicitly. To switch host, run `npx klaudius@latest configure` (Cloudflare adds CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID; Netlify adds NETLIFY_AUTH_TOKEN)."},{key:"OPERATOR_COUNTRY",value:"the United Kingdom",comment:"Operating country (canonical full name). Used as the default region for /find."},{key:"OPERATOR_COUNTRY_CODE",value:"GB",comment:"ISO 3166-1 alpha-2 code. Passed to the Google Places API for region biasing."},{key:"OPERATOR_LANGUAGE",value:"English",comment:"Language all outreach + websites are written in."},{key:"OPERATOR_LANGUAGE_CODE",value:"en",comment:'ISO 639-1 code. Used by Google Places + <html lang="..."> on built sites.'}];function Zt(e,n){if(/[\s"'`$\\#&|<>;()*?\[\]{}!~]/.test(n)){let o=n.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\$/g,"\\$").replace(/`/g,"\\`");return`${e}="${o}"`}return`${e}=${n}`}function Qe(e,n,o){let t=o.filter(l=>!(l.key in n));if(t.length===0)return null;let i=e.endsWith(`
7
+ `}function fe(e){let n={mcpServers:{supabase:{command:"npx",args:["-y","@supabase/mcp-server-supabase@latest",`--project-ref=${e.supabaseProjectRef}`],env:{SUPABASE_ACCESS_TOKEN:e.supabasePat,NODE_OPTIONS:"--use-system-ca"}}}};return JSON.stringify(n,null,2)+`
8
+ `}function me(e){let n=e.supabaseProjectRef,s=Zt(e.supabasePat);return["# Codex MCP config \u2014 generated by `npx klaudius init` / `configure`.","# Edit freely. NEVER commit this file \u2014 .gitignore already excludes it.","# See `.codex/config.toml.example` for the documented format.","","[mcp_servers.supabase]",'command = "npx"',`args = ["-y", "@supabase/mcp-server-supabase@latest", "--project-ref=${n}"]`,`env = { SUPABASE_ACCESS_TOKEN = "${s}", NODE_OPTIONS = "--use-system-ca" }`,""].join(`
9
+ `)}function Zt(e){return e.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}var Ze=[{key:"AI_AGENT",value:"claude-code",comment:"Which AI coding agent drives this install. Pre-codex installs were Claude Code by default \u2014 this records that explicitly so `update` re-fetches the matching template tarball and `doctor` checks the right CLI."},{key:"PRICING_TERMS",value:"one-off, no monthly fees",comment:"Phrasing slotted next to ${PRICING} in outreach copy. See template/CLAUDE.md."},{key:"VERCEL_SCOPE",value:"",comment:"Vercel team slug. Leave blank unless `vercel link` errors about scope (post-2024 multi-team Vercel accounts)."},{key:"DEPLOY_PROVIDER",value:"vercel",comment:"Where the deploy skill ships client sites: 'vercel', 'cloudflare', or 'netlify'. Pre-Cloudflare installs deployed to Vercel, so this records that explicitly. To switch host, run `npx klaudius@latest configure` (Cloudflare adds CLOUDFLARE_API_TOKEN + CLOUDFLARE_ACCOUNT_ID; Netlify adds NETLIFY_AUTH_TOKEN)."},{key:"OPERATOR_COUNTRY",value:"the United Kingdom",comment:"Operating country (canonical full name). Used as the default region for /find."},{key:"OPERATOR_COUNTRY_CODE",value:"GB",comment:"ISO 3166-1 alpha-2 code. Passed to the Google Places API for region biasing."},{key:"OPERATOR_LANGUAGE",value:"English",comment:"Language all outreach + websites are written in."},{key:"OPERATOR_LANGUAGE_CODE",value:"en",comment:'ISO 639-1 code. Used by Google Places + <html lang="..."> on built sites.'}];function en(e,n){if(/[\s"'`$\\#&|<>;()*?\[\]{}!~]/.test(n)){let s=n.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\$/g,"\\$").replace(/`/g,"\\`");return`${e}="${s}"`}return`${e}=${n}`}function et(e,n,s){let t=s.filter(l=>!(l.key in n));if(t.length===0)return null;let i=e.endsWith(`
10
10
  `)?"":`
11
- `,a=["","# "+"=".repeat(60),"# Backfilled by `klaudius update` (new template env keys)","# "+"=".repeat(60)];for(let l of t)a.push(""),l.comment&&a.push(`# ${l.comment}`),a.push(Zt(l.key,l.value));return e+i+a.join(`
11
+ `,a=["","# "+"=".repeat(60),"# Backfilled by `klaudius update` (new template env keys)","# "+"=".repeat(60)];for(let l of t)a.push(""),l.comment&&a.push(`# ${l.comment}`),a.push(en(l.key,l.value));return e+i+a.join(`
12
12
  `)+`
13
- `}function en(e){return e.length>=2&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1).replace(/\\\\/g,"\\").replace(/\\"/g,'"').replace(/\\\$/g,"$").replace(/\\`/g,"`"):e.length>=2&&e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function $(e){let n={};for(let o of e.split(`
14
- `)){let t=o.trim();if(!t||t.startsWith("#"))continue;let i=t.indexOf("=");if(i===-1)continue;let a=t.slice(0,i).trim(),l=en(t.slice(i+1).trim());n[a]=l}return n}function Ze(e){let n=c=>{let f=e[c];if(!f)return;let g=parseInt(f,10);return isNaN(g)?void 0:g},o=e.SMS_PROVIDER,t=c=>c==="email"||c==="sms"||c==="whatsapp",i=e.OUTREACH_CHANNELS?.split(",").map(c=>c.trim()).filter(t),a=e.OUTREACH_PRIORITY?.split(",").map(c=>c.trim()).filter(t),l=e.WHATSAPP_ACCOUNTS?.split(",").map(c=>c.trim()).filter(c=>c.length>0);return{licenseKey:e.KLAUDIUS_LICENSE_KEY,aiAgent:qe(e.AI_AGENT)??Ce,country:e.OPERATOR_COUNTRY||void 0,countryCode:e.OPERATOR_COUNTRY_CODE||void 0,language:e.OPERATOR_LANGUAGE||void 0,languageCode:e.OPERATOR_LANGUAGE_CODE||void 0,pricing:e.PRICING,pricingTerms:e.PRICING_TERMS,pricingMonthly:e.PRICING_MONTHLY||void 0,outreachEnabled:e.OUTREACH_ENABLED?e.OUTREACH_ENABLED.toLowerCase()==="true":void 0,name:e.OPERATOR_NAME,signature:e.SIGNATURE,outreachChannels:i&&i.length>0?i:void 0,outreachPriority:a&&a.length>0?a:void 0,whatsappAccounts:l&&l.length>0?l:void 0,emailAddress:e.EMAIL_ADDRESS,emailFromName:e.EMAIL_FROM_NAME,emailSmtpHost:e.EMAIL_SMTP_HOST,emailSmtpPort:n("EMAIL_SMTP_PORT"),emailImapHost:e.EMAIL_IMAP_HOST,emailImapPort:n("EMAIL_IMAP_PORT"),emailSentFolder:e.EMAIL_SENT_FOLDER,emailInboxFolder:e.EMAIL_INBOX_FOLDER,smsProvider:o==="imessage"||o==="twilio"?o:void 0,testPhone:e.TEST_PHONE,twilioAccountSid:e.TWILIO_ACCOUNT_SID,twilioPhoneNumber:e.TWILIO_PHONE_NUMBER,twilioAuthToken:e.TWILIO_AUTH_TOKEN,supabaseUrl:e.SUPABASE_URL,supabaseProjectRef:e.SUPABASE_PROJECT_REF,supabaseServiceKey:e.SUPABASE_SERVICE_KEY,supabasePat:e.SUPABASE_PAT,deployProvider:Xe(e.DEPLOY_PROVIDER)??Ie,vercelToken:e.VERCEL_TOKEN,vercelScope:e.VERCEL_SCOPE||void 0,cloudflareApiToken:e.CLOUDFLARE_API_TOKEN||void 0,cloudflareAccountId:e.CLOUDFLARE_ACCOUNT_ID||void 0,netlifyAuthToken:e.NETLIFY_AUTH_TOKEN||void 0,netlifyAccountSlug:e.NETLIFY_ACCOUNT_SLUG||void 0,googlePlacesApiKey:e.GOOGLE_PLACES_API_KEY,serpapiKey:e.SERPAPI_KEY,emailPassword:e.EMAIL_PASSWORD,telegramBotToken:e.TELEGRAM_BOT_TOKEN,telegramChatId:e.TELEGRAM_CHAT_ID}}function Se(e){let n=E=>{let v=e[E];if(!v)return;let y=parseInt(v,10);return isNaN(y)?void 0:y},o=e.SUPABASE_URL,t=e.SUPABASE_SERVICE_KEY?.replace(/\s+/g,""),i=e.SUPABASE_PAT?.replace(/\s+/g,""),a=e.SUPABASE_PROJECT_REF,l=e.PRICING,c=e.PRICING_TERMS||"one-off, no monthly fees",f=Xe(e.DEPLOY_PROVIDER)??Ie,g=e.VERCEL_TOKEN,r=e.CLOUDFLARE_API_TOKEN,A=e.CLOUDFLARE_ACCOUNT_ID,h=e.NETLIFY_AUTH_TOKEN;if(!l||!o||!t||!i||!a||!(f==="cloudflare"?!!r&&!!A:f==="netlify"?!!h:!!g))return null;let L=e.SMS_PROVIDER,V=E=>E==="email"||E==="sms"||E==="whatsapp",D=e.OUTREACH_CHANNELS?.split(",").map(E=>E.trim()).filter(V),T=e.OUTREACH_PRIORITY?.split(",").map(E=>E.trim()).filter(V),S=e.WHATSAPP_ACCOUNTS?.split(",").map(E=>E.trim()).filter(E=>E.length>0);return{licenseKey:e.KLAUDIUS_LICENSE_KEY,aiAgent:qe(e.AI_AGENT)??Ce,country:e.OPERATOR_COUNTRY||void 0,countryCode:e.OPERATOR_COUNTRY_CODE||void 0,language:e.OPERATOR_LANGUAGE||void 0,languageCode:e.OPERATOR_LANGUAGE_CODE||void 0,pricing:l,pricingTerms:c,pricingMonthly:e.PRICING_MONTHLY||void 0,outreachEnabled:e.OUTREACH_ENABLED?.toLowerCase()==="true",name:e.OPERATOR_NAME,signature:e.SIGNATURE,outreachChannels:D&&D.length>0?D:void 0,outreachPriority:T&&T.length>0?T:void 0,whatsappAccounts:S&&S.length>0?S:void 0,emailAddress:e.EMAIL_ADDRESS,emailPassword:e.EMAIL_PASSWORD,emailFromName:e.EMAIL_FROM_NAME,emailSmtpHost:e.EMAIL_SMTP_HOST,emailSmtpPort:n("EMAIL_SMTP_PORT"),emailImapHost:e.EMAIL_IMAP_HOST,emailImapPort:n("EMAIL_IMAP_PORT"),emailSentFolder:e.EMAIL_SENT_FOLDER,emailInboxFolder:e.EMAIL_INBOX_FOLDER,smsProvider:L==="imessage"||L==="twilio"?L:void 0,testPhone:e.TEST_PHONE,twilioAccountSid:e.TWILIO_ACCOUNT_SID,twilioAuthToken:e.TWILIO_AUTH_TOKEN,twilioPhoneNumber:e.TWILIO_PHONE_NUMBER,deployProvider:f,vercelToken:g,vercelScope:e.VERCEL_SCOPE||void 0,cloudflareApiToken:r||void 0,cloudflareAccountId:A||void 0,netlifyAuthToken:h||void 0,netlifyAccountSlug:e.NETLIFY_ACCOUNT_SLUG||void 0,supabaseUrl:o,supabaseServiceKey:t,supabasePat:i,supabaseProjectRef:a,googlePlacesApiKey:e.GOOGLE_PLACES_API_KEY,serpapiKey:e.SERPAPI_KEY,telegramBotToken:e.TELEGRAM_BOT_TOKEN,telegramChatId:e.TELEGRAM_CHAT_ID}}import{mkdir as tn,rm as nn}from"fs/promises";import{Readable as sn}from"stream";import*as et from"tar";var on="https://klaudius.dev/api/template";function an(e){return sn.fromWeb(e)}async function me(e){let n=process.env.KLAUDIUS_TEMPLATE_URL??on,o="0.17.1",t;try{t=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${e.licenseKey}`,"Content-Type":"application/json"},body:JSON.stringify({machine_id:e.machineId,hostname:e.hostname,os:e.os,cli_version:o,...e.agent==="codex"?{agent:"codex"}:{}})})}catch(l){throw new Error(`Could not reach klaudius.dev to download the template: ${P(l)}`)}if(!t.ok){let l="";try{let c=await t.json();l=c.reason?` (${c.reason})`:""}catch{}throw new Error(`Template download failed: HTTP ${t.status}${l}`)}if(!t.body)throw new Error("Template download succeeded but response had no body");let i=t.headers.get("x-klaudius-tier");await tn(e.destDir,{recursive:!0});let a=0;try{await new Promise((l,c)=>{let f=et.extract({cwd:e.destDir,strict:!0,onReadEntry:()=>{a++}});f.on("finish",l),f.on("error",c),an(t.body).on("error",c).pipe(f)})}catch(l){throw await nn(e.destDir,{recursive:!0,force:!0}).catch(()=>{}),new Error(`Failed to extract template archive: ${l.message}`)}return{filesExtracted:a,tier:i}}import B from"picocolors";var s={info:e=>console.log(B.cyan("\u2139"),e),success:e=>console.log(B.green("\u2713"),e),warn:e=>console.log(B.yellow("\u26A0"),e),error:e=>console.error(B.red("\u2717"),e),step:e=>console.log(B.dim("\u2192"),e),blank:()=>console.log(""),heading:e=>console.log(`
15
- `+B.bold(B.cyan(e))),detail:e=>console.log(B.dim(" "+e))};var rn="https://registry.npmjs.org/klaudius/latest";async function ln(e=1500){let n=new AbortController,o=setTimeout(()=>n.abort(),e);try{let t=await fetch(rn,{signal:n.signal,headers:{accept:"application/json"}});if(!t.ok)return null;let i=await t.json();return typeof i.version=="string"?i.version:null}catch{return null}finally{clearTimeout(o)}}function cn(e,n){let o=a=>a.split("-")[0].split(".").map(l=>Number.parseInt(l,10)),t=o(e),i=o(n);if(t.length<3||i.length<3)return!1;for(let a=0;a<3;a++){if(Number.isNaN(t[a])||Number.isNaN(i[a]))return!1;if(t[a]>i[a])return!0;if(t[a]<i[a])return!1}return!1}async function he(e,n){if(n==="dev"||process.env.CI||process.env.NO_UPDATE_NOTIFIER)return;let o=await ln();!o||!cn(o,n)||(s.blank(),s.warn(`A newer Klaudius CLI is available: you have ${n}, latest is ${o}.`),e==="update"&&(s.detail("Your project content is fetched fresh either way, so you're not missing any"),s.detail("pipeline updates. But the CLI itself, including its update logic, is behind.")),s.detail(`Re-run with \`npx klaudius@latest ${e}\` to use the latest CLI.`),s.blank())}import{createHash as dn}from"crypto";import{hostname as tt,userInfo as un,platform as nt,arch as st}from"os";var pn="https://klaudius.dev",fn="/api/licenses/validate",mn="0.17.1";async function ot(e){if(!e||e.trim().length===0)return{ok:!1,reason:"No license key provided. Pass one via --license <key> or paste it when prompted."};let n=e.trim(),t=(process.env.KLAUDIUS_API_URL??pn).replace(/\/$/,"")+fn,i=ie(),a;try{a=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({license_key:n,machine_id:i,hostname:tt(),os:`${nt()}-${st()}`,cli_version:mn})})}catch(c){return{ok:!1,reason:`Could not reach the Klaudius license server (${P(c)}). Check your internet connection or try again later.`}}let l;try{l=await a.json()}catch{return{ok:!1,reason:`License server returned an unparseable response (HTTP ${a.status}).`}}return l.ok?{ok:!0,tier:l.tier??"core"}:{ok:!1,reason:l.reason??`License rejected (HTTP ${a.status}).`}}function ie(){let e=[tt(),un().username,nt(),st()].join("|");return dn("sha256").update(e).digest("hex").slice(0,32)}import{readFile as hn}from"fs/promises";import{join as gn}from"path";async function ee(e){let n=e.serviceKey.replace(/\s+/g,"");try{let o=await fetch(e.url+"/rest/v1/",{headers:{apikey:n,Authorization:`Bearer ${n}`}});return o.status===401||o.status===403?{ok:!1,message:`Supabase rejected auth (HTTP ${o.status}). Check SUPABASE_SERVICE_KEY.`}:{ok:!0}}catch(o){return{ok:!1,message:`Could not reach Supabase: ${P(o)}`}}}async function it(e){let n;try{n=await hn(gn(e.projectRoot,"scripts","schema.sql"),"utf-8")}catch(t){return{ok:!1,message:`Could not read scripts/schema.sql: ${t.message}`}}let o=e.pat.replace(/\s+/g,"");try{let t=await fetch(`https://api.supabase.com/v1/projects/${e.projectRef}/database/query`,{method:"POST",headers:{Authorization:`Bearer ${o}`,"Content-Type":"application/json"},body:JSON.stringify({query:n})});if(t.ok)return{ok:!0};let i=await t.text();return i.includes("already exists")||i.includes('relation "clients" already exists')||i.includes("duplicate")?(s.detail("Schema appears already applied (tables exist). Skipping."),{ok:!0}):{ok:!1,message:`Supabase Management API rejected schema (HTTP ${t.status}): ${i.slice(0,300)}`}}catch(t){return{ok:!1,message:`Schema apply failed: ${t.message}`}}}async function ge(e){try{let n=await fetch("https://api.vercel.com/v2/user",{headers:{Authorization:`Bearer ${e}`}});if(n.status===401||n.status===403)return{ok:!1,message:`Vercel rejected the token (HTTP ${n.status}). The token is invalid, expired, or has been revoked.`};if(!n.ok)return{ok:!1,message:`Vercel API returned HTTP ${n.status}. Try again or check status.vercel.com.`};let o=await n.json();return{ok:!0,username:o.user?.username??o.user?.email}}catch(n){return{ok:!1,message:`Could not reach Vercel: ${P(n)}`}}}var at="https://api.cloudflare.com/client/v4";function rt(e){let n=e?.errors?.[0];if(n)return n.message?`${n.message}${n.code?` (code ${n.code})`:""}`:void 0}async function ye(e){let{token:n,accountId:o}=e,t={Authorization:`Bearer ${n}`,"Content-Type":"application/json"};try{let i=await fetch(`${at}/user/tokens/verify`,{headers:t});if(i.status===401||i.status===403)return{ok:!1,message:`Cloudflare rejected the token (HTTP ${i.status}). The token is invalid, expired, or has been revoked. Create a fresh one at https://dash.cloudflare.com/profile/api-tokens.`};if(!i.ok)return{ok:!1,message:`Cloudflare API returned HTTP ${i.status} verifying the token. Try again or check cloudflarestatus.com.`};let a=await i.json(),l=a.result?.status;if(a.success===!1||l&&l!=="active")return{ok:!1,message:`Cloudflare reports the token is not active${l?` (status: ${l})`:""}. ${rt(a)??"Create a fresh token at https://dash.cloudflare.com/profile/api-tokens."}`}}catch(i){return{ok:!1,message:`Could not reach Cloudflare: ${P(i)}`}}try{let i=await fetch(`${at}/accounts/${encodeURIComponent(o)}/pages/projects`,{headers:t});if(i.status===403)return{ok:!1,message:`The token is valid but can't manage Pages in account ${o} (HTTP 403). Most likely the token is missing the "Account \u2192 Cloudflare Pages \u2192 Edit" permission, or the Account ID belongs to a different account than the token. Re-create the token with that exact permission and your account selected under "Account Resources".`};if(i.status===404)return{ok:!1,message:`Account ${o} was not found (HTTP 404). Double-check the Account ID \u2014 it's the 32-character hex string in the dashboard URL (dash.cloudflare.com/<ID>).`};if(!i.ok)return{ok:!1,message:`Cloudflare API returned HTTP ${i.status} listing Pages projects. Try again or check cloudflarestatus.com.`};let a=await i.json();return a.success===!1?{ok:!1,message:rt(a)??"Cloudflare rejected the Pages project listing request."}:{ok:!0,projectCount:Array.isArray(a.result)?a.result.length:void 0}}catch(i){return{ok:!1,message:`Could not reach Cloudflare: ${P(i)}`}}}var lt="https://api.netlify.com/api/v1";async function ke(e){let{token:n}=e,o={Authorization:`Bearer ${n}`};try{let t=await fetch(`${lt}/user`,{headers:o});if(t.status===401||t.status===403)return{ok:!1,message:`Netlify rejected the token (HTTP ${t.status}). The token is invalid, expired, or has been revoked. Create a fresh one at https://app.netlify.com/user/applications#personal-access-tokens.`};if(!t.ok)return{ok:!1,message:`Netlify API returned HTTP ${t.status} verifying the token. Try again or check netlifystatus.com.`}}catch(t){return{ok:!1,message:`Could not reach Netlify: ${P(t)}`}}try{let t=await fetch(`${lt}/accounts`,{headers:o});if(!t.ok)return{ok:!1,message:`Netlify API returned HTTP ${t.status} listing your teams. Try again or check netlifystatus.com.`};let i=await t.json(),a=Array.isArray(i)?i:[];if(a.length===0)return{ok:!1,message:"The token is valid but isn't a member of any Netlify team. Klaudius creates each client's site under a team, so it needs at least one. Open https://app.netlify.com and confirm your account has a team."};let l=typeof a[0]?.slug=="string"?a[0].slug:void 0;return{ok:!0,accountCount:a.length,accountSlug:l}}catch(t){return{ok:!1,message:`Could not reach Netlify: ${P(t)}`}}}async function we(e){try{let n=await fetch("https://places.googleapis.com/v1/places:searchText",{method:"POST",headers:{"Content-Type":"application/json","X-Goog-Api-Key":e,"X-Goog-FieldMask":"places.id"},body:JSON.stringify({textQuery:"x"})});if(n.ok)return{ok:!0};if(n.status===429)return{ok:!0};let o={};try{o=await n.json()}catch{}let t=o.error?.message??"",i=o.error?.status??"";return n.status===400&&(i==="PERMISSION_DENIED"||/Places API \(New\) has not been enabled|API_KEY_SERVICE_BLOCKED/i.test(t))?{ok:!1,message:"Key is valid, but Places API (New) is not enabled on its Cloud project. Open https://console.cloud.google.com/apis/library and enable 'Places API (New)' for the project this key belongs to, then try again."}:n.status===401||n.status===403?{ok:!1,message:t||`Google rejected the key (HTTP ${n.status}). Common causes: invalid key, billing not enabled on the Cloud project, or API key restrictions blocking this caller.`}:{ok:!1,message:`Google API returned HTTP ${n.status}${t?`: ${t}`:""}.`}}catch(n){return{ok:!1,message:`Could not reach Google: ${P(n)}`}}}import yn from"nodemailer";import{ImapFlow as kn}from"imapflow";async function dt(e){let n=yn.createTransport({host:e.emailSmtpHost,port:e.emailSmtpPort,secure:e.emailSmtpPort===465,auth:{user:e.emailAddress,pass:e.emailPassword},connectionTimeout:1e4,greetingTimeout:5e3,socketTimeout:1e4});try{await n.verify()}catch(t){return{ok:!1,failedAt:"smtp",message:ct(t,"SMTP")}}finally{n.close()}let o=new kn({host:e.emailImapHost,port:e.emailImapPort,secure:e.emailImapPort===993,auth:{user:e.emailAddress,pass:e.emailPassword},logger:!1});try{await o.connect(),await o.logout()}catch(t){try{await o.logout()}catch{}return{ok:!1,failedAt:"imap",message:ct(t,"IMAP")}}return{ok:!0}}function ct(e,n){let o=e instanceof Error?e.message:String(e),t=o.toLowerCase();return t.includes("invalid credentials")||t.includes("authentication failed")||t.includes("auth failed")||t.includes("login failed")?`${n} rejected the credentials. Most common causes:
13
+ `}function tn(e){return e.length>=2&&e.startsWith('"')&&e.endsWith('"')?e.slice(1,-1).replace(/\\\\/g,"\\").replace(/\\"/g,'"').replace(/\\\$/g,"$").replace(/\\`/g,"`"):e.length>=2&&e.startsWith("'")&&e.endsWith("'")?e.slice(1,-1):e}function $(e){let n={};for(let s of e.split(`
14
+ `)){let t=s.trim();if(!t||t.startsWith("#"))continue;let i=t.indexOf("=");if(i===-1)continue;let a=t.slice(0,i).trim(),l=tn(t.slice(i+1).trim());n[a]=l}return n}function tt(e){let n=c=>{let p=e[c];if(!p)return;let g=parseInt(p,10);return isNaN(g)?void 0:g},s=e.SMS_PROVIDER,t=c=>c==="email"||c==="sms"||c==="whatsapp",i=e.OUTREACH_CHANNELS?.split(",").map(c=>c.trim()).filter(t),a=e.OUTREACH_PRIORITY?.split(",").map(c=>c.trim()).filter(t),l=e.WHATSAPP_ACCOUNTS?.split(",").map(c=>c.trim()).filter(c=>c.length>0);return{licenseKey:e.KLAUDIUS_LICENSE_KEY,aiAgent:Je(e.AI_AGENT)??Ce,country:e.OPERATOR_COUNTRY||void 0,countryCode:e.OPERATOR_COUNTRY_CODE||void 0,language:e.OPERATOR_LANGUAGE||void 0,languageCode:e.OPERATOR_LANGUAGE_CODE||void 0,pricing:e.PRICING,pricingTerms:e.PRICING_TERMS,pricingMonthly:e.PRICING_MONTHLY||void 0,outreachEnabled:e.OUTREACH_ENABLED?e.OUTREACH_ENABLED.toLowerCase()==="true":void 0,name:e.OPERATOR_NAME,signature:e.SIGNATURE,outreachChannels:i&&i.length>0?i:void 0,outreachPriority:a&&a.length>0?a:void 0,whatsappAccounts:l&&l.length>0?l:void 0,emailAddress:e.EMAIL_ADDRESS,emailFromName:e.EMAIL_FROM_NAME,emailSmtpHost:e.EMAIL_SMTP_HOST,emailSmtpPort:n("EMAIL_SMTP_PORT"),emailImapHost:e.EMAIL_IMAP_HOST,emailImapPort:n("EMAIL_IMAP_PORT"),emailSentFolder:e.EMAIL_SENT_FOLDER,emailInboxFolder:e.EMAIL_INBOX_FOLDER,smsProvider:s==="imessage"||s==="twilio"?s:void 0,testPhone:e.TEST_PHONE,twilioAccountSid:e.TWILIO_ACCOUNT_SID,twilioPhoneNumber:e.TWILIO_PHONE_NUMBER,twilioAuthToken:e.TWILIO_AUTH_TOKEN,supabaseUrl:e.SUPABASE_URL,supabaseProjectRef:e.SUPABASE_PROJECT_REF,supabaseServiceKey:e.SUPABASE_SERVICE_KEY,supabasePat:e.SUPABASE_PAT,deployProvider:Qe(e.DEPLOY_PROVIDER)??Ie,vercelToken:e.VERCEL_TOKEN,vercelScope:e.VERCEL_SCOPE||void 0,cloudflareApiToken:e.CLOUDFLARE_API_TOKEN||void 0,cloudflareAccountId:e.CLOUDFLARE_ACCOUNT_ID||void 0,netlifyAuthToken:e.NETLIFY_AUTH_TOKEN||void 0,netlifyAccountSlug:e.NETLIFY_ACCOUNT_SLUG||void 0,googlePlacesApiKey:e.GOOGLE_PLACES_API_KEY,serpapiKey:e.SERPAPI_KEY,emailPassword:e.EMAIL_PASSWORD,telegramBotToken:e.TELEGRAM_BOT_TOKEN,telegramChatId:e.TELEGRAM_CHAT_ID}}function Se(e){let n=E=>{let v=e[E];if(!v)return;let y=parseInt(v,10);return isNaN(y)?void 0:y},s=e.SUPABASE_URL,t=e.SUPABASE_SERVICE_KEY?.replace(/\s+/g,""),i=e.SUPABASE_PAT?.replace(/\s+/g,""),a=e.SUPABASE_PROJECT_REF,l=e.PRICING,c=e.PRICING_TERMS||"one-off, no monthly fees",p=Qe(e.DEPLOY_PROVIDER)??Ie,g=e.VERCEL_TOKEN,r=e.CLOUDFLARE_API_TOKEN,A=e.CLOUDFLARE_ACCOUNT_ID,h=e.NETLIFY_AUTH_TOKEN;if(!l||!s||!t||!i||!a||!(p==="cloudflare"?!!r&&!!A:p==="netlify"?!!h:!!g))return null;let L=e.SMS_PROVIDER,V=E=>E==="email"||E==="sms"||E==="whatsapp",D=e.OUTREACH_CHANNELS?.split(",").map(E=>E.trim()).filter(V),T=e.OUTREACH_PRIORITY?.split(",").map(E=>E.trim()).filter(V),S=e.WHATSAPP_ACCOUNTS?.split(",").map(E=>E.trim()).filter(E=>E.length>0);return{licenseKey:e.KLAUDIUS_LICENSE_KEY,aiAgent:Je(e.AI_AGENT)??Ce,country:e.OPERATOR_COUNTRY||void 0,countryCode:e.OPERATOR_COUNTRY_CODE||void 0,language:e.OPERATOR_LANGUAGE||void 0,languageCode:e.OPERATOR_LANGUAGE_CODE||void 0,pricing:l,pricingTerms:c,pricingMonthly:e.PRICING_MONTHLY||void 0,outreachEnabled:e.OUTREACH_ENABLED?.toLowerCase()==="true",name:e.OPERATOR_NAME,signature:e.SIGNATURE,outreachChannels:D&&D.length>0?D:void 0,outreachPriority:T&&T.length>0?T:void 0,whatsappAccounts:S&&S.length>0?S:void 0,emailAddress:e.EMAIL_ADDRESS,emailPassword:e.EMAIL_PASSWORD,emailFromName:e.EMAIL_FROM_NAME,emailSmtpHost:e.EMAIL_SMTP_HOST,emailSmtpPort:n("EMAIL_SMTP_PORT"),emailImapHost:e.EMAIL_IMAP_HOST,emailImapPort:n("EMAIL_IMAP_PORT"),emailSentFolder:e.EMAIL_SENT_FOLDER,emailInboxFolder:e.EMAIL_INBOX_FOLDER,smsProvider:L==="imessage"||L==="twilio"?L:void 0,testPhone:e.TEST_PHONE,twilioAccountSid:e.TWILIO_ACCOUNT_SID,twilioAuthToken:e.TWILIO_AUTH_TOKEN,twilioPhoneNumber:e.TWILIO_PHONE_NUMBER,deployProvider:p,vercelToken:g,vercelScope:e.VERCEL_SCOPE||void 0,cloudflareApiToken:r||void 0,cloudflareAccountId:A||void 0,netlifyAuthToken:h||void 0,netlifyAccountSlug:e.NETLIFY_ACCOUNT_SLUG||void 0,supabaseUrl:s,supabaseServiceKey:t,supabasePat:i,supabaseProjectRef:a,googlePlacesApiKey:e.GOOGLE_PLACES_API_KEY,serpapiKey:e.SERPAPI_KEY,telegramBotToken:e.TELEGRAM_BOT_TOKEN,telegramChatId:e.TELEGRAM_CHAT_ID}}import{mkdir as nn,rm as sn}from"fs/promises";import{Readable as on}from"stream";import*as nt from"tar";var an="https://klaudius.dev/api/template";function rn(e){return on.fromWeb(e)}async function he(e){let n=process.env.KLAUDIUS_TEMPLATE_URL??an,s="0.17.3",t;try{t=await fetch(n,{method:"POST",headers:{Authorization:`Bearer ${e.licenseKey}`,"Content-Type":"application/json"},body:JSON.stringify({machine_id:e.machineId,hostname:e.hostname,os:e.os,cli_version:s,...e.agent==="codex"?{agent:"codex"}:{}})})}catch(l){throw new Error(`Could not reach klaudius.dev to download the template: ${P(l)}`)}if(!t.ok){let l="";try{let c=await t.json();l=c.reason?` (${c.reason})`:""}catch{}throw new Error(`Template download failed: HTTP ${t.status}${l}`)}if(!t.body)throw new Error("Template download succeeded but response had no body");let i=t.headers.get("x-klaudius-tier");await nn(e.destDir,{recursive:!0});let a=0;try{await new Promise((l,c)=>{let p=nt.extract({cwd:e.destDir,strict:!0,onReadEntry:()=>{a++}});p.on("finish",l),p.on("error",c),rn(t.body).on("error",c).pipe(p)})}catch(l){throw await sn(e.destDir,{recursive:!0,force:!0}).catch(()=>{}),new Error(`Failed to extract template archive: ${l.message}`)}return{filesExtracted:a,tier:i}}import B from"picocolors";var o={info:e=>console.log(B.cyan("\u2139"),e),success:e=>console.log(B.green("\u2713"),e),warn:e=>console.log(B.yellow("\u26A0"),e),error:e=>console.error(B.red("\u2717"),e),step:e=>console.log(B.dim("\u2192"),e),blank:()=>console.log(""),heading:e=>console.log(`
15
+ `+B.bold(B.cyan(e))),detail:e=>console.log(B.dim(" "+e))};var ln="https://registry.npmjs.org/klaudius/latest";async function cn(e=1500){let n=new AbortController,s=setTimeout(()=>n.abort(),e);try{let t=await fetch(ln,{signal:n.signal,headers:{accept:"application/json"}});if(!t.ok)return null;let i=await t.json();return typeof i.version=="string"?i.version:null}catch{return null}finally{clearTimeout(s)}}function dn(e,n){let s=a=>a.split("-")[0].split(".").map(l=>Number.parseInt(l,10)),t=s(e),i=s(n);if(t.length<3||i.length<3)return!1;for(let a=0;a<3;a++){if(Number.isNaN(t[a])||Number.isNaN(i[a]))return!1;if(t[a]>i[a])return!0;if(t[a]<i[a])return!1}return!1}async function ge(e,n){if(n==="dev"||process.env.CI||process.env.NO_UPDATE_NOTIFIER)return;let s=await cn();!s||!dn(s,n)||(o.blank(),o.warn(`A newer Klaudius CLI is available: you have ${n}, latest is ${s}.`),e==="update"&&(o.detail("Your project content is fetched fresh either way, so you're not missing any"),o.detail("pipeline updates. But the CLI itself, including its update logic, is behind.")),o.detail(`Re-run with \`npx klaudius@latest ${e}\` to use the latest CLI.`),o.blank())}import{createHash as un}from"crypto";import{hostname as st,userInfo as pn,platform as ot,arch as it}from"os";var fn="https://klaudius.dev",mn="/api/licenses/validate",hn="0.17.3";async function at(e){if(!e||e.trim().length===0)return{ok:!1,reason:"No license key provided. Pass one via --license <key> or paste it when prompted."};let n=e.trim(),t=(process.env.KLAUDIUS_API_URL??fn).replace(/\/$/,"")+mn,i=ae(),a;try{a=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({license_key:n,machine_id:i,hostname:st(),os:`${ot()}-${it()}`,cli_version:hn})})}catch(c){return{ok:!1,reason:`Could not reach the Klaudius license server (${P(c)}). Check your internet connection or try again later.`}}let l;try{l=await a.json()}catch{return{ok:!1,reason:`License server returned an unparseable response (HTTP ${a.status}).`}}return l.ok?{ok:!0,tier:l.tier??"core"}:{ok:!1,reason:l.reason??`License rejected (HTTP ${a.status}).`}}function ae(){let e=[st(),pn().username,ot(),it()].join("|");return un("sha256").update(e).digest("hex").slice(0,32)}import{readFile as gn}from"fs/promises";import{join as yn}from"path";async function ee(e){let n=e.serviceKey.replace(/\s+/g,"");try{let s=await fetch(e.url+"/rest/v1/",{headers:{apikey:n,Authorization:`Bearer ${n}`}});return s.status===401||s.status===403?{ok:!1,message:`Supabase rejected auth (HTTP ${s.status}). Check SUPABASE_SERVICE_KEY.`}:{ok:!0}}catch(s){return{ok:!1,message:`Could not reach Supabase: ${P(s)}`}}}async function rt(e){let n;try{n=await gn(yn(e.projectRoot,"scripts","schema.sql"),"utf-8")}catch(t){return{ok:!1,message:`Could not read scripts/schema.sql: ${t.message}`}}let s=e.pat.replace(/\s+/g,"");try{let t=await fetch(`https://api.supabase.com/v1/projects/${e.projectRef}/database/query`,{method:"POST",headers:{Authorization:`Bearer ${s}`,"Content-Type":"application/json"},body:JSON.stringify({query:n})});if(t.ok)return{ok:!0};let i=await t.text();return i.includes("already exists")||i.includes('relation "clients" already exists')||i.includes("duplicate")?(o.detail("Schema appears already applied (tables exist). Skipping."),{ok:!0}):{ok:!1,message:`Supabase Management API rejected schema (HTTP ${t.status}): ${i.slice(0,300)}`}}catch(t){return{ok:!1,message:`Schema apply failed: ${t.message}`}}}async function ye(e){try{let n=await fetch("https://api.vercel.com/v2/user",{headers:{Authorization:`Bearer ${e}`}});if(n.status===401||n.status===403)return{ok:!1,message:`Vercel rejected the token (HTTP ${n.status}). The token is invalid, expired, or has been revoked.`};if(!n.ok)return{ok:!1,message:`Vercel API returned HTTP ${n.status}. Try again or check status.vercel.com.`};let s=await n.json();return{ok:!0,username:s.user?.username??s.user?.email}}catch(n){return{ok:!1,message:`Could not reach Vercel: ${P(n)}`}}}var lt="https://api.cloudflare.com/client/v4";function ct(e){let n=e?.errors?.[0];if(n)return n.message?`${n.message}${n.code?` (code ${n.code})`:""}`:void 0}async function ke(e){let{token:n,accountId:s}=e,t={Authorization:`Bearer ${n}`,"Content-Type":"application/json"};try{let i=await fetch(`${lt}/user/tokens/verify`,{headers:t});if(i.status===401||i.status===403)return{ok:!1,message:`Cloudflare rejected the token (HTTP ${i.status}). The token is invalid, expired, or has been revoked. Create a fresh one at https://dash.cloudflare.com/profile/api-tokens.`};if(!i.ok)return{ok:!1,message:`Cloudflare API returned HTTP ${i.status} verifying the token. Try again or check cloudflarestatus.com.`};let a=await i.json(),l=a.result?.status;if(a.success===!1||l&&l!=="active")return{ok:!1,message:`Cloudflare reports the token is not active${l?` (status: ${l})`:""}. ${ct(a)??"Create a fresh token at https://dash.cloudflare.com/profile/api-tokens."}`}}catch(i){return{ok:!1,message:`Could not reach Cloudflare: ${P(i)}`}}try{let i=await fetch(`${lt}/accounts/${encodeURIComponent(s)}/pages/projects`,{headers:t});if(i.status===403)return{ok:!1,message:`The token is valid but can't manage Pages in account ${s} (HTTP 403). Most likely the token is missing the "Account \u2192 Cloudflare Pages \u2192 Edit" permission, or the Account ID belongs to a different account than the token. Re-create the token with that exact permission and your account selected under "Account Resources".`};if(i.status===404)return{ok:!1,message:`Account ${s} was not found (HTTP 404). Double-check the Account ID \u2014 it's the 32-character hex string in the dashboard URL (dash.cloudflare.com/<ID>).`};if(!i.ok)return{ok:!1,message:`Cloudflare API returned HTTP ${i.status} listing Pages projects. Try again or check cloudflarestatus.com.`};let a=await i.json();return a.success===!1?{ok:!1,message:ct(a)??"Cloudflare rejected the Pages project listing request."}:{ok:!0,projectCount:Array.isArray(a.result)?a.result.length:void 0}}catch(i){return{ok:!1,message:`Could not reach Cloudflare: ${P(i)}`}}}var dt="https://api.netlify.com/api/v1";async function we(e){let{token:n}=e,s={Authorization:`Bearer ${n}`};try{let t=await fetch(`${dt}/user`,{headers:s});if(t.status===401||t.status===403)return{ok:!1,message:`Netlify rejected the token (HTTP ${t.status}). The token is invalid, expired, or has been revoked. Create a fresh one at https://app.netlify.com/user/applications#personal-access-tokens.`};if(!t.ok)return{ok:!1,message:`Netlify API returned HTTP ${t.status} verifying the token. Try again or check netlifystatus.com.`}}catch(t){return{ok:!1,message:`Could not reach Netlify: ${P(t)}`}}try{let t=await fetch(`${dt}/accounts`,{headers:s});if(!t.ok)return{ok:!1,message:`Netlify API returned HTTP ${t.status} listing your teams. Try again or check netlifystatus.com.`};let i=await t.json(),a=Array.isArray(i)?i:[];if(a.length===0)return{ok:!1,message:"The token is valid but isn't a member of any Netlify team. Klaudius creates each client's site under a team, so it needs at least one. Open https://app.netlify.com and confirm your account has a team."};let l=typeof a[0]?.slug=="string"?a[0].slug:void 0;return{ok:!0,accountCount:a.length,accountSlug:l}}catch(t){return{ok:!1,message:`Could not reach Netlify: ${P(t)}`}}}async function Ae(e){try{let n=await fetch("https://places.googleapis.com/v1/places:searchText",{method:"POST",headers:{"Content-Type":"application/json","X-Goog-Api-Key":e,"X-Goog-FieldMask":"places.id"},body:JSON.stringify({textQuery:"x"})});if(n.ok)return{ok:!0};if(n.status===429)return{ok:!0};let s={};try{s=await n.json()}catch{}let t=s.error?.message??"",i=s.error?.status??"";return n.status===400&&(i==="PERMISSION_DENIED"||/Places API \(New\) has not been enabled|API_KEY_SERVICE_BLOCKED/i.test(t))?{ok:!1,message:"Key is valid, but Places API (New) is not enabled on its Cloud project. Open https://console.cloud.google.com/apis/library and enable 'Places API (New)' for the project this key belongs to, then try again."}:n.status===401||n.status===403?{ok:!1,message:t||`Google rejected the key (HTTP ${n.status}). Common causes: invalid key, billing not enabled on the Cloud project, or API key restrictions blocking this caller.`}:{ok:!1,message:`Google API returned HTTP ${n.status}${t?`: ${t}`:""}.`}}catch(n){return{ok:!1,message:`Could not reach Google: ${P(n)}`}}}import kn from"nodemailer";import{ImapFlow as wn}from"imapflow";async function pt(e){let n=kn.createTransport({host:e.emailSmtpHost,port:e.emailSmtpPort,secure:e.emailSmtpPort===465,auth:{user:e.emailAddress,pass:e.emailPassword},connectionTimeout:1e4,greetingTimeout:5e3,socketTimeout:1e4});try{await n.verify()}catch(t){return{ok:!1,failedAt:"smtp",message:ut(t,"SMTP")}}finally{n.close()}let s=new wn({host:e.emailImapHost,port:e.emailImapPort,secure:e.emailImapPort===993,auth:{user:e.emailAddress,pass:e.emailPassword},logger:!1});try{await s.connect(),await s.logout()}catch(t){try{await s.logout()}catch{}return{ok:!1,failedAt:"imap",message:ut(t,"IMAP")}}return{ok:!0}}function ut(e,n){let s=e instanceof Error?e.message:String(e),t=s.toLowerCase();return t.includes("invalid credentials")||t.includes("authentication failed")||t.includes("auth failed")||t.includes("login failed")?`${n} rejected the credentials. Most common causes:
16
16
  \u2022 The app password is wrong, expired, or for a different provider.
17
17
  \u2022 The email address doesn't match the account that issued the password.
18
- \u2022 2FA is required but no app-specific password was generated.`:t.includes("etimedout")||t.includes("timeout")?`${n} server didn't respond in time. Check the host/port, or your network.`:t.includes("enotfound")||t.includes("getaddrinfo")?`${n} host could not be resolved. Check the host setting.`:`${n} check failed: ${o}`}async function ut(e){if(!e.accountSid||!e.authToken)return{ok:!1,message:"Missing Twilio Account SID or Auth Token."};let n=`https://api.twilio.com/2010-04-01/Accounts/${encodeURIComponent(e.accountSid)}.json`,o=Buffer.from(`${e.accountSid}:${e.authToken}`).toString("base64");try{let t=await fetch(n,{headers:{Authorization:`Basic ${o}`}});if(t.status===401)return{ok:!1,message:"Twilio rejected the credentials (401). Check the Account SID and Auth Token from https://console.twilio.com/ \u2014 the Auth Token shown there is the value to paste."};if(!t.ok)return{ok:!1,message:`Twilio API returned HTTP ${t.status}. Try again or check status.twilio.com.`};let i=await t.json();return i.status&&i.status!=="active"?{ok:!1,message:`Twilio account is in '${i.status}' state. Check the console for any holds before sending SMS.`}:{ok:!0,friendlyName:i.friendly_name}}catch(t){return{ok:!1,message:`Could not reach Twilio: ${P(t)}`}}}import{spawn as wn}from"child_process";async function pt(e){if(process.platform!=="darwin")return{ok:!1,message:"iMessage send is only supported on macOS. To run init from a non-Mac, switch the SMS provider to Twilio in the wizard."};let o=`tell application "Messages" to send "Klaudius connected (setup ping; ignore)." to buddy "${e.testPhone.replace(/"/g,"")}"`,t=await An(o);if(t.code===0)return{ok:!0};let i=t.stderr.toLowerCase();return i.includes("can't get application")||i.includes("isn't running")||i.includes("can't make some data")?{ok:!1,message:"Messages.app didn't respond. Open Messages on your Mac and sign in with your Apple ID, then retry."}:i.includes("(-1728)")||i.includes("not found")||i.includes("buddy")?{ok:!1,message:`Couldn't reach ${e.testPhone}. Either the number format is wrong (use the international format with a leading +) or this Mac doesn't have a path to that number. If TEST_PHONE is a non-Apple phone (Android), you need an iPhone signed into the same Apple ID with Settings \u2192 Messages \u2192 Text Message Forwarding turned ON for this Mac.`}:i.includes("(-1719)")||i.includes("(-25006)")?{ok:!1,message:"Messages.app refused the send \u2014 usually means iMessage isn't configured on this Mac. Open Messages \u2192 Settings \u2192 iMessage and sign in with your Apple ID."}:{ok:!1,message:`osascript error: ${t.stderr.trim()||`exit code ${t.code}`}`}}function An(e){return new Promise(n=>{let o=wn("osascript",["-e",e],{stdio:["ignore","ignore","pipe"]}),t="";o.stderr.on("data",i=>{t+=i.toString()}),o.on("close",i=>n({code:i??1,stderr:t})),o.on("error",i=>n({code:1,stderr:i.message}))})}import{spawn as ft}from"child_process";function En(){let e=process.env.NODE_OPTIONS?.trim(),n=e?`${e} --use-system-ca`:"--use-system-ca";return{...process.env,NODE_OPTIONS:n}}var te=2,mt=2e3,Pn=[/ECONNRESET/,/ETIMEDOUT/,/ENOTFOUND/,/EAI_AGAIN/,/socket hang up/i,/Connection reset/i,/network timeout/i,/could not resolve host/i];function ht(e,n){let o=e+`
19
- `+n;return Pn.some(t=>t.test(o))}function gt(e){return new Promise(n=>setTimeout(n,e))}function bn(e,n,o){return new Promise(t=>{let i=ft(e,n,{cwd:o.cwd,stdio:["ignore","pipe","pipe"],shell:!1,env:o.env??process.env}),a="",l="";i.stdout?.on("data",c=>{let f=c.toString();a+=f,process.stdout.write(f)}),i.stderr?.on("data",c=>{let f=c.toString();l+=f,process.stderr.write(f)}),i.on("close",c=>t({code:c??1,stdout:a,stderr:l})),i.on("error",c=>t({code:1,stdout:a,stderr:l+c.message}))})}async function Re(e,n,o){let t={code:0,stdout:"",stderr:""};for(let i=0;i<=te;i++){if(t=await bn(e,n,{cwd:o.cwd,env:o.env}),t.code===0||!ht(t.stderr,t.stdout))return t;i<te&&(s.detail(`${o.label} failed with a transient network error \u2014 retrying (${i+2}/${te+1})\u2026`),await gt(mt))}return t}function Tn(e,n,o){return new Promise(t=>{let i=ft(e,n,{cwd:o.cwd,stdio:["ignore","pipe","pipe"],shell:!1}),a="",l="";i.stdout?.on("data",c=>{a+=c.toString()}),i.stderr?.on("data",c=>{l+=c.toString()}),i.on("close",c=>t({code:c??1,stdout:a,stderr:l})),i.on("error",c=>t({code:1,stdout:a,stderr:l+c.message}))})}var _n=[{pattern:/UNABLE_TO_VERIFY_LEAF_SIGNATURE|unable to verify the first certificate/i,hint:"TLS-handshake error \u2014 your machine appears to be intercepting HTTPS (antivirus, corporate proxy, or VPN re-signing traffic with its own root CA). We work around this with NODE_OPTIONS=--use-system-ca, which needs Node 22.15+. Run `node --version` to verify, upgrade if older, then re-run setup."},{pattern:/Microsoft Visual C\+\+ 14\.0 or greater is required/i,hint:"Python tried to compile a package from source and couldn't find the Microsoft C++ Build Tools. The latest Klaudius pins supabase<2.26 to skip the offending dependency entirely. Re-run with `npx klaudius@latest init` (pulls the latest) \u2014 that should bypass the source build."}];function Cn(e){let n=`${e.stderr??""}
20
- ${e.stdout??""}`;return _n.find(t=>t.pattern.test(n))?.hint}async function In(e){let n=["supabase<2.26","python-dotenv","requests","httpx","Pillow","truststore"],o=["-m","pip","install","--quiet","--user","--prefer-binary"],i=(await Te())?.command??["python3"],a=async c=>{let f={code:0,stdout:"",stderr:""};for(let g=0;g<=te;g++){if(f=await Tn(i[0],[...i.slice(1),...c],{cwd:e}),f.code===0||!ht(f.stderr,f.stdout))return f;g<te&&(s.detail(`pip install hit a transient network error \u2014 retrying (${g+2}/${te+1})\u2026`),await gt(mt))}return f},l=await a([...o,"--break-system-packages",...n]);return l.code!==0&&/no such option:.*break-system-packages/i.test(l.stderr)&&(s.detail("Older pip detected; retrying without --break-system-packages"),l=await a([...o,...n])),l.code!==0&&(l.stderr.trim()&&process.stderr.write(l.stderr),l.stdout.trim()&&process.stdout.write(l.stdout)),l}async function Ae(e){let n={npm:"skipped",pip:"skipped",playwright:"skipped",patchright:"skipped"},o=En(),t=(f,g)=>{let r=Cn(g);r&&((n.hints??={})[f]=r)};s.step("Running npm install (Next.js, Playwright JS, etc.)...");let i=await Re("npm",["install"],{cwd:e,label:"npm install",env:o});n.npm=i.code===0?"ok":"failed",i.code!==0&&t("npm",i),s.step("Installing Python packages (supabase, dotenv, requests, httpx, Pillow)...");let a=await In(e);n.pip=a.code===0?"ok":"failed",a.code!==0&&t("pip",a),s.step("Installing Playwright browser (chromium ~200MB; one-time)...");let l=await Re("npx",["playwright","install","chromium"],{cwd:e,label:"playwright install",env:o});n.playwright=l.code===0?"ok":"failed",l.code!==0&&t("playwright",l),s.step("Installing Patchright browser (chromium ~200MB; one-time)...");let c=await Re("npx",["patchright","install","chromium"],{cwd:e,label:"patchright install",env:o});return n.patchright=c.code===0?"ok":"failed",c.code!==0&&t("patchright",c),n}import{mkdir as Sn,readFile as Rn,writeFile as xn}from"fs/promises";import{join as yt}from"path";async function Ee(e,n){let o=yt(e,".claude");await Sn(o,{recursive:!0});let t=yt(o,"settings.json"),i={};try{let f=await Rn(t,"utf-8"),g=JSON.parse(f);g&&typeof g=="object"&&!Array.isArray(g)&&(i=g)}catch{}let a=i.enabledMcpjsonServers,l=Array.isArray(a)?a.filter(f=>typeof f=="string"):[];l.includes(n)||l.push(n);let c={...i,enabledMcpjsonServers:l};await xn(t,JSON.stringify(c,null,2)+`
21
- `,"utf-8")}var At="0.17.1",b=5;function Y(e,n){s.blank(),s.error(`${e} validation failed ${b} times in a row. Pausing setup so you don't get stuck in a loop.`),s.detail(`Last error: ${n}`),s.blank(),s.detail("Your credentials are saved in `.env`. Two ways forward:"),s.detail(" \u2022 Open `.env` in any text editor, fix the value, re-run `npx klaudius@latest init` and pick Resume."),s.detail(" \u2022 Or email hello@klaudius.dev with the error above and we'll dig in."),s.blank(),process.exit(1)}async function Pt(e){let n=e.target??".",o=Nn(n)?n:On(process.cwd(),n),t=Un(o);t&&(s.error("Klaudius can't be installed inside a protected system folder."),s.detail(`Path: ${o}`),s.detail(`Reason: ${t}`),s.blank(),s.detail("Pick a normal user folder instead \u2014 Documents and Desktop are the safe defaults."),s.blank(),process.platform==="win32"?(s.detail("For example, open a fresh PowerShell window (not 'Run as Administrator') and run:"),console.log(` ${u.cyan("cd $HOME\\Documents")}`),console.log(` ${u.cyan("npx klaudius@latest init my-agency")}`)):(s.detail("For example:"),console.log(` ${u.cyan("cd ~/Documents")}`),console.log(` ${u.cyan("npx klaudius@latest init my-agency")}`)),s.blank(),process.exit(1)),process.platform==="win32"&&jn()&&(s.warn("You appear to be running in an elevated (Administrator) PowerShell."),s.detail("This isn't fatal, but Python paths and Playwright's browser cache will land in a different location than a normal user shell, which often causes installs to fail or run-time scripts to break. Easiest fix: close this window, open a new regular PowerShell (NOT 'Run as Administrator'), then re-run npx klaudius@latest init."),s.blank()),await he("init",At);let i=await Ln(o);if(i.kind==="scaffolded"){s.blank(),s.warn(`Found an existing Klaudius project at ${u.bold(o)}.`),s.detail("(Your .env and project files are in place.)"),s.blank(),i.nodeModulesMissing?(s.detail("It looks like a previous setup didn't finish installing dependencies."),s.detail("To pick up where it left off, run:"),s.blank(),o!==process.cwd()&&console.log(` ${u.cyan(`cd ${n}`)}`),console.log(` ${u.cyan("npx klaudius@latest install")} ${u.dim("# retries npm + pip + browsers; idempotent")}`),s.blank(),s.detail("Then verify with:"),s.blank(),console.log(` ${u.cyan("npx klaudius@latest doctor")} ${u.dim("# checks Node / Python / installers / credentials")}`),s.blank()):(s.detail("Everything is scaffolded and dependencies look installed."),s.detail("Pick the action you wanted:"),s.blank(),console.log(` ${u.cyan("npx klaudius@latest doctor")} ${u.dim("# verify Node / Python / installers / credentials")}`),console.log(` ${u.cyan("npx klaudius@latest configure")} ${u.dim("# change a credential / API key")}`),console.log(` ${u.cyan("npx klaudius@latest update")} ${u.dim("# pull the latest skills, scripts, lessons")}`),s.blank()),s.detail("If you wanted to start over from scratch, delete this folder and re-run `npx klaudius@latest init`."),s.blank();return}if(i.kind==="occupied"){let d=n===".";s.error("Klaudius needs an empty folder to scaffold into. This directory isn't empty."),s.detail(`Path: ${o}`),s.detail(`Contains: ${i.entries.slice(0,5).join(", ")}${i.entries.length>5?`, \u2026 (+${i.entries.length-5} more)`:""}`),s.blank(),d?(s.detail("Two ways forward:"),s.blank(),s.detail("1. Pass a folder name and Klaudius creates it for you:"),console.log(` ${u.cyan("npx klaudius@latest init my-agency")}`),s.blank(),s.detail("2. Or cd into an empty folder first, then re-run:"),console.log(` ${u.cyan("mkdir my-agency && cd my-agency && npx klaudius@latest init")}`)):(s.detail(`The folder '${n}' already exists and isn't empty.`),s.detail("Either pick a different name:"),console.log(` ${u.cyan(`npx klaudius@latest init ${n}-2`)}`),s.detail("\u2026or delete the existing folder if it's safe to remove.")),process.exit(1)}let a=await Mn(e.license),l=k.spinner();l.start("Validating license");let c=await ot(a);c.ok||(l.stop(`License invalid: ${c.reason??"unknown"}`,2),s.detail("If you believe this is in error, email hello@klaudius.dev with your purchase details."),process.exit(1)),l.stop(`License valid (${c.tier??"core"} tier)`);let f=await Z();f.ok||(s.error(f.message??"Python version check failed."),s.blank(),s.detail("Once you've installed Python 3.10+, re-run `npx klaudius@latest init` in this folder."),process.exit(1));let g=G();g.ok||(s.error(g.message??"Node.js version check failed."),s.blank(),s.detail("Once you've installed Node.js 22.15+, re-run `npx klaudius@latest init` in this folder."),process.exit(1));let r,A=!1;if(i.kind==="partial")if(await Dn(o)==="resume"){let m=await kt(i.envPath,"utf-8"),p=Se($(m));p?(s.success("Resuming with values from your existing .env"),s.detail("(Skipping the wizard \u2014 edit .env directly if you need to change anything.)"),r=p,A=!0):(s.warn("Existing .env was missing required fields \u2014 starting wizard fresh."),r=await I())}else{let m=await kt(i.envPath,"utf-8"),p=Se($(m));r=await I(p??{})}else r=await I();r.licenseKey=a,await M(o,r),A||(s.success("Saved .env"),s.success(r.aiAgent==="codex"?"Saved .codex/config.toml":"Saved .mcp.json")),s.blank();for(let d=1;;d++){let m=k.spinner();m.start("Validating Supabase credentials");let p=await ee({url:r.supabaseUrl,serviceKey:r.supabaseServiceKey});if(p.ok){m.stop("Supabase credentials accepted");break}m.stop(p.message??"Supabase check failed",2),d>=b&&Y("Supabase",p.message??"Supabase check failed");let w=p.message??"Supabase check failed";s.blank(),s.warn(`Bouncing you back into the Supabase section so you can fix it in place. (attempt ${d+1} of ${b})`),s.detail("(Press Enter through any field to keep its current value. Ctrl+C to exit.)"),s.blank(),r=await I(r,{onlySection:"supabase",banner:`Supabase rejected your credentials:
18
+ \u2022 2FA is required but no app-specific password was generated.`:t.includes("etimedout")||t.includes("timeout")?`${n} server didn't respond in time. Check the host/port, or your network.`:t.includes("enotfound")||t.includes("getaddrinfo")?`${n} host could not be resolved. Check the host setting.`:`${n} check failed: ${s}`}async function ft(e){if(!e.accountSid||!e.authToken)return{ok:!1,message:"Missing Twilio Account SID or Auth Token."};let n=`https://api.twilio.com/2010-04-01/Accounts/${encodeURIComponent(e.accountSid)}.json`,s=Buffer.from(`${e.accountSid}:${e.authToken}`).toString("base64");try{let t=await fetch(n,{headers:{Authorization:`Basic ${s}`}});if(t.status===401)return{ok:!1,message:"Twilio rejected the credentials (401). Check the Account SID and Auth Token from https://console.twilio.com/ \u2014 the Auth Token shown there is the value to paste."};if(!t.ok)return{ok:!1,message:`Twilio API returned HTTP ${t.status}. Try again or check status.twilio.com.`};let i=await t.json();return i.status&&i.status!=="active"?{ok:!1,message:`Twilio account is in '${i.status}' state. Check the console for any holds before sending SMS.`}:{ok:!0,friendlyName:i.friendly_name}}catch(t){return{ok:!1,message:`Could not reach Twilio: ${P(t)}`}}}import{spawn as An}from"child_process";async function mt(e){if(process.platform!=="darwin")return{ok:!1,message:"iMessage send is only supported on macOS. To run init from a non-Mac, switch the SMS provider to Twilio in the wizard."};let s=`tell application "Messages" to send "Klaudius connected (setup ping; ignore)." to buddy "${e.testPhone.replace(/"/g,"")}"`,t=await En(s);if(t.code===0)return{ok:!0};let i=t.stderr.toLowerCase();return i.includes("can't get application")||i.includes("isn't running")||i.includes("can't make some data")?{ok:!1,message:"Messages.app didn't respond. Open Messages on your Mac and sign in with your Apple ID, then retry."}:i.includes("(-1728)")||i.includes("not found")||i.includes("buddy")?{ok:!1,message:`Couldn't reach ${e.testPhone}. Either the number format is wrong (use the international format with a leading +) or this Mac doesn't have a path to that number. If TEST_PHONE is a non-Apple phone (Android), you need an iPhone signed into the same Apple ID with Settings \u2192 Messages \u2192 Text Message Forwarding turned ON for this Mac.`}:i.includes("(-1719)")||i.includes("(-25006)")?{ok:!1,message:"Messages.app refused the send \u2014 usually means iMessage isn't configured on this Mac. Open Messages \u2192 Settings \u2192 iMessage and sign in with your Apple ID."}:{ok:!1,message:`osascript error: ${t.stderr.trim()||`exit code ${t.code}`}`}}function En(e){return new Promise(n=>{let s=An("osascript",["-e",e],{stdio:["ignore","ignore","pipe"]}),t="";s.stderr.on("data",i=>{t+=i.toString()}),s.on("close",i=>n({code:i??1,stderr:t})),s.on("error",i=>n({code:1,stderr:i.message}))})}import{spawn as xe}from"child_process";function Pn(){let e=process.env.NODE_OPTIONS?.trim(),n=e?`${e} --use-system-ca`:"--use-system-ca";return{...process.env,NODE_OPTIONS:n}}var te=2,ht=2e3,bn=[/ECONNRESET/,/ETIMEDOUT/,/ENOTFOUND/,/EAI_AGAIN/,/socket hang up/i,/Connection reset/i,/network timeout/i,/could not resolve host/i];function gt(e,n){let s=e+`
19
+ `+n;return bn.some(t=>t.test(s))}function yt(e){return new Promise(n=>setTimeout(n,e))}function Tn(e,n,s){return new Promise(t=>{let i=s.shell?xe([e,...n].join(" "),{cwd:s.cwd,stdio:["ignore","pipe","pipe"],shell:!0,env:s.env??process.env}):xe(e,n,{cwd:s.cwd,stdio:["ignore","pipe","pipe"],shell:!1,env:s.env??process.env}),a="",l="";i.stdout?.on("data",c=>{let p=c.toString();a+=p,process.stdout.write(p)}),i.stderr?.on("data",c=>{let p=c.toString();l+=p,process.stderr.write(p)}),i.on("close",c=>t({code:c??1,stdout:a,stderr:l})),i.on("error",c=>t({code:1,stdout:a,stderr:l+c.message}))})}async function Re(e,n,s){let t={code:0,stdout:"",stderr:""};for(let i=0;i<=te;i++){if(t=await Tn(e,n,{cwd:s.cwd,env:s.env,shell:s.shell}),t.code===0||!gt(t.stderr,t.stdout))return t;i<te&&(o.detail(`${s.label} failed with a transient network error \u2014 retrying (${i+2}/${te+1})\u2026`),await yt(ht))}return t}function _n(e,n,s){return new Promise(t=>{let i=xe(e,n,{cwd:s.cwd,stdio:["ignore","pipe","pipe"],shell:!1}),a="",l="";i.stdout?.on("data",c=>{a+=c.toString()}),i.stderr?.on("data",c=>{l+=c.toString()}),i.on("close",c=>t({code:c??1,stdout:a,stderr:l})),i.on("error",c=>t({code:1,stdout:a,stderr:l+c.message}))})}var Cn=[{pattern:/UNABLE_TO_VERIFY_LEAF_SIGNATURE|unable to verify the first certificate/i,hint:"TLS-handshake error \u2014 your machine appears to be intercepting HTTPS (antivirus, corporate proxy, or VPN re-signing traffic with its own root CA). We work around this with NODE_OPTIONS=--use-system-ca, which needs Node 22.15+. Run `node --version` to verify, upgrade if older, then re-run setup."},{pattern:/Microsoft Visual C\+\+ 14\.0 or greater is required/i,hint:"Python tried to compile a package from source and couldn't find the Microsoft C++ Build Tools. The latest Klaudius pins supabase<2.26 to skip the offending dependency entirely. Re-run with `npx klaudius@latest init` (pulls the latest) \u2014 that should bypass the source build."}];function In(e){let n=`${e.stderr??""}
20
+ ${e.stdout??""}`;return Cn.find(t=>t.pattern.test(n))?.hint}async function Sn(e){let n=["supabase<2.26","python-dotenv","requests","httpx","Pillow","truststore"],s=["-m","pip","install","--quiet","--user","--prefer-binary"],i=(await ie())?.command??["python3"],a=async c=>{let p={code:0,stdout:"",stderr:""};for(let g=0;g<=te;g++){if(p=await _n(i[0],[...i.slice(1),...c],{cwd:e}),p.code===0||!gt(p.stderr,p.stdout))return p;g<te&&(o.detail(`pip install hit a transient network error \u2014 retrying (${g+2}/${te+1})\u2026`),await yt(ht))}return p},l=await a([...s,"--break-system-packages",...n]);return l.code!==0&&/no such option:.*break-system-packages/i.test(l.stderr)&&(o.detail("Older pip detected; retrying without --break-system-packages"),l=await a([...s,...n])),l.code!==0&&(l.stderr.trim()&&process.stderr.write(l.stderr),l.stdout.trim()&&process.stdout.write(l.stdout)),l}async function Ee(e){let n={npm:"skipped",pip:"skipped",playwright:"skipped",patchright:"skipped"},s=Pn(),t=process.platform==="win32",i=(g,r)=>{let A=In(r);A&&((n.hints??={})[g]=A)};o.step("Running npm install (Next.js, Playwright JS, etc.)...");let a=await Re("npm",["install"],{cwd:e,label:"npm install",env:s,shell:t});n.npm=a.code===0?"ok":"failed",a.code!==0&&i("npm",a),o.step("Installing Python packages (supabase, dotenv, requests, httpx, Pillow)...");let l=await Sn(e);n.pip=l.code===0?"ok":"failed",l.code!==0&&i("pip",l),o.step("Installing Playwright browser (chromium ~200MB; one-time)...");let c=await Re("npx",["playwright","install","chromium"],{cwd:e,label:"playwright install",env:s,shell:t});n.playwright=c.code===0?"ok":"failed",c.code!==0&&i("playwright",c),o.step("Installing Patchright browser (chromium ~200MB; one-time)...");let p=await Re("npx",["patchright","install","chromium"],{cwd:e,label:"patchright install",env:s,shell:t});return n.patchright=p.code===0?"ok":"failed",p.code!==0&&i("patchright",p),n}import{mkdir as Rn,readFile as xn,writeFile as vn}from"fs/promises";import{join as kt}from"path";async function Pe(e,n){let s=kt(e,".claude");await Rn(s,{recursive:!0});let t=kt(s,"settings.json"),i={};try{let p=await xn(t,"utf-8"),g=JSON.parse(p);g&&typeof g=="object"&&!Array.isArray(g)&&(i=g)}catch{}let a=i.enabledMcpjsonServers,l=Array.isArray(a)?a.filter(p=>typeof p=="string"):[];l.includes(n)||l.push(n);let c={...i,enabledMcpjsonServers:l};await vn(t,JSON.stringify(c,null,2)+`
21
+ `,"utf-8")}var Et="0.17.3",b=5;function Y(e,n){o.blank(),o.error(`${e} validation failed ${b} times in a row. Pausing setup so you don't get stuck in a loop.`),o.detail(`Last error: ${n}`),o.blank(),o.detail("Your credentials are saved in `.env`. Two ways forward:"),o.detail(" \u2022 Open `.env` in any text editor, fix the value, re-run `npx klaudius@latest init` and pick Resume."),o.detail(" \u2022 Or email hello@klaudius.dev with the error above and we'll dig in."),o.blank(),process.exit(1)}async function bt(e){let n=e.target??".",s=$n(n)?n:Nn(process.cwd(),n),t=jn(s);t&&(o.error("Klaudius can't be installed inside a protected system folder."),o.detail(`Path: ${s}`),o.detail(`Reason: ${t}`),o.blank(),o.detail("Pick a normal user folder instead \u2014 Documents and Desktop are the safe defaults."),o.blank(),process.platform==="win32"?(o.detail("For example, open a fresh PowerShell window (not 'Run as Administrator') and run:"),console.log(` ${u.cyan("cd $HOME\\Documents")}`),console.log(` ${u.cyan("npx klaudius@latest init my-agency")}`)):(o.detail("For example:"),console.log(` ${u.cyan("cd ~/Documents")}`),console.log(` ${u.cyan("npx klaudius@latest init my-agency")}`)),o.blank(),process.exit(1)),process.platform==="win32"&&Kn()&&(o.warn("You appear to be running in an elevated (Administrator) PowerShell."),o.detail("This isn't fatal, but Python paths and Playwright's browser cache will land in a different location than a normal user shell, which often causes installs to fail or run-time scripts to break. Easiest fix: close this window, open a new regular PowerShell (NOT 'Run as Administrator'), then re-run npx klaudius@latest init."),o.blank()),await ge("init",Et);let i=await Dn(s);if(i.kind==="scaffolded"){o.blank(),o.warn(`Found an existing Klaudius project at ${u.bold(s)}.`),o.detail("(Your .env and project files are in place.)"),o.blank(),i.nodeModulesMissing?(o.detail("It looks like a previous setup didn't finish installing dependencies."),o.detail("To pick up where it left off, run:"),o.blank(),s!==process.cwd()&&console.log(` ${u.cyan(`cd ${n}`)}`),console.log(` ${u.cyan("npx klaudius@latest install")} ${u.dim("# retries npm + pip + browsers; idempotent")}`),o.blank(),o.detail("Then verify with:"),o.blank(),console.log(` ${u.cyan("npx klaudius@latest doctor")} ${u.dim("# checks Node / Python / installers / credentials")}`),o.blank()):(o.detail("Everything is scaffolded and dependencies look installed."),o.detail("Pick the action you wanted:"),o.blank(),console.log(` ${u.cyan("npx klaudius@latest doctor")} ${u.dim("# verify Node / Python / installers / credentials")}`),console.log(` ${u.cyan("npx klaudius@latest configure")} ${u.dim("# change a credential / API key")}`),console.log(` ${u.cyan("npx klaudius@latest update")} ${u.dim("# pull the latest skills, scripts, lessons")}`),o.blank()),o.detail("If you wanted to start over from scratch, delete this folder and re-run `npx klaudius@latest init`."),o.blank();return}if(i.kind==="occupied"){let d=n===".";o.error("Klaudius needs an empty folder to scaffold into. This directory isn't empty."),o.detail(`Path: ${s}`),o.detail(`Contains: ${i.entries.slice(0,5).join(", ")}${i.entries.length>5?`, \u2026 (+${i.entries.length-5} more)`:""}`),o.blank(),d?(o.detail("Two ways forward:"),o.blank(),o.detail("1. Pass a folder name and Klaudius creates it for you:"),console.log(` ${u.cyan("npx klaudius@latest init my-agency")}`),o.blank(),o.detail("2. Or cd into an empty folder first, then re-run:"),console.log(` ${u.cyan("mkdir my-agency && cd my-agency && npx klaudius@latest init")}`)):(o.detail(`The folder '${n}' already exists and isn't empty.`),o.detail("Either pick a different name:"),console.log(` ${u.cyan(`npx klaudius@latest init ${n}-2`)}`),o.detail("\u2026or delete the existing folder if it's safe to remove.")),process.exit(1)}let a=await Un(e.license),l=k.spinner();l.start("Validating license");let c=await at(a);c.ok||(l.stop(`License invalid: ${c.reason??"unknown"}`,2),o.detail("If you believe this is in error, email hello@klaudius.dev with your purchase details."),process.exit(1)),l.stop(`License valid (${c.tier??"core"} tier)`);let p=await Z();p.ok||(o.error(p.message??"Python version check failed."),o.blank(),o.detail("Once you've installed Python 3.10+, re-run `npx klaudius@latest init` in this folder."),process.exit(1));let g=G();g.ok||(o.error(g.message??"Node.js version check failed."),o.blank(),o.detail("Once you've installed Node.js 22.15+, re-run `npx klaudius@latest init` in this folder."),process.exit(1));let r,A=!1;if(i.kind==="partial")if(await Mn(s)==="resume"){let m=await wt(i.envPath,"utf-8"),f=Se($(m));f?(o.success("Resuming with values from your existing .env"),o.detail("(Skipping the wizard \u2014 edit .env directly if you need to change anything.)"),r=f,A=!0):(o.warn("Existing .env was missing required fields \u2014 starting wizard fresh."),r=await I())}else{let m=await wt(i.envPath,"utf-8"),f=Se($(m));r=await I(f??{})}else r=await I();r.licenseKey=a,await M(s,r),A||(o.success("Saved .env"),o.success(r.aiAgent==="codex"?"Saved .codex/config.toml":"Saved .mcp.json")),o.blank();for(let d=1;;d++){let m=k.spinner();m.start("Validating Supabase credentials");let f=await ee({url:r.supabaseUrl,serviceKey:r.supabaseServiceKey});if(f.ok){m.stop("Supabase credentials accepted");break}m.stop(f.message??"Supabase check failed",2),d>=b&&Y("Supabase",f.message??"Supabase check failed");let w=f.message??"Supabase check failed";o.blank(),o.warn(`Bouncing you back into the Supabase section so you can fix it in place. (attempt ${d+1} of ${b})`),o.detail("(Press Enter through any field to keep its current value. Ctrl+C to exit.)"),o.blank(),r=await I(r,{onlySection:"supabase",banner:`Supabase rejected your credentials:
22
22
  ${w}
23
23
 
24
24
  Re-enter the URL, secret key, or PAT below. Press Enter on any
25
- field to keep what's already there.`}),await M(o,r)}if(s.blank(),r.deployProvider==="cloudflare")for(let d=1;;d++){let m=k.spinner();m.start("Validating Cloudflare token + account");let p=await ye({token:r.cloudflareApiToken??"",accountId:r.cloudflareAccountId??""});if(p.ok){m.stop(`Cloudflare credentials accepted (${p.projectCount??0} existing Pages project${p.projectCount===1?"":"s"})`);break}m.stop(p.message??"Cloudflare check failed",2),d>=b&&Y("Cloudflare",p.message??"Cloudflare check failed");let w=p.message??"Cloudflare check failed";s.blank(),s.warn(`Bouncing you back into the Cloudflare section so you can fix it in place. (attempt ${d+1} of ${b})`),s.detail("(Press Enter on a field to keep its current value. Ctrl+C to exit.)"),s.blank(),r=await I(r,{onlySection:"cloudflare",banner:`Cloudflare rejected the credentials:
25
+ field to keep what's already there.`}),await M(s,r)}if(o.blank(),r.deployProvider==="cloudflare")for(let d=1;;d++){let m=k.spinner();m.start("Validating Cloudflare token + account");let f=await ke({token:r.cloudflareApiToken??"",accountId:r.cloudflareAccountId??""});if(f.ok){m.stop(`Cloudflare credentials accepted (${f.projectCount??0} existing Pages project${f.projectCount===1?"":"s"})`);break}m.stop(f.message??"Cloudflare check failed",2),d>=b&&Y("Cloudflare",f.message??"Cloudflare check failed");let w=f.message??"Cloudflare check failed";o.blank(),o.warn(`Bouncing you back into the Cloudflare section so you can fix it in place. (attempt ${d+1} of ${b})`),o.detail("(Press Enter on a field to keep its current value. Ctrl+C to exit.)"),o.blank(),r=await I(r,{onlySection:"cloudflare",banner:`Cloudflare rejected the credentials:
26
26
  ${w}
27
27
 
28
28
  Re-enter the API token or Account ID below. The token needs the
29
29
  "Account \u2192 Cloudflare Pages \u2192 Edit" permission. Press Enter to keep
30
- the current value.`}),await M(o,r)}else if(r.deployProvider==="netlify")for(let d=1;;d++){let m=k.spinner();m.start("Validating Netlify token");let p=await ke({token:r.netlifyAuthToken??""});if(p.ok){m.stop(p.accountSlug?`Netlify token accepted (team: ${p.accountSlug})`:"Netlify token accepted");break}m.stop(p.message??"Netlify check failed",2),d>=b&&Y("Netlify",p.message??"Netlify check failed");let w=p.message??"Netlify check failed";s.blank(),s.warn(`Bouncing you back into the Netlify section so you can fix it in place. (attempt ${d+1} of ${b})`),s.detail("(Press Enter on the field to keep its current value. Ctrl+C to exit.)"),s.blank(),r=await I(r,{onlySection:"netlify",banner:`Netlify rejected the token:
30
+ the current value.`}),await M(s,r)}else if(r.deployProvider==="netlify")for(let d=1;;d++){let m=k.spinner();m.start("Validating Netlify token");let f=await we({token:r.netlifyAuthToken??""});if(f.ok){m.stop(f.accountSlug?`Netlify token accepted (team: ${f.accountSlug})`:"Netlify token accepted");break}m.stop(f.message??"Netlify check failed",2),d>=b&&Y("Netlify",f.message??"Netlify check failed");let w=f.message??"Netlify check failed";o.blank(),o.warn(`Bouncing you back into the Netlify section so you can fix it in place. (attempt ${d+1} of ${b})`),o.detail("(Press Enter on the field to keep its current value. Ctrl+C to exit.)"),o.blank(),r=await I(r,{onlySection:"netlify",banner:`Netlify rejected the token:
31
31
  ${w}
32
32
 
33
33
  Generate a new token at
34
34
  https://app.netlify.com/user/applications#personal-access-tokens
35
- and paste it below. Press Enter to keep the current value.`}),await M(o,r)}else for(let d=1;;d++){let m=k.spinner();m.start("Validating Vercel token");let p=await ge(r.vercelToken??"");if(p.ok){m.stop(p.username?`Vercel token accepted (signed in as ${p.username})`:"Vercel token accepted");break}m.stop(p.message??"Vercel check failed",2),d>=b&&Y("Vercel",p.message??"Vercel check failed");let w=p.message??"Vercel check failed";s.blank(),s.warn(`Bouncing you back into the Vercel section so you can fix it in place. (attempt ${d+1} of ${b})`),s.detail("(Press Enter on the field to keep its current value. Ctrl+C to exit.)"),s.blank(),r=await I(r,{onlySection:"vercel",banner:`Vercel rejected the token:
35
+ and paste it below. Press Enter to keep the current value.`}),await M(s,r)}else for(let d=1;;d++){let m=k.spinner();m.start("Validating Vercel token");let f=await ye(r.vercelToken??"");if(f.ok){m.stop(f.username?`Vercel token accepted (signed in as ${f.username})`:"Vercel token accepted");break}m.stop(f.message??"Vercel check failed",2),d>=b&&Y("Vercel",f.message??"Vercel check failed");let w=f.message??"Vercel check failed";o.blank(),o.warn(`Bouncing you back into the Vercel section so you can fix it in place. (attempt ${d+1} of ${b})`),o.detail("(Press Enter on the field to keep its current value. Ctrl+C to exit.)"),o.blank(),r=await I(r,{onlySection:"vercel",banner:`Vercel rejected the token:
36
36
  ${w}
37
37
 
38
38
  Generate a new token at https://vercel.com/account/tokens and
39
- paste it below. Press Enter to keep the current value.`}),await M(o,r)}s.blank();for(let d=1;;d++){let m=k.spinner();m.start("Validating Google Places API key");let p=await we(r.googlePlacesApiKey??"");if(p.ok){m.stop("Google Places API key accepted");break}m.stop(p.message??"Google Places check failed",2),d>=b&&Y("Google Places",p.message??"Google Places check failed");let w=p.message??"Google Places check failed";s.blank(),s.warn(`Bouncing you back into the Google Places section so you can fix it in place. (attempt ${d+1} of ${b})`),s.detail("(Press Enter on the field to keep its current value. Ctrl+C to exit.)"),s.blank(),r=await I(r,{onlySection:"google-places",banner:`Google rejected the key:
39
+ paste it below. Press Enter to keep the current value.`}),await M(s,r)}o.blank();for(let d=1;;d++){let m=k.spinner();m.start("Validating Google Places API key");let f=await Ae(r.googlePlacesApiKey??"");if(f.ok){m.stop("Google Places API key accepted");break}m.stop(f.message??"Google Places check failed",2),d>=b&&Y("Google Places",f.message??"Google Places check failed");let w=f.message??"Google Places check failed";o.blank(),o.warn(`Bouncing you back into the Google Places section so you can fix it in place. (attempt ${d+1} of ${b})`),o.detail("(Press Enter on the field to keep its current value. Ctrl+C to exit.)"),o.blank(),r=await I(r,{onlySection:"google-places",banner:`Google rejected the key:
40
40
  ${w}
41
41
 
42
42
  Generate (or fix) the key at https://console.cloud.google.com
43
- and paste it below. Press Enter to keep the current value.`}),await M(o,r)}if(r.outreachEnabled&&r.outreachChannels?.includes("email")&&r.emailAddress&&r.emailPassword&&r.emailSmtpHost&&r.emailSmtpPort&&r.emailImapHost&&r.emailImapPort){s.blank();for(let d=1;;d++){let m=k.spinner();m.start("Validating email credentials (SMTP + IMAP)");let p=await dt({emailAddress:r.emailAddress,emailPassword:r.emailPassword,emailSmtpHost:r.emailSmtpHost,emailSmtpPort:r.emailSmtpPort,emailImapHost:r.emailImapHost,emailImapPort:r.emailImapPort});if(p.ok){m.stop("Email credentials accepted (SMTP + IMAP)");break}m.stop(p.message??"Email check failed",2),d>=b&&Y("Email",p.message??"Email check failed");let w=p.message??"Email check failed";s.blank(),s.warn(`Bouncing you back into the email section so you can fix it in place. (attempt ${d+1} of ${b})`),s.detail("(Press Enter on any field to keep its current value. Ctrl+C to exit.)"),s.blank(),r=await I(r,{onlySection:"email",banner:`${p.failedAt==="imap"?"IMAP":"SMTP"} check failed:
43
+ and paste it below. Press Enter to keep the current value.`}),await M(s,r)}if(r.outreachEnabled&&r.outreachChannels?.includes("email")&&r.emailAddress&&r.emailPassword&&r.emailSmtpHost&&r.emailSmtpPort&&r.emailImapHost&&r.emailImapPort){o.blank();for(let d=1;;d++){let m=k.spinner();m.start("Validating email credentials (SMTP + IMAP)");let f=await pt({emailAddress:r.emailAddress,emailPassword:r.emailPassword,emailSmtpHost:r.emailSmtpHost,emailSmtpPort:r.emailSmtpPort,emailImapHost:r.emailImapHost,emailImapPort:r.emailImapPort});if(f.ok){m.stop("Email credentials accepted (SMTP + IMAP)");break}m.stop(f.message??"Email check failed",2),d>=b&&Y("Email",f.message??"Email check failed");let w=f.message??"Email check failed";o.blank(),o.warn(`Bouncing you back into the email section so you can fix it in place. (attempt ${d+1} of ${b})`),o.detail("(Press Enter on any field to keep its current value. Ctrl+C to exit.)"),o.blank(),r=await I(r,{onlySection:"email",banner:`${f.failedAt==="imap"?"IMAP":"SMTP"} check failed:
44
44
  ${w}
45
45
 
46
46
  Re-enter the email address, app password, or host details below.
47
- Press Enter on any field to keep its current value.`}),await M(o,r)}}if(r.outreachEnabled&&r.outreachChannels?.includes("sms")&&r.smsProvider==="twilio"&&r.twilioAccountSid&&r.twilioAuthToken){s.blank();for(let d=1;;d++){let m=k.spinner();m.start("Validating Twilio credentials");let p=await ut({accountSid:r.twilioAccountSid,authToken:r.twilioAuthToken});if(p.ok){m.stop(p.friendlyName?`Twilio credentials accepted (${p.friendlyName})`:"Twilio credentials accepted");break}m.stop(p.message??"Twilio check failed",2),d>=b&&Y("Twilio",p.message??"Twilio check failed");let w=p.message??"Twilio check failed";s.blank(),s.warn(`Bouncing you back into the SMS section so you can fix it in place. (attempt ${d+1} of ${b})`),s.detail("(Press Enter on any field to keep its current value. Ctrl+C to exit.)"),s.blank(),r=await I(r,{onlySection:"sms",banner:`Twilio rejected the credentials:
47
+ Press Enter on any field to keep its current value.`}),await M(s,r)}}if(r.outreachEnabled&&r.outreachChannels?.includes("sms")&&r.smsProvider==="twilio"&&r.twilioAccountSid&&r.twilioAuthToken){o.blank();for(let d=1;;d++){let m=k.spinner();m.start("Validating Twilio credentials");let f=await ft({accountSid:r.twilioAccountSid,authToken:r.twilioAuthToken});if(f.ok){m.stop(f.friendlyName?`Twilio credentials accepted (${f.friendlyName})`:"Twilio credentials accepted");break}m.stop(f.message??"Twilio check failed",2),d>=b&&Y("Twilio",f.message??"Twilio check failed");let w=f.message??"Twilio check failed";o.blank(),o.warn(`Bouncing you back into the SMS section so you can fix it in place. (attempt ${d+1} of ${b})`),o.detail("(Press Enter on any field to keep its current value. Ctrl+C to exit.)"),o.blank(),r=await I(r,{onlySection:"sms",banner:`Twilio rejected the credentials:
48
48
  ${w}
49
49
 
50
50
  Re-enter the Account SID or Auth Token below.
51
- Press Enter on any field to keep its current value.`}),await M(o,r)}}if(r.outreachEnabled&&r.outreachChannels?.includes("sms")&&r.smsProvider==="imessage"&&r.testPhone){s.blank();for(let d=1;;d++){let m=k.spinner();m.start("Validating iMessage setup (sending a test ping)");let p=await pt({testPhone:r.testPhone});if(p.ok){m.stop("iMessage dispatched (check your phone for the test ping)");break}m.stop(p.message??"iMessage check failed",2),d>=b&&Y("iMessage",p.message??"iMessage check failed");let w=p.message??"iMessage check failed";s.blank(),s.warn(`Bouncing you back into the SMS section so you can fix it in place. (attempt ${d+1} of ${b})`),s.detail("(Press Enter on any field to keep its current value. Ctrl+C to exit.)"),s.blank(),r=await I(r,{onlySection:"sms",banner:`iMessage check failed:
51
+ Press Enter on any field to keep its current value.`}),await M(s,r)}}if(r.outreachEnabled&&r.outreachChannels?.includes("sms")&&r.smsProvider==="imessage"&&r.testPhone){o.blank();for(let d=1;;d++){let m=k.spinner();m.start("Validating iMessage setup (sending a test ping)");let f=await mt({testPhone:r.testPhone});if(f.ok){m.stop("iMessage dispatched (check your phone for the test ping)");break}m.stop(f.message??"iMessage check failed",2),d>=b&&Y("iMessage",f.message??"iMessage check failed");let w=f.message??"iMessage check failed";o.blank(),o.warn(`Bouncing you back into the SMS section so you can fix it in place. (attempt ${d+1} of ${b})`),o.detail("(Press Enter on any field to keep its current value. Ctrl+C to exit.)"),o.blank(),r=await I(r,{onlySection:"sms",banner:`iMessage check failed:
52
52
  ${w}
53
53
 
54
54
  Either fix the underlying issue (sign in to Messages.app, configure
55
55
  Text Message Forwarding) and press Enter through, or change SMS
56
- provider to Twilio.`}),await M(o,r)}}if(r.telegramBotToken&&r.telegramChatId){s.blank();let d=0,m=!1;for(;!m;){d++;let p=k.spinner();p.start("Validating Telegram bot + chat (sending a test ping)");let w=await Fe({botToken:r.telegramBotToken,chatId:r.telegramChatId});if(w.ok){p.stop(w.botHandle?`Telegram bot ${w.botHandle} accepted, test message delivered`:"Telegram credentials accepted, test message delivered"),m=!0;break}p.stop(w.message??"Telegram check failed",2);let Ue=w.message??"Telegram check failed";s.blank(),s.warn("Telegram is optional \u2014 you can skip it now and wire it up later by editing `.env`."),s.blank();let z=await k.select({message:"What would you like to do?",initialValue:d>=2?"skip":"retry",options:[{value:"retry",label:"Retry the check (good if it was a momentary network blip)"},{value:"edit",label:"Edit my bot token / chat ID and retry"},{value:"skip",label:"Skip Telegram for now (I'll add it later by editing .env)"}]});if(k.isCancel(z)&&(k.cancel("Setup cancelled. Your .env is saved \u2014 re-run `npx klaudius@latest init` to resume."),process.exit(0)),z==="skip"){r.telegramBotToken=void 0,r.telegramChatId=void 0,await M(o,r),s.success("Skipped Telegram. Setup will continue."),s.detail("Wire it up later by pasting your bot token and chat ID into the TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID lines of `.env`."),m=!0;break}if(z==="edit"&&(s.blank(),r=await I(r,{onlySection:"telegram",banner:`Telegram check failed:
57
- ${Ue}
56
+ provider to Twilio.`}),await M(s,r)}}if(r.telegramBotToken&&r.telegramChatId){o.blank();let d=0,m=!1;for(;!m;){d++;let f=k.spinner();f.start("Validating Telegram bot + chat (sending a test ping)");let w=await Ve({botToken:r.telegramBotToken,chatId:r.telegramChatId});if(w.ok){f.stop(w.botHandle?`Telegram bot ${w.botHandle} accepted, test message delivered`:"Telegram credentials accepted, test message delivered"),m=!0;break}f.stop(w.message??"Telegram check failed",2);let je=w.message??"Telegram check failed";o.blank(),o.warn("Telegram is optional \u2014 you can skip it now and wire it up later by editing `.env`."),o.blank();let z=await k.select({message:"What would you like to do?",initialValue:d>=2?"skip":"retry",options:[{value:"retry",label:"Retry the check (good if it was a momentary network blip)"},{value:"edit",label:"Edit my bot token / chat ID and retry"},{value:"skip",label:"Skip Telegram for now (I'll add it later by editing .env)"}]});if(k.isCancel(z)&&(k.cancel("Setup cancelled. Your .env is saved \u2014 re-run `npx klaudius@latest init` to resume."),process.exit(0)),z==="skip"){r.telegramBotToken=void 0,r.telegramChatId=void 0,await M(s,r),o.success("Skipped Telegram. Setup will continue."),o.detail("Wire it up later by pasting your bot token and chat ID into the TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID lines of `.env`."),m=!0;break}if(z==="edit"&&(o.blank(),r=await I(r,{onlySection:"telegram",banner:`Telegram check failed:
57
+ ${je}
58
58
 
59
59
  Re-enter the bot token or chat_id below.
60
- Press Enter on any field to keep its current value.`}),await M(o,r),!r.telegramBotToken||!r.telegramChatId)){s.success("Skipped Telegram. Setup will continue."),m=!0;break}}}s.blank();let h=k.spinner();h.start("Downloading Klaudius template");let C;try{C=(await me({licenseKey:a,machineId:ie(),hostname:process.platform==="win32"?process.env.COMPUTERNAME:void 0,os:`${process.platform}-${process.arch}`,agent:r.aiAgent,destDir:o})).filesExtracted,h.stop(`Downloaded ${C} files into ${u.bold(o)}`)}catch(d){h.stop(d.message,2);let m=r.aiAgent==="codex"?".codex/config.toml":".mcp.json";s.detail(`Your .env / ${m} are saved. Re-run init once the issue is resolved to retry the download.`),process.exit(1)}await ve(q(o,"clients"),{recursive:!0});let L=await Ye(o);await ce(o,Be(At,L)),s.success("Wrote .klaudius/manifest.json");let V=!1,D="";if(e.skipSchema)s.warn("--skip-schema set; not applying scripts/schema.sql to your Supabase project."),s.detail(`Apply manually later via the SQL editor: ${r.supabaseUrl.replace("https://","https://supabase.com/dashboard/project/"+r.supabaseProjectRef+"/sql/new").replace(r.supabaseProjectRef+".supabase.co","")}`);else{s.blank();let d=k.spinner();d.start("Applying schema to Supabase");let m=await it({projectRoot:o,pat:r.supabasePat,projectRef:r.supabaseProjectRef});m.ok?d.stop("Schema applied (or already present)"):(d.stop(m.message??"Schema apply failed",2),V=!0,D=`https://supabase.com/dashboard/project/${r.supabaseProjectRef}/sql/new`)}let T=[],S={};if(e.skipInstall)s.warn("--skip-install set; you'll need to run npm install + pip install + playwright/patchright install yourself.");else{s.blank(),s.heading("Installing dependencies");let d=await Ae(o);s.detail(`npm: ${d.npm}, pip: ${d.pip}, playwright: ${d.playwright}, patchright: ${d.patchright}`),d.npm==="failed"&&T.push("npm"),d.pip==="failed"&&T.push("pip"),d.playwright==="failed"&&T.push("playwright"),d.patchright==="failed"&&T.push("patchright"),S=d.hints??{}}let E=r.outreachEnabled&&r.outreachPriority?.includes("whatsapp")&&(r.whatsappAccounts?.length??0)>0,v=!e.skipInstall&&!T.includes("npm");if(E&&v){s.blank(),s.heading("Linking WhatsApp accounts"),console.log(u.dim(`You'll be prompted to scan one QR per linked number. Open WhatsApp on the
60
+ Press Enter on any field to keep its current value.`}),await M(s,r),!r.telegramBotToken||!r.telegramChatId)){o.success("Skipped Telegram. Setup will continue."),m=!0;break}}}o.blank();let h=k.spinner();h.start("Downloading Klaudius template");let C;try{C=(await he({licenseKey:a,machineId:ae(),hostname:process.platform==="win32"?process.env.COMPUTERNAME:void 0,os:`${process.platform}-${process.arch}`,agent:r.aiAgent,destDir:s})).filesExtracted,h.stop(`Downloaded ${C} files into ${u.bold(s)}`)}catch(d){h.stop(d.message,2);let m=r.aiAgent==="codex"?".codex/config.toml":".mcp.json";o.detail(`Your .env / ${m} are saved. Re-run init once the issue is resolved to retry the download.`),process.exit(1)}await Oe(q(s,"clients"),{recursive:!0});let L=await We(s);await de(s,Ye(Et,L)),o.success("Wrote .klaudius/manifest.json");let V=!1,D="";if(e.skipSchema)o.warn("--skip-schema set; not applying scripts/schema.sql to your Supabase project."),o.detail(`Apply manually later via the SQL editor: ${r.supabaseUrl.replace("https://","https://supabase.com/dashboard/project/"+r.supabaseProjectRef+"/sql/new").replace(r.supabaseProjectRef+".supabase.co","")}`);else{o.blank();let d=k.spinner();d.start("Applying schema to Supabase");let m=await rt({projectRoot:s,pat:r.supabasePat,projectRef:r.supabaseProjectRef});m.ok?d.stop("Schema applied (or already present)"):(d.stop(m.message??"Schema apply failed",2),V=!0,D=`https://supabase.com/dashboard/project/${r.supabaseProjectRef}/sql/new`)}let T=[],S={};if(e.skipInstall)o.warn("--skip-install set; you'll need to run npm install + pip install + playwright/patchright install yourself.");else{o.blank(),o.heading("Installing dependencies");let d=await Ee(s);o.detail(`npm: ${d.npm}, pip: ${d.pip}, playwright: ${d.playwright}, patchright: ${d.patchright}`),d.npm==="failed"&&T.push("npm"),d.pip==="failed"&&T.push("pip"),d.playwright==="failed"&&T.push("playwright"),d.patchright==="failed"&&T.push("patchright"),S=d.hints??{}}let E=r.outreachEnabled&&r.outreachPriority?.includes("whatsapp")&&(r.whatsappAccounts?.length??0)>0,v=!e.skipInstall&&!T.includes("npm");if(E&&v){o.blank(),o.heading("Linking WhatsApp accounts"),console.log(u.dim(`You'll be prompted to scan one QR per linked number. Open WhatsApp on the
61
61
  phone whose number you want to link, then Settings \u2192 Linked Devices \u2192
62
- Link a Device, and point it at the QR shown in this terminal.`)),s.blank();for(let d of r.whatsappAccounts){console.log(u.cyan(`Pairing WhatsApp account '${d}'...`)),console.log(u.dim(`(Ctrl-C abandons init but your .env is already saved \u2014 finish later via: npx klaudius@latest pair-whatsapp --label ${d})`));let m=Et(process.execPath,["scripts/whatsapp.mjs","pair","--account",d],{cwd:o,stdio:"inherit"});m.status===0?s.detail(`Paired '${d}'.`):(console.log(u.yellow(`'${d}' did not pair (exit ${m.status??"signalled"}). You can finish later via:`)),console.log(u.cyan(` npx klaudius@latest pair-whatsapp --label ${d}`))),s.blank()}}else if(E&&!v){s.blank(),console.log(u.yellow("Skipping WhatsApp pairing \u2014 baileys isn't installed yet (npm install failed earlier or was skipped).")),console.log(u.dim("Once `npx klaudius@latest install` completes successfully, pair via:"));for(let d of r.whatsappAccounts)console.log(u.cyan(` npx klaudius@latest pair-whatsapp --label ${d}`))}s.blank();let y=[...T,...V?["schema"]:[]];if(y.length>0){k.outro(u.yellow(u.bold(`Setup paused \u2014 ${y.join(", ")} failed.`))),console.log(u.dim("Your credentials and project files are all saved.")),s.blank();for(let[J,Ut]of Object.entries(S))console.log(u.yellow(`Likely cause of ${J} failure:`)),console.log(u.dim(` ${Ut}`)),s.blank();let d=o!==process.cwd()?` ${u.cyan(`cd ${e.target}`)}
63
- `:"",m=r.aiAgent==="codex"?"codex":"claude",p=r.aiAgent==="codex"?"Codex":"Claude Code",w=r.aiAgent==="codex"?"npm install -g @openai/codex":"npm install -g @anthropic-ai/claude-code";T.length>0&&(console.log(u.dim(`Easiest fix \u2014 let ${p} finish it for you:`)),s.blank(),d&&process.stdout.write(d),console.log(` ${u.cyan(m)} ${u.dim(`# open ${p} in this folder`)}`),console.log(u.dim(" Then paste:")),console.log(u.cyan(` "Finish my Klaudius install \u2014 ${T.join(", ")} failed during setup. Debug the install output, retry, then run npx klaudius@latest doctor."`)),s.blank(),console.log(u.dim(` (Don't have ${p} yet? Install with: \`${w}\`)`)),s.blank(),console.log(u.dim("Or do it yourself:")),s.blank(),d&&process.stdout.write(d),console.log(` ${u.cyan("npx klaudius@latest install")} ${u.dim("# retry the failing installers")}`),console.log(` ${u.cyan("npx klaudius@latest doctor")} ${u.dim("# verify everything")}`),s.blank()),V&&(console.log(u.dim("For the schema failure specifically, apply scripts/schema.sql in the Supabase SQL editor:")),console.log(` ${u.cyan(D)}`),console.log(u.dim(" Open scripts/schema.sql, copy the contents, paste into the editor, click Run.")),s.blank()),T.includes("pip")&&!S.pip&&(console.log(u.dim("If pip fails again with a build error, check `python3 --version` \u2014 Klaudius needs")),console.log(u.dim(`Python 3.10+. Install a newer one from ${Kn()}`)),console.log(u.dim("and open a fresh Terminal before retrying.")),s.blank());let z=["npm","playwright","patchright"].filter(J=>T.includes(J)&&!S[J]);if(z.length>0){let J=z.length===1?"keeps":"keep";console.log(u.dim(`If ${z.join(" / ")} ${J} failing with network errors (ECONNRESET,`)),console.log(u.dim("ETIMEDOUT, ENOTFOUND), they're transient \u2014 try a different network or your")),console.log(u.dim("phone's hotspot, then re-run `npx klaudius@latest install`.")),s.blank()}console.log(u.dim("Stuck? Email hello@klaudius.dev with the last ~20 lines of the install output.")),s.blank();return}k.outro(u.green(u.bold("Project ready."))),console.log(u.dim("Next steps:")),o!==process.cwd()&&console.log(` ${u.cyan(`cd ${e.target}`)}`);let j=process.platform==="win32"?"start":process.platform==="linux"?"xdg-open":"open",X=u.dim("# read this first \u2014 operator basics + commands");console.log(` ${u.cyan(`${j} DOCS.html`)}${" ".repeat(Math.max(1,17-j.length))}${X}`);let re=r.aiAgent==="codex"?"codex":"claude",Me=r.aiAgent==="codex"?"Codex":"Claude Code";console.log(` ${u.cyan(re)} ${u.dim(`# open ${Me} in this project`)}`),console.log(` ${u.dim(`then ask ${Me}:`)}`),console.log(` ${u.cyan(' "Run the pipeline."')}`),s.blank()}async function M(e,n){await ve(e,{recursive:!0}),await xe(q(e,".env"),ue(n),"utf-8"),n.aiAgent==="codex"?(await ve(q(e,".codex"),{recursive:!0}),await xe(q(e,".codex","config.toml"),fe(n),"utf-8")):(await xe(q(e,".mcp.json"),pe(n),"utf-8"),await Ee(e,"supabase"))}async function Ln(e){try{(await wt(e)).isDirectory()||(s.error(`Target exists but is not a directory: ${e}`),process.exit(1))}catch{return{kind:"fresh"}}let n=await vn(e),o=n.filter(c=>!c.startsWith(".DS_Store"));if(o.length===0)return{kind:"fresh"};let t=new Set([".env",".mcp.json",".claude",".codex"]),i=o.every(c=>t.has(c)),a=o.includes(".env"),l=n.includes(".klaudius");if(i&&a&&!l)return{kind:"partial",envPath:q(e,".env")};if(l&&a){let c=!0;try{c=!(await wt(q(e,"node_modules"))).isDirectory()}catch{c=!0}return{kind:"scaffolded",nodeModulesMissing:c}}return{kind:"occupied",entries:o}}async function Dn(e){s.blank(),s.warn(`Found a partial setup at ${u.bold(e)}.`),s.detail(`A previous init wrote ${u.bold(".env")} but didn't finish scaffolding.`),s.blank();let n=await k.select({message:"How would you like to proceed?",initialValue:"resume",options:[{value:"resume",label:"Resume \u2014 use my saved .env values, skip the wizard, retry validation"},{value:"redo",label:"Restart \u2014 walk through the wizard again (existing values pre-filled as defaults)"}]});return k.isCancel(n)&&(k.cancel("Setup cancelled. Existing .env left in place."),process.exit(0)),n}async function Mn(e){if(e&&e.trim().length>0)return e;k.intro("Klaudius");let n=await k.text({message:"Enter your Klaudius license key",placeholder:"KLAU-XXXX-XXXX-XXXX-XXXX",validate:o=>o.trim().length===0?"Required. Check your purchase confirmation email.":void 0});return k.isCancel(n)&&(k.cancel("Setup cancelled. No files written."),process.exit(0)),n}function Un(e){let n=$n(e);if(process.platform==="win32"){let o=n.toLowerCase();if(o.startsWith("c:\\windows\\"))return"Inside C:\\Windows (Windows system directory).";if(o.startsWith("c:\\program files\\"))return"Inside C:\\Program Files (Windows protected directory).";if(o.startsWith("c:\\program files (x86)\\"))return"Inside C:\\Program Files (x86) (Windows protected directory).";if(o.startsWith("c:\\programdata\\"))return"Inside C:\\ProgramData (Windows protected directory)."}else{let o=["/System/","/usr/","/bin/","/sbin/"];for(let t of o)if(n.startsWith(t))return`Inside ${t.slice(0,-1)} (system-managed directory).`}}function jn(){if(process.platform!=="win32")return!1;try{return Et("net",["session"],{stdio:"ignore",windowsHide:!0}).status===0}catch{return!1}}function Kn(){switch(process.platform){case"win32":return"https://www.python.org/downloads/windows/";case"darwin":return"https://www.python.org/downloads/macos/";default:return"https://www.python.org/downloads/"}}import{access as Hn,readFile as Fn}from"fs/promises";import{join as Oe,resolve as Vn}from"path";import O from"picocolors";async function Tt(e){let n=e.target?Vn(process.cwd(),e.target):process.cwd(),o=await bt(Oe(n,".env")),t=await bt(Oe(n,"package.json"));(!o||!t)&&(s.error("This doesn't look like a Klaudius project."),s.detail(`Path: ${n}`),o||s.detail("Missing: .env"),t||s.detail("Missing: package.json"),s.blank(),s.detail("Run `npx klaudius@latest init` to scaffold a new project first,"),s.detail("or cd into an existing project directory and re-run this command."),process.exit(1));let i="claude-code";try{$(await Fn(Oe(n,".env"),"utf-8")).AI_AGENT==="codex"&&(i="codex")}catch{}s.heading("Installing dependencies");let a=await Ae(n);s.blank(),s.detail(`npm: ${a.npm}, pip: ${a.pip}, playwright: ${a.playwright}, patchright: ${a.patchright}`);let l=[];if(a.npm==="failed"&&l.push("npm"),a.pip==="failed"&&l.push("pip"),a.playwright==="failed"&&l.push("playwright"),a.patchright==="failed"&&l.push("patchright"),l.length===0){s.blank(),console.log(O.green(O.bold("All dependencies installed."))),console.log(O.dim("Run `npx klaudius@latest doctor` to verify everything else (credentials, files).")),s.blank();return}s.blank(),console.log(O.yellow(O.bold(`${l.join(", ")} still failing.`))),s.blank();for(let[r,A]of Object.entries(a.hints??{}))console.log(O.yellow(`Likely cause of ${r} failure:`)),console.log(O.dim(` ${A}`)),s.blank();let c=i==="codex"?"codex":"claude",f=i==="codex"?"Codex":"Claude Code",g=i==="codex"?"npm install -g @openai/codex":"npm install -g @anthropic-ai/claude-code";console.log(O.dim("Options:")),console.log(O.dim(` \u2022 Open ${f} in this folder (\`${c}\`) and paste:`)),console.log(O.cyan(` "Finish my Klaudius install \u2014 ${l.join(", ")} failed. Debug the install output, retry, then run npx klaudius@latest doctor."`)),console.log(O.dim(` (Don't have ${f} yet? Install with: \`${g}\`)`)),console.log(O.dim(" \u2022 Or run `npx klaudius@latest doctor` for a structured diagnostic.")),console.log(O.dim(" \u2022 Or email hello@klaudius.dev with the last ~20 lines of the install output above.")),s.blank(),process.exitCode=1}async function bt(e){try{return await Hn(e),!0}catch{return!1}}import{readFile as Gn,writeFile as Ne,access as Bn}from"fs/promises";import{join as ne}from"path";import*as Pe from"@clack/prompts";import K from"picocolors";import{mkdir as Yn}from"fs/promises";async function _t(e){let n=e.projectRoot??process.cwd(),o=ne(n,".env"),t=ne(n,".mcp.json"),i=ne(n,".codex","config.toml"),a=await $e(ne(n,".klaudius","manifest.json")),l=await $e(o);!a&&!l&&(s.error("This doesn't look like a Klaudius project."),s.detail("Expected `.klaudius/manifest.json` or `.env` in this folder. Run `npx klaudius@latest init` first."),process.exit(1));let c=G();c.ok||(s.error(c.message??"Node.js version check failed."),s.blank(),s.detail("Once you've installed Node.js 22.15+, re-run `npx klaudius@latest configure` in this folder."),process.exit(1));let f={};try{let h=await Gn(o,"utf-8");f=$(h)}catch{s.warn("No .env found. Starting from an empty configuration.")}let g=Ze(f);Pe.intro("Reconfigure Klaudius"),s.detail("Press Enter on any prompt to keep its current value."),s.blank();let r=await I(g),A=g.aiAgent??"claude-code";if(r.aiAgent&&r.aiAgent!==A&&(s.error(`Switching AI coding agent (${A} \u2192 ${r.aiAgent}) isn't supported via configure.`),s.detail("configure only rewrites .env / MCP config \u2014 it doesn't restructure the scaffolded files. To switch, run:"),s.blank(),console.log(` ${K.cyan("npx klaudius@latest init <new-folder>")} ${K.dim("# pick the new agent in the wizard")}`),s.blank(),s.detail(".env is unchanged."),process.exit(1)),r.supabaseUrl!==f.SUPABASE_URL||r.supabaseServiceKey!==f.SUPABASE_SERVICE_KEY){s.heading("Re-validating Supabase credentials");let h=await ee({url:r.supabaseUrl,serviceKey:r.supabaseServiceKey});h.ok||(s.error(h.message??"Supabase check failed"),s.warn("Aborting. .env not modified."),process.exit(1)),s.success("Supabase credentials accepted")}await Ne(o,ue(r),"utf-8"),s.success("Updated .env"),r.aiAgent==="codex"?(await Yn(ne(n,".codex"),{recursive:!0}),await Ne(i,fe(r),"utf-8"),s.success("Updated .codex/config.toml")):(await Ne(t,pe(r),"utf-8"),s.success("Updated .mcp.json"),await Ee(n,"supabase")),s.blank(),Pe.outro(K.green("Configuration updated.")),await Wn(n,a)}async function Wn(e,n){let o=await $e(ne(e,"node_modules"));s.blank(),n?o||(s.detail("Your project files are in place but dependencies aren't installed yet."),s.detail("To finish setup, run:"),s.blank(),console.log(` ${K.cyan("npx klaudius@latest install")} ${K.dim("# (re-)installs npm + pip + browsers; idempotent")}`),s.blank(),s.detail("Then verify with:"),s.blank(),console.log(` ${K.cyan("npx klaudius@latest doctor")} ${K.dim("# checks Node / Python / installers / credentials")}`),s.blank()):(s.detail("Looks like a previous `klaudius init` saved your .env but didn't finish scaffolding."),s.detail("To finish setup, run:"),s.blank(),console.log(` ${K.cyan("npx klaudius@latest init")} ${K.dim("# pick Resume when prompted")}`),s.blank())}async function $e(e){try{return await Bn(e),!0}catch{return!1}}import{copyFile as Ct,mkdir as It,readdir as zn,readFile as qn,rm as ae,writeFile as St,access as Rt}from"fs/promises";import{dirname as xt,join as N,relative as Xn}from"path";import{tmpdir as Jn}from"os";import*as se from"@clack/prompts";import Le from"picocolors";var be="0.17.1";async function vt(e){let n=e.projectRoot??process.cwd(),o=await Ge(n);o||(s.error("This doesn't look like a Klaudius project."),s.detail("Expected `.klaudius/manifest.json`. Run `npx klaudius@latest init` first."),process.exit(1));for(let y of Ve)delete o.files[y];let t,i=N(n,".env"),a,l;try{a=await qn(i,"utf-8"),l=$(a)}catch{s.error("Couldn't read .env from this directory."),s.detail("Are you running `klaudius update` from inside a Klaudius project?"),process.exit(1)}t=l.KLAUDIUS_LICENSE_KEY??"",t||(s.error("Couldn't find KLAUDIUS_LICENSE_KEY in your .env file."),s.detail("This file is created by `npx klaudius@latest init`. If your project predates"),s.detail("the licence-gated template (CLI version 0.1.x), re-run `npx klaudius@latest init`"),s.detail("in a sibling directory, then copy KLAUDIUS_LICENSE_KEY from its .env."),process.exit(1));let c=Qe(a,l,Je);c!==null&&(await St(i,c,"utf-8"),s.detail("Backfilled new env keys")),await he("update",be),se.intro(`Update from ${o.templateVersion} \u2192 ${be}`);let g=l.AI_AGENT==="codex"?"codex":"claude-code",r=N(Jn(),`klaudius-update-${process.pid}-${Date.now()}`),A;try{s.heading("Downloading the latest Klaudius template");let y=await me({licenseKey:t,machineId:ie(),hostname:process.env.HOSTNAME??process.env.COMPUTERNAME,os:`${process.platform}-${process.arch}`,agent:g,destDir:r});s.success(`Fetched ${y.filesExtracted} canonical files`),A=r}catch(y){s.error(y.message),s.detail("Update aborted. Your project is unchanged."),await ae(r,{recursive:!0,force:!0}).catch(()=>{}),process.exit(1)}let h=await Qn(A,n,o),C=h.filter(y=>y.state==="new"),L=h.filter(y=>y.state==="clean-update"),V=h.filter(y=>y.state==="user-only"),D=h.filter(y=>y.state==="conflict"),T=h.filter(y=>y.state==="no-change"),S=h.filter(y=>y.state==="removed-clean"),E=h.filter(y=>y.state==="removed-modified"),v=[...D,...E];if(s.blank(),s.heading("Change summary"),s.detail(`${H(T.length,"file")} unchanged`),s.detail(`${H(C.length,"new file")}`),s.detail(`${H(L.length,"file")} updated cleanly (no local edits)`),s.detail(`${H(V.length,"file")} you've edited (no upstream change \u2014 left alone)`),s.detail(`${H(S.length,"file")} removed upstream (deleted cleanly)`),s.detail(`${H(D.length,"file")} with conflicts (you edited AND we have a new version)`),s.detail(`${H(E.length,"file")} removed upstream but edited locally (need your decision)`),C.length===0&&L.length===0&&S.length===0&&v.length===0){s.blank(),se.outro(Le.green("Already up to date.")),await ae(r,{recursive:!0,force:!0}).catch(()=>{});return}s.blank(),s.heading("Applying clean updates");for(let y of[...C,...L]){let j=N(A,y.path),X=N(n,y.path);await It(xt(X),{recursive:!0}),await Ct(j,X),o.files[y.path]=y.canonicalHash}C.length+L.length>0&&s.success(`Wrote ${H(C.length+L.length,"file")}`);for(let y of S){let j=N(n,y.path);await ae(j,{force:!0}),delete o.files[y.path]}if(S.length>0&&s.success(`Deleted ${H(S.length,"file")} removed upstream`),v.length>0){s.blank(),s.heading(`${v.length} conflict(s) need resolution`);let y=N(n,".klaudius","incoming");try{await ae(y,{recursive:!0,force:!0})}catch{}for(let j of D){let X=N(A,j.path),re=N(y,j.path);await It(xt(re),{recursive:!0}),await Ct(X,re)}await St(N(n,".klaudius","conflicts.md"),Zn(v,o.templateVersion,be),"utf-8"),D.length>0&&s.detail("Staged canonical versions to .klaudius/incoming/"),s.detail("Wrote conflict report to .klaudius/conflicts.md")}if(o.updatedAt=new Date().toISOString(),v.length===0&&(o.templateVersion=be),await ce(n,o),s.blank(),v.length===0)se.outro(Le.green("Update complete."));else{let y=g==="codex"?"Codex":"Claude Code";se.outro(Le.yellow(`${v.length} conflict(s) staged. Open ${y} in this project and ask:
64
- "Run /resolve-conflicts"`))}await ae(r,{recursive:!0,force:!0}).catch(()=>{})}async function Qn(e,n,o){let t=await Ot(e),i=new Set(t),a=[];for(let l of t){let c=await le(N(e,l)),f=o.files[l],g=N(n,l),r;try{await Rt(g),r=await le(g)}catch{a.push({path:l,state:"new",canonicalHash:c,manifestHash:f});continue}c===f?r===f?a.push({path:l,state:"no-change",canonicalHash:c,localHash:r,manifestHash:f}):a.push({path:l,state:"user-only",canonicalHash:c,localHash:r,manifestHash:f}):r===f?a.push({path:l,state:"clean-update",canonicalHash:c,localHash:r,manifestHash:f}):a.push({path:l,state:"conflict",canonicalHash:c,localHash:r,manifestHash:f})}for(let l of Object.keys(o.files)){if(i.has(l))continue;let c=o.files[l],f=N(n,l),g;try{await Rt(f),g=await le(f)}catch{delete o.files[l];continue}g===c?a.push({path:l,state:"removed-clean",localHash:g,manifestHash:c}):a.push({path:l,state:"removed-modified",localHash:g,manifestHash:c})}return a}function H(e,n){return`${e} ${n}${e===1?"":"s"}`}async function Ot(e,n=e){let o=await zn(e,{withFileTypes:!0}),t=[];for(let i of o){let a=N(e,i.name);i.isDirectory()?t.push(...await Ot(a,n)):i.isFile()&&t.push(Xn(n,a))}return t}function Zn(e,n,o){let t=e.filter(c=>c.state==="conflict").length,i=e.filter(c=>c.state==="removed-modified").length,a=[];a.push("# Update Conflicts"),a.push(""),a.push(`Generated by \`npx klaudius@latest update\` on ${new Date().toISOString()}.`),a.push(`Updating from canonical version **${n}** to **${o}**.`),a.push("");let l=[];t>0&&l.push(`${t} file${t===1?"":"s"} ha${t===1?"s":"ve"} BOTH local edits AND upstream changes`),i>0&&l.push(`${i} file${i===1?"":"s"} ${i===1?"was":"were"} removed upstream but edited locally`),a.push(l.join(", and ")+"."),a.push("Open Claude Code in this project and run `/resolve-conflicts` \u2014 that skill walks through each conflict interactively, helping you decide what to keep, take, merge, or delete."),a.push(""),a.push("---"),a.push("");for(let c of e)a.push(`## ${c.path}`),a.push(""),c.state==="removed-modified"?(a.push("**Type:** Removed upstream"),a.push(""),a.push(`- Your local copy: \`${c.path}\``),a.push("- This file no longer exists in the canonical template."),a.push("- You've modified it locally since install."),a.push(`- Hash at last install/update: \`${(c.manifestHash??"(none)").slice(0,16)}\``),a.push(`- Your local hash now: \`${(c.localHash??"(missing)").slice(0,16)}\``),a.push(""),a.push("**Resolution options for the SKILL to walk through:**"),a.push(""),a.push("1. Keep mine \u2014 leave the file in place; stop tracking it in the manifest"),a.push("2. Delete \u2014 remove the file from disk and from the manifest")):(a.push("**Type:** Edit conflict"),a.push(""),a.push(`- Your version (with your local edits): \`${c.path}\``),a.push(`- New canonical version: \`.klaudius/incoming/${c.path}\``),a.push(`- Hash at last install/update: \`${(c.manifestHash??"(none)").slice(0,16)}\``),a.push(`- Your local hash now: \`${(c.localHash??"(missing)").slice(0,16)}\``),a.push(`- New canonical hash: \`${(c.canonicalHash??"(none)").slice(0,16)}\``),a.push(""),a.push("**Resolution options for the SKILL to walk through:**"),a.push(""),a.push("1. Keep mine \u2014 discard the new canonical changes"),a.push("2. Take canonical \u2014 overwrite my edits with the new version"),a.push("3. Merge \u2014 review both side-by-side and produce a combined version")),a.push(""),a.push("---"),a.push("");return a.join(`
65
- `)}import{access as es,readFile as Nt,stat as ts}from"fs/promises";import{join as U}from"path";import R from"picocolors";import{spawn as ns}from"child_process";async function $t(e){let n=e.projectRoot??process.cwd(),o=[];console.log(R.bold(`Klaudius doctor \u2014 checking your project\u2026
66
- `)),o.push(await ss()),o.push(await os());let t=U(n,".env"),i=U(n,".klaudius","manifest.json"),a=U(n,".mcp.json"),l=U(n,".codex","config.toml"),c=await W(t),f=await W(i),g="claude-code";if(c)try{$(await Nt(t,"utf-8")).AI_AGENT==="codex"&&(g="codex")}catch{}if(g==="claude-code"){let h=await W(U(n,"AGENTS.md")),C=!await W(U(n,".claude"));h&&C&&(g="codex")}if(o.push({name:".env present",status:c?"ok":"fail",detail:c?t:"missing",nextAction:c?void 0:"Run `npx klaudius@latest init` in this folder."}),o.push({name:"Template scaffolded (.klaudius/manifest.json)",status:f?"ok":"fail",detail:f?i:"missing",nextAction:f?void 0:c?"Init didn't finish \u2014 run `npx klaudius@latest init` and pick Resume.":"Run `npx klaudius@latest init`."}),g==="codex"){let h=await W(l);o.push({name:".codex/config.toml present",status:h?"ok":"warn",detail:h?l:"missing",nextAction:h?void 0:"Run `npx klaudius@latest configure` to regenerate."})}else{let h=await W(a);o.push({name:".mcp.json present",status:h?"ok":"warn",detail:h?a:"missing",nextAction:h?void 0:"Run `npx klaudius@latest configure` to regenerate."})}if(o.push(await cs(g)),o.push(await is(n)),o.push(await as(n)),o.push(await rs()),!c)o.push({name:"Credential validations",status:"skip",detail:".env missing"});else if(e.offline)o.push({name:"Credential validations",status:"skip",detail:"--offline set"});else{let h=await Nt(t,"utf-8"),C=$(h);await ls(C,o)}console.log();for(let h of o){let C=h.status==="ok"?R.green("\u2713"):h.status==="warn"?R.yellow("\u26A0"):h.status==="skip"?R.dim("\xB7"):R.red("\u2717");console.log(` ${C} ${h.name}${h.detail?R.dim(` \u2014 ${h.detail}`):""}`),h.nextAction&&console.log(` ${R.dim("\u2192")} ${R.cyan(h.nextAction)}`)}let r=o.filter(h=>h.status==="fail").length,A=o.filter(h=>h.status==="warn").length;console.log(),r===0&&A===0?console.log(R.green(R.bold("Everything checks out. You're good to go."))):r===0?console.log(R.yellow(R.bold(`${A} warning${A===1?"":"s"} \u2014 review above.`))):(console.log(R.red(R.bold(`${r} failed check${r===1?"":"s"} \u2014 see the \u2192 next actions above.`))),process.exitCode=1),console.log()}async function W(e){try{return await es(e),!0}catch{return!1}}async function ss(){let e=await Z();return e.ok?{name:"Python \u2265 3.10",status:"ok",detail:e.version}:{name:"Python \u2265 3.10",status:"fail",detail:e.version??"not found",nextAction:"Install Python 3.10+ from https://www.python.org/downloads/"}}async function os(){let e=process.version,n=/^v(\d+)\.(\d+)\.(\d+)$/.exec(e);if(!n)return{name:"Node \u2265 22.15",status:"warn",detail:e};let o=parseInt(n[1],10),t=parseInt(n[2],10);return o<22||o===22&&t<15?{name:"Node \u2265 22.15",status:"fail",detail:e,nextAction:"Upgrade Node.js to 22.15+ from https://nodejs.org/"}:{name:"Node \u2265 22.15",status:"ok",detail:e}}async function is(e){let n=U(e,"node_modules");if(!await W(n))return{name:"node_modules installed",status:"fail",detail:"missing",nextAction:"Run `npx klaudius@latest install` in this folder."};try{if(!(await ts(n)).isDirectory())return{name:"node_modules installed",status:"warn",detail:"exists but isn't a directory"}}catch{}return{name:"node_modules installed",status:"ok"}}async function as(e){let n=process.platform==="darwin"?U(process.env.HOME??"","Library","Caches","ms-playwright"):process.platform==="win32"?U(process.env.USERPROFILE??"","AppData","Local","ms-playwright"):U(process.env.HOME??"",".cache","ms-playwright");return await W(n)?{name:"Playwright browser installed",status:"ok",detail:n}:{name:"Playwright browser installed",status:"fail",detail:"no browser cache found",nextAction:"Run `npx playwright install chromium` in this folder."}}async function rs(){let e=["supabase","dotenv","requests","httpx","PIL"],n=`import sys
62
+ Link a Device, and point it at the QR shown in this terminal.`)),o.blank();for(let d of r.whatsappAccounts){console.log(u.cyan(`Pairing WhatsApp account '${d}'...`)),console.log(u.dim(`(Ctrl-C abandons init but your .env is already saved \u2014 finish later via: npx klaudius@latest pair-whatsapp --label ${d})`));let m=Pt(process.execPath,["scripts/whatsapp.mjs","pair","--account",d],{cwd:s,stdio:"inherit"});m.status===0?o.detail(`Paired '${d}'.`):(console.log(u.yellow(`'${d}' did not pair (exit ${m.status??"signalled"}). You can finish later via:`)),console.log(u.cyan(` npx klaudius@latest pair-whatsapp --label ${d}`))),o.blank()}}else if(E&&!v){o.blank(),console.log(u.yellow("Skipping WhatsApp pairing \u2014 baileys isn't installed yet (npm install failed earlier or was skipped).")),console.log(u.dim("Once `npx klaudius@latest install` completes successfully, pair via:"));for(let d of r.whatsappAccounts)console.log(u.cyan(` npx klaudius@latest pair-whatsapp --label ${d}`))}o.blank();let y=[...T,...V?["schema"]:[]];if(y.length>0){k.outro(u.yellow(u.bold(`Setup paused \u2014 ${y.join(", ")} failed.`))),console.log(u.dim("Your credentials and project files are all saved.")),o.blank();for(let[J,Kt]of Object.entries(S))console.log(u.yellow(`Likely cause of ${J} failure:`)),console.log(u.dim(` ${Kt}`)),o.blank();let d=s!==process.cwd()?` ${u.cyan(`cd ${e.target}`)}
63
+ `:"",m=r.aiAgent==="codex"?"codex":"claude",f=r.aiAgent==="codex"?"Codex":"Claude Code",w=r.aiAgent==="codex"?"npm install -g @openai/codex":"npm install -g @anthropic-ai/claude-code";T.length>0&&(console.log(u.dim(`Easiest fix \u2014 let ${f} finish it for you:`)),o.blank(),d&&process.stdout.write(d),console.log(` ${u.cyan(m)} ${u.dim(`# open ${f} in this folder`)}`),console.log(u.dim(" Then paste:")),console.log(u.cyan(` "Finish my Klaudius install \u2014 ${T.join(", ")} failed during setup. Debug the install output, retry, then run npx klaudius@latest doctor."`)),o.blank(),console.log(u.dim(` (Don't have ${f} yet? Install with: \`${w}\`)`)),o.blank(),console.log(u.dim("Or do it yourself:")),o.blank(),d&&process.stdout.write(d),console.log(` ${u.cyan("npx klaudius@latest install")} ${u.dim("# retry the failing installers")}`),console.log(` ${u.cyan("npx klaudius@latest doctor")} ${u.dim("# verify everything")}`),o.blank()),V&&(console.log(u.dim("For the schema failure specifically, apply scripts/schema.sql in the Supabase SQL editor:")),console.log(` ${u.cyan(D)}`),console.log(u.dim(" Open scripts/schema.sql, copy the contents, paste into the editor, click Run.")),o.blank()),T.includes("pip")&&!S.pip&&(console.log(u.dim("If pip fails again with a build error, check `python3 --version` \u2014 Klaudius needs")),console.log(u.dim(`Python 3.10+. Install a newer one from ${Hn()}`)),console.log(u.dim("and open a fresh Terminal before retrying.")),o.blank());let z=["npm","playwright","patchright"].filter(J=>T.includes(J)&&!S[J]);if(z.length>0){let J=z.length===1?"keeps":"keep";console.log(u.dim(`If ${z.join(" / ")} ${J} failing with network errors (ECONNRESET,`)),console.log(u.dim("ETIMEDOUT, ENOTFOUND), they're transient \u2014 try a different network or your")),console.log(u.dim("phone's hotspot, then re-run `npx klaudius@latest install`.")),o.blank()}console.log(u.dim("Stuck? Email hello@klaudius.dev with the last ~20 lines of the install output.")),o.blank();return}k.outro(u.green(u.bold("Project ready."))),console.log(u.dim("Next steps:")),s!==process.cwd()&&console.log(` ${u.cyan(`cd ${e.target}`)}`);let j=process.platform==="win32"?"start":process.platform==="linux"?"xdg-open":"open",X=u.dim("# read this first \u2014 operator basics + commands");console.log(` ${u.cyan(`${j} DOCS.html`)}${" ".repeat(Math.max(1,17-j.length))}${X}`);let le=r.aiAgent==="codex"?"codex":"claude",Ue=r.aiAgent==="codex"?"Codex":"Claude Code";console.log(` ${u.cyan(le)} ${u.dim(`# open ${Ue} in this project`)}`),console.log(` ${u.dim(`then ask ${Ue}:`)}`),console.log(` ${u.cyan(' "Run the pipeline."')}`),o.blank()}async function M(e,n){await Oe(e,{recursive:!0}),await ve(q(e,".env"),pe(n),"utf-8"),n.aiAgent==="codex"?(await Oe(q(e,".codex"),{recursive:!0}),await ve(q(e,".codex","config.toml"),me(n),"utf-8")):(await ve(q(e,".mcp.json"),fe(n),"utf-8"),await Pe(e,"supabase"))}async function Dn(e){try{(await At(e)).isDirectory()||(o.error(`Target exists but is not a directory: ${e}`),process.exit(1))}catch{return{kind:"fresh"}}let n=await On(e),s=n.filter(c=>!c.startsWith(".DS_Store"));if(s.length===0)return{kind:"fresh"};let t=new Set([".env",".mcp.json",".claude",".codex"]),i=s.every(c=>t.has(c)),a=s.includes(".env"),l=n.includes(".klaudius");if(i&&a&&!l)return{kind:"partial",envPath:q(e,".env")};if(l&&a){let c=!0;try{c=!(await At(q(e,"node_modules"))).isDirectory()}catch{c=!0}return{kind:"scaffolded",nodeModulesMissing:c}}return{kind:"occupied",entries:s}}async function Mn(e){o.blank(),o.warn(`Found a partial setup at ${u.bold(e)}.`),o.detail(`A previous init wrote ${u.bold(".env")} but didn't finish scaffolding.`),o.blank();let n=await k.select({message:"How would you like to proceed?",initialValue:"resume",options:[{value:"resume",label:"Resume \u2014 use my saved .env values, skip the wizard, retry validation"},{value:"redo",label:"Restart \u2014 walk through the wizard again (existing values pre-filled as defaults)"}]});return k.isCancel(n)&&(k.cancel("Setup cancelled. Existing .env left in place."),process.exit(0)),n}async function Un(e){if(e&&e.trim().length>0)return e;k.intro("Klaudius");let n=await k.text({message:"Enter your Klaudius license key",placeholder:"KLAU-XXXX-XXXX-XXXX-XXXX",validate:s=>s.trim().length===0?"Required. Check your purchase confirmation email.":void 0});return k.isCancel(n)&&(k.cancel("Setup cancelled. No files written."),process.exit(0)),n}function jn(e){let n=Ln(e);if(process.platform==="win32"){let s=n.toLowerCase();if(s.startsWith("c:\\windows\\"))return"Inside C:\\Windows (Windows system directory).";if(s.startsWith("c:\\program files\\"))return"Inside C:\\Program Files (Windows protected directory).";if(s.startsWith("c:\\program files (x86)\\"))return"Inside C:\\Program Files (x86) (Windows protected directory).";if(s.startsWith("c:\\programdata\\"))return"Inside C:\\ProgramData (Windows protected directory)."}else{let s=["/System/","/usr/","/bin/","/sbin/"];for(let t of s)if(n.startsWith(t))return`Inside ${t.slice(0,-1)} (system-managed directory).`}}function Kn(){if(process.platform!=="win32")return!1;try{return Pt("net",["session"],{stdio:"ignore",windowsHide:!0}).status===0}catch{return!1}}function Hn(){switch(process.platform){case"win32":return"https://www.python.org/downloads/windows/";case"darwin":return"https://www.python.org/downloads/macos/";default:return"https://www.python.org/downloads/"}}import{access as Fn,readFile as Vn}from"fs/promises";import{join as Ne,resolve as Gn}from"path";import O from"picocolors";async function _t(e){let n=e.target?Gn(process.cwd(),e.target):process.cwd(),s=await Tt(Ne(n,".env")),t=await Tt(Ne(n,"package.json"));(!s||!t)&&(o.error("This doesn't look like a Klaudius project."),o.detail(`Path: ${n}`),s||o.detail("Missing: .env"),t||o.detail("Missing: package.json"),o.blank(),o.detail("Run `npx klaudius@latest init` to scaffold a new project first,"),o.detail("or cd into an existing project directory and re-run this command."),process.exit(1));let i="claude-code";try{$(await Vn(Ne(n,".env"),"utf-8")).AI_AGENT==="codex"&&(i="codex")}catch{}o.heading("Installing dependencies");let a=await Ee(n);o.blank(),o.detail(`npm: ${a.npm}, pip: ${a.pip}, playwright: ${a.playwright}, patchright: ${a.patchright}`);let l=[];if(a.npm==="failed"&&l.push("npm"),a.pip==="failed"&&l.push("pip"),a.playwright==="failed"&&l.push("playwright"),a.patchright==="failed"&&l.push("patchright"),l.length===0){o.blank(),console.log(O.green(O.bold("All dependencies installed."))),console.log(O.dim("Run `npx klaudius@latest doctor` to verify everything else (credentials, files).")),o.blank();return}o.blank(),console.log(O.yellow(O.bold(`${l.join(", ")} still failing.`))),o.blank();for(let[r,A]of Object.entries(a.hints??{}))console.log(O.yellow(`Likely cause of ${r} failure:`)),console.log(O.dim(` ${A}`)),o.blank();let c=i==="codex"?"codex":"claude",p=i==="codex"?"Codex":"Claude Code",g=i==="codex"?"npm install -g @openai/codex":"npm install -g @anthropic-ai/claude-code";console.log(O.dim("Options:")),console.log(O.dim(` \u2022 Open ${p} in this folder (\`${c}\`) and paste:`)),console.log(O.cyan(` "Finish my Klaudius install \u2014 ${l.join(", ")} failed. Debug the install output, retry, then run npx klaudius@latest doctor."`)),console.log(O.dim(` (Don't have ${p} yet? Install with: \`${g}\`)`)),console.log(O.dim(" \u2022 Or run `npx klaudius@latest doctor` for a structured diagnostic.")),console.log(O.dim(" \u2022 Or email hello@klaudius.dev with the last ~20 lines of the install output above.")),o.blank(),process.exitCode=1}async function Tt(e){try{return await Fn(e),!0}catch{return!1}}import{readFile as Bn,writeFile as $e,access as Yn}from"fs/promises";import{join as ne}from"path";import*as be from"@clack/prompts";import K from"picocolors";import{mkdir as Wn}from"fs/promises";async function Ct(e){let n=e.projectRoot??process.cwd(),s=ne(n,".env"),t=ne(n,".mcp.json"),i=ne(n,".codex","config.toml"),a=await Le(ne(n,".klaudius","manifest.json")),l=await Le(s);!a&&!l&&(o.error("This doesn't look like a Klaudius project."),o.detail("Expected `.klaudius/manifest.json` or `.env` in this folder. Run `npx klaudius@latest init` first."),process.exit(1));let c=G();c.ok||(o.error(c.message??"Node.js version check failed."),o.blank(),o.detail("Once you've installed Node.js 22.15+, re-run `npx klaudius@latest configure` in this folder."),process.exit(1));let p={};try{let h=await Bn(s,"utf-8");p=$(h)}catch{o.warn("No .env found. Starting from an empty configuration.")}let g=tt(p);be.intro("Reconfigure Klaudius"),o.detail("Press Enter on any prompt to keep its current value."),o.blank();let r=await I(g),A=g.aiAgent??"claude-code";if(r.aiAgent&&r.aiAgent!==A&&(o.error(`Switching AI coding agent (${A} \u2192 ${r.aiAgent}) isn't supported via configure.`),o.detail("configure only rewrites .env / MCP config \u2014 it doesn't restructure the scaffolded files. To switch, run:"),o.blank(),console.log(` ${K.cyan("npx klaudius@latest init <new-folder>")} ${K.dim("# pick the new agent in the wizard")}`),o.blank(),o.detail(".env is unchanged."),process.exit(1)),r.supabaseUrl!==p.SUPABASE_URL||r.supabaseServiceKey!==p.SUPABASE_SERVICE_KEY){o.heading("Re-validating Supabase credentials");let h=await ee({url:r.supabaseUrl,serviceKey:r.supabaseServiceKey});h.ok||(o.error(h.message??"Supabase check failed"),o.warn("Aborting. .env not modified."),process.exit(1)),o.success("Supabase credentials accepted")}await $e(s,pe(r),"utf-8"),o.success("Updated .env"),r.aiAgent==="codex"?(await Wn(ne(n,".codex"),{recursive:!0}),await $e(i,me(r),"utf-8"),o.success("Updated .codex/config.toml")):(await $e(t,fe(r),"utf-8"),o.success("Updated .mcp.json"),await Pe(n,"supabase")),o.blank(),be.outro(K.green("Configuration updated.")),await zn(n,a)}async function zn(e,n){let s=await Le(ne(e,"node_modules"));o.blank(),n?s||(o.detail("Your project files are in place but dependencies aren't installed yet."),o.detail("To finish setup, run:"),o.blank(),console.log(` ${K.cyan("npx klaudius@latest install")} ${K.dim("# (re-)installs npm + pip + browsers; idempotent")}`),o.blank(),o.detail("Then verify with:"),o.blank(),console.log(` ${K.cyan("npx klaudius@latest doctor")} ${K.dim("# checks Node / Python / installers / credentials")}`),o.blank()):(o.detail("Looks like a previous `klaudius init` saved your .env but didn't finish scaffolding."),o.detail("To finish setup, run:"),o.blank(),console.log(` ${K.cyan("npx klaudius@latest init")} ${K.dim("# pick Resume when prompted")}`),o.blank())}async function Le(e){try{return await Yn(e),!0}catch{return!1}}import{copyFile as It,mkdir as St,readdir as qn,readFile as Xn,rm as re,writeFile as Rt,access as xt}from"fs/promises";import{dirname as vt,join as N,relative as Jn}from"path";import{tmpdir as Qn}from"os";import*as se from"@clack/prompts";import De from"picocolors";var Te="0.17.3";async function Ot(e){let n=e.projectRoot??process.cwd(),s=await Be(n);s||(o.error("This doesn't look like a Klaudius project."),o.detail("Expected `.klaudius/manifest.json`. Run `npx klaudius@latest init` first."),process.exit(1));for(let y of Ge)delete s.files[y];let t,i=N(n,".env"),a,l;try{a=await Xn(i,"utf-8"),l=$(a)}catch{o.error("Couldn't read .env from this directory."),o.detail("Are you running `klaudius update` from inside a Klaudius project?"),process.exit(1)}t=l.KLAUDIUS_LICENSE_KEY??"",t||(o.error("Couldn't find KLAUDIUS_LICENSE_KEY in your .env file."),o.detail("This file is created by `npx klaudius@latest init`. If your project predates"),o.detail("the licence-gated template (CLI version 0.1.x), re-run `npx klaudius@latest init`"),o.detail("in a sibling directory, then copy KLAUDIUS_LICENSE_KEY from its .env."),process.exit(1));let c=et(a,l,Ze);c!==null&&(await Rt(i,c,"utf-8"),o.detail("Backfilled new env keys")),await ge("update",Te),se.intro(`Update from ${s.templateVersion} \u2192 ${Te}`);let g=l.AI_AGENT==="codex"?"codex":"claude-code",r=N(Qn(),`klaudius-update-${process.pid}-${Date.now()}`),A;try{o.heading("Downloading the latest Klaudius template");let y=await he({licenseKey:t,machineId:ae(),hostname:process.env.HOSTNAME??process.env.COMPUTERNAME,os:`${process.platform}-${process.arch}`,agent:g,destDir:r});o.success(`Fetched ${y.filesExtracted} canonical files`),A=r}catch(y){o.error(y.message),o.detail("Update aborted. Your project is unchanged."),await re(r,{recursive:!0,force:!0}).catch(()=>{}),process.exit(1)}let h=await Zn(A,n,s),C=h.filter(y=>y.state==="new"),L=h.filter(y=>y.state==="clean-update"),V=h.filter(y=>y.state==="user-only"),D=h.filter(y=>y.state==="conflict"),T=h.filter(y=>y.state==="no-change"),S=h.filter(y=>y.state==="removed-clean"),E=h.filter(y=>y.state==="removed-modified"),v=[...D,...E];if(o.blank(),o.heading("Change summary"),o.detail(`${H(T.length,"file")} unchanged`),o.detail(`${H(C.length,"new file")}`),o.detail(`${H(L.length,"file")} updated cleanly (no local edits)`),o.detail(`${H(V.length,"file")} you've edited (no upstream change \u2014 left alone)`),o.detail(`${H(S.length,"file")} removed upstream (deleted cleanly)`),o.detail(`${H(D.length,"file")} with conflicts (you edited AND we have a new version)`),o.detail(`${H(E.length,"file")} removed upstream but edited locally (need your decision)`),C.length===0&&L.length===0&&S.length===0&&v.length===0){o.blank(),se.outro(De.green("Already up to date.")),await re(r,{recursive:!0,force:!0}).catch(()=>{});return}o.blank(),o.heading("Applying clean updates");for(let y of[...C,...L]){let j=N(A,y.path),X=N(n,y.path);await St(vt(X),{recursive:!0}),await It(j,X),s.files[y.path]=y.canonicalHash}C.length+L.length>0&&o.success(`Wrote ${H(C.length+L.length,"file")}`);for(let y of S){let j=N(n,y.path);await re(j,{force:!0}),delete s.files[y.path]}if(S.length>0&&o.success(`Deleted ${H(S.length,"file")} removed upstream`),v.length>0){o.blank(),o.heading(`${v.length} conflict(s) need resolution`);let y=N(n,".klaudius","incoming");try{await re(y,{recursive:!0,force:!0})}catch{}for(let j of D){let X=N(A,j.path),le=N(y,j.path);await St(vt(le),{recursive:!0}),await It(X,le)}await Rt(N(n,".klaudius","conflicts.md"),es(v,s.templateVersion,Te),"utf-8"),D.length>0&&o.detail("Staged canonical versions to .klaudius/incoming/"),o.detail("Wrote conflict report to .klaudius/conflicts.md")}if(s.updatedAt=new Date().toISOString(),v.length===0&&(s.templateVersion=Te),await de(n,s),o.blank(),v.length===0)se.outro(De.green("Update complete."));else{let y=g==="codex"?"Codex":"Claude Code";se.outro(De.yellow(`${v.length} conflict(s) staged. Open ${y} in this project and ask:
64
+ "Run /resolve-conflicts"`))}await re(r,{recursive:!0,force:!0}).catch(()=>{})}async function Zn(e,n,s){let t=await Nt(e),i=new Set(t),a=[];for(let l of t){let c=await ce(N(e,l)),p=s.files[l],g=N(n,l),r;try{await xt(g),r=await ce(g)}catch{a.push({path:l,state:"new",canonicalHash:c,manifestHash:p});continue}c===p?r===p?a.push({path:l,state:"no-change",canonicalHash:c,localHash:r,manifestHash:p}):a.push({path:l,state:"user-only",canonicalHash:c,localHash:r,manifestHash:p}):r===p?a.push({path:l,state:"clean-update",canonicalHash:c,localHash:r,manifestHash:p}):a.push({path:l,state:"conflict",canonicalHash:c,localHash:r,manifestHash:p})}for(let l of Object.keys(s.files)){if(i.has(l))continue;let c=s.files[l],p=N(n,l),g;try{await xt(p),g=await ce(p)}catch{delete s.files[l];continue}g===c?a.push({path:l,state:"removed-clean",localHash:g,manifestHash:c}):a.push({path:l,state:"removed-modified",localHash:g,manifestHash:c})}return a}function H(e,n){return`${e} ${n}${e===1?"":"s"}`}async function Nt(e,n=e){let s=await qn(e,{withFileTypes:!0}),t=[];for(let i of s){let a=N(e,i.name);i.isDirectory()?t.push(...await Nt(a,n)):i.isFile()&&t.push(Jn(n,a))}return t}function es(e,n,s){let t=e.filter(c=>c.state==="conflict").length,i=e.filter(c=>c.state==="removed-modified").length,a=[];a.push("# Update Conflicts"),a.push(""),a.push(`Generated by \`npx klaudius@latest update\` on ${new Date().toISOString()}.`),a.push(`Updating from canonical version **${n}** to **${s}**.`),a.push("");let l=[];t>0&&l.push(`${t} file${t===1?"":"s"} ha${t===1?"s":"ve"} BOTH local edits AND upstream changes`),i>0&&l.push(`${i} file${i===1?"":"s"} ${i===1?"was":"were"} removed upstream but edited locally`),a.push(l.join(", and ")+"."),a.push("Open Claude Code in this project and run `/resolve-conflicts` \u2014 that skill walks through each conflict interactively, helping you decide what to keep, take, merge, or delete."),a.push(""),a.push("---"),a.push("");for(let c of e)a.push(`## ${c.path}`),a.push(""),c.state==="removed-modified"?(a.push("**Type:** Removed upstream"),a.push(""),a.push(`- Your local copy: \`${c.path}\``),a.push("- This file no longer exists in the canonical template."),a.push("- You've modified it locally since install."),a.push(`- Hash at last install/update: \`${(c.manifestHash??"(none)").slice(0,16)}\``),a.push(`- Your local hash now: \`${(c.localHash??"(missing)").slice(0,16)}\``),a.push(""),a.push("**Resolution options for the SKILL to walk through:**"),a.push(""),a.push("1. Keep mine \u2014 leave the file in place; stop tracking it in the manifest"),a.push("2. Delete \u2014 remove the file from disk and from the manifest")):(a.push("**Type:** Edit conflict"),a.push(""),a.push(`- Your version (with your local edits): \`${c.path}\``),a.push(`- New canonical version: \`.klaudius/incoming/${c.path}\``),a.push(`- Hash at last install/update: \`${(c.manifestHash??"(none)").slice(0,16)}\``),a.push(`- Your local hash now: \`${(c.localHash??"(missing)").slice(0,16)}\``),a.push(`- New canonical hash: \`${(c.canonicalHash??"(none)").slice(0,16)}\``),a.push(""),a.push("**Resolution options for the SKILL to walk through:**"),a.push(""),a.push("1. Keep mine \u2014 discard the new canonical changes"),a.push("2. Take canonical \u2014 overwrite my edits with the new version"),a.push("3. Merge \u2014 review both side-by-side and produce a combined version")),a.push(""),a.push("---"),a.push("");return a.join(`
65
+ `)}import{access as ts,readFile as $t,stat as ns}from"fs/promises";import{join as U}from"path";import R from"picocolors";import{spawn as Lt}from"child_process";async function Dt(e){let n=e.projectRoot??process.cwd(),s=[];console.log(R.bold(`Klaudius doctor \u2014 checking your project\u2026
66
+ `)),s.push(await ss()),s.push(await os());let t=U(n,".env"),i=U(n,".klaudius","manifest.json"),a=U(n,".mcp.json"),l=U(n,".codex","config.toml"),c=await W(t),p=await W(i),g="claude-code";if(c)try{$(await $t(t,"utf-8")).AI_AGENT==="codex"&&(g="codex")}catch{}if(g==="claude-code"){let h=await W(U(n,"AGENTS.md")),C=!await W(U(n,".claude"));h&&C&&(g="codex")}if(s.push({name:".env present",status:c?"ok":"fail",detail:c?t:"missing",nextAction:c?void 0:"Run `npx klaudius@latest init` in this folder."}),s.push({name:"Template scaffolded (.klaudius/manifest.json)",status:p?"ok":"fail",detail:p?i:"missing",nextAction:p?void 0:c?"Init didn't finish \u2014 run `npx klaudius@latest init` and pick Resume.":"Run `npx klaudius@latest init`."}),g==="codex"){let h=await W(l);s.push({name:".codex/config.toml present",status:h?"ok":"warn",detail:h?l:"missing",nextAction:h?void 0:"Run `npx klaudius@latest configure` to regenerate."})}else{let h=await W(a);s.push({name:".mcp.json present",status:h?"ok":"warn",detail:h?a:"missing",nextAction:h?void 0:"Run `npx klaudius@latest configure` to regenerate."})}if(s.push(await cs(g)),s.push(await is(n)),s.push(await as(n)),s.push(await rs()),!c)s.push({name:"Credential validations",status:"skip",detail:".env missing"});else if(e.offline)s.push({name:"Credential validations",status:"skip",detail:"--offline set"});else{let h=await $t(t,"utf-8"),C=$(h);await ls(C,s)}console.log();for(let h of s){let C=h.status==="ok"?R.green("\u2713"):h.status==="warn"?R.yellow("\u26A0"):h.status==="skip"?R.dim("\xB7"):R.red("\u2717");console.log(` ${C} ${h.name}${h.detail?R.dim(` \u2014 ${h.detail}`):""}`),h.nextAction&&console.log(` ${R.dim("\u2192")} ${R.cyan(h.nextAction)}`)}let r=s.filter(h=>h.status==="fail").length,A=s.filter(h=>h.status==="warn").length;console.log(),r===0&&A===0?console.log(R.green(R.bold("Everything checks out. You're good to go."))):r===0?console.log(R.yellow(R.bold(`${A} warning${A===1?"":"s"} \u2014 review above.`))):(console.log(R.red(R.bold(`${r} failed check${r===1?"":"s"} \u2014 see the \u2192 next actions above.`))),process.exitCode=1),console.log()}async function W(e){try{return await ts(e),!0}catch{return!1}}async function ss(){let e=await Z();return e.ok?{name:"Python \u2265 3.10",status:"ok",detail:e.version}:{name:"Python \u2265 3.10",status:"fail",detail:e.version??"not found",nextAction:"Install Python 3.10+ from https://www.python.org/downloads/"}}async function os(){let e=process.version,n=/^v(\d+)\.(\d+)\.(\d+)$/.exec(e);if(!n)return{name:"Node \u2265 22.15",status:"warn",detail:e};let s=parseInt(n[1],10),t=parseInt(n[2],10);return s<22||s===22&&t<15?{name:"Node \u2265 22.15",status:"fail",detail:e,nextAction:"Upgrade Node.js to 22.15+ from https://nodejs.org/"}:{name:"Node \u2265 22.15",status:"ok",detail:e}}async function is(e){let n=U(e,"node_modules");if(!await W(n))return{name:"node_modules installed",status:"fail",detail:"missing",nextAction:"Run `npx klaudius@latest install` in this folder."};try{if(!(await ns(n)).isDirectory())return{name:"node_modules installed",status:"warn",detail:"exists but isn't a directory"}}catch{}return{name:"node_modules installed",status:"ok"}}async function as(e){let n=process.platform==="darwin"?U(process.env.HOME??"","Library","Caches","ms-playwright"):process.platform==="win32"?U(process.env.USERPROFILE??"","AppData","Local","ms-playwright"):U(process.env.HOME??"",".cache","ms-playwright");return await W(n)?{name:"Playwright browser installed",status:"ok",detail:n}:{name:"Playwright browser installed",status:"fail",detail:"no browser cache found",nextAction:"Run `npx playwright install chromium` in this folder."}}async function rs(){let e=["supabase","dotenv","requests","httpx","PIL"],n=`import sys
67
67
  try:
68
- ${e.map(t=>` import ${t}`).join(`
68
+ ${e.map(a=>` import ${a}`).join(`
69
69
  `)}
70
70
  except Exception as e:
71
71
  print(str(e))
72
72
  sys.exit(1)
73
- `,o=await Lt("python3",["-c",n]);return o.code===0?{name:"Python packages installed",status:"ok",detail:e.join(", ")}:{name:"Python packages installed",status:"fail",detail:(o.stdout||o.stderr).trim().split(`
74
- `).pop()??"import failed",nextAction:"Run `npx klaudius@latest install` in this folder."}}async function ls(e,n){if(e.SUPABASE_URL&&e.SUPABASE_SERVICE_KEY){let t=await ee({url:e.SUPABASE_URL,serviceKey:e.SUPABASE_SERVICE_KEY});n.push({name:"Supabase credentials",status:t.ok?"ok":"fail",detail:t.ok?"connected":t.message,nextAction:t.ok?void 0:"Run `npx klaudius@latest configure` to fix the URL or key."})}else n.push({name:"Supabase credentials",status:"fail",detail:"missing in .env"});let o=e.DEPLOY_PROVIDER==="cloudflare"?"cloudflare":e.DEPLOY_PROVIDER==="netlify"?"netlify":"vercel";if(o==="cloudflare")if(e.CLOUDFLARE_API_TOKEN&&e.CLOUDFLARE_ACCOUNT_ID){let t=await ye({token:e.CLOUDFLARE_API_TOKEN,accountId:e.CLOUDFLARE_ACCOUNT_ID});n.push({name:"Cloudflare token + account",status:t.ok?"ok":"fail",detail:t.ok?`valid (${t.projectCount??0} Pages project${t.projectCount===1?"":"s"})`:t.message,nextAction:t.ok?void 0:"Fix the token/account at https://dash.cloudflare.com/profile/api-tokens, then `npx klaudius@latest configure`."})}else n.push({name:"Cloudflare token + account",status:"fail",detail:"CLOUDFLARE_API_TOKEN and/or CLOUDFLARE_ACCOUNT_ID missing in .env",nextAction:"Run `npx klaudius@latest configure` and pick Cloudflare."});else if(o==="netlify")if(e.NETLIFY_AUTH_TOKEN){let t=await ke({token:e.NETLIFY_AUTH_TOKEN});n.push({name:"Netlify token",status:t.ok?"ok":"fail",detail:t.ok?t.accountSlug?`valid (team: ${t.accountSlug})`:"valid":t.message,nextAction:t.ok?void 0:"Fix the token at https://app.netlify.com/user/applications#personal-access-tokens, then `npx klaudius@latest configure`."})}else n.push({name:"Netlify token",status:"fail",detail:"NETLIFY_AUTH_TOKEN missing in .env",nextAction:"Run `npx klaudius@latest configure` and pick Netlify."});else if(e.VERCEL_TOKEN){let t=await ge(e.VERCEL_TOKEN);n.push({name:"Vercel token",status:t.ok?"ok":"fail",detail:t.ok?t.username??"valid":t.message,nextAction:t.ok?void 0:"Generate a new token at https://vercel.com/account/tokens, then `npx klaudius@latest configure`."})}else n.push({name:"Vercel token",status:"fail",detail:"missing in .env"});if(e.GOOGLE_PLACES_API_KEY){let t=await we(e.GOOGLE_PLACES_API_KEY);n.push({name:"Google Places API key",status:t.ok?"ok":"fail",detail:t.ok?"accepted":t.message,nextAction:t.ok?void 0:"Fix the key in https://console.cloud.google.com and `npx klaudius@latest configure`."})}else n.push({name:"Google Places API key",status:"warn",detail:"not set (find skill will fail until you add one)"});if(e.TELEGRAM_BOT_TOKEN&&e.TELEGRAM_CHAT_ID){let t=await He({botToken:e.TELEGRAM_BOT_TOKEN});n.push({name:"Telegram bot token",status:t.ok?"ok":"fail",detail:t.ok?`bot ${t.botHandle??"ok"} (chat_id not tested)`:t.message,nextAction:t.ok?void 0:"Fix TELEGRAM_BOT_TOKEN in .env (or blank both Telegram lines to disable)."})}else e.TELEGRAM_BOT_TOKEN||e.TELEGRAM_CHAT_ID?n.push({name:"Telegram credentials",status:"warn",detail:"partial config (one of bot token / chat ID set, other missing)",nextAction:"Either set both, or blank both to disable Telegram notifications."}):n.push({name:"Telegram credentials",status:"skip",detail:"not configured (optional)"})}async function cs(e){let n=e==="codex"?"codex":"claude",o=e==="codex"?"Codex CLI on PATH":"Claude Code CLI on PATH",t=e==="codex"?"Install Codex with `npm install -g @openai/codex` (or your preferred installer).":"Install Claude Code with `npm install -g @anthropic-ai/claude-code`.",i=await Lt(n,["--version"]);return i.code===0?{name:o,status:"ok",detail:(i.stdout||i.stderr).trim().split(`
75
- `)[0]}:{name:o,status:"warn",detail:"not found",nextAction:t}}function Lt(e,n){return new Promise(o=>{let t=ns(e,n,{stdio:["ignore","pipe","pipe"],shell:!1}),i="",a="";t.stdout?.on("data",l=>{i+=l.toString()}),t.stderr?.on("data",l=>{a+=l.toString()}),t.on("close",l=>o({code:l??1,stdout:i,stderr:a})),t.on("error",()=>o({code:1,stdout:i,stderr:a}))})}import{existsSync as ds}from"fs";import{spawnSync as us}from"child_process";import{join as ps,resolve as fs}from"path";import x from"picocolors";async function Dt(e){let n=fs(e.projectRoot??process.cwd()),o=ps(n,"scripts","whatsapp.mjs");ds(o)||(console.error(x.red("Couldn't find scripts/whatsapp.mjs in this directory.")),console.error(x.dim("Run this command from the root of a Klaudius project (the directory created by `npx klaudius@latest init`).")),console.error(x.dim(`Looked for: ${o}`)),process.exit(1));let t=(e.label??"primary").trim(),i=t.replace(/[^A-Za-z0-9_-]/g,"");i||(console.error(x.red(`Invalid label '${t}'. Use letters, digits, underscore, or hyphen only.`)),process.exit(1)),i!==t&&console.error(x.yellow(`Note: cleaned label '${t}' \u2192 '${i}' (filename-safe characters only).`)),console.log(x.cyan(`Pairing WhatsApp account '${i}'...`)),console.log(x.dim(`If a daemon is already running for this account, it will be stopped automatically before the QR prompt. After the pair completes, the next /outreach send for this account will respawn the daemon with the new auth.
76
- `));let a=us(process.execPath,[o,"pair","--account",i],{cwd:n,stdio:"inherit"});if(a.status===0){console.log(x.green(`Paired '${i}'.`)),console.log(x.dim(`
73
+ `,s=await ie();if(!s)return{name:"Python packages installed",status:"fail",detail:"no Python interpreter found (tried python3, python, py -3)",nextAction:"Fix the Python check above first \u2014 the packages live inside that interpreter."};let t=s.command,i=await Mt(t[0],[...t.slice(1),"-c",n]);return i.code===0?{name:"Python packages installed",status:"ok",detail:e.join(", ")}:{name:"Python packages installed",status:"fail",detail:(i.stdout||i.stderr).trim().split(`
74
+ `).pop()??"import failed",nextAction:"Run `npx klaudius@latest install` in this folder."}}async function ls(e,n){if(e.SUPABASE_URL&&e.SUPABASE_SERVICE_KEY){let t=await ee({url:e.SUPABASE_URL,serviceKey:e.SUPABASE_SERVICE_KEY});n.push({name:"Supabase credentials",status:t.ok?"ok":"fail",detail:t.ok?"connected":t.message,nextAction:t.ok?void 0:"Run `npx klaudius@latest configure` to fix the URL or key."})}else n.push({name:"Supabase credentials",status:"fail",detail:"missing in .env"});let s=e.DEPLOY_PROVIDER==="cloudflare"?"cloudflare":e.DEPLOY_PROVIDER==="netlify"?"netlify":"vercel";if(s==="cloudflare")if(e.CLOUDFLARE_API_TOKEN&&e.CLOUDFLARE_ACCOUNT_ID){let t=await ke({token:e.CLOUDFLARE_API_TOKEN,accountId:e.CLOUDFLARE_ACCOUNT_ID});n.push({name:"Cloudflare token + account",status:t.ok?"ok":"fail",detail:t.ok?`valid (${t.projectCount??0} Pages project${t.projectCount===1?"":"s"})`:t.message,nextAction:t.ok?void 0:"Fix the token/account at https://dash.cloudflare.com/profile/api-tokens, then `npx klaudius@latest configure`."})}else n.push({name:"Cloudflare token + account",status:"fail",detail:"CLOUDFLARE_API_TOKEN and/or CLOUDFLARE_ACCOUNT_ID missing in .env",nextAction:"Run `npx klaudius@latest configure` and pick Cloudflare."});else if(s==="netlify")if(e.NETLIFY_AUTH_TOKEN){let t=await we({token:e.NETLIFY_AUTH_TOKEN});n.push({name:"Netlify token",status:t.ok?"ok":"fail",detail:t.ok?t.accountSlug?`valid (team: ${t.accountSlug})`:"valid":t.message,nextAction:t.ok?void 0:"Fix the token at https://app.netlify.com/user/applications#personal-access-tokens, then `npx klaudius@latest configure`."})}else n.push({name:"Netlify token",status:"fail",detail:"NETLIFY_AUTH_TOKEN missing in .env",nextAction:"Run `npx klaudius@latest configure` and pick Netlify."});else if(e.VERCEL_TOKEN){let t=await ye(e.VERCEL_TOKEN);n.push({name:"Vercel token",status:t.ok?"ok":"fail",detail:t.ok?t.username??"valid":t.message,nextAction:t.ok?void 0:"Generate a new token at https://vercel.com/account/tokens, then `npx klaudius@latest configure`."})}else n.push({name:"Vercel token",status:"fail",detail:"missing in .env"});if(e.GOOGLE_PLACES_API_KEY){let t=await Ae(e.GOOGLE_PLACES_API_KEY);n.push({name:"Google Places API key",status:t.ok?"ok":"fail",detail:t.ok?"accepted":t.message,nextAction:t.ok?void 0:"Fix the key in https://console.cloud.google.com and `npx klaudius@latest configure`."})}else n.push({name:"Google Places API key",status:"warn",detail:"not set (find skill will fail until you add one)"});if(e.TELEGRAM_BOT_TOKEN&&e.TELEGRAM_CHAT_ID){let t=await Fe({botToken:e.TELEGRAM_BOT_TOKEN});n.push({name:"Telegram bot token",status:t.ok?"ok":"fail",detail:t.ok?`bot ${t.botHandle??"ok"} (chat_id not tested)`:t.message,nextAction:t.ok?void 0:"Fix TELEGRAM_BOT_TOKEN in .env (or blank both Telegram lines to disable)."})}else e.TELEGRAM_BOT_TOKEN||e.TELEGRAM_CHAT_ID?n.push({name:"Telegram credentials",status:"warn",detail:"partial config (one of bot token / chat ID set, other missing)",nextAction:"Either set both, or blank both to disable Telegram notifications."}):n.push({name:"Telegram credentials",status:"skip",detail:"not configured (optional)"})}async function cs(e){let n=e==="codex"?"codex":"claude",s=e==="codex"?"Codex CLI on PATH":"Claude Code CLI on PATH",t=e==="codex"?"Install Codex with `npm install -g @openai/codex` (or your preferred installer).":"Install Claude Code with `npm install -g @anthropic-ai/claude-code`.",i=await Mt(n,["--version"],process.platform==="win32");return i.code===0?{name:s,status:"ok",detail:(i.stdout||i.stderr).trim().split(`
75
+ `)[0]}:{name:s,status:"warn",detail:"not found",nextAction:t}}function Mt(e,n,s=!1){return new Promise(t=>{let i=s?Lt([e,...n].join(" "),{stdio:["ignore","pipe","pipe"],shell:!0}):Lt(e,n,{stdio:["ignore","pipe","pipe"],shell:!1}),a="",l="";i.stdout?.on("data",c=>{a+=c.toString()}),i.stderr?.on("data",c=>{l+=c.toString()}),i.on("close",c=>t({code:c??1,stdout:a,stderr:l})),i.on("error",()=>t({code:1,stdout:a,stderr:l}))})}import{existsSync as ds}from"fs";import{spawnSync as us}from"child_process";import{join as ps,resolve as fs}from"path";import x from"picocolors";async function Ut(e){let n=fs(e.projectRoot??process.cwd()),s=ps(n,"scripts","whatsapp.mjs");ds(s)||(console.error(x.red("Couldn't find scripts/whatsapp.mjs in this directory.")),console.error(x.dim("Run this command from the root of a Klaudius project (the directory created by `npx klaudius@latest init`).")),console.error(x.dim(`Looked for: ${s}`)),process.exit(1));let t=(e.label??"primary").trim(),i=t.replace(/[^A-Za-z0-9_-]/g,"");i||(console.error(x.red(`Invalid label '${t}'. Use letters, digits, underscore, or hyphen only.`)),process.exit(1)),i!==t&&console.error(x.yellow(`Note: cleaned label '${t}' \u2192 '${i}' (filename-safe characters only).`)),console.log(x.cyan(`Pairing WhatsApp account '${i}'...`)),console.log(x.dim(`If a daemon is already running for this account, it will be stopped automatically before the QR prompt. After the pair completes, the next /outreach send for this account will respawn the daemon with the new auth.
76
+ `));let a=us(process.execPath,[s,"pair","--account",i],{cwd:n,stdio:"inherit"});if(a.status===0){console.log(x.green(`Paired '${i}'.`)),console.log(x.dim(`
77
77
  If you haven't already, add '${i}' to WHATSAPP_ACCOUNTS in .env so /outreach round-robins to it. Example:
78
78
  WHATSAPP_ACCOUNTS=primary,${i}
79
- (Skip this if '${i}' is already there or you set it via the init wizard.)`));return}a.error?console.error(x.red(`Pair failed: ${a.error.message}`)):(console.error(x.red(`Pair did not complete (exit ${a.status??"signalled"}). Common causes:`)),console.error(x.dim(" - QR scan window timed out: re-run and scan promptly.")),console.error(x.dim(" - WhatsApp's 4-linked-device limit: open WhatsApp \u2192 Settings \u2192 Linked Devices, unlink an unused entry, then re-run.")),console.error(x.dim(` - Existing daemon couldn't be stopped: check the log at ~/.klaudius/whatsapp/${i}/daemon.log`))),process.exit(a.status??1)}import{spawnSync as ms}from"child_process";var De="--use-system-ca";function Mt(){let e=process.env.NODE_OPTIONS??"";if(e.includes(De)||!G().ok)return;let o=e?`${e} ${De}`:De,t=ms(process.execPath,[...process.execArgv,...process.argv.slice(1)],{env:{...process.env,NODE_OPTIONS:o},stdio:"inherit"});t.signal&&(process.kill(process.pid,t.signal),process.exit(1)),process.exit(t.status??1)}Mt();var gs="0.17.1",F=new hs;F.name("klaudius").description("Scaffold and maintain a Klaudius pipeline project").version(gs);F.command("preflight").description("Check this machine can run Klaudius (Node, Python, pip, npm, network) \u2014 no project or license needed. Safe for an AI assistant to run, fix, and re-run before init.").action(async()=>{try{await ze({})}catch(e){console.error("preflight failed:",e.message),process.exit(1)}});F.command("init").description("Scaffold a new Klaudius project").argument("[target]","Directory to create (defaults to current directory)",".").option("--license <key>","License key (received in your purchase confirmation email)").option("--skip-install","Skip npm/pip/playwright installation").option("--skip-schema","Skip applying schema.sql to your Supabase project").action(async(e,n)=>{try{await Pt({target:e,license:n.license,skipInstall:!!n.skipInstall,skipSchema:!!n.skipSchema})}catch(o){console.error("init failed:",o.message),process.exit(1)}});F.command("install").description("Re-run dependency installers against an already-scaffolded project (npm, pip, playwright, patchright)").argument("[target]","Project directory (defaults to current directory)").action(async e=>{try{await Tt({target:e})}catch(n){console.error("install failed:",n.message),process.exit(1)}});F.command("configure").description("Re-run the setup wizard with current values pre-filled").action(async()=>{try{await _t({})}catch(e){console.error("configure failed:",e.message),process.exit(1)}});F.command("update").description("Pull latest template; produce a conflicts report for any files you've modified").action(async()=>{try{await vt({})}catch(e){console.error("update failed:",e.message),process.exit(1)}});F.command("doctor").description("Diagnose a broken install \u2014 env versions, files, installed deps, credentials").option("--offline","Skip credential validations that require network calls").action(async e=>{try{await $t({offline:!!e.offline})}catch(n){console.error("doctor failed:",n.message),process.exit(1)}});F.command("pair-whatsapp").description("Link a WhatsApp account to this project (or re-pair if it logged out)").option("--label <name>","Account label (default: primary). Should match a value in WHATSAPP_ACCOUNTS.","primary").action(async e=>{try{await Dt({label:e.label})}catch(n){console.error("pair-whatsapp failed:",n.message),process.exit(1)}});F.parse(process.argv);
79
+ (Skip this if '${i}' is already there or you set it via the init wizard.)`));return}a.error?console.error(x.red(`Pair failed: ${a.error.message}`)):(console.error(x.red(`Pair did not complete (exit ${a.status??"signalled"}). Common causes:`)),console.error(x.dim(" - QR scan window timed out: re-run and scan promptly.")),console.error(x.dim(" - WhatsApp's 4-linked-device limit: open WhatsApp \u2192 Settings \u2192 Linked Devices, unlink an unused entry, then re-run.")),console.error(x.dim(` - Existing daemon couldn't be stopped: check the log at ~/.klaudius/whatsapp/${i}/daemon.log`))),process.exit(a.status??1)}import{spawnSync as ms}from"child_process";var Me="--use-system-ca";function jt(){let e=process.env.NODE_OPTIONS??"";if(e.includes(Me)||!G().ok)return;let s=e?`${e} ${Me}`:Me,t=ms(process.execPath,[...process.execArgv,...process.argv.slice(1)],{env:{...process.env,NODE_OPTIONS:s},stdio:"inherit"});t.signal&&(process.kill(process.pid,t.signal),process.exit(1)),process.exit(t.status??1)}jt();var gs="0.17.3",F=new hs;F.name("klaudius").description("Scaffold and maintain a Klaudius pipeline project").version(gs);F.command("preflight").description("Check this machine can run Klaudius (Node, Python, pip, npm, network) \u2014 no project or license needed. Safe for an AI assistant to run, fix, and re-run before init.").action(async()=>{try{await Xe({})}catch(e){console.error("preflight failed:",e.message),process.exit(1)}});F.command("init").description("Scaffold a new Klaudius project").argument("[target]","Directory to create (defaults to current directory)",".").option("--license <key>","License key (received in your purchase confirmation email)").option("--skip-install","Skip npm/pip/playwright installation").option("--skip-schema","Skip applying schema.sql to your Supabase project").action(async(e,n)=>{try{await bt({target:e,license:n.license,skipInstall:!!n.skipInstall,skipSchema:!!n.skipSchema})}catch(s){console.error("init failed:",s.message),process.exit(1)}});F.command("install").description("Re-run dependency installers against an already-scaffolded project (npm, pip, playwright, patchright)").argument("[target]","Project directory (defaults to current directory)").action(async e=>{try{await _t({target:e})}catch(n){console.error("install failed:",n.message),process.exit(1)}});F.command("configure").description("Re-run the setup wizard with current values pre-filled").action(async()=>{try{await Ct({})}catch(e){console.error("configure failed:",e.message),process.exit(1)}});F.command("update").description("Pull latest template; produce a conflicts report for any files you've modified").action(async()=>{try{await Ot({})}catch(e){console.error("update failed:",e.message),process.exit(1)}});F.command("doctor").description("Diagnose a broken install \u2014 env versions, files, installed deps, credentials").option("--offline","Skip credential validations that require network calls").action(async e=>{try{await Dt({offline:!!e.offline})}catch(n){console.error("doctor failed:",n.message),process.exit(1)}});F.command("pair-whatsapp").description("Link a WhatsApp account to this project (or re-pair if it logged out)").option("--label <name>","Account label (default: primary). Should match a value in WHATSAPP_ACCOUNTS.","primary").action(async e=>{try{await Ut({label:e.label})}catch(n){console.error("pair-whatsapp failed:",n.message),process.exit(1)}});F.parse(process.argv);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "klaudius",
3
- "version": "0.17.1",
3
+ "version": "0.17.3",
4
4
  "description": "Scaffold and maintain a Klaudius project — an autonomous web agency pipeline that runs on Claude Code (find, build, deploy, outreach end-to-end).",
5
5
  "homepage": "https://klaudius.dev",
6
6
  "bugs": {