@easbot/plugin 0.1.11

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 houjallen
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
File without changes
package/dist/index.cjs ADDED
@@ -0,0 +1 @@
1
+ 'use strict';var x=require('zod'),types=require('@easbot/types');require('@easbot/sdk');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var x__default=/*#__PURE__*/_interopDefault(x);function k(r){return {description:r.description,args:r.args,execute:r.execute}}k.schema=x__default.default;var a={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",HeartbeatTrigger:"scheduler.heartbeat.trigger",HeartbeatComplete:"scheduler.heartbeat.complete",ScheduledTaskTrigger:"scheduler.task.trigger",ScheduledTaskComplete:"scheduler.task.complete",ContextBuildBefore:"context.build.before",ContextBuildAfter:"context.build.after"},Pe=Object.values(o);var l=x.z.string().optional(),C=x.z.object({type:x.z.literal(a.Command),command:x.z.string(),if:l,shell:x.z.enum(["bash","powershell"]).optional(),timeout:x.z.number().positive().optional(),statusMessage:x.z.string().optional(),once:x.z.boolean().optional(),async:x.z.boolean().optional()}),T=x.z.object({type:x.z.literal(a.Prompt),if:l,timeout:x.z.number().positive().optional(),model:x.z.string().optional(),statusMessage:x.z.string().optional(),once:x.z.boolean().optional(),runMode:x.z.enum(["session","fork"]).optional(),system:x.z.string().optional(),parts:x.z.array(x.z.unknown())}),v=x.z.object({type:x.z.literal(a.Http),url:x.z.string(),if:l,timeout:x.z.number().positive().optional(),method:x.z.enum(["GET","POST","PUT","DELETE"]).optional(),headers:x.z.record(x.z.string(),x.z.string()).optional(),allowedEnvVars:x.z.array(x.z.string()).optional(),statusMessage:x.z.string().optional(),once:x.z.boolean().optional()}),P=x.z.object({type:x.z.literal(a.Agent),if:l,timeout:x.z.number().positive().optional(),model:x.z.string().optional(),statusMessage:x.z.string().optional(),once:x.z.boolean().optional(),system:x.z.string().optional(),parts:x.z.array(x.z.unknown())}),H=x.z.object({type:x.z.literal(a.Function),handler:x.z.function()}),D=x.z.discriminatedUnion("type",[C,T,v,P,H]),E=x.z.object({event:x.z.string(),matcher:x.z.string().optional(),hooks:x.z.array(D)}),Me=x.z.record(x.z.string(),x.z.array(E)),n=x.z.string().min(1).describe("Session unique identifier"),s=x.z.string().min(1).describe("Message unique identifier"),m=x.z.string().min(1).describe("Tool call unique identifier"),p=x.z.string().optional().describe("Agent name"),c=x.z.string().optional().describe("Model identifier"),y=x.z.object({providerID:x.z.string().describe("Provider ID"),modelID:x.z.string().describe("Model ID"),api:x.z.object({id:x.z.string().describe("API ID"),npm:x.z.string().optional().describe("NPM package name")}).optional().describe("API information")}).optional().describe("Model object"),b=x.z.string().optional().describe("Working directory path"),w=x.z.enum(["user_request","max_tokens","stop","error","timeout","cancelled"]).describe("Session end reason"),M=x.z.enum(["stop","max_tokens","end_turn","stop_sequence"]).describe("Step finish reason"),j=x.z.object({sessionID:n,source:x.z.enum(["user","agent","system","scheduled"]).optional().describe("Session source"),model:c,agent:p,cwd:b}),A=x.z.object({sessionID:n,reason:w,duration:x.z.number().positive().optional().describe("Session duration in milliseconds")}),z=x.z.object({sessionID:n,trigger:x.z.enum(["manual","auto","threshold"]).describe("Compaction trigger"),contextLength:x.z.number().positive().describe("Current context length"),threshold:x.z.number().positive().describe("Trigger threshold")}),R=x.z.object({sessionID:n,summary:x.z.string().describe("Compaction summary"),previousLength:x.z.number().positive().describe("Previous context length"),newLength:x.z.number().positive().describe("New context length")}),F=x.z.object({sessionID:n,messageID:s,model:c,agent:p}),O=x.z.object({sessionID:n,messageID:s,model:c,agent:p,finishReason:M,tokens:x.z.object({input:x.z.number().int().nonnegative().optional(),output:x.z.number().int().nonnegative().optional(),total:x.z.number().int().nonnegative().optional()}).optional().describe("Token usage statistics")}),W=x.z.object({sessionID:n,reason:x.z.string().describe("Stop reason")}),B=x.z.object({sessionID:n,error:x.z.string().describe("Error message"),errorType:x.z.enum(["rate_limit","auth_error","network_error","timeout","invalid_request","server_error"]).describe("Error type")}),G=x.z.enum(["user","assistant","system","tool"]),S=x.z.discriminatedUnion("type",[x.z.object({type:x.z.literal("text"),text:x.z.string().describe("Text content")}),x.z.object({type:x.z.literal("image"),source:x.z.object({type:x.z.enum(["base64","url"]),mime:x.z.string().optional().describe("File mime type"),data:x.z.string().describe("File base64 encoding data or url")})}),x.z.object({type:x.z.literal("file"),url:x.z.string().describe("File path"),filename:x.z.string().describe("File name"),mime:x.z.string().optional().describe("File mime type")})]),I=x.z.object({id:s,role:G,content:x.z.union([x.z.string(),x.z.array(S)]),name:x.z.string().optional().describe("Message sender name"),tool_call_id:m.optional().describe("Related tool call ID")}),L=x.z.object({sessionID:n,agent:p,model:c,messageID:s,message:x.z.object({id:s,role:x.z.literal("user"),content:x.z.union([x.z.string(),x.z.array(S)])}).describe("User message")}),_=x.z.object({sessionID:n,messages:x.z.array(I).describe("Messages to transform")}),q=x.z.object({sessionID:n,model:c,system:x.z.array(x.z.string()).describe("Current system prompt")}),d=x.z.record(x.z.string(),x.z.unknown()).describe("Tool call arguments"),N=x.z.object({title:x.z.string().optional().describe("Result title"),content:x.z.string().describe("Result content"),is_error:x.z.boolean().optional().describe("Is error result"),metadata:x.z.record(x.z.string(),x.z.unknown()).optional().describe("Extra metadata")}),U=x.z.object({sessionID:n,tool:x.z.string().describe("Tool name"),callID:m,args:d}),Z=x.z.object({sessionID:n,tool:x.z.string(),callID:m,args:d,result:N,duration:x.z.number().nonnegative().optional().describe("Execution duration in milliseconds")}),V=x.z.object({sessionID:n,tool:x.z.string(),callID:m,args:d,error:x.z.string().describe("Error message"),errorType:x.z.enum(["timeout","invalid_args","execution_error","permission_denied"])}),$=x.z.object({sessionID:n,toolID:x.z.string().describe("Tool ID"),definition:x.z.object({name:x.z.string(),description:x.z.string().optional(),parameters:x.z.record(x.z.string(),x.z.unknown()).optional()}).describe("Tool definition")}),K=x.z.object({sessionID:n,command:x.z.string().describe("Command name"),arguments:x.z.union([x.z.string(),x.z.record(x.z.string(),x.z.unknown())]).describe("Command arguments")}),J=x.z.object({sessionID:n,command:x.z.string().describe("Command name"),arguments:x.z.union([x.z.string(),x.z.record(x.z.string(),x.z.unknown())]).optional(),result:x.z.object({info:x.z.unknown().optional().describe("Message info"),parts:x.z.array(x.z.unknown()).optional().describe("Message parts"),title:x.z.string().optional().describe("Result title"),metadata:x.z.record(x.z.string(),x.z.unknown()).optional().describe("Result metadata"),output:x.z.string().optional().describe("Result output"),success:x.z.boolean().optional().describe("Whether execution succeeded"),error:x.z.string().optional().describe("Error message if failed")}).describe("Command execution result")}),Q=x.z.enum(["read","write","exec","admin"]),X=x.z.object({tool:x.z.string().describe("Tool name requesting permission"),args:d.optional(),level:Q.optional(),reason:x.z.string().optional().describe("Reason for permission request")}),Y=x.z.object({sessionID:n,request:X}),ee=x.z.object({sessionID:n,tool:x.z.string(),reason:x.z.string().optional()}),h=x.z.enum(["openai","anthropic","google","azure","custom"]),te=x.z.object({temperature:x.z.number().min(0).max(2).optional(),topP:x.z.number().min(0).max(1).optional(),topK:x.z.number().int().positive().optional(),maxTokens:x.z.number().int().positive().optional(),stopSequences:x.z.array(x.z.string()).optional(),responseFormat:x.z.enum(["text","json_object"]).optional()}),oe=x.z.object({sessionID:n,agent:p,model:y,provider:h,params:te.partial().optional()}),ne=x.z.object({sessionID:n,agent:p,model:y,provider:h,headers:x.z.record(x.z.string(),x.z.string()).optional()}),re=x.z.object({cwd:b.describe("Working directory"),sessionID:n.optional(),callID:m.optional()}),se=x.z.object({sessionID:n,messageID:s,partID:x.z.string().describe("Text part ID"),text:x.z.string().describe("Completed text")}),ie=x.z.object({sessionID:n,mode:x.z.enum(["agent","chat","query"]).describe("Build mode"),projectID:x.z.string().optional()}),ae=x.z.object({sessionID:n,context:x.z.object({messages:x.z.array(I),system:x.z.array(x.z.string()),metadata:x.z.record(x.z.string(),x.z.unknown())}).describe("Built context")}),pe=x.z.object({gatewayID:x.z.string().describe("Gateway ID"),messageID:s,message:x.z.unknown().describe("Received message")}),ue=x.z.object({gatewayID:x.z.string(),messageID:s,message:x.z.unknown(),sessionID:n.optional()}),me=x.z.object({gatewayID:x.z.string(),messageID:s,result:x.z.unknown().optional()}),ce=x.z.object({gatewayID:x.z.string(),messageID:s,message:x.z.unknown(),target:x.z.string().optional().describe("Send target")}),le=x.z.object({sessionID:n.optional(),timestamp:x.z.number().describe("Heartbeat timestamp"),name:x.z.string().optional().describe("Heartbeat name")}),de=x.z.object({sessionID:n.optional(),timestamp:x.z.number(),duration:x.z.number().nonnegative().optional()}),ge=x.z.object({taskID:x.z.string().describe("Task ID"),taskName:x.z.string().optional(),timestamp:x.z.number(),payload:x.z.record(x.z.string(),x.z.unknown()).optional()}),fe=x.z.object({taskID:x.z.string(),timestamp:x.z.number(),success:x.z.boolean(),result:x.z.record(x.z.string(),x.z.unknown()).optional(),error:x.z.string().optional()}),f={[o.SessionStart]:j,[o.SessionEnd]:A,[o.SessionCompacting]:z,[o.SessionCompact]:R,[o.StepStart]:F,[o.StepFinish]:O,[o.StepStop]:W,[o.StepStopFailure]:B,[o.MessageReceive]:L,[o.MessageTransform]:_,[o.SystemTransform]:q,[o.ToolBefore]:U,[o.ToolAfter]:Z,[o.ToolFailure]:V,[o.ToolDefinition]:$,[o.CommandBefore]:K,[o.CommandAfter]:J,[o.PermissionAsk]:Y,[o.PermissionDenied]:ee,[o.LlmParams]:oe,[o.LlmHeaders]:ne,[o.ShellEnv]:re,[o.TextComplete]:se,[o.ContextBuildBefore]:ie,[o.ContextBuildAfter]:ae,[o.GatewayMessageReceive]:pe,[o.GatewayMessageProcess]:ue,[o.GatewayMessageComplete]:me,[o.GatewayMessageSend]:ce,[o.HeartbeatTrigger]:le,[o.HeartbeatComplete]:de,[o.ScheduledTaskTrigger]:ge,[o.ScheduledTaskComplete]:fe};function je(r){return f[r]}function Ae(r,g){let u=f[r];if(!u)throw new Error(`No schema found for event: ${r}`);return u.parse(g)}function ze(r,g){let u=f[r];return u?u.safeParse(g):{success:false,error:new x.z.ZodError([{code:"custom",path:[],message:`No schema found for event: ${r}`}])}}var qe=x.z.enum(["command","mcp","skill"]).describe("Command source"),ye=x.z.union([x.z.string(),x.z.record(x.z.string(),x.z.unknown())]).describe("Command arguments"),be=x.z.discriminatedUnion("type",[x.z.object({type:x.z.literal("text"),text:x.z.string().describe("Text content")}),x.z.object({type:x.z.literal("image"),source:x.z.object({type:x.z.enum(["base64","url"]),mime:x.z.string().describe("File mime type"),data:x.z.string().describe("File base64 encoding data or url")})}),x.z.object({type:x.z.literal("file"),url:x.z.string().describe("File path"),filename:x.z.string().describe("File name"),mime:x.z.string().optional().describe("File mime type")})]),Ne=x.z.object({name:x.z.string().describe("Command name"),description:x.z.string().describe("Command description"),agent:x.z.string().optional().describe("Specified agent name"),model:x.z.string().optional().describe("Specified model"),hints:x.z.array(x.z.string()).optional().describe("Argument hints"),commandType:x.z.enum(["prompt","local"]).optional().describe("Command type"),hidden:x.z.boolean().optional().describe("Whether hidden")}),Ue=x.z.object({sessionID:x.z.string().describe("Session ID"),directory:x.z.string().describe("Working directory"),model:x.z.string().optional().describe("Model identifier"),agent:x.z.string().optional().describe("Agent name"),arguments:ye.describe("Command arguments")}),Se=x.z.record(x.z.string(),x.z.unknown()).describe("Result metadata"),Ze=x.z.object({title:x.z.string().describe("Result title"),metadata:Se.describe("Result metadata"),output:x.z.string().describe("Result output"),parts:x.z.array(be).optional().describe("Result parts"),success:x.z.boolean().describe("Whether execution succeeded"),error:x.z.string().optional().describe("Error message if failed")}),Ve=x.z.object({agent:x.z.object({name:x.z.string().describe("Agent name"),model:x.z.string().optional().describe("Agent model")}).optional().describe("Agent context")}),$e=x.z.object({isEnabled:x.z.boolean().optional().describe("Is enabled check result")});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=P;exports.AgentSchema=p;exports.CallIDSchema=m;exports.CommandAfterInputSchema=J;exports.CommandArgumentsSchema=ye;exports.CommandBeforeInputSchema=K;exports.CommandExecuteResultMetadataSchema=Se;exports.CommandExecuteResultSchema=Ze;exports.CommandExecutionContextSchema=Ue;exports.CommandExecutorSchema=C;exports.CommandInitContextSchema=Ve;exports.CommandInitResultSchema=$e;exports.CommandMetadataSchema=Ne;exports.CommandPromptPartSchema=be;exports.CommandSourceSchema=qe;exports.ContentPartSchema=S;exports.ContextBuildAfterInputSchema=ae;exports.ContextBuildBeforeInputSchema=ie;exports.CwdSchema=b;exports.EndReasonSchema=w;exports.EventInputSchemas=f;exports.FinishReasonSchema=M;exports.FunctionExecutorSchema=H;exports.GatewayMessageCompleteInputSchema=me;exports.GatewayMessageProcessInputSchema=ue;exports.GatewayMessageReceiveInputSchema=pe;exports.GatewayMessageSendInputSchema=ce;exports.HOOK_EVENTS=Pe;exports.HeartbeatCompleteInputSchema=de;exports.HeartbeatTriggerInputSchema=le;exports.HookEvent=o;exports.HookExecutorSchema=D;exports.HookMatcherSchema=E;exports.HookType=a;exports.HooksConfigSchema=Me;exports.HttpExecutorSchema=v;exports.LlmHeadersInputSchema=ne;exports.LlmParamsInputSchema=oe;exports.LlmParamsSchema=te;exports.LlmProviderSchema=h;exports.MessageIDSchema=s;exports.MessageReceiveInputSchema=L;exports.MessageRoleSchema=G;exports.MessageSchema=I;exports.MessageTransformInputSchema=_;exports.ModelObjectSchema=y;exports.ModelSchema=c;exports.PermissionAskInputSchema=Y;exports.PermissionDeniedInputSchema=ee;exports.PermissionLevelSchema=Q;exports.PermissionRequestSchema=X;exports.PromptExecutorSchema=T;exports.ScheduledTaskCompleteInputSchema=fe;exports.ScheduledTaskTriggerInputSchema=ge;exports.SessionCompactInputSchema=R;exports.SessionCompactingInputSchema=z;exports.SessionEndInputSchema=A;exports.SessionIDSchema=n;exports.SessionStartInputSchema=j;exports.ShellEnvInputSchema=re;exports.StepFinishInputSchema=O;exports.StepStartInputSchema=F;exports.StepStopFailureInputSchema=B;exports.StepStopInputSchema=W;exports.SystemTransformInputSchema=q;exports.TextCompleteInputSchema=se;exports.ToolAfterInputSchema=Z;exports.ToolArgsSchema=d;exports.ToolBeforeInputSchema=U;exports.ToolDefinitionInputSchema=$;exports.ToolFailureInputSchema=V;exports.ToolResultSchema=N;exports.getEventInputSchema=je;exports.safeValidateHookInput=ze;exports.tool=k;exports.validateHookInput=Ae;