@easbot/plugin 0.3.36 → 0.3.39
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/README.en.md +107 -20
- package/README.md +114 -29
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +452 -79
- package/dist/index.d.ts +452 -79
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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};
|
|
1
|
+
import h,{z as z$1}from'zod';import {ContextBuildSceneValues,ContextModeValues,ContextSourceValues,UsageSchema,AgentInfoSchema}from'@easbot/types';export{AgentInfoSchema,AgentModelSchema,AgentPermissionSchema,CommandArgumentsSchema,CommandConfigInfoSchema,CommandExecuteResultMetadataSchema,CommandExecuteResultSchema,CommandExecutionContextSchema,CommandInfoSchema,CommandInitContextSchema,CommandInitResultSchema,CommandMetadataSchema,CommandPromptPartSchema,CommandSourceSchema,PermissionActionSchema,PermissionRuleSchema,buildToolArgs,toolSchema as schema}from'@easbot/types';function Wt(o){return {description:o.description,args:o.args,execute:o.execute,isEnabled:o.isEnabled}}function Z(o){return {description:o.description,args:o.args,execute:o.execute,isEnabled:o.isEnabled}}Z.schema=h;var T={Command:"command",Prompt:"prompt",Http:"http",Agent:"agent",Function:"function"},t={SessionStart:"session.start",SessionEnd:"session.end",SessionCompacting:"session.compacting",SessionCompact:"session.compact",SessionInterrupt:"session.interrupt",MessageReceive:"message.receive",UserPromptSubmit:"user.prompt.submit",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",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",ContextCollect:"context.collect",Stop:"agent.stop",TaskStart:"task.start",TaskRunning:"task.running",TaskProgress:"task.progress",TaskComplete:"task.complete",LoopStart:"loop.start",LoopEnd:"loop.end",SubagentStart:"subagent.start",SubagentStop:"subagent.stop",Notification:"notification",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",ProjectTrust:"project.trust",CreationRequest:"creation.request",CreationComplete:"creation.complete"},Y={UserPromptSubmit:t.UserPromptSubmit,Stop:t.Stop,PreToolUse:t.ToolBefore,PostToolUse:t.ToolAfter,PostToolUseFailure:t.ToolFailure,SessionStart:t.SessionStart,SessionEnd:t.SessionEnd,PreCompact:t.SessionCompacting,PostCompact:t.SessionCompact,SubagentStart:t.SubagentStart,SubagentStop:t.SubagentStop,Notification:t.Notification,StopCancelled:t.SessionInterrupt};function z(o){return M.includes(o)?o:Y[o]??o}var M=Object.values(t),D={[t.SessionStart]:"chain",[t.SessionEnd]:"collect",[t.SessionCompacting]:"chain",[t.SessionCompact]:"chain",[t.SessionInterrupt]:"collect",[t.MessageReceive]:"collect",[t.UserPromptSubmit]:"chain",[t.MessageTransform]:"chain",[t.SystemTransform]:"chain",[t.ToolBefore]:"chain",[t.ToolAfter]:"chain",[t.ToolFailure]:"collect",[t.ToolDefinition]:"chain",[t.CommandBefore]:"chain",[t.CommandAfter]:"chain",[t.PermissionAsk]:"chain",[t.LlmParams]:"chain",[t.LlmHeaders]:"chain",[t.ShellEnv]:"chain",[t.GatewayMessageReceive]:"collect",[t.GatewayMessageProcess]:"chain",[t.GatewayMessageComplete]:"collect",[t.GatewayMessageSend]:"chain",[t.GatewayMessageDelivered]:"collect",[t.GatewayMessageRead]:"collect",[t.HeartbeatTrigger]:"chain",[t.HeartbeatComplete]:"chain",[t.ScheduledTaskTrigger]:"chain",[t.ScheduledTaskComplete]:"chain",[t.CommandTrigger]:"chain",[t.CommandComplete]:"chain",[t.ContextBuildBefore]:"chain",[t.ContextBuildAfter]:"chain",[t.ContextCollect]:"collect",[t.Stop]:"chain",[t.TaskStart]:"chain",[t.TaskRunning]:"chain",[t.TaskProgress]:"chain",[t.TaskComplete]:"chain",[t.LoopStart]:"chain",[t.LoopEnd]:"chain",[t.SubagentStart]:"collect",[t.SubagentStop]:"collect",[t.Notification]:"collect",[t.ProcessorStart]:"chain",[t.ProcessorStepStart]:"chain",[t.ProcessorReasoningStart]:"collect",[t.ProcessorReasoningDelta]:"collect",[t.ProcessorReasoningEnd]:"collect",[t.ProcessorToolInputStart]:"collect",[t.ProcessorToolCall]:"collect",[t.ProcessorToolResult]:"collect",[t.ProcessorToolError]:"chain",[t.ProcessorStepFinish]:"chain",[t.ProcessorTextStart]:"collect",[t.ProcessorTextDelta]:"collect",[t.ProcessorTextEnd]:"collect",[t.ProcessorError]:"chain",[t.ProcessorFinish]:"chain",[t.ProjectTrust]:"collect",[t.CreationRequest]:"chain",[t.CreationComplete]:"chain"};function eo(o){return D[o]}function to(o){return D[o]==="collect"}var A=z$1.string().optional(),Q=z$1.object({type:z$1.literal(T.Command),command:z$1.string(),if:A,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()}),ee=z$1.object({type:z$1.literal(T.Prompt),if:A,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()}),te=z$1.object({type:z$1.literal(T.Http),url:z$1.string(),if:A,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()}),oe=z$1.object({type:z$1.literal(T.Agent),if:A,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()}),ne=z$1.object({type:z$1.literal(T.Function),handler:z$1.function()}),re=z$1.discriminatedUnion("type",[Q,ee,te,oe,ne]),se=z$1.object({event:z$1.string(),matcher:z$1.string().optional(),hooks:z$1.array(re),priority:z$1.number().optional(),timeoutMs:z$1.number().nonnegative().optional(),failurePolicy:z$1.enum(["fail-open","fail-closed"]).optional()}),ao=z$1.record(z$1.string(),z$1.array(se)),i=z$1.string().min(1).describe("Session unique identifier"),ie=z$1.string().min(1).describe("Part unique identifier"),l=z$1.string().min(1).describe("Message unique identifier"),x=z$1.string().min(1).describe("Tool call unique identifier"),P=z$1.string().optional().describe("Agent name"),C=z$1.string().optional().describe("Model identifier"),N=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"),H=z$1.string().optional().describe("Working directory path"),ae=z$1.enum(["user_request","max_tokens","stop","error","timeout","cancelled"]).describe("Session end reason"),po=z$1.enum(["stop","max_tokens","end_turn","stop_sequence"]).describe("Step finish reason"),pe=z$1.object({sessionId:i,source:z$1.enum(["user","agent","system","scheduled"]).optional().describe("Session source"),model:C,agent:P,cwd:H}),ce=z$1.object({sessionId:i,reason:ae,duration:z$1.number().positive().optional().describe("Session duration in milliseconds")}),ue=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")}),le=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")}),me=z$1.enum(["user","assistant","system","tool"]),L=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")})]),F=z$1.object({id:l,role:me,content:z$1.union([z$1.string(),z$1.array(L)]),name:z$1.string().optional().describe("Message sender name"),tool_call_id:x.optional().describe("Related tool call ID")}),de=z$1.object({sessionId:i,agent:P,model:C,messageId:l,message:z$1.object({id:l,role:z$1.literal("user"),content:z$1.union([z$1.string(),z$1.array(L)])}).describe("User message")}),ge=z$1.object({sessionId:i,agent:P,model:C.optional(),userMessageId:l,prompt:z$1.string(),cwd:H.optional(),transcriptPath:z$1.string().optional()}),co=z$1.object({additionalContext:z$1.string().optional().describe("Context to inject into this turn"),block:z$1.boolean().optional().describe("Block this prompt submission"),reason:z$1.string().optional().describe("Reason shown to user when blocked")}),fe=z$1.object({sessionId:i,messages:z$1.array(F).describe("Messages to transform")}),be=z$1.object({sessionId:i,model:C,system:z$1.array(z$1.string()).describe("Current system prompt")}),I=z$1.record(z$1.string(),z$1.unknown()).describe("Tool call arguments"),he=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")}),ye=z$1.object({sessionId:i,userMessageId:l.optional().describe("User message ID for the current step"),tool:z$1.string().describe("Tool name"),callId:x,args:I}),Se=z$1.object({sessionId:i,userMessageId:l.optional().describe("User message ID for the current step"),tool:z$1.string(),callId:x,args:I,result:he,duration:z$1.number().nonnegative().optional().describe("Execution duration in milliseconds")}),xe=z$1.object({sessionId:i,tool:z$1.string(),callId:x,args:I,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")}),ke=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")}),Te=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")}),Pe=z$1.enum(["read","write","exec","admin"]),Ce=z$1.object({tool:z$1.string().describe("Tool name requesting permission"),args:I.optional(),level:Pe.optional(),reason:z$1.string().optional().describe("Reason for permission request")}),Ee=z$1.object({sessionId:i,request:Ce}),_=z$1.enum(["openai","anthropic","google","azure","custom"]),ve=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()}),Ae=z$1.object({sessionId:i,agent:P,model:N,provider:_,params:ve.partial().optional()}),He=z$1.object({sessionId:i,agent:P,model:N,provider:_,headers:z$1.record(z$1.string(),z$1.string()).optional()}),Re=z$1.object({cwd:H.describe("Working directory"),sessionId:i.optional(),callId:x.optional()}),Me=z$1.object({sessionId:i,mode:z$1.enum(ContextModeValues).optional().describe("Host capability profile (ContextMode)"),scene:z$1.enum(ContextBuildSceneValues).optional().describe("Context build scene (ContextBuildScene)"),providerId:z$1.string().optional()}),we=z$1.object({sessionId:i,context:z$1.object({messages:z$1.array(F),system:z$1.array(z$1.string()),metadata:z$1.record(z$1.string(),z$1.unknown())}).describe("Built context")}),je=z$1.object({id:z$1.string().describe("Fragment id (globally unique across plugins)"),title:z$1.string().optional().describe("Section title"),content:z$1.string().describe("Fragment body"),source:z$1.string().optional().describe("Fragment source"),tokens:z$1.number().nonnegative().optional().describe("Estimated token count"),order:z$1.number().int().optional().describe("Sort weight, smaller first"),markers:z$1.tuple([z$1.string(),z$1.string()]).optional().describe("Start/end markers")}),uo=z$1.object({fragments:z$1.array(je)}),ze=z$1.object({sessionId:i,mode:z$1.enum(ContextModeValues).describe("Host capability profile (ContextMode)"),scene:z$1.enum(ContextBuildSceneValues).optional().describe("Context build scene"),providerId:z$1.string().optional(),agentId:z$1.string().optional(),agentName:z$1.string().optional().describe("Agent name (human-readable)"),modelId:z$1.string().optional().describe("Model identifier (provider/model)"),query:z$1.string().optional().describe("Current user query for relevance-based retrieval"),maxTokens:z$1.number().positive().optional().describe("Fragment token budget granted by host"),trimOrder:z$1.array(z$1.enum(ContextSourceValues)).optional().describe("Source-level trim priority")}),De=z$1.object({gatewayID:z$1.string().describe("Gateway ID"),messageId:l,message:z$1.unknown().describe("Received message")}),$e=z$1.object({gatewayID:z$1.string(),messageId:l,message:z$1.unknown(),sessionId:i.optional()}),Oe=z$1.object({gatewayID:z$1.string(),messageId:l,result:z$1.unknown().optional()}),Ne=z$1.object({gatewayID:z$1.string(),messageId:l,message:z$1.unknown(),target:z$1.string().optional().describe("Send target")}),Le=z$1.object({gatewayID:z$1.string(),messageId:l,sessionId:i.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:l,sessionId:i.optional(),channel:z$1.object({platform:z$1.string(),channelId:z$1.string()}),timestamp:z$1.number().describe("Read timestamp")}),_e=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()})}),Ge=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()}),Ue=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()}),Be=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:Ge.optional()}),Ve=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()}),qe=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:Ue.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()}),We=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:_e.optional()}),Ze=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")}),R=z$1.enum(["tool","scheduler","cli","api"]),Ye=z$1.object({taskId:z$1.string().describe("Task unique identifier"),sessionId:z$1.string().describe("Session ID for this task"),source:R.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")}),Xe=z$1.object({taskId:z$1.string().describe("Task unique identifier"),sessionId:z$1.string().describe("Session ID for this task"),source:R.describe("Task source: tool, scheduler, cli, api")}),Je=z$1.object({taskId:z$1.string(),sessionId:z$1.string(),source:R,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")}),Qe=z$1.object({taskId:z$1.string(),sessionId:z$1.string(),source:R,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")}),et=z$1.object({sessionId:z$1.string().describe("Session ID"),step:z$1.number().describe("Current step number"),userMessageId:z$1.string().describe("User message ID driving this loop step"),result:z$1.enum(["start","continue","stop"]).optional().describe("Loop result: start, continue, or stop")}),tt=z$1.object({sessionId:z$1.string().describe("Session ID"),step:z$1.number().describe("Current step number"),userMessageId:z$1.string().describe("User message ID that drove this loop step"),messageId:z$1.string().optional().describe("Assistant message id of this step (absent when stopped before an assistant reply)"),result:z$1.enum(["stop","continue"]).describe("Loop result: stop or continue")}),ot=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()),subcommand:z$1.string().optional(),origin:z$1.object({source:z$1.enum(["human","tool","scheduler","namespace"]).optional(),timestamp:z$1.number().int().nonnegative()})}),nt=z$1.object({requestId:z$1.string(),status:z$1.enum(["success","failed"]),specId:z$1.string().optional(),subcommand:z$1.string().optional(),durationMs:z$1.number().int().nonnegative(),error:z$1.string().optional()}),u=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:l.describe("Assistant message id created by the processor, constant within one process() call"),userMessageId:l.describe("User message id that triggered this response, equals assistant.parentId"),model:C}),g={partId:ie.describe("Part id allocated and maintained by the processor")},rt=u,st=u.extend(g),it=u.extend({...g,reasoningId:z$1.string().describe("Provider-side reasoning block id"),text:z$1.string().describe("Reasoning text so far (empty at start)")}),at=u.extend({...g,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")}),pt=u.extend({...g,reasoningId:z$1.string().describe("Provider-side reasoning block id"),text:z$1.string().describe("Accumulated reasoning text (trimmed)")}),ct=u.extend({...g,callId:x,tool:z$1.string().describe("Tool name")}),ut=u.extend({...g,callId:x,tool:z$1.string().describe("Tool name"),args:I}),lt=u.extend({...g,callId:x,tool:z$1.string().describe("Tool name"),args:I,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")}),mt=u.extend({...g,callId:x,tool:z$1.string().describe("Tool name"),args:I,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")}),dt=u.extend({...g,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")}),gt=u.extend({...g,text:z$1.string().describe("Text so far (empty at start)")}),ft=u.extend({...g,delta:z$1.string().describe("Incremental text"),text:z$1.string().describe("Accumulated text")}),bt=u.extend({...g,text:z$1.string().describe("Accumulated text (trimmed)")}),ht=u.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")}),yt=u.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")}),St=z$1.object({sessionId:i,cwd:H.optional(),transcriptPath:z$1.string().optional(),stopHookActive:z$1.boolean().optional(),result:z$1.enum(["stop","continue","compact"]).optional()}),lo=z$1.object({continue:z$1.boolean().optional(),reason:z$1.string().optional()}),xt=z$1.object({sessionId:i,reason:z$1.string().optional().describe("Interruption reason")}),It=z$1.object({sessionId:i.optional(),agentId:z$1.string().describe("Sub agent id"),agentName:z$1.string().optional(),prompt:z$1.string().optional()}),kt=z$1.object({sessionId:i.optional(),agentId:z$1.string(),agentName:z$1.string().optional(),success:z$1.boolean().describe("Whether the sub agent finished successfully"),durationMs:z$1.number().nonnegative().optional(),error:z$1.string().optional()}),Tt=z$1.object({sessionId:i.optional(),message:z$1.string().describe("Notification body"),level:z$1.enum(["info","warn","error"]).optional(),source:z$1.string().optional()}),Pt=z$1.object({cwd:z$1.string().describe("Project directory"),trusted:z$1.boolean().describe("Trust decision")}),w={[t.SessionStart]:pe,[t.SessionEnd]:ce,[t.SessionCompacting]:ue,[t.SessionCompact]:le,[t.SessionInterrupt]:xt,[t.MessageReceive]:de,[t.UserPromptSubmit]:ge,[t.MessageTransform]:fe,[t.SystemTransform]:be,[t.ToolBefore]:ye,[t.ToolAfter]:Se,[t.ToolFailure]:xe,[t.ToolDefinition]:Ie,[t.CommandBefore]:ke,[t.CommandAfter]:Te,[t.PermissionAsk]:Ee,[t.LlmParams]:Ae,[t.LlmHeaders]:He,[t.ShellEnv]:Re,[t.ContextBuildBefore]:Me,[t.ContextBuildAfter]:we,[t.ContextCollect]:ze,[t.Stop]:St,[t.GatewayMessageReceive]:De,[t.GatewayMessageProcess]:$e,[t.GatewayMessageComplete]:Oe,[t.GatewayMessageSend]:Ne,[t.GatewayMessageDelivered]:Le,[t.GatewayMessageRead]:Fe,[t.HeartbeatTrigger]:Be,[t.HeartbeatComplete]:Ve,[t.ScheduledTaskTrigger]:qe,[t.ScheduledTaskComplete]:Ke,[t.CommandTrigger]:We,[t.CommandComplete]:Ze,[t.TaskStart]:Ye,[t.TaskRunning]:Xe,[t.TaskProgress]:Je,[t.TaskComplete]:Qe,[t.LoopStart]:et,[t.LoopEnd]:tt,[t.SubagentStart]:It,[t.SubagentStop]:kt,[t.Notification]:Tt,[t.ProcessorStart]:rt,[t.ProcessorStepStart]:st,[t.ProcessorReasoningStart]:it,[t.ProcessorReasoningDelta]:at,[t.ProcessorReasoningEnd]:pt,[t.ProcessorToolInputStart]:ct,[t.ProcessorToolCall]:ut,[t.ProcessorToolResult]:lt,[t.ProcessorToolError]:mt,[t.ProcessorStepFinish]:dt,[t.ProcessorTextStart]:gt,[t.ProcessorTextDelta]:ft,[t.ProcessorTextEnd]:bt,[t.ProcessorError]:ht,[t.ProcessorFinish]:yt,[t.ProjectTrust]:Pt,[t.CreationRequest]:ot,[t.CreationComplete]:nt};function mo(o){return w[o]}function go(o,r){let n=w[o];if(!n)throw new Error(`No schema found for event: ${o}`);return n.parse(r)}function fo(o,r){let n=w[o];return n?n.safeParse(r):{success:false,error:new z$1.ZodError([{code:"custom",path:[],message:`No schema found for event: ${o}`}])}}var Vo=z$1.enum(["subagent","primary","all"]),qo=z$1.enum(["general","coder","all"]),Ko=AgentInfoSchema;var en=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")}),tn=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")}),on=z$1.object({isEnabled:z$1.boolean().optional().describe("Is enabled check result")});var q=/^[a-z0-9][a-z0-9._-]{1,63}$/,U=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/,Et="1.0.0";function B(o){let r=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/.exec(o);if(r)return {major:Number(r[1]),minor:Number(r[2]),patch:Number(r[3]),prerelease:r[4]?r[4].split("."):[]}}function vt(o,r){let n=B(o),s=B(r);if(!n||!s)return o===r?0:o<r?-1:1;if(n.major!==s.major)return n.major<s.major?-1:1;if(n.minor!==s.minor)return n.minor<s.minor?-1:1;if(n.patch!==s.patch)return n.patch<s.patch?-1:1;if(n.prerelease.length===0&&s.prerelease.length===0)return 0;if(n.prerelease.length===0)return 1;if(s.prerelease.length===0)return -1;let a=Math.max(n.prerelease.length,s.prerelease.length);for(let p=0;p<a;p++){let f=n.prerelease[p],y=s.prerelease[p];if(f===void 0)return -1;if(y===void 0)return 1;let S=/^\d+$/.test(f),k=/^\d+$/.test(y);if(S&&k){let v=Number(f)-Number(y);if(v!==0)return v<0?-1:1;continue}if(S!==k)return S?-1:1;if(f!==y)return f<y?-1:1}return 0}function mn(o,r=Et){return o?vt(r,o)>=0:true}var j=["hooks","commands","tools","agents","skills","auth","event","config","mcpServers","setup"],At=[...j,"extensions"],Ht=["fail-open","fail-closed"],Rt=[".mjs",".js",".cjs"],dn=["default","Plugin","plugin"],Mt=["command","prompt","http","agent","function"],wt=["commands","tools","agents","skills","mcpServers"],jt=["event","config","setup"];function E(o){return typeof o=="string"&&q.test(o)}function zt(o){if(typeof o!="string"||!o.startsWith("./"))return false;let r=o.slice(2);return r.length===0||r.includes("\\")||r.split("/").some(s=>s.length===0||s==="."||s==="..")?false:Rt.some(s=>r.endsWith(s))}var Dt=h.object({name:h.string().regex(q,"plugin name must match ^[a-z0-9][a-z0-9._-]{1,63}$"),version:h.string().regex(U,"plugin version must be SemVer x.y.z").optional(),description:h.string().max(200,"plugin description must be at most 200 characters").optional(),entry:h.string().refine(zt,"plugin entry must be a safe relative .mjs/.js/.cjs path").optional(),apiVersion:h.string().regex(U,"plugin apiVersion must be SemVer x.y.z").optional(),capabilities:h.array(h.enum(j)).optional(),skills:h.array(h.string()).optional()});function gn(o){let r=Dt.safeParse(o);return r.success?{ok:true,manifest:r.data}:{ok:false,errors:r.error.issues.map(n=>`${n.path.length>0?n.path.join("."):"<root>"}: ${n.message}`)}}function c(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}function V(o){return c(o)&&typeof o.safeParse=="function"}function $t(o){return typeof o=="number"&&Number.isFinite(o)&&o>=0}function Ot(o){if(!Array.isArray(o))return "plugin.hooks must be an array";for(let[r,n]of o.entries()){if(!c(n))return `plugin.hooks[${r}] must be an object`;let s=typeof n.event=="string"?z(n.event):n.event;if(typeof s!="string"||!M.includes(s))return `plugin.hooks[${r}].event must be a HookEvent value (or a supported ecosystem alias)`;if(n.matcher!==void 0&&typeof n.matcher!="string")return `plugin.hooks[${r}].matcher must be a string`;if(n.priority!==void 0&&typeof n.priority!="number")return `plugin.hooks[${r}].priority must be a number`;if(n.timeoutMs!==void 0&&!$t(n.timeoutMs))return `plugin.hooks[${r}].timeoutMs must be a non-negative number`;if(n.failurePolicy!==void 0&&!Ht.includes(n.failurePolicy))return `plugin.hooks[${r}].failurePolicy must be fail-open or fail-closed`;if(!Array.isArray(n.hooks))return `plugin.hooks[${r}].hooks must be an array`;if(n.hooks.length===0)return `plugin.hooks[${r}].hooks must not be empty`;for(let[a,p]of n.hooks.entries()){if(!c(p)||typeof p.type!="string")return `plugin.hooks[${r}].hooks[${a}] must be a hook executor object`;if(!Mt.includes(p.type))return `plugin.hooks[${r}].hooks[${a}].type is unknown: ${p.type}`;if(p.type==="function"&&typeof p.handler!="function")return `plugin.hooks[${r}].hooks[${a}].handler must be a function`}}return null}function Nt(o){for(let[r,n]of Object.entries(o)){if(!E(r))return `plugin.tools key "${r}" must match the plugin id pattern`;if(!c(n))return `plugin.tools.${r} must be an object`;if(typeof n.description!="string"||n.description.length===0)return `plugin.tools.${r}.description must be a non-empty string`;if(!V(n.args)){if(!c(n.args))return `plugin.tools.${r}.args must be a Zod schema or a Zod schema map`;for(let[s,a]of Object.entries(n.args))if(!V(a))return `plugin.tools.${r}.args.${s} must be a Zod schema`}if(typeof n.execute!="function")return `plugin.tools.${r}.execute must be a function`}return null}function Lt(o){for(let[r,n]of Object.entries(o)){if(!E(r))return `plugin.commands key "${r}" must match the plugin id pattern`;if(!c(n))return `plugin.commands.${r} must be an object`;if(typeof n.name!="string"||n.name.length===0)return `plugin.commands.${r}.name must be a non-empty string`;if(n.name!==r)return `plugin.commands.${r}.name must equal its map key`;if(typeof n.execute!="function")return `plugin.commands.${r}.execute must be a function`}return null}function Ft(o){for(let[r,n]of Object.entries(o)){if(!E(r))return `plugin.agents key "${r}" must match the plugin id pattern`;if(!c(n)||typeof n.name!="string"||n.name.length===0)return `plugin.agents.${r}.name must be a non-empty string`}return null}function _t(o){for(let[r,n]of Object.entries(o)){if(!E(r))return `plugin.skills key "${r}" must match the plugin id pattern`;if(!c(n))return `plugin.skills.${r} must be an object`;if(typeof n.name!="string"||n.name.length===0)return `plugin.skills.${r}.name must be a non-empty string`;if(n.name!==r)return `plugin.skills.${r}.name must equal its map key`;if(typeof n.description!="string"||n.description.length===0)return `plugin.skills.${r}.description must be a non-empty string`}return null}function Gt(o){for(let[r,n]of Object.entries(o)){let s=`plugin.mcpServers.${r}`;if(!c(n))return `${s} must be an object`;let a=n.type;if(a!==void 0&&a!=="local"&&a!=="remote")return `${s}.type must be local or remote`;let p=Array.isArray(n.command)&&n.command.length>0,f=typeof n.url=="string"&&n.url.length>0;if(n.command!==void 0&&(!Array.isArray(n.command)||n.command.some(S=>typeof S!="string")))return `${s}.command must be an array of strings`;if(n.url!==void 0&&typeof n.url!="string")return `${s}.url must be a string`;let y=a??(p?"local":f?"remote":void 0);if(y===void 0)return `${s} must declare command (local) or url (remote)`;if(y==="local"&&!p)return `${s}.command must be a non-empty array for local servers`;if(y==="remote"&&!f)return `${s}.url must be a non-empty string for remote servers`;if(n.timeout!==void 0&&(typeof n.timeout!="number"||n.timeout<=0))return `${s}.timeout must be a positive number`;if(n.enabled!==void 0&&typeof n.enabled!="boolean")return `${s}.enabled must be a boolean`;for(let S of ["environment","headers"]){let k=n[S];if(k!==void 0){if(!c(k))return `${s}.${S} must be an object of string values`;for(let[v,K]of Object.entries(k))if(typeof K!="string")return `${s}.${S}.${v} must be a string`}}}return null}function Ut(o,r){if(!c(o))return `${r} must be an object`;if(o.type!=="text"&&o.type!=="select")return `${r}.type must be text or select`;if(typeof o.key!="string"||o.key.length===0)return `${r}.key must be a non-empty string`;if(typeof o.message!="string"||o.message.length===0)return `${r}.message must be a non-empty string`;if(o.type==="text"&&o.validate!==void 0&&typeof o.validate!="function")return `${r}.validate must be a function`;if(o.type==="select"){if(!Array.isArray(o.options))return `${r}.options must be an array`;for(let n of o.options)if(!c(n)||typeof n.label!="string"||typeof n.value!="string")return `${r}.options entries must have string label and value`}return o.condition!==void 0&&typeof o.condition!="function"?`${r}.condition must be a function`:null}function Bt(o){if(!c(o))return "plugin.auth must be an object";if(typeof o.provider!="string"||!E(o.provider))return "plugin.auth.provider must be a non-empty plugin id";if(o.loader!==void 0&&typeof o.loader!="function")return "plugin.auth.loader must be a function";if(!Array.isArray(o.methods))return "plugin.auth.methods must be an array";for(let[r,n]of o.methods.entries()){let s=`plugin.auth.methods[${r}]`;if(!c(n))return `${s} must be an object`;if(n.type!=="oauth"&&n.type!=="api")return `${s}.type must be oauth or api`;if(typeof n.label!="string"||n.label.length===0)return `${s}.label must be a non-empty string`;if(n.prompts!==void 0){if(!Array.isArray(n.prompts))return `${s}.prompts must be an array`;for(let[a,p]of n.prompts.entries()){let f=Ut(p,`${s}.prompts[${a}]`);if(f)return f}}if(n.type==="oauth"&&typeof n.authorize!="function")return `${s}.authorize must be a function for oauth methods`;if(n.type==="api"&&n.authorize!==void 0&&typeof n.authorize!="function")return `${s}.authorize must be a function`}return null}var Vt={commands:Lt,tools:Nt,agents:Ft,skills:_t,mcpServers:Gt};function qt(o){return j.filter(r=>o[r]!==void 0)}function fn(o,r){if(!c(o))return {ok:false,reason:"plugin returned non-object value"};for(let s of Object.keys(o))if(!At.includes(s))return {ok:false,reason:`plugin.${s} is not a supported definition field`};if(o.extensions!==void 0&&!c(o.extensions))return {ok:false,reason:"plugin.extensions must be a plain object map"};let n=qt(o);if(n.length===0)return {ok:false,reason:"plugin definition must declare at least one capability"};if(o.hooks!==void 0){let s=Ot(o.hooks);if(s)return {ok:false,reason:s}}for(let s of wt){let a=o[s];if(a===void 0)continue;if(!c(a))return {ok:false,reason:`plugin.${s} must be a plain object map`};let p=Vt[s](a);if(p)return {ok:false,reason:p}}for(let s of jt){let a=o[s];if(a!==void 0&&typeof a!="function")return {ok:false,reason:`plugin.${s} must be a function`}}if(o.auth!==void 0){let s=Bt(o.auth);if(s)return {ok:false,reason:s}}if(r?.capabilities!==void 0){let s=new Set(r.capabilities);for(let a of n)if(!s.has(a))return {ok:false,reason:`plugin.${a} is not declared in plugin.json capabilities`};for(let a of s)if(!n.includes(a))return {ok:false,reason:`plugin.json declares capability ${a} but definition omits it`}}return {ok:true}}export{oe as AgentExecutorSchema,Ko as AgentMetadataSchema,Vo as AgentModeSchema,P as AgentSchema,qo as AgentScopeSchema,x as CallIDSchema,Te as CommandAfterInputSchema,ke as CommandBeforeInputSchema,Ze as CommandCompleteInputSchema,Q as CommandExecutorSchema,_e as CommandTaskDefinitionSchema,We as CommandTriggerInputSchema,L as ContentPartSchema,we as ContextBuildAfterInputSchema,Me as ContextBuildBeforeInputSchema,ze as ContextCollectInputSchema,uo as ContextCollectOutputSchema,je as ContextFragmentSchema,nt as CreationCompleteInputSchema,ot as CreationRequestInputSchema,H as CwdSchema,ae as EndReasonSchema,w as EventInputSchemas,po as FinishReasonSchema,ne as FunctionExecutorSchema,Oe as GatewayMessageCompleteInputSchema,Le as GatewayMessageDeliveredInputSchema,$e as GatewayMessageProcessInputSchema,Fe as GatewayMessageReadInputSchema,De as GatewayMessageReceiveInputSchema,Ne as GatewayMessageSendInputSchema,M as HOOK_EVENTS,Y as HOOK_EVENT_ALIASES,D as HOOK_EVENT_SEMANTICS,Ve as HeartbeatCompleteInputSchema,Ge as HeartbeatTaskDefinitionSchema,Be as HeartbeatTriggerInputSchema,t as HookEvent,re as HookExecutorSchema,se as HookMatcherSchema,T as HookType,ao as HooksConfigSchema,te as HttpExecutorSchema,He as LlmHeadersInputSchema,Ae as LlmParamsInputSchema,ve as LlmParamsSchema,_ as LlmProviderSchema,tt as LoopEndInputSchema,et as LoopStartInputSchema,l as MessageIDSchema,de as MessageReceiveInputSchema,me as MessageRoleSchema,F as MessageSchema,fe as MessageTransformInputSchema,N as ModelObjectSchema,C as ModelSchema,Tt as NotificationInputSchema,Et as PLUGIN_API_VERSION,j as PLUGIN_CAPABILITIES,At as PLUGIN_DEFINITION_KEYS,Rt as PLUGIN_ENTRY_EXTENSIONS,dn as PLUGIN_ENTRY_NAMES,Mt as PLUGIN_HOOK_EXECUTOR_TYPES,Ht as PLUGIN_HOOK_FAILURE_POLICIES,q as PLUGIN_ID_PATTERN,U as PLUGIN_VERSION_PATTERN,ie as PartIDSchema,Ee as PermissionAskInputSchema,Pe as PermissionLevelSchema,Ce as PermissionRequestSchema,Dt as PluginManifestSchema,ht as ProcessorErrorInputSchema,yt as ProcessorFinishInputSchema,at as ProcessorReasoningDeltaInputSchema,pt as ProcessorReasoningEndInputSchema,it as ProcessorReasoningStartInputSchema,rt as ProcessorStartInputSchema,dt as ProcessorStepFinishInputSchema,st as ProcessorStepStartInputSchema,ft as ProcessorTextDeltaInputSchema,bt as ProcessorTextEndInputSchema,gt as ProcessorTextStartInputSchema,ut as ProcessorToolCallInputSchema,mt as ProcessorToolErrorInputSchema,ct as ProcessorToolInputStartInputSchema,lt as ProcessorToolResultInputSchema,Pt as ProjectTrustInputSchema,ee as PromptExecutorSchema,Ke as ScheduledTaskCompleteInputSchema,qe as ScheduledTaskTriggerInputSchema,Ue as SchedulerTaskDefinitionSchema,le as SessionCompactInputSchema,ue as SessionCompactingInputSchema,ce as SessionEndInputSchema,i as SessionIDSchema,xt as SessionInterruptInputSchema,pe as SessionStartInputSchema,Re as ShellEnvInputSchema,tn as SkillInitContextSchema,on as SkillInitResultSchema,en as SkillMetadataSchema,St as StopInputSchema,lo as StopOutputSchema,It as SubagentStartInputSchema,kt as SubagentStopInputSchema,be as SystemTransformInputSchema,Qe as TaskCompleteInputSchema,Je as TaskProgressInputSchema,Xe as TaskRunningInputSchema,R as TaskSourceSchema,Ye as TaskStartInputSchema,Se as ToolAfterInputSchema,I as ToolArgsSchema,ye as ToolBeforeInputSchema,Ie as ToolDefinitionInputSchema,xe as ToolFailureInputSchema,he as ToolResultSchema,ge as UserPromptSubmitInputSchema,co as UserPromptSubmitOutputSchema,vt as compareSemVer,Wt as createTool,mo as getEventInputSchema,eo as getEventSemantics,to as isCollectEvent,zt as isValidPluginEntry,E as isValidPluginId,V as isZodSchema,z as normalizeHookEvent,fo as safeValidateHookInput,mn as satisfiesApiVersion,Z as tool,go as validateHookInput,fn as validatePluginDefinition,gn as validatePluginManifest};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easbot/plugin",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.39",
|
|
4
4
|
"description": "EASBot Plugin for client applications",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.cjs",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
],
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"zod": "^4.6.7",
|
|
42
|
-
"@easbot/sdk": "0.3.
|
|
43
|
-
"@easbot/types": "0.3.
|
|
42
|
+
"@easbot/sdk": "0.3.39",
|
|
43
|
+
"@easbot/types": "0.3.39"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "^25.9.5",
|