@yukino.js/yukino 0.0.2 → 0.0.3-dev

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 (35) hide show
  1. package/README.md +34 -27
  2. package/dist/{acp-GPESP7MI.js → acp-J6EPN6TP.js} +6 -6
  3. package/dist/{agent-MPSZKLGX.js → agent-LA65FOAB.js} +1 -1
  4. package/dist/{anthropic-D7RVWNCE.js → anthropic-YP6DY2F3.js} +1 -1
  5. package/dist/{chunk-UPNNYP7M.js → chunk-2UNWKNDU.js} +1 -1
  6. package/dist/{chunk-IXRJQ6NU.js → chunk-675L7SRF.js} +96 -96
  7. package/dist/{chunk-RC3MYRC3.js → chunk-7CVY4FXY.js} +1 -1
  8. package/dist/{chunk-MY5FSQD6.js → chunk-CT773IEX.js} +3 -3
  9. package/dist/{chunk-Z2OKAF7A.js → chunk-JEOQXHOX.js} +24 -24
  10. package/dist/chunk-M5H5EYXN.js +5 -0
  11. package/dist/{chunk-SAJCBGHL.js → chunk-P77AEADG.js} +1 -1
  12. package/dist/{chunk-XO7ITAWR.js → chunk-Y6COQ5UY.js} +1 -1
  13. package/dist/{chunk-RCXKUD3Y.js → chunk-ZQP5DTJA.js} +1 -1
  14. package/dist/{esm-ZTIYTMTS.js → esm-NCEEJIH3.js} +3 -3
  15. package/dist/lib/{agent-H42OYQUH.js → agent-KDWPLLAV.js} +3 -3
  16. package/dist/lib/{anthropic-GTRJZUG3.js → anthropic-OJALXK4E.js} +2 -2
  17. package/dist/lib/{chunk-UOQV7CZM.js → chunk-2DEH6DOX.js} +1 -1
  18. package/dist/lib/{chunk-OMEH2HQI.js → chunk-77FSPN6Y.js} +8 -8
  19. package/dist/lib/{chunk-AR6FQWXI.js → chunk-7G4AI2PP.js} +1 -1
  20. package/dist/lib/{chunk-PY2WWTDH.js → chunk-SS7OJYHN.js} +15 -6
  21. package/dist/lib/{chunk-AEGITC5R.js → chunk-WOMWIFSN.js} +2 -2
  22. package/dist/lib/{chunk-MDX24JQ5.js → chunk-ZF52ER22.js} +1 -1
  23. package/dist/lib/index.d.ts +52 -43
  24. package/dist/lib/index.js +52 -43
  25. package/dist/lib/{openai-UQC5X2TR.js → openai-FB7BBZVN.js} +2 -2
  26. package/dist/lib/{permissions-Q4FBU5VD.js → permissions-BZRN4RES.js} +1 -1
  27. package/dist/lib/{providers-UA4VT5HA.js → providers-7ZGRBCQ4.js} +1 -1
  28. package/dist/main.js +223 -217
  29. package/dist/{openai-AEXTBM62.js → openai-2FE77NB2.js} +1 -1
  30. package/dist/{permissions-VCDMNX3L.js → permissions-R7P7RWZU.js} +1 -1
  31. package/dist/{providers-JRGWHWTS.js → providers-EZFC2EPW.js} +1 -1
  32. package/dist/{server-SAJ7FDJQ.js → server-54LNMGWU.js} +1 -1
  33. package/package.json +16 -8
  34. package/postinstall.mjs +80 -0
  35. package/dist/chunk-7UAMH7BZ.js +0 -5
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __yukinoCreateRequire } from "node:module";
3
3
  const require = __yukinoCreateRequire(import.meta.url);
