Lines 1-61javascript
2import{readFileSync as Ki}from"node:fs";import{homedir as R}from"node:os";import{existsSync as dn,mkdirSync as To,readFileSync as Ao,rmSync as _o,writeFileSync as Uo}from"node:fs";import{dirname as No,join as $o}from"node:path";import{randomBytes as Mo}from"node:crypto";import{existsSync as dr,readFileSync as pr}from"node:fs";import{join as fr}from"node:path";import{copyFileSync as ir,existsSync as Ye,mkdirSync as ar,renameSync as cr,writeFileSync as lr}from"node:fs";import{dirname as ur}from"node:path";var ze=".venos-backup";function m(e,t){ar(ur(e),{recursive:!0}),Ye(e)&&!Ye(e+ze)&&ir(e,e+ze ...
3`}var W="http://127.0.0.1:4000/v1";var Xe="venos",mr="venos usage-sync --throttle";function z(e){return(e??[]).some(t=>t.hooks.some(n=>typeof n.command=="string"&&n.command.includes(Xe)))}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(Xe))})).filter(t=>t.hooks.length>0)}var he={name:"claude-code",transport:"claude-hook",configPath(e){return fr(e,".claude","settings.json")},isInstalled(e){return!0},load(e){if(!dr(e))return{};try{r ...
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]=hr(n.toml,n.ptr),s=yr(n.toml,r,o);super(`Invalid TOML document: ${t}
7${s}`,n),this.line=r,this.column=o,this.codeblock=s}};function vr(e,t){let n=0;for(;e[t-++n]==="\\";);return--n&&n%2}function Z(e,t
8`,t);return e[r-1]==="\r"&&r--,r<=n?r:-1}function A(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 w(e,t,n,r){let o;for(;;){for
11`||o==="\r"&&e[t+1]===`
12`);)t++;if(r||o!=="#")break;t=A(e,t)}return t}function qe(e,t,n,r,o=!1){if(!r)return t=Z(e,t),t<0?e.length:t;for(
13`||i==="\r"&&e[s+1]===`
14`))return s}}throw new p("cannot find end of structure",{toml:e,ptr:t})}function q(e,t){let n=e[t],r=n===e[t+1]&&e[t+1]===e[t+2]?e.slice(t,t+3):n;t+=
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===`
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(!xr.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=w(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=w(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 et(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=wr.test(e);if(o||kr.test(e)){if(Cr.test(e))throw new p("leading zeroes are not allowed",{toml:t,ptr:n});e=e.replac ...
21`&&e[i]!=="\r")throw new p("unexpected character encountered",{toml:e,ptr:i});i+=+(e[i]===",")}return[l,i]}i=qe(e,t,",",n);let a=br(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[
22`&&i!=="\r"){let a,l=o,c=!1,[u,d]=ee(e,t-1);for(let y=0;y<u.length;y++){if(y&&(l=c?l[a]:l[a]={}),a=u[y],(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,S]=D(e,d,"}",n-1,r);s.add(f),l[a]=f,t=S}}if(!i)throw new p("unfinished table encountered",{toml:e,ptr:t});return[o,t]}function nt(e,t,n,r){let o=[],s;for(t++;(s=e[t++])!=="]"&&s;){if(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 rt(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: ...
24`&&e[a]!=="\r")throw new p("each key-value declaration must be followed by an end-of-line",{toml:e,ptr:a});a=w(e,a)}return r}var ot=/^[a-z0-9-_]+$/i;function H(e){let t=typeof e;if(t==="object"){if(Array.isArray(e))
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
27`)+Rr(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`}}return e&&(s||!i)&&(s=s?`[${e}]
30${s}`:`[${e}]`),s&&i?`${s}
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);
33`:r}function it(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 at={name:"codex",transport:"mcp-toml"
34`)}};import{existsSync as ct,readFileSync as Ar}from"node:fs";import{join as lt}from"node:path";var pt="venos";function be(e){return(e??[]).some(t=>t.hooks.some(n=>typeof n.command=="string"&&n.command.includes(pt)))}function ut(e,t){let n=e??[];return be(n)?n:[...n,{matcher:"*",hooks:[{type:"command",command:t}]}]}function dt(e){return(e??[]).map(t=>({...t,hooks:t.hooks.filter(n=>typeof n.command!="string"||!n.command.includes(pt))})).filter(t=>t.hooks.length>0)}function _r(e){return`${e.hookCommand} --source codex`}var ft={name:"codex-hook",transport:"claude-hook",configPath(e){return lt(e," ...
35`).some(r=>r.trim()===Et()),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=>!Hr(s)),o=t.wired?[...r,Et()]:r;if(o.length===0){It(e)&&Wr(e,{force:!0});
38`)}};import{accessSync as Jr,constants as Kr,existsSync as At,readFileSync as Br}from"node:fs";import{delimiter as Gr}from"node:path";import{join as _t}from"node:path";var Yr="obsidian-cli",zr="obsidian-cli.json";function Xr(e){try{return Jr(e,Kr.X_OK
39 VENOS_MCP_SERVER_PATH=${e??"(unset)"}
42If you are developing locally, run: pnpm --filter @venos/mcp-server build`)}import{existsSync as eo}from"node:fs";function to(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 Mt(e,t, ...
MediumInstall Persistence
Source writes installer persistence such as shell profile or service configuration.
dist/index.jsView on unpkg · L2 43`,"utf8")}function N(e){let t=_e(e);return Dt(t)?(io(t,{force:!0}),!0):!1}function $(e){return Dt(_e(e))}function Jt(e){return ho(e,"Library","LaunchAgents"
44<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
48 <string>${Ae}</string>
49 <key>ProgramArguments</key>
53 <string>heartbeat</string>
57 <key>StartInterval</key>
58 <integer>${3600}</integer>
61 <key>SuccessfulExit</key>
Long lines were clipped for display.