@venos-inc/venos 0.1.11 → 0.1.12
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 +6 -4
- package/dist/index.js +47 -45
- 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/eslintrc/node_modules/.bin/js-yaml +2 -2
- 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/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,9 +28,11 @@ venos init --orchestrator https://gateway.your-org.venos.ai --api-key venos_xxx
|
|
|
28
28
|
```
|
|
29
29
|
|
|
30
30
|
`venos init` detects the AI clients installed on your machine and wires each one
|
|
31
|
-
to the gateway.
|
|
32
|
-
errors out if
|
|
33
|
-
|
|
31
|
+
to the gateway. **`--orchestrator` and `--org` are always required** —
|
|
32
|
+
`venos init` errors out if either is missing rather than guessing a default, so
|
|
33
|
+
the CLI is never half-configured. `--api-key` is required for a hosted gateway
|
|
34
|
+
but not for a localhost orchestrator (the local `make dev` stack, which is
|
|
35
|
+
unauthenticated). It is safe to re-run; it only adds what is missing. The API key
|
|
34
36
|
(issued to you by venos) is stored in `~/.venos/config.json` and sent on every
|
|
35
37
|
request. Always pass `--org` with the org id your key is bound to: the gateway
|
|
36
38
|
rejects events whose org does not match the key.
|
|
@@ -40,7 +42,7 @@ Options:
|
|
|
40
42
|
| Flag | Effect |
|
|
41
43
|
|---|---|
|
|
42
44
|
| `--orchestrator <url>` | (required) Gateway base URL |
|
|
43
|
-
| `--api-key <key>` |
|
|
45
|
+
| `--api-key <key>` | Per-customer API key (`venos_*`) for the gateway. Required for a hosted gateway; not needed for a localhost orchestrator |
|
|
44
46
|
| `--org <orgId>` | (required) Tenant org id to pin (the org your API key is bound to) |
|
|
45
47
|
| `--json` | Emit machine-readable JSON instead of the human summary |
|
|
46
48
|
| `--no-telemetry` | Skip the activation ping |
|
package/dist/index.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{readFileSync as Ji}from"node:fs";import{homedir as j}from"node:os";import{existsSync as un,mkdirSync as
|
|
3
|
-
`}var W="http://127.0.0.1:4000/v1";var ze="venos",
|
|
2
|
+
import{readFileSync as Ji}from"node:fs";import{homedir as j}from"node:os";import{existsSync as un,mkdirSync as Io,readFileSync as Eo,rmSync as Ro,writeFileSync as To}from"node:fs";import{dirname as Ao,join as _o}from"node:path";import{randomBytes as Uo}from"node:crypto";import{existsSync as cr,readFileSync as lr}from"node:fs";import{join as ur}from"node:path";import{copyFileSync as rr,existsSync as Ge,mkdirSync as or,renameSync as sr,writeFileSync as ir}from"node:fs";import{dirname as ar}from"node:path";var Ye=".venos-backup";function m(e,t){or(ar(e),{recursive:!0}),Ge(e)&&!Ge(e+Ye)&&rr(e,e+Ye);let n=e+".tmp";ir(n,t,{mode:420}),sr(n,e)}function g(e){return JSON.stringify(e,null,2)+`
|
|
3
|
+
`}var W="http://127.0.0.1:4000/v1";var ze="venos",dr="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 ur(e,".claude","settings.json")},isInstalled(e){return!0},load(e){if(!cr(e))return{};try{return JSON.parse(lr(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??dr)}}},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 pr}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(pr(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 Ir}from"node:fs";import{join as ot}from"node:path";function fr(e,t){let n=e.slice(0,t).split(/\r\n|\n|\r/g);return[n.length,n.pop().length+1]}function mr(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
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]=
|
|
5
|
+
`))}return o}var p=class extends Error{line;column;codeblock;constructor(t,n){let[r,o]=fr(n.toml,n.ptr),s=mr(n.toml,r,o);super(`Invalid TOML document: ${t}
|
|
6
6
|
|
|
7
|
-
${s}`,n),this.line=r,this.column=o,this.codeblock=s}};function
|
|
7
|
+
${s}`,n),this.line=r,this.column=o,this.codeblock=s}};function gr(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
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
9
|
`)return n;if(r==="\r"&&e[n+1]===`
|
|
10
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
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 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!=="'"&&
|
|
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!=="'"&&gr(e,t));return t>-1&&(t+=r.length,r.length>1&&(e[t]===n&&t++,e[t]===n&&t++)),t}var hr=/^(\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(hr);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 yr=/^((0x[0-9a-fA-F](_?[0-9a-fA-F])*)|(([+-]|0[ob])?\d(_?\d)*))$/,vr=/^[+-]?\d(_?\d)*(\.\d(_?\d)*)?([eE][+-]?\d(_?\d)*)?$/,Sr=/^[+-]?0[0-9_]/,wr=/^[0-9a-f]{2,8}$/i,qe={b:"\b",t:" ",n:`
|
|
15
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
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 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(!
|
|
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(!wr.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
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=
|
|
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=
|
|
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=yr.test(e);if(o||vr.test(e)){if(Sr.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 kr(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=kr(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 Cr=/^[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(!Cr.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
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
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
|
|
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 xr(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 br(e,n,r);if(t==="array")return Pr(e,n,r)}function br(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 Pr(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 Or(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+=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"&&
|
|
27
|
-
`)+
|
|
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"&&xr(t[c]))i+=(i&&`
|
|
27
|
+
`)+Or(t[c],n?`${n}.${d}`:d,r-1,o);else if(u==="object"){let f=n?`${n}.${d}`:d;i+=(i&&`
|
|
28
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
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
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(
|
|
34
|
-
`)}};import{existsSync as at,readFileSync as
|
|
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(Ir(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 Er}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 Rr(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(Er(e,"utf8"))}catch{return{}}},isWired(e){return be(e.hooks?.PreToolUse)&&be(e.hooks?.PostToolUse)},inject(e,t){let n=e.hooks??{},r=Rr(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 Tr}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(Tr(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 Ar}from"node:fs";import{join as T}from"node:path";var ht="saoudrizwan.claude-dev",_r="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",_r)},isInstalled(e){return Oe(T(yt(e),"globalStorage",ht))},load(e){if(!Oe(e))return{};try{return JSON.parse(Ar(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 Ur}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(Ur(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 Nr}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(Nr(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 $r,rmSync as Mr}from"node:fs";import{join as jr}from"node:path";var Vr="openai-api-base",Wr=".aider.conf.yml";function It(){return`${Vr}: ${W}`}function Fr(e){return/^\s*openai-api-base\s*:/.test(e)}var Et={name:"aider",transport:"mcp-json",configPath(e){return jr(e,Wr)},isInstalled(){return!0},load(e){let t=Ot(e)?$r(e,"utf8"):"";return{wired:t.split(`
|
|
35
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=>!
|
|
36
|
+
`);n.length>0&&n[n.length-1]===""&&n.pop();let r=n.filter(s=>!Fr(s)),o=t.wired?[...r,It()]:r;if(o.length===0){Ot(e)&&Mr(e,{force:!0});return}m(e,o.join(`
|
|
37
37
|
`)+`
|
|
38
|
-
`)}};import{accessSync as
|
|
38
|
+
`)}};import{accessSync as Lr,constants as Dr,existsSync as Tt,readFileSync as Hr}from"node:fs";import{delimiter as Jr}from"node:path";import{join as At}from"node:path";var Kr="obsidian-cli",Br="obsidian-cli.json";function Gr(e){try{return Lr(e,Dr.X_OK),!0}catch{return!1}}function Yr(e){return(process.env.PATH??"").split(Jr).some(n=>{if(n.trim()==="")return!1;let r=At(n,e);return Tt(r)&&Gr(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",Br)},isInstalled(){return Yr(Kr)},load(e){if(!Tt(e))return{};try{return JSON.parse(Hr(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 zr,join as Ut,resolve as Te}from"node:path";import{fileURLToPath as Xr}from"node:url";var Nt=zr(Xr(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
41
|
sibling: ${n}
|
|
42
|
-
If you are developing locally, run: pnpm --filter @venos/mcp-server build`)}import{existsSync as
|
|
43
|
-
`,"utf8")}function _(e){let t=_e(e);return Lt(t)?(
|
|
42
|
+
If you are developing locally, run: pnpm --filter @venos/mcp-server build`)}import{existsSync as Zr}from"node:fs";function qr(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=>qr(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(!Zr(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 eo,readFileSync as to}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(to(n,"utf8"));o&&typeof o=="object"&&(r=o)}catch{}return r[Wt]===W?{status:"already-wired",path:n}:(eo(t,{recursive:!0}),m(n,g({...r,[Wt]:W})),{status:"wired",path:n})}import{execFileSync as ko}from"node:child_process";import{existsSync as Dt,mkdirSync as co,rmSync as lo,writeFileSync as uo}from"node:fs";import{dirname as po,join as fo}from"node:path";var Ae="ai.venos.agent";import{existsSync as Lt,mkdirSync as no,rmSync as ro,writeFileSync as oo}from"node:fs";import{dirname as so,join as io}from"node:path";function _e(e){return io(e,".venos","service.json")}function A(e,t){let n=_e(e);no(so(n),{recursive:!0}),oo(n,JSON.stringify(t,null,2)+`
|
|
43
|
+
`,"utf8")}function _(e){let t=_e(e);return Lt(t)?(ro(t,{force:!0}),!0):!1}function U(e){return Lt(_e(e))}function Ht(e){return fo(e,"Library","LaunchAgents",`${Ae}.plist`)}function mo(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>
|
|
@@ -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 Jt={platform:"darwin",install(e){let t=Ht(e.home);try{let n=Dt(t);
|
|
72
|
+
`}var Jt={platform:"darwin",install(e){let t=Ht(e.home);try{let n=Dt(t);co(po(t),{recursive:!0}),uo(t,mo(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:go(n)}}},remove(e,t){let n=Ht(e),r=Dt(n);try{t("launchctl",["unload",n])}catch{}r&&lo(n,{force:!0});let o=_(e);return{platform:"darwin",status:r||o?"removed":"already-removed",path:n}}};function go(e){return e instanceof Error?e.message:String(e)}import{existsSync as ne,mkdirSync as ho,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 yo(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 vo(){return`[Unit]
|
|
81
81
|
Description=venos endpoint heartbeat (hourly)
|
|
82
82
|
|
|
83
83
|
[Timer]
|
|
@@ -87,35 +87,35 @@ Persistent=true
|
|
|
87
87
|
|
|
88
88
|
[Install]
|
|
89
89
|
WantedBy=timers.target
|
|
90
|
-
`}var zt={platform:"linux",install(e){let t=Yt(e.home),n=K(t,re);try{let r=ne(n);return
|
|
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=
|
|
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`)}
|
|
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
|
|
94
|
-
venos init --remove ${n?"done":"(no changes)"}`);for(let s of e){let i=
|
|
95
|
-
`,"utf8")}var
|
|
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
|
|
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
|
|
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 ho(t,{recursive:!0}),Bt(K(t,Gt),yo(e.nodePath,e.cliEntry),"utf8"),Bt(n,vo(),"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:So(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 So(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:wo(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 wo(e){return e instanceof Error?e.message:String(e)}var Zt=[Jt,zt,Xt],qt=(e,t)=>{try{ko(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 Co={wired:"OK","already-wired":"\xB7","skipped-not-installed":"\u2014",error:"FAIL"},xo={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=Co[r.status],s=xo[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`)}bo(t.clineWorkspace)}function bo(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 Po={removed:"OK","already-removed":"\xB7","skipped-not-installed":"\u2014",error:"FAIL"},Oo={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=Po[s.status],a=Oo[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 _o(e,".venos","config.json")}function No(){return`org-${Uo(4).toString("hex")}`}function $o(e,t,n,r){let o=B(e);if(un(o))try{let s=JSON.parse(Eo(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??No(),orchestratorUrl:t,createdAt:new Date().toISOString(),failMode:"closed",...n?{apiKey:n}:{}}}function Mo(e,t){let n=B(e);Io(Ao(n),{recursive:!0}),To(n,JSON.stringify(t,null,2)+`
|
|
95
|
+
`,"utf8")}var jo=5e3,Vo=5e3;async function Wo(e){let t=e.replace(/\/$/,""),n=new AbortController,r=setTimeout(()=>n.abort(),jo);try{return(await fetch(`${t}/healthz`,{signal:n.signal})).ok}catch{return!1}finally{clearTimeout(r)}}async function Fo(e,t){let n=e.replace(/\/$/,""),r=new AbortController,o=setTimeout(()=>r.abort(),Vo);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 dn(e){try{let t=new URL(e);return t.hostname==="localhost"||t.hostname==="127.0.0.1"||t.hostname==="::1"}catch{return!1}}function pn(e){let t=[];return e.orchestratorUrl?.trim()||t.push("--orchestrator"),!e.apiKey?.trim()&&!dn(e.orchestratorUrl??"")&&t.push("--api-key"),e.orgId?.trim()||t.push("--org"),t}async function fn(e){let t=e.home??process.env.HOME??process.env.USERPROFILE??"",n=e.orchestratorUrl;await Wo(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=$o(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);Mo(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||dn(n)||!!r.apiKey||await Fo(n,r.orgId);let c={orgId:r.orgId,orchestratorUrl:n,clineWorkspace:i,...a?{service:a}:{}};e.json?sn(s,c):on(s,c)}function mn(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&&Ro(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 On}from"node:child_process";import{randomBytes as In}from"node:crypto";import{dirname as ls,join as En}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 hn,readdirSync as Ko,statSync as Bo,writeFileSync as Go}from"node:fs";import{dirname as Yo,extname as zo,join as yn,resolve as gn,sep as Xo}from"node:path";var Zo=new Set([".pdf",".png",".jpg",".jpeg",".xlsx",".xlsm",".xls"]),vn=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 vn)if(t.includes(`/${r}/`)||t.includes(`\\${r}\\`))return!1;return(t.split(/[/\\]/).pop()??"").startsWith(".env")?!1:Zo.has(zo(t))}function $e(e){return yn(e,".venos","dspm-scanned.json")}function Sn(e){try{let t=hn($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 wn(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 kn(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=hn(n)}catch{return"skipped-missing"}let c=ts(l),u=e.seen===void 0,d=e.seen??Sn(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&&wn(t,d),"classified")}function Cn(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=yn(e,o.name);if(o.isDirectory()){if(vn.has(o.name))continue;Cn(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=Sn(t),l=[];for(let d of r)Ho(d)&&Cn(d,l,Number.MAX_SAFE_INTEGER);let c=0,u=0;for(let d of l){if(c>=o)break;await kn({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 wn(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=gn(e);for(let r of t){let o=gn(r);if(n===o||n.startsWith(o+Xo))return!0}return!1}async function xn(e,t){try{let n=k(e);return await kn({home:e,filePath:t,source:"hook-realtime",config:n,machineId:y(e),hostname:w()})}catch{return"skipped-missing"}}function bn(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 En(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=On("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===""?"":En(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=In(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 On("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 Rn(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(!Rn(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 Tn(e,t="claude-code"){let n=e??process.env.HOME??process.env.USERPROFILE??"",r=k(n),o=await ds();try{bn(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=In(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,Pn(t,s,r);return}if(Rn(f.status)){await f.text(),await d,Pn(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 Pn(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 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
|
|
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 Un}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 An(){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:
|
|
102
102
|
VENOS_SESSION_WASTE_PATH=${e??"(unset)"}
|
|
103
103
|
bundled: ${t}
|
|
104
104
|
sibling: ${n}
|
|
105
|
-
If you are developing locally, run: pnpm --filter @venos/session-waste build`)}function
|
|
105
|
+
If you are developing locally, run: pnpm --filter @venos/session-waste build`)}function _n(){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:
|
|
106
106
|
VENOS_USAGE_AGGREGATOR_PATH=${e??"(unset)"}
|
|
107
107
|
bundled: ${t}
|
|
108
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}).
|
|
109
|
+
If you are developing locally, run: pnpm --filter @venos/session-waste build`)}var As=Ts(Rs);async function Nn(e){let t=e??process.env.HOME??process.env.USERPROFILE??"",n=Un(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=An(),s=Un(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 $n(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 Mn(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=_n(),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 nr=await fe.json();O+=nr.sessionsStored??V.sessions.length}return{sessionsScanned:d.sessionsScanned??0,sessionsStored:O}}import{existsSync as Fi,readFileSync as Li,writeFileSync as zn}from"node:fs";import{join as Xn}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 jn,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(jn(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=jn("/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 Wn,readFileSync as Fn}from"node:fs";import{join as C}from"node:path";function Le(e){try{return Wn(e,{withFileTypes:!0}).filter(t=>t.isDirectory()).map(t=>t.name)}catch{return[]}}function hi(e,t){let n;try{n=Fn(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 Vn(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 Ln(e){let t=[...Vn(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(Fn(C(a,".claude-plugin","plugin.json"),"utf8"));l=f.description??"",c=f.author?.name??o}catch{}let u=Vn(C(a,"skills"),"plugin",i);t.push(...u);let d=0;try{d=Wn(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 Dn=6e3;async function pe(e){let t=e??process.env.HOME??process.env.USERPROFILE??"",n=k(t),r=Ln(C(t,".claude")),o=yi(r,Dn),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 Hn(e,t=wi){let n=e??process.env.HOME??process.env.USERPROFILE??"",r=k(n),o=Ln(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,Dn);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 Jn,dirname as Bn,join as De}from"node:path";var Oi=1440*60*1e3,Ii=2e3,Ei=6e4,Ri=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?$/;function Gn(e){return De(e,".venos","update-check.json")}function Ti(e){try{let t=JSON.parse(bi(Gn(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(Gn(e),JSON.stringify(t))}catch{}}function Kn(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=Kn(e),r=Kn(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
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=
|
|
112
|
-
`)}}function Ke(e,t=60,n=Di){let r=e??process.env.HOME??process.env.USERPROFILE??"",o=
|
|
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=Bn(t),r=e.PATH??"";return r===""?{...e,PATH:n}:r.split(Jn).includes(n)?{...e,PATH:r}:{...e,PATH:`${n}${Jn}${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=Bn(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 Yn(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 Zn(e={},t){let n=t??process.env.HOME??process.env.USERPROFILE??"",r=Xn(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{zn(qn(n),new Date().toISOString())}catch{}let V=e.cliVersion??"";return V!==""&&process.env.VENOS_SKIP_AUTOUPDATE!=="1"&&await Yn({currentVersion:V,orchestratorUrl:i,orgId:s,home:n,machineId:l}),{machineId:l,status:"sent",checks:u}}function qn(e){return Xn(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=qn(r);if(!We(o,t*6e4,Date.now()))return{ran:!1,reason:"throttled"};try{zn(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.12";async function er(){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(`
|
|
113
113
|
${t.message}
|
|
114
114
|
`);let n=await Je(t.targetVersion);process.stderr.write(n?`venos: updated to ${t.targetVersion}. Re-run venos to use it.
|
|
115
115
|
`:`venos: auto-update failed. Install manually: npm i -g @venos-inc/venos@${t.targetVersion}
|
|
116
116
|
`);return}process.stderr.write(`
|
|
117
117
|
${t.message}
|
|
118
|
-
`)}catch{}}var
|
|
118
|
+
`)}catch{}}var tr=`Usage: venos <command> [options]
|
|
119
119
|
|
|
120
120
|
Commands:
|
|
121
121
|
init Wire your AI client(s) to the venos security gateway
|
|
@@ -131,7 +131,9 @@ Commands:
|
|
|
131
131
|
|
|
132
132
|
Options (init):
|
|
133
133
|
--orchestrator <url> (required) Gateway base URL
|
|
134
|
-
--api-key <key>
|
|
134
|
+
--api-key <key> Per-customer API key (venos_*) for the gateway. Required
|
|
135
|
+
for a hosted gateway; not needed for a localhost
|
|
136
|
+
orchestrator (the local "make dev" stack).
|
|
135
137
|
--org <orgId> (required) Tenant org id to pin (the org your API key is
|
|
136
138
|
bound to on the gateway)
|
|
137
139
|
--json Emit machine-readable JSON instead of the human summary
|
|
@@ -139,22 +141,22 @@ Options (init):
|
|
|
139
141
|
--remove Inverse of init \u2014 drop the venos entry from every
|
|
140
142
|
wired client's config and delete ~/.venos/config.json.
|
|
141
143
|
Pre-venos .venos-backup snapshots are preserved.
|
|
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")){
|
|
144
|
+
`;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")){mn({json:I(e,"--json")});break}let n=x(e,"--orchestrator"),r=x(e,"--api-key"),o=x(e,"--org"),s=pn({orchestratorUrl:n,apiKey:r,orgId:o});s.length>0&&(console.error(`venos init: missing required flag(s): ${s.join(", ")}`),console.error(`
|
|
143
145
|
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
|
|
145
|
-
`);break}case"usage-sync":{if(I(e,"--throttle")){let i
|
|
146
|
-
`);break}let n=x(e,"--org"),r=x(e,"--orchestrator"),o=x(e,"--api-key"),s=await
|
|
147
|
-
`);break}case"scan-skills":{if(I(e,"--scan")){let r=await
|
|
146
|
+
venos init --orchestrator <gateway-url> --api-key venos_xxx --org org-xxxx`),process.exit(1));let i=I(e,"--json");await fn({orchestratorUrl:n,apiKey:r,orgId:o,json:i,noTelemetry:I(e,"--no-telemetry")}),i||await er();break}case"hook":{let n=x(e,"--source");await Tn(void 0,n??"claude-code");break}case"waste-scan":{let n=await Nn();process.stdout.write(`venos waste-scan: ${n.sessionsScanned} session(s) scanned, ${n.findingsStored} finding(s) reported
|
|
147
|
+
`);break}case"usage-sync":{if(I(e,"--throttle")){let i=$n();Ke(),process.stdout.write(`venos usage-sync --throttle: ${i.reason}
|
|
148
|
+
`);break}let n=x(e,"--org"),r=x(e,"--orchestrator"),o=x(e,"--api-key"),s=await Mn({...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
|
|
149
|
+
`);break}case"scan-skills":{if(I(e,"--scan")){let r=await Hn();process.stdout.write(`venos scan-skills --scan: ${r.findings} finding(s) from ${r.skillsScanned} skill(s) reported in ${r.chunks} chunk(s)
|
|
148
150
|
`);break}let n=await pe();process.stdout.write(`venos scan-skills: ${n.skills} skill(s) + ${n.plugins} plugin(s) reported
|
|
149
151
|
`);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
152
|
`);break}case"scan-agents":{if(I(e,"--dry-run")){let r=await Y({dryRun:!0});process.stdout.write(JSON.stringify(r,null,2)+`
|
|
151
153
|
`);break}let n=await Y();process.stdout.write(`venos scan-agents: ${n.agents} local AI agent(s) reported
|
|
152
154
|
`);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
155
|
`:`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
|
|
155
|
-
`);break}let n=x(e,"--org"),r=x(e,"--orchestrator"),o=x(e,"--api-key"),s=await
|
|
156
|
+
`);break}case"classify-file":{let n=e[0];n&&await xn(j(),n);break}case"heartbeat":{if(I(e,"--throttle")){let i=Ke();process.stdout.write(`venos heartbeat --throttle: ${i.reason}
|
|
157
|
+
`);break}let n=x(e,"--org"),r=x(e,"--orchestrator"),o=x(e,"--api-key"),s=await Zn({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)})
|
|
156
158
|
`:`venos heartbeat: no config \u2014 run "venos init" first
|
|
157
|
-
`),s.status==="sent"&&n===void 0&&r===void 0&&o===void 0&&await
|
|
158
|
-
`),process.exit(0);break;case"help":case void 0:process.stdout.write(
|
|
159
|
-
${
|
|
159
|
+
`),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}
|
|
160
|
+
`),process.exit(0);break;case"help":case void 0:process.stdout.write(tr),await er(),process.exit(0);break;default:process.stderr.write(`Unknown subcommand: ${t}
|
|
161
|
+
${tr}`),process.exit(2)}}try{await Ki()}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`venos: ${t}
|
|
160
162
|
`),process.exit(1)}
|
|
@@ -6,9 +6,9 @@ case `uname` in
|
|
|
6
6
|
esac
|
|
7
7
|
|
|
8
8
|
if [ -z "$NODE_PATH" ]; then
|
|
9
|
-
export NODE_PATH="/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.
|
|
9
|
+
export NODE_PATH="/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/node_modules:/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/json5@2.2.3/node_modules/json5/node_modules:/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/json5@2.2.3/node_modules:/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/node_modules"
|
|
10
10
|
else
|
|
11
|
-
export NODE_PATH="/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.
|
|
11
|
+
export NODE_PATH="/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/json5@2.2.3/node_modules/json5/lib/node_modules:/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/json5@2.2.3/node_modules/json5/node_modules:/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/json5@2.2.3/node_modules:/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
12
|
fi
|
|
13
13
|
if [ -x "$basedir/node" ]; then
|
|
14
14
|
exec "$basedir/node" "$basedir/../../../../../../json5@2.2.3/node_modules/json5/lib/cli.js" "$@"
|
|
@@ -6,9 +6,9 @@ case `uname` in
|
|
|
6
6
|
esac
|
|
7
7
|
|
|
8
8
|
if [ -z "$NODE_PATH" ]; then
|
|
9
|
-
export NODE_PATH="/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.
|
|
9
|
+
export NODE_PATH="/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/@babel+parser@7.29.7/node_modules/@babel/parser/bin/node_modules:/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/@babel+parser@7.29.7/node_modules/@babel/parser/node_modules:/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/@babel+parser@7.29.7/node_modules/@babel/node_modules:/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/@babel+parser@7.29.7/node_modules:/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/node_modules"
|
|
10
10
|
else
|
|
11
|
-
export NODE_PATH="/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.
|
|
11
|
+
export NODE_PATH="/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/@babel+parser@7.29.7/node_modules/@babel/parser/bin/node_modules:/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/@babel+parser@7.29.7/node_modules/@babel/parser/node_modules:/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/@babel+parser@7.29.7/node_modules/@babel/node_modules:/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/@babel+parser@7.29.7/node_modules:/Users/baraklagziel/code/venos/.worktrees/cli-publish-0.1.12/node_modules/.pnpm/node_modules:$NODE_PATH"
|
|
12
12
|
fi
|
|
13
13
|
if [ -x "$basedir/node" ]; then
|
|
14
14
|
exec "$basedir/node" "$basedir/../../../../../../@babel+parser@7.29.7/node_modules/@babel/parser/bin/babel-parser.js" "$@"
|