@venos-inc/venos 0.1.9 → 0.1.11
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/README.md +10 -9
- package/dist/index.js +75 -79
- package/etc/mcp-server/bin.js +2 -2
- package/etc/mcp-server/client.js +23 -0
- package/etc/mcp-server/node_modules/@babel/core/node_modules/.bin/json5 +2 -2
- package/etc/mcp-server/node_modules/@babel/core/node_modules/.bin/parser +2 -2
- package/etc/mcp-server/node_modules/@babel/core/node_modules/.bin/semver +2 -2
- package/etc/mcp-server/node_modules/@babel/generator/node_modules/.bin/jsesc +2 -2
- package/etc/mcp-server/node_modules/@babel/generator/node_modules/.bin/parser +2 -2
- package/etc/mcp-server/node_modules/@babel/helper-compilation-targets/node_modules/.bin/browserslist +2 -2
- package/etc/mcp-server/node_modules/@babel/helper-compilation-targets/node_modules/.bin/semver +2 -2
- package/etc/mcp-server/node_modules/@babel/template/node_modules/.bin/parser +2 -2
- package/etc/mcp-server/node_modules/@babel/traverse/node_modules/.bin/parser +2 -2
- package/etc/mcp-server/node_modules/@eslint/core/README.md +3 -3
- package/etc/mcp-server/node_modules/@eslint/core/dist/cjs/types.d.cts +47 -9
- package/etc/mcp-server/node_modules/@eslint/core/dist/esm/types.d.ts +47 -9
- package/etc/mcp-server/node_modules/@eslint/core/package.json +5 -5
- package/etc/mcp-server/node_modules/@eslint/eslintrc/node_modules/.bin/js-yaml +2 -2
- package/etc/mcp-server/node_modules/@eslint/plugin-kit/README.md +9 -11
- package/etc/mcp-server/node_modules/@eslint/plugin-kit/dist/cjs/index.cjs +21 -12
- package/etc/mcp-server/node_modules/@eslint/plugin-kit/dist/cjs/index.d.cts +31 -19
- package/etc/mcp-server/node_modules/@eslint/plugin-kit/dist/esm/index.d.ts +31 -19
- package/etc/mcp-server/node_modules/@eslint/plugin-kit/dist/esm/index.js +21 -12
- package/etc/mcp-server/node_modules/@eslint/plugin-kit/package.json +6 -9
- package/etc/mcp-server/node_modules/@eslint-community/eslint-utils/node_modules/.bin/eslint +2 -2
- package/etc/mcp-server/node_modules/@types/babel__core/node_modules/.bin/parser +2 -2
- package/etc/mcp-server/node_modules/@types/babel__template/node_modules/.bin/parser +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/eslint-plugin/node_modules/.bin/eslint +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/eslint-plugin/node_modules/.bin/tsc +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/eslint-plugin/node_modules/.bin/tsserver +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/parser/node_modules/.bin/eslint +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/parser/node_modules/.bin/tsc +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/parser/node_modules/.bin/tsserver +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/project-service/node_modules/.bin/tsc +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/project-service/node_modules/.bin/tsserver +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/tsconfig-utils/node_modules/.bin/tsc +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/tsconfig-utils/node_modules/.bin/tsserver +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/type-utils/node_modules/.bin/eslint +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/type-utils/node_modules/.bin/tsc +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/type-utils/node_modules/.bin/tsserver +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/typescript-estree/node_modules/.bin/semver +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/typescript-estree/node_modules/.bin/tsc +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/typescript-estree/node_modules/.bin/tsserver +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/utils/node_modules/.bin/eslint +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/utils/node_modules/.bin/tsc +2 -2
- package/etc/mcp-server/node_modules/@typescript-eslint/utils/node_modules/.bin/tsserver +2 -2
- package/etc/mcp-server/node_modules/@vitest/mocker/node_modules/.bin/vite +2 -2
- package/etc/mcp-server/node_modules/acorn-jsx/node_modules/.bin/acorn +2 -2
- package/etc/mcp-server/node_modules/browserslist/node_modules/.bin/baseline-browser-mapping +2 -2
- package/etc/mcp-server/node_modules/browserslist/node_modules/.bin/update-browserslist-db +2 -2
- package/etc/mcp-server/node_modules/cross-spawn/node_modules/.bin/node-which +2 -2
- package/etc/mcp-server/node_modules/espree/node_modules/.bin/acorn +2 -2
- package/etc/mcp-server/node_modules/postcss/node_modules/.bin/nanoid +2 -2
- package/etc/mcp-server/node_modules/sharp/node_modules/.bin/semver +2 -2
- package/etc/mcp-server/node_modules/ts-api-utils/node_modules/.bin/tsc +2 -2
- package/etc/mcp-server/node_modules/ts-api-utils/node_modules/.bin/tsserver +2 -2
- package/etc/mcp-server/node_modules/typescript-eslint/node_modules/.bin/eslint +2 -2
- package/etc/mcp-server/node_modules/typescript-eslint/node_modules/.bin/tsc +2 -2
- package/etc/mcp-server/node_modules/typescript-eslint/node_modules/.bin/tsserver +2 -2
- package/etc/mcp-server/node_modules/update-browserslist-db/node_modules/.bin/browserslist +2 -2
- package/etc/mcp-server/node_modules/vite/node_modules/.bin/esbuild +2 -2
- package/etc/mcp-server/node_modules/vite/node_modules/.bin/rollup +2 -2
- package/etc/mcp-server/node_modules/vite-node/node_modules/.bin/vite +2 -2
- package/etc/mcp-server/node_modules/vitest/node_modules/.bin/vite +2 -2
- package/etc/mcp-server/node_modules/vitest/node_modules/.bin/vite-node +2 -2
- package/etc/mcp-server/node_modules/vitest/node_modules/.bin/why-is-node-running +2 -2
- package/etc/mcp-server/tools.js +172 -138
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,51 +1,51 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{readFileSync as
|
|
3
|
-
`}var
|
|
4
|
-
`,i===t&&(o+=" ".repeat(s+
|
|
5
|
-
`))}return o}var
|
|
2
|
+
import{readFileSync as Ji}from"node:fs";import{homedir as j}from"node:os";import{existsSync as un,mkdirSync as Oo,readFileSync as Io,rmSync as Eo,writeFileSync as Ro}from"node:fs";import{dirname as To,join as Ao}from"node:path";import{randomBytes as _o}from"node:crypto";import{existsSync as ar,readFileSync as cr}from"node:fs";import{join as lr}from"node:path";import{copyFileSync as nr,existsSync as Ge,mkdirSync as rr,renameSync as or,writeFileSync as sr}from"node:fs";import{dirname as ir}from"node:path";var Ye=".venos-backup";function m(e,t){rr(ir(e),{recursive:!0}),Ge(e)&&!Ge(e+Ye)&&nr(e,e+Ye);let n=e+".tmp";sr(n,t,{mode:420}),or(n,e)}function g(e){return JSON.stringify(e,null,2)+`
|
|
3
|
+
`}var W="http://127.0.0.1:4000/v1";var ze="venos",ur="venos usage-sync --throttle";function z(e){return(e??[]).some(t=>t.hooks.some(n=>typeof n.command=="string"&&n.command.includes(ze)))}function me(e,t){let n=e??[];return z(n)?n:[...n,{matcher:"*",hooks:[{type:"command",command:t}]}]}function ge(e){return(e??[]).map(t=>({...t,hooks:t.hooks.filter(n=>typeof n.command!="string"||!n.command.includes(ze))})).filter(t=>t.hooks.length>0)}var he={name:"claude-code",transport:"claude-hook",configPath(e){return lr(e,".claude","settings.json")},isInstalled(e){return!0},load(e){if(!ar(e))return{};try{return JSON.parse(cr(e,"utf8"))}catch{return{}}},isWired(e){return z(e.hooks?.PreToolUse)&&z(e.hooks?.PostToolUse)&&z(e.hooks?.Stop)},inject(e,t){let n=e.hooks??{};return{...e,hooks:{...n,PreToolUse:me(n.PreToolUse,t.hookCommand),PostToolUse:me(n.PostToolUse,t.hookCommand),Stop:me(n.Stop,t.usageSyncCommand??ur)}}},remove(e){return e.hooks?{...e,hooks:{...e.hooks,PreToolUse:ge(e.hooks.PreToolUse),PostToolUse:ge(e.hooks.PostToolUse),Stop:ge(e.hooks.Stop)}}:e},write(e,t){m(e,g(t))}};import{existsSync as F,readFileSync as dr}from"node:fs";import{join as X}from"node:path";function Xe(e){let t=e.mcpServers?.venos;if(!t||t.command!=="node")return!1;let n=t.args?.[0];return!n||n.includes("/A2A/")?!1:F(n)}var ye={name:"cursor",transport:"mcp-json",configPath(e){return X(e,".cursor","mcp.json")},isInstalled(e){let t=X(e,".cursor");return F(t)?F(X(t,"mcp.json"))||F(X(t,"extensions")):!1},load(e){if(!F(e))return{};try{return JSON.parse(dr(e,"utf8"))}catch{return{}}},isWired(e){return Xe(e)},inject(e,t){return Xe(e)?e:{...e,mcpServers:{...e.mcpServers??{},venos:{command:"node",args:[t.mcpServerPath],env:{VENOS_URL:t.orchestratorUrl,VENOS_ORG_ID:t.orgId,...t.apiKey?{VENOS_API_KEY:t.apiKey}:{}}}}}},remove(e){if(!e.mcpServers?.venos)return e;let{venos:t,...n}=e.mcpServers;return{...e,mcpServers:n}},write(e,t){m(e,g(t))}};import{existsSync as xe,readFileSync as Or}from"node:fs";import{join as ot}from"node:path";function pr(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function fr(e,t,n){let r=e.split(/\r\n|\n|\r/g),o="",s=(Math.log10(t+1)|0)+1;for(let i=t-1;i<=t+1;i++){let a=r[i-1];a&&(o+=i.toString().padEnd(s," "),o+=": ",o+=a,o+=`
|
|
4
|
+
`,i===t&&(o+=" ".repeat(s+n+2),o+=`^
|
|
5
|
+
`))}return o}var p=class extends Error{line;column;codeblock;constructor(t,n){let[r,o]=pr(n.toml,n.ptr),s=fr(n.toml,r,o);super(`Invalid TOML document: ${t}
|
|
6
6
|
|
|
7
|
-
${s}`,
|
|
8
|
-
`,t);return e[
|
|
9
|
-
`)return
|
|
10
|
-
`)return
|
|
7
|
+
${s}`,n),this.line=r,this.column=o,this.codeblock=s}};function mr(e,t){let n=0;for(;e[t-++n]==="\\";);return--n&&n%2}function Z(e,t=0,n=e.length){let r=e.indexOf(`
|
|
8
|
+
`,t);return e[r-1]==="\r"&&r--,r<=n?r:-1}function R(e,t){for(let n=t;n<e.length;n++){let r=e[n];if(r===`
|
|
9
|
+
`)return n;if(r==="\r"&&e[n+1]===`
|
|
10
|
+
`)return n+1;if(r<" "&&r!==" "||r==="\x7F")throw new p("control characters are not allowed in comments",{toml:e,ptr:t})}return e.length}function S(e,t,n,r){let o;for(;;){for(;(o=e[t])===" "||o===" "||!n&&(o===`
|
|
11
11
|
`||o==="\r"&&e[t+1]===`
|
|
12
|
-
`);)t++;if(
|
|
12
|
+
`);)t++;if(r||o!=="#")break;t=R(e,t)}return t}function Ze(e,t,n,r,o=!1){if(!r)return t=Z(e,t),t<0?e.length:t;for(let s=t;s<e.length;s++){let i=e[s];if(i==="#")s=Z(e,s);else{if(i===n)return s+1;if(i===r||o&&(i===`
|
|
13
13
|
`||i==="\r"&&e[s+1]===`
|
|
14
|
-
`))return s}}throw new
|
|
15
|
-
`,f:"\f",r:"\r",e:"\x1B",'"':'"',"\\":"\\"};function
|
|
16
|
-
`&&t++);let s=0,i,a="",l=t;for(;t<
|
|
14
|
+
`))return s}}throw new p("cannot find end of structure",{toml:e,ptr:t})}function q(e,t){let n=e[t],r=n===e[t+1]&&e[t+1]===e[t+2]?e.slice(t,t+3):n;t+=r.length-1;do t=e.indexOf(r,++t);while(t>-1&&n!=="'"&&mr(e,t));return t>-1&&(t+=r.length,r.length>1&&(e[t]===n&&t++,e[t]===n&&t++)),t}var gr=/^(\d{4}-\d{2}-\d{2})?[T ]?(?:(\d{2}):\d{2}(?::\d{2}(?:\.\d+)?)?)?(Z|[-+]\d{2}:\d{2})?$/i,L=class e extends Date{#t=!1;#n=!1;#e=null;constructor(t){let n=!0,r=!0,o="Z";if(typeof t=="string"){let s=t.match(gr);s?(s[1]||(n=!1,t=`0000-01-01T${t}`),r=!!s[2],r&&t[10]===" "&&(t=t.replace(" ","T")),s[2]&&+s[2]>23?t="":(o=s[3]||null,t=t.toUpperCase(),!o&&r&&(t+="Z"))):t=""}super(t),isNaN(this.getTime())||(this.#t=n,this.#n=r,this.#e=o)}isDateTime(){return this.#t&&this.#n}isLocal(){return!this.#t||!this.#n||!this.#e}isDate(){return this.#t&&!this.#n}isTime(){return this.#n&&!this.#t}isValid(){return this.#t||this.#n}toISOString(){let t=super.toISOString();if(this.isDate())return t.slice(0,10);if(this.isTime())return t.slice(11,23);if(this.#e===null)return t.slice(0,-1);if(this.#e==="Z")return t;let n=+this.#e.slice(1,3)*60+ +this.#e.slice(4,6);return n=this.#e[0]==="-"?n:-n,new Date(this.getTime()-n*6e4).toISOString().slice(0,-1)+this.#e}static wrapAsOffsetDateTime(t,n="Z"){let r=new e(t);return r.#e=n,r}static wrapAsLocalDateTime(t){let n=new e(t);return n.#e=null,n}static wrapAsLocalDate(t){let n=new e(t);return n.#n=!1,n.#e=null,n}static wrapAsLocalTime(t){let n=new e(t);return n.#t=!1,n.#e=null,n}};var hr=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,yr=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,vr=/^[+-]?0[0-9_]/,Sr=/^[0-9a-f]{2,8}$/i,qe={b:"\b",t:" ",n:`
|
|
15
|
+
`,f:"\f",r:"\r",e:"\x1B",'"':'"',"\\":"\\"};function Q(e,t=0,n=e.length){let r=e[t]==="'",o=e[t++]===e[t]&&e[t]===e[t+1];o&&(n-=2,e[t+=2]==="\r"&&t++,e[t]===`
|
|
16
|
+
`&&t++);let s=0,i,a="",l=t;for(;t<n-1;){let c=e[t++];if(c===`
|
|
17
17
|
`||c==="\r"&&e[t]===`
|
|
18
|
-
`){if(!o)throw new
|
|
19
|
-
`||c===" "||c===" "||c==="\r")){if(t=
|
|
20
|
-
`&&e[t]!=="\r")throw new
|
|
21
|
-
`&&e[i]!=="\r")throw new
|
|
22
|
-
`&&i!=="\r"){let a,l=o,c=!1,[u,
|
|
23
|
-
`&&s!=="\r"){let i=
|
|
24
|
-
`&&e[a]!=="\r")throw new
|
|
18
|
+
`){if(!o)throw new p("newlines are not allowed in strings",{toml:e,ptr:t-1})}else if(c<" "&&c!==" "||c==="\x7F")throw new p("control characters are not allowed in strings",{toml:e,ptr:t-1});if(i){if(i=!1,c==="x"||c==="u"||c==="U"){let u=e.slice(t,t+=c==="x"?2:c==="u"?4:8);if(!Sr.test(u))throw new p("invalid unicode escape",{toml:e,ptr:s});try{a+=String.fromCodePoint(parseInt(u,16))}catch{throw new p("invalid unicode escape",{toml:e,ptr:s})}}else if(o&&(c===`
|
|
19
|
+
`||c===" "||c===" "||c==="\r")){if(t=S(e,t-1,!0),e[t]!==`
|
|
20
|
+
`&&e[t]!=="\r")throw new p("invalid escape: only line-ending whitespace may be escaped",{toml:e,ptr:s});t=S(e,t)}else if(c in qe)a+=qe[c];else throw new p("unrecognized escape sequence",{toml:e,ptr:s});l=t}else!r&&c==="\\"&&(s=t-1,i=!0,a+=e.slice(l,s))}return a+e.slice(l,n-1)}function Qe(e,t,n,r){if(e==="true")return!0;if(e==="false")return!1;if(e==="-inf")return-1/0;if(e==="inf"||e==="+inf")return 1/0;if(e==="nan"||e==="+nan"||e==="-nan")return NaN;if(e==="-0")return r?0n:0;let o=hr.test(e);if(o||yr.test(e)){if(vr.test(e))throw new p("leading zeroes are not allowed",{toml:t,ptr:n});e=e.replace(/_/g,"");let i=+e;if(isNaN(i))throw new p("invalid number",{toml:t,ptr:n});if(o){if((o=!Number.isSafeInteger(i))&&!r)throw new p("integer value cannot be represented losslessly",{toml:t,ptr:n});(o||r===!0)&&(i=BigInt(e))}return i}let s=new L(e);if(!s.isValid())throw new p("invalid value",{toml:t,ptr:n});return s}function wr(e,t,n){let r=e.slice(t,n),o=r.indexOf("#");return o>-1&&(R(e,o),r=r.slice(0,o)),[r.trimEnd(),o]}function D(e,t,n,r,o){if(r===0)throw new p("document contains excessively nested structures. aborting.",{toml:e,ptr:t});let s=e[t];if(s==="["||s==="{"){let[l,c]=s==="["?tt(e,t,r,o):et(e,t,r,o);if(n){if(c=S(e,c),e[c]===",")c++;else if(e[c]!==n)throw new p("expected comma or end of structure",{toml:e,ptr:c})}return[l,c]}let i;if(s==='"'||s==="'"){i=q(e,t);let l=Q(e,t,i);if(n){if(i=S(e,i),e[i]&&e[i]!==","&&e[i]!==n&&e[i]!==`
|
|
21
|
+
`&&e[i]!=="\r")throw new p("unexpected character encountered",{toml:e,ptr:i});i+=+(e[i]===",")}return[l,i]}i=Ze(e,t,",",n);let a=wr(e,t,i-+(e[i-1]===","));if(!a[0])throw new p("incomplete key-value declaration: no value specified",{toml:e,ptr:t});return n&&a[1]>-1&&(i=S(e,t+a[1]),i+=+(e[i]===",")),[Qe(a[0],e,t,o),i]}var kr=/^[a-zA-Z0-9-_]+[ \t]*$/;function ee(e,t,n="="){let r=t-1,o=[],s=e.indexOf(n,t);if(s<0)throw new p("incomplete key-value: cannot find end of key",{toml:e,ptr:t});do{let i=e[t=++r];if(i!==" "&&i!==" ")if(i==='"'||i==="'"){if(i===e[t+1]&&i===e[t+2])throw new p("multiline strings are not allowed in keys",{toml:e,ptr:t});let a=q(e,t);if(a<0)throw new p("unfinished string encountered",{toml:e,ptr:t});r=e.indexOf(".",a);let l=e.slice(a,r<0||r>s?s:r),c=Z(l);if(c>-1)throw new p("newlines are not allowed in keys",{toml:e,ptr:t+r+c});if(l.trimStart())throw new p("found extra tokens after the string part",{toml:e,ptr:a});if(s<a&&(s=e.indexOf(n,a),s<0))throw new p("incomplete key-value: cannot find end of key",{toml:e,ptr:t});o.push(Q(e,t,a))}else{r=e.indexOf(".",t);let a=e.slice(t,r<0||r>s?s:r);if(!kr.test(a))throw new p("only letter, numbers, dashes and underscores are allowed in keys",{toml:e,ptr:t});o.push(a.trimEnd())}}while(r+1&&r<s);return[o,S(e,s+1,!0,!0)]}function et(e,t,n,r){let o={},s=new Set,i;for(t++;(i=e[t++])!=="}"&&i;){if(i===",")throw new p("expected value, found comma",{toml:e,ptr:t-1});if(i==="#")t=R(e,t);else if(i!==" "&&i!==" "&&i!==`
|
|
22
|
+
`&&i!=="\r"){let a,l=o,c=!1,[u,d]=ee(e,t-1);for(let h=0;h<u.length;h++){if(h&&(l=c?l[a]:l[a]={}),a=u[h],(c=Object.hasOwn(l,a))&&(typeof l[a]!="object"||s.has(l[a])))throw new p("trying to redefine an already defined value",{toml:e,ptr:t});!c&&a==="__proto__"&&Object.defineProperty(l,a,{enumerable:!0,configurable:!0,writable:!0})}if(c)throw new p("trying to redefine an already defined value",{toml:e,ptr:t});let[f,v]=D(e,d,"}",n-1,r);s.add(f),l[a]=f,t=v}}if(!i)throw new p("unfinished table encountered",{toml:e,ptr:t});return[o,t]}function tt(e,t,n,r){let o=[],s;for(t++;(s=e[t++])!=="]"&&s;){if(s===",")throw new p("expected value, found comma",{toml:e,ptr:t-1});if(s==="#")t=R(e,t);else if(s!==" "&&s!==" "&&s!==`
|
|
23
|
+
`&&s!=="\r"){let i=D(e,t-1,"]",n-1,r);o.push(i[0]),t=i[1]}}if(!s)throw new p("unfinished array encountered",{toml:e,ptr:t});return[o,t]}function nt(e,t,n,r){let o=t,s=n,i,a=!1,l;for(let c=0;c<e.length;c++){if(c){if(o=a?o[i]:o[i]={},s=(l=s[i]).c,r===0&&(l.t===1||l.t===2))return null;if(l.t===2){let u=o.length-1;o=o[u],s=s[u].c}}if(i=e[c],(a=Object.hasOwn(o,i))&&s[i]?.t===0&&s[i]?.d)return null;a||(i==="__proto__"&&(Object.defineProperty(o,i,{enumerable:!0,configurable:!0,writable:!0}),Object.defineProperty(s,i,{enumerable:!0,configurable:!0,writable:!0})),s[i]={t:c<e.length-1&&r===2?3:r,d:!1,i:0,c:{}})}if(l=s[i],l.t!==r&&!(r===1&&l.t===3)||(r===2&&(l.d||(l.d=!0,o[i]=[]),o[i].push(o={}),l.c[l.i++]=l={t:1,d:!1,i:0,c:{}}),l.d))return null;if(l.d=!0,r===1)o=a?o[i]:o[i]={};else if(r===0&&a)return null;return[i,o,l.c]}function ve(e,{maxDepth:t=1e3,integersAsBigInt:n}={}){let r={},o={},s=r,i=o;for(let a=S(e,0);a<e.length;){if(e[a]==="["){let l=e[++a]==="[",c=ee(e,a+=+l,"]");if(l){if(e[c[1]-1]!=="]")throw new p("expected end of table declaration",{toml:e,ptr:c[1]-1});c[1]++}let u=nt(c[0],r,o,l?2:1);if(!u)throw new p("trying to redefine an already defined table or value",{toml:e,ptr:a});i=u[2],s=u[1],a=c[1]}else{let l=ee(e,a),c=nt(l[0],s,i,0);if(!c)throw new p("trying to redefine an already defined table or value",{toml:e,ptr:a});let u=D(e,l[1],void 0,t,n);c[1][c[0]]=u[0],a=u[1]}if(a=S(e,a,!0),e[a]&&e[a]!==`
|
|
24
|
+
`&&e[a]!=="\r")throw new p("each key-value declaration must be followed by an end-of-line",{toml:e,ptr:a});a=S(e,a)}return r}var rt=/^[a-z0-9-_]+$/i;function H(e){let t=typeof e;if(t==="object"){if(Array.isArray(e))return"array";if(e instanceof Date)return"date"}return t}function Cr(e){for(let t=0;t<e.length;t++)if(H(e[t])!=="object")return!1;return e.length!=0}function Se(e){return JSON.stringify(e).replace(/\x7f/g,"\\u007f")}function we(e,t,n,r){if(n===0)throw new Error("Could not stringify the object: maximum object depth exceeded");if(t==="number")return isNaN(e)?"nan":e===1/0?"inf":e===-1/0?"-inf":r&&Number.isInteger(e)?e.toFixed(1):e.toString();if(t==="bigint"||t==="boolean")return e.toString();if(t==="string")return Se(e);if(t==="date"){if(isNaN(e.getTime()))throw new TypeError("cannot serialize invalid date");return e.toISOString()}if(t==="object")return xr(e,n,r);if(t==="array")return br(e,n,r)}function xr(e,t,n){let r=Object.keys(e);if(r.length===0)return"{}";let o="{ ";for(let s=0;s<r.length;s++){let i=r[s];s&&(o+=", "),o+=rt.test(i)?i:Se(i),o+=" = ",o+=we(e[i],H(e[i]),t-1,n)}return o+" }"}function br(e,t,n){if(e.length===0)return"[]";let r="[ ";for(let o=0;o<e.length;o++){if(o&&(r+=", "),e[o]===null||e[o]===void 0)throw new TypeError("arrays cannot contain null or undefined values");r+=we(e[o],H(e[o]),t-1,n)}return r+" ]"}function Pr(e,t,n,r){if(n===0)throw new Error("Could not stringify the object: maximum object depth exceeded");let o="";for(let s=0;s<e.length;s++)o+=`${o&&`
|
|
25
25
|
`}[[${t}]]
|
|
26
|
-
`,o+=
|
|
27
|
-
`)+
|
|
28
|
-
`)+
|
|
26
|
+
`,o+=ke(0,e[s],t,n,r);return o}function ke(e,t,n,r,o){if(r===0)throw new Error("Could not stringify the object: maximum object depth exceeded");let s="",i="",a=Object.keys(t);for(let l=0;l<a.length;l++){let c=a[l];if(t[c]!==null&&t[c]!==void 0){let u=H(t[c]);if(u==="symbol"||u==="function")throw new TypeError(`cannot serialize values of type '${u}'`);let d=rt.test(c)?c:Se(c);if(u==="array"&&Cr(t[c]))i+=(i&&`
|
|
27
|
+
`)+Pr(t[c],n?`${n}.${d}`:d,r-1,o);else if(u==="object"){let f=n?`${n}.${d}`:d;i+=(i&&`
|
|
28
|
+
`)+ke(f,t[c],f,r-1,o)}else s+=d,s+=" = ",s+=we(t[c],u,r,o),s+=`
|
|
29
29
|
`}}return e&&(s||!i)&&(s=s?`[${e}]
|
|
30
30
|
${s}`:`[${e}]`),s&&i?`${s}
|
|
31
|
-
${i}`:s||i}function
|
|
32
|
-
`?
|
|
33
|
-
`:
|
|
34
|
-
`)}};import{existsSync as
|
|
35
|
-
`).some(
|
|
36
|
-
`);
|
|
31
|
+
${i}`:s||i}function Ce(e,{maxDepth:t=1e3,numbersAsFloat:n=!1}={}){if(H(e)!=="object")throw new TypeError("stringify can only be called with an object");let r=ke(0,e,"",t,n);return r[r.length-1]!==`
|
|
32
|
+
`?r+`
|
|
33
|
+
`:r}function st(e){let t=e.mcp_servers?.venos;if(!t||t.command!=="node")return!1;let n=t.args?.[0];return!n||n.includes("/A2A/")?!1:xe(n)}var it={name:"codex",transport:"mcp-toml",configPath(e){return ot(e,".codex","config.toml")},isInstalled(e){return xe(ot(e,".codex"))},load(e){if(!xe(e))return{};try{return ve(Or(e,"utf8"))}catch{return{}}},isWired(e){return st(e)},inject(e,t){return st(e)?e:{...e,mcp_servers:{...e.mcp_servers??{},venos:{command:"node",args:[t.mcpServerPath],env:{VENOS_URL:t.orchestratorUrl,VENOS_ORG_ID:t.orgId,...t.apiKey?{VENOS_API_KEY:t.apiKey}:{},VENOS_SOURCE:"codex"}}}}},remove(e){if(!e.mcp_servers?.venos)return e;let{venos:t,...n}=e.mcp_servers;return{...e,mcp_servers:n}},write(e,t){m(e,Ce(t)+`
|
|
34
|
+
`)}};import{existsSync as at,readFileSync as Ir}from"node:fs";import{join as ct}from"node:path";var dt="venos";function be(e){return(e??[]).some(t=>t.hooks.some(n=>typeof n.command=="string"&&n.command.includes(dt)))}function lt(e,t){let n=e??[];return be(n)?n:[...n,{matcher:"*",hooks:[{type:"command",command:t}]}]}function ut(e){return(e??[]).map(t=>({...t,hooks:t.hooks.filter(n=>typeof n.command!="string"||!n.command.includes(dt))})).filter(t=>t.hooks.length>0)}function Er(e){return`${e.hookCommand} --source codex`}var pt={name:"codex-hook",transport:"claude-hook",configPath(e){return ct(e,".codex","hooks.json")},isInstalled(e){return at(ct(e,".codex"))},load(e){if(!at(e))return{};try{return JSON.parse(Ir(e,"utf8"))}catch{return{}}},isWired(e){return be(e.hooks?.PreToolUse)&&be(e.hooks?.PostToolUse)},inject(e,t){let n=e.hooks??{},r=Er(t);return{...e,hooks:{...n,PreToolUse:lt(n.PreToolUse,r),PostToolUse:lt(n.PostToolUse,r)}}},remove(e){return e.hooks?{...e,hooks:{...e.hooks,PreToolUse:ut(e.hooks.PreToolUse),PostToolUse:ut(e.hooks.PostToolUse)}}:e},write(e,t){m(e,g(t))}};import{existsSync as Pe,readFileSync as Rr}from"node:fs";import{join as ft}from"node:path";function mt(e){let t=e.mcpServers?.venos;if(!t||t.command!=="node")return!1;let n=t.args?.[0];return!n||n.includes("/A2A/")?!1:Pe(n)}var gt={name:"windsurf",transport:"mcp-json",configPath(e){return ft(e,".codeium","windsurf","mcp_config.json")},isInstalled(e){return Pe(ft(e,".codeium","windsurf"))},load(e){if(!Pe(e))return{};try{return JSON.parse(Rr(e,"utf8"))}catch{return{}}},isWired(e){return mt(e)},inject(e,t){return mt(e)?e:{...e,mcpServers:{...e.mcpServers??{},venos:{command:"node",args:[t.mcpServerPath],env:{VENOS_URL:t.orchestratorUrl,VENOS_ORG_ID:t.orgId,...t.apiKey?{VENOS_API_KEY:t.apiKey}:{}}}}}},remove(e){if(!e.mcpServers?.venos)return e;let{venos:t,...n}=e.mcpServers;return{...e,mcpServers:n}},write(e,t){m(e,g(t))}};import{existsSync as Oe,readFileSync as Tr}from"node:fs";import{join as T}from"node:path";var ht="saoudrizwan.claude-dev",Ar="cline_mcp_settings.json";function yt(e){if(process.platform==="darwin")return T(e,"Library","Application Support","Code","User");if(process.platform==="win32"){let t=process.env.APPDATA??T(e,"AppData","Roaming");return T(t,"Code","User")}return T(e,".config","Code","User")}function vt(e){let t=e.mcpServers?.venos;if(!t||t.command!=="node")return!1;let n=t.args?.[0];return!n||n.includes("/A2A/")?!1:Oe(n)}var St={name:"cline",transport:"mcp-json",configPath(e){return T(yt(e),"globalStorage",ht,"settings",Ar)},isInstalled(e){return Oe(T(yt(e),"globalStorage",ht))},load(e){if(!Oe(e))return{};try{return JSON.parse(Tr(e,"utf8"))}catch{return{}}},isWired(e){return vt(e)},inject(e,t){return vt(e)?e:{...e,mcpServers:{...e.mcpServers??{},venos:{command:"node",args:[t.mcpServerPath],env:{VENOS_URL:t.orchestratorUrl,VENOS_ORG_ID:t.orgId,...t.apiKey?{VENOS_API_KEY:t.apiKey}:{}}}}}},remove(e){if(!e.mcpServers?.venos)return e;let{venos:t,...n}=e.mcpServers;return{...e,mcpServers:n}},write(e,t){m(e,g(t))}};import{existsSync as Ie,readFileSync as _r}from"node:fs";import{join as wt}from"node:path";function kt(e){let t=e.context_servers?.venos;if(!t||t.command?.path!=="node")return!1;let n=t.command.args?.[0];return!n||n.includes("/A2A/")?!1:Ie(n)}var Ct={name:"zed",transport:"mcp-json",configPath(e){return wt(e,".config","zed","settings.json")},isInstalled(e){return Ie(wt(e,".config","zed"))},load(e){if(!Ie(e))return{};try{return JSON.parse(_r(e,"utf8"))}catch{return{}}},isWired(e){return kt(e)},inject(e,t){return kt(e)?e:{...e,context_servers:{...e.context_servers??{},venos:{command:{path:"node",args:[t.mcpServerPath],env:{VENOS_URL:t.orchestratorUrl,VENOS_ORG_ID:t.orgId,...t.apiKey?{VENOS_API_KEY:t.apiKey}:{}}},settings:{}}}}},remove(e){if(!e.context_servers?.venos)return e;let{venos:t,...n}=e.context_servers;return{...e,context_servers:n}},write(e,t){m(e,g(t))}};import{existsSync as Ee,readFileSync as Ur}from"node:fs";import{join as xt}from"node:path";function bt(e){let t=e.mcpServers?.venos;if(!t||t.command!=="node")return!1;let n=t.args?.[0];return!n||n.includes("/A2A/")?!1:Ee(n)}var Pt={name:"jetbrains",transport:"mcp-json",configPath(e){return xt(e,".junie","mcp","mcp.json")},isInstalled(e){return Ee(xt(e,".junie"))},load(e){if(!Ee(e))return{};try{return JSON.parse(Ur(e,"utf8"))}catch{return{}}},isWired(e){return bt(e)},inject(e,t){return bt(e)?e:{...e,mcpServers:{...e.mcpServers??{},venos:{command:"node",args:[t.mcpServerPath],env:{VENOS_URL:t.orchestratorUrl,VENOS_ORG_ID:t.orgId,...t.apiKey?{VENOS_API_KEY:t.apiKey}:{}}}}}},remove(e){if(!e.mcpServers?.venos)return e;let{venos:t,...n}=e.mcpServers;return{...e,mcpServers:n}},write(e,t){m(e,g(t))}};import{existsSync as Ot,readFileSync as Nr,rmSync as $r}from"node:fs";import{join as Mr}from"node:path";var jr="openai-api-base",Vr=".aider.conf.yml";function It(){return`${jr}: ${W}`}function Wr(e){return/^\s*openai-api-base\s*:/.test(e)}var Et={name:"aider",transport:"mcp-json",configPath(e){return Mr(e,Vr)},isInstalled(){return!0},load(e){let t=Ot(e)?Nr(e,"utf8"):"";return{wired:t.split(`
|
|
35
|
+
`).some(r=>r.trim()===It()),raw:t}},isWired(e){return e.wired},inject(e){return e.wired?e:{...e,wired:!0}},remove(e){return{...e,wired:!1}},write(e,t){let n=t.raw===""?[]:t.raw.split(`
|
|
36
|
+
`);n.length>0&&n[n.length-1]===""&&n.pop();let r=n.filter(s=>!Wr(s)),o=t.wired?[...r,It()]:r;if(o.length===0){Ot(e)&&$r(e,{force:!0});return}m(e,o.join(`
|
|
37
37
|
`)+`
|
|
38
|
-
`)}};import{accessSync as
|
|
38
|
+
`)}};import{accessSync as Fr,constants as Lr,existsSync as Tt,readFileSync as Dr}from"node:fs";import{delimiter as Hr}from"node:path";import{join as At}from"node:path";var Jr="obsidian-cli",Kr="obsidian-cli.json";function Br(e){try{return Fr(e,Lr.X_OK),!0}catch{return!1}}function Gr(e){return(process.env.PATH??"").split(Hr).some(n=>{if(n.trim()==="")return!1;let r=At(n,e);return Tt(r)&&Br(r)})}function Rt(e){return e.venos?.source==="obsidian-cli"&&e.venos.wired===!0}var _t={name:"obsidian-cli",transport:"mcp-json",configPath(e){return At(e,".venos",Kr)},isInstalled(){return Gr(Jr)},load(e){if(!Tt(e))return{};try{return JSON.parse(Dr(e,"utf8"))}catch{return{}}},isWired(e){return Rt(e)},inject(e,t){return Rt(e)?e:{...e,venos:{source:"obsidian-cli",orgId:t.orgId,orchestratorUrl:t.orchestratorUrl,wired:!0}}},remove(e){if(!e.venos)return e;let t={...e};return delete t.venos,t},write(e,t){m(e,g(t))}};var J=[he,ye,it,pt,gt,St,Ct,Pt,Et,_t];import{existsSync as Re}from"node:fs";import{dirname as Yr,join as Ut,resolve as Te}from"node:path";import{fileURLToPath as zr}from"node:url";var Nt=Yr(zr(import.meta.url));function te(){let e=process.env.VENOS_MCP_SERVER_PATH;if(e&&Re(e))return Te(e);let t=Te(Ut(Nt,"..","etc","mcp-server","bin.js"));if(Re(t))return t;let n=Te(Ut(Nt,"..","..","..","packages","mcp-server","dist","bin.js"));if(Re(n))return n;throw new Error(`venos: bundled mcp-server not found. Tried:
|
|
39
39
|
VENOS_MCP_SERVER_PATH=${e??"(unset)"}
|
|
40
40
|
bundled: ${t}
|
|
41
|
-
sibling: ${
|
|
42
|
-
If you are developing locally, run: pnpm --filter @venos/mcp-server build`)}import{existsSync as
|
|
43
|
-
`,"utf8")}function
|
|
41
|
+
sibling: ${n}
|
|
42
|
+
If you are developing locally, run: pnpm --filter @venos/mcp-server build`)}import{existsSync as Xr}from"node:fs";function Zr(e,t,n){let r=e.configPath(t);if(!e.isInstalled(t))return{client:e.name,transport:e.transport,status:"skipped-not-installed"};try{let o=e.load(r);if(e.isWired(o,n))return{client:e.name,transport:e.transport,status:"already-wired",path:r};let s=e.inject(o,n);return e.write(r,s),{client:e.name,transport:e.transport,status:"wired",path:r}}catch(o){return{client:e.name,transport:e.transport,status:"error",path:r,error:o instanceof Error?o.message:String(o)}}}function $t(e,t,n){return n.map(r=>Zr(r,e,t))}function qr(e,t){let n=e.configPath(t);if(!e.isInstalled(t))return{client:e.name,transport:e.transport,status:"skipped-not-installed"};if(!Xr(n))return{client:e.name,transport:e.transport,status:"already-removed",path:n};try{let r=e.load(n),o=e.remove(r);return JSON.stringify(o)===JSON.stringify(r)?{client:e.name,transport:e.transport,status:"already-removed",path:n}:(e.write(n,o),{client:e.name,transport:e.transport,status:"removed",path:n})}catch(r){return{client:e.name,transport:e.transport,status:"error",path:n,error:r instanceof Error?r.message:String(r)}}}function Mt(e,t){return t.map(n=>qr(n,e))}import{existsSync as jt,mkdirSync as Qr,readFileSync as eo}from"node:fs";import{join as Vt}from"node:path";var Wt="cline.openaiBaseUrl";function Ft(e){let t=Vt(e,".vscode");if(!jt(t))return{status:"no-workspace"};let n=Vt(t,"settings.json"),r={};if(jt(n))try{let o=JSON.parse(eo(n,"utf8"));o&&typeof o=="object"&&(r=o)}catch{}return r[Wt]===W?{status:"already-wired",path:n}:(Qr(t,{recursive:!0}),m(n,g({...r,[Wt]:W})),{status:"wired",path:n})}import{execFileSync as wo}from"node:child_process";import{existsSync as Dt,mkdirSync as ao,rmSync as co,writeFileSync as lo}from"node:fs";import{dirname as uo,join as po}from"node:path";var Ae="ai.venos.agent";import{existsSync as Lt,mkdirSync as to,rmSync as no,writeFileSync as ro}from"node:fs";import{dirname as oo,join as so}from"node:path";function _e(e){return so(e,".venos","service.json")}function A(e,t){let n=_e(e);to(oo(n),{recursive:!0}),ro(n,JSON.stringify(t,null,2)+`
|
|
43
|
+
`,"utf8")}function _(e){let t=_e(e);return Lt(t)?(no(t,{force:!0}),!0):!1}function U(e){return Lt(_e(e))}function Ht(e){return po(e,"Library","LaunchAgents",`${Ae}.plist`)}function fo(e,t){return`<?xml version="1.0" encoding="UTF-8"?>
|
|
44
44
|
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
45
45
|
<plist version="1.0">
|
|
46
46
|
<dict>
|
|
47
47
|
<key>Label</key>
|
|
48
|
-
<string>${
|
|
48
|
+
<string>${Ae}</string>
|
|
49
49
|
<key>ProgramArguments</key>
|
|
50
50
|
<array>
|
|
51
51
|
<string>${e}</string>
|
|
@@ -69,7 +69,7 @@ If you are developing locally, run: pnpm --filter @venos/mcp-server build`)}impo
|
|
|
69
69
|
<string>/dev/null</string>
|
|
70
70
|
</dict>
|
|
71
71
|
</plist>
|
|
72
|
-
`}var
|
|
72
|
+
`}var Jt={platform:"darwin",install(e){let t=Ht(e.home);try{let n=Dt(t);ao(uo(t),{recursive:!0}),lo(t,fo(e.nodePath,e.cliEntry),"utf8");try{e.run("launchctl",["unload",t])}catch{}return e.run("launchctl",["load","-w",t]),A(e.home,{kind:"launchd",path:t}),{platform:"darwin",status:n?"already-installed":"installed",path:t}}catch(n){return{platform:"darwin",status:"error",path:t,error:mo(n)}}},remove(e,t){let n=Ht(e),r=Dt(n);try{t("launchctl",["unload",n])}catch{}r&&co(n,{force:!0});let o=_(e);return{platform:"darwin",status:r||o?"removed":"already-removed",path:n}}};function mo(e){return e instanceof Error?e.message:String(e)}import{existsSync as ne,mkdirSync as go,rmSync as Kt,writeFileSync as Bt}from"node:fs";import{join as K}from"node:path";var re="venos-heartbeat.timer",Gt="venos-heartbeat.service";function Yt(e){return K(e,".config","systemd","user")}function ho(e,t){return`[Unit]
|
|
73
73
|
Description=venos endpoint heartbeat
|
|
74
74
|
|
|
75
75
|
[Service]
|
|
@@ -77,7 +77,7 @@ Type=oneshot
|
|
|
77
77
|
ExecStart=${e} ${t} heartbeat
|
|
78
78
|
Restart=on-failure
|
|
79
79
|
RestartSec=${60}
|
|
80
|
-
`}function
|
|
80
|
+
`}function yo(){return`[Unit]
|
|
81
81
|
Description=venos endpoint heartbeat (hourly)
|
|
82
82
|
|
|
83
83
|
[Timer]
|
|
@@ -87,43 +87,35 @@ Persistent=true
|
|
|
87
87
|
|
|
88
88
|
[Install]
|
|
89
89
|
WantedBy=timers.target
|
|
90
|
-
`}var
|
|
91
|
-
venos init ${
|
|
92
|
-
Next steps:`);let
|
|
93
|
-
Gateway routing (hard block via apps/mcp-proxy):`),console.log(` \u2022 Cursor \u2014 Settings \u2192 Models \u2192 Custom OpenAI Base URL: ${
|
|
94
|
-
venos init --remove ${
|
|
95
|
-
`,"utf8")}var
|
|
96
|
-
venos init failed: orchestrator unreachable at ${
|
|
97
|
-
`,"utf8"),
|
|
98
|
-
`),process.exit(1))}function
|
|
90
|
+
`}var zt={platform:"linux",install(e){let t=Yt(e.home),n=K(t,re);try{let r=ne(n);return go(t,{recursive:!0}),Bt(K(t,Gt),ho(e.nodePath,e.cliEntry),"utf8"),Bt(n,yo(),"utf8"),e.run("systemctl",["--user","daemon-reload"]),e.run("systemctl",["--user","enable","--now",re]),A(e.home,{kind:"systemd",path:n}),{platform:"linux",status:r?"already-installed":"installed",path:n}}catch(r){return{platform:"linux",status:"error",path:n,error:vo(r)}}},remove(e,t){let n=Yt(e),r=K(n,re),o=K(n,Gt),s=ne(r);try{t("systemctl",["--user","disable","--now",re])}catch{}ne(r)&&Kt(r,{force:!0}),ne(o)&&Kt(o,{force:!0});try{t("systemctl",["--user","daemon-reload"])}catch{}let i=_(e);return{platform:"linux",status:s||i?"removed":"already-removed",path:r}}};function vo(e){return e instanceof Error?e.message:String(e)}var oe="venos-heartbeat",Xt={platform:"win32",install(e){let t=`Scheduled Task: ${oe}`;try{let n=U(e.home),r=`"${e.nodePath}" "${e.cliEntry}" heartbeat`;return e.run("schtasks",["/Create","/TN",oe,"/TR",r,"/SC","HOURLY","/MO","1","/F"]),A(e.home,{kind:"schtasks",path:t}),{platform:"win32",status:n?"already-installed":"installed",path:t}}catch(n){return{platform:"win32",status:"error",path:t,error:So(n)}}},remove(e,t){let n=U(e);try{t("schtasks",["/Delete","/TN",oe,"/F"])}catch{}return _(e),{platform:"win32",status:n?"removed":"already-removed",path:`Scheduled Task: ${oe}`}}};function So(e){return e instanceof Error?e.message:String(e)}var Zt=[Jt,zt,Xt],qt=(e,t)=>{try{wo(e,t,{stdio:"ignore"})}catch{}};function Qt(e){return e??process.env.HOME??process.env.USERPROFILE??""}function en(e={}){let t=Zt.find(n=>n.platform===process.platform);return t?t.install({home:Qt(e.home),nodePath:process.execPath,cliEntry:process.argv[1]??"",run:e.run??qt}):{platform:"unsupported",status:"unsupported"}}function tn(e={}){let t=Zt.find(n=>n.platform===process.platform);return t?t.remove(Qt(e.home),e.run??qt):{platform:"unsupported",status:"unsupported"}}function nn(e){return U(e)}function rn(e){switch(e.status){case"installed":return` OK service boot service installed ${e.path??""}`;case"already-installed":return` \xB7 service boot service already installed ${e.path??""}`;case"removed":return" OK service boot service removed";case"already-removed":return" \xB7 service boot service already removed";case"unsupported":return" \u2014 service boot service not supported on this OS";case"error":return` FAIL service boot service install failed \u2014 ${e.error??""} (health still reports via the Stop hook)`;default:return null}}var ko={wired:"OK","already-wired":"\xB7","skipped-not-installed":"\u2014",error:"FAIL"},Co={wired:"wired","already-wired":"already wired","skipped-not-installed":"skipped (not installed)",error:"ERROR"},Ne="http://127.0.0.1:4000/v1";function on(e,t){let n=e.some(r=>r.status==="wired");console.log(`
|
|
91
|
+
venos init ${n?"done":"(no changes)"}`),console.log(` org ID : ${t.orgId}`),console.log(` orchestrator: ${t.orchestratorUrl}`);for(let r of e){let o=ko[r.status],s=Co[r.status],i=r.path?` ${r.path}`:"",a=r.error?` \u2014 ${r.error}`:"";console.log(` ${o} ${r.client.padEnd(12)} ${s}${i}${a}`)}if(t.clineWorkspace){let r=t.clineWorkspace;r.status==="wired"?console.log(` OK cline (ws) wired ${r.path}`):r.status==="already-wired"&&console.log(` \xB7 cline (ws) already wired ${r.path}`)}if(t.service){let r=rn(t.service);r&&console.log(r)}if(n){console.log(`
|
|
92
|
+
Next steps:`);let r={"claude-code":"Restart Claude Code for the hook to take effect.",cursor:"Restart Cursor to load the venos MCP server.",codex:"Restart Codex to pick up the new MCP config + gateway routing (~/.codex/.env).",windsurf:"Restart Windsurf to load the venos MCP server.",cline:"Reload the Cline extension (or restart VS Code) to load the venos MCP server.",zed:"Restart Zed to load the venos context server.",jetbrains:"Restart your JetBrains IDE (or just Junie) to load the venos MCP server.",aider:"Aider will route LLM calls through the venos gateway on next launch (~/.aider.conf.yml)."};for(let o of e){if(o.status!=="wired")continue;let s=r[o.client];s&&console.log(` \u2022 ${s}`)}console.log(` \u2022 Test: curl ${t.orchestratorUrl}/healthz`)}xo(t.clineWorkspace)}function xo(e){console.log(`
|
|
93
|
+
Gateway routing (hard block via apps/mcp-proxy):`),console.log(` \u2022 Cursor \u2014 Settings \u2192 Models \u2192 Custom OpenAI Base URL: ${Ne}`),console.log(" Optional: Custom HTTP Headers \u2192 X-Venos-Source: cursor"),console.log(` \u2022 Windsurf \u2014 Settings \u2192 Models \u2192 Custom OpenAI Base URL: ${Ne}`),(!e||e.status==="no-workspace")&&(console.log(" \u2022 Cline \u2014 Open VS Code in your project, then add to .vscode/settings.json:"),console.log(` "cline.openaiBaseUrl": "${Ne}"`)),console.log(" \u2022 VS Code Copilot \u2014 closed provider, no custom endpoint. Coverage = MCP advisory only."),console.log(" \u2022 JetBrains AI Assistant \u2014 closed provider, no custom endpoint. Coverage = MCP advisory only.")}function sn(e,t){console.log(JSON.stringify({...t,outcomes:e},null,2))}var bo={removed:"OK","already-removed":"\xB7","skipped-not-installed":"\u2014",error:"FAIL"},Po={removed:"removed","already-removed":"already removed","skipped-not-installed":"skipped (not installed)",error:"ERROR"};function an(e,t){let n=e.some(s=>s.status==="removed");console.log(`
|
|
94
|
+
venos init --remove ${n?"done":"(no changes)"}`);for(let s of e){let i=bo[s.status],a=Po[s.status],l=s.path?` ${s.path}`:"",c=s.error?` \u2014 ${s.error}`:"";console.log(` ${i} ${s.client.padEnd(12)} ${a}${l}${c}`)}let r=t.venosConfigRemoved?"OK":"\xB7",o=t.venosConfigRemoved?"removed":"already removed";if(console.log(` ${r} venos-config ${o} ${t.venosConfigPath}`),t.service){let s=rn(t.service);s&&console.log(s)}console.log("\nPre-venos `.venos-backup` snapshots are preserved \u2014 delete manually if you don't want them.")}function cn(e,t){console.log(JSON.stringify({...t,outcomes:e},null,2))}var ln=1;function B(e){return Ao(e,".venos","config.json")}function Uo(){return`org-${_o(4).toString("hex")}`}function No(e,t,n,r){let o=B(e);if(un(o))try{let s=JSON.parse(Io(o,"utf8")),i={schemaVersion:s.schemaVersion??ln,...s,orchestratorUrl:t};return n&&(i.apiKey=n),r&&(i.orgId=r),i}catch{}return{schemaVersion:ln,orgId:r??Uo(),orchestratorUrl:t,createdAt:new Date().toISOString(),failMode:"closed",...n?{apiKey:n}:{}}}function $o(e,t){let n=B(e);Oo(To(n),{recursive:!0}),Ro(n,JSON.stringify(t,null,2)+`
|
|
95
|
+
`,"utf8")}var Mo=5e3,jo=5e3;async function Vo(e){let t=e.replace(/\/$/,""),n=new AbortController,r=setTimeout(()=>n.abort(),Mo);try{return(await fetch(`${t}/healthz`,{signal:n.signal})).ok}catch{return!1}finally{clearTimeout(r)}}async function Wo(e,t){let n=e.replace(/\/$/,""),r=new AbortController,o=setTimeout(()=>r.abort(),jo);try{let s=await fetch(`${n}/api/activation/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({orgId:t}),signal:r.signal});s.ok||console.warn(`[venos] activation telemetry: non-200 response (${s.status}) \u2014 init continues`)}catch{console.warn("[venos] activation telemetry: failed to reach orchestrator \u2014 init continues")}finally{clearTimeout(o)}}function Fo(e){try{let t=new URL(e);return t.hostname==="localhost"||t.hostname==="127.0.0.1"||t.hostname==="::1"}catch{return!1}}function dn(e){let t=[];return e.orchestratorUrl?.trim()||t.push("--orchestrator"),e.apiKey?.trim()||t.push("--api-key"),e.orgId?.trim()||t.push("--org"),t}async function pn(e){let t=e.home??process.env.HOME??process.env.USERPROFILE??"",n=e.orchestratorUrl;await Vo(n)||(console.error(`
|
|
96
|
+
venos init failed: orchestrator unreachable at ${n}/healthz`),console.error("Check the --orchestrator URL is correct and reachable, then re-run."),process.exit(1));let r=No(t,n,e.apiKey,e.orgId),o={orgId:r.orgId,orchestratorUrl:n,mcpServerPath:te(),hookCommand:"venos hook",usageSyncCommand:"venos usage-sync --throttle",...r.apiKey?{apiKey:r.apiKey}:{}},s=$t(t,o,J);$o(t,r);let i=Ft(e.cwd??process.cwd()),a=process.env.VITEST&&!e.serviceRun?void 0:en({home:t,...e.serviceRun?{run:e.serviceRun}:{}});e.noTelemetry===!0||Fo(n)||!!r.apiKey||await Wo(n,r.orgId);let c={orgId:r.orgId,orchestratorUrl:n,clineWorkspace:i,...a?{service:a}:{}};e.json?sn(s,c):on(s,c)}function fn(e={}){let t=e.home??process.env.HOME??process.env.USERPROFILE??"",n=Mt(t,J),r=process.env.VITEST&&!e.serviceRun?void 0:tn({home:t,...e.serviceRun?{run:e.serviceRun}:{}}),o=B(t),s=un(o);s&&Eo(o,{force:!0});let i={venosConfigPath:o,venosConfigRemoved:s,...r?{service:r}:{}};e.json?cn(n,i):an(n,i)}import{mkdirSync as os,readFileSync as ie,existsSync as ss,writeFileSync as is}from"node:fs";import{hostname as as,userInfo as cs}from"node:os";import{execFileSync as Pn}from"node:child_process";import{randomBytes as On}from"node:crypto";import{dirname as ls,join as In}from"node:path";import{spawn as Lo}from"node:child_process";import{createHash as Do}from"node:crypto";import{existsSync as Ho,mkdirSync as Jo,readFileSync as gn,readdirSync as Ko,statSync as Bo,writeFileSync as Go}from"node:fs";import{dirname as Yo,extname as zo,join as hn,resolve as mn,sep as Xo}from"node:path";var Zo=new Set([".pdf",".png",".jpg",".jpeg",".xlsx",".xlsm",".xls"]),yn=new Set([".git",".ssh",".gnupg",".venos","node_modules","vendor","dist","build",".next",".cache"]),qo=[".ssh",".gnupg","keychain"],Qo=25<<20,es=25;function Me(e){let t=e.toLowerCase();for(let r of qo)if(t.includes(`/${r}`)||t.includes(`\\${r}`))return!1;for(let r of yn)if(t.includes(`/${r}/`)||t.includes(`\\${r}\\`))return!1;return(t.split(/[/\\]/).pop()??"").startsWith(".env")?!1:Zo.has(zo(t))}function $e(e){return hn(e,".venos","dspm-scanned.json")}function vn(e){try{let t=gn($e(e),"utf8"),n=JSON.parse(t);if(Array.isArray(n))return new Set(n.filter(r=>typeof r=="string"))}catch{}return new Set}function Sn(e,t){try{Jo(Yo($e(e)),{recursive:!0}),Go($e(e),JSON.stringify([...t]))}catch{}}function ts(e){return Do("sha256").update(e).digest("hex")}async function wn(e){let{home:t,filePath:n,source:r,config:o,machineId:s,hostname:i}=e,a=e.fetchImpl??globalThis.fetch;if(!Me(n))return"skipped-unsupported";let l;try{let O=Bo(n);if(!O.isFile())return"skipped-missing";if(O.size>Qo)return"skipped-too-large";l=gn(n)}catch{return"skipped-missing"}let c=ts(l),u=e.seen===void 0,d=e.seen??vn(t);if(d.has(c))return"skipped-dedup";let v=`${o.orchestratorUrl.replace(/\/$/,"")}/api/dspm/documents/classify?orgId=${encodeURIComponent(o.orgId)}`,h=new FormData;h.append("file",new Blob([new Uint8Array(l)]),n.split(/[/\\]/).pop()??"document"),h.append("orgId",o.orgId),h.append("source",r),h.append("machine_id",s),h.append("hostname",i);let E={"X-Venos-Org":o.orgId};o.apiKey&&(E.Authorization=`Bearer ${o.apiKey}`);let P=await a(v,{method:"POST",headers:E,body:h});return!P.ok&&P.status>=500?"skipped-missing":(d.add(c),u&&Sn(t,d),"classified")}function kn(e,t,n){if(t.length>=n)return;let r;try{r=Ko(e,{withFileTypes:!0})}catch{return}for(let o of r){if(t.length>=n)return;let s=hn(e,o.name);if(o.isDirectory()){if(yn.has(o.name))continue;kn(s,t,n)}else o.isFile()&&Me(s)&&t.push(s)}}async function se(e){let{home:t}=e,n=k(t),r=n.dspmScan?.dirs??[];if(r.length===0)return{scanned:0,classified:0,skipped:0,reason:"not-configured"};let o=n.dspmScan?.maxFilesPerRun??es,s=y(t),i=w(),a=vn(t),l=[];for(let d of r)Ho(d)&&kn(d,l,Number.MAX_SAFE_INTEGER);let c=0,u=0;for(let d of l){if(c>=o)break;await wn({home:t,filePath:d,source:"cli-heartbeat-scan",config:n,machineId:s,hostname:i,seen:a,...e.fetchImpl?{fetchImpl:e.fetchImpl}:{}})==="classified"?c++:u++}return Sn(t,a),{scanned:l.length,classified:c,skipped:u}}function ns(e){let t;try{t=JSON.parse(e)}catch{return null}if(typeof t!="object"||t===null)return null;let n=t.tool_input;if(typeof n!="object"||n===null)return null;for(let r of["file_path","path","notebook_path"]){let o=n[r];if(typeof o=="string"&&o.trim()!=="")return o}return null}function rs(e,t){let n=mn(e);for(let r of t){let o=mn(r);if(n===o||n.startsWith(o+Xo))return!0}return!1}async function Cn(e,t){try{let n=k(e);return await wn({home:e,filePath:t,source:"hook-realtime",config:n,machineId:y(e),hostname:w()})}catch{return"skipped-missing"}}function xn(e,t,n=Lo){let r=e.dspmScan?.dirs??[];if(r.length===0)return!1;let o=ns(t);if(o===null||!Me(o)||!rs(o,r))return!1;let s=process.argv[1]??"";try{return n(process.execPath,[s,"classify-file",o],{detached:!0,stdio:"ignore"}).unref(),!0}catch{return!1}}function us(e){return In(e,".venos","config.json")}function k(e){let t=us(e);if(!ss(t))throw new Error(`venos config not found at ${t} - run "venos init" first`);return JSON.parse(ie(t,"utf8"))}function ds(){return new Promise((e,t)=>{let n="";process.stdin.setEncoding("utf8"),process.stdin.on("data",r=>{n+=r}),process.stdin.on("end",()=>e(n)),process.stdin.on("error",t)})}function ps(e){let t;try{t=ie(e,"utf8")}catch{return null}let n=t.split(/\r?\n/);for(let r=n.length-1;r>=0;r--){let o=n[r]?.trim();if(!o)continue;let s;try{s=JSON.parse(o)}catch{continue}if(s.type!=="assistant"||!s.message||s.message.model==="<synthetic>")continue;let i=s.message.usage;if(!i)continue;let a=typeof i.cache_creation_input_tokens=="number"?i.cache_creation_input_tokens:void 0,l=typeof i.cache_read_input_tokens=="number"?i.cache_read_input_tokens:void 0,c=(i.input_tokens??0)+(a??0)+(l??0),u=i.output_tokens??0,d=s.message.model??"";if(c===0&&u===0&&d==="")return null;let f={tokensIn:c,tokensOut:u,model:d};return l!==void 0&&(f.cacheReadTokens=l),a!==void 0&&(f.cacheWriteTokens=a),f}return null}function fs(e){let t;try{t=JSON.parse(e)}catch{return e}if(typeof t!="object"||t===null||Array.isArray(t))return e;let n=t,r=n.transcript_path;if(typeof r!="string"||r==="")return e;let o=ps(r);return o?(n.usage_tokens_in=o.tokensIn,n.usage_tokens_out=o.tokensOut,o.cacheReadTokens!==void 0&&(n.cache_read_input_tokens=o.cacheReadTokens),o.cacheWriteTokens!==void 0&&(n.cache_creation_input_tokens=o.cacheWriteTokens),o.model!==""&&(n.usage_model=o.model),JSON.stringify(n)):e}function ms(e,t){if(t==="")return e;let n;try{n=JSON.parse(e)}catch{return JSON.stringify({orgId:t,content:e})}if(typeof n!="object"||n===null||Array.isArray(n))return e;let r=n;for(let o of["orgId","org_id","tenantId","tenant_id"]){let s=r[o];if(typeof s=="string"&&s.trim()!=="")return e}return r.orgId=t,JSON.stringify(r)}function gs(e){try{let n=JSON.parse(e).cursor_version;return typeof n=="string"&&n!==""}catch{return!1}}function je(){try{let e=cs().username;if(typeof e=="string"&&e.trim()!=="")return e.trim()}catch{}for(let e of["USER","USERNAME","LOGNAME"]){let t=process.env[e];if(typeof t=="string"&&t.trim()!=="")return t.trim()}return""}function hs(e,t,n){if(t==="")return e;let r;try{r=JSON.parse(e)}catch{return e}if(typeof r!="object"||r===null||Array.isArray(r))return e;let o=r;for(let s of["userId","user_id"]){let i=o[s];if(typeof i=="string"&&i.trim()!=="")return e}return o.userId=t,n&&(o.actor_email=n),JSON.stringify(o)}async function ys(e){if(process.env.VENOS_EMIT_ACTOR_EMAIL==="false")return null;try{let t=Pn("git",["config","user.email"],{encoding:"utf8",stdio:["pipe","pipe","pipe"]}).trim();if(t)return t.toLowerCase()}catch{}try{let t=k(e);if(t.actor_email?.trim())return t.actor_email.trim().toLowerCase()}catch{}return null}function y(e){let t=e===""?"":In(e,".venos","machine-id");if(t!=="")try{let n=ie(t,"utf8").trim();if(n!=="")return n}catch{}try{let n=ie("/etc/machine-id","utf8").trim();if(n!=="")return n}catch{}if(t==="")return"";try{let n=On(16).toString("hex");return os(ls(t),{recursive:!0}),is(t,n+`
|
|
97
|
+
`,"utf8"),n}catch{return""}}function vs(e,t,n){if(t===""&&n==="")return e;let r;try{r=JSON.parse(e)}catch{return e}if(typeof r!="object"||r===null||Array.isArray(r))return e;let o=r,s=i=>{let a=o[i];return typeof a=="string"&&a.trim()!==""};return t!==""&&!s("machine_id")&&!s("machineId")&&(o.machine_id=t),n!==""&&(o.hostname=n),JSON.stringify(o)}function w(e=process.platform,t=Ss){if(e==="darwin")try{let n=t().trim();if(n!=="")return n.endsWith(".local")?n:`${n}.local`}catch{}try{let n=as();return typeof n=="string"?n.trim():""}catch{return""}}function Ss(){try{return Pn("scutil",["--get","LocalHostName"],{encoding:"utf8",timeout:1e3}).trim()}catch{return""}}function b(e,t,n){let r={"Content-Type":"application/json","X-Venos-Org":e};return t&&(r.Authorization=`Bearer ${t}`),n&&(r["X-Venos-Idempotency-Key"]=n),r}function ws(e){return e.failMode==="closed"?{mode:"closed",implicit:!1}:e.failMode==="open"?{mode:"open",implicit:!1}:{mode:"open",implicit:!0}}function En(e){return e===502||e===503}async function N(e,t,n={}){let r=n.attempts??3,o=n.backoffMs??[250,750],s=n.timeoutMs??3e3,i;for(let a=0;a<r;a++){if(a>0){let l=o[Math.min(a-1,o.length-1)]??0;await new Promise(c=>setTimeout(c,l))}try{let l=await fetch(e,{...t,signal:AbortSignal.timeout(s)});if(!En(l.status)||a===r-1)return l;i=new Error(`orchestrator returned ${l.status}`)}catch(l){i=l}}throw i}function ks(e){let t=e.orchestratorUrl.replace(/\/$/,"").trim(),n=new Set([t]),r=[];for(let o of e.mirrors??[]){let s=(o?.url??"").replace(/\/$/,"").trim();s===""||n.has(s)||(n.add(s),r.push(o.apiKey?{url:s,apiKey:o.apiKey}:{url:s}))}return r}async function Cs(e,t,n,r,o){e.length!==0&&await Promise.allSettled(e.map(async s=>{let i=`${s.url}/v1/hooks/${encodeURIComponent(t)}`;try{await(await N(i,{method:"POST",headers:b(n,s.apiKey,o),body:r})).text()}catch{}}))}async function Rn(e,t="claude-code"){let n=e??process.env.HOME??process.env.USERPROFILE??"",r=k(n),o=await ds();try{xn(r,o)}catch{}let s=gs(o),i=await ys(n),a=vs(hs(fs(ms(o,r.orgId)),je(),i),y(n),w()),c=`${r.orchestratorUrl.replace(/\/$/,"")}/v1/hooks/${encodeURIComponent(t)}`,u=On(16).toString("hex"),d=Cs(ks(r),t,r.orgId,a,u),f;try{f=await N(c,{method:"POST",headers:b(r.orgId,r.apiKey,u),body:a})}catch{await d,bn(t,s,r);return}if(En(f.status)){await f.text(),await d,bn(t,s,r);return}if(s){await f.text(),await d;return}let v=await f.text(),h=t==="codex"?xs(v):t==="claude-code"?bs(v):v;process.stdout.write(h),await d,f.ok||(process.stderr.write(`venos hook: orchestrator returned ${f.status}
|
|
98
|
+
`),process.exit(1))}function bn(e,t,n){if(t)return;let{mode:r,implicit:o}=ws(n);if(r==="open"){o?process.stderr.write(`venos hook: orchestrator unreachable; proceeding because ~/.venos/config.json has no "failMode". This default flips to "closed" in a future release - set failMode explicitly to keep proceeding.
|
|
99
99
|
`):process.stderr.write(`venos hook: orchestrator unreachable; proceeding (failMode=open)
|
|
100
100
|
`);return}let s='venos orchestrator unreachable (fail-closed); set failMode "open" in ~/.venos/config.json to proceed without recording';if(e==="codex"){process.stdout.write(JSON.stringify({decision:"block",reason:s}));return}process.stderr.write(`venos hook: ${s}
|
|
101
|
-
`),process.exit(2)}function
|
|
102
|
-
`),process.exit(1);return}if(s.status===503){process.stderr.write(`venos: billing is not yet configured on this server
|
|
103
|
-
`),process.exit(1);return}if(!s.ok){process.stderr.write(`venos: checkout failed (${s.status})
|
|
104
|
-
`),process.exit(1);return}let i=await s.json();if(!i.url){process.stderr.write(`venos: no checkout URL returned
|
|
105
|
-
`),process.exit(1);return}process.stdout.write(`
|
|
106
|
-
Open this URL to upgrade your venos plan:
|
|
107
|
-
|
|
108
|
-
${i.url}
|
|
109
|
-
|
|
110
|
-
`)}import{readFileSync as Qo,existsSync as es}from"node:fs";import{join as hr}from"node:path";import{execFile as ts}from"node:child_process";import{promisify as rs}from"node:util";import{existsSync as _}from"node:fs";import{dirname as Xo,join as ne,resolve as U}from"node:path";import{fileURLToPath as qo}from"node:url";var oe=Xo(qo(import.meta.url));function mr(){let e=process.env.VENOS_SESSION_WASTE_PATH;if(e&&_(e))return U(e);let t=U(ne(oe,"..","etc","session-waste","bin.js"));if(_(t))return t;let r=U(ne(oe,"..","..","..","packages","session-waste","dist","bin.js"));if(_(r))return r;throw new Error(`venos: bundled session-waste scanner not found. Tried:
|
|
101
|
+
`),process.exit(2)}function xs(e){let t;try{t=JSON.parse(e)}catch{return e}let n=typeof t.decision=="string"?t.decision:"";if(n==="deny"||n==="block"){let r=typeof t.severity=="string"?t.severity:"",o=typeof t.eventId=="string"?t.eventId:"",s=`blocked by venos policy${r?` (severity=${r})`:""}${o?` [event ${o}]`:""}`;return JSON.stringify({decision:"block",reason:s})}return n==="allow"?JSON.stringify({decision:"approve"}):e}function bs(e){let t;try{t=JSON.parse(e)}catch{return""}let n=typeof t.decision=="string"?t.decision:"";if(n==="deny"||n==="block"){let r=typeof t.severity=="string"?t.severity:"",o=typeof t.eventId=="string"?t.eventId:"",s=`blocked by venos policy${r?` (severity=${r})`:""}${o?` [event ${o}]`:""}`;return JSON.stringify({decision:"block",reason:s})}return""}import{readFileSync as Is,existsSync as Es}from"node:fs";import{join as _n}from"node:path";import{execFile as Rs}from"node:child_process";import{promisify as Ts}from"node:util";import{existsSync as $}from"node:fs";import{dirname as Ps,join as ae,resolve as M}from"node:path";import{fileURLToPath as Os}from"node:url";var ce=Ps(Os(import.meta.url));function Tn(){let e=process.env.VENOS_SESSION_WASTE_PATH;if(e&&$(e))return M(e);let t=M(ae(ce,"..","etc","session-waste","bin.js"));if($(t))return t;let n=M(ae(ce,"..","..","..","packages","session-waste","dist","bin.js"));if($(n))return n;throw new Error(`venos: bundled session-waste scanner not found. Tried:
|
|
111
102
|
VENOS_SESSION_WASTE_PATH=${e??"(unset)"}
|
|
112
103
|
bundled: ${t}
|
|
113
|
-
sibling: ${
|
|
114
|
-
If you are developing locally, run: pnpm --filter @venos/session-waste build`)}function
|
|
104
|
+
sibling: ${n}
|
|
105
|
+
If you are developing locally, run: pnpm --filter @venos/session-waste build`)}function An(){let e=process.env.VENOS_USAGE_AGGREGATOR_PATH;if(e&&$(e))return M(e);let t=M(ae(ce,"..","etc","session-waste","usage-bin.js"));if($(t))return t;let n=M(ae(ce,"..","..","..","packages","session-waste","dist","usage-bin.js"));if($(n))return n;throw new Error(`venos: bundled usage aggregator not found. Tried:
|
|
115
106
|
VENOS_USAGE_AGGREGATOR_PATH=${e??"(unset)"}
|
|
116
107
|
bundled: ${t}
|
|
117
|
-
sibling: ${
|
|
118
|
-
If you are developing locally, run: pnpm --filter @venos/session-waste build`)}var ns=rs(ts);async function yr(e){let t=e??process.env.HOME??process.env.USERPROFILE??"",r=hr(t,".venos","config.json");if(!es(r))throw new Error(`venos config not found at ${r} \u2014 run "venos init" first`);let n=JSON.parse(Qo(r,"utf8")),o=mr(),s=hr(t,".claude"),{stdout:i}=await ns(process.execPath,[o,s],{maxBuffer:32*1024*1024}),a=JSON.parse(i),l=Array.isArray(a.findings)?a.findings:[];if(l.length===0)return{sessionsScanned:a.sessionsScanned??0,findingsStored:0};let u=`${n.orchestratorUrl.replace(/\/$/,"")}/api/finops/session-waste?orgId=${encodeURIComponent(n.orgId)}`,p=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json","X-Venos-Org":n.orgId},body:JSON.stringify({findings:l})});if(!p.ok)throw new Error(`venos waste-scan: orchestrator returned ${p.status}`);let f=await p.json();return{sessionsScanned:a.sessionsScanned??0,findingsStored:f.stored??l.length}}import{readFileSync as os,existsSync as ss,statSync as is,writeFileSync as as}from"node:fs";import{join as Ae}from"node:path";import{execFile as cs,spawn as ls}from"node:child_process";import{promisify as us}from"node:util";var ds=us(cs),ps=500;function fs(e,t,r=ps){let n=[];for(let o=0;o<e.length;o+=r)n.push({sessions:e.slice(o,o+r),attribution:[]});for(let o=0;o<t.length;o+=r)n.push({sessions:[],attribution:t.slice(o,o+r)});return n}function ms(e){return Ae(e,".venos","usage-sync.last")}function _e(e,t,r){try{return r-is(e).mtimeMs>=t}catch{return!0}}function vr(e,t=60,r=ls){let n=e??process.env.HOME??process.env.USERPROFILE??"",o=ms(n);if(!_e(o,t*6e4,Date.now()))return{ran:!1,reason:"throttled"};try{as(o,new Date().toISOString())}catch{return{ran:!1,reason:"stamp-write-failed"}}let s=process.argv[1]??"";return r(process.execPath,[s,"usage-sync"],{detached:!0,stdio:"ignore"}).unref(),{ran:!0,reason:"spawned"}}async function Sr(e={},t){let r=t??process.env.HOME??process.env.USERPROFILE??"",n=Ae(r,".venos","config.json");if(!ss(n))throw new Error(`venos config not found at ${n} \u2014 run "venos init" first`);let o=JSON.parse(os(n,"utf8")),s=e.orgId??o.orgId,i=e.orchestratorUrl??o.orchestratorUrl,a=e.apiKey??o.apiKey,l=gr(),c=Ae(r,".claude"),{stdout:u}=await ds(process.execPath,[l,c],{maxBuffer:64*1024*1024}),p=JSON.parse(u),f=Array.isArray(p.sessions)?p.sessions:[],v=Array.isArray(p.attribution)?p.attribution:[];if(f.length===0)return{sessionsScanned:p.sessionsScanned??0,sessionsStored:0};let ae=`${i.replace(/\/$/,"")}/api/finops/claude-usage?orgId=${encodeURIComponent(s)}`,N={"Content-Type":"application/json","X-Venos-Org":s};a&&(N.Authorization=`Bearer ${a}`);let $=0;for(let M of fs(f,v)){let ce=await A(ae,{method:"POST",headers:N,body:JSON.stringify(M)},{timeoutMs:1e4});if(!ce.ok)throw new Error(`venos usage-sync: orchestrator returned ${ce.status}`);let Lr=await ce.json();$+=Lr.sessionsStored??M.sessions.length}return{sessionsScanned:p.sessionsScanned??0,sessionsStored:$}}import{existsSync as ri,readFileSync as ni,writeFileSync as Pr}from"node:fs";import{join as Er}from"node:path";import{spawn as oi}from"node:child_process";import{execFileSync as se}from"node:child_process";import{existsSync as gs,readdirSync as hs,readFileSync as wr,realpathSync as ys}from"node:fs";import{homedir as vs,hostname as Ss,release as K}from"node:os";import{basename as ws,dirname as ks,join as Cs}from"node:path";var xs=[{key:"claude-code",displayName:"Claude Code",isCli:!0,detect:{darwin:["~/.local/bin/claude","~/.claude/local/claude","/opt/homebrew/bin/claude","/usr/local/bin/claude"],linux:["~/.local/bin/claude","~/.npm-global/bin/claude","/usr/local/bin/claude"],win32:["%APPDATA%\\npm\\claude.cmd","%USERPROFILE%\\.local\\bin\\claude.exe"]},version:{darwin:{strategy:"symlink-version"},linux:{strategy:"symlink-version"},win32:{strategy:"none"}}},{key:"claude-desktop",displayName:"Claude Desktop",isCli:!1,detect:{darwin:["/Applications/Claude.app/Contents/Info.plist","~/Applications/Claude.app/Contents/Info.plist"],win32:["%LOCALAPPDATA%\\AnthropicClaude\\claude.exe"]},version:{darwin:{strategy:"plist"},win32:{strategy:"none"}}},{key:"chatgpt-desktop",displayName:"ChatGPT Desktop",isCli:!1,detect:{darwin:["/Applications/ChatGPT.app/Contents/Info.plist","~/Applications/ChatGPT.app/Contents/Info.plist"]},version:{darwin:{strategy:"plist"}}},{key:"cursor",displayName:"Cursor",isCli:!1,detect:{darwin:["/Applications/Cursor.app/Contents/Info.plist"],win32:["%LOCALAPPDATA%\\Programs\\cursor\\Cursor.exe"],linux:["/usr/share/cursor/resources/app/package.json","/opt/cursor/resources/app/package.json"]},version:{darwin:{strategy:"plist"},linux:{strategy:"pkgjson"},win32:{strategy:"none"}}},{key:"windsurf",displayName:"Windsurf",isCli:!1,detect:{darwin:["/Applications/Windsurf.app/Contents/Info.plist"],win32:["%LOCALAPPDATA%\\Programs\\Windsurf\\Windsurf.exe"],linux:["/usr/share/windsurf/resources/app/package.json","/opt/windsurf/resources/app/package.json"]},version:{darwin:{strategy:"plist"},linux:{strategy:"pkgjson"},win32:{strategy:"none"}}},{key:"ollama",displayName:"Ollama",isCli:!0,detect:{darwin:["/opt/homebrew/bin/ollama","/usr/local/bin/ollama","/Applications/Ollama.app/Contents/Info.plist"],win32:["%LOCALAPPDATA%\\Programs\\Ollama\\ollama.exe"],linux:["/usr/local/bin/ollama","/usr/bin/ollama"]},version:{darwin:{strategy:"exec-version"},linux:{strategy:"exec-version"},win32:{strategy:"none"}}},{key:"openai-codex",displayName:"OpenAI Codex",isCli:!0,detect:{darwin:["/Applications/Codex.app/Contents/Info.plist","~/.npm-global/bin/codex"]},version:{darwin:{strategy:"plist"}}},{key:"perplexity-desktop",displayName:"Perplexity Desktop",isCli:!1,detect:{darwin:["/Applications/Perplexity.app/Contents/Info.plist"]},version:{darwin:{strategy:"plist"}}},{key:"google-antigravity",displayName:"Google Antigravity",isCli:!1,detect:{darwin:["/Applications/Antigravity.app/Contents/Info.plist"]},version:{darwin:{strategy:"plist"}}},{key:"warp",displayName:"Warp",isCli:!1,detect:{darwin:["/Applications/Warp.app/Contents/Info.plist"]},version:{darwin:{strategy:"plist"}}},{key:"wispr-flow",displayName:"Wispr Flow",isCli:!1,detect:{darwin:["/Applications/Wispr Flow.app/Contents/Info.plist"]},version:{darwin:{strategy:"plist"}}},{key:"conductor",displayName:"Conductor",isCli:!1,detect:{darwin:["/Applications/Conductor.app/Contents/Info.plist"]},version:{darwin:{strategy:"plist"}}},{key:"lm-studio",displayName:"LM Studio",isCli:!1,detect:{darwin:["/Applications/LM Studio.app/Contents/Info.plist"],win32:["%LOCALAPPDATA%\\Programs\\lm-studio\\LM Studio.exe"]},version:{darwin:{strategy:"plist"},win32:{strategy:"none"}}}],bs=/\d+(?:\.\d+){1,4}/;function Os(e,t){let r=e;return r.startsWith("~")&&(r=t+r.slice(1)),r=r.replace(/%([^%]+)%/g,(n,o)=>process.env[o]??""),r}function Ps(e){if(!e.includes("*"))return gs(e)?e:null;let t=ks(e),r=ws(e),n=r.indexOf("*"),o=r.slice(0,n),s=r.slice(n+1),i;try{i=hs(t)}catch{return null}for(let a of i)if(a.startsWith(o)&&a.endsWith(s)&&a.length>=o.length+s.length)return Cs(t,a);return null}function Es(e){let t=e.replace(/\.plist$/,"");try{return se("defaults",["read",t,"CFBundleShortVersionString"],{encoding:"utf8",timeout:4e3,stdio:["ignore","pipe","ignore"]}).trim()}catch{return""}}function Is(e){try{let t=JSON.parse(wr(e,"utf8"));return typeof t.version=="string"?t.version.trim():""}catch{return""}}function Rs(e){try{let t=ys(e);for(let r of t.split(/[/\\]/)){let n=r.match(/^\d+(?:\.\d+){1,4}$/);if(n)return n[0]}}catch{}return""}function Ts(e){try{let r=se(e,["--version"],{encoding:"utf8",timeout:4e3,stdio:["ignore","pipe","ignore"]}).match(bs);return r?r[0]:""}catch{return""}}function As(e,t){switch(e){case"plist":return Es(t);case"pkgjson":return Is(t);case"symlink-version":return Rs(t);case"exec-version":return Ts(t);case"none":return""}}function _s(e,t){let r=[];for(let n of xs){let o=n.detect[e];if(!o)continue;let s="";for(let l of o){let c=Ps(Os(l,t));if(c){s=c;break}}if(s==="")continue;let i=n.version[e],a=i?As(i.strategy,s):"";r.push({key:n.key,name:n.displayName,version:a,sourcePath:s})}return r.sort((n,o)=>n.name.localeCompare(o.name)),r}function Us(){try{let e=se("sw_vers",["-productName"],{encoding:"utf8",timeout:4e3}).trim(),t=se("sw_vers",["-productVersion"],{encoding:"utf8",timeout:4e3}).trim(),r=t.split(".")[0]??"";return{platform:r?`${e} ${r}`:e,version:t}}catch{return{platform:"macOS",version:K()}}}function Ns(){try{let t=wr("/etc/os-release","utf8").match(/^PRETTY_NAME="?([^"\n]+)"?/m);if(t&&t[1])return{platform:t[1],version:K()}}catch{}return{platform:"Linux",version:K()}}function $s(){let e=K();return{platform:Number(e.split(".")[2]??"0")>=22e3?"Windows 11":"Windows 10",version:e}}function Ue(e){let t;return e==="darwin"?t=Us():e==="linux"?t=Ns():e==="win32"?t=$s():t={platform:e,version:K()},{osPlatform:t.platform,osVersion:t.version}}function Ms(e){let t=Ue(e),r={platform:t.osPlatform,version:t.osVersion},n="";return e==="win32"&&(n=(process.env.USERDNSDOMAIN??process.env.USERDOMAIN??"").trim()),{hostname:w()||Ss(),osPlatform:r.platform,osVersion:r.version,deviceType:"Workstation",accountName:Te(),accountDomain:n}}async function Ne(e={}){let t=e.home??process.env.HOME??process.env.USERPROFILE??vs(),r=process.platform,n=_s(r,t),o=Ms(r);if(e.dryRun)return{agents:n.length,detected:n,host:o,uploaded:!1};let s=C(t),i=s.orchestratorUrl.replace(/\/$/,""),a=y(t),l=await fetch(`${i}/v1/inventory/agents`,{method:"POST",headers:x(s.orgId,s.apiKey),body:JSON.stringify({orgId:s.orgId,machineId:a,hostname:o.hostname,osPlatform:o.osPlatform,osVersion:o.osVersion,deviceType:o.deviceType,accountName:o.accountName,accountDomain:o.accountDomain,agents:n.map(c=>({key:c.key,name:c.name,version:c.version,sourcePath:c.sourcePath}))})});if(!l.ok){let c=await l.text();throw new Error(`scan-agents upload failed: ${l.status} ${c}`)}return{agents:n.length,detected:n,host:o,uploaded:!0}}import{execFile as js,spawn as Vs}from"node:child_process";import{existsSync as Ws,readFileSync as Ls,writeFileSync as Hs}from"node:fs";import{delimiter as kr,dirname as xr,join as $e}from"node:path";var Fs=1440*60*1e3,Ds=2e3,Js=6e4,Ks=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;function br(e){return $e(e,".venos","update-check.json")}function Bs(e){try{let t=JSON.parse(Ls(br(e),"utf8"));if(typeof t.checkedAt=="number"&&t.policy&&typeof t.policy.mode=="string")return t}catch{}return null}function Gs(e,t){try{Hs(br(e),JSON.stringify(t))}catch{}}function Cr(e){let t=/^(\d+)\.(\d+)\.(\d+)/.exec(e.trim());return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}function Ys(e,t){let r=Cr(e),n=Cr(t);if(!r||!n)return!1;for(let o=0;o<3;o++){if(r[o]>n[o])return!0;if(r[o]<n[o])return!1}return!1}async function zs(e,t,r,n){let s=`${e.replace(/\/$/,"")}/api/cli/policy?orgId=${encodeURIComponent(t)}`;n&&n.trim()!==""&&(s+=`&machineId=${encodeURIComponent(n)}`);try{let i=await r(s,{signal:AbortSignal.timeout(Ds)});if(!i.ok)return null;let a=await i.json();return{mode:typeof a.mode=="string"&&a.mode!==""?a.mode:"notify",latest:typeof a.latest=="string"?a.latest.trim():"",pinnedVersion:typeof a.pinnedVersion=="string"?a.pinnedVersion.trim():""}}catch{return null}}function Zs(e,t){if(e.mode==="off")return null;if(e.mode==="pinned"){let r=e.pinnedVersion;return r===""||r===t?null:{kind:"notify",targetVersion:r,message:`venos: your organization pins venos to ${r} (you have ${t}).
|
|
119
|
-
Install it with: npm i -g @venos-inc/venos@${
|
|
120
|
-
Update with: npm i -g @venos-inc/venos@latest`}:null}async function
|
|
108
|
+
sibling: ${n}
|
|
109
|
+
If you are developing locally, run: pnpm --filter @venos/session-waste build`)}var As=Ts(Rs);async function Un(e){let t=e??process.env.HOME??process.env.USERPROFILE??"",n=_n(t,".venos","config.json");if(!Es(n))throw new Error(`venos config not found at ${n} \u2014 run "venos init" first`);let r=JSON.parse(Is(n,"utf8")),o=Tn(),s=_n(t,".claude"),{stdout:i}=await As(process.execPath,[o,s],{maxBuffer:32*1024*1024}),a=JSON.parse(i),l=Array.isArray(a.findings)?a.findings:[];if(l.length===0)return{sessionsScanned:a.sessionsScanned??0,findingsStored:0};let u=`${r.orchestratorUrl.replace(/\/$/,"")}/api/finops/session-waste?orgId=${encodeURIComponent(r.orgId)}`,d=await fetch(u,{method:"POST",headers:{"Content-Type":"application/json","X-Venos-Org":r.orgId},body:JSON.stringify({findings:l})});if(!d.ok)throw new Error(`venos waste-scan: orchestrator returned ${d.status}`);let f=await d.json();return{sessionsScanned:a.sessionsScanned??0,findingsStored:f.stored??l.length}}import{readFileSync as _s,existsSync as Us,statSync as Ns,writeFileSync as $s}from"node:fs";import{join as Ve}from"node:path";import{execFile as Ms,spawn as js}from"node:child_process";import{promisify as Vs}from"node:util";var Ws=Vs(Ms),Fs=500;function Ls(e,t,n=Fs){let r=[];for(let o=0;o<e.length;o+=n)r.push({sessions:e.slice(o,o+n),attribution:[]});for(let o=0;o<t.length;o+=n)r.push({sessions:[],attribution:t.slice(o,o+n)});return r}function Ds(e){return Ve(e,".venos","usage-sync.last")}function We(e,t,n){try{return n-Ns(e).mtimeMs>=t}catch{return!0}}function Nn(e,t=60,n=js){let r=e??process.env.HOME??process.env.USERPROFILE??"",o=Ds(r);if(!We(o,t*6e4,Date.now()))return{ran:!1,reason:"throttled"};try{$s(o,new Date().toISOString())}catch{return{ran:!1,reason:"stamp-write-failed"}}let s=process.argv[1]??"";return n(process.execPath,[s,"usage-sync"],{detached:!0,stdio:"ignore"}).unref(),{ran:!0,reason:"spawned"}}async function $n(e={},t){let n=t??process.env.HOME??process.env.USERPROFILE??"",r=Ve(n,".venos","config.json");if(!Us(r))throw new Error(`venos config not found at ${r} \u2014 run "venos init" first`);let o=JSON.parse(_s(r,"utf8")),s=e.orgId??o.orgId,i=e.orchestratorUrl??o.orchestratorUrl,a=e.apiKey??o.apiKey,l=An(),c=Ve(n,".claude"),{stdout:u}=await Ws(process.execPath,[l,c],{maxBuffer:64*1024*1024}),d=JSON.parse(u),f=Array.isArray(d.sessions)?d.sessions:[],v=Array.isArray(d.attribution)?d.attribution:[];if(f.length===0)return{sessionsScanned:d.sessionsScanned??0,sessionsStored:0};let E=`${i.replace(/\/$/,"")}/api/finops/claude-usage?orgId=${encodeURIComponent(s)}`,P={"Content-Type":"application/json","X-Venos-Org":s};a&&(P.Authorization=`Bearer ${a}`);let O=0;for(let V of Ls(f,v)){let fe=await N(E,{method:"POST",headers:P,body:JSON.stringify(V)},{timeoutMs:1e4});if(!fe.ok)throw new Error(`venos usage-sync: orchestrator returned ${fe.status}`);let tr=await fe.json();O+=tr.sessionsStored??V.sessions.length}return{sessionsScanned:d.sessionsScanned??0,sessionsStored:O}}import{existsSync as Fi,readFileSync as Li,writeFileSync as Yn}from"node:fs";import{join as zn}from"node:path";import{spawn as Di}from"node:child_process";import{execFileSync as le}from"node:child_process";import{existsSync as Hs,readdirSync as Js,readFileSync as Mn,realpathSync as Ks}from"node:fs";import{homedir as Bs,hostname as Gs,release as G}from"node:os";import{basename as Ys,dirname as zs,join as Xs}from"node:path";var Zs=[{key:"claude-code",displayName:"Claude Code",isCli:!0,detect:{darwin:["~/.local/bin/claude","~/.claude/local/claude","/opt/homebrew/bin/claude","/usr/local/bin/claude"],linux:["~/.local/bin/claude","~/.npm-global/bin/claude","/usr/local/bin/claude"],win32:["%APPDATA%\\npm\\claude.cmd","%USERPROFILE%\\.local\\bin\\claude.exe"]},version:{darwin:{strategy:"symlink-version"},linux:{strategy:"symlink-version"},win32:{strategy:"none"}}},{key:"claude-desktop",displayName:"Claude Desktop",isCli:!1,detect:{darwin:["/Applications/Claude.app/Contents/Info.plist","~/Applications/Claude.app/Contents/Info.plist"],win32:["%LOCALAPPDATA%\\AnthropicClaude\\claude.exe"]},version:{darwin:{strategy:"plist"},win32:{strategy:"none"}}},{key:"chatgpt-desktop",displayName:"ChatGPT Desktop",isCli:!1,detect:{darwin:["/Applications/ChatGPT.app/Contents/Info.plist","~/Applications/ChatGPT.app/Contents/Info.plist"]},version:{darwin:{strategy:"plist"}}},{key:"cursor",displayName:"Cursor",isCli:!1,detect:{darwin:["/Applications/Cursor.app/Contents/Info.plist"],win32:["%LOCALAPPDATA%\\Programs\\cursor\\Cursor.exe"],linux:["/usr/share/cursor/resources/app/package.json","/opt/cursor/resources/app/package.json"]},version:{darwin:{strategy:"plist"},linux:{strategy:"pkgjson"},win32:{strategy:"none"}}},{key:"windsurf",displayName:"Windsurf",isCli:!1,detect:{darwin:["/Applications/Windsurf.app/Contents/Info.plist"],win32:["%LOCALAPPDATA%\\Programs\\Windsurf\\Windsurf.exe"],linux:["/usr/share/windsurf/resources/app/package.json","/opt/windsurf/resources/app/package.json"]},version:{darwin:{strategy:"plist"},linux:{strategy:"pkgjson"},win32:{strategy:"none"}}},{key:"ollama",displayName:"Ollama",isCli:!0,detect:{darwin:["/opt/homebrew/bin/ollama","/usr/local/bin/ollama","/Applications/Ollama.app/Contents/Info.plist"],win32:["%LOCALAPPDATA%\\Programs\\Ollama\\ollama.exe"],linux:["/usr/local/bin/ollama","/usr/bin/ollama"]},version:{darwin:{strategy:"exec-version"},linux:{strategy:"exec-version"},win32:{strategy:"none"}}},{key:"openai-codex",displayName:"OpenAI Codex",isCli:!0,detect:{darwin:["/Applications/Codex.app/Contents/Info.plist","~/.npm-global/bin/codex"]},version:{darwin:{strategy:"plist"}}},{key:"perplexity-desktop",displayName:"Perplexity Desktop",isCli:!1,detect:{darwin:["/Applications/Perplexity.app/Contents/Info.plist"]},version:{darwin:{strategy:"plist"}}},{key:"google-antigravity",displayName:"Google Antigravity",isCli:!1,detect:{darwin:["/Applications/Antigravity.app/Contents/Info.plist"]},version:{darwin:{strategy:"plist"}}},{key:"warp",displayName:"Warp",isCli:!1,detect:{darwin:["/Applications/Warp.app/Contents/Info.plist"]},version:{darwin:{strategy:"plist"}}},{key:"wispr-flow",displayName:"Wispr Flow",isCli:!1,detect:{darwin:["/Applications/Wispr Flow.app/Contents/Info.plist"]},version:{darwin:{strategy:"plist"}}},{key:"conductor",displayName:"Conductor",isCli:!1,detect:{darwin:["/Applications/Conductor.app/Contents/Info.plist"]},version:{darwin:{strategy:"plist"}}},{key:"lm-studio",displayName:"LM Studio",isCli:!1,detect:{darwin:["/Applications/LM Studio.app/Contents/Info.plist"],win32:["%LOCALAPPDATA%\\Programs\\lm-studio\\LM Studio.exe"]},version:{darwin:{strategy:"plist"},win32:{strategy:"none"}}}],qs=/\d+(?:\.\d+){1,4}/;function Qs(e,t){let n=e;return n.startsWith("~")&&(n=t+n.slice(1)),n=n.replace(/%([^%]+)%/g,(r,o)=>process.env[o]??""),n}function ei(e){if(!e.includes("*"))return Hs(e)?e:null;let t=zs(e),n=Ys(e),r=n.indexOf("*"),o=n.slice(0,r),s=n.slice(r+1),i;try{i=Js(t)}catch{return null}for(let a of i)if(a.startsWith(o)&&a.endsWith(s)&&a.length>=o.length+s.length)return Xs(t,a);return null}function ti(e){let t=e.replace(/\.plist$/,"");try{return le("defaults",["read",t,"CFBundleShortVersionString"],{encoding:"utf8",timeout:4e3,stdio:["ignore","pipe","ignore"]}).trim()}catch{return""}}function ni(e){try{let t=JSON.parse(Mn(e,"utf8"));return typeof t.version=="string"?t.version.trim():""}catch{return""}}function ri(e){try{let t=Ks(e);for(let n of t.split(/[/\\]/)){let r=n.match(/^\d+(?:\.\d+){1,4}$/);if(r)return r[0]}}catch{}return""}function oi(e){try{let n=le(e,["--version"],{encoding:"utf8",timeout:4e3,stdio:["ignore","pipe","ignore"]}).match(qs);return n?n[0]:""}catch{return""}}function si(e,t){switch(e){case"plist":return ti(t);case"pkgjson":return ni(t);case"symlink-version":return ri(t);case"exec-version":return oi(t);case"none":return""}}function ii(e,t){let n=[];for(let r of Zs){let o=r.detect[e];if(!o)continue;let s="";for(let l of o){let c=ei(Qs(l,t));if(c){s=c;break}}if(s==="")continue;let i=r.version[e],a=i?si(i.strategy,s):"";n.push({key:r.key,name:r.displayName,version:a,sourcePath:s})}return n.sort((r,o)=>r.name.localeCompare(o.name)),n}function ai(){try{let e=le("sw_vers",["-productName"],{encoding:"utf8",timeout:4e3}).trim(),t=le("sw_vers",["-productVersion"],{encoding:"utf8",timeout:4e3}).trim(),n=t.split(".")[0]??"";return{platform:n?`${e} ${n}`:e,version:t}}catch{return{platform:"macOS",version:G()}}}function ci(){try{let t=Mn("/etc/os-release","utf8").match(/^PRETTY_NAME="?([^"\n]+)"?/m);if(t&&t[1])return{platform:t[1],version:G()}}catch{}return{platform:"Linux",version:G()}}function li(){let e=G();return{platform:Number(e.split(".")[2]??"0")>=22e3?"Windows 11":"Windows 10",version:e}}function Fe(e){let t;return e==="darwin"?t=ai():e==="linux"?t=ci():e==="win32"?t=li():t={platform:e,version:G()},{osPlatform:t.platform,osVersion:t.version}}function ui(e){let t=Fe(e),n={platform:t.osPlatform,version:t.osVersion},r="";return e==="win32"&&(r=(process.env.USERDNSDOMAIN??process.env.USERDOMAIN??"").trim()),{hostname:w()||Gs(),osPlatform:n.platform,osVersion:n.version,deviceType:"Workstation",accountName:je(),accountDomain:r}}async function Y(e={}){let t=e.home??process.env.HOME??process.env.USERPROFILE??Bs(),n=process.platform,r=ii(n,t),o=ui(n);if(e.dryRun)return{agents:r.length,detected:r,host:o,uploaded:!1};let s=k(t),i=s.orchestratorUrl.replace(/\/$/,""),a=y(t),l=await fetch(`${i}/v1/inventory/agents`,{method:"POST",headers:b(s.orgId,s.apiKey),body:JSON.stringify({orgId:s.orgId,machineId:a,hostname:o.hostname,osPlatform:o.osPlatform,osVersion:o.osVersion,deviceType:o.deviceType,accountName:o.accountName,accountDomain:o.accountDomain,agents:r.map(c=>({key:c.key,name:c.name,version:c.version,sourcePath:c.sourcePath}))})});if(!l.ok){let c=await l.text();throw new Error(`scan-agents upload failed: ${l.status} ${c}`)}return{agents:r.length,detected:r,host:o,uploaded:!0}}import{readFileSync as di}from"node:fs";import{join as ue}from"node:path";function pi(e,t){let n;try{n=JSON.parse(di(e,"utf8"))}catch{return[]}let r=n.mcpServers;if(!r||typeof r!="object")return[];let o=[];for(let[s,i]of Object.entries(r)){if(!s||!i||typeof i!="object")continue;let a=i.url??i.serverUrl??"",l=(i.type??i.transport??"").toLowerCase(),c=a?l==="sse"?"sse":"streamable-http":"stdio";o.push({name:s,client:t,transport:c,command:i.command??"",args:Array.isArray(i.args)?i.args.map(String):[],url:a,sourcePath:e})}return o}function fi(e){let t=[{path:ue(e,".claude.json"),client:"Claude Code"},{path:ue(e,".cursor","mcp.json"),client:"Cursor"},{path:ue(e,".codeium","windsurf","mcp_config.json"),client:"Windsurf"},{path:ue(e,"Library","Application Support","Claude","claude_desktop_config.json"),client:"Claude Desktop"}],n=[];for(let r of t)n.push(...pi(r.path,r.client));return n.sort((r,o)=>r.name.localeCompare(o.name)||r.client.localeCompare(o.client)),n}function mi(e,t){let n=[],r={mode:"replace",servers:[]},o=JSON.stringify({servers:[]}).length;for(let s of e){let i=JSON.stringify(s).length+1;o+i>t&&r.servers.length>0&&(n.push(r),r={mode:"append",servers:[]},o=JSON.stringify({servers:[]}).length),r.servers.push(s),o+=i}return n.push(r),n}var gi=6e3;async function de(e){let t=e??process.env.HOME??process.env.USERPROFILE??"",n=k(t),r=fi(t),o=mi(r,gi),s=n.orchestratorUrl.replace(/\/$/,""),i=y(t),a=w();for(let l of o){let c=await fetch(`${s}/v1/inventory/mcp`,{method:"POST",headers:b(n.orgId,n.apiKey),body:JSON.stringify({orgId:n.orgId,machineId:i,hostname:a,mode:l.mode,servers:l.servers})});if(!c.ok){let u=await c.text();throw new Error(`scan-mcp upload failed: ${c.status} ${u}`)}}return{servers:r.length,chunks:o.length}}import{readdirSync as Vn,readFileSync as Wn}from"node:fs";import{join as C}from"node:path";function Le(e){try{return Vn(e,{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>t.name)}catch{return[]}}function hi(e,t){let n;try{n=Wn(C(e,"SKILL.md"),"utf8")}catch{return null}let r=n.match(/^---\s*\n([\s\S]*?)\n---/);if(!r)return{name:t,description:""};let o=r[1]??"",s=o.match(/^name:\s*(.+)$/m)?.[1]?.trim()??t,a=o.match(/^description:\s*(.+?)(?=\n\w+:|$)/ms)?.[1]?.trim().replace(/\s+/g," ")??"";return{name:s,description:a}}function jn(e,t,n){let r=[];for(let o of Le(e)){let s=C(e,o),i=hi(s,o);i&&r.push({name:i.name,description:i.description,source:t,pluginName:n,path:s})}return r}function Fn(e){let t=[...jn(C(e,"skills"),"user","")],n=[],r=C(e,"plugins","marketplaces");for(let o of Le(r)){let s=C(r,o,"plugins");for(let i of Le(s)){let a=C(s,i),l="",c=o;try{let f=JSON.parse(Wn(C(a,".claude-plugin","plugin.json"),"utf8"));l=f.description??"",c=f.author?.name??o}catch{}let u=jn(C(a,"skills"),"plugin",i);t.push(...u);let d=0;try{d=Vn(C(a,"commands"),{withFileTypes:!0}).filter(f=>f.name.endsWith(".md")).length}catch{}n.push({name:i,description:l,author:c,source:"marketplace",skillCount:u.length,commandCount:d})}}return t.sort((o,s)=>o.name.localeCompare(s.name)||o.pluginName.localeCompare(s.pluginName)),n.sort((o,s)=>o.name.localeCompare(s.name)),{skills:t,plugins:n}}function yi(e,t){let n=[],r={mode:"replace",skills:[],plugins:[]},o=JSON.stringify({skills:[],plugins:[]}).length,s=(i,a)=>{let l=JSON.stringify(i).length+1;o+l>t&&(r.skills.length>0||r.plugins.length>0)&&(n.push(r),r={mode:"append",skills:[],plugins:[]},o=JSON.stringify({skills:[],plugins:[]}).length),a==="skill"?r.skills.push(i):r.plugins.push(i),o+=l};for(let i of e.skills)s(i,"skill");for(let i of e.plugins)s(i,"plugin");return n.push(r),n}var Ln=6e3;async function pe(e){let t=e??process.env.HOME??process.env.USERPROFILE??"",n=k(t),r=Fn(C(t,".claude")),o=yi(r,Ln),s=n.orchestratorUrl.replace(/\/$/,""),i=y(t),a=w();for(let l of o){let c=await fetch(`${s}/v1/inventory/skills`,{method:"POST",headers:b(n.orgId,n.apiKey),body:JSON.stringify({orgId:n.orgId,machineId:i,hostname:a,mode:l.mode,skills:l.skills,plugins:l.plugins})});if(!c.ok){let u=await c.text();throw new Error(`scan-skills upload failed: ${c.status} ${u}`)}}return{uploaded:r.skills.length+r.plugins.length,skills:r.skills.length,plugins:r.plugins.length,chunks:o.length}}function vi(e,t,n){let r=n.risk_assessment?.recommendation??"",o=n.risk_assessment?.score??0;return(n.issues??[]).map(s=>({category:s.category??"uncategorized",severity:(s.severity??"low").toLowerCase(),title:s.finding??s.id??"finding",owaspMcp:"",skillName:e.name,recommendation:r,metadata:{rule_id:s.id??"",skill_name:e.name,plugin_name:e.pluginName,source_path:e.path,file:s.location?.file??"",start_line:s.location?.start_line??null,explanation:s.explanation??"",remediation:s.remediation??"",recommendation:r,risk_score:o,machine_id:t}}))}function Si(e,t){let n=[],r=[],o=0;for(let s of e){let i=JSON.stringify(s).length+1;o+i>t&&r.length>0&&(n.push(r),r=[],o=0),r.push(s),o+=i}return r.length>0&&n.push(r),n}async function wi(e){let{execFile:t}=await import("node:child_process"),{promisify:n}=await import("node:util"),r=n(t),o;try{({stdout:o}=await r("skillspector",["scan",e,"--format","json","--no-llm"],{timeout:18e4,maxBuffer:50*1024*1024}))}catch(s){if(o=s.stdout??"",!o)return null}try{return JSON.parse(o)}catch{return null}}async function Dn(e,t=wi){let n=e??process.env.HOME??process.env.USERPROFILE??"",r=k(n),o=Fn(C(n,".claude")),s=y(n),i=w(),a=[],l=0;for(let d of o.skills){if(!d.path)continue;let f=await t(d.path);f&&(l++,a.push(...vi(d,s,f)))}let c=r.orchestratorUrl.replace(/\/$/,""),u=Si(a,Ln);for(let d of u){let f=await fetch(`${c}/v1/inventory/skill-findings`,{method:"POST",headers:b(r.orgId,r.apiKey),body:JSON.stringify({orgId:r.orgId,machineId:s,hostname:i,findings:d})});if(!f.ok){let v=await f.text();throw new Error(`scan-skills findings upload failed: ${f.status} ${v}`)}}return{skillsScanned:l,findings:a.length,chunks:u.length}}import{execFile as ki,spawn as Ci}from"node:child_process";import{existsSync as xi,readFileSync as bi,writeFileSync as Pi}from"node:fs";import{delimiter as Hn,dirname as Kn,join as De}from"node:path";var Oi=1440*60*1e3,Ii=2e3,Ei=6e4,Ri=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;function Bn(e){return De(e,".venos","update-check.json")}function Ti(e){try{let t=JSON.parse(bi(Bn(e),"utf8"));if(typeof t.checkedAt=="number"&&t.policy&&typeof t.policy.mode=="string")return t}catch{}return null}function Ai(e,t){try{Pi(Bn(e),JSON.stringify(t))}catch{}}function Jn(e){let t=/^(\d+)\.(\d+)\.(\d+)/.exec(e.trim());return t?[Number(t[1]),Number(t[2]),Number(t[3])]:null}function _i(e,t){let n=Jn(e),r=Jn(t);if(!n||!r)return!1;for(let o=0;o<3;o++){if(n[o]>r[o])return!0;if(n[o]<r[o])return!1}return!1}async function Ui(e,t,n,r){let s=`${e.replace(/\/$/,"")}/api/cli/policy?orgId=${encodeURIComponent(t)}`;r&&r.trim()!==""&&(s+=`&machineId=${encodeURIComponent(r)}`);try{let i=await n(s,{signal:AbortSignal.timeout(Ii)});if(!i.ok)return null;let a=await i.json();return{mode:typeof a.mode=="string"&&a.mode!==""?a.mode:"notify",latest:typeof a.latest=="string"?a.latest.trim():"",pinnedVersion:typeof a.pinnedVersion=="string"?a.pinnedVersion.trim():""}}catch{return null}}function Ni(e,t){if(e.mode==="off")return null;if(e.mode==="pinned"){let n=e.pinnedVersion;return n===""||n===t?null:{kind:"notify",targetVersion:n,message:`venos: your organization pins venos to ${n} (you have ${t}).
|
|
110
|
+
Install it with: npm i -g @venos-inc/venos@${n}`}}return _i(e.latest,t)?e.mode==="auto"?{kind:"auto",targetVersion:e.latest,message:`venos: auto-updating ${t} -> ${e.latest} per your organization's policy...`}:{kind:"notify",targetVersion:e.latest,message:`venos: a newer version is available (${t} -> ${e.latest}).
|
|
111
|
+
Update with: npm i -g @venos-inc/venos@latest`}:null}async function He(e){let t=e.now??Date.now(),n=e.fetchImpl??fetch,r,o=e.bypassCache?null:Ti(e.home);if(o&&t-o.checkedAt<Oi)r=o.policy;else{if(r=await Ui(e.orchestratorUrl,e.orgId,n,e.machineId),r===null)return null;Ai(e.home,{checkedAt:t,policy:r})}return Ni(r,e.currentVersion)}function $i(e=process.env,t=process.execPath){let n=Kn(t),r=e.PATH??"";return r===""?{...e,PATH:n}:r.split(Hn).includes(n)?{...e,PATH:r}:{...e,PATH:`${n}${Hn}${r}`}}var Mi=(e,t)=>new Promise((n,r)=>{ki(e,t,{timeout:Ei,env:$i()},o=>{o?r(o):n()})});function ji(e=process.execPath,t=xi){let n=Kn(e),r=[De(n,"node_modules","npm","bin","npm-cli.js"),De(n,"..","lib","node_modules","npm","bin","npm-cli.js")];for(let o of r)if(t(o))return o;return null}function Vi(e,t,n=process.execPath){if(!Ri.test(e))return null;let r=`@venos-inc/venos@${e}`;return t!==null?{cmd:n,args:[t,"install","-g",r]}:{cmd:"npm",args:["install","-g",r]}}async function Je(e,t=Mi){let n=Vi(e,ji());if(n===null)return!1;try{return await t(n.cmd,n.args),!0}catch{return!1}}function Wi(){let e=process.argv[1]??"";if(e!=="")try{Ci(process.execPath,[e,"heartbeat"],{detached:!0,stdio:"ignore",env:{...process.env,VENOS_SKIP_AUTOUPDATE:"1"}}).unref()}catch{}}async function Gn(e,t=Je,n=Wi){try{let r=await He({...e,bypassCache:!0});return!r||r.kind!=="auto"||!await t(r.targetVersion)?null:(n(),r.targetVersion)}catch{return null}}function Hi(e,t){let n=typeof t.orgId=="string"&&t.orgId.trim()!==""&&typeof t.orchestratorUrl=="string"&&t.orchestratorUrl.trim()!=="",r="";try{r=te()}catch{}let o={orgId:t.orgId,orchestratorUrl:t.orchestratorUrl,mcpServerPath:r,hookCommand:"venos hook",usageSyncCommand:"venos usage-sync --throttle",...t.apiKey?{apiKey:t.apiKey}:{}},s=!1,i=!1;for(let c of J)if(c.isInstalled(e)){s=!0;try{c.isWired(c.load(c.configPath(e)),o)&&(i=!0)}catch{}}let a=!s||i,l=nn(e);return{config_valid:n,hooks_wired:a,service_installed:l}}async function Xn(e={},t){let n=t??process.env.HOME??process.env.USERPROFILE??"",r=zn(n,".venos","config.json");if(!Fi(r))return{machineId:"",status:"skipped-no-config",checks:{}};let o=JSON.parse(Li(r,"utf8")),s=e.orgId??o.orgId,i=e.orchestratorUrl??o.orchestratorUrl,a=e.apiKey??o.apiKey,l=y(n),c=w(),u=Hi(n,o),{osPlatform:d,osVersion:f}=Fe(process.platform),v={orgId:s,machineId:l,hostname:c,cliVersion:e.cliVersion??"",osPlatform:d,osVersion:f,checks:u},E=`${i.replace(/\/$/,"")}/v1/inventory/heartbeat?orgId=${encodeURIComponent(s)}`,P={"Content-Type":"application/json","X-Venos-Org":s};a&&(P.Authorization=`Bearer ${a}`);let O=await N(E,{method:"POST",headers:P,body:JSON.stringify(v)},{timeoutMs:5e3});if(!O.ok)throw new Error(`venos heartbeat: orchestrator returned ${O.status}`);try{Yn(Zn(n),new Date().toISOString())}catch{}let V=e.cliVersion??"";return V!==""&&process.env.VENOS_SKIP_AUTOUPDATE!=="1"&&await Gn({currentVersion:V,orchestratorUrl:i,orgId:s,home:n,machineId:l}),{machineId:l,status:"sent",checks:u}}function Zn(e){return zn(e,".venos","heartbeat.last")}async function qn(e){let t=[["scan-mcp",()=>de(e)],["scan-skills",()=>pe(e)],["scan-agents",()=>Y({home:e})],["scan-documents",()=>se({home:e})]];for(let[n,r]of t)try{await r()}catch(o){let s=o instanceof Error?o.message:String(o);process.stderr.write(`venos heartbeat: ${n} inventory refresh skipped (${s})
|
|
112
|
+
`)}}function Ke(e,t=60,n=Di){let r=e??process.env.HOME??process.env.USERPROFILE??"",o=Zn(r);if(!We(o,t*6e4,Date.now()))return{ran:!1,reason:"throttled"};try{Yn(o,new Date().toISOString())}catch{}let s=process.argv[1]??"";return n(process.execPath,[s,"heartbeat"],{detached:!0,stdio:"ignore"}).unref(),{ran:!0,reason:"spawned"}}var Be="0.1.11";async function Qn(){try{let e=JSON.parse(Ji(B(j()),"utf8"));if(!e.orchestratorUrl||!e.orgId)return;let t=await He({currentVersion:Be,orchestratorUrl:e.orchestratorUrl,orgId:e.orgId,home:j(),machineId:y(j())});if(!t)return;if(t.kind==="auto"){process.stderr.write(`
|
|
121
113
|
${t.message}
|
|
122
|
-
`);let
|
|
114
|
+
`);let n=await Je(t.targetVersion);process.stderr.write(n?`venos: updated to ${t.targetVersion}. Re-run venos to use it.
|
|
123
115
|
`:`venos: auto-update failed. Install manually: npm i -g @venos-inc/venos@${t.targetVersion}
|
|
124
116
|
`);return}process.stderr.write(`
|
|
125
117
|
${t.message}
|
|
126
|
-
`)}catch{}}var
|
|
118
|
+
`)}catch{}}var er=`Usage: venos <command> [options]
|
|
127
119
|
|
|
128
120
|
Commands:
|
|
129
121
|
init Wire your AI client(s) to the venos security gateway
|
|
@@ -138,27 +130,31 @@ Commands:
|
|
|
138
130
|
help Show this help
|
|
139
131
|
|
|
140
132
|
Options (init):
|
|
141
|
-
--orchestrator <url>
|
|
142
|
-
--api-key <key> Per-customer API key (venos_*) for the
|
|
143
|
-
--org <orgId> Tenant org id to pin (
|
|
144
|
-
bound to on
|
|
133
|
+
--orchestrator <url> (required) Gateway base URL
|
|
134
|
+
--api-key <key> (required) Per-customer API key (venos_*) for the gateway
|
|
135
|
+
--org <orgId> (required) Tenant org id to pin (the org your API key is
|
|
136
|
+
bound to on the gateway)
|
|
145
137
|
--json Emit machine-readable JSON instead of the human summary
|
|
146
138
|
--no-telemetry Skip activation ping even on a non-localhost URL
|
|
147
139
|
--remove Inverse of init \u2014 drop the venos entry from every
|
|
148
140
|
wired client's config and delete ~/.venos/config.json.
|
|
149
141
|
Pre-venos .venos-backup snapshots are preserved.
|
|
150
|
-
`;function
|
|
151
|
-
|
|
152
|
-
`);
|
|
153
|
-
`);break}case"
|
|
154
|
-
`);break}let r=await $r
|
|
155
|
-
`);break}case"scan-
|
|
156
|
-
`);break}
|
|
157
|
-
`);break}let
|
|
158
|
-
`);break}case"
|
|
159
|
-
`);break}let
|
|
142
|
+
`;function x(e,t){let n=e.indexOf(t);if(!(n===-1||n+1>=e.length))return e[n+1]}function I(e,t){return e.includes(t)}async function Ki(){let e=process.argv.slice(2),t=e[0];switch(t){case"init":{if(I(e,"--remove")){fn({json:I(e,"--json")});break}let n=x(e,"--orchestrator"),r=x(e,"--api-key"),o=x(e,"--org"),s=dn({orchestratorUrl:n,apiKey:r,orgId:o});s.length>0&&(console.error(`venos init: missing required flag(s): ${s.join(", ")}`),console.error(`
|
|
143
|
+
All three connection flags are required:
|
|
144
|
+
venos init --orchestrator <gateway-url> --api-key venos_xxx --org org-xxxx`),process.exit(1));let i=I(e,"--json");await pn({orchestratorUrl:n,apiKey:r,orgId:o,json:i,noTelemetry:I(e,"--no-telemetry")}),i||await Qn();break}case"hook":{let n=x(e,"--source");await Rn(void 0,n??"claude-code");break}case"waste-scan":{let n=await Un();process.stdout.write(`venos waste-scan: ${n.sessionsScanned} session(s) scanned, ${n.findingsStored} finding(s) reported
|
|
145
|
+
`);break}case"usage-sync":{if(I(e,"--throttle")){let i=Nn();Ke(),process.stdout.write(`venos usage-sync --throttle: ${i.reason}
|
|
146
|
+
`);break}let n=x(e,"--org"),r=x(e,"--orchestrator"),o=x(e,"--api-key"),s=await $n({...n!==void 0?{orgId:n}:{},...r!==void 0?{orchestratorUrl:r}:{},...o!==void 0?{apiKey:o}:{}});process.stdout.write(`venos usage-sync: ${s.sessionsScanned} session(s) scanned, ${s.sessionsStored} stored
|
|
147
|
+
`);break}case"scan-skills":{if(I(e,"--scan")){let r=await Dn();process.stdout.write(`venos scan-skills --scan: ${r.findings} finding(s) from ${r.skillsScanned} skill(s) reported in ${r.chunks} chunk(s)
|
|
148
|
+
`);break}let n=await pe();process.stdout.write(`venos scan-skills: ${n.skills} skill(s) + ${n.plugins} plugin(s) reported
|
|
149
|
+
`);break}case"scan-mcp":{let n=await de();process.stdout.write(`venos scan-mcp: ${n.servers} MCP server(s) reported in ${n.chunks} chunk(s)
|
|
150
|
+
`);break}case"scan-agents":{if(I(e,"--dry-run")){let r=await Y({dryRun:!0});process.stdout.write(JSON.stringify(r,null,2)+`
|
|
151
|
+
`);break}let n=await Y();process.stdout.write(`venos scan-agents: ${n.agents} local AI agent(s) reported
|
|
152
|
+
`);break}case"scan-documents":{let n=await se({home:j()});process.stdout.write(n.reason==="not-configured"?`venos scan-documents: not configured (set dspmScan.dirs in ~/.venos/config.json)
|
|
153
|
+
`:`venos scan-documents: ${n.classified} document(s) classified, ${n.skipped} skipped of ${n.scanned} scanned
|
|
154
|
+
`);break}case"classify-file":{let n=e[0];n&&await Cn(j(),n);break}case"heartbeat":{if(I(e,"--throttle")){let i=Ke();process.stdout.write(`venos heartbeat --throttle: ${i.reason}
|
|
155
|
+
`);break}let n=x(e,"--org"),r=x(e,"--orchestrator"),o=x(e,"--api-key"),s=await Xn({cliVersion:Be,...n!==void 0?{orgId:n}:{},...r!==void 0?{orchestratorUrl:r}:{},...o!==void 0?{apiKey:o}:{}});process.stdout.write(s.status==="sent"?`venos heartbeat: reported (${s.machineId.slice(0,12)})
|
|
160
156
|
`:`venos heartbeat: no config \u2014 run "venos init" first
|
|
161
|
-
`)
|
|
162
|
-
`),process.exit(0);break;case"help":case void 0:process.stdout.write(
|
|
163
|
-
${
|
|
157
|
+
`),s.status==="sent"&&n===void 0&&r===void 0&&o===void 0&&await qn(j());break}case"version":case"--version":case"-v":process.stdout.write(`${Be}
|
|
158
|
+
`),process.exit(0);break;case"help":case void 0:process.stdout.write(er),await Qn(),process.exit(0);break;default:process.stderr.write(`Unknown subcommand: ${t}
|
|
159
|
+
${er}`),process.exit(2)}}try{await Ki()}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`venos: ${t}
|
|
164
160
|
`),process.exit(1)}
|