rawi
Version:
Rawi (راوي) is the developer-friendly AI CLI that brings the power of 11 major AI providers directly to your terminal. With seamless shell integration, persistent conversations, and 200+ specialized prompt templates, Rawi transforms your command line into
4 lines • 2.7 kB
JavaScript
Object.defineProperty(exports, "__esModule", {value: true});/* Rawi (راوي) is the developer-friendly AI CLI that brings the power of 11 major AI providers directly to your terminal. With seamless shell integration, persistent conversations, and 200+ specialized prompt templates, Rawi transforms your command line into an intelligent development workspace. */
var _provider = require('@ai-sdk/provider');var _providerutils = require('@ai-sdk/provider-utils');function f(u){let a=[];for(let{content:s,role:i}of u)switch(i){case"system":{a.push({content:s,role:"system"});break}case"user":{a.push({...s.reduce((t,e)=>{if(e.type==="text")t.content+=e.text;else{if(e.type==="file"&&e.mediaType.startsWith("image/")&&e.data instanceof URL)throw new (0, _provider.UnsupportedFunctionalityError)({functionality:"Image URLs in user messages"});e.type==="file"&&e.mediaType.startsWith("image/")&&typeof e.data=="string"?(t.images=t.images||[],t.images.push(e.data)):e.type==="file"&&e.mediaType.startsWith("image/")&&e.data instanceof Uint8Array&&(t.images=t.images||[],t.images.push(_providerutils.convertUint8ArrayToBase64.call(void 0, e.data)))}return t},{content:""}),role:"user"});break}case"assistant":{let t=[],e=[];for(let o of s)switch(o.type){case"text":{t.push(o.text);break}case"tool-call":{e.push({function:{arguments:o.input,name:o.toolName},id:o.toolCallId,type:"function"});break}case"tool-result":{if(o.output.type==="text"||o.output.type==="error-text")t.push(o.output.value);else if(o.output.type==="json"||o.output.type==="error-json")t.push(JSON.stringify(o.output.value));else if(o.output.type==="content"){let n=o.output.value.map(l=>l.type==="text"?l.text:"[media]").join("");t.push(n)}break}case"file":case"reasoning":break;default:{let n=o;throw new Error(`Unsupported part: ${n}`)}}a.push({content:t.join(","),role:"assistant",tool_calls:e.length>0?e:void 0});break}case"tool":{a.push(...s.map(t=>{let e;return t.output.type==="text"||t.output.type==="error-text"?e=t.output.value:t.output.type==="json"||t.output.type==="error-json"?e=JSON.stringify(t.output.value):t.output.type==="content"?e=t.output.value.map(o=>o.type==="text"?o.text:"[media]").join(""):e=String(t.output),{content:e,role:"tool",tool_call_id:t.toolCallId}}));break}default:{let t=i;throw new Error(`Unsupported role: ${t}`)}}return a}exports.a = f;
/* Rawi (راوي) is the developer-friendly AI CLI that brings the power of 11 major AI providers directly to your terminal. With seamless shell integration, persistent conversations, and 200+ specialized prompt templates, Rawi transforms your command line into an intelligent development workspace. */
//# sourceMappingURL=chunk-KE7P5FK7.cjs.map
;