claude-down 0.4.0 → 0.4.2
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/dist/bin/cli.mjs +5 -4
- package/package.json +1 -1
package/dist/bin/cli.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{
|
|
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 l}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,m=Object.getOwnPropertyNames,h=Object.prototype.hasOwnProperty,g=(e,t)=>()=>(e&&(t=e(e=0)),t),_=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),ee=(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},te=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=m(t),a=0,o=i.length,s;a<o;a++)s=i[a],!h.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=>h.call(e,`module.exports`)?e[`module.exports`]:te(f({},`__esModule`,{value:!0}),e),re=`claude-down`,v=`0.4.2`,y=`Is claude code down? Probably...`;const b=[`anthropic`,`downdetector`],x={anthropic:`Anthropic`,downdetector:`Downdetector`},S={none:0,minor:1,major:2,critical:2,unavailable:21},C=`https://status.claude.com`,w=`https://downdetector.com/status/claude-ai/`,ie=[`google-chrome-stable`,`google-chrome`,`chromium`,`brave`,`microsoft-edge-stable`,`microsoft-edge`],T=n.boolean().alias(`q`).describe(`Silent; exit code only`),E=n.string().default(C).env(`CLAUDE_DOWN_ANTHROPIC_STATUS_BASE`).describe(`Override Anthropic status page base URL`),ae=n.array(n.enum(b)).default([...b]).alias(`s`).describe(`Data source(s) to check`),D=`\x1B[31m`,O=`\x1B[32m`;function k(e,t,n){return n?`${t}${e}[0m`:e}function A(e,t,n){return n?`\x1b]8;;${t}\x1b\\${e}\x1b]8;;\x1b\\`:e}function j(e){if(e.indicator===`unavailable`)return`\x1B[2m`;if(e.source===`downdetector`)return e.reportsOutage?D:O;switch(e.indicator){case`none`:return O;case`minor`:return`\x1B[33m`;case`major`:case`critical`:return D}}function M(e){return e.source===`anthropic`?C:w}function N(e,t,n){if(n.length!==0){e.push(` ${t}:`);for(let t of n)e.push(` - ${t}`)}}function P(e,t){let n=j(e),r=[A(k(x[e.source],`[1m${n}`,t),M(e),t)];if(e.indicator===`unavailable`){let i=e.summaryText??`unknown error`;return r.push(` ${k(`Unavailable: ${i}`,n,t)}`),r.join(`
|
|
3
|
+
`)}if(e.source===`downdetector`){let i=e.summaryText??`No user-reported issues`;return r.push(` ${k(i,n,t)}`),r.join(`
|
|
4
|
+
`)}let i=e.summaryText??`All systems operational`;r.push(` ${k(i,n,t)}`);let a=e.incidents?.map(e=>`${e.name} (${e.status})`)??[];return N(r,a.length===1?`Active incident`:`Active incidents`,a),N(r,`Affected components`,e.affectedComponents?.map(e=>e.name)??[]),r.join(`
|
|
5
|
+
`)}function F(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 I(e){return e.map(e=>F(e))}function L(e,t){if(t.jsonMode||!t.isTTY){t.json(I(e));return}t.log(e.map(e=>P(e,t.isTTY)).join(`
|
|
5
6
|
|
|
6
|
-
`))}var A=h((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`}})),j=h((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=A();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})}}})),M=h((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=A();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})}}})),N=h((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=A();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})}}})),P=h((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(j(),e),n(M(),e),n(N(),e)})),F=h((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),I=h((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),L=h((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={}))})),R=h((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(F(),e),n(I(),e),n(L(),e)})),z,B=m((()=>{z=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()}}}})),V=m((()=>{})),H=re({APIClient:()=>z}),U=m((()=>{B(),V()})),W=h((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=(U(),_(H)),r=P(),i=A();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)}}})),G=h((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(P(),e),n(R(),e),n(W(),e)}))();async function K(e=x){try{let t=new G.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 q(e){return typeof e==`object`&&!!e&&`webSocketDebuggerUrl`in e&&typeof e.webSocketDebuggerUrl==`string`}function ae(e){return typeof e==`object`&&!!e&&`id`in e&&typeof e.id==`number`}function J(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(!ae(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 oe(e,t){let n=await(await fetch(`${e}/json/new?${encodeURIComponent(t)}`,{method:`PUT`})).json();if(!q(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:J(r),close:()=>r.close()}}function se(){for(let e of ie){let t=s(`which`,[e]);if(t.status===0&&t.stdout)return t.stdout.toString().trim()}return null}async function ce(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 le(e){let t;try{t=c(ne(te(),`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 ce(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(),ee(t,{recursive:!0,force:!0,maxRetries:5,retryDelay:100})}function ue(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 de(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 fe(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(ue(t)){let e;try{e=JSON.parse(t.result.result.value)}catch{e=null}if(de(e)&&e.pogo!==null&&e.title!==`Just a moment...`)return{pogo:e.pogo,heading:e.h1}}await l(700)}return null}async function pe(){let e=se();if(e===null)return{ok:!1,error:`no chromium/chrome binary found`};let t=await le(e);if(!t.ok)return t;let{browser:{proc:n,userDataDir:r,base:i}}=t;try{let e=await oe(i,`https://downdetector.com/status/claude-ai/`);if(!e.ok)return e;let t=await fe(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 me(e){return e===`none`||e===`minor`||e===`major`||e===`critical`?e:`critical`}async function X(t){let n=await K(t);if(n.kind===`unknown`)throw new e(`anthropic unavailable: ${n.reason}`,{code:`ANTHROPIC_UNAVAILABLE`,exitCode:b.unavailable,details:{anthropic:n.reason}});let r=me(n.summary.status.indicator),i=n.summary.components.filter(e=>e.status!==`operational`);return{source:`anthropic`,indicator:r,summaryText:n.summary.status.description,incidents:n.summary.incidents.length>0?n.summary.incidents.map(e=>({name:e.name,status:e.status})):null,affectedComponents:i.length>0?i.map(e=>({name:e.name,status:e.status})):null}}async function Z(){let t=await pe();if(!t.ok)throw new e(`downdetector unavailable: ${t.error}`,{code:`DOWNDETECTOR_UNAVAILABLE`,exitCode:b.unavailable,details:{downdetector:t.error}});return{source:`downdetector`,indicator:t.down?`major`:`none`,summaryText:t.down?t.reason:null,reportsOutage:t.down}}async function Q(e,t){switch(e){case`anthropic`:return X(t);case`downdetector`:return Z()}}async function he(e,t){return Promise.all(e.map(e=>Q(e,t)))}function ge(e){return b[e.indicator]}function _e(e){return e.reduce((e,t)=>Math.max(e,ge(t)),b.none)}function ve(e){return[...e].sort((e,t)=>e.source.localeCompare(t.source))}function $(e,t,n){if(t){let t=_e(e);t!==0&&i(t);return}k(ve(e),n)}const ye=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`,C).flag(`quiet`,S).flag(`source`,w).action(async({flags:e,out:t})=>{$(await he(e.source,e.anthropicStatusBase),e.quiet,t)}),be=n(`anthropic`).description(`Check only ${y.anthropic}`).example(`anthropic`,`Check only ${y.anthropic}`).flag(`anthropicStatusBase`,C).flag(`quiet`,S).action(async({flags:e,out:t})=>{$([await X(e.anthropicStatusBase)],e.quiet,t)}),xe=n(`downdetector`).description(`Check only ${y.downdetector}`).example(`downdetector`,`Check only ${y.downdetector}`).flag(`quiet`,S).action(async({flags:e,out:t})=>{$([await Z()],e.quiet,t)}),Se=t(`claude-down`).packageJson({inferName:!0}).command(ye).command(be).command(xe).completions();import.meta.main&&Se.run({help:{width:a.columns}});export{};
|
|
7
|
+
`))}var R=_((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`}})),z=_((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=R();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})}}})),B=_((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=R();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})}}})),V=_((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=R();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})}}})),H=_((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(B(),e),n(V(),e)})),U=_((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),W=_((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),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={}))})),K=_((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(U(),e),n(W(),e),n(G(),e)})),q,J=g((()=>{q=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()}}}})),oe=g((()=>{})),se=ee({APIClient:()=>q}),ce=g((()=>{J(),oe()})),le=_((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=(ce(),ne(se)),r=H(),i=R();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)}}})),ue=_((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(H(),e),n(K(),e),n(le(),e)}))();async function de(e=C){try{let t=new ue.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 fe(e){return typeof e==`object`&&!!e&&`webSocketDebuggerUrl`in e&&typeof e.webSocketDebuggerUrl==`string`}function pe(e){return typeof e==`object`&&!!e&&`id`in e&&typeof e.id==`number`}function me(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(!pe(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 he(e,t){let n=await(await fetch(`${e}/json/new?${encodeURIComponent(t)}`,{method:`PUT`})).json();if(!fe(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:me(r),close:()=>r.close()}}function ge(){for(let e of ie){let t=o(`which`,[e]);if(t.status===0&&t.stdout)return t.stdout.toString().trim()}return null}async function _e(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}async function ve(e){let t;try{t=s(u(l(),`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 _e(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 ye(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 be(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 xe(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(ye(t)){let e;try{e=JSON.parse(t.result.result.value)}catch{e=null}if(be(e)&&e.pogo!==null&&e.title!==`Just a moment...`)return{pogo:e.pogo,heading:e.h1}}await d(700)}return null}async function Se(){let e=ge();if(e===null)return{ok:!1,error:`no chromium/chrome binary found`};let t=await ve(e);if(!t.ok)return t;let{browser:{proc:n,userDataDir:r,base:i}}=t;try{let e=await he(i,w);if(!e.ok)return e;let t=await xe(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 Ce(e){return e===`none`||e===`minor`||e===`major`||e===`critical`?e:`critical`}async function X(e){let t=await de(e);if(t.kind===`unknown`)return{source:`anthropic`,indicator:`unavailable`,summaryText:t.reason,incidents:null,affectedComponents:null};let n=Ce(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 Se();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 we(e,t){switch(e){case`anthropic`:return X(t);case`downdetector`:return Z()}}async function Q(e,t){return Promise.all(e.map(e=>we(e,t)))}function Te(e){return S[e.indicator]}function Ee(e){return e.reduce((e,t)=>Math.max(e,Te(t)),S.none)}function De(e){return[...e].sort((e,t)=>e.source.localeCompare(t.source))}function $(e,t,n){if(t){let t=Ee(e);t!==0&&r(t);return}L(De(e),n)}const Oe=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`,E).flag(`quiet`,T).flag(`source`,ae).action(async({flags:e,out:t})=>{$(await Q(e.source,e.anthropicStatusBase),e.quiet,t)}),ke=t(`anthropic`).description(`Check only ${x.anthropic}`).example(`anthropic`,`Check only ${x.anthropic}`).flag(`anthropicStatusBase`,E).flag(`quiet`,T).action(async({flags:e,out:t})=>{$([await X(e.anthropicStatusBase)],e.quiet,t)}),Ae=t(`downdetector`).description(`Check only ${x.downdetector}`).example(`downdetector`,`Check only ${x.downdetector}`).flag(`quiet`,T).action(async({flags:e,out:t})=>{$([await Z()],e.quiet,t)}),je=e(re).version(v).description(y).command(Oe).command(ke).command(Ae).completions();import.meta.main&&je.run({help:{width:i.columns}});export{};
|