opik 2.2.100 → 2.2.102
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 {createHash,randomBytes}from'crypto';import L,{accessSync,constants}from'fs';import f from'os';import i from'path';import U from'ini';var b="https://stats.comet.com/notify/event/",T="opik_typescript_sdk__configuration__cli",S=3e3,l="default",p="npx",h="OPIK_CLI_LAUNCHER",E="OPIK_CLI_SESSION_ID",D=9,g="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";function V(){return Array.from(randomBytes(D),n=>g[n%g.length]).join("")}var v="2.2.
|
|
2
|
+
import {spawnSync}from'child_process';import {chalkStderr}from'chalk';import {createHash,randomBytes}from'crypto';import L,{accessSync,constants}from'fs';import f from'os';import i from'path';import U from'ini';var b="https://stats.comet.com/notify/event/",T="opik_typescript_sdk__configuration__cli",S=3e3,l="default",p="npx",h="OPIK_CLI_LAUNCHER",E="OPIK_CLI_SESSION_ID",D=9,g="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";function V(){return Array.from(randomBytes(D),n=>g[n%g.length]).join("")}var v="2.2.102";function K(n){return `${T}__${n}`}function M(n=process.env){let e=n.OPIK_ANALYTICS_ENABLE;return e===void 0?true:!["0","false","no"].includes(e.trim().toLowerCase())}var H=/^--[a-z][a-z0-9-]*$/,$=/^-[A-Za-z]$/,F=/^[a-z][a-z0-9-]*$/,j=3;function B(n){let e=[],t=[],o=false;for(let r of n){if(r==="--")break;if(r.startsWith("-")){o=true;let s=r.split("=")[0];(H.test(s)||$.test(s))&&t.push(s);continue}!o&&e.length<j&&F.test(r)&&e.push(r);}return {command:e.join(" "),flags:[...new Set(t)].join(",")}}function J(n=process.env,e=f.homedir()){var r;let t=((r=I(n.OPIK_WORKSPACE))!=null?r:z(n,e)).trim();if(t!==""&&t!==l)return t;let o=createHash("sha256").update(f.hostname()+W()).digest("hex");return `${l}_${o}`}function N(n,e=process.env){var m;let t=M(e),o=(m=e.OPIK_ANALYTICS_URL)!=null?m:b,r=t?J(e):"",{command:s,flags:c}=B(n),_=V(),u=[];return {sessionId:_,track(d,w={}){if(!t||o==="")return;let k={anonymous_id:r,event_type:K(d),event_properties:{session_id:_,launcher:p,sdk_version:v,command:s,flags:c,node_version:process.versions.node,os:process.platform,arch:process.arch,ci:!!e.CI,...w}};u.push(G(o,k));},async flush(){u.length!==0&&await Promise.race([Promise.allSettled(u),new Promise(d=>setTimeout(d,S).unref())]);}}}async function G(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(S)});}catch{}}function z(n,e){var r;let t=I(n.OPIK_CONFIG_PATH),o=t===void 0?i.join(e,".opik.config"):t.trim().replace(/^~(?=$|\/|\\)/,e);try{let s=U.parse(L.readFileSync(o,"utf8")),c=(r=s==null?void 0:s.opik)==null?void 0:r.workspace;return typeof c=="string"?c:""}catch{return ""}}function I(n){return n===void 0||n.trim()===""?void 0:n}function W(){try{return f.userInfo().username}catch{return ""}}var Q=1e4;function A(n=process.platform){return n==="win32"?"uv.exe":"uv"}function nn(n=process.env,e=process.platform,t=f.homedir()){let o=[y(n.XDG_BIN_HOME),y(n.CARGO_HOME,"bin"),i.join(t,".local","bin"),i.join(t,".cargo","bin")].filter(s=>s!==void 0),r=A(e);return [...new Set(o)].map(s=>i.join(s,r))}function y(n,...e){let t=(n!=null?n:"").trim();if(!(t===""||!i.isAbsolute(t)))return i.join(t,...e)}function P(){let n=A();if(O(n))return {path:n,source:"path"};for(let e of nn())if(en(e)&&O(e))return {path:e,source:"install-dir"}}function en(n){try{return accessSync(n,constants.X_OK),!0}catch{return false}}function O(n){let e=spawnSync(n,["--version"],{stdio:"ignore",timeout:Q});return e.error===void 0&&e.status===0}var rn="https://www.comet.com/docs/opik/mcp-server#install-uv-if-you-dont-have-it";async function on(){var r;let n=process.argv.slice(2),e=N(n);e.track("invoked");let t=P();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(rn)}
|