claude-down 0.4.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/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 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
|
-
`))}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 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{};
|