@easbot/plugin 0.3.29 → 0.3.36

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/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import M,{z as z$1}from'zod';import {AgentPermissionSchema}from'@easbot/types';export{AgentPermissionSchema,PermissionActionSchema,PermissionRuleSchema,buildToolArgs,createTool,toolSchema as schema}from'@easbot/types';import'@easbot/sdk';function P(r){return {description:r.description,args:r.args,execute:r.execute}}P.schema=M;var m={Command:"command",Prompt:"prompt",Http:"http",Agent:"agent",Function:"function"},o={SessionStart:"session.start",SessionEnd:"session.end",SessionCompacting:"session.compacting",SessionCompact:"session.compact",StepStart:"step.start",StepFinish:"step.finish",StepStop:"step.stop",StepStopFailure:"step.stop.failure",MessageReceive:"message.receive",MessageTransform:"message.transform",SystemTransform:"system.transform",ToolBefore:"tool.before",ToolAfter:"tool.after",ToolFailure:"tool.failure",ToolDefinition:"tool.definition",CommandBefore:"command.before",CommandAfter:"command.after",PermissionAsk:"permission.ask",PermissionDenied:"permission.denied",LlmParams:"llm.params",LlmHeaders:"llm.headers",ShellEnv:"shell.env",TextComplete:"text.complete",GatewayMessageReceive:"gateway.message.receive",GatewayMessageProcess:"gateway.message.process",GatewayMessageComplete:"gateway.message.complete",GatewayMessageSend:"gateway.message.send",GatewayMessageDelivered:"gateway.message.delivered",GatewayMessageRead:"gateway.message.read",HeartbeatTrigger:"scheduler.heartbeat.trigger",HeartbeatComplete:"scheduler.heartbeat.complete",ScheduledTaskTrigger:"scheduler.task.trigger",ScheduledTaskComplete:"scheduler.task.complete",CommandTrigger:"scheduler.command.trigger",CommandComplete:"scheduler.command.complete",ContextBuildBefore:"context.build.before",ContextBuildAfter:"context.build.after",TaskStart:"task.start",TaskRunning:"task.running",TaskProgress:"task.progress",TaskComplete:"task.complete",LoopStart:"loop.start",LoopEnd:"loop.end",CreationRequest:"creation.request",CreationComplete:"creation.complete",EvolutionRequest:"evolution.request",EvolutionComplete:"evolution.complete"},Ye=Object.values(o);var y=z$1.string().optional(),w=z$1.object({type:z$1.literal(m.Command),command:z$1.string(),if:y,shell:z$1.enum(["bash","powershell"]).optional(),timeout:z$1.number().positive().optional(),statusMessage:z$1.string().optional(),once:z$1.boolean().optional(),async:z$1.boolean().optional()}),E=z$1.object({type:z$1.literal(m.Prompt),if:y,timeout:z$1.number().positive().optional(),model:z$1.string().optional(),statusMessage:z$1.string().optional(),once:z$1.boolean().optional(),runMode:z$1.enum(["session","fork"]).optional(),system:z$1.string().optional(),parts:z$1.array(z$1.unknown()),onMessage:z$1.custom(r=>typeof r=="function").optional()}),D=z$1.object({type:z$1.literal(m.Http),url:z$1.string(),if:y,timeout:z$1.number().positive().optional(),method:z$1.enum(["GET","POST","PUT","DELETE"]).optional(),headers:z$1.record(z$1.string(),z$1.string()).optional(),allowedEnvVars:z$1.array(z$1.string()).optional(),statusMessage:z$1.string().optional(),once:z$1.boolean().optional()}),A=z$1.object({type:z$1.literal(m.Agent),if:y,timeout:z$1.number().positive().optional(),agent:z$1.string().optional(),model:z$1.string().optional(),statusMessage:z$1.string().optional(),once:z$1.boolean().optional(),system:z$1.string().optional(),parts:z$1.array(z$1.unknown()),onMessage:z$1.custom(r=>typeof r=="function").optional()}),j=z$1.object({type:z$1.literal(m.Function),handler:z$1.function()}),R=z$1.discriminatedUnion("type",[w,E,D,A,j]),z=z$1.object({event:z$1.string(),matcher:z$1.string().optional(),hooks:z$1.array(R)}),rt=z$1.record(z$1.string(),z$1.array(z)),n=z$1.string().min(1).describe("Session unique identifier"),h=z$1.string().min(1).describe("Part unique identifier"),i=z$1.string().min(1).describe("Message unique identifier"),f=z$1.string().min(1).describe("Tool call unique identifier"),u=z$1.string().optional().describe("Agent name"),b=z$1.string().optional().describe("Model identifier"),k=z$1.object({providerId:z$1.string().describe("Provider ID"),modelId:z$1.string().describe("Model ID"),api:z$1.object({id:z$1.string().describe("API ID"),npm:z$1.string().optional().describe("NPM package name")}).optional().describe("API information")}).optional().describe("Model object"),C=z$1.string().optional().describe("Working directory path"),O=z$1.enum(["user_request","max_tokens","stop","error","timeout","cancelled"]).describe("Session end reason"),F=z$1.enum(["stop","max_tokens","end_turn","stop_sequence"]).describe("Step finish reason"),W=z$1.object({sessionId:n,source:z$1.enum(["user","agent","system","scheduled"]).optional().describe("Session source"),model:b,agent:u,cwd:C}),G=z$1.object({sessionId:n,reason:O,duration:z$1.number().positive().optional().describe("Session duration in milliseconds")}),B=z$1.object({sessionId:n,trigger:z$1.enum(["manual","auto","threshold"]).describe("Compaction trigger"),contextLength:z$1.number().positive().describe("Current context length"),threshold:z$1.number().positive().describe("Trigger threshold")}),L=z$1.object({sessionId:n,summary:z$1.string().describe("Compaction summary"),previousLength:z$1.number().positive().describe("Previous context length"),newLength:z$1.number().positive().describe("New context length")}),q=z$1.object({sessionId:n,messageId:i,partId:h.optional().describe("step-start part ID (created by processor before hook trigger)"),userMessageId:i.optional().describe("User message ID for the current step"),model:b,agent:u}),_=z$1.object({sessionId:n,messageId:i,partId:h.optional().describe("step-finish part ID (created by processor before hook trigger)"),userMessageId:i.optional().describe("User message ID for the current step"),model:b,agent:u,finishReason:F,tokens:z$1.object({input:z$1.number().int().nonnegative().optional(),output:z$1.number().int().nonnegative().optional(),total:z$1.number().int().nonnegative().optional()}).optional().describe("Token usage statistics")}),U=z$1.object({sessionId:n,reason:z$1.string().describe("Stop reason")}),N=z$1.object({sessionId:n,error:z$1.string().describe("Error message"),errorType:z$1.enum(["rate_limit","auth_error","network_error","timeout","invalid_request","server_error"]).describe("Error type")}),$=z$1.enum(["user","assistant","system","tool"]),T=z$1.discriminatedUnion("type",[z$1.object({type:z$1.literal("text"),text:z$1.string().describe("Text content")}),z$1.object({type:z$1.literal("image"),source:z$1.object({type:z$1.enum(["base64","url"]),mime:z$1.string().optional().describe("File mime type"),data:z$1.string().describe("File base64 encoding data or url")})}),z$1.object({type:z$1.literal("file"),url:z$1.string().describe("File path"),filename:z$1.string().describe("File name"),mime:z$1.string().optional().describe("File mime type")})]),v=z$1.object({id:i,role:$,content:z$1.union([z$1.string(),z$1.array(T)]),name:z$1.string().optional().describe("Message sender name"),tool_call_id:f.optional().describe("Related tool call ID")}),Z=z$1.object({sessionId:n,agent:u,model:b,messageId:i,message:z$1.object({id:i,role:z$1.literal("user"),content:z$1.union([z$1.string(),z$1.array(T)])}).describe("User message")}),V=z$1.object({sessionId:n,messages:z$1.array(v).describe("Messages to transform")}),K=z$1.object({sessionId:n,model:b,system:z$1.array(z$1.string()).describe("Current system prompt")}),S=z$1.record(z$1.string(),z$1.unknown()).describe("Tool call arguments"),J=z$1.object({title:z$1.string().optional().describe("Result title"),content:z$1.string().describe("Result content"),is_error:z$1.boolean().optional().describe("Is error result"),metadata:z$1.record(z$1.string(),z$1.unknown()).optional().describe("Extra metadata")}),Q=z$1.object({sessionId:n,userMessageId:i.optional().describe("User message ID for the current step"),tool:z$1.string().describe("Tool name"),callId:f,args:S}),X=z$1.object({sessionId:n,userMessageId:i.optional().describe("User message ID for the current step"),tool:z$1.string(),callId:f,args:S,result:J,duration:z$1.number().nonnegative().optional().describe("Execution duration in milliseconds")}),Y=z$1.object({sessionId:n,tool:z$1.string(),callId:f,args:S,error:z$1.string().describe("Error message"),errorType:z$1.enum(["timeout","invalid_args","execution_error","permission_denied"])}),ee=z$1.object({sessionId:n,toolID:z$1.string().describe("Tool ID"),definition:z$1.object({name:z$1.string(),description:z$1.string().optional(),parameters:z$1.record(z$1.string(),z$1.unknown()).optional()}).describe("Tool definition")}),te=z$1.object({sessionId:n,command:z$1.string().describe("Command name"),arguments:z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.unknown())]).describe("Command arguments")}),oe=z$1.object({sessionId:n,command:z$1.string().describe("Command name"),arguments:z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.unknown())]).optional(),result:z$1.object({info:z$1.unknown().optional().describe("Message info"),parts:z$1.array(z$1.unknown()).optional().describe("Message parts"),title:z$1.string().optional().describe("Result title"),metadata:z$1.record(z$1.string(),z$1.unknown()).optional().describe("Result metadata"),output:z$1.string().optional().describe("Result output"),success:z$1.boolean().optional().describe("Whether execution succeeded"),error:z$1.string().optional().describe("Error message if failed")}).describe("Command execution result")}),ne=z$1.enum(["read","write","exec","admin"]),re=z$1.object({tool:z$1.string().describe("Tool name requesting permission"),args:S.optional(),level:ne.optional(),reason:z$1.string().optional().describe("Reason for permission request")}),se=z$1.object({sessionId:n,request:re}),ie=z$1.object({sessionId:n,tool:z$1.string(),reason:z$1.string().optional()}),H=z$1.enum(["openai","anthropic","google","azure","custom"]),ae=z$1.object({temperature:z$1.number().min(0).max(2).optional(),topP:z$1.number().min(0).max(1).optional(),topK:z$1.number().int().positive().optional(),maxTokens:z$1.number().int().positive().optional(),stopSequences:z$1.array(z$1.string()).optional(),responseFormat:z$1.enum(["text","json_object"]).optional()}),pe=z$1.object({sessionId:n,agent:u,model:k,provider:H,params:ae.partial().optional()}),ce=z$1.object({sessionId:n,agent:u,model:k,provider:H,headers:z$1.record(z$1.string(),z$1.string()).optional()}),me=z$1.object({cwd:C.describe("Working directory"),sessionId:n.optional(),callId:f.optional()}),ue=z$1.object({sessionId:n,messageId:i,partId:z$1.string().describe("Text part ID"),text:z$1.string().describe("Completed text")}),le=z$1.object({sessionId:n,mode:z$1.enum(["agent","chat","query"]).describe("Build mode"),providerId:z$1.string().optional()}),de=z$1.object({sessionId:n,context:z$1.object({messages:z$1.array(v),system:z$1.array(z$1.string()),metadata:z$1.record(z$1.string(),z$1.unknown())}).describe("Built context")}),ge=z$1.object({gatewayID:z$1.string().describe("Gateway ID"),messageId:i,message:z$1.unknown().describe("Received message")}),fe=z$1.object({gatewayID:z$1.string(),messageId:i,message:z$1.unknown(),sessionId:n.optional()}),be=z$1.object({gatewayID:z$1.string(),messageId:i,result:z$1.unknown().optional()}),ye=z$1.object({gatewayID:z$1.string(),messageId:i,message:z$1.unknown(),target:z$1.string().optional().describe("Send target")}),Se=z$1.object({gatewayID:z$1.string(),messageId:i,sessionId:n.optional(),channel:z$1.object({platform:z$1.string(),channelId:z$1.string()}),timestamp:z$1.number().describe("Delivery timestamp")}),Ie=z$1.object({gatewayID:z$1.string(),messageId:i,sessionId:n.optional(),channel:z$1.object({platform:z$1.string(),channelId:z$1.string()}),timestamp:z$1.number().describe("Read timestamp")}),xe=z$1.object({type:z$1.literal("command"),config:z$1.object({command:z$1.string(),arguments:z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.unknown())]).optional()})}),he=z$1.object({type:z$1.literal("heartbeat"),parts:z$1.array(z$1.unknown()),system:z$1.string().optional(),config:z$1.object({session:z$1.string().optional(),mode:z$1.enum(["session","fork"]).optional(),agent:z$1.string().optional(),model:z$1.string().optional(),tools:z$1.record(z$1.string(),z$1.boolean()).optional()}).optional()}),ke=z$1.object({type:z$1.literal("scheduler"),parts:z$1.array(z$1.unknown()),system:z$1.string().optional(),config:z$1.object({agentType:z$1.string().optional(),transport:z$1.enum(["stdio","http","websocket","cli"]).optional(),model:z$1.string().optional(),tools:z$1.record(z$1.string(),z$1.boolean()).optional()}).optional()}),Ce=z$1.object({taskId:z$1.string().describe("Heartbeat task ID"),timestamp:z$1.number().describe("Heartbeat timestamp"),name:z$1.string().optional().describe("Heartbeat name"),definition:he.optional()}),Te=z$1.object({taskId:z$1.string().describe("Heartbeat task ID"),sessionId:n.optional(),timestamp:z$1.number(),duration:z$1.number().nonnegative().optional(),success:z$1.boolean().optional(),error:z$1.string().optional()}),ve=z$1.object({taskId:z$1.string().describe("Task ID"),taskName:z$1.string().optional(),timestamp:z$1.number(),payload:z$1.record(z$1.string(),z$1.unknown()).optional(),definition:ke.optional()}),He=z$1.object({taskId:z$1.string(),timestamp:z$1.number(),success:z$1.boolean(),result:z$1.record(z$1.string(),z$1.unknown()).optional(),error:z$1.string().optional()}),Me=z$1.object({taskId:z$1.string().describe("Command task unique identifier"),taskName:z$1.string().describe("Command task name"),command:z$1.string().describe("Command name"),arguments:z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.unknown())]).optional().describe("Command arguments"),timestamp:z$1.number().describe("Trigger timestamp"),definition:xe.optional()}),Pe=z$1.object({taskId:z$1.string(),timestamp:z$1.number(),success:z$1.boolean(),output:z$1.string().optional(),error:z$1.string().optional(),duration:z$1.number().describe("Execution duration in milliseconds")}),I=z$1.enum(["tool","scheduler","cli","api"]),we=z$1.object({taskId:z$1.string().describe("Task unique identifier"),sessionId:z$1.string().describe("Session ID for this task"),source:I.describe("Task source: tool, scheduler, cli, api"),agentType:z$1.string().describe("Agent type to execute this task"),description:z$1.string().describe("Task description"),prompt:z$1.string().describe("Task prompt content"),timeout:z$1.number().positive().optional().describe("Task timeout in milliseconds")}),Ee=z$1.object({taskId:z$1.string().describe("Task unique identifier"),sessionId:z$1.string().describe("Session ID for this task"),source:I.describe("Task source: tool, scheduler, cli, api")}),De=z$1.object({taskId:z$1.string(),sessionId:z$1.string(),source:I,step:z$1.number().describe("Current step number"),totalSteps:z$1.number().optional().describe("Total number of steps"),output:z$1.string().describe("Progress output content"),timestamp:z$1.number().describe("Progress timestamp")}),Ae=z$1.object({taskId:z$1.string(),sessionId:z$1.string(),source:I,result:z$1.string().describe("Task result content"),duration:z$1.number().nonnegative().describe("Task duration in milliseconds"),attachments:z$1.array(z$1.unknown()).optional().describe("Task result attachments"),error:z$1.string().optional().describe("Error message if task failed"),agentType:z$1.string().optional().describe("Agent type that executed the task"),metadata:z$1.record(z$1.string(),z$1.unknown()).optional().describe("Additional metadata for the task result")}),je=z$1.object({sessionId:z$1.string().describe("Session ID"),step:z$1.number().describe("Current step number"),lastUserId:z$1.string().describe("Last user message ID"),result:z$1.enum(["start","continue","stop"]).optional().describe("Loop result: start, continue, or stop")}),Re=z$1.object({sessionId:z$1.string().describe("Session ID"),step:z$1.number().describe("Current step number"),lastUserId:z$1.string().describe("Last user message ID"),result:z$1.enum(["stop","continue"]).describe("Loop result: stop or continue")}),ze=z$1.object({requestId:z$1.string(),kind:z$1.enum(["create-skill","create-workflow","create-bundle"]),requirement:z$1.string(),hints:z$1.array(z$1.string()),origin:z$1.object({source:z$1.enum(["human","tool","scheduler","namespace"]).optional(),timestamp:z$1.number().int().nonnegative()})}),Oe=z$1.object({requestId:z$1.string(),status:z$1.enum(["success","failed"]),specId:z$1.string().optional(),durationMs:z$1.number().int().nonnegative(),error:z$1.string().optional()}),Fe=z$1.object({dryRun:z$1.boolean()}),We=z$1.object({status:z$1.enum(["success","failed","awaiting-approval"]),applied:z$1.number().int().nonnegative().optional(),awaitingApproval:z$1.number().int().nonnegative().optional(),error:z$1.string().optional()}),x={[o.SessionStart]:W,[o.SessionEnd]:G,[o.SessionCompacting]:B,[o.SessionCompact]:L,[o.StepStart]:q,[o.StepFinish]:_,[o.StepStop]:U,[o.StepStopFailure]:N,[o.MessageReceive]:Z,[o.MessageTransform]:V,[o.SystemTransform]:K,[o.ToolBefore]:Q,[o.ToolAfter]:X,[o.ToolFailure]:Y,[o.ToolDefinition]:ee,[o.CommandBefore]:te,[o.CommandAfter]:oe,[o.PermissionAsk]:se,[o.PermissionDenied]:ie,[o.LlmParams]:pe,[o.LlmHeaders]:ce,[o.ShellEnv]:me,[o.TextComplete]:ue,[o.ContextBuildBefore]:le,[o.ContextBuildAfter]:de,[o.GatewayMessageReceive]:ge,[o.GatewayMessageProcess]:fe,[o.GatewayMessageComplete]:be,[o.GatewayMessageSend]:ye,[o.GatewayMessageDelivered]:Se,[o.GatewayMessageRead]:Ie,[o.HeartbeatTrigger]:Ce,[o.HeartbeatComplete]:Te,[o.ScheduledTaskTrigger]:ve,[o.ScheduledTaskComplete]:He,[o.CommandTrigger]:Me,[o.CommandComplete]:Pe,[o.TaskStart]:we,[o.TaskRunning]:Ee,[o.TaskProgress]:De,[o.TaskComplete]:Ae,[o.LoopStart]:je,[o.LoopEnd]:Re,[o.CreationRequest]:ze,[o.CreationComplete]:Oe,[o.EvolutionRequest]:Fe,[o.EvolutionComplete]:We};function st(r){return x[r]}function it(r,d){let g=x[r];if(!g)throw new Error(`No schema found for event: ${r}`);return g.parse(d)}function at(r,d){let g=x[r];return g?g.safeParse(d):{success:false,error:new z$1.ZodError([{code:"custom",path:[],message:`No schema found for event: ${r}`}])}}var bt=z$1.enum(["command","mcp","skill"]).describe("Command source"),Ge=z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.unknown())]).describe("Command arguments"),Be=z$1.discriminatedUnion("type",[z$1.object({type:z$1.literal("text"),text:z$1.string().describe("Text content")}),z$1.object({type:z$1.literal("image"),source:z$1.object({type:z$1.enum(["base64","url"]),mime:z$1.string().describe("File mime type"),data:z$1.string().describe("File base64 encoding data or url")})}),z$1.object({type:z$1.literal("file"),url:z$1.string().describe("File path"),filename:z$1.string().describe("File name"),mime:z$1.string().optional().describe("File mime type")})]),yt=z$1.object({name:z$1.string().describe("Command name"),description:z$1.string().describe("Command description"),scope:z$1.enum(["general","coder","all"]).optional().describe("Context mode scope"),agent:z$1.string().optional().describe("Specified agent name"),model:z$1.string().optional().describe("Specified model"),hints:z$1.array(z$1.string()).optional().describe("Argument hints"),commandType:z$1.enum(["prompt","local"]).optional().describe("Command type"),hidden:z$1.boolean().optional().describe("Whether hidden")}),St=z$1.object({sessionId:z$1.string().describe("Session ID"),directory:z$1.string().describe("Working directory"),model:z$1.string().optional().describe("Model identifier"),agent:z$1.string().optional().describe("Agent name"),arguments:Ge.describe("Command arguments")}),Le=z$1.record(z$1.string(),z$1.unknown()).describe("Result metadata"),It=z$1.object({title:z$1.string().describe("Result title"),metadata:Le.describe("Result metadata"),output:z$1.string().describe("Result output"),parts:z$1.array(Be).optional().describe("Result parts"),success:z$1.boolean().describe("Whether execution succeeded"),error:z$1.string().optional().describe("Error message if failed")}),xt=z$1.object({agent:z$1.object({name:z$1.string().describe("Agent name"),model:z$1.string().optional().describe("Agent model")}).optional().describe("Agent context")}),ht=z$1.object({isEnabled:z$1.boolean().optional().describe("Is enabled check result")});var _e=z$1.enum(["subagent","primary","all"]),Ue=z$1.enum(["general","coder","all"]),Ne=z$1.object({providerId:z$1.string().min(1).describe("Model provider ID"),modelId:z$1.string().min(1).describe("Model ID")}),Dt=z$1.object({name:z$1.string().min(1).describe("Unique agent name"),description:z$1.string().optional().describe("When to use this agent"),mode:_e.optional().describe("Agent mode"),hidden:z$1.boolean().optional().describe("Hide from @ autocomplete menu"),scope:Ue.optional().describe("Agent scope (general / coder / all)"),model:Ne.optional().describe("Default model"),variant:z$1.string().optional().describe("Default model variant"),temperature:z$1.number().min(0).max(2).optional().describe("Sampling temperature"),topP:z$1.number().min(0).max(1).optional().describe("Top-p sampling"),prompt:z$1.string().optional().describe("System prompt"),permission:AgentPermissionSchema.optional().describe("Tool permissions"),steps:z$1.number().int().positive().optional().describe("Maximum execution steps"),color:z$1.union([z$1.string().regex(/^#[0-9a-fA-F]{6}$/),z$1.enum(["primary","secondary","accent","success","warning","error","info"])]).optional().describe("UI color (hex code or theme name)"),options:z$1.record(z$1.string(),z$1.unknown()).optional().describe("Additional options")}).meta({ref:"PluginAgent"});var Wt=z$1.object({name:z$1.string().min(1).describe("Unique skill name"),description:z$1.string().min(1).describe("When to use this skill"),scope:z$1.enum(["general","coder","all"]).optional().describe("Context mode scope")}),Gt=z$1.object({agent:z$1.object({name:z$1.string().describe("Agent name"),model:z$1.string().optional().describe("Agent model")}).optional().describe("Agent context")}),Bt=z$1.object({isEnabled:z$1.boolean().optional().describe("Is enabled check result")});var l=new Map;function Zt(r){if(l.has(r.id))throw new Error(`Marketplace with id "${r.id}" already registered`);l.set(r.id,r);}function Vt(r){return l.delete(r)}function Kt(){return Array.from(l.values()).map(r=>r)}function Jt(r){return l.get(r)??null}function Qt(r){return Array.from(l.values()).filter(d=>d.category===r)}export{A as AgentExecutorSchema,Dt as AgentMetadataSchema,_e as AgentModeSchema,Ne as AgentModelSchema,u as AgentSchema,Ue as AgentScopeSchema,f as CallIDSchema,oe as CommandAfterInputSchema,Ge as CommandArgumentsSchema,te as CommandBeforeInputSchema,Pe as CommandCompleteInputSchema,Le as CommandExecuteResultMetadataSchema,It as CommandExecuteResultSchema,St as CommandExecutionContextSchema,w as CommandExecutorSchema,xt as CommandInitContextSchema,ht as CommandInitResultSchema,yt as CommandMetadataSchema,Be as CommandPromptPartSchema,bt as CommandSourceSchema,xe as CommandTaskDefinitionSchema,Me as CommandTriggerInputSchema,T as ContentPartSchema,de as ContextBuildAfterInputSchema,le as ContextBuildBeforeInputSchema,Oe as CreationCompleteInputSchema,ze as CreationRequestInputSchema,C as CwdSchema,O as EndReasonSchema,x as EventInputSchemas,We as EvolutionCompleteInputSchema,Fe as EvolutionRequestInputSchema,F as FinishReasonSchema,j as FunctionExecutorSchema,be as GatewayMessageCompleteInputSchema,Se as GatewayMessageDeliveredInputSchema,fe as GatewayMessageProcessInputSchema,Ie as GatewayMessageReadInputSchema,ge as GatewayMessageReceiveInputSchema,ye as GatewayMessageSendInputSchema,Ye as HOOK_EVENTS,Te as HeartbeatCompleteInputSchema,he as HeartbeatTaskDefinitionSchema,Ce as HeartbeatTriggerInputSchema,o as HookEvent,R as HookExecutorSchema,z as HookMatcherSchema,m as HookType,rt as HooksConfigSchema,D as HttpExecutorSchema,ce as LlmHeadersInputSchema,pe as LlmParamsInputSchema,ae as LlmParamsSchema,H as LlmProviderSchema,Re as LoopEndInputSchema,je as LoopStartInputSchema,i as MessageIDSchema,Z as MessageReceiveInputSchema,$ as MessageRoleSchema,v as MessageSchema,V as MessageTransformInputSchema,k as ModelObjectSchema,b as ModelSchema,h as PartIDSchema,se as PermissionAskInputSchema,ie as PermissionDeniedInputSchema,ne as PermissionLevelSchema,re as PermissionRequestSchema,E as PromptExecutorSchema,He as ScheduledTaskCompleteInputSchema,ve as ScheduledTaskTriggerInputSchema,ke as SchedulerTaskDefinitionSchema,L as SessionCompactInputSchema,B as SessionCompactingInputSchema,G as SessionEndInputSchema,n as SessionIDSchema,W as SessionStartInputSchema,me as ShellEnvInputSchema,Gt as SkillInitContextSchema,Bt as SkillInitResultSchema,Wt as SkillMetadataSchema,_ as StepFinishInputSchema,q as StepStartInputSchema,N as StepStopFailureInputSchema,U as StepStopInputSchema,K as SystemTransformInputSchema,Ae as TaskCompleteInputSchema,De as TaskProgressInputSchema,Ee as TaskRunningInputSchema,I as TaskSourceSchema,we as TaskStartInputSchema,ue as TextCompleteInputSchema,X as ToolAfterInputSchema,S as ToolArgsSchema,Q as ToolBeforeInputSchema,ee as ToolDefinitionInputSchema,Y as ToolFailureInputSchema,J as ToolResultSchema,Jt as findMarketplace,Qt as findMarketplacesByCategory,st as getEventInputSchema,Kt as listMarketplaces,Zt as registerMarketplace,at as safeValidateHookInput,P as tool,Vt as unregisterMarketplace,it as validateHookInput};
1
+ import b,{z as z$1}from'zod';import {UsageSchema,AgentInfoSchema}from'@easbot/types';export{AgentInfoSchema,AgentModelSchema,AgentPermissionSchema,CommandArgumentsSchema,CommandConfigInfoSchema,CommandExecuteResultMetadataSchema,CommandExecuteResultSchema,CommandExecutionContextSchema,CommandInfoSchema,CommandInitContextSchema,CommandInitResultSchema,CommandMetadataSchema,CommandPromptPartSchema,CommandSourceSchema,PermissionActionSchema,PermissionRuleSchema,buildToolArgs,createTool,toolSchema as schema}from'@easbot/types';function L(t){return {description:t.description,args:t.args,execute:t.execute}}L.schema=b;var y={Command:"command",Prompt:"prompt",Http:"http",Agent:"agent",Function:"function"},r={SessionStart:"session.start",SessionEnd:"session.end",SessionCompacting:"session.compacting",SessionCompact:"session.compact",MessageReceive:"message.receive",MessageTransform:"message.transform",SystemTransform:"system.transform",ToolBefore:"tool.before",ToolAfter:"tool.after",ToolFailure:"tool.failure",ToolDefinition:"tool.definition",CommandBefore:"command.before",CommandAfter:"command.after",PermissionAsk:"permission.ask",PermissionDenied:"permission.denied",LlmParams:"llm.params",LlmHeaders:"llm.headers",ShellEnv:"shell.env",GatewayMessageReceive:"gateway.message.receive",GatewayMessageProcess:"gateway.message.process",GatewayMessageComplete:"gateway.message.complete",GatewayMessageSend:"gateway.message.send",GatewayMessageDelivered:"gateway.message.delivered",GatewayMessageRead:"gateway.message.read",HeartbeatTrigger:"scheduler.heartbeat.trigger",HeartbeatComplete:"scheduler.heartbeat.complete",ScheduledTaskTrigger:"scheduler.task.trigger",ScheduledTaskComplete:"scheduler.task.complete",CommandTrigger:"scheduler.command.trigger",CommandComplete:"scheduler.command.complete",ContextBuildBefore:"context.build.before",ContextBuildAfter:"context.build.after",TaskStart:"task.start",TaskRunning:"task.running",TaskProgress:"task.progress",TaskComplete:"task.complete",LoopStart:"loop.start",LoopEnd:"loop.end",ProcessorStart:"processor.start",ProcessorStepStart:"processor.step.start",ProcessorReasoningStart:"processor.reasoning.start",ProcessorReasoningDelta:"processor.reasoning.delta",ProcessorReasoningEnd:"processor.reasoning.end",ProcessorToolInputStart:"processor.tool.input.start",ProcessorToolCall:"processor.tool.call",ProcessorToolResult:"processor.tool.result",ProcessorToolError:"processor.tool.error",ProcessorStepFinish:"processor.step.finish",ProcessorTextStart:"processor.text.start",ProcessorTextDelta:"processor.text.delta",ProcessorTextEnd:"processor.text.end",ProcessorError:"processor.error",ProcessorFinish:"processor.finish",CreationRequest:"creation.request",CreationComplete:"creation.complete",EvolutionRequest:"evolution.request",EvolutionComplete:"evolution.complete"},v=Object.values(r);var I=z$1.string().optional(),F=z$1.object({type:z$1.literal(y.Command),command:z$1.string(),if:I,shell:z$1.enum(["bash","powershell"]).optional(),timeout:z$1.number().positive().optional(),statusMessage:z$1.string().optional(),once:z$1.boolean().optional(),async:z$1.boolean().optional(),allowedEnvVars:z$1.array(z$1.string()).optional()}),_=z$1.object({type:z$1.literal(y.Prompt),if:I,timeout:z$1.number().positive().optional(),model:z$1.string().optional().describe("Model identifier in provider/model format"),statusMessage:z$1.string().optional(),once:z$1.boolean().optional(),runMode:z$1.enum(["session","fork"]).optional(),system:z$1.string().optional(),parts:z$1.array(z$1.unknown()),onMessage:z$1.custom(t=>typeof t=="function").optional()}),G=z$1.object({type:z$1.literal(y.Http),url:z$1.string(),if:I,timeout:z$1.number().positive().optional(),method:z$1.enum(["GET","POST","PUT","DELETE"]).optional(),headers:z$1.record(z$1.string(),z$1.string()).optional(),allowedEnvVars:z$1.array(z$1.string()).optional(),statusMessage:z$1.string().optional(),once:z$1.boolean().optional()}),N=z$1.object({type:z$1.literal(y.Agent),if:I,timeout:z$1.number().positive().optional(),agent:z$1.string().optional(),model:z$1.string().optional().describe("Model identifier in provider/model format"),statusMessage:z$1.string().optional(),once:z$1.boolean().optional(),system:z$1.string().optional(),parts:z$1.array(z$1.unknown()),onMessage:z$1.custom(t=>typeof t=="function").optional()}),q=z$1.object({type:z$1.literal(y.Function),handler:z$1.function()}),B=z$1.discriminatedUnion("type",[F,_,G,N,q]),U=z$1.object({event:z$1.string(),matcher:z$1.string().optional(),hooks:z$1.array(B),priority:z$1.number().optional(),timeoutMs:z$1.number().nonnegative().optional(),failurePolicy:z$1.enum(["fail-open","fail-closed"]).optional()}),Ot=z$1.record(z$1.string(),z$1.array(U)),i=z$1.string().min(1).describe("Session unique identifier"),V=z$1.string().min(1).describe("Part unique identifier"),u=z$1.string().min(1).describe("Message unique identifier"),f=z$1.string().min(1).describe("Tool call unique identifier"),k=z$1.string().optional().describe("Agent name"),T=z$1.string().optional().describe("Model identifier"),R=z$1.object({providerId:z$1.string().describe("Provider ID"),modelId:z$1.string().describe("Model ID"),api:z$1.object({id:z$1.string().describe("API ID"),npm:z$1.string().optional().describe("NPM package name")}).optional().describe("API information")}).optional().describe("Model object"),M=z$1.string().optional().describe("Working directory path"),W=z$1.enum(["user_request","max_tokens","stop","error","timeout","cancelled"]).describe("Session end reason"),Ft=z$1.enum(["stop","max_tokens","end_turn","stop_sequence"]).describe("Step finish reason"),K=z$1.object({sessionId:i,source:z$1.enum(["user","agent","system","scheduled"]).optional().describe("Session source"),model:T,agent:k,cwd:M}),Z=z$1.object({sessionId:i,reason:W,duration:z$1.number().positive().optional().describe("Session duration in milliseconds")}),Y=z$1.object({sessionId:i,trigger:z$1.enum(["manual","auto","threshold"]).describe("Compaction trigger"),contextLength:z$1.number().positive().describe("Current context length"),threshold:z$1.number().positive().describe("Trigger threshold")}),X=z$1.object({sessionId:i,summary:z$1.string().describe("Compaction summary"),previousLength:z$1.number().positive().describe("Previous context length"),newLength:z$1.number().positive().describe("New context length")}),J=z$1.enum(["user","assistant","system","tool"]),w=z$1.discriminatedUnion("type",[z$1.object({type:z$1.literal("text"),text:z$1.string().describe("Text content")}),z$1.object({type:z$1.literal("image"),source:z$1.object({type:z$1.enum(["base64","url"]),mime:z$1.string().optional().describe("File mime type"),data:z$1.string().describe("File base64 encoding data or url")})}),z$1.object({type:z$1.literal("file"),url:z$1.string().describe("File path"),filename:z$1.string().describe("File name"),mime:z$1.string().optional().describe("File mime type")})]),j=z$1.object({id:u,role:J,content:z$1.union([z$1.string(),z$1.array(w)]),name:z$1.string().optional().describe("Message sender name"),tool_call_id:f.optional().describe("Related tool call ID")}),Q=z$1.object({sessionId:i,agent:k,model:T,messageId:u,message:z$1.object({id:u,role:z$1.literal("user"),content:z$1.union([z$1.string(),z$1.array(w)])}).describe("User message")}),ee=z$1.object({sessionId:i,messages:z$1.array(j).describe("Messages to transform")}),te=z$1.object({sessionId:i,model:T,system:z$1.array(z$1.string()).describe("Current system prompt")}),h=z$1.record(z$1.string(),z$1.unknown()).describe("Tool call arguments"),oe=z$1.object({title:z$1.string().optional().describe("Result title"),content:z$1.string().describe("Result content"),is_error:z$1.boolean().optional().describe("Is error result"),metadata:z$1.record(z$1.string(),z$1.unknown()).optional().describe("Extra metadata")}),ne=z$1.object({sessionId:i,userMessageId:u.optional().describe("User message ID for the current step"),tool:z$1.string().describe("Tool name"),callId:f,args:h}),re=z$1.object({sessionId:i,userMessageId:u.optional().describe("User message ID for the current step"),tool:z$1.string(),callId:f,args:h,result:oe,duration:z$1.number().nonnegative().optional().describe("Execution duration in milliseconds")}),se=z$1.object({sessionId:i,tool:z$1.string(),callId:f,args:h,error:z$1.string().describe("Error message"),errorType:z$1.enum(["timeout","invalid_args","execution_error","permission_denied"])}),ie=z$1.object({sessionId:i,toolID:z$1.string().describe("Tool ID"),definition:z$1.object({name:z$1.string(),description:z$1.string().optional(),parameters:z$1.record(z$1.string(),z$1.unknown()).optional()}).describe("Tool definition")}),ae=z$1.object({sessionId:i,command:z$1.string().describe("Command name"),arguments:z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.unknown())]).describe("Command arguments")}),pe=z$1.object({sessionId:i,command:z$1.string().describe("Command name"),arguments:z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.unknown())]).optional(),result:z$1.object({info:z$1.unknown().optional().describe("Message info"),parts:z$1.array(z$1.unknown()).optional().describe("Message parts"),title:z$1.string().optional().describe("Result title"),metadata:z$1.record(z$1.string(),z$1.unknown()).optional().describe("Result metadata"),output:z$1.string().optional().describe("Result output"),success:z$1.boolean().optional().describe("Whether execution succeeded"),error:z$1.string().optional().describe("Error message if failed")}).describe("Command execution result")}),ce=z$1.enum(["read","write","exec","admin"]),ue=z$1.object({tool:z$1.string().describe("Tool name requesting permission"),args:h.optional(),level:ce.optional(),reason:z$1.string().optional().describe("Reason for permission request")}),me=z$1.object({sessionId:i,request:ue}),le=z$1.object({sessionId:i,tool:z$1.string(),reason:z$1.string().optional()}),H=z$1.enum(["openai","anthropic","google","azure","custom"]),de=z$1.object({temperature:z$1.number().min(0).max(2).optional(),topP:z$1.number().min(0).max(1).optional(),topK:z$1.number().int().positive().optional(),maxTokens:z$1.number().int().positive().optional(),stopSequences:z$1.array(z$1.string()).optional(),responseFormat:z$1.enum(["text","json_object"]).optional()}),ge=z$1.object({sessionId:i,agent:k,model:R,provider:H,params:de.partial().optional()}),fe=z$1.object({sessionId:i,agent:k,model:R,provider:H,headers:z$1.record(z$1.string(),z$1.string()).optional()}),be=z$1.object({cwd:M.describe("Working directory"),sessionId:i.optional(),callId:f.optional()}),he=z$1.object({sessionId:i,mode:z$1.enum(["agent","chat","query"]).describe("Build mode"),providerId:z$1.string().optional()}),ye=z$1.object({sessionId:i,context:z$1.object({messages:z$1.array(j),system:z$1.array(z$1.string()),metadata:z$1.record(z$1.string(),z$1.unknown())}).describe("Built context")}),xe=z$1.object({gatewayID:z$1.string().describe("Gateway ID"),messageId:u,message:z$1.unknown().describe("Received message")}),Se=z$1.object({gatewayID:z$1.string(),messageId:u,message:z$1.unknown(),sessionId:i.optional()}),Ie=z$1.object({gatewayID:z$1.string(),messageId:u,result:z$1.unknown().optional()}),ke=z$1.object({gatewayID:z$1.string(),messageId:u,message:z$1.unknown(),target:z$1.string().optional().describe("Send target")}),Te=z$1.object({gatewayID:z$1.string(),messageId:u,sessionId:i.optional(),channel:z$1.object({platform:z$1.string(),channelId:z$1.string()}),timestamp:z$1.number().describe("Delivery timestamp")}),Pe=z$1.object({gatewayID:z$1.string(),messageId:u,sessionId:i.optional(),channel:z$1.object({platform:z$1.string(),channelId:z$1.string()}),timestamp:z$1.number().describe("Read timestamp")}),Ce=z$1.object({type:z$1.literal("command"),config:z$1.object({command:z$1.string(),arguments:z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.unknown())]).optional()})}),Ee=z$1.object({type:z$1.literal("heartbeat"),parts:z$1.array(z$1.unknown()),system:z$1.string().optional(),config:z$1.object({session:z$1.string().optional(),mode:z$1.enum(["session","fork"]).optional(),agent:z$1.string().optional(),model:z$1.string().optional().describe("Model identifier in provider/model format"),tools:z$1.record(z$1.string(),z$1.boolean()).optional()}).optional()}),Ae=z$1.object({type:z$1.literal("scheduler"),parts:z$1.array(z$1.unknown()),system:z$1.string().optional(),config:z$1.object({agentType:z$1.string().optional(),transport:z$1.enum(["stdio","http","websocket","cli"]).optional(),model:z$1.string().optional(),tools:z$1.record(z$1.string(),z$1.boolean()).optional()}).optional()}),ve=z$1.object({taskId:z$1.string().describe("Heartbeat task ID"),timestamp:z$1.number().describe("Heartbeat timestamp"),name:z$1.string().optional().describe("Heartbeat name"),definition:Ee.optional()}),Re=z$1.object({taskId:z$1.string().describe("Heartbeat task ID"),sessionId:i.optional(),timestamp:z$1.number(),duration:z$1.number().nonnegative().optional(),success:z$1.boolean().optional(),error:z$1.string().optional()}),Me=z$1.object({taskId:z$1.string().describe("Task ID"),taskName:z$1.string().optional(),timestamp:z$1.number(),payload:z$1.record(z$1.string(),z$1.unknown()).optional(),definition:Ae.optional()}),we=z$1.object({taskId:z$1.string(),timestamp:z$1.number(),success:z$1.boolean(),result:z$1.record(z$1.string(),z$1.unknown()).optional(),error:z$1.string().optional()}),je=z$1.object({taskId:z$1.string().describe("Command task unique identifier"),taskName:z$1.string().describe("Command task name"),command:z$1.string().describe("Command name"),arguments:z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.unknown())]).optional().describe("Command arguments"),timestamp:z$1.number().describe("Trigger timestamp"),definition:Ce.optional()}),He=z$1.object({taskId:z$1.string(),timestamp:z$1.number(),success:z$1.boolean(),output:z$1.string().optional(),error:z$1.string().optional(),duration:z$1.number().describe("Execution duration in milliseconds")}),P=z$1.enum(["tool","scheduler","cli","api"]),De=z$1.object({taskId:z$1.string().describe("Task unique identifier"),sessionId:z$1.string().describe("Session ID for this task"),source:P.describe("Task source: tool, scheduler, cli, api"),agentType:z$1.string().describe("Agent type to execute this task"),description:z$1.string().describe("Task description"),prompt:z$1.string().describe("Task prompt content"),timeout:z$1.number().positive().optional().describe("Task timeout in milliseconds")}),ze=z$1.object({taskId:z$1.string().describe("Task unique identifier"),sessionId:z$1.string().describe("Session ID for this task"),source:P.describe("Task source: tool, scheduler, cli, api")}),$e=z$1.object({taskId:z$1.string(),sessionId:z$1.string(),source:P,step:z$1.number().describe("Current step number"),totalSteps:z$1.number().optional().describe("Total number of steps"),output:z$1.string().describe("Progress output content"),timestamp:z$1.number().describe("Progress timestamp")}),Le=z$1.object({taskId:z$1.string(),sessionId:z$1.string(),source:P,result:z$1.string().describe("Task result content"),duration:z$1.number().nonnegative().describe("Task duration in milliseconds"),attachments:z$1.array(z$1.unknown()).optional().describe("Task result attachments"),error:z$1.string().optional().describe("Error message if task failed"),agentType:z$1.string().optional().describe("Agent type that executed the task"),metadata:z$1.record(z$1.string(),z$1.unknown()).optional().describe("Additional metadata for the task result")}),Oe=z$1.object({sessionId:z$1.string().describe("Session ID"),step:z$1.number().describe("Current step number"),lastUserId:z$1.string().describe("Last user message ID"),result:z$1.enum(["start","continue","stop"]).optional().describe("Loop result: start, continue, or stop")}),Fe=z$1.object({sessionId:z$1.string().describe("Session ID"),step:z$1.number().describe("Current step number"),lastUserId:z$1.string().describe("Last user message ID"),result:z$1.enum(["stop","continue"]).describe("Loop result: stop or continue")}),_e=z$1.object({requestId:z$1.string(),kind:z$1.enum(["create-skill","create-workflow","create-bundle"]),requirement:z$1.string(),hints:z$1.array(z$1.string()),origin:z$1.object({source:z$1.enum(["human","tool","scheduler","namespace"]).optional(),timestamp:z$1.number().int().nonnegative()})}),Ge=z$1.object({requestId:z$1.string(),status:z$1.enum(["success","failed"]),specId:z$1.string().optional(),durationMs:z$1.number().int().nonnegative(),error:z$1.string().optional()}),Ne=z$1.object({dryRun:z$1.boolean()}),qe=z$1.object({status:z$1.enum(["success","failed","awaiting-approval"]),applied:z$1.number().int().nonnegative().optional(),awaitingApproval:z$1.number().int().nonnegative().optional(),error:z$1.string().optional()}),p=z$1.object({streamId:z$1.string().describe("Unique id of one stream invocation"),step:z$1.number().int().nonnegative().describe("Step index (1-based, 0 before first step)"),agent:z$1.string().describe("Agent name that initiated this stream invocation"),sessionId:z$1.string().describe("Session id passed in by the application layer"),messageId:u.describe("Assistant message id created by the processor, constant within one process() call"),userMessageId:u.describe("User message id that triggered this response, equals assistant.parentId"),model:T}),d={partId:V.describe("Part id allocated and maintained by the processor")},Be=p,Ue=p.extend(d),Ve=p.extend({...d,reasoningId:z$1.string().describe("Provider-side reasoning block id"),text:z$1.string().describe("Reasoning text so far (empty at start)")}),We=p.extend({...d,reasoningId:z$1.string().describe("Provider-side reasoning block id"),delta:z$1.string().describe("Incremental reasoning text"),text:z$1.string().describe("Accumulated reasoning text")}),Ke=p.extend({...d,reasoningId:z$1.string().describe("Provider-side reasoning block id"),text:z$1.string().describe("Accumulated reasoning text (trimmed)")}),Ze=p.extend({...d,callId:f,tool:z$1.string().describe("Tool name")}),Ye=p.extend({...d,callId:f,tool:z$1.string().describe("Tool name"),args:h}),Xe=p.extend({...d,callId:f,tool:z$1.string().describe("Tool name"),args:h,title:z$1.string().optional().describe("Result title"),output:z$1.unknown().describe("Tool output payload"),metadata:z$1.record(z$1.string(),z$1.unknown()).optional(),durationMs:z$1.number().nonnegative().describe("Tool execution duration")}),Je=p.extend({...d,callId:f,tool:z$1.string().describe("Tool name"),args:h,error:z$1.string().describe("Error message"),errorName:z$1.string().optional().describe("Named error name"),durationMs:z$1.number().nonnegative().describe("Tool execution duration")}),Qe=p.extend({...d,reason:z$1.string().optional().describe("Finish reason reported by provider"),tokens:UsageSchema.optional().describe("Normalized token usage"),cost:z$1.number().nonnegative().optional().describe("Estimated cost of this step")}),et=p.extend({...d,text:z$1.string().describe("Text so far (empty at start)")}),tt=p.extend({...d,delta:z$1.string().describe("Incremental text"),text:z$1.string().describe("Accumulated text")}),ot=p.extend({...d,text:z$1.string().describe("Accumulated text (trimmed)")}),nt=p.extend({error:z$1.string().describe("Error message"),errorName:z$1.string().optional().describe("Named error name"),aborted:z$1.boolean().optional().describe("Whether aborted by signal")}),rt=p.extend({result:z$1.enum(["stop","continue","compact"]).describe("Processor loop verdict"),cost:z$1.number().nonnegative().optional().describe("Accumulated cost of this stream"),tokens:z$1.number().nonnegative().optional().describe("Accumulated tokens of this stream")}),C={[r.SessionStart]:K,[r.SessionEnd]:Z,[r.SessionCompacting]:Y,[r.SessionCompact]:X,[r.MessageReceive]:Q,[r.MessageTransform]:ee,[r.SystemTransform]:te,[r.ToolBefore]:ne,[r.ToolAfter]:re,[r.ToolFailure]:se,[r.ToolDefinition]:ie,[r.CommandBefore]:ae,[r.CommandAfter]:pe,[r.PermissionAsk]:me,[r.PermissionDenied]:le,[r.LlmParams]:ge,[r.LlmHeaders]:fe,[r.ShellEnv]:be,[r.ContextBuildBefore]:he,[r.ContextBuildAfter]:ye,[r.GatewayMessageReceive]:xe,[r.GatewayMessageProcess]:Se,[r.GatewayMessageComplete]:Ie,[r.GatewayMessageSend]:ke,[r.GatewayMessageDelivered]:Te,[r.GatewayMessageRead]:Pe,[r.HeartbeatTrigger]:ve,[r.HeartbeatComplete]:Re,[r.ScheduledTaskTrigger]:Me,[r.ScheduledTaskComplete]:we,[r.CommandTrigger]:je,[r.CommandComplete]:He,[r.TaskStart]:De,[r.TaskRunning]:ze,[r.TaskProgress]:$e,[r.TaskComplete]:Le,[r.LoopStart]:Oe,[r.LoopEnd]:Fe,[r.ProcessorStart]:Be,[r.ProcessorStepStart]:Ue,[r.ProcessorReasoningStart]:Ve,[r.ProcessorReasoningDelta]:We,[r.ProcessorReasoningEnd]:Ke,[r.ProcessorToolInputStart]:Ze,[r.ProcessorToolCall]:Ye,[r.ProcessorToolResult]:Xe,[r.ProcessorToolError]:Je,[r.ProcessorStepFinish]:Qe,[r.ProcessorTextStart]:et,[r.ProcessorTextDelta]:tt,[r.ProcessorTextEnd]:ot,[r.ProcessorError]:nt,[r.ProcessorFinish]:rt,[r.CreationRequest]:_e,[r.CreationComplete]:Ge,[r.EvolutionRequest]:Ne,[r.EvolutionComplete]:qe};function _t(t){return C[t]}function Gt(t,n){let o=C[t];if(!o)throw new Error(`No schema found for event: ${t}`);return o.parse(n)}function Nt(t,n){let o=C[t];return o?o.safeParse(n):{success:false,error:new z$1.ZodError([{code:"custom",path:[],message:`No schema found for event: ${t}`}])}}var xo=z$1.enum(["subagent","primary","all"]),So=z$1.enum(["general","coder","all"]),Io=AgentInfoSchema;var vo=z$1.object({name:z$1.string().min(1).describe("Unique skill name"),description:z$1.string().min(1).describe("When to use this skill"),scope:z$1.enum(["general","coder","all"]).optional().describe("Context mode scope")}),Ro=z$1.object({agent:z$1.object({name:z$1.string().describe("Agent name"),model:z$1.string().optional().describe("Agent model in provider/model format")}).optional().describe("Agent context")}),Mo=z$1.object({isEnabled:z$1.boolean().optional().describe("Is enabled check result")});var z=/^[a-z0-9][a-z0-9._-]{1,63}$/,it=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,E=["hooks","commands","tools","agents","skills","auth","event","config"],at=E,pt=["fail-open","fail-closed"],ct=[".mjs",".js",".cjs"],Fo=["default","Plugin","plugin"],ut=["command","prompt","http","agent","function"],mt=["commands","tools","agents","skills"],lt=["event","config"];function x(t){return typeof t=="string"&&z.test(t)}function dt(t){if(typeof t!="string"||!t.startsWith("./"))return false;let n=t.slice(2);return n.length===0||n.includes("\\")||n.split("/").some(s=>s.length===0||s==="."||s==="..")?false:ct.some(s=>n.endsWith(s))}var gt=b.object({name:b.string().regex(z,"plugin name must match ^[a-z0-9][a-z0-9._-]{1,63}$"),version:b.string().regex(it,"plugin version must be SemVer x.y.z").optional(),description:b.string().max(200,"plugin description must be at most 200 characters").optional(),entry:b.string().refine(dt,"plugin entry must be a safe relative .mjs/.js/.cjs path").optional(),capabilities:b.array(b.enum(E)).optional(),skills:b.array(b.string()).optional()});function _o(t){let n=gt.safeParse(t);return n.success?{ok:true,manifest:n.data}:{ok:false,errors:n.error.issues.map(o=>`${o.path.length>0?o.path.join("."):"<root>"}: ${o.message}`)}}function c(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)}function ft(t){return c(t)&&typeof t.safeParse=="function"}function bt(t){return typeof t=="number"&&Number.isFinite(t)&&t>=0}function ht(t){if(!Array.isArray(t))return "plugin.hooks must be an array";for(let[n,o]of t.entries()){if(!c(o))return `plugin.hooks[${n}] must be an object`;if(typeof o.event!="string"||!v.includes(o.event))return `plugin.hooks[${n}].event must be a HookEvent value`;if(o.matcher!==void 0&&typeof o.matcher!="string")return `plugin.hooks[${n}].matcher must be a string`;if(o.priority!==void 0&&typeof o.priority!="number")return `plugin.hooks[${n}].priority must be a number`;if(o.timeoutMs!==void 0&&!bt(o.timeoutMs))return `plugin.hooks[${n}].timeoutMs must be a non-negative number`;if(o.failurePolicy!==void 0&&!pt.includes(o.failurePolicy))return `plugin.hooks[${n}].failurePolicy must be fail-open or fail-closed`;if(!Array.isArray(o.hooks))return `plugin.hooks[${n}].hooks must be an array`;if(o.hooks.length===0)return `plugin.hooks[${n}].hooks must not be empty`;for(let[s,a]of o.hooks.entries()){if(!c(a)||typeof a.type!="string")return `plugin.hooks[${n}].hooks[${s}] must be a hook executor object`;if(!ut.includes(a.type))return `plugin.hooks[${n}].hooks[${s}].type is unknown: ${a.type}`;if(a.type==="function"&&typeof a.handler!="function")return `plugin.hooks[${n}].hooks[${s}].handler must be a function`}}return null}function yt(t){for(let[n,o]of Object.entries(t)){if(!x(n))return `plugin.tools key "${n}" must match the plugin id pattern`;if(!c(o))return `plugin.tools.${n} must be an object`;if(typeof o.description!="string"||o.description.length===0)return `plugin.tools.${n}.description must be a non-empty string`;if(!c(o.args))return `plugin.tools.${n}.args must be a Zod schema map`;for(let[s,a]of Object.entries(o.args))if(!ft(a))return `plugin.tools.${n}.args.${s} must be a Zod schema`;if(typeof o.execute!="function")return `plugin.tools.${n}.execute must be a function`}return null}function xt(t){for(let[n,o]of Object.entries(t)){if(!x(n))return `plugin.commands key "${n}" must match the plugin id pattern`;if(!c(o))return `plugin.commands.${n} must be an object`;if(typeof o.name!="string"||o.name.length===0)return `plugin.commands.${n}.name must be a non-empty string`;if(o.name!==n)return `plugin.commands.${n}.name must equal its map key`;if(typeof o.execute!="function")return `plugin.commands.${n}.execute must be a function`}return null}function St(t){for(let[n,o]of Object.entries(t)){if(!x(n))return `plugin.agents key "${n}" must match the plugin id pattern`;if(!c(o)||typeof o.name!="string"||o.name.length===0)return `plugin.agents.${n}.name must be a non-empty string`}return null}function It(t){for(let[n,o]of Object.entries(t)){if(!x(n))return `plugin.skills key "${n}" must match the plugin id pattern`;if(!c(o))return `plugin.skills.${n} must be an object`;if(typeof o.name!="string"||o.name.length===0)return `plugin.skills.${n}.name must be a non-empty string`;if(o.name!==n)return `plugin.skills.${n}.name must equal its map key`;if(typeof o.description!="string"||o.description.length===0)return `plugin.skills.${n}.description must be a non-empty string`}return null}function kt(t,n){if(!c(t))return `${n} must be an object`;if(t.type!=="text"&&t.type!=="select")return `${n}.type must be text or select`;if(typeof t.key!="string"||t.key.length===0)return `${n}.key must be a non-empty string`;if(typeof t.message!="string"||t.message.length===0)return `${n}.message must be a non-empty string`;if(t.type==="text"&&t.validate!==void 0&&typeof t.validate!="function")return `${n}.validate must be a function`;if(t.type==="select"){if(!Array.isArray(t.options))return `${n}.options must be an array`;for(let o of t.options)if(!c(o)||typeof o.label!="string"||typeof o.value!="string")return `${n}.options entries must have string label and value`}return t.condition!==void 0&&typeof t.condition!="function"?`${n}.condition must be a function`:null}function Tt(t){if(!c(t))return "plugin.auth must be an object";if(typeof t.provider!="string"||!x(t.provider))return "plugin.auth.provider must be a non-empty plugin id";if(t.loader!==void 0&&typeof t.loader!="function")return "plugin.auth.loader must be a function";if(!Array.isArray(t.methods))return "plugin.auth.methods must be an array";for(let[n,o]of t.methods.entries()){let s=`plugin.auth.methods[${n}]`;if(!c(o))return `${s} must be an object`;if(o.type!=="oauth"&&o.type!=="api")return `${s}.type must be oauth or api`;if(typeof o.label!="string"||o.label.length===0)return `${s}.label must be a non-empty string`;if(o.prompts!==void 0){if(!Array.isArray(o.prompts))return `${s}.prompts must be an array`;for(let[a,S]of o.prompts.entries()){let A=kt(S,`${s}.prompts[${a}]`);if(A)return A}}if(o.type==="oauth"&&typeof o.authorize!="function")return `${s}.authorize must be a function for oauth methods`;if(o.type==="api"&&o.authorize!==void 0&&typeof o.authorize!="function")return `${s}.authorize must be a function`}return null}var Pt={commands:xt,tools:yt,agents:St,skills:It};function Ct(t){return E.filter(n=>t[n]!==void 0)}function Go(t,n){if(!c(t))return {ok:false,reason:"plugin returned non-object value"};for(let s of Object.keys(t))if(!at.includes(s))return {ok:false,reason:`plugin.${s} is not a supported definition field`};let o=Ct(t);if(o.length===0)return {ok:false,reason:"plugin definition must declare at least one capability"};if(t.hooks!==void 0){let s=ht(t.hooks);if(s)return {ok:false,reason:s}}for(let s of mt){let a=t[s];if(a===void 0)continue;if(!c(a))return {ok:false,reason:`plugin.${s} must be a plain object map`};let S=Pt[s](a);if(S)return {ok:false,reason:S}}for(let s of lt){let a=t[s];if(a!==void 0&&typeof a!="function")return {ok:false,reason:`plugin.${s} must be a function`}}if(t.auth!==void 0){let s=Tt(t.auth);if(s)return {ok:false,reason:s}}if(n?.capabilities!==void 0){let s=new Set(n.capabilities);for(let a of o)if(!s.has(a))return {ok:false,reason:`plugin.${a} is not declared in plugin.json capabilities`};for(let a of s)if(!o.includes(a))return {ok:false,reason:`plugin.json declares capability ${a} but definition omits it`}}return {ok:true}}export{N as AgentExecutorSchema,Io as AgentMetadataSchema,xo as AgentModeSchema,k as AgentSchema,So as AgentScopeSchema,f as CallIDSchema,pe as CommandAfterInputSchema,ae as CommandBeforeInputSchema,He as CommandCompleteInputSchema,F as CommandExecutorSchema,Ce as CommandTaskDefinitionSchema,je as CommandTriggerInputSchema,w as ContentPartSchema,ye as ContextBuildAfterInputSchema,he as ContextBuildBeforeInputSchema,Ge as CreationCompleteInputSchema,_e as CreationRequestInputSchema,M as CwdSchema,W as EndReasonSchema,C as EventInputSchemas,qe as EvolutionCompleteInputSchema,Ne as EvolutionRequestInputSchema,Ft as FinishReasonSchema,q as FunctionExecutorSchema,Ie as GatewayMessageCompleteInputSchema,Te as GatewayMessageDeliveredInputSchema,Se as GatewayMessageProcessInputSchema,Pe as GatewayMessageReadInputSchema,xe as GatewayMessageReceiveInputSchema,ke as GatewayMessageSendInputSchema,v as HOOK_EVENTS,Re as HeartbeatCompleteInputSchema,Ee as HeartbeatTaskDefinitionSchema,ve as HeartbeatTriggerInputSchema,r as HookEvent,B as HookExecutorSchema,U as HookMatcherSchema,y as HookType,Ot as HooksConfigSchema,G as HttpExecutorSchema,fe as LlmHeadersInputSchema,ge as LlmParamsInputSchema,de as LlmParamsSchema,H as LlmProviderSchema,Fe as LoopEndInputSchema,Oe as LoopStartInputSchema,u as MessageIDSchema,Q as MessageReceiveInputSchema,J as MessageRoleSchema,j as MessageSchema,ee as MessageTransformInputSchema,R as ModelObjectSchema,T as ModelSchema,E as PLUGIN_CAPABILITIES,at as PLUGIN_DEFINITION_KEYS,ct as PLUGIN_ENTRY_EXTENSIONS,Fo as PLUGIN_ENTRY_NAMES,ut as PLUGIN_HOOK_EXECUTOR_TYPES,pt as PLUGIN_HOOK_FAILURE_POLICIES,z as PLUGIN_ID_PATTERN,it as PLUGIN_VERSION_PATTERN,V as PartIDSchema,me as PermissionAskInputSchema,le as PermissionDeniedInputSchema,ce as PermissionLevelSchema,ue as PermissionRequestSchema,gt as PluginManifestSchema,nt as ProcessorErrorInputSchema,rt as ProcessorFinishInputSchema,We as ProcessorReasoningDeltaInputSchema,Ke as ProcessorReasoningEndInputSchema,Ve as ProcessorReasoningStartInputSchema,Be as ProcessorStartInputSchema,Qe as ProcessorStepFinishInputSchema,Ue as ProcessorStepStartInputSchema,tt as ProcessorTextDeltaInputSchema,ot as ProcessorTextEndInputSchema,et as ProcessorTextStartInputSchema,Ye as ProcessorToolCallInputSchema,Je as ProcessorToolErrorInputSchema,Ze as ProcessorToolInputStartInputSchema,Xe as ProcessorToolResultInputSchema,_ as PromptExecutorSchema,we as ScheduledTaskCompleteInputSchema,Me as ScheduledTaskTriggerInputSchema,Ae as SchedulerTaskDefinitionSchema,X as SessionCompactInputSchema,Y as SessionCompactingInputSchema,Z as SessionEndInputSchema,i as SessionIDSchema,K as SessionStartInputSchema,be as ShellEnvInputSchema,Ro as SkillInitContextSchema,Mo as SkillInitResultSchema,vo as SkillMetadataSchema,te as SystemTransformInputSchema,Le as TaskCompleteInputSchema,$e as TaskProgressInputSchema,ze as TaskRunningInputSchema,P as TaskSourceSchema,De as TaskStartInputSchema,re as ToolAfterInputSchema,h as ToolArgsSchema,ne as ToolBeforeInputSchema,ie as ToolDefinitionInputSchema,se as ToolFailureInputSchema,oe as ToolResultSchema,_t as getEventInputSchema,dt as isValidPluginEntry,x as isValidPluginId,Nt as safeValidateHookInput,L as tool,Gt as validateHookInput,Go as validatePluginDefinition,_o as validatePluginManifest};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easbot/plugin",
3
- "version": "0.3.29",
3
+ "version": "0.3.36",
4
4
  "description": "EASBot Plugin for client applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -38,15 +38,15 @@
