@venos-inc/venos 0.1.10 → 0.1.11

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