UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

4 lines (3 loc) • 4.51 kB
import { createRequire as __piCreateRequire } from "node:module"; const require = __piCreateRequire(import.meta.url); { const __piWorkerThreads = require("node:worker_threads"); if (typeof __piWorkerThreads.markAsUncloneable !== "function") { __piWorkerThreads.markAsUncloneable = () => {}; } } import{objectType}from"./chunk-RNLFZ67U.js";import{$ZodObject,$ZodType,$constructor,clone,installLazyProp,normalizeParams,own,parse,parseAsync,safeParse,safeParseAsync}from"./chunk-FKX6EWFV.js";var ZodMiniType=$constructor("ZodMiniType",(inst,def)=>{if(!inst._zod)throw new Error("Uninitialized schema in ZodMiniType.");$ZodType.init(inst,def),inst.def=def,inst.type=def.type},{get with(){return this.check},set with(value){own(this,"with",value)},parse(data,params){return parse(this,data,params,{callee:this.parse})},parseAsync(data,params){return parseAsync(this,data,params,{callee:this.parseAsync})},safeParse(data,params){return safeParse(this,data,params)},safeParseAsync(data,params){return safeParseAsync(this,data,params)},check(...checks){let def=this.def;return this.clone({...def,checks:[...def.checks??[],...checks.map(ch=>typeof ch=="function"?{_zod:{check:ch,def:{check:"custom"},onattach:[]}}:ch)]},{parent:!0})},clone(_def,params){return clone(this,_def,params)},brand(){return this},register(reg,meta2){return reg.add(this,meta2),this},apply(fn,...args){return args.length===0?fn(this):fn(this,...args)}});var ZodMiniObject=$constructor("ZodMiniObject",(inst,def)=>{$ZodObject.init(inst,def),ZodMiniType.init(inst,def),installLazyProp(inst,"shape",self=>self._zod.def.shape,!1)});function object(shape,params){let def={type:"object",shape:shape??{},...normalizeParams(params)};return new ZodMiniObject(def)}function isZ4Schema(s){return!!s._zod}function objectFromShape(shape){let values=Object.values(shape);if(values.length===0)return object({});let allV4=values.every(isZ4Schema),allV3=values.every(s=>!isZ4Schema(s));if(allV4)return object(shape);if(allV3)return objectType(shape);throw new Error("Mixed Zod versions detected in object shape.")}function safeParse2(schema,data){return isZ4Schema(schema)?safeParse(schema,data):schema.safeParse(data)}async function safeParseAsync2(schema,data){return isZ4Schema(schema)?await safeParseAsync(schema,data):await schema.safeParseAsync(data)}function getObjectShape(schema){if(!schema)return;let rawShape;if(isZ4Schema(schema)?rawShape=schema._zod?.def?.shape:rawShape=schema.shape,!!rawShape){if(typeof rawShape=="function")try{return rawShape()}catch{return}return rawShape}}function normalizeObjectSchema(schema){if(schema){if(typeof schema=="object"){let asV3=schema,asV4=schema;if(!asV3._def&&!asV4._zod){let values=Object.values(schema);if(values.length>0&&values.every(v=>typeof v=="object"&&v!==null&&(v._def!==void 0||v._zod!==void 0||typeof v.parse=="function")))return objectFromShape(schema)}}if(isZ4Schema(schema)){let def=schema._zod?.def;if(def&&(def.type==="object"||def.shape!==void 0))return schema}else if(schema.shape!==void 0)return schema}}function getDotPath(path){return path.length===0?"object root":path.reduce((acc,seg,index)=>index===0?String(seg):typeof seg=="number"?`${acc}[${seg}]`:`${acc}.${seg}`,"")}function getParseErrorMessage(error){if(error&&typeof error=="object"){if("issues"in error&&Array.isArray(error.issues)&&error.issues.length>0)return error.issues.map(i=>i.path?.length?`${i.message} at ${getDotPath(i.path)}`:i.message).join(` `);if("message"in error&&typeof error.message=="string")return error.message;try{return JSON.stringify(error)}catch{return String(error)}}return String(error)}function getSchemaDescription(schema){return schema.description}function isSchemaOptional(schema){if(isZ4Schema(schema))return schema._zod?.def?.type==="optional";let v3Schema=schema;return typeof schema.isOptional=="function"?schema.isOptional():v3Schema._def?.typeName==="ZodOptional"}function getLiteralValue(schema){if(isZ4Schema(schema)){let def2=schema._zod?.def;if(def2){if(def2.value!==void 0)return def2.value;if(Array.isArray(def2.values)&&def2.values.length>0)return def2.values[0]}}let def=schema._def;if(def){if(def.value!==void 0)return def.value;if(Array.isArray(def.values)&&def.values.length>0)return def.values[0]}let directValue=schema.value;if(directValue!==void 0)return directValue}export{isZ4Schema,objectFromShape,safeParse2 as safeParse,safeParseAsync2 as safeParseAsync,getObjectShape,normalizeObjectSchema,getParseErrorMessage,getSchemaDescription,isSchemaOptional,getLiteralValue};