@easbot/plugin 0.1.11 → 0.1.14

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 ADDED
@@ -0,0 +1,116 @@
1
+ [中文](./README.md) | English
2
+
3
+ # @easbot/plugin
4
+
5
+ EASBot Plugin System - Hooks, Commands, and Tool Management
6
+
7
+ ## Features
8
+
9
+ - **Hook System**: Event-driven hook mechanism for extending Agent behavior
10
+ - **Command System**: Extensible command registration and execution
11
+ - **Tool System**: Plugin tools with permission control
12
+ - **Shell Integration**: Shell command execution support
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ pnpm add @easbot/plugin
18
+ ```
19
+
20
+ ## Quick Start
21
+
22
+ ### Hook System
23
+
24
+ ```typescript
25
+ import { createHookRegistry, HOOK_EVENTS } from '@easbot/plugin';
26
+
27
+ // Create hook registry
28
+ const hooks = createHookRegistry();
29
+
30
+ // Register a hook
31
+ hooks.register(HOOK_EVENTS.BEFORE_TOOL_CALL, async (tool, context) => {
32
+ console.log('Tool called:', tool.name);
33
+ return context;
34
+ });
35
+ ```
36
+
37
+ ### Command System
38
+
39
+ ```typescript
40
+ import { createCommandRegistry } from '@easbot/plugin';
41
+
42
+ const commands = createCommandRegistry();
43
+
44
+ // Register a command
45
+ commands.register({
46
+ name: 'hello',
47
+ description: 'Say hello',
48
+ execute: async (args, session) => {
49
+ await session.send('Hello!');
50
+ }
51
+ });
52
+ ```
53
+
54
+ ### Tool System
55
+
56
+ ```typescript
57
+ import { createTool } from '@easbot/plugin';
58
+
59
+ const tool = createTool({
60
+ name: 'my-tool',
61
+ description: 'A custom tool',
62
+ parameters: z.object({
63
+ input: z.string()
64
+ }),
65
+ execute: async ({ input }) => {
66
+ return { result: input.toUpperCase() };
67
+ }
68
+ });
69
+ ```
70
+
71
+ ## API
72
+
73
+ ### HookRegistry
74
+
75
+ | Method | Description |
76
+ |--------|-------------|
77
+ | `register(event, handler)` | Register a hook handler |
78
+ | `unregister(event, handler)` | Remove a hook handler |
79
+ | `clear(event)` | Clear all handlers for an event |
80
+
81
+ ### CommandRegistry
82
+
83
+ | Method | Description |
84
+ |--------|-------------|
85
+ | `register(command)` | Register a command |
86
+ | `get(name)` | Get a command |
87
+ | `execute(name, args)` | Execute a command |
88
+
89
+ ### createTool
90
+
91
+ | Property | Type | Description |
92
+ |----------|------|-------------|
93
+ | name | string | Tool name |
94
+ | description | string | Tool description |
95
+ | parameters | ZodSchema | Parameter schema |
96
+ | execute | function | Tool implementation |
97
+
98
+ ## Development
99
+
100
+ ```bash
101
+ # Install dependencies
102
+ pnpm install
103
+
104
+ # Build
105
+ pnpm build
106
+
107
+ # Test
108
+ pnpm test
109
+
110
+ # Type check
111
+ pnpm type-check
112
+ ```
113
+
114
+ ## License
115
+
116
+ MIT
package/README.md CHANGED
@@ -0,0 +1,116 @@
1
+ [English](./README.en.md) | 中文
2
+
3
+ # @easbot/plugin
4
+
5
+ EASBot 插件系统 - Hook、命令和工具管理
6
+
7
+ ## 特性
8
+
9
+ - **Hook 系统**:事件驱动的 Hook 机制,扩展 Agent 行为
10
+ - **命令系统**:可扩展的命令注册和执行
11
+ - **工具系统**:插件工具与权限控制
12
+ - **Shell 集成**:Shell 命令执行支持
13
+
14
+ ## 安装
15
+
16
+ ```bash
17
+ pnpm add @easbot/plugin
18
+ ```
19
+
20
+ ## 快速开始
21
+
22
+ ### Hook 系统
23
+
24
+ ```typescript
25
+ import { createHookRegistry, HOOK_EVENTS } from '@easbot/plugin';
26
+
27
+ // 创建 Hook 注册表
28
+ const hooks = createHookRegistry();
29
+
30
+ // 注册 Hook
31
+ hooks.register(HOOK_EVENTS.BEFORE_TOOL_CALL, async (tool, context) => {
32
+ console.log('Tool called:', tool.name);
33
+ return context;
34
+ });
35
+ ```
36
+
37
+ ### 命令系统
38
+
39
+ ```typescript
40
+ import { createCommandRegistry } from '@easbot/plugin';
41
+
42
+ const commands = createCommandRegistry();
43
+
44
+ // 注册命令
45
+ commands.register({
46
+ name: 'hello',
47
+ description: '打招呼',
48
+ execute: async (args, session) => {
49
+ await session.send('你好!');
50
+ }
51
+ });
52
+ ```
53
+
54
+ ### 工具系统
55
+
56
+ ```typescript
57
+ import { createTool } from '@easbot/plugin';
58
+
59
+ const tool = createTool({
60
+ name: 'my-tool',
61
+ description: '自定义工具',
62
+ parameters: z.object({
63
+ input: z.string()
64
+ }),
65
+ execute: async ({ input }) => {
66
+ return { result: input.toUpperCase() };
67
+ }
68
+ });
69
+ ```
70
+
71
+ ## API
72
+
73
+ ### HookRegistry
74
+
75
+ | 方法 | 说明 |
76
+ |------|------|
77
+ | `register(event, handler)` | 注册 Hook 处理器 |
78
+ | `unregister(event, handler)` | 移除 Hook 处理器 |
79
+ | `clear(event)` | 清除事件的所有处理器 |
80
+
81
+ ### CommandRegistry
82
+
83
+ | 方法 | 说明 |
84
+ |------|------|
85
+ | `register(command)` | 注册命令 |
86
+ | `get(name)` | 获取命令 |
87
+ | `execute(name, args)` | 执行命令 |
88
+
89
+ ### createTool
90
+
91
+ | 属性 | 类型 | 说明 |
92
+ |------|------|------|
93
+ | name | string | 工具名称 |
94
+ | description | string | 工具描述 |
95
+ | parameters | ZodSchema | 参数模式 |
96
+ | execute | function | 工具实现 |
97
+
98
+ ## 开发
99
+
100
+ ```bash
101
+ # 安装依赖
102
+ pnpm install
103
+
104
+ # 构建
105
+ pnpm build
106
+
107
+ # 测试
108
+ pnpm test
109
+
110
+ # 类型检查
111
+ pnpm type-check
112
+ ```
113
+
114
+ ## 许可证
115
+
116
+ MIT
package/dist/index.cjs CHANGED
@@ -1 +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;
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(s){return {description:s.description,args:s.args,execute:s.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"),r=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:r,userMessageID:r.optional().describe("User message ID for the current step"),model:c,agent:p}),O=x.z.object({sessionID:n,messageID:r,userMessageID:r.optional().describe("User message ID for the current step"),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"]),I=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")})]),S=x.z.object({id:r,role:G,content:x.z.union([x.z.string(),x.z.array(I)]),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:r,message:x.z.object({id:r,role:x.z.literal("user"),content:x.z.union([x.z.string(),x.z.array(I)])}).describe("User message")}),_=x.z.object({sessionID:n,messages:x.z.array(S).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"),U=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")}),N=x.z.object({sessionID:n,userMessageID:r.optional().describe("User message ID for the current step"),tool:x.z.string().describe("Tool name"),callID:m,args:d}),Z=x.z.object({sessionID:n,userMessageID:r.optional().describe("User message ID for the current step"),tool:x.z.string(),callID:m,args:d,result:U,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:r,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(S),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:r,message:x.z.unknown().describe("Received message")}),ue=x.z.object({gatewayID:x.z.string(),messageID:r,message:x.z.unknown(),sessionID:n.optional()}),me=x.z.object({gatewayID:x.z.string(),messageID:r,result:x.z.unknown().optional()}),ce=x.z.object({gatewayID:x.z.string(),messageID:r,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]:N,[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(s){return f[s]}function Ae(s,g){let u=f[s];if(!u)throw new Error(`No schema found for event: ${s}`);return u.parse(g)}function ze(s,g){let u=f[s];return u?u.safeParse(g):{success:false,error:new x.z.ZodError([{code:"custom",path:[],message:`No schema found for event: ${s}`}])}}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")})]),Ue=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")}),Ne=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")}),Ie=x.z.record(x.z.string(),x.z.unknown()).describe("Result metadata"),Ze=x.z.object({title:x.z.string().describe("Result title"),metadata:Ie.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=Ie;exports.CommandExecuteResultSchema=Ze;exports.CommandExecutionContextSchema=Ne;exports.CommandExecutorSchema=C;exports.CommandInitContextSchema=Ve;exports.CommandInitResultSchema=$e;exports.CommandMetadataSchema=Ue;exports.CommandPromptPartSchema=be;exports.CommandSourceSchema=qe;exports.ContentPartSchema=I;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=r;exports.MessageReceiveInputSchema=L;exports.MessageRoleSchema=G;exports.MessageSchema=S;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=N;exports.ToolDefinitionInputSchema=$;exports.ToolFailureInputSchema=V;exports.ToolResultSchema=U;exports.getEventInputSchema=je;exports.safeValidateHookInput=ze;exports.tool=k;exports.validateHookInput=Ae;
package/dist/index.d.cts CHANGED
@@ -418,6 +418,7 @@ type SessionCompactInput = z$1.infer<typeof SessionCompactInputSchema>;
418
418
  declare const StepStartInputSchema: z$1.ZodObject<{
419
419
  sessionID: z$1.ZodString;
420
420
  messageID: z$1.ZodString;
421
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
421
422
  model: z$1.ZodOptional<z$1.ZodString>;
422
423
  agent: z$1.ZodOptional<z$1.ZodString>;
423
424
  }, z$1.core.$strip>;
@@ -425,6 +426,7 @@ type StepStartInput = z$1.infer<typeof StepStartInputSchema>;
425
426
  declare const StepFinishInputSchema: z$1.ZodObject<{
426
427
  sessionID: z$1.ZodString;
427
428
  messageID: z$1.ZodString;
429
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
428
430
  model: z$1.ZodOptional<z$1.ZodString>;
429
431
  agent: z$1.ZodOptional<z$1.ZodString>;
430
432
  finishReason: z$1.ZodEnum<{
@@ -592,6 +594,7 @@ declare const ToolResultSchema: z$1.ZodObject<{
592
594
  }, z$1.core.$strip>;
593
595
  declare const ToolBeforeInputSchema: z$1.ZodObject<{
594
596
  sessionID: z$1.ZodString;
597
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
595
598
  tool: z$1.ZodString;
596
599
  callID: z$1.ZodString;
597
600
  args: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
@@ -599,6 +602,7 @@ declare const ToolBeforeInputSchema: z$1.ZodObject<{
599
602
  type ToolBeforeInput = z$1.infer<typeof ToolBeforeInputSchema>;
600
603
  declare const ToolAfterInputSchema: z$1.ZodObject<{
601
604
  sessionID: z$1.ZodString;
605
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
602
606
  tool: z$1.ZodString;
603
607
  callID: z$1.ZodString;
604
608
  args: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
@@ -922,12 +926,14 @@ declare const EventInputSchemas: {
922
926
  readonly "step.start": z$1.ZodObject<{
923
927
  sessionID: z$1.ZodString;
924
928
  messageID: z$1.ZodString;
929
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
925
930
  model: z$1.ZodOptional<z$1.ZodString>;
926
931
  agent: z$1.ZodOptional<z$1.ZodString>;
927
932
  }, z$1.core.$strip>;
928
933
  readonly "step.finish": z$1.ZodObject<{
929
934
  sessionID: z$1.ZodString;
930
935
  messageID: z$1.ZodString;
936
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
931
937
  model: z$1.ZodOptional<z$1.ZodString>;
932
938
  agent: z$1.ZodOptional<z$1.ZodString>;
933
939
  finishReason: z$1.ZodEnum<{
@@ -1027,12 +1033,14 @@ declare const EventInputSchemas: {
1027
1033
  }, z$1.core.$strip>;
1028
1034
  readonly "tool.before": z$1.ZodObject<{
1029
1035
  sessionID: z$1.ZodString;
1036
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
1030
1037
  tool: z$1.ZodString;
1031
1038
  callID: z$1.ZodString;
1032
1039
  args: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
1033
1040
  }, z$1.core.$strip>;
1034
1041
  readonly "tool.after": z$1.ZodObject<{
1035
1042
  sessionID: z$1.ZodString;
1043
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
1036
1044
  tool: z$1.ZodString;
1037
1045
  callID: z$1.ZodString;
1038
1046
  args: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
@@ -1301,11 +1309,13 @@ declare function getEventInputSchema(event: HookEvent): z$1.ZodObject<{
1301
1309
  }, z$1.core.$strip> | z$1.ZodObject<{
1302
1310
  sessionID: z$1.ZodString;
1303
1311
  messageID: z$1.ZodString;
1312
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
1304
1313
  model: z$1.ZodOptional<z$1.ZodString>;
1305
1314
  agent: z$1.ZodOptional<z$1.ZodString>;
1306
1315
  }, z$1.core.$strip> | z$1.ZodObject<{
1307
1316
  sessionID: z$1.ZodString;
1308
1317
  messageID: z$1.ZodString;
1318
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
1309
1319
  model: z$1.ZodOptional<z$1.ZodString>;
1310
1320
  agent: z$1.ZodOptional<z$1.ZodString>;
1311
1321
  finishReason: z$1.ZodEnum<{
@@ -1399,11 +1409,13 @@ declare function getEventInputSchema(event: HookEvent): z$1.ZodObject<{
1399
1409
  system: z$1.ZodArray<z$1.ZodString>;
1400
1410
  }, z$1.core.$strip> | z$1.ZodObject<{
1401
1411
  sessionID: z$1.ZodString;
1412
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
1402
1413
  tool: z$1.ZodString;
1403
1414
  callID: z$1.ZodString;
1404
1415
  args: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
1405
1416
  }, z$1.core.$strip> | z$1.ZodObject<{
1406
1417
  sessionID: z$1.ZodString;
1418
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
1407
1419
  tool: z$1.ZodString;
1408
1420
  callID: z$1.ZodString;
1409
1421
  args: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
package/dist/index.d.ts CHANGED
@@ -418,6 +418,7 @@ type SessionCompactInput = z$1.infer<typeof SessionCompactInputSchema>;
418
418
  declare const StepStartInputSchema: z$1.ZodObject<{
419
419
  sessionID: z$1.ZodString;
420
420
  messageID: z$1.ZodString;
421
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
421
422
  model: z$1.ZodOptional<z$1.ZodString>;
422
423
  agent: z$1.ZodOptional<z$1.ZodString>;
423
424
  }, z$1.core.$strip>;
@@ -425,6 +426,7 @@ type StepStartInput = z$1.infer<typeof StepStartInputSchema>;
425
426
  declare const StepFinishInputSchema: z$1.ZodObject<{
426
427
  sessionID: z$1.ZodString;
427
428
  messageID: z$1.ZodString;
429
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
428
430
  model: z$1.ZodOptional<z$1.ZodString>;
429
431
  agent: z$1.ZodOptional<z$1.ZodString>;
430
432
  finishReason: z$1.ZodEnum<{
@@ -592,6 +594,7 @@ declare const ToolResultSchema: z$1.ZodObject<{
592
594
  }, z$1.core.$strip>;
593
595
  declare const ToolBeforeInputSchema: z$1.ZodObject<{
594
596
  sessionID: z$1.ZodString;
597
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
595
598
  tool: z$1.ZodString;
596
599
  callID: z$1.ZodString;
597
600
  args: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
@@ -599,6 +602,7 @@ declare const ToolBeforeInputSchema: z$1.ZodObject<{
599
602
  type ToolBeforeInput = z$1.infer<typeof ToolBeforeInputSchema>;
600
603
  declare const ToolAfterInputSchema: z$1.ZodObject<{
601
604
  sessionID: z$1.ZodString;
605
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
602
606
  tool: z$1.ZodString;
603
607
  callID: z$1.ZodString;
604
608
  args: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
@@ -922,12 +926,14 @@ declare const EventInputSchemas: {
922
926
  readonly "step.start": z$1.ZodObject<{
923
927
  sessionID: z$1.ZodString;
924
928
  messageID: z$1.ZodString;
929
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
925
930
  model: z$1.ZodOptional<z$1.ZodString>;
926
931
  agent: z$1.ZodOptional<z$1.ZodString>;
927
932
  }, z$1.core.$strip>;
928
933
  readonly "step.finish": z$1.ZodObject<{
929
934
  sessionID: z$1.ZodString;
930
935
  messageID: z$1.ZodString;
936
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
931
937
  model: z$1.ZodOptional<z$1.ZodString>;
932
938
  agent: z$1.ZodOptional<z$1.ZodString>;
933
939
  finishReason: z$1.ZodEnum<{
@@ -1027,12 +1033,14 @@ declare const EventInputSchemas: {
1027
1033
  }, z$1.core.$strip>;
1028
1034
  readonly "tool.before": z$1.ZodObject<{
1029
1035
  sessionID: z$1.ZodString;
1036
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
1030
1037
  tool: z$1.ZodString;
1031
1038
  callID: z$1.ZodString;
1032
1039
  args: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
1033
1040
  }, z$1.core.$strip>;
1034
1041
  readonly "tool.after": z$1.ZodObject<{
1035
1042
  sessionID: z$1.ZodString;
1043
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
1036
1044
  tool: z$1.ZodString;
1037
1045
  callID: z$1.ZodString;
1038
1046
  args: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
@@ -1301,11 +1309,13 @@ declare function getEventInputSchema(event: HookEvent): z$1.ZodObject<{
1301
1309
  }, z$1.core.$strip> | z$1.ZodObject<{
1302
1310
  sessionID: z$1.ZodString;
1303
1311
  messageID: z$1.ZodString;
1312
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
1304
1313
  model: z$1.ZodOptional<z$1.ZodString>;
1305
1314
  agent: z$1.ZodOptional<z$1.ZodString>;
1306
1315
  }, z$1.core.$strip> | z$1.ZodObject<{
1307
1316
  sessionID: z$1.ZodString;
1308
1317
  messageID: z$1.ZodString;
1318
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
1309
1319
  model: z$1.ZodOptional<z$1.ZodString>;
1310
1320
  agent: z$1.ZodOptional<z$1.ZodString>;
1311
1321
  finishReason: z$1.ZodEnum<{
@@ -1399,11 +1409,13 @@ declare function getEventInputSchema(event: HookEvent): z$1.ZodObject<{
1399
1409
  system: z$1.ZodArray<z$1.ZodString>;
1400
1410
  }, z$1.core.$strip> | z$1.ZodObject<{
1401
1411
  sessionID: z$1.ZodString;
1412
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
1402
1413
  tool: z$1.ZodString;
1403
1414
  callID: z$1.ZodString;
1404
1415
  args: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
1405
1416
  }, z$1.core.$strip> | z$1.ZodObject<{
1406
1417
  sessionID: z$1.ZodString;
1418
+ userMessageID: z$1.ZodOptional<z$1.ZodString>;
1407
1419
  tool: z$1.ZodString;
1408
1420
  callID: z$1.ZodString;
1409
1421
  args: z$1.ZodRecord<z$1.ZodString, z$1.ZodUnknown>;
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import k,{z as z$1}from'zod';export{buildToolArgs,createTool,toolSchema as schema}from'@easbot/types';import'@easbot/sdk';function C(r){return {description:r.description,args:r.args,execute:r.execute}}C.schema=k;var p={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"},He=Object.values(o);var d=z$1.string().optional(),T=z$1.object({type:z$1.literal(p.Command),command:z$1.string(),if:d,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()}),v=z$1.object({type:z$1.literal(p.Prompt),if:d,timeout:z$1.number().positive().optional(),model:z$1.string().optional(),statusMessage:z$1.string().optional(),once:z$1.boolean().optional(),runMode:z$1.enum(["session","fork"]).optional(),system:z$1.string().optional(),parts:z$1.array(z$1.unknown())}),P=z$1.object({type:z$1.literal(p.Http),url:z$1.string(),if:d,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()}),H=z$1.object({type:z$1.literal(p.Agent),if:d,timeout:z$1.number().positive().optional(),model:z$1.string().optional(),statusMessage:z$1.string().optional(),once:z$1.boolean().optional(),system:z$1.string().optional(),parts:z$1.array(z$1.unknown())}),D=z$1.object({type:z$1.literal(p.Function),handler:z$1.function()}),E=z$1.discriminatedUnion("type",[T,v,P,H,D]),w=z$1.object({event:z$1.string(),matcher:z$1.string().optional(),hooks:z$1.array(E)}),je=z$1.record(z$1.string(),z$1.array(w)),n=z$1.string().min(1).describe("Session unique identifier"),s=z$1.string().min(1).describe("Message unique identifier"),c=z$1.string().min(1).describe("Tool call unique identifier"),u=z$1.string().optional().describe("Agent name"),l=z$1.string().optional().describe("Model identifier"),b=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"),S=z$1.string().optional().describe("Working directory path"),M=z$1.enum(["user_request","max_tokens","stop","error","timeout","cancelled"]).describe("Session end reason"),j=z$1.enum(["stop","max_tokens","end_turn","stop_sequence"]).describe("Step finish reason"),A=z$1.object({sessionID:n,source:z$1.enum(["user","agent","system","scheduled"]).optional().describe("Session source"),model:l,agent:u,cwd:S}),z=z$1.object({sessionID:n,reason:M,duration:z$1.number().positive().optional().describe("Session duration in milliseconds")}),R=z$1.object({sessionID:n,trigger:z$1.enum(["manual","auto","threshold"]).describe("Compaction trigger"),contextLength:z$1.number().positive().describe("Current context length"),threshold:z$1.number().positive().describe("Trigger threshold")}),F=z$1.object({sessionID:n,summary:z$1.string().describe("Compaction summary"),previousLength:z$1.number().positive().describe("Previous context length"),newLength:z$1.number().positive().describe("New context length")}),O=z$1.object({sessionID:n,messageID:s,model:l,agent:u}),W=z$1.object({sessionID:n,messageID:s,model:l,agent:u,finishReason:j,tokens:z$1.object({input:z$1.number().int().nonnegative().optional(),output:z$1.number().int().nonnegative().optional(),total:z$1.number().int().nonnegative().optional()}).optional().describe("Token usage statistics")}),B=z$1.object({sessionID:n,reason:z$1.string().describe("Stop reason")}),G=z$1.object({sessionID:n,error:z$1.string().describe("Error message"),errorType:z$1.enum(["rate_limit","auth_error","network_error","timeout","invalid_request","server_error"]).describe("Error type")}),L=z$1.enum(["user","assistant","system","tool"]),I=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")})]),h=z$1.object({id:s,role:L,content:z$1.union([z$1.string(),z$1.array(I)]),name:z$1.string().optional().describe("Message sender name"),tool_call_id:c.optional().describe("Related tool call ID")}),_=z$1.object({sessionID:n,agent:u,model:l,messageID:s,message:z$1.object({id:s,role:z$1.literal("user"),content:z$1.union([z$1.string(),z$1.array(I)])}).describe("User message")}),q=z$1.object({sessionID:n,messages:z$1.array(h).describe("Messages to transform")}),N=z$1.object({sessionID:n,model:l,system:z$1.array(z$1.string()).describe("Current system prompt")}),g=z$1.record(z$1.string(),z$1.unknown()).describe("Tool call arguments"),U=z$1.object({title:z$1.string().optional().describe("Result title"),content:z$1.string().describe("Result content"),is_error:z$1.boolean().optional().describe("Is error result"),metadata:z$1.record(z$1.string(),z$1.unknown()).optional().describe("Extra metadata")}),Z=z$1.object({sessionID:n,tool:z$1.string().describe("Tool name"),callID:c,args:g}),V=z$1.object({sessionID:n,tool:z$1.string(),callID:c,args:g,result:U,duration:z$1.number().nonnegative().optional().describe("Execution duration in milliseconds")}),$=z$1.object({sessionID:n,tool:z$1.string(),callID:c,args:g,error:z$1.string().describe("Error message"),errorType:z$1.enum(["timeout","invalid_args","execution_error","permission_denied"])}),K=z$1.object({sessionID:n,toolID:z$1.string().describe("Tool ID"),definition:z$1.object({name:z$1.string(),description:z$1.string().optional(),parameters:z$1.record(z$1.string(),z$1.unknown()).optional()}).describe("Tool definition")}),J=z$1.object({sessionID:n,command:z$1.string().describe("Command name"),arguments:z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.unknown())]).describe("Command arguments")}),Q=z$1.object({sessionID:n,command:z$1.string().describe("Command name"),arguments:z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.unknown())]).optional(),result:z$1.object({info:z$1.unknown().optional().describe("Message info"),parts:z$1.array(z$1.unknown()).optional().describe("Message parts"),title:z$1.string().optional().describe("Result title"),metadata:z$1.record(z$1.string(),z$1.unknown()).optional().describe("Result metadata"),output:z$1.string().optional().describe("Result output"),success:z$1.boolean().optional().describe("Whether execution succeeded"),error:z$1.string().optional().describe("Error message if failed")}).describe("Command execution result")}),X=z$1.enum(["read","write","exec","admin"]),Y=z$1.object({tool:z$1.string().describe("Tool name requesting permission"),args:g.optional(),level:X.optional(),reason:z$1.string().optional().describe("Reason for permission request")}),ee=z$1.object({sessionID:n,request:Y}),te=z$1.object({sessionID:n,tool:z$1.string(),reason:z$1.string().optional()}),x=z$1.enum(["openai","anthropic","google","azure","custom"]),oe=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()}),ne=z$1.object({sessionID:n,agent:u,model:b,provider:x,params:oe.partial().optional()}),re=z$1.object({sessionID:n,agent:u,model:b,provider:x,headers:z$1.record(z$1.string(),z$1.string()).optional()}),se=z$1.object({cwd:S.describe("Working directory"),sessionID:n.optional(),callID:c.optional()}),ie=z$1.object({sessionID:n,messageID:s,partID:z$1.string().describe("Text part ID"),text:z$1.string().describe("Completed text")}),ae=z$1.object({sessionID:n,mode:z$1.enum(["agent","chat","query"]).describe("Build mode"),projectID:z$1.string().optional()}),pe=z$1.object({sessionID:n,context:z$1.object({messages:z$1.array(h),system:z$1.array(z$1.string()),metadata:z$1.record(z$1.string(),z$1.unknown())}).describe("Built context")}),ue=z$1.object({gatewayID:z$1.string().describe("Gateway ID"),messageID:s,message:z$1.unknown().describe("Received message")}),me=z$1.object({gatewayID:z$1.string(),messageID:s,message:z$1.unknown(),sessionID:n.optional()}),ce=z$1.object({gatewayID:z$1.string(),messageID:s,result:z$1.unknown().optional()}),le=z$1.object({gatewayID:z$1.string(),messageID:s,message:z$1.unknown(),target:z$1.string().optional().describe("Send target")}),de=z$1.object({sessionID:n.optional(),timestamp:z$1.number().describe("Heartbeat timestamp"),name:z$1.string().optional().describe("Heartbeat name")}),ge=z$1.object({sessionID:n.optional(),timestamp:z$1.number(),duration:z$1.number().nonnegative().optional()}),fe=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()}),ye=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()}),y={[o.SessionStart]:A,[o.SessionEnd]:z,[o.SessionCompacting]:R,[o.SessionCompact]:F,[o.StepStart]:O,[o.StepFinish]:W,[o.StepStop]:B,[o.StepStopFailure]:G,[o.MessageReceive]:_,[o.MessageTransform]:q,[o.SystemTransform]:N,[o.ToolBefore]:Z,[o.ToolAfter]:V,[o.ToolFailure]:$,[o.ToolDefinition]:K,[o.CommandBefore]:J,[o.CommandAfter]:Q,[o.PermissionAsk]:ee,[o.PermissionDenied]:te,[o.LlmParams]:ne,[o.LlmHeaders]:re,[o.ShellEnv]:se,[o.TextComplete]:ie,[o.ContextBuildBefore]:ae,[o.ContextBuildAfter]:pe,[o.GatewayMessageReceive]:ue,[o.GatewayMessageProcess]:me,[o.GatewayMessageComplete]:ce,[o.GatewayMessageSend]:le,[o.HeartbeatTrigger]:de,[o.HeartbeatComplete]:ge,[o.ScheduledTaskTrigger]:fe,[o.ScheduledTaskComplete]:ye};function Ae(r){return y[r]}function ze(r,f){let m=y[r];if(!m)throw new Error(`No schema found for event: ${r}`);return m.parse(f)}function Re(r,f){let m=y[r];return m?m.safeParse(f):{success:false,error:new z$1.ZodError([{code:"custom",path:[],message:`No schema found for event: ${r}`}])}}var Ne=z$1.enum(["command","mcp","skill"]).describe("Command source"),be=z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.unknown())]).describe("Command arguments"),Se=z$1.discriminatedUnion("type",[z$1.object({type:z$1.literal("text"),text:z$1.string().describe("Text content")}),z$1.object({type:z$1.literal("image"),source:z$1.object({type:z$1.enum(["base64","url"]),mime:z$1.string().describe("File mime type"),data:z$1.string().describe("File base64 encoding data or url")})}),z$1.object({type:z$1.literal("file"),url:z$1.string().describe("File path"),filename:z$1.string().describe("File name"),mime:z$1.string().optional().describe("File mime type")})]),Ue=z$1.object({name:z$1.string().describe("Command name"),description:z$1.string().describe("Command description"),agent:z$1.string().optional().describe("Specified agent name"),model:z$1.string().optional().describe("Specified model"),hints:z$1.array(z$1.string()).optional().describe("Argument hints"),commandType:z$1.enum(["prompt","local"]).optional().describe("Command type"),hidden:z$1.boolean().optional().describe("Whether hidden")}),Ze=z$1.object({sessionID:z$1.string().describe("Session ID"),directory:z$1.string().describe("Working directory"),model:z$1.string().optional().describe("Model identifier"),agent:z$1.string().optional().describe("Agent name"),arguments:be.describe("Command arguments")}),Ie=z$1.record(z$1.string(),z$1.unknown()).describe("Result metadata"),Ve=z$1.object({title:z$1.string().describe("Result title"),metadata:Ie.describe("Result metadata"),output:z$1.string().describe("Result output"),parts:z$1.array(Se).optional().describe("Result parts"),success:z$1.boolean().describe("Whether execution succeeded"),error:z$1.string().optional().describe("Error message if failed")}),$e=z$1.object({agent:z$1.object({name:z$1.string().describe("Agent name"),model:z$1.string().optional().describe("Agent model")}).optional().describe("Agent context")}),Ke=z$1.object({isEnabled:z$1.boolean().optional().describe("Is enabled check result")});export{H as AgentExecutorSchema,u as AgentSchema,c as CallIDSchema,Q as CommandAfterInputSchema,be as CommandArgumentsSchema,J as CommandBeforeInputSchema,Ie as CommandExecuteResultMetadataSchema,Ve as CommandExecuteResultSchema,Ze as CommandExecutionContextSchema,T as CommandExecutorSchema,$e as CommandInitContextSchema,Ke as CommandInitResultSchema,Ue as CommandMetadataSchema,Se as CommandPromptPartSchema,Ne as CommandSourceSchema,I as ContentPartSchema,pe as ContextBuildAfterInputSchema,ae as ContextBuildBeforeInputSchema,S as CwdSchema,M as EndReasonSchema,y as EventInputSchemas,j as FinishReasonSchema,D as FunctionExecutorSchema,ce as GatewayMessageCompleteInputSchema,me as GatewayMessageProcessInputSchema,ue as GatewayMessageReceiveInputSchema,le as GatewayMessageSendInputSchema,He as HOOK_EVENTS,ge as HeartbeatCompleteInputSchema,de as HeartbeatTriggerInputSchema,o as HookEvent,E as HookExecutorSchema,w as HookMatcherSchema,p as HookType,je as HooksConfigSchema,P as HttpExecutorSchema,re as LlmHeadersInputSchema,ne as LlmParamsInputSchema,oe as LlmParamsSchema,x as LlmProviderSchema,s as MessageIDSchema,_ as MessageReceiveInputSchema,L as MessageRoleSchema,h as MessageSchema,q as MessageTransformInputSchema,b as ModelObjectSchema,l as ModelSchema,ee as PermissionAskInputSchema,te as PermissionDeniedInputSchema,X as PermissionLevelSchema,Y as PermissionRequestSchema,v as PromptExecutorSchema,ye as ScheduledTaskCompleteInputSchema,fe as ScheduledTaskTriggerInputSchema,F as SessionCompactInputSchema,R as SessionCompactingInputSchema,z as SessionEndInputSchema,n as SessionIDSchema,A as SessionStartInputSchema,se as ShellEnvInputSchema,W as StepFinishInputSchema,O as StepStartInputSchema,G as StepStopFailureInputSchema,B as StepStopInputSchema,N as SystemTransformInputSchema,ie as TextCompleteInputSchema,V as ToolAfterInputSchema,g as ToolArgsSchema,Z as ToolBeforeInputSchema,K as ToolDefinitionInputSchema,$ as ToolFailureInputSchema,U as ToolResultSchema,Ae as getEventInputSchema,Re as safeValidateHookInput,C as tool,ze as validateHookInput};
1
+ import k,{z as z$1}from'zod';export{buildToolArgs,createTool,toolSchema as schema}from'@easbot/types';import'@easbot/sdk';function C(s){return {description:s.description,args:s.args,execute:s.execute}}C.schema=k;var p={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"},He=Object.values(o);var d=z$1.string().optional(),T=z$1.object({type:z$1.literal(p.Command),command:z$1.string(),if:d,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()}),v=z$1.object({type:z$1.literal(p.Prompt),if:d,timeout:z$1.number().positive().optional(),model:z$1.string().optional(),statusMessage:z$1.string().optional(),once:z$1.boolean().optional(),runMode:z$1.enum(["session","fork"]).optional(),system:z$1.string().optional(),parts:z$1.array(z$1.unknown())}),P=z$1.object({type:z$1.literal(p.Http),url:z$1.string(),if:d,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()}),H=z$1.object({type:z$1.literal(p.Agent),if:d,timeout:z$1.number().positive().optional(),model:z$1.string().optional(),statusMessage:z$1.string().optional(),once:z$1.boolean().optional(),system:z$1.string().optional(),parts:z$1.array(z$1.unknown())}),D=z$1.object({type:z$1.literal(p.Function),handler:z$1.function()}),E=z$1.discriminatedUnion("type",[T,v,P,H,D]),w=z$1.object({event:z$1.string(),matcher:z$1.string().optional(),hooks:z$1.array(E)}),je=z$1.record(z$1.string(),z$1.array(w)),n=z$1.string().min(1).describe("Session unique identifier"),r=z$1.string().min(1).describe("Message unique identifier"),c=z$1.string().min(1).describe("Tool call unique identifier"),u=z$1.string().optional().describe("Agent name"),l=z$1.string().optional().describe("Model identifier"),b=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"),I=z$1.string().optional().describe("Working directory path"),M=z$1.enum(["user_request","max_tokens","stop","error","timeout","cancelled"]).describe("Session end reason"),j=z$1.enum(["stop","max_tokens","end_turn","stop_sequence"]).describe("Step finish reason"),A=z$1.object({sessionID:n,source:z$1.enum(["user","agent","system","scheduled"]).optional().describe("Session source"),model:l,agent:u,cwd:I}),z=z$1.object({sessionID:n,reason:M,duration:z$1.number().positive().optional().describe("Session duration in milliseconds")}),R=z$1.object({sessionID:n,trigger:z$1.enum(["manual","auto","threshold"]).describe("Compaction trigger"),contextLength:z$1.number().positive().describe("Current context length"),threshold:z$1.number().positive().describe("Trigger threshold")}),F=z$1.object({sessionID:n,summary:z$1.string().describe("Compaction summary"),previousLength:z$1.number().positive().describe("Previous context length"),newLength:z$1.number().positive().describe("New context length")}),O=z$1.object({sessionID:n,messageID:r,userMessageID:r.optional().describe("User message ID for the current step"),model:l,agent:u}),W=z$1.object({sessionID:n,messageID:r,userMessageID:r.optional().describe("User message ID for the current step"),model:l,agent:u,finishReason:j,tokens:z$1.object({input:z$1.number().int().nonnegative().optional(),output:z$1.number().int().nonnegative().optional(),total:z$1.number().int().nonnegative().optional()}).optional().describe("Token usage statistics")}),B=z$1.object({sessionID:n,reason:z$1.string().describe("Stop reason")}),G=z$1.object({sessionID:n,error:z$1.string().describe("Error message"),errorType:z$1.enum(["rate_limit","auth_error","network_error","timeout","invalid_request","server_error"]).describe("Error type")}),L=z$1.enum(["user","assistant","system","tool"]),S=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")})]),h=z$1.object({id:r,role:L,content:z$1.union([z$1.string(),z$1.array(S)]),name:z$1.string().optional().describe("Message sender name"),tool_call_id:c.optional().describe("Related tool call ID")}),_=z$1.object({sessionID:n,agent:u,model:l,messageID:r,message:z$1.object({id:r,role:z$1.literal("user"),content:z$1.union([z$1.string(),z$1.array(S)])}).describe("User message")}),q=z$1.object({sessionID:n,messages:z$1.array(h).describe("Messages to transform")}),U=z$1.object({sessionID:n,model:l,system:z$1.array(z$1.string()).describe("Current system prompt")}),g=z$1.record(z$1.string(),z$1.unknown()).describe("Tool call arguments"),N=z$1.object({title:z$1.string().optional().describe("Result title"),content:z$1.string().describe("Result content"),is_error:z$1.boolean().optional().describe("Is error result"),metadata:z$1.record(z$1.string(),z$1.unknown()).optional().describe("Extra metadata")}),Z=z$1.object({sessionID:n,userMessageID:r.optional().describe("User message ID for the current step"),tool:z$1.string().describe("Tool name"),callID:c,args:g}),V=z$1.object({sessionID:n,userMessageID:r.optional().describe("User message ID for the current step"),tool:z$1.string(),callID:c,args:g,result:N,duration:z$1.number().nonnegative().optional().describe("Execution duration in milliseconds")}),$=z$1.object({sessionID:n,tool:z$1.string(),callID:c,args:g,error:z$1.string().describe("Error message"),errorType:z$1.enum(["timeout","invalid_args","execution_error","permission_denied"])}),K=z$1.object({sessionID:n,toolID:z$1.string().describe("Tool ID"),definition:z$1.object({name:z$1.string(),description:z$1.string().optional(),parameters:z$1.record(z$1.string(),z$1.unknown()).optional()}).describe("Tool definition")}),J=z$1.object({sessionID:n,command:z$1.string().describe("Command name"),arguments:z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.unknown())]).describe("Command arguments")}),Q=z$1.object({sessionID:n,command:z$1.string().describe("Command name"),arguments:z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.unknown())]).optional(),result:z$1.object({info:z$1.unknown().optional().describe("Message info"),parts:z$1.array(z$1.unknown()).optional().describe("Message parts"),title:z$1.string().optional().describe("Result title"),metadata:z$1.record(z$1.string(),z$1.unknown()).optional().describe("Result metadata"),output:z$1.string().optional().describe("Result output"),success:z$1.boolean().optional().describe("Whether execution succeeded"),error:z$1.string().optional().describe("Error message if failed")}).describe("Command execution result")}),X=z$1.enum(["read","write","exec","admin"]),Y=z$1.object({tool:z$1.string().describe("Tool name requesting permission"),args:g.optional(),level:X.optional(),reason:z$1.string().optional().describe("Reason for permission request")}),ee=z$1.object({sessionID:n,request:Y}),te=z$1.object({sessionID:n,tool:z$1.string(),reason:z$1.string().optional()}),x=z$1.enum(["openai","anthropic","google","azure","custom"]),oe=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()}),ne=z$1.object({sessionID:n,agent:u,model:b,provider:x,params:oe.partial().optional()}),re=z$1.object({sessionID:n,agent:u,model:b,provider:x,headers:z$1.record(z$1.string(),z$1.string()).optional()}),se=z$1.object({cwd:I.describe("Working directory"),sessionID:n.optional(),callID:c.optional()}),ie=z$1.object({sessionID:n,messageID:r,partID:z$1.string().describe("Text part ID"),text:z$1.string().describe("Completed text")}),ae=z$1.object({sessionID:n,mode:z$1.enum(["agent","chat","query"]).describe("Build mode"),projectID:z$1.string().optional()}),pe=z$1.object({sessionID:n,context:z$1.object({messages:z$1.array(h),system:z$1.array(z$1.string()),metadata:z$1.record(z$1.string(),z$1.unknown())}).describe("Built context")}),ue=z$1.object({gatewayID:z$1.string().describe("Gateway ID"),messageID:r,message:z$1.unknown().describe("Received message")}),me=z$1.object({gatewayID:z$1.string(),messageID:r,message:z$1.unknown(),sessionID:n.optional()}),ce=z$1.object({gatewayID:z$1.string(),messageID:r,result:z$1.unknown().optional()}),le=z$1.object({gatewayID:z$1.string(),messageID:r,message:z$1.unknown(),target:z$1.string().optional().describe("Send target")}),de=z$1.object({sessionID:n.optional(),timestamp:z$1.number().describe("Heartbeat timestamp"),name:z$1.string().optional().describe("Heartbeat name")}),ge=z$1.object({sessionID:n.optional(),timestamp:z$1.number(),duration:z$1.number().nonnegative().optional()}),fe=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()}),ye=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()}),y={[o.SessionStart]:A,[o.SessionEnd]:z,[o.SessionCompacting]:R,[o.SessionCompact]:F,[o.StepStart]:O,[o.StepFinish]:W,[o.StepStop]:B,[o.StepStopFailure]:G,[o.MessageReceive]:_,[o.MessageTransform]:q,[o.SystemTransform]:U,[o.ToolBefore]:Z,[o.ToolAfter]:V,[o.ToolFailure]:$,[o.ToolDefinition]:K,[o.CommandBefore]:J,[o.CommandAfter]:Q,[o.PermissionAsk]:ee,[o.PermissionDenied]:te,[o.LlmParams]:ne,[o.LlmHeaders]:re,[o.ShellEnv]:se,[o.TextComplete]:ie,[o.ContextBuildBefore]:ae,[o.ContextBuildAfter]:pe,[o.GatewayMessageReceive]:ue,[o.GatewayMessageProcess]:me,[o.GatewayMessageComplete]:ce,[o.GatewayMessageSend]:le,[o.HeartbeatTrigger]:de,[o.HeartbeatComplete]:ge,[o.ScheduledTaskTrigger]:fe,[o.ScheduledTaskComplete]:ye};function Ae(s){return y[s]}function ze(s,f){let m=y[s];if(!m)throw new Error(`No schema found for event: ${s}`);return m.parse(f)}function Re(s,f){let m=y[s];return m?m.safeParse(f):{success:false,error:new z$1.ZodError([{code:"custom",path:[],message:`No schema found for event: ${s}`}])}}var Ue=z$1.enum(["command","mcp","skill"]).describe("Command source"),be=z$1.union([z$1.string(),z$1.record(z$1.string(),z$1.unknown())]).describe("Command arguments"),Ie=z$1.discriminatedUnion("type",[z$1.object({type:z$1.literal("text"),text:z$1.string().describe("Text content")}),z$1.object({type:z$1.literal("image"),source:z$1.object({type:z$1.enum(["base64","url"]),mime:z$1.string().describe("File mime type"),data:z$1.string().describe("File base64 encoding data or url")})}),z$1.object({type:z$1.literal("file"),url:z$1.string().describe("File path"),filename:z$1.string().describe("File name"),mime:z$1.string().optional().describe("File mime type")})]),Ne=z$1.object({name:z$1.string().describe("Command name"),description:z$1.string().describe("Command description"),agent:z$1.string().optional().describe("Specified agent name"),model:z$1.string().optional().describe("Specified model"),hints:z$1.array(z$1.string()).optional().describe("Argument hints"),commandType:z$1.enum(["prompt","local"]).optional().describe("Command type"),hidden:z$1.boolean().optional().describe("Whether hidden")}),Ze=z$1.object({sessionID:z$1.string().describe("Session ID"),directory:z$1.string().describe("Working directory"),model:z$1.string().optional().describe("Model identifier"),agent:z$1.string().optional().describe("Agent name"),arguments:be.describe("Command arguments")}),Se=z$1.record(z$1.string(),z$1.unknown()).describe("Result metadata"),Ve=z$1.object({title:z$1.string().describe("Result title"),metadata:Se.describe("Result metadata"),output:z$1.string().describe("Result output"),parts:z$1.array(Ie).optional().describe("Result parts"),success:z$1.boolean().describe("Whether execution succeeded"),error:z$1.string().optional().describe("Error message if failed")}),$e=z$1.object({agent:z$1.object({name:z$1.string().describe("Agent name"),model:z$1.string().optional().describe("Agent model")}).optional().describe("Agent context")}),Ke=z$1.object({isEnabled:z$1.boolean().optional().describe("Is enabled check result")});export{H as AgentExecutorSchema,u as AgentSchema,c as CallIDSchema,Q as CommandAfterInputSchema,be as CommandArgumentsSchema,J as CommandBeforeInputSchema,Se as CommandExecuteResultMetadataSchema,Ve as CommandExecuteResultSchema,Ze as CommandExecutionContextSchema,T as CommandExecutorSchema,$e as CommandInitContextSchema,Ke as CommandInitResultSchema,Ne as CommandMetadataSchema,Ie as CommandPromptPartSchema,Ue as CommandSourceSchema,S as ContentPartSchema,pe as ContextBuildAfterInputSchema,ae as ContextBuildBeforeInputSchema,I as CwdSchema,M as EndReasonSchema,y as EventInputSchemas,j as FinishReasonSchema,D as FunctionExecutorSchema,ce as GatewayMessageCompleteInputSchema,me as GatewayMessageProcessInputSchema,ue as GatewayMessageReceiveInputSchema,le as GatewayMessageSendInputSchema,He as HOOK_EVENTS,ge as HeartbeatCompleteInputSchema,de as HeartbeatTriggerInputSchema,o as HookEvent,E as HookExecutorSchema,w as HookMatcherSchema,p as HookType,je as HooksConfigSchema,P as HttpExecutorSchema,re as LlmHeadersInputSchema,ne as LlmParamsInputSchema,oe as LlmParamsSchema,x as LlmProviderSchema,r as MessageIDSchema,_ as MessageReceiveInputSchema,L as MessageRoleSchema,h as MessageSchema,q as MessageTransformInputSchema,b as ModelObjectSchema,l as ModelSchema,ee as PermissionAskInputSchema,te as PermissionDeniedInputSchema,X as PermissionLevelSchema,Y as PermissionRequestSchema,v as PromptExecutorSchema,ye as ScheduledTaskCompleteInputSchema,fe as ScheduledTaskTriggerInputSchema,F as SessionCompactInputSchema,R as SessionCompactingInputSchema,z as SessionEndInputSchema,n as SessionIDSchema,A as SessionStartInputSchema,se as ShellEnvInputSchema,W as StepFinishInputSchema,O as StepStartInputSchema,G as StepStopFailureInputSchema,B as StepStopInputSchema,U as SystemTransformInputSchema,ie as TextCompleteInputSchema,V as ToolAfterInputSchema,g as ToolArgsSchema,Z as ToolBeforeInputSchema,K as ToolDefinitionInputSchema,$ as ToolFailureInputSchema,N as ToolResultSchema,Ae as getEventInputSchema,Re as safeValidateHookInput,C as tool,ze as validateHookInput};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@easbot/plugin",
3
- "version": "0.1.11",
3
+ "version": "0.1.14",
4
4
  "description": "EASBot Plugin for client applications",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -19,23 +19,6 @@
19
19
  },
20
20
  "./package.json": "./package.json"
21
21
  },
22
- "scripts": {
23
- "dev": "tsup --watch --env.NODE_ENV development",
24
- "build": "tsup --env.NODE_ENV production",
25
- "test": "vitest",
26
- "test:run": "vitest run",
27
- "lint": "biome check .",
28
- "lint:fix": "biome check --write .",
29
- "lint:report": "biome check --reporter=summary .",
30
- "format": "biome format .",
31
- "format:fix": "biome format --write .",
32
- "type-check": "tsc --noEmit",
33
- "clean": "npx rimraf dist node_modules",
34
- "prepare": "echo norun",
35
- "prepublishOnly": "pnpm build",
36
- "publish:npm": "bash script/publish.sh",
37
- "publish:npm:win": "powershell -ExecutionPolicy Bypass -File script/publish.ps1"
38
- },
39
22
  "keywords": [
40
23
  "easbot",
41
24
  "plugin",
@@ -61,8 +44,8 @@
61
44
  ],
62
45
  "dependencies": {
63
46
  "zod": "^4.3.6",
64
- "@easbot/sdk": "workspace:*",
65
- "@easbot/types": "workspace:*"
47
+ "@easbot/sdk": "0.1.14",
48
+ "@easbot/types": "0.1.14"
66
49
  },
67
50
  "devDependencies": {
68
51
  "@types/node": "^22.17.0",
@@ -76,5 +59,20 @@
76
59
  },
77
60
  "publishConfig": {
78
61
  "access": "public"
62
+ },
63
+ "scripts": {
64
+ "dev": "tsup --watch --env.NODE_ENV development",
65
+ "build": "tsup --env.NODE_ENV production",
66
+ "test": "vitest",
67
+ "test:run": "vitest run",
68
+ "lint": "biome check .",
69
+ "lint:fix": "biome check --write .",
70
+ "lint:report": "biome check --reporter=summary .",
71
+ "format": "biome format .",
72
+ "format:fix": "biome format --write .",
73
+ "type-check": "tsc --noEmit",
74
+ "clean": "npx rimraf dist node_modules",
75
+ "publish:npm": "bash scripts/publish.sh",
76
+ "publish:npm:win": "powershell -ExecutionPolicy Bypass -File scripts/publish.ps1"
79
77
  }
80
- }
78
+ }