opik 2.2.111 → 2.2.113
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/cli.js +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {spawnSync}from'child_process';import {chalkStderr}from'chalk';import {randomBytes,createHash}from'crypto';import U,{accessSync,constants}from'fs';import _ from'os';import i from'path';import b from'ini';function l(){return createHash("sha256").update(_.hostname()+L()).digest("hex")}function L(n=process.env){for(let e of ["LOGNAME","USER","LNAME","USERNAME"])if(n[e])return n[e];try{return _.userInfo().username}catch{return "unknown"}}var M="https://stats.comet.com/notify/event/",V="opik_typescript_sdk__configuration__cli",E=3e3,g="default",f="npx",h="OPIK_CLI_LAUNCHER",N="OPIK_CLI_SESSION_ID",K=9,S="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";function H(){return Array.from(randomBytes(K),n=>S[n%S.length]).join("")}var v="2.2.
|
|
2
|
+
import {spawnSync}from'child_process';import {chalkStderr}from'chalk';import {randomBytes,createHash}from'crypto';import U,{accessSync,constants}from'fs';import _ from'os';import i from'path';import b from'ini';function l(){return createHash("sha256").update(_.hostname()+L()).digest("hex")}function L(n=process.env){for(let e of ["LOGNAME","USER","LNAME","USERNAME"])if(n[e])return n[e];try{return _.userInfo().username}catch{return "unknown"}}var M="https://stats.comet.com/notify/event/",V="opik_typescript_sdk__configuration__cli",E=3e3,g="default",f="npx",h="OPIK_CLI_LAUNCHER",N="OPIK_CLI_SESSION_ID",K=9,S="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";function H(){return Array.from(randomBytes(K),n=>S[n%S.length]).join("")}var v="2.2.113";function $(n){return `${V}__${n}`}function F(n=process.env){let e=n.OPIK_ANALYTICS_ENABLE;return e===void 0?true:!["0","false","no"].includes(e.trim().toLowerCase())}var j=/^--[a-z][a-z0-9-]*$/,B=/^-[A-Za-z]$/,J=/^[a-z][a-z0-9-]*$/,G=3;function z(n){let e=[],t=[],r=false;for(let o of n){if(o==="--")break;if(o.startsWith("-")){r=true;let s=o.split("=")[0];(j.test(s)||B.test(s))&&t.push(s);continue}!r&&e.length<G&&J.test(o)&&e.push(o);}return {command:e.join(" "),flags:[...new Set(t)].join(",")}}function X(n=process.env,e=_.homedir()){var r;let t=((r=A(n.OPIK_WORKSPACE))!=null?r:Y(n,e)).trim();return t!==""&&t!==g?t:`${g}_${l()}`}function I(n,e=process.env){var m;let t=F(e),r=(m=e.OPIK_ANALYTICS_URL)!=null?m:M,o=t?X(e):"",{command:s,flags:c}=z(n),p=H(),u=[];return {sessionId:p,track(d,R={}){if(!t||r==="")return;let k={anonymous_id:o,event_type:$(d),event_properties:{session_id:p,launcher:f,sdk_version:v,command:s,flags:c,node_version:process.versions.node,os:process.platform,arch:process.arch,ci:!!e.CI,...R}};u.push(W(r,k));},async flush(){u.length!==0&&await Promise.race([Promise.allSettled(u),new Promise(d=>setTimeout(d,E).unref())]);}}}async function W(n,e){try{await fetch(n,{method:"POST",headers:{"Content-Type":"application/json","User-Agent":`opik-typescript-sdk/${v}`},body:JSON.stringify(e),signal:AbortSignal.timeout(E)});}catch{}}function Y(n,e){var o;let t=A(n.OPIK_CONFIG_PATH),r=t===void 0?i.join(e,".opik.config"):t.trim().replace(/^~(?=$|\/|\\)/,e);try{let s=b.parse(U.readFileSync(r,"utf8")),c=(o=s==null?void 0:s.opik)==null?void 0:o.workspace;return typeof c=="string"?c:""}catch{return ""}}function A(n){return n===void 0||n.trim()===""?void 0:n}var en=1e4;function P(n=process.platform){return n==="win32"?"uv.exe":"uv"}function tn(n=process.env,e=process.platform,t=_.homedir()){let r=[O(n.XDG_BIN_HOME),O(n.CARGO_HOME,"bin"),i.join(t,".local","bin"),i.join(t,".cargo","bin")].filter(s=>s!==void 0),o=P(e);return [...new Set(r)].map(s=>i.join(s,o))}function O(n,...e){let t=(n!=null?n:"").trim();if(!(t===""||!i.isAbsolute(t)))return i.join(t,...e)}function w(){let n=P();if(y(n))return {path:n,source:"path"};for(let e of tn())if(rn(e)&&y(e))return {path:e,source:"install-dir"}}function rn(n){try{return accessSync(n,constants.X_OK),!0}catch{return false}}function y(n){let e=spawnSync(n,["--version"],{stdio:"ignore",timeout:en});return e.error===void 0&&e.status===0}var sn="https://www.comet.com/docs/opik/mcp-server#install-uv-if-you-dont-have-it";async function cn(){var o;let n=process.argv.slice(2),e=I(n);e.track("invoked");let t=w();if(e.track("uv_detected",{uv_found:t!==void 0,uv_source:t==null?void 0:t.source}),t===void 0)return process.stderr.write(`
|
|
3
3
|
${chalkStderr.red("\u2717")} ${chalkStderr.bold("The Opik MCP configuration requires uv, which is not installed on this machine.")}
|
|
4
4
|
|
|
5
5
|
How to install uv: ${chalkStderr.cyan.underline(sn)}
|