@yukino.js/yukino 0.0.12 → 0.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -69
- package/dist/{a2a-RMMY65QU.js → a2a-DKWMWGID.js} +2 -2
- package/dist/{acp-WY6JO5LK.js → acp-RL6DKS3R.js} +1 -1
- package/dist/{anthropic-55TYAIKB.js → anthropic-74ALYMH2.js} +1 -1
- package/dist/{chunk-SYKQXO6W.js → chunk-556TRLPT.js} +1 -1
- package/dist/{chunk-7TZ52NFW.js → chunk-6FSIG63T.js} +25 -25
- package/dist/{chunk-HTLXOBAC.js → chunk-6JUOKMSJ.js} +1 -1
- package/dist/{chunk-V7Q2SA7H.js → chunk-A5G5NTDB.js} +179 -173
- package/dist/{chunk-4CLD7LEU.js → chunk-A7CJPQC5.js} +1 -1
- package/dist/{chunk-33HUTVDG.js → chunk-APJAUOF6.js} +1 -1
- package/dist/{chunk-IX65B3M7.js → chunk-CJSMVCUF.js} +1 -1
- package/dist/{chunk-OI2W6R6H.js → chunk-HWCLMDQF.js} +8 -8
- package/dist/chunk-NEU4ER5V.js +4 -0
- package/dist/{chunk-5URXBVET.js → chunk-OREDGNI6.js} +1 -1
- package/dist/chunk-SCR7NDDL.js +63 -0
- package/dist/lib/{anthropic-AVZIC22O.js → anthropic-EQRUGP2C.js} +4 -4
- package/dist/lib/{chunk-XH7D5FLE.js → chunk-CDMR25FD.js} +3 -3
- package/dist/lib/{chunk-O2H6VKKR.js → chunk-EGT7BJRD.js} +2 -2
- package/dist/lib/{chunk-LSI3T24Q.js → chunk-FUJDUZTH.js} +1 -1
- package/dist/lib/{chunk-GVI5R2DA.js → chunk-HUTUNNDX.js} +1 -1
- package/dist/lib/{chunk-WL3ML2TB.js → chunk-JYCSWXCR.js} +2 -2
- package/dist/lib/{chunk-QJ32WYQY.js → chunk-UBVKYJFI.js} +124 -27
- package/dist/lib/{chunk-TUNZLQLO.js → chunk-WWCSFKMR.js} +1 -1
- package/dist/lib/index.d.ts +61 -38
- package/dist/lib/index.js +383 -202
- package/dist/lib/{openai-54IQOU6Y.js → openai-B3I5WBFT.js} +3 -3
- package/dist/lib/{providers-DPVHJZAX.js → providers-EJ4VBHNP.js} +2 -2
- package/dist/lib/{tool-filter-5Z6UTRRR.js → tool-filter-TURPCYFR.js} +3 -3
- package/dist/{main-L3JP6JDZ.js → main-JEEKFCGX.js} +226 -217
- package/dist/main.js +11 -2
- package/dist/{openai-I2TTMBWK.js → openai-7C6BVQ7M.js} +1 -1
- package/dist/{providers-VFEHLGQG.js → providers-U23PWAHG.js} +1 -1
- package/dist/{server-F4PJ3W62.js → server-EOSEQPNY.js} +1 -1
- package/dist/tool-filter-UDSHRE5F.js +4 -0
- package/package.json +1 -1
- package/dist/chunk-D4MZQCMB.js +0 -59
- package/dist/chunk-PWLFGDME.js +0 -4
- package/dist/tool-filter-5WW6YGKC.js +0 -4
|
@@ -1,5 +1,5 @@
|
|
|
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{a as _}from"./chunk-MQAQBW7F.js";import{b}from"./chunk-
|
|
4
|
+
import{a as _}from"./chunk-MQAQBW7F.js";import{b}from"./chunk-HWCLMDQF.js";import{C as r,b as x}from"./chunk-W4GMCNWF.js";function m(){return b("config.yaml")}var g=["off","minimal","low","medium","high","xhigh","max"],p=r.enum(["none","minimal","low","medium","high","xhigh","max"]),D=r.enum(["low","medium","high","xhigh","max"]),M=r.strictObject({off:r.literal("none").nullable().optional(),minimal:p.nullable().optional(),low:p.nullable().optional(),medium:p.nullable().optional(),high:p.nullable().optional(),xhigh:p.nullable().optional(),max:p.nullable().optional()}),y=r.looseObject({name:r.string(),protocol:r.enum(["anthropic","openai","openai-compat"]),base_url:r.string(),model:r.string(),api_key:r.string().optional(),thinking:r.enum(g).optional(),reasoning:r.boolean().optional(),thinking_level_map:M.optional(),thinking_mode:r.enum(["budget","adaptive"]).optional(),context_window:r.coerce.number().optional(),max_output_tokens:r.coerce.number().optional()});function ue(e,n){return e[n]??e[0]}var K="high",d=1e6,h=128e3,V={minimal:1024,low:2048,medium:8192,high:16384,xhigh:32768,max:65536},$=1024,F=1024;function ae(e){return g.some(n=>n===e)}function v(e){return B(e,e.thinking??K)}function fe(e){return e==="off"?0:V[e]}function w(e,n){if(n?.reasoning===!1)return null;if(e==="off")return"none";let t=n?.thinking_level_map?.[e];if(t!==void 0)return t;if(n?.protocol==="anthropic"&&n.thinking_mode==="adaptive"){if(e==="minimal")return"low";if(e==="xhigh")return"high"}return(n?.protocol==="openai"||n?.protocol==="openai-compat")&&(e==="xhigh"||e==="max")?"high":e}function G(e,n){let t=D.safeParse(w(e,n));return t.success?t.data:null}function H(e){return e.reasoning===!1||e.protocol==="anthropic"&&e.thinking_mode!=="adaptive"&&P(e)<$+F?["off"]:g.filter(n=>{if(n==="off")return!0;if(e.protocol==="anthropic"&&e.thinking_mode==="adaptive")return G(n,e)!==null;let t=w(n,e);return!(t===null||t==="none"||(e.protocol==="openai"||e.protocol==="openai-compat")&&(n==="xhigh"||n==="max")&&e.thinking_level_map?.[n]===void 0)})}function B(e,n){let t=H(e),o="off";for(let s of g)if(t.includes(s)&&(o=s),s===n)break;return o}function ce(e){return{...e,thinking:v(e),context_window:E(e),max_output_tokens:P(e)}}function E(e){return Number.isSafeInteger(e.context_window)&&(e.context_window??0)>0?e.context_window??d:d}function P(e){let n=e.max_output_tokens,t=Number.isSafeInteger(n)&&(n??0)>0?n??h:h;return Math.min(t,E(e))}import{randomUUID as W}from"crypto";import{existsSync as N,mkdirSync as X,readFileSync as q,renameSync as Z,unlinkSync as J,writeFileSync as Q}from"fs";import{dirname as Y,join as ee}from"path";var L=(e,n,t)=>r.preprocess(o=>o===void 0||typeof o=="string"&&!o.trim()?e:o,r.union([r.number(),r.string().trim().regex(/^\d+$/,"Enter a whole number").transform(Number)]).pipe(r.number().int().min(n).max(t))),ne=y.extend({name:r.string().trim().min(1,"Name is required"),base_url:r.url("Enter a valid HTTP(S) URL").refine(e=>/^https?:\/\//i.test(e),"Use an HTTP(S) URL"),api_key:r.string().trim().min(1,"API key is required"),model:r.string().trim().min(1,"Model is required"),thinking:r.enum(g).optional(),context_window:L(d,1e3,1e7),max_output_tokens:L(h,1,1e6)}).refine(e=>e.max_output_tokens<=e.context_window,{path:["max_output_tokens"],message:"Max output tokens must not exceed the context window"}).transform(e=>({...e,thinking:v(e)}));function k(e){if(!N(e))return{};let n;try{n=_.load(q(e,"utf-8"))}catch{throw new Error(`Unable to read existing ${e}; it has not been changed.`)}return r.record(r.string(),r.unknown()).parse(n??{})}function T(e,n){let t=Y(e);X(t,{recursive:!0});let o=ee(t,`.config-${W()}.tmp`);try{Q(o,_.dump(n,{lineWidth:-1,noRefs:!0}),{encoding:"utf-8",mode:384,flag:"wx"}),Z(o,e)}finally{N(o)&&J(o)}}function _e(e,n){let t=ne.parse(e),o=m(),s=k(o),f=[...r.array(r.record(r.string(),r.unknown())).parse(s.providers??[])];for(let c of n)f.some(z=>z.base_url===c.base_url)||f.push({...c});let i=[],a=!1;for(let c of f){if(c.base_url!==t.base_url){i.push(c);continue}a||(a=!0,i.push(t))}a||i.push(t);let j=i.map(c=>y.parse(c));return T(o,{...s,providers:i}),{provider:t,providers:j,replaced:a,path:o}}function A(e,n,t){let o=m(),s=k(o),u=r.array(r.record(r.string(),r.unknown())).parse(s.providers??[]),f=u.filter(a=>a.base_url===e);if(f.length===0)throw new Error(`Provider with base URL "${e}" not found in ${o}.`);let i=f.filter(a=>a[n]!==t);if(i.length!==0){for(let a of i)a[n]=t;T(o,{...s,providers:u})}}function ye(e,n){A(e,"thinking",n)}function ve(e,n){A(e,"model",n)}function ke(e){let n=m(),t=k(n);t.default_provider!==e&&T(n,{...t,default_provider:e})}var te="Tool execution was interrupted. The tool may or may not have completed; verify before relying on its effects.",Se="The user rejected this tool use. Nothing was changed (for file edits, the new content was NOT written).";function be(e){let n=[];for(let t=0;t<e.length;t++){let o=e[t];if(o.role==="assistant"&&o.toolUses?.length){n.push(o);let s=new Set(o.toolUses.map(i=>i.toolUseId)),u=[],f=[];for(;t+1<e.length;){let i=e[t+1];if(i.role!=="user"||!i.toolResults?.length||i.toolUses?.length)break;t++,f.push(i);for(let a of i.toolResults)s.delete(a.toolUseId)&&u.push(a)}for(let i of s)u.push({toolUseId:i,content:te,isError:!0});n.push({...f[0]??{role:"user",content:""},toolResults:u});for(let i of f.slice(1))(i.content.length>0||i.thinkingBlocks?.length)&&n.push({...i,toolResults:[]});continue}if((o.toolResults?.length??0)>0){if(o.content.length===0&&!o.toolUses?.length&&!o.thinkingBlocks?.length)continue;n.push({...o,toolResults:[]})}else n.push(o)}return n}var l=class extends Error{constructor(n){super(n),this.name="LLMError"}},C=class extends l{constructor(n){super(n),this.name="AuthenticationError"}},O=class extends l{retryAfter;constructor(n,t){super(n),this.name="RateLimitError",this.retryAfter=t}},U=class extends l{constructor(n){super(n),this.name="NetworkError"}},I=class extends l{constructor(t,o){super(t);this.retryAfter=o;this.name="ServerError"}retryAfter},R=class extends l{constructor(n){super(n),this.name="ContextTooLongError"}};function Ee(e){return/context_length_exceeded/i.test(e)||/maximum\s+context\s+length/i.test(e)||/prompts?\s+(?:is\s+)?too\s+long/i.test(e)}function S(e){return!!e._zod}function Ge(e,n){return S(e)?x(e,n):e.safeParse(n)}function He(e){if(!e)return;let n;if(S(e)?n=e._zod?.def?.shape:n=e.shape,!!n){if(typeof n=="function")try{return n()}catch{return}return n}}function re(e){return e.length===0?"object root":e.reduce((n,t,o)=>o===0?String(t):typeof t=="number"?`${n}[${t}]`:`${n}.${t}`,"")}function Be(e){if(e&&typeof e=="object"){if("issues"in e&&Array.isArray(e.issues)&&e.issues.length>0)return e.issues.map(n=>n.path?.length?`${n.message} at ${re(n.path)}`:n.message).join(`
|
|
5
5
|
`);if("message"in e&&typeof e.message=="string")return e.message;try{return JSON.stringify(e)}catch{return String(e)}}return String(e)}function We(e){if(S(e)){let u=e._zod?.def;if(u){if(u.value!==void 0)return u.value;if(Array.isArray(u.values)&&u.values.length>0)return u.values[0]}}let t=e._def;if(t){if(t.value!==void 0)return t.value;if(Array.isArray(t.values)&&t.values.length>0)return t.values[0]}let o=e.value;if(o!==void 0)return o}export{Ge as a,He as b,Be as c,We as d,m as e,g as f,y as g,ue as h,K as i,d as j,h as k,F as l,ae as m,v as n,fe as o,w as p,G as q,H as r,B as s,ce as t,E as u,P as v,ne as w,_e as x,ye as y,ve as z,ke as A,Se as B,be as C,l as D,C as E,O as F,U as G,I as H,R as I,Ee as J};
|
|
@@ -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{k as h,p as g,r as T,v as c}from"./chunk-
|
|
4
|
+
import{k as h,p as g,r as T,v as c}from"./chunk-HWCLMDQF.js";function u(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}var C=new Set(["image/jpeg","image/png","image/gif","image/webp"]);function R(e){return C.has(e)}function y(e){return u(e)&&e.type==="text"&&typeof e.text=="string"?{type:"text",text:e.text}:null}function k(e){return!u(e)||e.type!=="image"||!u(e.source)?null:e.source.type==="url"&&typeof e.source.url=="string"?{type:"image",source:{type:"url",url:e.source.url}}:e.source.type==="base64"&&typeof e.source.media_type=="string"&&R(e.source.media_type)&&typeof e.source.data=="string"?{type:"image",source:{type:"base64",media_type:e.source.media_type,data:e.source.data}}:null}function _(e){if(e.type!=="document"||!u(e.source))return null;let t=null;if(e.source.type==="url"&&typeof e.source.url=="string")t={type:"url",url:e.source.url};else if(e.source.type==="base64"&&e.source.media_type==="application/pdf"&&typeof e.source.data=="string")t={type:"base64",media_type:"application/pdf",data:e.source.data};else if(e.source.type==="text"&&e.source.media_type==="text/plain"&&typeof e.source.data=="string")t={type:"text",media_type:"text/plain",data:e.source.data};else if(e.source.type==="content"){if(typeof e.source.content=="string")t={type:"content",content:e.source.content};else if(Array.isArray(e.source.content)){let o=[];for(let r of e.source.content){let i=y(r)??k(r);if(!i)return null;o.push(i)}t={type:"content",content:o}}}return t?{type:"document",source:t,...typeof e.title=="string"||e.title===null?{title:e.title}:{},...typeof e.context=="string"||e.context===null?{context:e.context}:{}}:null}function I(e){let t=y(e);if(t)return t;let o=k(e);if(o)return o;if(!u(e))return null;if(e.type==="tool_reference"&&typeof e.tool_name=="string")return{type:"tool_reference",tool_name:e.tool_name};if(e.type==="search_result"&&typeof e.source=="string"&&typeof e.title=="string"&&Array.isArray(e.content)){let r=[];for(let i of e.content){let n=y(i);if(!n)return null;r.push(n)}return{type:"search_result",source:e.source,title:e.title,content:r}}return _(e)}var j=new Set([".agents",".git",".yukino",".next",".venv",".mypy_cache","__pycache__","dist","node_modules"]);var A=h({module:"mcp"}),a="mcp__",l="__";function m(e){return e.replace(/[^a-zA-Z0-9_]/g,"_")}function M(e){let t=m(e);return`${a}${String(t.length)}_${t}${l}`}function f(e,t){return M(e)+m(t)}var x=class{name;description;category="command";deferred=!0;mcpServerName;client;originalName;inputSchema;constructor(t,o,r){this.name=f(o,r.name),this.description=r.description,this.originalName=r.name,this.client=t,this.inputSchema=r.inputSchema,this.mcpServerName=o}mcpInputSchema(){return this.inputSchema??{}}setDeferLoading(t){this.deferred=t}schema(){return{name:this.name,description:this.description,input_schema:this.inputSchema}}async execute(t,o){try{return await this.client.callTool(this.originalName,o,t.abortSignal)}catch(r){return A.error({err:r},"mcp operation failed"),{output:`MCP tool error: ${T(r)}`,isError:!0}}}};function w(e,t){if(t==="string"&&typeof e=="number"&&Number.isFinite(e))return String(e);if((t==="integer"||t==="number")&&typeof e=="string"){let o=e.trim();if(o===""||!(t==="integer"?/^[+-]?\d+$/:/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/).test(o))return e;let i=t==="integer"?Number.parseInt(o,10):Number.parseFloat(o);return Number.isFinite(i)?i:e}if(t==="boolean"&&typeof e=="string"){let o=e.trim().toLowerCase();if(o==="true")return!0;if(o==="false")return!1}return e}function d(e,t){if(typeof t!="object"||t===null)return e;let o=g(t),r=c(o,"type","");if(r==="object"&&typeof e=="object"&&e!==null&&!Array.isArray(e)){let i=g(o.properties??{}),n={};for(let[s,p]of Object.entries(e))n[s]=s in i?d(p,i[s]):p;return n}if(r==="array"){let i=o.items??{},n=e;if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let s=Object.values(n);s.length===1&&Array.isArray(s[0])&&(n=s[0])}else typeof n=="string"&&(n=n.split(",").map(s=>s.trim()).filter(s=>s!==""));return Array.isArray(n)?n.map(s=>d(s,i)):n}return r!==""?w(e,r):e}function D(e,t){if(t.startsWith(a)){let o=t.slice(a.length),r=/^(\d+)_/u.exec(o);if(r){let i=r[0].length,n=Number.parseInt(r[1],10),s=i+n;if(o.slice(s,s+2)===l)return o.slice(i,s)+l+o.slice(s+l.length)}}return m(e)+l+m(t)}function P(e){return"mcpInputSchema"in e&&typeof e.mcpInputSchema=="function"}var S=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 o=c(t,"server"),r=c(t,"tool");if(!o||!r)return;let i=r.startsWith(a)?r:f(o,r),n=this.registry.get(i);return n&&P(n)&&n.mcpServerName===o?n:void 0}availableNames(){return this.registry.listTools().filter(t=>t.name.startsWith(a)).map(t=>t.name).sort()}prepareArguments(t){let o=this.resolveTarget(t);return!o||typeof t.arguments!="object"||t.arguments===null||Array.isArray(t.arguments)?t:{...t,arguments:d(t.arguments,o.mcpInputSchema())}}async execute(t,o){let r=c(o,"server",""),i=c(o,"tool","");if(i==="")return{output:"McpCall requires a 'tool' name",isError:!0};let n=this.resolveTarget(o);if(!n){let p=this.availableNames(),b=p.length>0?p.join(", "):"(none connected)";return{output:`Unknown MCP tool '${i}' on server '${r}'. Available tools: ${b}`,isError:!0}}if(typeof o.arguments!="object"||o.arguments===null||Array.isArray(o.arguments))return{output:"McpCall requires an 'arguments' object matching the target schema",isError:!0};let s=g(this.prepareArguments(o).arguments);return t.abortSignal?.throwIfAborted(),n.execute(t,s)}};export{I as a,j as b,a as c,x as d,D as e,P as f,S as g};
|