4
- import{f as d,m as f,o as y,s as l}from"./chunk-UPNNYP7M.js";var S=d({module:"mcp"}),u="mcp__",p="__";function a(e){return e.replace(/[^a-zA-Z0-9_]/g,"_")}function M(e){return u+a(e)+p}function g(e,t){return M(e)+a(t)}var T=class{name;description;category="command";deferred=!0;mcpServerName;client;originalName;inputSchema;constructor(t,r,n){this.name=g(r,n.name),this.description=n.description,this.originalName=n.name,this.client=t,this.inputSchema=n.inputSchema,this.mcpServerName=r}mcpInputSchema(){return this.inputSchema??{}}setDeferLoading(t){this.deferred=t}schema(){return{name:this.name,description:this.description,input_schema:this.inputSchema}}async execute(t,r){try{return await this.client.callTool(this.originalName,r,t.abortSignal)}catch(n){return S.error({err:n},"mcp operation failed"),{output:`MCP tool error: ${y(n)}`,isError:!0}}}};function P(e,t){if(t==="string"&&typeof e=="number"&&Number.isFinite(e))return String(e);if((t==="integer"||t==="number")&&typeof e=="string"){let r=e.trim();if(r===""||!(t==="integer"?/^[+-]?\d+$/:/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/).test(r))return e;let s=t==="integer"?Number.parseInt(r,10):Number.parseFloat(r);return Number.isFinite(s)?s:e}if(t==="boolean"&&typeof e=="string"){let r=e.trim().toLowerCase();if(r==="true")return!0;if(r==="false")return!1}return e}function h(e,t){if(typeof t!="object"||t===null)return e;let r=f(t),n=l(r,"type","");if(n==="object"&&typeof e=="object"&&e!==null&&!Array.isArray(e)){let s=f(r.properties??{}),o={};for(let[i,c]of Object.entries(e))o[i]=i in s?h(c,s[i]):c;return o}if(n==="array"){let s=r.items??{},o=e;if(typeof o=="object"&&o!==null&&!Array.isArray(o)){let i=Object.values(o);i.length===1&&Array.isArray(i[0])&&(o=i[0])}else typeof o=="string"&&(o=o.split(",").map(i=>i.trim()).filter(i=>i!==""));return Array.isArray(o)?o.map(i=>h(i,s)):o}return n!==""?P(e,n):e}function A(e,t){if(t.startsWith(u)){let r=t.slice(u.length),n=r.indexOf(p);if(n>=0)return a(r.slice(0,n))+p+a(r.slice(n+p.length))}return a(e)+p+a(t)}function b(e){return"mcpInputSchema"in e&&typeof e.mcpInputSchema=="function"}var C=class{constructor(t){this.registry=t}registry;name="McpCall";description="Invoke a tool on a connected MCP server. Call ToolSearch first to load the tool's schema, then pass its arguments here exactly as that schema requires, using the same JSON types.";category="command";deferred=!1;schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{server:{type:"string",description:"MCP server name, e.g. 'linear'."},tool:{type:"string",description:"Full tool name as returned by ToolSearch, e.g. 'mcp__linear__create_issue'."},arguments:{type:"object",description:"The target tool's arguments. Must match that tool's input_schema exactly, including JSON types: bare numbers for integer fields, bare true/false for boolean fields, quoted strings for string fields, and plain JSON arrays for array fields."}},required:["server","tool","arguments"]}}}resolveTarget(t){let r=l(t,"server"),n=l(t,"tool");if(!r||!n)return;let s=n.startsWith(u)?n:g(r,n),o=this.registry.get(s);return o&&b(o)&&a(o.mcpServerName)===a(r)?o:void 0}availableNames(){return this.registry.listTools().filter(t=>t.name.startsWith(u)).map(t=>t.name).sort()}async execute(t,r){let n=l(r,"server",""),s=l(r,"tool","");if(s==="")return{output:"McpCall requires a 'tool' name",isError:!0};let o=this.resolveTarget(r);if(!o){let c=this.availableNames(),m=c.length>0?c.join(", "):"(none connected)";return{output:`Unknown MCP tool '${s}' on server '${n}'. Available tools: ${m}`,isError:!0}}if(typeof r.arguments!="object"||r.arguments===null||Array.isArray(r.arguments))return{output:"McpCall requires an 'arguments' object matching the target schema",isError:!0};let i=f(r.arguments);if(b(o)){let c=o.mcpInputSchema();if(Object.keys(c).length>0){let m=h(i,c);typeof m=="object"&&m!==null&&!Array.isArray(m)&&(i=f(m))}}return t.abortSignal?.throwIfAborted(),o.execute(t,i)}};export{u as a,T as b,A as c,b as d,C as e};
4
+ import{f as d,m as f,o as y,t as l}from"./chunk-2UNWKNDU.js";var S=d({module:"mcp"}),u="mcp__",p="__";function a(e){return e.replace(/[^a-zA-Z0-9_]/g,"_")}function M(e){return u+a(e)+p}function g(e,t){return M(e)+a(t)}var T=class{name;description;category="command";deferred=!0;mcpServerName;client;originalName;inputSchema;constructor(t,r,n){this.name=g(r,n.name),this.description=n.description,this.originalName=n.name,this.client=t,this.inputSchema=n.inputSchema,this.mcpServerName=r}mcpInputSchema(){return this.inputSchema??{}}setDeferLoading(t){this.deferred=t}schema(){return{name:this.name,description:this.description,input_schema:this.inputSchema}}async execute(t,r){try{return await this.client.callTool(this.originalName,r,t.abortSignal)}catch(n){return S.error({err:n},"mcp operation failed"),{output:`MCP tool error: ${y(n)}`,isError:!0}}}};function P(e,t){if(t==="string"&&typeof e=="number"&&Number.isFinite(e))return String(e);if((t==="integer"||t==="number")&&typeof e=="string"){let r=e.trim();if(r===""||!(t==="integer"?/^[+-]?\d+$/:/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/).test(r))return e;let s=t==="integer"?Number.parseInt(r,10):Number.parseFloat(r);return Number.isFinite(s)?s:e}if(t==="boolean"&&typeof e=="string"){let r=e.trim().toLowerCase();if(r==="true")return!0;if(r==="false")return!1}return e}function h(e,t){if(typeof t!="object"||t===null)return e;let r=f(t),n=l(r,"type","");if(n==="object"&&typeof e=="object"&&e!==null&&!Array.isArray(e)){let s=f(r.properties??{}),o={};for(let[i,c]of Object.entries(e))o[i]=i in s?h(c,s[i]):c;return o}if(n==="array"){let s=r.items??{},o=e;if(typeof o=="object"&&o!==null&&!Array.isArray(o)){let i=Object.values(o);i.length===1&&Array.isArray(i[0])&&(o=i[0])}else typeof o=="string"&&(o=o.split(",").map(i=>i.trim()).filter(i=>i!==""));return Array.isArray(o)?o.map(i=>h(i,s)):o}return n!==""?P(e,n):e}function A(e,t){if(t.startsWith(u)){let r=t.slice(u.length),n=r.indexOf(p);if(n>=0)return a(r.slice(0,n))+p+a(r.slice(n+p.length))}return a(e)+p+a(t)}function b(e){return"mcpInputSchema"in e&&typeof e.mcpInputSchema=="function"}var C=class{constructor(t){this.registry=t}registry;name="McpCall";description="Invoke a tool on a connected MCP server. Call ToolSearch first to load the tool's schema, then pass its arguments here exactly as that schema requires, using the same JSON types.";category="command";deferred=!1;schema(){return{name:this.name,description:this.description,input_schema:{type:"object",properties:{server:{type:"string",description:"MCP server name, e.g. 'linear'."},tool:{type:"string",description:"Full tool name as returned by ToolSearch, e.g. 'mcp__linear__create_issue'."},arguments:{type:"object",description:"The target tool's arguments. Must match that tool's input_schema exactly, including JSON types: bare numbers for integer fields, bare true/false for boolean fields, quoted strings for string fields, and plain JSON arrays for array fields."}},required:["server","tool","arguments"]}}}resolveTarget(t){let r=l(t,"server"),n=l(t,"tool");if(!r||!n)return;let s=n.startsWith(u)?n:g(r,n),o=this.registry.get(s);return o&&b(o)&&a(o.mcpServerName)===a(r)?o:void 0}availableNames(){return this.registry.listTools().filter(t=>t.name.startsWith(u)).map(t=>t.name).sort()}async execute(t,r){let n=l(r,"server",""),s=l(r,"tool","");if(s==="")return{output:"McpCall requires a 'tool' name",isError:!0};let o=this.resolveTarget(r);if(!o){let c=this.availableNames(),m=c.length>0?c.join(", "):"(none connected)";return{output:`Unknown MCP tool '${s}' on server '${n}'. Available tools: ${m}`,isError:!0}}if(typeof r.arguments!="object"||r.arguments===null||Array.isArray(r.arguments))return{output:"McpCall requires an 'arguments' object matching the target schema",isError:!0};let i=f(r.arguments);if(b(o)){let c=o.mcpInputSchema();if(Object.keys(c).length>0){let m=h(i,c);typeof m=="object"&&m!==null&&!Array.isArray(m)&&(i=f(m))}}return t.abortSignal?.throwIfAborted(),o.execute(t,i)}};export{u as a,T as b,A as c,b as d,C as e};
@@ -1,4 +1,4 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __yukinoCreateRequire } from "node:module";
3
3
  const require = __yukinoCreateRequire(import.meta.url);