38
38
  "LICENSE"
39
39
  ],
40
40
  "dependencies": {
41
- "zod": "^4.4.3",
42
- "@easbot/sdk": "0.3.29",
43
- "@easbot/types": "0.3.29"
41
+ "zod": "^4.6.7",
42
+ "@easbot/sdk": "0.3.36",
43
+ "@easbot/types": "0.3.36"
44
44
  },
45
45
  "devDependencies": {
46
46
  "@types/node": "^25.9.5",
47
47
  "tsup": "^8.5.1",
48
48
  "typescript": "^6.0.3",
49
- "vitest": "^4.1.10"
49
+ "vitest": "^5.0.5"
50
50
  },
51
51
  "engines": {
52
52
  "node": ">=22.22.2"
@@ -57,9 +57,9 @@
57
57
  "scripts": {
58
58
  "dev": "tsup --watch --env.NODE_ENV development",
59
59
  "build": "tsup --env.NODE_ENV production",
60
- "test": "echo norun",
61
- "test:run": "echo norun",
62
- "test:coverage": "echo norun",
60
+ "test": "vitest",
61
+ "test:run": "vitest run",
62
+ "test:coverage": "vitest run --coverage",
63
63
  "lint": "biome check .",
64
64
  "lint:fix": "biome check --write .",
65
65
  "lint:report": "biome check --reporter=summary .",