UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

3 lines • 2.13 kB
import{m as readNonBlankString}from"./string-coerce-CpTFcSwY.mjs";import{t as expandHomePrefix}from"./home-dir-DEN5DisQ.mjs";import{o as writeRuntimeJson,r as defaultRuntime}from"./runtime-DIcLIHcp.mjs";import{n as sanitizeTerminalText}from"./safe-text-B_QTgn0s.mjs";import{f as shortenHomePath}from"./utils-Dlk0IYAa.mjs";import{t as formatErrorMessage}from"./errors-D37BJTfI.mjs";import{n as throwExpectedCliError}from"./expected-cli-error-oDVmXYil.mjs";import{r as renderBlobsterSvgFromDesignText,t as MAX_BLOBSTER_DESIGN_CHARS}from"./blobster-generation-DuHlY8xL.mjs";import{n as readBoundedCliTextInput}from"./agent-message-input-CSKqkvmS.mjs";import path from"node:path";import fs from"node:fs/promises"; //!src/commands/agents.commands.blobster.ts const MAX_DESIGN_INPUT_BYTES=MAX_BLOBSTER_DESIGN_CHARS*4;async function agentsRenderBlobsterCommand(e){const t=readNonBlankString(e.design);if(!t)throwExpectedCliError(`Design path must not be blank`);const n=readNonBlankString(e.out);if(!n)throwExpectedCliError(`--out must not be blank`);const r=path.resolve(expandHomePrefix(n));const i=path.extname(r).toLowerCase();if(i!==`.svg`&&i!==`.png`)throwExpectedCliError(`--out must end with .svg or .png`);const a=i===`.png`?`png`:`svg`;let o;try{o=await readBoundedCliTextInput(t===`-`?`-`:expandHomePrefix(t),{maxBytes:MAX_DESIGN_INPUT_BYTES,label:`Design`})}catch(e){throwExpectedCliError(formatErrorMessage(e))}let s;try{s=renderBlobsterSvgFromDesignText(o)}catch(e){throwExpectedCliError(`Invalid Blobster design: ${formatErrorMessage(e)}`)}let c;if(a===`png`){const{Resvg:e}=await import(`@resvg/resvg-js`);c=new e(s.svg,{font:{loadSystemFonts:false}}).render().asPng()}else c=Buffer.from(s.svg,`utf8`);await fs.mkdir(path.dirname(r),{recursive:true});await fs.writeFile(r,c);if(e.json){writeRuntimeJson(defaultRuntime,{id:s.id,name:s.name,description:s.description,out:r,format:a,bytes:c.byteLength});return}defaultRuntime.log(`Name: ${sanitizeTerminalText(s.name)}`);defaultRuntime.log(`Output: ${sanitizeTerminalText(shortenHomePath(r))}`);defaultRuntime.log(`Bytes: ${c.byteLength}`)}export{agentsRenderBlobsterCommand};