@easbot/plugin 0.3.32 → 0.3.37

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 E,{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 H(o){return {description:o.description,args:o.args,execute:o.execute}}H.schema=E;var l={Command:"command",Prompt:"prompt",Http:"http",Agent:"agent",Function:"function"},t={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"},rt=Object.values(t);var b=z$1.string().optional(),w=z$1.object({type:z$1.literal(l.Command),command:z$1.string(),if:b,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()}),R=z$1.object({type:z$1.literal(l.Prompt),if:b,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(o=>typeof o=="function").optional()}),D=z$1.object({type:z$1.literal(l.Http),url:z$1.string(),if:b,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(l.Agent),if:b,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(o=>typeof o=="function").optional()}),z=z$1.object({type:z$1.literal(l.Function),handler:z$1.function()}),j=z$1.discriminatedUnion("type",[w,R,D,A,z]),O=z$1.object({event:z$1.string(),matcher:z$1.string().optional(),hooks:z$1.array(j)}),ut=z$1.record(z$1.string(),z$1.array(O)),n=z$1.string().min(1).describe("Session unique identifier"),G=z$1.string().min(1).describe("Part unique identifier"),a=z$1.string().min(1).describe("Message unique identifier"),u=z$1.string().min(1).describe("Tool call unique identifier"),y=z$1.string().optional().describe("Agent name"),I=z$1.string().optional().describe("Model identifier"),S=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"),k=z$1.string().optional().describe("Working directory path"),B=z$1.enum(["user_request","max_tokens","stop","error","timeout","cancelled"]).describe("Session end reason"),mt=z$1.enum(["stop","max_tokens","end_turn","stop_sequence"]).describe("Step finish reason"),F=z$1.object({sessionId:n,source:z$1.enum(["user","agent","system","scheduled"]).optional().describe("Session source"),model:I,agent:y,cwd:k}),W=z$1.object({sessionId:n,reason:B,duration:z$1.number().positive().optional().describe("Session duration in milliseconds")}),L=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")}),q=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")}),N=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")})]),C=z$1.object({id:a,role:N,content:z$1.union([z$1.string(),z$1.array(T)]),name:z$1.string().optional().describe("Message sender name"),tool_call_id:u.optional().describe("Related tool call ID")}),U=z$1.object({sessionId:n,agent:y,model:I,messageId:a,message:z$1.object({id:a,role:z$1.literal("user"),content:z$1.union([z$1.string(),z$1.array(T)])}).describe("User message")}),_=z$1.object({sessionId:n,messages:z$1.array(C).describe("Messages to transform")}),V=z$1.object({sessionId:n,model:I,system:z$1.array(z$1.string()).describe("Current system prompt")}),m=z$1.record(z$1.string(),z$1.unknown()).describe("Tool call arguments"),Z=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")}),$=z$1.object({sessionId:n,userMessageId:a.optional().describe("User message ID for the current step"),tool:z$1.string().describe("Tool name"),callId:u,args:m}),K=z$1.object({sessionId:n,userMessageId:a.optional().describe("User message ID for the current step"),tool:z$1.string(),callId:u,args:m,result:Z,duration:z$1.number().nonnegative().optional().describe("Execution duration in milliseconds")}),J=z$1.object({sessionId:n,tool:z$1.string(),callId:u,args:m,error:z$1.string().describe("Error message"),errorType:z$1.enum(["timeout","invalid_args","execution_error","permission_denied"])}),Q=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")}),X=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")}),Y=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")}),ee=z$1.enum(["read","write","exec","admin"]),te=z$1.object({tool:z$1.string().describe("Tool name requesting permission"),args:m.optional(),level:ee.optional(),reason:z$1.string().optional().describe("Reason for permission request")}),oe=z$1.object({sessionId:n,request:te}),ne=z$1.object({sessionId:n,tool:z$1.string(),reason:z$1.string().optional()}),P=z$1.enum(["openai","anthropic","google","azure","custom"]),re=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()}),se=z$1.object({sessionId:n,agent:y,model:S,provider:P,params:re.partial().optional()}),ie=z$1.object({sessionId:n,agent:y,model:S,provider:P,headers:z$1.record(z$1.string(),z$1.string()).optional()}),ae=z$1.object({cwd:k.describe("Working directory"),sessionId:n.optional(),callId:u.optional()}),pe=z$1.object({sessionId:n,mode:z$1.enum(["agent","chat","query"]).describe("Build mode"),providerId:z$1.string().optional()}),ce=z$1.object({sessionId:n,context:z$1.object({messages:z$1.array(C),system:z$1.array(z$1.string()),metadata:z$1.record(z$1.string(),z$1.unknown())}).describe("Built context")}),ue=z$1.object({gatewayID:z$1.string().describe("Gateway ID"),messageId:a,message:z$1.unknown().describe("Received message")}),me=z$1.object({gatewayID:z$1.string(),messageId:a,message:z$1.unknown(),sessionId:n.optional()}),le=z$1.object({gatewayID:z$1.string(),messageId:a,result:z$1.unknown().optional()}),de=z$1.object({gatewayID:z$1.string(),messageId:a,message:z$1.unknown(),target:z$1.string().optional().describe("Send target")}),ge=z$1.object({gatewayID:z$1.string(),messageId:a,sessionId:n.optional(),channel:z$1.object({platform:z$1.string(),channelId:z$1.string()}),timestamp:z$1.number().describe("Delivery timestamp")}),fe=z$1.object({gatewayID:z$1.string(),messageId:a,sessionId:n.optional(),channel:z$1.object({platform:z$1.string(),channelId:z$1.string()}),timestamp:z$1.number().describe("Read timestamp")}),be=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()})}),ye=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()}),Ie=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()}),xe=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:ye.optional()}),he=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()}),Se=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:Ie.optional()}),ke=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()}),Te=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:be.optional()}),Ce=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")}),x=z$1.enum(["tool","scheduler","cli","api"]),Pe=z$1.object({taskId:z$1.string().describe("Task unique identifier"),sessionId:z$1.string().describe("Session ID for this task"),source:x.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")}),ve=z$1.object({taskId:z$1.string().describe("Task unique identifier"),sessionId:z$1.string().describe("Session ID for this task"),source:x.describe("Task source: tool, scheduler, cli, api")}),Ee=z$1.object({taskId:z$1.string(),sessionId:z$1.string(),source:x,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")}),He=z$1.object({taskId:z$1.string(),sessionId:z$1.string(),source:x,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")}),Me=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")}),we=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")}),Re=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()})}),De=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()}),Ae=z$1.object({dryRun:z$1.boolean()}),ze=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()}),r=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:a.describe("Assistant message id created by the processor, constant within one process() call"),userMessageId:a.describe("User message id that triggered this response, equals assistant.parentId"),model:I}),p={partId:G.describe("Part id allocated and maintained by the processor")},je=r,Oe=r.extend(p),Ge=r.extend({...p,reasoningId:z$1.string().describe("Provider-side reasoning block id"),text:z$1.string().describe("Reasoning text so far (empty at start)")}),Be=r.extend({...p,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")}),Fe=r.extend({...p,reasoningId:z$1.string().describe("Provider-side reasoning block id"),text:z$1.string().describe("Accumulated reasoning text (trimmed)")}),We=r.extend({...p,callId:u,tool:z$1.string().describe("Tool name")}),Le=r.extend({...p,callId:u,tool:z$1.string().describe("Tool name"),args:m}),qe=r.extend({...p,callId:u,tool:z$1.string().describe("Tool name"),args:m,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")}),Ne=r.extend({...p,callId:u,tool:z$1.string().describe("Tool name"),args:m,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")}),Ue=r.extend({...p,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")}),_e=r.extend({...p,text:z$1.string().describe("Text so far (empty at start)")}),Ve=r.extend({...p,delta:z$1.string().describe("Incremental text"),text:z$1.string().describe("Accumulated text")}),Ze=r.extend({...p,text:z$1.string().describe("Accumulated text (trimmed)")}),$e=r.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")}),Ke=r.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")}),h={[t.SessionStart]:F,[t.SessionEnd]:W,[t.SessionCompacting]:L,[t.SessionCompact]:q,[t.MessageReceive]:U,[t.MessageTransform]:_,[t.SystemTransform]:V,[t.ToolBefore]:$,[t.ToolAfter]:K,[t.ToolFailure]:J,[t.ToolDefinition]:Q,[t.CommandBefore]:X,[t.CommandAfter]:Y,[t.PermissionAsk]:oe,[t.PermissionDenied]:ne,[t.LlmParams]:se,[t.LlmHeaders]:ie,[t.ShellEnv]:ae,[t.ContextBuildBefore]:pe,[t.ContextBuildAfter]:ce,[t.GatewayMessageReceive]:ue,[t.GatewayMessageProcess]:me,[t.GatewayMessageComplete]:le,[t.GatewayMessageSend]:de,[t.GatewayMessageDelivered]:ge,[t.GatewayMessageRead]:fe,[t.HeartbeatTrigger]:xe,[t.HeartbeatComplete]:he,[t.ScheduledTaskTrigger]:Se,[t.ScheduledTaskComplete]:ke,[t.CommandTrigger]:Te,[t.CommandComplete]:Ce,[t.TaskStart]:Pe,[t.TaskRunning]:ve,[t.TaskProgress]:Ee,[t.TaskComplete]:He,[t.LoopStart]:Me,[t.LoopEnd]:we,[t.ProcessorStart]:je,[t.ProcessorStepStart]:Oe,[t.ProcessorReasoningStart]:Ge,[t.ProcessorReasoningDelta]:Be,[t.ProcessorReasoningEnd]:Fe,[t.ProcessorToolInputStart]:We,[t.ProcessorToolCall]:Le,[t.ProcessorToolResult]:qe,[t.ProcessorToolError]:Ne,[t.ProcessorStepFinish]:Ue,[t.ProcessorTextStart]:_e,[t.ProcessorTextDelta]:Ve,[t.ProcessorTextEnd]:Ze,[t.ProcessorError]:$e,[t.ProcessorFinish]:Ke,[t.CreationRequest]:Re,[t.CreationComplete]:De,[t.EvolutionRequest]:Ae,[t.EvolutionComplete]:ze};function lt(o){return h[o]}function dt(o,g){let f=h[o];if(!f)throw new Error(`No schema found for event: ${o}`);return f.parse(g)}function gt(o,g){let f=h[o];return f?f.safeParse(g):{success:false,error:new z$1.ZodError([{code:"custom",path:[],message:`No schema found for event: ${o}`}])}}var Ut=z$1.enum(["subagent","primary","all"]),_t=z$1.enum(["general","coder","all"]),Vt=AgentInfoSchema;var Yt=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")}),eo=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")}),to=z$1.object({isEnabled:z$1.boolean().optional().describe("Is enabled check result")});var d=new Map;function po(o){if(d.has(o.id))throw new Error(`Marketplace with id "${o.id}" already registered`);d.set(o.id,o);}function co(o){return d.delete(o)}function uo(){return Array.from(d.values()).map(o=>o)}function mo(o){return d.get(o)??null}function lo(o){return Array.from(d.values()).filter(g=>g.category===o)}export{A as AgentExecutorSchema,Vt as AgentMetadataSchema,Ut as AgentModeSchema,y as AgentSchema,_t as AgentScopeSchema,u as CallIDSchema,Y as CommandAfterInputSchema,X as CommandBeforeInputSchema,Ce as CommandCompleteInputSchema,w as CommandExecutorSchema,be as CommandTaskDefinitionSchema,Te as CommandTriggerInputSchema,T as ContentPartSchema,ce as ContextBuildAfterInputSchema,pe as ContextBuildBeforeInputSchema,De as CreationCompleteInputSchema,Re as CreationRequestInputSchema,k as CwdSchema,B as EndReasonSchema,h as EventInputSchemas,ze as EvolutionCompleteInputSchema,Ae as EvolutionRequestInputSchema,mt as FinishReasonSchema,z as FunctionExecutorSchema,le as GatewayMessageCompleteInputSchema,ge as GatewayMessageDeliveredInputSchema,me as GatewayMessageProcessInputSchema,fe as GatewayMessageReadInputSchema,ue as GatewayMessageReceiveInputSchema,de as GatewayMessageSendInputSchema,rt as HOOK_EVENTS,he as HeartbeatCompleteInputSchema,ye as HeartbeatTaskDefinitionSchema,xe as HeartbeatTriggerInputSchema,t as HookEvent,j as HookExecutorSchema,O as HookMatcherSchema,l as HookType,ut as HooksConfigSchema,D as HttpExecutorSchema,ie as LlmHeadersInputSchema,se as LlmParamsInputSchema,re as LlmParamsSchema,P as LlmProviderSchema,we as LoopEndInputSchema,Me as LoopStartInputSchema,a as MessageIDSchema,U as MessageReceiveInputSchema,N as MessageRoleSchema,C as MessageSchema,_ as MessageTransformInputSchema,S as ModelObjectSchema,I as ModelSchema,G as PartIDSchema,oe as PermissionAskInputSchema,ne as PermissionDeniedInputSchema,ee as PermissionLevelSchema,te as PermissionRequestSchema,$e as ProcessorErrorInputSchema,Ke as ProcessorFinishInputSchema,Be as ProcessorReasoningDeltaInputSchema,Fe as ProcessorReasoningEndInputSchema,Ge as ProcessorReasoningStartInputSchema,je as ProcessorStartInputSchema,Ue as ProcessorStepFinishInputSchema,Oe as ProcessorStepStartInputSchema,Ve as ProcessorTextDeltaInputSchema,Ze as ProcessorTextEndInputSchema,_e as ProcessorTextStartInputSchema,Le as ProcessorToolCallInputSchema,Ne as ProcessorToolErrorInputSchema,We as ProcessorToolInputStartInputSchema,qe as ProcessorToolResultInputSchema,R as PromptExecutorSchema,ke as ScheduledTaskCompleteInputSchema,Se as ScheduledTaskTriggerInputSchema,Ie as SchedulerTaskDefinitionSchema,q as SessionCompactInputSchema,L as SessionCompactingInputSchema,W as SessionEndInputSchema,n as SessionIDSchema,F as SessionStartInputSchema,ae as ShellEnvInputSchema,eo as SkillInitContextSchema,to as SkillInitResultSchema,Yt as SkillMetadataSchema,V as SystemTransformInputSchema,He as TaskCompleteInputSchema,Ee as TaskProgressInputSchema,ve as TaskRunningInputSchema,x as TaskSourceSchema,Pe as TaskStartInputSchema,K as ToolAfterInputSchema,m as ToolArgsSchema,$ as ToolBeforeInputSchema,Q as ToolDefinitionInputSchema,J as ToolFailureInputSchema,Z as ToolResultSchema,mo as findMarketplace,lo as findMarketplacesByCategory,lt as getEventInputSchema,uo as listMarketplaces,po as registerMarketplace,gt as safeValidateHookInput,H as tool,co as unregisterMarketplace,dt 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.32",
3
+ "version": "0.3.37",
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.32",
43
- "@easbot/types": "0.3.32"
41
+ "zod": "^4.6.7",
42
+ "@easbot/sdk": "0.3.37",
43
+ "@easbot/types": "0.3.37"
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 .",