UNPKG

grix-connector

Version:

Connect local AI coding agents (Claude, Codex, Gemini, Qwen, DeepSeek, Cursor, OpenCode, Pi, OpenHuman, Reasonix) to the Grix scheduling platform. Also serves as an OpenClaw plugin for Grix channel transport.

2 lines (1 loc) 2.8 kB
import{log as i}from"../log/logger.js";import{resolveClientVersion as c}from"../util/client-version.js";let r=null,a=!1;const p="https://e8e202d7625372b1314b3ff4e85a7ff9@o119262.ingest.us.sentry.io/4511410543329280";function f(){if(!process.env.GRIX_SENTRY_DISABLE)return process.env.SENTRY_DSN||process.env.GRIX_SENTRY_DSN||p}async function g(){const e=f();if(!e){i.info("sentry","Sentry \u9519\u8BEF\u4E0A\u62A5\u5DF2\u7981\u7528\uFF08GRIX_SENTRY_DISABLE\uFF09");return}try{r=await import("@sentry/node")}catch(n){i.warn("sentry",`Sentry \u6A21\u5757\u52A0\u8F7D\u5931\u8D25\uFF08\u5E73\u53F0\u4E0D\u517C\u5BB9\uFF09\uFF0C\u9519\u8BEF\u4E0A\u62A5\u5DF2\u7981\u7528: ${n instanceof Error?n.message:String(n)}`);return}try{r.init({dsn:e,release:`grix-connector@${c()}`,environment:process.env.SENTRY_ENVIRONMENT||process.env.NODE_ENV||"production",sendDefaultPii:!1,initialScope:{tags:{component:"grix-connector"}},defaultIntegrations:!1,tracesSampleRate:0}),a=!0,i.info("sentry","Sentry \u9519\u8BEF\u4E0A\u62A5\u5DF2\u542F\u7528")}catch(n){i.error("sentry",`Sentry \u521D\u59CB\u5316\u5931\u8D25: ${n instanceof Error?n.message:String(n)}`)}}function T(){return a}const E=new Set(["INSTALL_FAILED","INSTALL_TIMEOUT","FALLBACK_EXHAUSTED","PREREQ_INSTALL_FAILED","VERIFICATION_FAILED","ENVIRONMENT_UNSUPPORTED","INTERNAL"]);function S(e){if(e.ok)return!1;const n=e.error?.code;return!!n&&E.has(n)}function I(e){if(!a||!r||!S(e))return;const n=e.error?.code??"INTERNAL",o=e.error?.message??"unknown install failure",t=e.environment;try{r.withScope(s=>{s.setLevel("error"),s.setTags({agent_type:e.agentType,error_code:n,phase:e.phase}),s.setContext("install",{agentType:e.agentType,code:n,phase:e.phase,durationMs:e.durationMs,os:t?.platform,osVersion:t?.osVersion,arch:t?.arch,nodeVersion:t?.nodeVersion,npmVersion:t?.npmVersion,isDocker:t?.isDocker,isCI:t?.isCI,outputTail:(e.output??"").slice(-2e3)}),s.setFingerprint(["agent-install-failure",e.agentType,n]),r.captureException(new Error(`Agent install failed [${e.agentType}/${n}]: ${o}`))}),i.info("sentry",`\u5DF2\u4E0A\u62A5\u5B89\u88C5\u5931\u8D25: ${e.agentType}/${n}`)}catch(s){i.error("sentry",`\u4E0A\u62A5\u5B89\u88C5\u5931\u8D25\u65F6\u51FA\u9519: ${s instanceof Error?s.message:String(s)}`)}}function N(e,n){if(!(!a||!r))try{r.withScope(o=>{o.setLevel("fatal"),o.setTag("crash_type",n);const t=e instanceof Error?e:new Error(String(e));r.captureException(t)}),i.info("sentry",`\u5DF2\u4E0A\u62A5\u5D29\u6E83: ${n}`)}catch(o){i.error("sentry",`\u4E0A\u62A5\u5D29\u6E83\u65F6\u51FA\u9519: ${o instanceof Error?o.message:String(o)}`)}}async function u(e=2e3){if(!(!a||!r))try{await r.close(e)}catch{}}export{u as closeSentry,g as initSentry,T as isSentryEnabled,N as reportFatal,I as reportInstallFailure,S as shouldReportInstallFailure};