4
- import{c as C}from"./chunk-XO7ITAWR.js";import{a as y,f as D,g as d,h as m,l as j,s as c}from"./chunk-UPNNYP7M.js";import{D as p,d as S}from"./chunk-GYBJR2RB.js";import{readFileSync as I,writeFileSync as O,mkdirSync as M,statSync as W}from"fs";import{homedir as T,tmpdir as _}from"os";import{join as g,resolve as f,dirname as z}from"path";var k=D({module:"permissions"}),L=[],N=["basename","cat","cksum","cmp","column","comm","cut","df","dirname","du","echo","expr","false","fold","fmt","grep","groups","head","id","jq","locate","ls","md5","md5sum","nl","od","paste","pgrep","printenv","printf","ps","pwd","readlink","realpath","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shasum","stat","strings","tac","tail","tr","true","tty","type","uname","uptime","w","wc","whereis","which","who","whoami","ack","ag","alias","arch","base64","bat","bzcat","cal","col","cloc","diff","diff3","dig","dmesg","expand","factor","free","help","hexdump","host","iconv","info","locale","lscpu","lsblk","lsof","lspci","lsusb","man","mdfind","mdls","ncal","netstat","nproc","nslookup","objdump","otool","pbpaste","ping","readelf","rev","sdiff","seq","sum","sw_vers","tldr","traceroute","unexpand","vm_stat","whois","xxd","xzcat","zcat","zgrep","zipinfo",/^command\s+(?:-v|-V)\s+\S+(?:\s+\S+)*$/,/^date(?!.*\s(?:-s|--set)(?:=|\s|$))(?:\s.*)?$/,/^file(?!.*(?:\s--compile(?:=|\s|$)|\s-[^-\s]*C))(?:\s.*)?$/,/^find(?!.*\s(?:-delete|-exec(?:dir)?|-ok(?:dir)?|-fls|-fprint(?:0)?|-fprintf)(?:\s|$))(?:\s.*)?$/,/^fd(?!.*\s(?:-x|-X|--exec|--exec-batch)(?:=|\s|$))(?:\s.*)?$/,/^hostname(?:\s+(?:-[adfFiIsyVh]|--(?:alias|all-fqdns|all-ip-addresses|domain|fqdn|help|ip-address|long|nis|short|version|yp)))*$/,/^rg(?!.*\s(?:--pre|--pre-glob|--hostname-bin)(?:=|\s|$))(?:\s.*)?$/,/^sort(?!.*\s(?:-o|--output|--compress-program)(?:=|\s|$))(?:\s.*)?$/,/^ss(?!.*\s(?:--kill|-[^-\s]*K)(?:\s|$))(?:\s.*)?$/,/^tree(?!.*\s(?:-o|--output)(?:=|\s|$))(?:\s.*)?$/,/^git\s+(?:--version|version)$/,/^git\s+(?:blame|cat-file|count-objects|describe|for-each-ref|ls-files|ls-tree|merge-base|name-rev|rev-parse|shortlog|show-ref|status|verify-pack)(?:\s.*)?$/,/^git\s+(?:diff|log|show)(?!.*\s(?:--ext-diff|--output)(?:=|\s|$))(?:\s.*)?$/,/^git\s+branch$/,/^git\s+branch(?=.*\s(?:-a|--all|-r|--remotes|--list|--show-current|--contains|--no-contains|--merged|--no-merged)(?:=|\s|$))(?!.*\s(?:-[dDmMcCf]|--(?:copy|create-reflog|delete|edit-description|move|set-upstream-to|unset-upstream))(?:=|\s|$))(?:\s.*)?$/,/^git\s+config(?:\s+(?:--blob(?:=|\s)\S+|--file(?:=|\s)\S+|--fixed-value|--global|--local|--null|--show-names|--show-origin|--show-scope|--system|--worktree|-z))*\s+(?:--get|--get-all|--get-regexp|--get-urlmatch|--list|-l)(?:\s.*)?$/,/^git\s+notes\s+(?:list|show)(?:\s.*)?$/,/^git\s+reflog\s+show(?:\s.*)?$/,/^git\s+remote(?:\s+-v)?$/,/^git\s+remote\s+get-url(?:\s+(?:--all|--push))*\s+\S+$/,/^git\s+remote\s+show(?:\s+-n)?(?:\s+\S+)?$/,/^git\s+stash\s+(?:list|show)(?:\s.*)?$/,/^git\s+submodule\s+(?:status|summary)(?:\s.*)?$/,/^git\s+tag(?:\s+(?:-l|--list)(?:\s.*)?)?$/,/^git\s+worktree\s+list(?:\s.*)?$/,/^(?:bun|npm|pnpm|yarn)\s+(?:explain|help|info|list|ls|outdated|prefix|query|root|search|show|view|why)(?:\s.*)?$/,/^(?:npm|pnpm|yarn)\s+config\s+(?:get|list)(?:\s.*)?$/,/^npm\s+pkg\s+get(?:\s.*)?$/,/^bun\s+pm\s+ls(?:\s.*)?$/,/^(?:bun|cargo|clang|cmake|composer|deno|gcc|gem|node|npm|php|pip|pip3|pnpm|python|python3|ruby|rustc|swift|yarn)\s+(?:--version|-V)$/,/^(?:go|helm|kubectl|podman|terraform)\s+version(?:\s.*)?$/,/^(?:java|javac)\s+-version$/,/^dotnet\s+(?:--info|--list-runtimes|--list-sdks|--version)$/,/^(?:docker|podman)\s+(?:diff|events|images|info|inspect|logs|port|ps|stats|top|version)(?:\s.*)?$/,/^(?:docker|podman)\s+(?:container|image|network|volume)\s+(?:inspect|ls)(?:\s.*)?$/,/^docker\s+compose\s+(?:config|images|logs|ps|top|version)(?:\s.*)?$/,/^kubectl\s+(?:api-resources|api-versions|cluster-info|describe|explain|get|logs|top|version)(?:\s.*)?$/,/^kubectl\s+config\s+(?:current-context|get-contexts|view)(?:\s.*)?$/,/^helm\s+(?:env|get|history|list|search|show|status|version)(?:\s.*)?$/,/^terraform\s+(?:output|providers|show|version)(?:\s.*)?$/,/^terraform\s+workspace\s+(?:list|show)(?:\s.*)?$/,/^systemctl\s+(?:is-active|is-enabled|is-failed|list-dependencies|list-jobs|list-sockets|list-timers|list-unit-files|list-units|show|show-environment|status)(?:\s.*)?$/,/^launchctl\s+(?:error|hostinfo|list|managername|managerpid|manageruid|print|print-cache|procinfo|variant|version)(?:\s.*)?$/,/^journalctl(?!.*\s--(?:rotate|vacuum|flush|sync))(?:\s.*)?$/,/^defaults\s+read(?:\s.*)?$/,/^ifconfig$/,/^ipconfig(?:\s+\/(?:all|allcompartments|displaydns))?\s*$/,/^ip\s+(?:addr(?:ess)?|route)$/,/^ip\s+(?:addr(?:ess)?|link|route|neigh(?:bor)?)\s+(?:show|list)\b(?:\s.*)?$/,/^tar\s+(?:--list\b|-[a-zA-Z]*t[a-zA-Z]*)(?:\s.*)?$/,/^unzip\s+-[a-zA-Z]*l(?:\s.*)?$/,/^git\s+(?:grep|fsck|rev-list|whatchanged|help|diff-tree|diff-index|diff-files|ls-remote|verify-tag|verify-commit)(?:\s.*)?$/,/^git\s+archive(?!.*\s(?:-o|--output)(?:=|\s|$))(?:\s.*)?$/,/^svn\s+(?:status|stat|st|diff|di|log|info|list|ls|cat|blame|ann|annotate|proplist|propget|pg)(?:\s.*)?$/,/^hg\s+(?:status|st|log|diff|summary|id|identify|branches|tags|manifest|cat|files|locate|heads|tip|parents|paths|root)(?:\s.*)?$/,/^cargo\s+(?:tree|search|locate-project|verify-project|config\s+get)(?:\s.*)?$/,/^gem\s+(?:list|search|info|env|dependency|contents|specification|sources\s+(?:-l|--list))(?:\s.*)?$/,/^brew\s+(?:--version|-v|list|info|search|outdated|deps|uses|config|leaves|doctor)(?:\s.*)?$/,/^choco\s+(?:--version|list|info|search|outdated)(?:\s.*)?$/,/^apt(?:-get)?\s+list(?:\s.*)?$/,/^apt-cache\s+(?:search|show|showpkg|policy|depends|rdepends|pkgnames)(?:\s.*)?$/,/^dpkg\s+(?:-l|-L|-s|-S|--list|--listfiles|--status|--search)\b(?:\s.*)?$/,/^rpm\s+-q[a-zA-Z]*(?:\s.*)?$/,/^(?:aws|gh|gcloud|az)\s+--version$/,/^aws\s+(?:\S+\s+)?(?:describe|list|get|wait)-\S+(?:\s.*)?$/,/^aws\s+s3\s+ls(?:\s.*)?$/,/^gcloud\s+\S+(?:\s+\S+)*\s+(?:list|describe)(?:\s.*)?$/,/^az\s+\S+(?:\s+\S+)*\s+(?:list|show)(?:\s.*)?$/,/^gh\s+(?:pr|issue|repo|run|release|gist)\s+(?:view|list|status|checks|diff)(?:\s.*)?$/,/^(?:docker|podman)\s+(?:system\s+(?:df|info)|history|context\s+(?:ls|list|show|inspect))(?:\s.*)?$/,/^(?:Get-(?:Acl|Alias|AuthenticodeSignature|ChildItem|CimInstance|Clipboard|Command|ComputerInfo|Content|Counter|Culture|Date|DnsClientCache|EventLog|ExecutionPolicy|FileHash|Help|History|Host|HotFix|Item|ItemProperty|Location|Member|Module|NetAdapter|NetIPAddress|NetNeighbor|NetIPConfiguration|NetRoute|NetTCPConnection|NetUDPEndpoint|Package|PackageProvider|PnpDevice|Printer|Process|PSDrive|PSProvider|PSRepository|PSSnapin|ScheduledTask|Service|TimeZone|UICulture|Variable|Verb|WinEvent|WmiObject)|Compare-Object|Format-(?:Custom|Hex|List|Table|Wide)|Group-Object|Measure-Object|Out-String|Resolve-Path|Select-Object|Select-String|Sort-Object|Test-Path|Where-Object|Write-(?:Debug|Error|Host|Information|Output|Progress|Verbose|Warning))(?:\s.*)?$/i],H={Bash:"command",PowerShell:"command",ComputerUse:"action",ReadFile:"file_path",WriteFile:"file_path",EditFile:"file_path",Glob:"pattern",Grep:"pattern",InstallSkill:"source"},U=[];function v(n,e){if(n==="McpCall")return C(c(e,"server",""),c(e,"tool",""));let s=H[n];if(!s)return"";let t=e[s];return typeof t=="string"?t:n==="ComputerUse"&&Array.isArray(e.actions)?e.actions.map(r=>j(r)?c(r,"type"):"").filter(Boolean).join(","):""}var P=class{allowedRoots;denyWritePaths;projectDir;constructor(e){this.projectDir=f(e),this.allowedRoots=[this.projectDir,_()],this.denyWritePaths=U.map(s=>g(this.projectDir,s))}addRoot(e){this.allowedRoots.push(f(e))}addDenyWrite(e){this.denyWritePaths.push(f(e))}checkDenyWrite(e){let s=f(this.projectDir,e),t=d(s);for(let r of this.denyWritePaths)if(m(r,s)||m(d(r),t))return{effect:"deny",reason:`Path ${e} is in deny-write list`};return null}check(e){let s=d(f(this.projectDir,e));for(let t of this.allowedRoots)if(m(d(t),s))return null;return{effect:"deny",reason:`Path ${e} is outside allowed directories`}}};function q(n,e){let s="^"+n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")+"$";try{return new RegExp(s).test(e)}catch(t){return k.error({err:t},"permissions operation failed"),!1}}var V=/^(\w+)\((.+)\)$/;function A(n){let e;try{e=I(n,"utf-8")}catch(i){return i.code!=="ENOENT"&&k.error({err:i},"permissions operation failed"),[]}let s=p.object({rule:p.string().optional(),effect:p.string().optional()}),t;try{let i=y.load(e);t=S(p.array(s),i)}catch(i){return k.error({err:i},"permissions operation failed"),[]}let r=[];for(let i of t){if(i.effect!=="allow"&&i.effect!=="deny"&&i.effect!=="ask")continue;let o=V.exec((i.rule??"").trim());o&&r.push({tool:o[1],pattern:o[2],effect:i.effect})}return r}function h(n,e,s){let t=null;for(let r of n)if(!(r.tool!==e&&r.tool!=="*")&&q(r.pattern,s)){if(r.effect==="deny")return"deny";r.effect==="ask"?t="ask":t??="allow"}return t}var x=class{userPath;projectPath;cache=new Map;constructor(e){this.userPath=g(T(),".yukino","permissions.yaml"),this.projectPath=g(e,".yukino","permissions.yaml")}rulesFor(e){let s;try{s=W(e,{bigint:!0})}catch{return this.cache.delete(e),[]}let t=this.cache.get(e);if(t?.mtimeNs===s.mtimeNs&&t.size===s.size)return t.rules;let r=A(e);return this.cache.set(e,{mtimeNs:s.mtimeNs,size:s.size,rules:r}),r}snapshot(){return[this.userPath,this.projectPath].flatMap(e=>this.rulesFor(e))}evaluate(e,s){return h(this.snapshot(),e,s)}appendProjectRule(e){M(z(this.projectPath),{recursive:!0});let s=A(this.projectPath);if(s.some(i=>i.tool===e.tool&&i.pattern===e.pattern&&i.effect===e.effect))return;s.push(e);let r=s.map(i=>({rule:`${i.tool}(${i.pattern})`,effect:i.effect}));O(this.projectPath,y.dump(r),"utf-8")}};function G(n){for(let e of L)if(e.re.test(n))return e.reason;return""}function Y(n){let e=n.trim();return/[\r\n&|;<>`(){}[\]]/.test(e)?!1:N.some(s=>typeof s=="string"?e===s||e.startsWith(s+" ")||e.startsWith(s+" "):(s.lastIndex=0,s.test(e)))}function Z(n,e){switch(n){case"bypassPermissions":return"allow";case"plan":return e==="read"?"allow":"ask";case"acceptEdits":return e==="command"?"ask":"allow";default:return e==="read"?"allow":"ask"}}var F=class n{constructor(e,s="default"){this.workDir=e;this.mode=s,this.sandbox=new P(e),this.ruleEngine=new x(e)}workDir;mode;planFilePath="";sandboxEnabled=!1;sandboxAutoAllow=!1;sandbox;ruleEngine;forWorkDir(e){let s=new n(e,this.mode);return s.ruleEngine=this.ruleEngine,s.sandboxEnabled=this.sandboxEnabled,s.sandboxAutoAllow=this.sandboxAutoAllow,s}check(e,s,t){let r=v(e,t),i=null,o=()=>i??=this.ruleEngine.snapshot(),a=h(o(),e,r);if(a==="deny"||a==="ask")return{effect:a,reason:`Permission rule: ${a}`};if(this.mode==="plan"&&(e==="WriteFile"||e==="EditFile")){let u=c(t,"file_path","");if(this.planFilePath&&d(f(this.workDir,u))===d(f(this.workDir,this.planFilePath))&&!this.sandbox.checkDenyWrite(u))return{effect:"allow",reason:"Plan file write allowed in plan mode"}}if(s==="command"&&Y(r))return{effect:"allow",reason:"Safe read-only command"};let E=s==="command"?G(r):"";if(E)return{effect:"deny",reason:`Dangerous command blocked: ${E}`};if(this.sandboxEnabled&&this.sandboxAutoAllow&&e==="Bash"){let u=c(t,"command").split(/\s*(?:&&|\|\||[;|])\s*/).map(w=>w.trim()).filter(Boolean),l=!1;for(let w of u){let R=h(o(),e,w);if(R==="deny")return{effect:"deny",reason:"Permission rule: deny"};R==="ask"&&(l=!0)}return l?{effect:"ask",reason:"Permission rule: ask (sandbox does not override)"}:{effect:"allow",reason:"Sandbox auto-allow: OS sandbox active"}}let $=c(t,"file_path",c(t,"path",""));if((s==="read"||s==="write")&&$){if(s==="write"){let l=this.sandbox.checkDenyWrite($);if(l)return l}let u=this.sandbox.check($);if(u&&this.mode!=="bypassPermissions"){let l=this.ruleEngine.evaluate(e,r);return l?{effect:l,reason:`Permission rule: ${l}`}:{effect:"ask",reason:u.reason}}}let b=h(o(),e,r);return b?{effect:b,reason:`Permission rule: ${b}`}:{effect:Z(this.mode,s),reason:`Mode: ${this.mode}`}}allowExtraRoot(e){this.sandbox.addRoot(e)}allowAlways(e,s){let t=v(e,s),r=e==="ReadFile"||e==="WriteFile"||e==="EditFile",i;if(r&&t){let o=f(this.workDir,t),a=!1;try{a=W(o).isDirectory()}catch{}i=g(a?o:z(o),"*")}else i=t.trim().split(/\s+/).slice(0,2).join(" ")+"*";this.ruleEngine.appendProjectRule({tool:e,pattern:i,effect:"allow"})}describeToolAction(e,s){let t=v(e,s);if(t)return t;let r=[];for(let[i,o]of Object.entries(s)){let a=String(o);a.length>80&&(a=a.slice(0,80)+"..."),r.push(`${i}: ${a}`)}return r.join(", ")}};export{v as a,P as b,h as c,x as d,Y as e,F as f};
4
+ import{c as C}from"./chunk-Y6COQ5UY.js";import{a as y,f as D,g as d,h as m,l as j,t as c}from"./chunk-2UNWKNDU.js";import{D as p,d as S}from"./chunk-GYBJR2RB.js";import{readFileSync as I,writeFileSync as O,mkdirSync as M,statSync as W}from"fs";import{homedir as T,tmpdir as _}from"os";import{join as g,resolve as f,dirname as z}from"path";var k=D({module:"permissions"}),L=[],N=["basename","cat","cksum","cmp","column","comm","cut","df","dirname","du","echo","expr","false","fold","fmt","grep","groups","head","id","jq","locate","ls","md5","md5sum","nl","od","paste","pgrep","printenv","printf","ps","pwd","readlink","realpath","sha1sum","sha224sum","sha256sum","sha384sum","sha512sum","shasum","stat","strings","tac","tail","tr","true","tty","type","uname","uptime","w","wc","whereis","which","who","whoami","ack","ag","alias","arch","base64","bat","bzcat","cal","col","cloc","diff","diff3","dig","dmesg","expand","factor","free","help","hexdump","host","iconv","info","locale","lscpu","lsblk","lsof","lspci","lsusb","man","mdfind","mdls","ncal","netstat","nproc","nslookup","objdump","otool","pbpaste","ping","readelf","rev","sdiff","seq","sum","sw_vers","tldr","traceroute","unexpand","vm_stat","whois","xxd","xzcat","zcat","zgrep","zipinfo",/^command\s+(?:-v|-V)\s+\S+(?:\s+\S+)*$/,/^date(?!.*\s(?:-s|--set)(?:=|\s|$))(?:\s.*)?$/,/^file(?!.*(?:\s--compile(?:=|\s|$)|\s-[^-\s]*C))(?:\s.*)?$/,/^find(?!.*\s(?:-delete|-exec(?:dir)?|-ok(?:dir)?|-fls|-fprint(?:0)?|-fprintf)(?:\s|$))(?:\s.*)?$/,/^fd(?!.*\s(?:-x|-X|--exec|--exec-batch)(?:=|\s|$))(?:\s.*)?$/,/^hostname(?:\s+(?:-[adfFiIsyVh]|--(?:alias|all-fqdns|all-ip-addresses|domain|fqdn|help|ip-address|long|nis|short|version|yp)))*$/,/^rg(?!.*\s(?:--pre|--pre-glob|--hostname-bin)(?:=|\s|$))(?:\s.*)?$/,/^sort(?!.*\s(?:-o|--output|--compress-program)(?:=|\s|$))(?:\s.*)?$/,/^ss(?!.*\s(?:--kill|-[^-\s]*K)(?:\s|$))(?:\s.*)?$/,/^tree(?!.*\s(?:-o|--output)(?:=|\s|$))(?:\s.*)?$/,/^git\s+(?:--version|version)$/,/^git\s+(?:blame|cat-file|count-objects|describe|for-each-ref|ls-files|ls-tree|merge-base|name-rev|rev-parse|shortlog|show-ref|status|verify-pack)(?:\s.*)?$/,/^git\s+(?:diff|log|show)(?!.*\s(?:--ext-diff|--output)(?:=|\s|$))(?:\s.*)?$/,/^git\s+branch$/,/^git\s+branch(?=.*\s(?:-a|--all|-r|--remotes|--list|--show-current|--contains|--no-contains|--merged|--no-merged)(?:=|\s|$))(?!.*\s(?:-[dDmMcCf]|--(?:copy|create-reflog|delete|edit-description|move|set-upstream-to|unset-upstream))(?:=|\s|$))(?:\s.*)?$/,/^git\s+config(?:\s+(?:--blob(?:=|\s)\S+|--file(?:=|\s)\S+|--fixed-value|--global|--local|--null|--show-names|--show-origin|--show-scope|--system|--worktree|-z))*\s+(?:--get|--get-all|--get-regexp|--get-urlmatch|--list|-l)(?:\s.*)?$/,/^git\s+notes\s+(?:list|show)(?:\s.*)?$/,/^git\s+reflog\s+show(?:\s.*)?$/,/^git\s+remote(?:\s+-v)?$/,/^git\s+remote\s+get-url(?:\s+(?:--all|--push))*\s+\S+$/,/^git\s+remote\s+show(?:\s+-n)?(?:\s+\S+)?$/,/^git\s+stash\s+(?:list|show)(?:\s.*)?$/,/^git\s+submodule\s+(?:status|summary)(?:\s.*)?$/,/^git\s+tag(?:\s+(?:-l|--list)(?:\s.*)?)?$/,/^git\s+worktree\s+list(?:\s.*)?$/,/^(?:bun|npm|pnpm|yarn)\s+(?:explain|help|info|list|ls|outdated|prefix|query|root|search|show|view|why)(?:\s.*)?$/,/^(?:npm|pnpm|yarn)\s+config\s+(?:get|list)(?:\s.*)?$/,/^npm\s+pkg\s+get(?:\s.*)?$/,/^bun\s+pm\s+ls(?:\s.*)?$/,/^(?:bun|cargo|clang|cmake|composer|deno|gcc|gem|node|npm|php|pip|pip3|pnpm|python|python3|ruby|rustc|swift|yarn)\s+(?:--version|-V)$/,/^(?:go|helm|kubectl|podman|terraform)\s+version(?:\s.*)?$/,/^(?:java|javac)\s+-version$/,/^dotnet\s+(?:--info|--list-runtimes|--list-sdks|--version)$/,/^(?:docker|podman)\s+(?:diff|events|images|info|inspect|logs|port|ps|stats|top|version)(?:\s.*)?$/,/^(?:docker|podman)\s+(?:container|image|network|volume)\s+(?:inspect|ls)(?:\s.*)?$/,/^docker\s+compose\s+(?:config|images|logs|ps|top|version)(?:\s.*)?$/,/^kubectl\s+(?:api-resources|api-versions|cluster-info|describe|explain|get|logs|top|version)(?:\s.*)?$/,/^kubectl\s+config\s+(?:current-context|get-contexts|view)(?:\s.*)?$/,/^helm\s+(?:env|get|history|list|search|show|status|version)(?:\s.*)?$/,/^terraform\s+(?:output|providers|show|version)(?:\s.*)?$/,/^terraform\s+workspace\s+(?:list|show)(?:\s.*)?$/,/^systemctl\s+(?:is-active|is-enabled|is-failed|list-dependencies|list-jobs|list-sockets|list-timers|list-unit-files|list-units|show|show-environment|status)(?:\s.*)?$/,/^launchctl\s+(?:error|hostinfo|list|managername|managerpid|manageruid|print|print-cache|procinfo|variant|version)(?:\s.*)?$/,/^journalctl(?!.*\s--(?:rotate|vacuum|flush|sync))(?:\s.*)?$/,/^defaults\s+read(?:\s.*)?$/,/^ifconfig$/,/^ipconfig(?:\s+\/(?:all|allcompartments|displaydns))?\s*$/,/^ip\s+(?:addr(?:ess)?|route)$/,/^ip\s+(?:addr(?:ess)?|link|route|neigh(?:bor)?)\s+(?:show|list)\b(?:\s.*)?$/,/^tar\s+(?:--list\b|-[a-zA-Z]*t[a-zA-Z]*)(?:\s.*)?$/,/^unzip\s+-[a-zA-Z]*l(?:\s.*)?$/,/^git\s+(?:grep|fsck|rev-list|whatchanged|help|diff-tree|diff-index|diff-files|ls-remote|verify-tag|verify-commit)(?:\s.*)?$/,/^git\s+archive(?!.*\s(?:-o|--output)(?:=|\s|$))(?:\s.*)?$/,/^svn\s+(?:status|stat|st|diff|di|log|info|list|ls|cat|blame|ann|annotate|proplist|propget|pg)(?:\s.*)?$/,/^hg\s+(?:status|st|log|diff|summary|id|identify|branches|tags|manifest|cat|files|locate|heads|tip|parents|paths|root)(?:\s.*)?$/,/^cargo\s+(?:tree|search|locate-project|verify-project|config\s+get)(?:\s.*)?$/,/^gem\s+(?:list|search|info|env|dependency|contents|specification|sources\s+(?:-l|--list))(?:\s.*)?$/,/^brew\s+(?:--version|-v|list|info|search|outdated|deps|uses|config|leaves|doctor)(?:\s.*)?$/,/^choco\s+(?:--version|list|info|search|outdated)(?:\s.*)?$/,/^apt(?:-get)?\s+list(?:\s.*)?$/,/^apt-cache\s+(?:search|show|showpkg|policy|depends|rdepends|pkgnames)(?:\s.*)?$/,/^dpkg\s+(?:-l|-L|-s|-S|--list|--listfiles|--status|--search)\b(?:\s.*)?$/,/^rpm\s+-q[a-zA-Z]*(?:\s.*)?$/,/^(?:aws|gh|gcloud|az)\s+--version$/,/^aws\s+(?:\S+\s+)?(?:describe|list|get|wait)-\S+(?:\s.*)?$/,/^aws\s+s3\s+ls(?:\s.*)?$/,/^gcloud\s+\S+(?:\s+\S+)*\s+(?:list|describe)(?:\s.*)?$/,/^az\s+\S+(?:\s+\S+)*\s+(?:list|show)(?:\s.*)?$/,/^gh\s+(?:pr|issue|repo|run|release|gist)\s+(?:view|list|status|checks|diff)(?:\s.*)?$/,/^(?:docker|podman)\s+(?:system\s+(?:df|info)|history|context\s+(?:ls|list|show|inspect))(?:\s.*)?$/,/^(?:Get-(?:Acl|Alias|AuthenticodeSignature|ChildItem|CimInstance|Clipboard|Command|ComputerInfo|Content|Counter|Culture|Date|DnsClientCache|EventLog|ExecutionPolicy|FileHash|Help|History|Host|HotFix|Item|ItemProperty|Location|Member|Module|NetAdapter|NetIPAddress|NetNeighbor|NetIPConfiguration|NetRoute|NetTCPConnection|NetUDPEndpoint|Package|PackageProvider|PnpDevice|Printer|Process|PSDrive|PSProvider|PSRepository|PSSnapin|ScheduledTask|Service|TimeZone|UICulture|Variable|Verb|WinEvent|WmiObject)|Compare-Object|Format-(?:Custom|Hex|List|Table|Wide)|Group-Object|Measure-Object|Out-String|Resolve-Path|Select-Object|Select-String|Sort-Object|Test-Path|Where-Object|Write-(?:Debug|Error|Host|Information|Output|Progress|Verbose|Warning))(?:\s.*)?$/i],H={Bash:"command",PowerShell:"command",ComputerUse:"action",ReadFile:"file_path",WriteFile:"file_path",EditFile:"file_path",Glob:"pattern",Grep:"pattern",InstallSkill:"source"},U=[];function v(n,e){if(n==="McpCall")return C(c(e,"server",""),c(e,"tool",""));let s=H[n];if(!s)return"";let t=e[s];return typeof t=="string"?t:n==="ComputerUse"&&Array.isArray(e.actions)?e.actions.map(r=>j(r)?c(r,"type"):"").filter(Boolean).join(","):""}var P=class{allowedRoots;denyWritePaths;projectDir;constructor(e){this.projectDir=f(e),this.allowedRoots=[this.projectDir,_()],this.denyWritePaths=U.map(s=>g(this.projectDir,s))}addRoot(e){this.allowedRoots.push(f(e))}addDenyWrite(e){this.denyWritePaths.push(f(e))}checkDenyWrite(e){let s=f(this.projectDir,e),t=d(s);for(let r of this.denyWritePaths)if(m(r,s)||m(d(r),t))return{effect:"deny",reason:`Path ${e} is in deny-write list`};return null}check(e){let s=d(f(this.projectDir,e));for(let t of this.allowedRoots)if(m(d(t),s))return null;return{effect:"deny",reason:`Path ${e} is outside allowed directories`}}};function q(n,e){let s="^"+n.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*/g,".*").replace(/\?/g,".")+"$";try{return new RegExp(s).test(e)}catch(t){return k.error({err:t},"permissions operation failed"),!1}}var V=/^(\w+)\((.+)\)$/;function A(n){let e;try{e=I(n,"utf-8")}catch(i){return i.code!=="ENOENT"&&k.error({err:i},"permissions operation failed"),[]}let s=p.looseObject({rule:p.string().optional(),effect:p.string().optional()}),t;try{let i=y.load(e);t=S(p.array(s),i)}catch(i){return k.error({err:i},"permissions operation failed"),[]}let r=[];for(let i of t){if(i.effect!=="allow"&&i.effect!=="deny"&&i.effect!=="ask")continue;let o=V.exec((i.rule??"").trim());o&&r.push({tool:o[1],pattern:o[2],effect:i.effect})}return r}function h(n,e,s){let t=null;for(let r of n)if(!(r.tool!==e&&r.tool!=="*")&&q(r.pattern,s)){if(r.effect==="deny")return"deny";r.effect==="ask"?t="ask":t??="allow"}return t}var x=class{userPath;projectPath;cache=new Map;constructor(e){this.userPath=g(T(),".yukino","permissions.yaml"),this.projectPath=g(e,".yukino","permissions.yaml")}rulesFor(e){let s;try{s=W(e,{bigint:!0})}catch{return this.cache.delete(e),[]}let t=this.cache.get(e);if(t?.mtimeNs===s.mtimeNs&&t.size===s.size)return t.rules;let r=A(e);return this.cache.set(e,{mtimeNs:s.mtimeNs,size:s.size,rules:r}),r}snapshot(){return[this.userPath,this.projectPath].flatMap(e=>this.rulesFor(e))}evaluate(e,s){return h(this.snapshot(),e,s)}appendProjectRule(e){M(z(this.projectPath),{recursive:!0});let s=A(this.projectPath);if(s.some(i=>i.tool===e.tool&&i.pattern===e.pattern&&i.effect===e.effect))return;s.push(e);let r=s.map(i=>({rule:`${i.tool}(${i.pattern})`,effect:i.effect}));O(this.projectPath,y.dump(r),"utf-8")}};function G(n){for(let e of L)if(e.re.test(n))return e.reason;return""}function Y(n){let e=n.trim();return/[\r\n&|;<>`(){}[\]]/.test(e)?!1:N.some(s=>typeof s=="string"?e===s||e.startsWith(s+" ")||e.startsWith(s+" "):(s.lastIndex=0,s.test(e)))}function Z(n,e){switch(n){case"bypassPermissions":return"allow";case"plan":return e==="read"?"allow":"ask";case"acceptEdits":return e==="command"?"ask":"allow";default:return e==="read"?"allow":"ask"}}var F=class n{constructor(e,s="default"){this.workDir=e;this.mode=s,this.sandbox=new P(e),this.ruleEngine=new x(e)}workDir;mode;planFilePath="";sandboxEnabled=!1;sandboxAutoAllow=!1;sandbox;ruleEngine;forWorkDir(e){let s=new n(e,this.mode);return s.ruleEngine=this.ruleEngine,s.sandboxEnabled=this.sandboxEnabled,s.sandboxAutoAllow=this.sandboxAutoAllow,s}check(e,s,t){let r=v(e,t),i=null,o=()=>i??=this.ruleEngine.snapshot(),a=h(o(),e,r);if(a==="deny"||a==="ask")return{effect:a,reason:`Permission rule: ${a}`};if(this.mode==="plan"&&(e==="WriteFile"||e==="EditFile")){let u=c(t,"file_path","");if(this.planFilePath&&d(f(this.workDir,u))===d(f(this.workDir,this.planFilePath))&&!this.sandbox.checkDenyWrite(u))return{effect:"allow",reason:"Plan file write allowed in plan mode"}}if(s==="command"&&Y(r))return{effect:"allow",reason:"Safe read-only command"};let E=s==="command"?G(r):"";if(E)return{effect:"deny",reason:`Dangerous command blocked: ${E}`};if(this.sandboxEnabled&&this.sandboxAutoAllow&&e==="Bash"){let u=c(t,"command").split(/\s*(?:&&|\|\||[;|])\s*/).map(w=>w.trim()).filter(Boolean),l=!1;for(let w of u){let R=h(o(),e,w);if(R==="deny")return{effect:"deny",reason:"Permission rule: deny"};R==="ask"&&(l=!0)}return l?{effect:"ask",reason:"Permission rule: ask (sandbox does not override)"}:{effect:"allow",reason:"Sandbox auto-allow: OS sandbox active"}}let $=c(t,"file_path",c(t,"path",""));if((s==="read"||s==="write")&&$){if(s==="write"){let l=this.sandbox.checkDenyWrite($);if(l)return l}let u=this.sandbox.check($);if(u&&this.mode!=="bypassPermissions"){let l=this.ruleEngine.evaluate(e,r);return l?{effect:l,reason:`Permission rule: ${l}`}:{effect:"ask",reason:u.reason}}}let b=h(o(),e,r);return b?{effect:b,reason:`Permission rule: ${b}`}:{effect:Z(this.mode,s),reason:`Mode: ${this.mode}`}}allowExtraRoot(e){this.sandbox.addRoot(e)}allowAlways(e,s){let t=v(e,s),r=e==="ReadFile"||e==="WriteFile"||e==="EditFile",i;if(r&&t){let o=f(this.workDir,t),a=!1;try{a=W(o).isDirectory()}catch{}i=g(a?o:z(o),"*")}else i=t.trim().split(/\s+/).slice(0,2).join(" ")+"*";this.ruleEngine.appendProjectRule({tool:e,pattern:i,effect:"allow"})}describeToolAction(e,s){let t=v(e,s);if(t)return t;let r=[];for(let[i,o]of Object.entries(s)){let a=String(o);a.length>80&&(a=a.slice(0,80)+"..."),r.push(`${i}: ${a}`)}return r.join(", ")}};export{v as a,P as b,h as c,x as d,Y as e,F as f};