@x-otto/env 0.1.0-alpha.13 → 0.1.0-alpha.14
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/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{homedir as e,hostname as t}from"node:os";import{existsSync as n,readFileSync as r}from"node:fs";import{dirname as i,join as a,normalize as o,sep as s}from"node:path";import{spawnSync as c}from"node:child_process";function l(e){return o(e).replaceAll(s===`\\`?`\\`:s,`/`)}const u=
|
|
1
|
+
import{homedir as e,hostname as t}from"node:os";import{existsSync as n,readFileSync as r}from"node:fs";import{dirname as i,join as a,normalize as o,sep as s}from"node:path";import{spawnSync as c}from"node:child_process";function l(e){return o(e).replaceAll(s===`\\`?`\\`:s,`/`)}const u=5547;function d(e){let{cwd:t,homedir:n,workspaceRoot:r}=e,i=e.claudeCompat??U(),o=[];return o.push({kind:`otto`,scope:`project`,dir:l(a(t,`.otto`))}),r&&l(r)!==l(t)&&o.push({kind:`otto`,scope:`repository`,dir:l(a(r,`.otto`))}),i&&o.push({kind:`claude`,scope:`project`,dir:l(a(t,`.claude`))}),n&&o.push({kind:`otto`,scope:`user`,dir:l(a(n,`.otto`))}),i&&n&&o.push({kind:`claude`,scope:`user`,dir:l(a(n,`.claude`))}),o}function f(e){try{return process.kill(e,0),!0}catch{return!1}}function p(){return t()}function m(e,t,n){return`${e}:${t}:${n}`}function h(e){let t=e.indexOf(`:`);if(t===-1)return{token:e};let n=e.indexOf(`:`,t+1);if(n===-1)return{token:e};let r=e.slice(0,t),i=e.slice(t+1,n),a=e.slice(n+1),o=Number(i),s=Number.isFinite(o)&&o>0?o:void 0;return s!==void 0&&a.length>0?{token:r,pid:s,host:a}:{token:r}}function g(e){let t=e.trim().match(/^(?:(\d+)-)?(?:(\d+):)?(\d+):(\d+)$/);if(!t)return 0;let[,n,r,i,a]=t;return(Number(n??0)*86400+Number(r??0)*3600+Number(i)*60+Number(a))*1e3}function _(e){return e.match(/--continue\s+([0-9a-f-]{36})/)?.[1]}function v(e){let t=e.match(/--restart-generation=(\d+)/);return t?Number(t[1]):void 0}function y(e=`bin/otto.js`){let t=c(`ps`,[`-axo`,`pid=,ppid=,rss=,tty=,etime=,args=`],{encoding:`utf8`,timeout:1e4,maxBuffer:16*1024*1024});return t.status!==0||!t.stdout?[]:b(t.stdout,e)}function b(e,t=`bin/otto.js`){let n=[];for(let r of e.split(`
|
|
2
2
|
`)){if(!r.includes(t))continue;let e=r.match(/^\s*(\d+)\s+(\d+)\s+(\d+)\s+(\S+)\s+(\S+)\s+(.*)$/);if(!e)continue;let[,i,a,o,s,c,l]=e;l.includes(`spawn-helper`)||n.push({pid:Number(i),ppid:Number(a),rssKb:Number(o),tty:s,etimeMs:g(c),command:l,sessionId:_(l),generation:v(l)})}return n}function x(){if(process.platform===`darwin`)return!1;try{if(n(`/.dockerenv`))return!0;if(n(`/proc/1/cgroup`)){let e=r(`/proc/1/cgroup`,`utf8`);return/docker|kubepods|containerd/.test(e)}}catch{}return!1}const S={stream:{maxRetries:5,initialDelayMs:500,backoffFactor:2,maxDelayMs:6e4},networkDisconnect:{maxRetries:5,intervalMs:3e4},mcp:{maxReconnectAttempts:3,reconnectDelayMs:500,requestTimeoutMs:3e4},schedule:{retryBackoffMs:0},errorRetry:{maxAttempts:5,intervalMs:3e4},oauth:{refreshLockTimeoutMs:15e3}};function C(...e){let t={stream:{...S.stream},networkDisconnect:{...S.networkDisconnect},mcp:{...S.mcp},schedule:{...S.schedule},errorRetry:{...S.errorRetry},oauth:{...S.oauth}};for(let n of e)if(n)for(let e of Object.keys(t)){let r=n[e];r&&Object.assign(t[e],r)}return t}const w=[];function ee(e){let t=w.splice(0);for(let n of t)e(n)}function T(){return w.splice(0)}const E=(e,t)=>{if(e===void 0)return t;let n=parseInt(e,10);return isNaN(n)||n<=0?(w.push(`Invalid environment variable value: ${e}. Using default: ${t}`),t):n},D=(e,t)=>{if(e===void 0)return t;let n=parseFloat(e);return isNaN(n)||n<=0||n>1?(w.push(`Invalid fraction environment variable value: ${e}. Using default: ${t}`),t):n};function O(e){let t=e;for(;;){if(n(a(t,`pnpm-workspace.yaml`)))return t;let e=i(t);if(e===t)return;t=e}}function k(){try{let e=l(`${l(new URL(`.`,import.meta.url).pathname)}/../package.json`);return JSON.parse(r(e,`utf-8`)).version||`unknown`}catch{return`unknown`}}const A=k(),j=`otto/${A}`,M=`.otto`,N=process.env.OTTO_CONFIG_FILENAME||`config.json`,P=`${M}/${N}`,F=l(process.env.OTTO_HOME||`${e()}/.otto`),I=`${F}/sessions`,L=`${I}/locks`,R=`${F}/daemon`,z=l(e()+`/.config/otto`),B=l(`${process.cwd()}/${M}`),V=`.claude`,H=l(`${e()}/${V}`);function U(){let e=process.env.OTTO_CLAUDE_COMPAT?.toLowerCase();return!(e===`0`||e===`false`||e===`no`||e===`off`)}function W(){if(!U())return!1;let e=process.env.OTTO_CLAUDE_COMPAT_SETTINGS?.toLowerCase();return e===`1`||e===`true`||e===`yes`||e===`on`}function G(){if(!U())return!1;let e=process.env.OTTO_CLAUDE_COMPAT_HOOKS?.toLowerCase();return e===`1`||e===`true`||e===`yes`||e===`on`}const K=process.env.OTTO_LOG_FILE?l(process.env.OTTO_LOG_FILE):``,q=E(process.env.OTTO_SERVICE_PORT,8417),J=process.env.OTTO_SERVICE_URL??`http://127.0.0.1:${q}`,Y=()=>(process.env.OTTO_NPM_SNIFF_REGISTRIES??``).split(`,`).map(e=>e.trim().replace(/\/+$/,``)).filter(e=>e.length>0),X=()=>(process.env.OTTO_INTRANET_PROBE_URLS??``).split(`,`).map(e=>e.trim().replace(/\/+$/,``)).filter(e=>e.length>0),Z=process.env.OTTO_LOG_LEVEL||(process.env.NODE_ENV===`production`?`info`:`trace`),Q=process.env.OTTO_OFFLINE===`1`||process.env.OTTO_OFFLINE?.toLowerCase()===`true`||process.env.OTTO_OFFLINE?.toLowerCase()===`yes`;function te(){let e=process.env.OTTO_SHADOW?.toLowerCase();return e===`1`||e===`true`||e===`yes`||e===`on`}const ne=l(process.env.OTTO_AUTH_PATH||`${z}/auth.json`),$=l(process.env.OTTO_IDENTITY_PATH||`${F}/identity.json`);async function re(e){let t=e??$;try{let{readFile:e}=await import(`node:fs/promises`),n=await e(t,`utf-8`),r=JSON.parse(n);return typeof r.userId==`string`&&typeof r.token==`string`&&typeof r.serviceUrl==`string`&&typeof r.loginAt==`number`?r:null}catch{return null}}export{ne as AUTH_PATH,u as BUILD_ID,H as CLAUDE_HOME,V as CLAUDE_ROOT,S as DEFAULT_RESILIENCE_CONFIG,K as LOG_FILE,Z as LOG_LEVEL,N as OTTO_CONFIG_FILENAME,R as OTTO_DAEMON_DIR,F as OTTO_HOME,$ as OTTO_IDENTITY_PATH,P as OTTO_PROJECT_CONFIG_RELPATH,B as OTTO_PROJECT_DIR,M as OTTO_ROOT,I as OTTO_SESSIONS_DIR,L as OTTO_SESSION_LOCKS_DIR,j as OTTO_USER_AGENT,z as OTTO_USER_CONFIG_DIR,A as SDK_VERSION,q as SERVICE_PORT,J as SERVICE_URL,Q as SETTING_OFFLINE_MODE_ENABLED,p as currentHostname,h as decodeLeaseToken,T as drainEnvWarnings,m as encodeLeaseToken,O as findWorkspaceRoot,ee as flushEnvWarnings,U as isClaudeCompatEnabled,G as isClaudeHooksCompatEnabled,W as isClaudeSettingsCompatEnabled,x as isContainerEnvironment,f as isProcessAlive,te as isShadowModeEnabled,y as listOttoProcesses,re as loadUserIdentity,C as mergeResilienceConfig,E as normalizeEnv,D as normalizeEnvFraction,l as normalizePath,g as parseEtimeMs,b as parseOttoProcessTable,d as resolveConfigLayers,X as resolveIntranetProbeUrls,Y as resolveNpmSniffRegistries};
|