claude-down 0.3.0 → 0.4.1
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.
- package/README.md +10 -4
- package/dist/anthropic.d.mts +1 -1
- package/dist/bin/cli.mjs +5 -4
- package/dist/cdp.d.mts +12 -0
- package/dist/chrome.d.mts +20 -0
- package/dist/downdetector.d.mts +1 -9
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -1
- package/dist/snapshot.d.mts +11 -0
- package/dist/{types-phXTAZxX.d.mts → types-4oEMjqAH.d.mts} +2 -1
- package/dist/types.d.mts +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -73,11 +73,17 @@ claude-down status -s downdetector
|
|
|
73
73
|
`claude-down` provides a browser-safe entry point that only includes the Anthropic Statuspage source (since Downdetector requires a local Chromium binary).
|
|
74
74
|
|
|
75
75
|
```typescript
|
|
76
|
-
import { checkAnthropic
|
|
76
|
+
import { checkAnthropic } from "claude-down/browser";
|
|
77
77
|
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
|
|
78
|
+
const result = await checkAnthropic();
|
|
79
|
+
|
|
80
|
+
if (result.kind === "ok") {
|
|
81
|
+
console.log(result.summary.status.description);
|
|
82
|
+
console.log(result.summary.status.indicator);
|
|
83
|
+
console.log(result.summary.incidents);
|
|
84
|
+
console.log(result.summary.components);
|
|
85
|
+
} else {
|
|
86
|
+
console.error(result.reason);
|
|
81
87
|
}
|
|
82
88
|
```
|
|
83
89
|
|
package/dist/anthropic.d.mts
CHANGED
package/dist/bin/cli.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{CLIError as e,cli as t,command as n,flag as r}from"@kjanat/dreamcli";import{exit as i,stdout as a}from"node:process";import{spawn as o,spawnSync as s}from"node:child_process";import{mkdtempSync as c,rmSync as l}from"node:fs";import{tmpdir as ee}from"node:os";import{join as u}from"node:path";import{setTimeout as d}from"node:timers/promises";var f=Object.defineProperty,p=Object.getOwnPropertyDescriptor,te=Object.getOwnPropertyNames,m=Object.prototype.hasOwnProperty,h=(e,t)=>()=>(e&&(t=e(e=0)),t),g=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),_=(e,t)=>{let n={};for(var r in e)f(n,r,{get:e[r],enumerable:!0});return t||f(n,Symbol.toStringTag,{value:`Module`}),n},v=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=te(t),a=0,o=i.length,s;a<o;a++)s=i[a],!m.call(e,s)&&s!==n&&f(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=p(t,s))||r.enumerable});return e},ne=e=>m.call(e,`module.exports`)?e[`module.exports`]:v(f({},`__esModule`,{value:!0}),e),y=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Endpoint=void 0,e.Endpoint={ACTIVE_JSON:`upcoming.json`,API_V2_BASE:`api/v2`,components(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.COMPONENTS_JSON}`},COMPONENTS_JSON:`components.json`,INCIDENTS:`incidents`,Incidents:{all(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.INCIDENTS_JSON}`},unresolved(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.INCIDENTS}/${e.Endpoint.UNRESOLVED_JSON}`}},INCIDENTS_JSON:`incidents.json`,SCHEDULED_MAINTENANCES:`scheduled-maintenances`,SCHEDULED_MAINTENANCES_JSON:`scheduled-maintenances.json`,ScheduledMaintenances:{active(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SCHEDULED_MAINTENANCES}/${e.Endpoint.ACTIVE_JSON}`},all(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SCHEDULED_MAINTENANCES_JSON}`},upcoming(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SCHEDULED_MAINTENANCES}/${e.Endpoint.UPCOMING_JSON}`}},status(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.STATUS_JSON}`},STATUS_JSON:`status.json`,subscriber(t){return`/${e.Endpoint.API_V2_BASE}/subscribers/${encodeURIComponent(t)}.json`},subscribers(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SUBSCRIBERS_JSON}`},SUBSCRIBERS_JSON:`subscribers.json`,summary(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SUMMARY_JSON}`},SUMMARY_JSON:`summary.json`,UNRESOLVED_JSON:`unresolved.json`,UPCOMING_JSON:`upcoming.json`}})),b=g((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.IncidentsAPI=void 0;let n=y();e.IncidentsAPI=class{constructor(e){this.apiClient=e}getAll(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.Incidents.all(),{data:t}=yield this.apiClient.get(e);return t})}getUnresolved(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.Incidents.unresolved(),{data:t}=yield this.apiClient.get(e);return t})}}})),x=g((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.ScheduledMaintenancesAPI=void 0;let n=y();e.ScheduledMaintenancesAPI=class{constructor(e){this.apiClient=e}getActive(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.ScheduledMaintenances.active(),{data:t}=yield this.apiClient.get(e);return t})}getAll(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.ScheduledMaintenances.all(),{data:t}=yield this.apiClient.get(e);return t})}getUpcoming(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.ScheduledMaintenances.upcoming(),{data:t}=yield this.apiClient.get(e);return t})}}})),S=g((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.SubscribersAPI=void 0;let n=y();e.SubscribersAPI=class{constructor(e){this.apiClient=e}createComponentSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscribers(),{data:r}=yield this.apiClient.post(t,{subscriber:e});return r})}createIncidentSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscribers(),{data:r}=yield this.apiClient.post(t,{subscriber:e});return r})}createPageSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscribers(),{data:r}=yield this.apiClient.post(t,{subscriber:e});return r})}getSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscribers(),{data:r}=yield this.apiClient.get(t,{params:{subscriber:{id:e}}});return r})}removeSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscriber(e),{data:r}=yield this.apiClient.delete(t);return r})}}})),C=g((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(b(),e),n(x(),e),n(S(),e)})),re=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),ie=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),ae=g((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MaintenanceStatus=e.IncidentStatus=e.IncidentImpact=void 0;var t;(function(e){e.Critical=`critical`,e.Major=`major`,e.Minor=`minor`,e.None=`none`})(t||(e.IncidentImpact=t={}));var n;(function(e){e.Identified=`identified`,e.Investigating=`investigating`,e.Monitoring=`monitoring`,e.Postmortem=`postmortem`,e.Resolved=`resolved`})(n||(e.IncidentStatus=n={}));var r;(function(e){e.Completed=`completed`,e.InProgress=`in_progress`,e.Scheduled=`scheduled`,e.Verifying=`verifying`})(r||(e.MaintenanceStatus=r={}))})),oe=g((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(re(),e),n(ie(),e),n(ae(),e)})),w,T=h((()=>{w=class{constructor(e,t){this.baseUrl=e,this.config=t,this.interceptors={request:[],response:[]}}async delete(e,t){let n=await this.request(e,{...t,method:`DELETE`});return{data:await this.formatData(n,t),headers:n.headers,status:n.status}}async get(e,t){let n=await this.request(e,{...t,method:`GET`});return{data:await this.formatData(n,t),headers:n.headers,status:n.status}}async head(e,t){let n=await this.request(e,{...t,method:`HEAD`});return{data:await this.formatData(n,t),headers:n.headers,status:n.status}}async options(e,t){let n=await this.request(e,{...t,method:`OPTIONS`});return{data:await this.formatData(n,t),headers:n.headers,status:n.status}}async patch(e,t,n){let r=await this.request(e,{...n,data:t,method:`PATCH`});return{data:await this.formatData(r,n),headers:r.headers,status:r.status}}async post(e,t,n){let r=await this.request(e,{data:t,...n,method:`POST`});return{data:await this.formatData(r,n),headers:r.headers,status:r.status}}async put(e,t,n){let r=await this.request(e,{data:t,...n,method:`PUT`});return{data:await this.formatData(r,n),headers:r.headers,status:r.status}}async request(e,t){let n=new URL(e,this.baseUrl);if(t.params)for(let[e,r]of Object.entries(t.params))r!=null&&n.searchParams.append(e,String(r));let r={method:t.method.toUpperCase(),url:n,...this.config};if(t.headers&&(r.headers={...r.headers,...t.headers}),this.config?.auth){let{password:e,username:t}=this.config.auth,n=btoa(`${t}:${e}`);r.headers={...r.headers,Authorization:`Basic ${n}`}}if(t.data&&(t.data instanceof Object&&(r.headers={...r.headers,"Content-Type":`application/json`},t.data=JSON.stringify(t.data)),r.body=t.data),this.interceptors.request.length>0)for(let e of this.interceptors.request)r={...r,...await e({...r,url:n})};n=r.url;let i=await fetch(n,r);if(!i.ok){let e;try{e=await i.text()}catch{e=i.statusText}throw Error(e?`Request failed with status code ${i.status}: ${e}`:`Request failed with status code ${i.status}`)}if(this.interceptors.response.length>0)for(let e of this.interceptors.response)await e(i);return i}setBaseURL(e){this.baseUrl=e}setConfig(e){this.config=e}formatData(e,t){switch(t?.responseType||`json`){case`arraybuffer`:return e.arrayBuffer();case`blob`:return e.blob();case`text`:return e.text();default:return e.json()}}}})),E=h((()=>{})),D=_({APIClient:()=>w}),O=h((()=>{T(),E()})),k=g((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.Statuspage=void 0;let n=(O(),ne(D)),r=C(),i=y();e.Statuspage=class{constructor(e){if(this.getComponents=()=>t(this,void 0,void 0,function*(){let e=i.Endpoint.components(),{data:t}=yield this.apiClient.get(e);return t}),this.getStatus=()=>t(this,void 0,void 0,function*(){let e=i.Endpoint.status(),{data:t}=yield this.apiClient.get(e);return t}),this.getSummary=()=>t(this,void 0,void 0,function*(){let e=i.Endpoint.summary(),{data:t}=yield this.apiClient.get(e);return t}),!e)throw Error(`A page ID needs to be set in order to use the client.`);this.apiClient=new n.APIClient(`https://${e}.statuspage.io`),this.api={getComponents:this.getComponents,getStatus:this.getStatus,getSummary:this.getSummary,incidents:new r.IncidentsAPI(this.apiClient),scheduledMaintenances:new r.ScheduledMaintenancesAPI(this.apiClient),subscribers:new r.SubscribersAPI(this.apiClient)}}setApiUrl(e){this.apiClient.setBaseURL(e)}}})),A=g((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(C(),e),n(oe(),e),n(k(),e)}))();const j={none:0,minor:1,major:2,critical:2,unavailable:21},M=`https://status.claude.com`,N=[`google-chrome-stable`,`google-chrome`,`chromium`,`brave`,`microsoft-edge-stable`,`microsoft-edge`];async function P(e=M){try{let t=new A.Statuspage(`anthropic`);return t.setApiUrl(e),{kind:`ok`,summary:await t.api.getSummary()}}catch(e){return{kind:`unknown`,reason:e instanceof Error?e.message:String(e)}}}function F(){for(let e of N){let t=s(`which`,[e]);if(t.status===0&&t.stdout)return t.stdout.toString().trim()}return null}function I(e){return typeof e==`object`&&!!e&&`webSocketDebuggerUrl`in e&&typeof e.webSocketDebuggerUrl==`string`}function L(e){return typeof e==`object`&&!!e&&`id`in e&&typeof e.id==`number`}function R(e){return typeof e==`object`&&!!e&&`result`in e&&typeof e.result==`object`&&e.result!==null&&`result`in e.result&&typeof e.result.result==`object`&&e.result.result!==null&&`value`in e.result.result&&typeof e.result.result.value==`string`}function z(e){if(typeof e!=`object`||!e||!(`title`in e)||typeof e.title!=`string`||`h1`in e&&e.h1!==null&&typeof e.h1!=`string`||!(`pogo`in e))return!1;if(e.pogo===null)return!0;if(typeof e.pogo!=`object`)return!1;let t=e.pogo;return!(`outage`in t&&t.outage!==void 0&&typeof t.outage!=`boolean`)}async function B(e,t){let n=Date.now()+t;for(;Date.now()<n;){try{if((await fetch(`${e}/json/version`)).ok)return!0}catch{}await d(100)}return!1}function V(e){let t=new Map,n=0;return e.onmessage=e=>{let n=typeof e.data==`string`?e.data:e.data instanceof ArrayBuffer?new TextDecoder().decode(e.data):null;if(n===null)return;let r;try{r=JSON.parse(n)}catch{return}if(!L(r))return;let i=t.get(r.id);i&&(t.delete(r.id),i(r))},(r,i={})=>new Promise((a,o)=>{let s=++n,c=setTimeout(()=>{t.delete(s),o(Error(`CDP command '${r}' timed out`))},5e3);t.set(s,e=>{clearTimeout(c),a(e)}),e.send(JSON.stringify({id:s,method:r,params:i}))})}async function H(e,t){await e(`Runtime.enable`);let n=Date.now()+t;for(;Date.now()<n;){let t=await e(`Runtime.evaluate`,{expression:`JSON.stringify({ title: document.title, pogo: window.PogoConfig ?? null, h1: document.querySelector("h1")?.innerText ?? null })`,returnByValue:!0});if(R(t)){let e;try{e=JSON.parse(t.result.result.value)}catch{e=null}if(z(e)&&e.pogo!==null&&e.title!==`Just a moment...`)return{pogo:e.pogo,heading:e.h1}}await d(700)}return null}async function se(e){let t;try{t=c(u(ee(),`claude-down-`))}catch(e){return{ok:!1,error:`mkdtemp failed: ${e instanceof Error?e.message:String(e)}`}}let n=9222+Math.floor(Math.random()*1e3),r=o(e,[`--headless=new`,`--disable-gpu`,`--no-sandbox`,`--disable-blink-features=AutomationControlled`,`--window-size=1920,1080`,`--user-data-dir=${t}`,`--remote-debugging-port=${n}`,`--user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36`,`about:blank`],{stdio:`ignore`}),i=`http://localhost:${n}`;return await B(i,5e3)?{ok:!0,proc:r,userDataDir:t,base:i}:(r.kill(),l(t,{recursive:!0,force:!0,maxRetries:5,retryDelay:100}),{ok:!1,error:`CDP endpoint never came up`})}async function U(e,t){let n=await(await fetch(`${e}/json/new?${encodeURIComponent(t)}`,{method:`PUT`})).json();if(!I(n))return{ok:!1,error:`unexpected CDP target shape`};let r=new WebSocket(n.webSocketDebuggerUrl);return await new Promise((e,t)=>{r.onopen=()=>e(),r.onerror=()=>t(Error(`WebSocket connection failed`)),r.onclose=()=>t(Error(`WebSocket closed before opening`))}),{ok:!0,send:V(r),close:()=>r.close()}}async function W(){let e=F();if(!e)return{ok:!1,error:`no chromium/chrome binary found`};let t=await se(e);if(!t.ok)return t;let{proc:n,userDataDir:r,base:i}=t;try{let e=await U(i,`https://downdetector.com/status/claude-ai/`);if(!e.ok)return e;let t=await H(e.send,2e4);return e.close(),t?t.pogo.outage===!0?{ok:!0,down:!0,reason:t.heading??`outage reported`}:{ok:!0,down:!1}:{ok:!1,error:`CF challenge not cleared in time`}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}finally{n.kill(),l(r,{recursive:!0,force:!0,maxRetries:5,retryDelay:100})}}const G=[`anthropic`,`downdetector`],K={anthropic:`Anthropic`,downdetector:`Downdetector`};function ce(e){return e===`none`||e===`minor`||e===`major`||e===`critical`?e:`critical`}function q(e,t,n){if(n.length!==0){e.push(` ${t}:`);for(let t of n)e.push(` - ${t}`)}}function le(e){let t=[K[e.source]];if(e.source===`downdetector`)return t.push(` ${e.details??`No user-reported issues`}`),t.join(`
|
|
3
|
-
`)
|
|
4
|
-
`)}
|
|
2
|
+
import{cli as e,command as t,flag as n}from"@kjanat/dreamcli";import{exit as r,stdout as i}from"node:process";import{spawn as a,spawnSync as o}from"node:child_process";import{mkdtempSync as s,rmSync as c}from"node:fs";import{tmpdir as ee}from"node:os";import{join as te}from"node:path";import{setTimeout as l}from"node:timers/promises";var u=Object.defineProperty,d=Object.getOwnPropertyDescriptor,ne=Object.getOwnPropertyNames,f=Object.prototype.hasOwnProperty,p=(e,t)=>()=>(e&&(t=e(e=0)),t),m=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),h=(e,t)=>{let n={};for(var r in e)u(n,r,{get:e[r],enumerable:!0});return t||u(n,Symbol.toStringTag,{value:`Module`}),n},g=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=ne(t),a=0,o=i.length,s;a<o;a++)s=i[a],!f.call(e,s)&&s!==n&&u(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=d(t,s))||r.enumerable});return e},re=e=>f.call(e,`module.exports`)?e[`module.exports`]:g(u({},`__esModule`,{value:!0}),e);const _=[`anthropic`,`downdetector`],v={anthropic:`Anthropic`,downdetector:`Downdetector`},y={none:0,minor:1,major:2,critical:2,unavailable:21},b=`https://status.claude.com`,x=`https://downdetector.com/status/claude-ai/`,S=[`google-chrome-stable`,`google-chrome`,`chromium`,`brave`,`microsoft-edge-stable`,`microsoft-edge`],C=n.boolean().alias(`q`).describe(`Silent; exit code only`),w=n.string().default(b).env(`CLAUDE_DOWN_ANTHROPIC_STATUS_BASE`).describe(`Override Anthropic status page base URL`),ie=n.array(n.enum(_)).default([..._]).alias(`s`).describe(`Data source(s) to check`),T=`\x1B[31m`,E=`\x1B[32m`;function D(e,t,n){return n?`${t}${e}[0m`:e}function ae(e,t,n){return n?`\x1b]8;;${t}\x1b\\${e}\x1b]8;;\x1b\\`:e}function O(e){if(e.indicator===`unavailable`)return`\x1B[2m`;if(e.source===`downdetector`)return e.reportsOutage?T:E;switch(e.indicator){case`none`:return E;case`minor`:return`\x1B[33m`;case`major`:case`critical`:return T}}function k(e){return e.source===`anthropic`?b:x}function A(e,t,n){if(n.length!==0){e.push(` ${t}:`);for(let t of n)e.push(` - ${t}`)}}function j(e,t){let n=O(e),r=[ae(D(v[e.source],`[1m${n}`,t),k(e),t)];if(e.indicator===`unavailable`){let i=e.summaryText??`unknown error`;return r.push(` ${D(`Unavailable: ${i}`,n,t)}`),r.join(`
|
|
3
|
+
`)}if(e.source===`downdetector`){let i=e.summaryText??`No user-reported issues`;return r.push(` ${D(i,n,t)}`),r.join(`
|
|
4
|
+
`)}let i=e.summaryText??`All systems operational`;r.push(` ${D(i,n,t)}`);let a=e.incidents?.map(e=>`${e.name} (${e.status})`)??[];return A(r,a.length===1?`Active incident`:`Active incidents`,a),A(r,`Affected components`,e.affectedComponents?.map(e=>e.name)??[]),r.join(`
|
|
5
|
+
`)}function M(e){return e.source===`downdetector`?{source:`downdetector`,status:e.indicator===`unavailable`?`unavailable`:e.reportsOutage?`down`:`up`,details:e.summaryText}:{source:`anthropic`,status:e.indicator===`none`?`up`:e.indicator,details:e.summaryText,incidents:e.incidents,affected:e.affectedComponents}}function N(e){return e.map(e=>M(e))}function P(e,t){if(t.jsonMode||!t.isTTY){t.json(N(e));return}t.log(e.map(e=>j(e,t.isTTY)).join(`
|
|
5
6
|
|
|
6
|
-
`))}const Z=r.boolean().alias(`q`).describe(`Silent; exit code only`),Q=r.string().default(M).env(`CLAUDE_DOWN_ANTHROPIC_STATUS_BASE`).describe(`Override Anthropic status page base URL`),pe=r.array(r.enum(G)).default([...G]).alias(`s`).describe(`Data source(s) to check`),me=n(`status`).description(`Check Claude status across Anthropic and Downdetector`).example(`status`,`Check all sources`).example(`status --source anthropic`,`Check only Anthropic`).example(`status --json`,`Emit machine-readable source rows`).flag(`anthropicStatusBase`,Q).flag(`quiet`,Z).flag(`source`,pe).action(async({flags:e,out:t})=>{let n=await ue(e.source,e.anthropicStatusBase);if(e.quiet){let e=de(n);e!==0&&i(e);return}X(fe(n),t)}),he=n(`anthropic`).description(`Check only ${K.anthropic}`).example(`anthropic`,`Check only ${K.anthropic}`).flag(`anthropicStatusBase`,Q).flag(`quiet`,Z).action(async({flags:e,out:t})=>{let n=await J(e.anthropicStatusBase);if(e.quiet){n.exitCode!==0&&i(n.exitCode);return}X([n.row],t)}),ge=n(`downdetector`).description(`Check only ${K.downdetector}`).example(`downdetector`,`Check only ${K.downdetector}`).flag(`quiet`,Z).action(async({flags:e,out:t})=>{let n=await Y();if(e.quiet){n.exitCode!==0&&i(n.exitCode);return}X([n.row],t)}),$=t(`claude-down`).packageJson({inferName:!0}).command(me).command(he).command(ge).completions();import.meta.main&&$.run({help:{width:a.columns}});export{$ as claudeDown};
|
|
7
|
+
`))}var F=m((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Endpoint=void 0,e.Endpoint={ACTIVE_JSON:`upcoming.json`,API_V2_BASE:`api/v2`,components(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.COMPONENTS_JSON}`},COMPONENTS_JSON:`components.json`,INCIDENTS:`incidents`,Incidents:{all(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.INCIDENTS_JSON}`},unresolved(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.INCIDENTS}/${e.Endpoint.UNRESOLVED_JSON}`}},INCIDENTS_JSON:`incidents.json`,SCHEDULED_MAINTENANCES:`scheduled-maintenances`,SCHEDULED_MAINTENANCES_JSON:`scheduled-maintenances.json`,ScheduledMaintenances:{active(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SCHEDULED_MAINTENANCES}/${e.Endpoint.ACTIVE_JSON}`},all(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SCHEDULED_MAINTENANCES_JSON}`},upcoming(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SCHEDULED_MAINTENANCES}/${e.Endpoint.UPCOMING_JSON}`}},status(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.STATUS_JSON}`},STATUS_JSON:`status.json`,subscriber(t){return`/${e.Endpoint.API_V2_BASE}/subscribers/${encodeURIComponent(t)}.json`},subscribers(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SUBSCRIBERS_JSON}`},SUBSCRIBERS_JSON:`subscribers.json`,summary(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SUMMARY_JSON}`},SUMMARY_JSON:`summary.json`,UNRESOLVED_JSON:`unresolved.json`,UPCOMING_JSON:`upcoming.json`}})),I=m((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.IncidentsAPI=void 0;let n=F();e.IncidentsAPI=class{constructor(e){this.apiClient=e}getAll(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.Incidents.all(),{data:t}=yield this.apiClient.get(e);return t})}getUnresolved(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.Incidents.unresolved(),{data:t}=yield this.apiClient.get(e);return t})}}})),L=m((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.ScheduledMaintenancesAPI=void 0;let n=F();e.ScheduledMaintenancesAPI=class{constructor(e){this.apiClient=e}getActive(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.ScheduledMaintenances.active(),{data:t}=yield this.apiClient.get(e);return t})}getAll(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.ScheduledMaintenances.all(),{data:t}=yield this.apiClient.get(e);return t})}getUpcoming(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.ScheduledMaintenances.upcoming(),{data:t}=yield this.apiClient.get(e);return t})}}})),R=m((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.SubscribersAPI=void 0;let n=F();e.SubscribersAPI=class{constructor(e){this.apiClient=e}createComponentSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscribers(),{data:r}=yield this.apiClient.post(t,{subscriber:e});return r})}createIncidentSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscribers(),{data:r}=yield this.apiClient.post(t,{subscriber:e});return r})}createPageSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscribers(),{data:r}=yield this.apiClient.post(t,{subscriber:e});return r})}getSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscribers(),{data:r}=yield this.apiClient.get(t,{params:{subscriber:{id:e}}});return r})}removeSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscriber(e),{data:r}=yield this.apiClient.delete(t);return r})}}})),z=m((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(I(),e),n(L(),e),n(R(),e)})),B=m((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),V=m((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),H=m((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MaintenanceStatus=e.IncidentStatus=e.IncidentImpact=void 0;var t;(function(e){e.Critical=`critical`,e.Major=`major`,e.Minor=`minor`,e.None=`none`})(t||(e.IncidentImpact=t={}));var n;(function(e){e.Identified=`identified`,e.Investigating=`investigating`,e.Monitoring=`monitoring`,e.Postmortem=`postmortem`,e.Resolved=`resolved`})(n||(e.IncidentStatus=n={}));var r;(function(e){e.Completed=`completed`,e.InProgress=`in_progress`,e.Scheduled=`scheduled`,e.Verifying=`verifying`})(r||(e.MaintenanceStatus=r={}))})),U=m((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(B(),e),n(V(),e),n(H(),e)})),W,G=p((()=>{W=class{constructor(e,t){this.baseUrl=e,this.config=t,this.interceptors={request:[],response:[]}}async delete(e,t){let n=await this.request(e,{...t,method:`DELETE`});return{data:await this.formatData(n,t),headers:n.headers,status:n.status}}async get(e,t){let n=await this.request(e,{...t,method:`GET`});return{data:await this.formatData(n,t),headers:n.headers,status:n.status}}async head(e,t){let n=await this.request(e,{...t,method:`HEAD`});return{data:await this.formatData(n,t),headers:n.headers,status:n.status}}async options(e,t){let n=await this.request(e,{...t,method:`OPTIONS`});return{data:await this.formatData(n,t),headers:n.headers,status:n.status}}async patch(e,t,n){let r=await this.request(e,{...n,data:t,method:`PATCH`});return{data:await this.formatData(r,n),headers:r.headers,status:r.status}}async post(e,t,n){let r=await this.request(e,{data:t,...n,method:`POST`});return{data:await this.formatData(r,n),headers:r.headers,status:r.status}}async put(e,t,n){let r=await this.request(e,{data:t,...n,method:`PUT`});return{data:await this.formatData(r,n),headers:r.headers,status:r.status}}async request(e,t){let n=new URL(e,this.baseUrl);if(t.params)for(let[e,r]of Object.entries(t.params))r!=null&&n.searchParams.append(e,String(r));let r={method:t.method.toUpperCase(),url:n,...this.config};if(t.headers&&(r.headers={...r.headers,...t.headers}),this.config?.auth){let{password:e,username:t}=this.config.auth,n=btoa(`${t}:${e}`);r.headers={...r.headers,Authorization:`Basic ${n}`}}if(t.data&&(t.data instanceof Object&&(r.headers={...r.headers,"Content-Type":`application/json`},t.data=JSON.stringify(t.data)),r.body=t.data),this.interceptors.request.length>0)for(let e of this.interceptors.request)r={...r,...await e({...r,url:n})};n=r.url;let i=await fetch(n,r);if(!i.ok){let e;try{e=await i.text()}catch{e=i.statusText}throw Error(e?`Request failed with status code ${i.status}: ${e}`:`Request failed with status code ${i.status}`)}if(this.interceptors.response.length>0)for(let e of this.interceptors.response)await e(i);return i}setBaseURL(e){this.baseUrl=e}setConfig(e){this.config=e}formatData(e,t){switch(t?.responseType||`json`){case`arraybuffer`:return e.arrayBuffer();case`blob`:return e.blob();case`text`:return e.text();default:return e.json()}}}})),K=p((()=>{})),q=h({APIClient:()=>W}),J=p((()=>{G(),K()})),oe=m((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.Statuspage=void 0;let n=(J(),re(q)),r=z(),i=F();e.Statuspage=class{constructor(e){if(this.getComponents=()=>t(this,void 0,void 0,function*(){let e=i.Endpoint.components(),{data:t}=yield this.apiClient.get(e);return t}),this.getStatus=()=>t(this,void 0,void 0,function*(){let e=i.Endpoint.status(),{data:t}=yield this.apiClient.get(e);return t}),this.getSummary=()=>t(this,void 0,void 0,function*(){let e=i.Endpoint.summary(),{data:t}=yield this.apiClient.get(e);return t}),!e)throw Error(`A page ID needs to be set in order to use the client.`);this.apiClient=new n.APIClient(`https://${e}.statuspage.io`),this.api={getComponents:this.getComponents,getStatus:this.getStatus,getSummary:this.getSummary,incidents:new r.IncidentsAPI(this.apiClient),scheduledMaintenances:new r.ScheduledMaintenancesAPI(this.apiClient),subscribers:new r.SubscribersAPI(this.apiClient)}}setApiUrl(e){this.apiClient.setBaseURL(e)}}})),se=m((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(z(),e),n(U(),e),n(oe(),e)}))();async function ce(e=b){try{let t=new se.Statuspage(`anthropic`);return t.setApiUrl(e),{kind:`ok`,summary:await t.api.getSummary()}}catch(e){return{kind:`unknown`,reason:e instanceof Error?e.message:String(e)}}}function le(e){return typeof e==`object`&&!!e&&`webSocketDebuggerUrl`in e&&typeof e.webSocketDebuggerUrl==`string`}function ue(e){return typeof e==`object`&&!!e&&`id`in e&&typeof e.id==`number`}function de(e){let t=new Map,n=0;return e.onmessage=e=>{let n=typeof e.data==`string`?e.data:e.data instanceof ArrayBuffer?new TextDecoder().decode(e.data):null;if(n===null)return;let r;try{r=JSON.parse(n)}catch{return}if(!ue(r))return;let i=t.get(r.id);i!==void 0&&(t.delete(r.id),i(r))},(r,i={})=>new Promise((a,o)=>{let s=++n,c=setTimeout(()=>{t.delete(s),o(Error(`CDP command '${r}' timed out`))},5e3);t.set(s,e=>{clearTimeout(c),a(e)}),e.send(JSON.stringify({id:s,method:r,params:i}))})}async function fe(e,t){let n=await(await fetch(`${e}/json/new?${encodeURIComponent(t)}`,{method:`PUT`})).json();if(!le(n))return{ok:!1,error:`unexpected CDP target shape`};let r=new WebSocket(n.webSocketDebuggerUrl);return await new Promise((e,t)=>{r.onopen=()=>e(),r.onerror=()=>t(Error(`WebSocket connection failed`)),r.onclose=()=>t(Error(`WebSocket closed before opening`))}),{ok:!0,send:de(r),close:()=>r.close()}}function pe(){for(let e of S){let t=o(`which`,[e]);if(t.status===0&&t.stdout)return t.stdout.toString().trim()}return null}async function me(e,t){let n=Date.now()+t;for(;Date.now()<n;){try{if((await fetch(`${e}/json/version`)).ok)return!0}catch{}await l(100)}return!1}async function he(e){let t;try{t=s(te(ee(),`claude-down-`))}catch(e){return{ok:!1,error:`mkdtemp failed: ${e instanceof Error?e.message:String(e)}`}}let n=9222+Math.floor(Math.random()*1e3),r=a(e,[`--headless=new`,`--disable-gpu`,`--no-sandbox`,`--disable-blink-features=AutomationControlled`,`--window-size=1920,1080`,`--user-data-dir=${t}`,`--remote-debugging-port=${n}`,`--user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36`,`about:blank`],{stdio:`ignore`}),i=`http://localhost:${n}`;return await me(i,5e3)?{ok:!0,browser:{proc:r,userDataDir:t,base:i}}:(Y(r,t),{ok:!1,error:`CDP endpoint never came up`})}function Y(e,t){e.kill(),c(t,{recursive:!0,force:!0,maxRetries:5,retryDelay:100})}function ge(e){return typeof e==`object`&&!!e&&`result`in e&&typeof e.result==`object`&&e.result!==null&&`result`in e.result&&typeof e.result.result==`object`&&e.result.result!==null&&`value`in e.result.result&&typeof e.result.result.value==`string`}function _e(e){if(typeof e!=`object`||!e||!(`title`in e)||typeof e.title!=`string`||`h1`in e&&e.h1!==null&&typeof e.h1!=`string`||!(`pogo`in e))return!1;if(e.pogo===null)return!0;if(typeof e.pogo!=`object`)return!1;let t=e.pogo;return!(`outage`in t&&t.outage!==void 0&&typeof t.outage!=`boolean`)}async function ve(e,t){await e(`Runtime.enable`);let n=Date.now()+t;for(;Date.now()<n;){let t=await e(`Runtime.evaluate`,{expression:`JSON.stringify({ title: document.title, pogo: window.PogoConfig ?? null, h1: document.querySelector("h1")?.innerText ?? null })`,returnByValue:!0});if(ge(t)){let e;try{e=JSON.parse(t.result.result.value)}catch{e=null}if(_e(e)&&e.pogo!==null&&e.title!==`Just a moment...`)return{pogo:e.pogo,heading:e.h1}}await l(700)}return null}async function ye(){let e=pe();if(e===null)return{ok:!1,error:`no chromium/chrome binary found`};let t=await he(e);if(!t.ok)return t;let{browser:{proc:n,userDataDir:r,base:i}}=t;try{let e=await fe(i,x);if(!e.ok)return e;let t=await ve(e.send,2e4);return e.close(),t===null?{ok:!1,error:`CF challenge not cleared in time`}:t.pogo.outage===!0?{ok:!0,down:!0,reason:t.heading??`outage reported`}:{ok:!0,down:!1}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}finally{Y(n,r)}}function be(e){return e===`none`||e===`minor`||e===`major`||e===`critical`?e:`critical`}async function X(e){let t=await ce(e);if(t.kind===`unknown`)return{source:`anthropic`,indicator:`unavailable`,summaryText:t.reason,incidents:null,affectedComponents:null};let n=be(t.summary.status.indicator),r=t.summary.components.filter(e=>e.status!==`operational`);return{source:`anthropic`,indicator:n,summaryText:t.summary.status.description,incidents:t.summary.incidents.length>0?t.summary.incidents.map(e=>({name:e.name,status:e.status})):null,affectedComponents:r.length>0?r.map(e=>({name:e.name,status:e.status})):null}}async function Z(){let e=await ye();return e.ok?{source:`downdetector`,indicator:e.down?`major`:`none`,summaryText:e.down?e.reason:null,reportsOutage:e.down}:{source:`downdetector`,indicator:`unavailable`,summaryText:e.error,reportsOutage:!1}}async function xe(e,t){switch(e){case`anthropic`:return X(t);case`downdetector`:return Z()}}async function Q(e,t){return Promise.all(e.map(e=>xe(e,t)))}function Se(e){return y[e.indicator]}function Ce(e){return e.reduce((e,t)=>Math.max(e,Se(t)),y.none)}function we(e){return[...e].sort((e,t)=>e.source.localeCompare(t.source))}function $(e,t,n){if(t){let t=Ce(e);t!==0&&r(t);return}P(we(e),n)}const Te=t(`status`).description(`Check Claude status across Anthropic and Downdetector`).example(`status`,`Check all sources`).example(`status --source anthropic`,`Check only Anthropic`).example(`status --json`,`Emit machine-readable source rows`).flag(`anthropicStatusBase`,w).flag(`quiet`,C).flag(`source`,ie).action(async({flags:e,out:t})=>{$(await Q(e.source,e.anthropicStatusBase),e.quiet,t)}),Ee=t(`anthropic`).description(`Check only ${v.anthropic}`).example(`anthropic`,`Check only ${v.anthropic}`).flag(`anthropicStatusBase`,w).flag(`quiet`,C).action(async({flags:e,out:t})=>{$([await X(e.anthropicStatusBase)],e.quiet,t)}),De=t(`downdetector`).description(`Check only ${v.downdetector}`).example(`downdetector`,`Check only ${v.downdetector}`).flag(`quiet`,C).action(async({flags:e,out:t})=>{$([await Z()],e.quiet,t)}),Oe=e(`claude-down`).packageJson({inferName:!0}).command(Te).command(Ee).command(De).completions();import.meta.main&&Oe.run({help:{width:i.columns}});export{};
|
package/dist/cdp.d.mts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/lib/downdetector/cdp.d.ts
|
|
2
|
+
type CdpSend = (method: string, params?: Record<string, unknown>) => Promise<unknown>;
|
|
3
|
+
declare function openCdpTarget(base: string, url: string): Promise<{
|
|
4
|
+
ok: true;
|
|
5
|
+
send: CdpSend;
|
|
6
|
+
close: () => void;
|
|
7
|
+
} | {
|
|
8
|
+
ok: false;
|
|
9
|
+
error: string;
|
|
10
|
+
}>;
|
|
11
|
+
//#endregion
|
|
12
|
+
export { type CdpSend, openCdpTarget };
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ChildProcess } from "node:child_process";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/downdetector/chrome.d.ts
|
|
4
|
+
type LaunchedBrowser = {
|
|
5
|
+
proc: ChildProcess;
|
|
6
|
+
userDataDir: string;
|
|
7
|
+
base: string;
|
|
8
|
+
};
|
|
9
|
+
type LaunchBrowserResult = {
|
|
10
|
+
ok: true;
|
|
11
|
+
browser: LaunchedBrowser;
|
|
12
|
+
} | {
|
|
13
|
+
ok: false;
|
|
14
|
+
error: string;
|
|
15
|
+
};
|
|
16
|
+
declare function findChrome(): string | null;
|
|
17
|
+
declare function launchBrowser(chrome: string): Promise<LaunchBrowserResult>;
|
|
18
|
+
declare function cleanupBrowser(proc: ChildProcess, userDataDir: string): void;
|
|
19
|
+
//#endregion
|
|
20
|
+
export { type LaunchedBrowser, cleanupBrowser, findChrome, launchBrowser };
|
package/dist/downdetector.d.mts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { i as Signal } from "./types-4oEMjqAH.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/downdetector.d.ts
|
|
4
|
-
/**
|
|
5
|
-
* Launches a headless Chrome instance, navigates to the Downdetector page for Claude AI,
|
|
6
|
-
* waits for the Cloudflare challenge to clear, and extracts the outage status.
|
|
7
|
-
*
|
|
8
|
-
* The browser and its temporary user data directory are cleaned up in all cases.
|
|
9
|
-
*
|
|
10
|
-
* @returns A {@link Signal} indicating whether an outage is reported, the service is up, or an error occurred.
|
|
11
|
-
*/
|
|
12
4
|
declare function check(): Promise<Signal>;
|
|
13
5
|
//#endregion
|
|
14
6
|
export { check as checkDownDetector, check as default };
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as EXIT_CODES } from "./constants-CY8aOEl6.mjs";
|
|
2
|
-
import {
|
|
2
|
+
import { a as Summary, i as Signal, n as Indicator, r as Result, t as AvailableIndicator } from "./types-4oEMjqAH.mjs";
|
|
3
3
|
import { checkAnthropic as check } from "./anthropic.mjs";
|
|
4
4
|
import { checkDownDetector as check$1 } from "./downdetector.mjs";
|
|
5
|
-
export { EXIT_CODES, type Indicator, type Result, type Signal, type Summary, check as checkAnthropic, check$1 as checkDownDetector };
|
|
5
|
+
export { type AvailableIndicator, EXIT_CODES, type Indicator, type Result, type Signal, type Summary, check as checkAnthropic, check$1 as checkDownDetector };
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{spawn as e,spawnSync as t}from"node:child_process";import{mkdtempSync as n,rmSync as r}from"node:fs";import{tmpdir as i}from"node:os";import{join as a}from"node:path";import{setTimeout as o}from"node:timers/promises";var s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.prototype.hasOwnProperty,d=(e,t)=>()=>(e&&(t=e(e=0)),t),f=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),p=(e,t)=>{let n={};for(var r in e)s(n,r,{get:e[r],enumerable:!0});return t||s(n,Symbol.toStringTag,{value:`Module`}),n},m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=l(t),a=0,o=i.length,d;a<o;a++)d=i[a],!u.call(e,d)&&d!==n&&s(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=c(t,d))||r.enumerable});return e},h=e=>u.call(e,`module.exports`)?e[`module.exports`]:m(s({},`__esModule`,{value:!0}),e),g=f((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Endpoint=void 0,e.Endpoint={ACTIVE_JSON:`upcoming.json`,API_V2_BASE:`api/v2`,components(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.COMPONENTS_JSON}`},COMPONENTS_JSON:`components.json`,INCIDENTS:`incidents`,Incidents:{all(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.INCIDENTS_JSON}`},unresolved(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.INCIDENTS}/${e.Endpoint.UNRESOLVED_JSON}`}},INCIDENTS_JSON:`incidents.json`,SCHEDULED_MAINTENANCES:`scheduled-maintenances`,SCHEDULED_MAINTENANCES_JSON:`scheduled-maintenances.json`,ScheduledMaintenances:{active(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SCHEDULED_MAINTENANCES}/${e.Endpoint.ACTIVE_JSON}`},all(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SCHEDULED_MAINTENANCES_JSON}`},upcoming(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SCHEDULED_MAINTENANCES}/${e.Endpoint.UPCOMING_JSON}`}},status(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.STATUS_JSON}`},STATUS_JSON:`status.json`,subscriber(t){return`/${e.Endpoint.API_V2_BASE}/subscribers/${encodeURIComponent(t)}.json`},subscribers(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SUBSCRIBERS_JSON}`},SUBSCRIBERS_JSON:`subscribers.json`,summary(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SUMMARY_JSON}`},SUMMARY_JSON:`summary.json`,UNRESOLVED_JSON:`unresolved.json`,UPCOMING_JSON:`upcoming.json`}})),_=f((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.IncidentsAPI=void 0;let n=g();e.IncidentsAPI=class{constructor(e){this.apiClient=e}getAll(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.Incidents.all(),{data:t}=yield this.apiClient.get(e);return t})}getUnresolved(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.Incidents.unresolved(),{data:t}=yield this.apiClient.get(e);return t})}}})),v=f((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.ScheduledMaintenancesAPI=void 0;let n=g();e.ScheduledMaintenancesAPI=class{constructor(e){this.apiClient=e}getActive(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.ScheduledMaintenances.active(),{data:t}=yield this.apiClient.get(e);return t})}getAll(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.ScheduledMaintenances.all(),{data:t}=yield this.apiClient.get(e);return t})}getUpcoming(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.ScheduledMaintenances.upcoming(),{data:t}=yield this.apiClient.get(e);return t})}}})),y=f((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.SubscribersAPI=void 0;let n=g();e.SubscribersAPI=class{constructor(e){this.apiClient=e}createComponentSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscribers(),{data:r}=yield this.apiClient.post(t,{subscriber:e});return r})}createIncidentSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscribers(),{data:r}=yield this.apiClient.post(t,{subscriber:e});return r})}createPageSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscribers(),{data:r}=yield this.apiClient.post(t,{subscriber:e});return r})}getSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscribers(),{data:r}=yield this.apiClient.get(t,{params:{subscriber:{id:e}}});return r})}removeSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscriber(e),{data:r}=yield this.apiClient.delete(t);return r})}}})),b=f((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(_(),e),n(v(),e),n(y(),e)})),x=f((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),S=f((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),C=f((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MaintenanceStatus=e.IncidentStatus=e.IncidentImpact=void 0;var t;(function(e){e.Critical=`critical`,e.Major=`major`,e.Minor=`minor`,e.None=`none`})(t||(e.IncidentImpact=t={}));var n;(function(e){e.Identified=`identified`,e.Investigating=`investigating`,e.Monitoring=`monitoring`,e.Postmortem=`postmortem`,e.Resolved=`resolved`})(n||(e.IncidentStatus=n={}));var r;(function(e){e.Completed=`completed`,e.InProgress=`in_progress`,e.Scheduled=`scheduled`,e.Verifying=`verifying`})(r||(e.MaintenanceStatus=r={}))})),w=f((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(x(),e),n(S(),e),n(C(),e)})),T,E=d((()=>{T=class{constructor(e,t){this.baseUrl=e,this.config=t,this.interceptors={request:[],response:[]}}async delete(e,t){let n=await this.request(e,{...t,method:`DELETE`});return{data:await this.formatData(n,t),headers:n.headers,status:n.status}}async get(e,t){let n=await this.request(e,{...t,method:`GET`});return{data:await this.formatData(n,t),headers:n.headers,status:n.status}}async head(e,t){let n=await this.request(e,{...t,method:`HEAD`});return{data:await this.formatData(n,t),headers:n.headers,status:n.status}}async options(e,t){let n=await this.request(e,{...t,method:`OPTIONS`});return{data:await this.formatData(n,t),headers:n.headers,status:n.status}}async patch(e,t,n){let r=await this.request(e,{...n,data:t,method:`PATCH`});return{data:await this.formatData(r,n),headers:r.headers,status:r.status}}async post(e,t,n){let r=await this.request(e,{data:t,...n,method:`POST`});return{data:await this.formatData(r,n),headers:r.headers,status:r.status}}async put(e,t,n){let r=await this.request(e,{data:t,...n,method:`PUT`});return{data:await this.formatData(r,n),headers:r.headers,status:r.status}}async request(e,t){let n=new URL(e,this.baseUrl);if(t.params)for(let[e,r]of Object.entries(t.params))r!=null&&n.searchParams.append(e,String(r));let r={method:t.method.toUpperCase(),url:n,...this.config};if(t.headers&&(r.headers={...r.headers,...t.headers}),this.config?.auth){let{password:e,username:t}=this.config.auth,n=btoa(`${t}:${e}`);r.headers={...r.headers,Authorization:`Basic ${n}`}}if(t.data&&(t.data instanceof Object&&(r.headers={...r.headers,"Content-Type":`application/json`},t.data=JSON.stringify(t.data)),r.body=t.data),this.interceptors.request.length>0)for(let e of this.interceptors.request)r={...r,...await e({...r,url:n})};n=r.url;let i=await fetch(n,r);if(!i.ok){let e;try{e=await i.text()}catch{e=i.statusText}throw Error(e?`Request failed with status code ${i.status}: ${e}`:`Request failed with status code ${i.status}`)}if(this.interceptors.response.length>0)for(let e of this.interceptors.response)await e(i);return i}setBaseURL(e){this.baseUrl=e}setConfig(e){this.config=e}formatData(e,t){switch(t?.responseType||`json`){case`arraybuffer`:return e.arrayBuffer();case`blob`:return e.blob();case`text`:return e.text();default:return e.json()}}}})),D=d((()=>{})),O=p({APIClient:()=>T}),k=d((()=>{E(),D()})),A=f((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.Statuspage=void 0;let n=(k(),h(O)),r=b(),i=g();e.Statuspage=class{constructor(e){if(this.getComponents=()=>t(this,void 0,void 0,function*(){let e=i.Endpoint.components(),{data:t}=yield this.apiClient.get(e);return t}),this.getStatus=()=>t(this,void 0,void 0,function*(){let e=i.Endpoint.status(),{data:t}=yield this.apiClient.get(e);return t}),this.getSummary=()=>t(this,void 0,void 0,function*(){let e=i.Endpoint.summary(),{data:t}=yield this.apiClient.get(e);return t}),!e)throw Error(`A page ID needs to be set in order to use the client.`);this.apiClient=new n.APIClient(`https://${e}.statuspage.io`),this.api={getComponents:this.getComponents,getStatus:this.getStatus,getSummary:this.getSummary,incidents:new r.IncidentsAPI(this.apiClient),scheduledMaintenances:new r.ScheduledMaintenancesAPI(this.apiClient),subscribers:new r.SubscribersAPI(this.apiClient)}}setApiUrl(e){this.apiClient.setBaseURL(e)}}})),j=f((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(b(),e),n(w(),e),n(A(),e)}))();const M={none:0,minor:1,major:2,critical:2,unavailable:21},N=[`google-chrome-stable`,`google-chrome`,`chromium`,`brave`,`microsoft-edge-stable`,`microsoft-edge`];async function P(e=`https://status.claude.com`){try{let t=new j.Statuspage(`anthropic`);return t.setApiUrl(e),{kind:`ok`,summary:await t.api.getSummary()}}catch(e){return{kind:`unknown`,reason:e instanceof Error?e.message:String(e)}}}function F(){for(let e of N){let n=t(`which`,[e]);if(n.status===0&&n.stdout)return n.stdout.toString().trim()}return null}function I(e){return typeof e==`object`&&!!e&&`webSocketDebuggerUrl`in e&&typeof e.webSocketDebuggerUrl==`string`}function L(e){return typeof e==`object`&&!!e&&`id`in e&&typeof e.id==`number`}function R(e){return typeof e==`object`&&!!e&&`result`in e&&typeof e.result==`object`&&e.result!==null&&`result`in e.result&&typeof e.result.result==`object`&&e.result.result!==null&&`value`in e.result.result&&typeof e.result.result.value==`string`}function z(e){if(typeof e!=`object`||!e||!(`title`in e)||typeof e.title!=`string`||`h1`in e&&e.h1!==null&&typeof e.h1!=`string`||!(`pogo`in e))return!1;if(e.pogo===null)return!0;if(typeof e.pogo!=`object`)return!1;let t=e.pogo;return!(`outage`in t&&t.outage!==void 0&&typeof t.outage!=`boolean`)}async function B(e,t){let n=Date.now()+t;for(;Date.now()<n;){try{if((await fetch(`${e}/json/version`)).ok)return!0}catch{}await o(100)}return!1}function V(e){let t=new Map,n=0;return e.onmessage=e=>{let n=typeof e.data==`string`?e.data:e.data instanceof ArrayBuffer?new TextDecoder().decode(e.data):null;if(n===null)return;let r;try{r=JSON.parse(n)}catch{return}if(!L(r))return;let i=t.get(r.id);i&&(t.delete(r.id),i(r))},(r,i={})=>new Promise((a,o)=>{let s=++n,c=setTimeout(()=>{t.delete(s),o(Error(`CDP command '${r}' timed out`))},5e3);t.set(s,e=>{clearTimeout(c),a(e)}),e.send(JSON.stringify({id:s,method:r,params:i}))})}async function H(e,t){await e(`Runtime.enable`);let n=Date.now()+t;for(;Date.now()<n;){let t=await e(`Runtime.evaluate`,{expression:`JSON.stringify({ title: document.title, pogo: window.PogoConfig ?? null, h1: document.querySelector("h1")?.innerText ?? null })`,returnByValue:!0});if(R(t)){let e;try{e=JSON.parse(t.result.result.value)}catch{e=null}if(z(e)&&e.pogo!==null&&e.title!==`Just a moment...`)return{pogo:e.pogo,heading:e.h1}}await o(700)}return null}async function U(t){let o;try{o=n(a(i(),`claude-down-`))}catch(e){return{ok:!1,error:`mkdtemp failed: ${e instanceof Error?e.message:String(e)}`}}let s=9222+Math.floor(Math.random()*1e3),c=e(t,[`--headless=new`,`--disable-gpu`,`--no-sandbox`,`--disable-blink-features=AutomationControlled`,`--window-size=1920,1080`,`--user-data-dir=${o}`,`--remote-debugging-port=${s}`,`--user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36`,`about:blank`],{stdio:`ignore`}),l=`http://localhost:${s}`;return await B(l,5e3)?{ok:!0,proc:c,userDataDir:o,base:l}:(c.kill(),r(o,{recursive:!0,force:!0,maxRetries:5,retryDelay:100}),{ok:!1,error:`CDP endpoint never came up`})}async function W(e,t){let n=await(await fetch(`${e}/json/new?${encodeURIComponent(t)}`,{method:`PUT`})).json();if(!I(n))return{ok:!1,error:`unexpected CDP target shape`};let r=new WebSocket(n.webSocketDebuggerUrl);return await new Promise((e,t)=>{r.onopen=()=>e(),r.onerror=()=>t(Error(`WebSocket connection failed`)),r.onclose=()=>t(Error(`WebSocket closed before opening`))}),{ok:!0,send:V(r),close:()=>r.close()}}async function G(){let e=F();if(!e)return{ok:!1,error:`no chromium/chrome binary found`};let t=await U(e);if(!t.ok)return t;let{proc:n,userDataDir:i,base:a}=t;try{let e=await W(a,`https://downdetector.com/status/claude-ai/`);if(!e.ok)return e;let t=await H(e.send,2e4);return e.close(),t?t.pogo.outage===!0?{ok:!0,down:!0,reason:t.heading??`outage reported`}:{ok:!0,down:!1}:{ok:!1,error:`CF challenge not cleared in time`}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}finally{n.kill(),r(i,{recursive:!0,force:!0,maxRetries:5,retryDelay:100})}}export{M as EXIT_CODES,P as checkAnthropic,G as checkDownDetector};
|
|
1
|
+
import{spawn as e,spawnSync as t}from"node:child_process";import{mkdtempSync as n,rmSync as r}from"node:fs";import{tmpdir as i}from"node:os";import{join as a}from"node:path";import{setTimeout as o}from"node:timers/promises";var s=Object.defineProperty,c=Object.getOwnPropertyDescriptor,l=Object.getOwnPropertyNames,u=Object.prototype.hasOwnProperty,d=(e,t)=>()=>(e&&(t=e(e=0)),t),f=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),p=(e,t)=>{let n={};for(var r in e)s(n,r,{get:e[r],enumerable:!0});return t||s(n,Symbol.toStringTag,{value:`Module`}),n},m=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=l(t),a=0,o=i.length,d;a<o;a++)d=i[a],!u.call(e,d)&&d!==n&&s(e,d,{get:(e=>t[e]).bind(null,d),enumerable:!(r=c(t,d))||r.enumerable});return e},h=e=>u.call(e,`module.exports`)?e[`module.exports`]:m(s({},`__esModule`,{value:!0}),e),g=f((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.Endpoint=void 0,e.Endpoint={ACTIVE_JSON:`upcoming.json`,API_V2_BASE:`api/v2`,components(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.COMPONENTS_JSON}`},COMPONENTS_JSON:`components.json`,INCIDENTS:`incidents`,Incidents:{all(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.INCIDENTS_JSON}`},unresolved(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.INCIDENTS}/${e.Endpoint.UNRESOLVED_JSON}`}},INCIDENTS_JSON:`incidents.json`,SCHEDULED_MAINTENANCES:`scheduled-maintenances`,SCHEDULED_MAINTENANCES_JSON:`scheduled-maintenances.json`,ScheduledMaintenances:{active(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SCHEDULED_MAINTENANCES}/${e.Endpoint.ACTIVE_JSON}`},all(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SCHEDULED_MAINTENANCES_JSON}`},upcoming(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SCHEDULED_MAINTENANCES}/${e.Endpoint.UPCOMING_JSON}`}},status(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.STATUS_JSON}`},STATUS_JSON:`status.json`,subscriber(t){return`/${e.Endpoint.API_V2_BASE}/subscribers/${encodeURIComponent(t)}.json`},subscribers(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SUBSCRIBERS_JSON}`},SUBSCRIBERS_JSON:`subscribers.json`,summary(){return`/${e.Endpoint.API_V2_BASE}/${e.Endpoint.SUMMARY_JSON}`},SUMMARY_JSON:`summary.json`,UNRESOLVED_JSON:`unresolved.json`,UPCOMING_JSON:`upcoming.json`}})),_=f((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.IncidentsAPI=void 0;let n=g();e.IncidentsAPI=class{constructor(e){this.apiClient=e}getAll(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.Incidents.all(),{data:t}=yield this.apiClient.get(e);return t})}getUnresolved(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.Incidents.unresolved(),{data:t}=yield this.apiClient.get(e);return t})}}})),v=f((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.ScheduledMaintenancesAPI=void 0;let n=g();e.ScheduledMaintenancesAPI=class{constructor(e){this.apiClient=e}getActive(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.ScheduledMaintenances.active(),{data:t}=yield this.apiClient.get(e);return t})}getAll(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.ScheduledMaintenances.all(),{data:t}=yield this.apiClient.get(e);return t})}getUpcoming(){return t(this,void 0,void 0,function*(){let e=n.Endpoint.ScheduledMaintenances.upcoming(),{data:t}=yield this.apiClient.get(e);return t})}}})),y=f((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.SubscribersAPI=void 0;let n=g();e.SubscribersAPI=class{constructor(e){this.apiClient=e}createComponentSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscribers(),{data:r}=yield this.apiClient.post(t,{subscriber:e});return r})}createIncidentSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscribers(),{data:r}=yield this.apiClient.post(t,{subscriber:e});return r})}createPageSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscribers(),{data:r}=yield this.apiClient.post(t,{subscriber:e});return r})}getSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscribers(),{data:r}=yield this.apiClient.get(t,{params:{subscriber:{id:e}}});return r})}removeSubscription(e){return t(this,void 0,void 0,function*(){let t=n.Endpoint.subscriber(e),{data:r}=yield this.apiClient.delete(t);return r})}}})),b=f((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(_(),e),n(v(),e),n(y(),e)})),x=f((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),S=f((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),C=f((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.MaintenanceStatus=e.IncidentStatus=e.IncidentImpact=void 0;var t;(function(e){e.Critical=`critical`,e.Major=`major`,e.Minor=`minor`,e.None=`none`})(t||(e.IncidentImpact=t={}));var n;(function(e){e.Identified=`identified`,e.Investigating=`investigating`,e.Monitoring=`monitoring`,e.Postmortem=`postmortem`,e.Resolved=`resolved`})(n||(e.IncidentStatus=n={}));var r;(function(e){e.Completed=`completed`,e.InProgress=`in_progress`,e.Scheduled=`scheduled`,e.Verifying=`verifying`})(r||(e.MaintenanceStatus=r={}))})),w=f((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(x(),e),n(S(),e),n(C(),e)})),T,E=d((()=>{T=class{constructor(e,t){this.baseUrl=e,this.config=t,this.interceptors={request:[],response:[]}}async delete(e,t){let n=await this.request(e,{...t,method:`DELETE`});return{data:await this.formatData(n,t),headers:n.headers,status:n.status}}async get(e,t){let n=await this.request(e,{...t,method:`GET`});return{data:await this.formatData(n,t),headers:n.headers,status:n.status}}async head(e,t){let n=await this.request(e,{...t,method:`HEAD`});return{data:await this.formatData(n,t),headers:n.headers,status:n.status}}async options(e,t){let n=await this.request(e,{...t,method:`OPTIONS`});return{data:await this.formatData(n,t),headers:n.headers,status:n.status}}async patch(e,t,n){let r=await this.request(e,{...n,data:t,method:`PATCH`});return{data:await this.formatData(r,n),headers:r.headers,status:r.status}}async post(e,t,n){let r=await this.request(e,{data:t,...n,method:`POST`});return{data:await this.formatData(r,n),headers:r.headers,status:r.status}}async put(e,t,n){let r=await this.request(e,{data:t,...n,method:`PUT`});return{data:await this.formatData(r,n),headers:r.headers,status:r.status}}async request(e,t){let n=new URL(e,this.baseUrl);if(t.params)for(let[e,r]of Object.entries(t.params))r!=null&&n.searchParams.append(e,String(r));let r={method:t.method.toUpperCase(),url:n,...this.config};if(t.headers&&(r.headers={...r.headers,...t.headers}),this.config?.auth){let{password:e,username:t}=this.config.auth,n=btoa(`${t}:${e}`);r.headers={...r.headers,Authorization:`Basic ${n}`}}if(t.data&&(t.data instanceof Object&&(r.headers={...r.headers,"Content-Type":`application/json`},t.data=JSON.stringify(t.data)),r.body=t.data),this.interceptors.request.length>0)for(let e of this.interceptors.request)r={...r,...await e({...r,url:n})};n=r.url;let i=await fetch(n,r);if(!i.ok){let e;try{e=await i.text()}catch{e=i.statusText}throw Error(e?`Request failed with status code ${i.status}: ${e}`:`Request failed with status code ${i.status}`)}if(this.interceptors.response.length>0)for(let e of this.interceptors.response)await e(i);return i}setBaseURL(e){this.baseUrl=e}setConfig(e){this.config=e}formatData(e,t){switch(t?.responseType||`json`){case`arraybuffer`:return e.arrayBuffer();case`blob`:return e.blob();case`text`:return e.text();default:return e.json()}}}})),D=d((()=>{})),O=p({APIClient:()=>T}),k=d((()=>{E(),D()})),A=f((e=>{var t=e&&e.__awaiter||function(e,t,n,r){function i(e){return e instanceof n?e:new n(function(t){t(e)})}return new(n||=Promise)(function(n,a){function o(e){try{c(r.next(e))}catch(e){a(e)}}function s(e){try{c(r.throw(e))}catch(e){a(e)}}function c(e){e.done?n(e.value):i(e.value).then(o,s)}c((r=r.apply(e,t||[])).next())})};Object.defineProperty(e,`__esModule`,{value:!0}),e.Statuspage=void 0;let n=(k(),h(O)),r=b(),i=g();e.Statuspage=class{constructor(e){if(this.getComponents=()=>t(this,void 0,void 0,function*(){let e=i.Endpoint.components(),{data:t}=yield this.apiClient.get(e);return t}),this.getStatus=()=>t(this,void 0,void 0,function*(){let e=i.Endpoint.status(),{data:t}=yield this.apiClient.get(e);return t}),this.getSummary=()=>t(this,void 0,void 0,function*(){let e=i.Endpoint.summary(),{data:t}=yield this.apiClient.get(e);return t}),!e)throw Error(`A page ID needs to be set in order to use the client.`);this.apiClient=new n.APIClient(`https://${e}.statuspage.io`),this.api={getComponents:this.getComponents,getStatus:this.getStatus,getSummary:this.getSummary,incidents:new r.IncidentsAPI(this.apiClient),scheduledMaintenances:new r.ScheduledMaintenancesAPI(this.apiClient),subscribers:new r.SubscribersAPI(this.apiClient)}}setApiUrl(e){this.apiClient.setBaseURL(e)}}})),j=f((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(b(),e),n(w(),e),n(A(),e)}))();const M={none:0,minor:1,major:2,critical:2,unavailable:21},N=[`google-chrome-stable`,`google-chrome`,`chromium`,`brave`,`microsoft-edge-stable`,`microsoft-edge`];async function P(e=`https://status.claude.com`){try{let t=new j.Statuspage(`anthropic`);return t.setApiUrl(e),{kind:`ok`,summary:await t.api.getSummary()}}catch(e){return{kind:`unknown`,reason:e instanceof Error?e.message:String(e)}}}function F(e){return typeof e==`object`&&!!e&&`webSocketDebuggerUrl`in e&&typeof e.webSocketDebuggerUrl==`string`}function I(e){return typeof e==`object`&&!!e&&`id`in e&&typeof e.id==`number`}function L(e){let t=new Map,n=0;return e.onmessage=e=>{let n=typeof e.data==`string`?e.data:e.data instanceof ArrayBuffer?new TextDecoder().decode(e.data):null;if(n===null)return;let r;try{r=JSON.parse(n)}catch{return}if(!I(r))return;let i=t.get(r.id);i!==void 0&&(t.delete(r.id),i(r))},(r,i={})=>new Promise((a,o)=>{let s=++n,c=setTimeout(()=>{t.delete(s),o(Error(`CDP command '${r}' timed out`))},5e3);t.set(s,e=>{clearTimeout(c),a(e)}),e.send(JSON.stringify({id:s,method:r,params:i}))})}async function R(e,t){let n=await(await fetch(`${e}/json/new?${encodeURIComponent(t)}`,{method:`PUT`})).json();if(!F(n))return{ok:!1,error:`unexpected CDP target shape`};let r=new WebSocket(n.webSocketDebuggerUrl);return await new Promise((e,t)=>{r.onopen=()=>e(),r.onerror=()=>t(Error(`WebSocket connection failed`)),r.onclose=()=>t(Error(`WebSocket closed before opening`))}),{ok:!0,send:L(r),close:()=>r.close()}}function z(){for(let e of N){let n=t(`which`,[e]);if(n.status===0&&n.stdout)return n.stdout.toString().trim()}return null}async function B(e,t){let n=Date.now()+t;for(;Date.now()<n;){try{if((await fetch(`${e}/json/version`)).ok)return!0}catch{}await o(100)}return!1}async function V(t){let r;try{r=n(a(i(),`claude-down-`))}catch(e){return{ok:!1,error:`mkdtemp failed: ${e instanceof Error?e.message:String(e)}`}}let o=9222+Math.floor(Math.random()*1e3),s=e(t,[`--headless=new`,`--disable-gpu`,`--no-sandbox`,`--disable-blink-features=AutomationControlled`,`--window-size=1920,1080`,`--user-data-dir=${r}`,`--remote-debugging-port=${o}`,`--user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36`,`about:blank`],{stdio:`ignore`}),c=`http://localhost:${o}`;return await B(c,5e3)?{ok:!0,browser:{proc:s,userDataDir:r,base:c}}:(H(s,r),{ok:!1,error:`CDP endpoint never came up`})}function H(e,t){e.kill(),r(t,{recursive:!0,force:!0,maxRetries:5,retryDelay:100})}function U(e){return typeof e==`object`&&!!e&&`result`in e&&typeof e.result==`object`&&e.result!==null&&`result`in e.result&&typeof e.result.result==`object`&&e.result.result!==null&&`value`in e.result.result&&typeof e.result.result.value==`string`}function W(e){if(typeof e!=`object`||!e||!(`title`in e)||typeof e.title!=`string`||`h1`in e&&e.h1!==null&&typeof e.h1!=`string`||!(`pogo`in e))return!1;if(e.pogo===null)return!0;if(typeof e.pogo!=`object`)return!1;let t=e.pogo;return!(`outage`in t&&t.outage!==void 0&&typeof t.outage!=`boolean`)}async function G(e,t){await e(`Runtime.enable`);let n=Date.now()+t;for(;Date.now()<n;){let t=await e(`Runtime.evaluate`,{expression:`JSON.stringify({ title: document.title, pogo: window.PogoConfig ?? null, h1: document.querySelector("h1")?.innerText ?? null })`,returnByValue:!0});if(U(t)){let e;try{e=JSON.parse(t.result.result.value)}catch{e=null}if(W(e)&&e.pogo!==null&&e.title!==`Just a moment...`)return{pogo:e.pogo,heading:e.h1}}await o(700)}return null}async function K(){let e=z();if(e===null)return{ok:!1,error:`no chromium/chrome binary found`};let t=await V(e);if(!t.ok)return t;let{browser:{proc:n,userDataDir:r,base:i}}=t;try{let e=await R(i,`https://downdetector.com/status/claude-ai/`);if(!e.ok)return e;let t=await G(e.send,2e4);return e.close(),t===null?{ok:!1,error:`CF challenge not cleared in time`}:t.pogo.outage===!0?{ok:!0,down:!0,reason:t.heading??`outage reported`}:{ok:!0,down:!1}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}finally{H(n,r)}}export{M as EXIT_CODES,P as checkAnthropic,K as checkDownDetector};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { CdpSend } from "./cdp.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/lib/downdetector/snapshot.d.ts
|
|
4
|
+
declare function pollPogoSnapshot(send: CdpSend, timeoutMs: number): Promise<{
|
|
5
|
+
pogo: {
|
|
6
|
+
outage?: boolean;
|
|
7
|
+
};
|
|
8
|
+
heading: string | null;
|
|
9
|
+
} | null>;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { pollPogoSnapshot };
|
|
@@ -91,6 +91,7 @@ type Summary = Components & Incidents & ScheduledMaintenances & Status;
|
|
|
91
91
|
//#region src/lib/types.d.ts
|
|
92
92
|
/** Indicator represents the specific status code or condition that can be used to determine the state of a service. */
|
|
93
93
|
type Indicator = keyof typeof EXIT_CODES;
|
|
94
|
+
type AvailableIndicator = Exclude<Indicator, 'unavailable'>;
|
|
94
95
|
/** A signal represents the outcome of a status check, indicating whether the service is down and providing relevant information. */
|
|
95
96
|
type Signal = {
|
|
96
97
|
ok: true;
|
|
@@ -112,4 +113,4 @@ type Result = {
|
|
|
112
113
|
reason: string;
|
|
113
114
|
};
|
|
114
115
|
//#endregion
|
|
115
|
-
export { Summary as i,
|
|
116
|
+
export { Summary as a, Signal as i, Indicator as n, Result as r, AvailableIndicator as t };
|
package/dist/types.d.mts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { Indicator, Result, Signal, Summary };
|
|
1
|
+
import { a as Summary, i as Signal, n as Indicator, r as Result, t as AvailableIndicator } from "./types-4oEMjqAH.mjs";
|
|
2
|
+
export { AvailableIndicator, Indicator, Result, Signal, Summary };
|