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