@easbot/plugin 0.3.27 → 0.3.29
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 +20 -21
- package/README.md +19 -20
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +207 -337
- package/dist/index.d.ts +207 -337
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
package/README.en.md
CHANGED
|
@@ -6,8 +6,7 @@ EASBot Plugin System - Hooks, Commands, and Tool Management
|
|
|
6
6
|
|
|
7
7
|
## Version
|
|
8
8
|
|
|
9
|
-
v0.3.
|
|
10
|
-
|
|
9
|
+
v0.3.29
|
|
11
10
|
## Features
|
|
12
11
|
|
|
13
12
|
- **Hook System**: Event-driven hook mechanism for extending Agent behavior
|
|
@@ -51,7 +50,7 @@ commands.register({
|
|
|
51
50
|
description: 'Say hello',
|
|
52
51
|
execute: async (args, session) => {
|
|
53
52
|
await session.send('Hello!');
|
|
54
|
-
}
|
|
53
|
+
},
|
|
55
54
|
});
|
|
56
55
|
```
|
|
57
56
|
|
|
@@ -64,11 +63,11 @@ const tool = createTool({
|
|
|
64
63
|
name: 'my-tool',
|
|
65
64
|
description: 'A custom tool',
|
|
66
65
|
parameters: z.object({
|
|
67
|
-
input: z.string()
|
|
66
|
+
input: z.string(),
|
|
68
67
|
}),
|
|
69
68
|
execute: async ({ input }) => {
|
|
70
69
|
return { result: input.toUpperCase() };
|
|
71
|
-
}
|
|
70
|
+
},
|
|
72
71
|
});
|
|
73
72
|
```
|
|
74
73
|
|
|
@@ -76,28 +75,28 @@ const tool = createTool({
|
|
|
76
75
|
|
|
77
76
|
### HookRegistry
|
|
78
77
|
|
|
79
|
-
| Method
|
|
80
|
-
|
|
81
|
-
| `register(event, handler)`
|
|
82
|
-
| `unregister(event, handler)` | Remove a hook handler
|
|
83
|
-
| `clear(event)`
|
|
78
|
+
| Method | Description |
|
|
79
|
+
| ---------------------------- | ------------------------------- |
|
|
80
|
+
| `register(event, handler)` | Register a hook handler |
|
|
81
|
+
| `unregister(event, handler)` | Remove a hook handler |
|
|
82
|
+
| `clear(event)` | Clear all handlers for an event |
|
|
84
83
|
|
|
85
84
|
### CommandRegistry
|
|
86
85
|
|
|
87
|
-
| Method
|
|
88
|
-
|
|
89
|
-
| `register(command)`
|
|
90
|
-
| `get(name)`
|
|
91
|
-
| `execute(name, args)` | Execute a command
|
|
86
|
+
| Method | Description |
|
|
87
|
+
| --------------------- | ------------------ |
|
|
88
|
+
| `register(command)` | Register a command |
|
|
89
|
+
| `get(name)` | Get a command |
|
|
90
|
+
| `execute(name, args)` | Execute a command |
|
|
92
91
|
|
|
93
92
|
### createTool
|
|
94
93
|
|
|
95
|
-
| Property
|
|
96
|
-
|
|
97
|
-
| name
|
|
98
|
-
| description | string
|
|
99
|
-
| parameters
|
|
100
|
-
| execute
|
|
94
|
+
| Property | Type | Description |
|
|
95
|
+
| ----------- | --------- | ------------------- |
|
|
96
|
+
| name | string | Tool name |
|
|
97
|
+
| description | string | Tool description |
|
|
98
|
+
| parameters | ZodSchema | Parameter schema |
|
|
99
|
+
| execute | function | Tool implementation |
|
|
101
100
|
|
|
102
101
|
## Development
|
|
103
102
|
|
package/README.md
CHANGED
|
@@ -6,8 +6,7 @@ EASBot 插件系统 - Hook、命令和工具管理
|
|
|
6
6
|
|
|
7
7
|
## 版本
|
|
8
8
|
|
|
9
|
-
v0.3.
|
|
10
|
-
|
|
9
|
+
v0.3.29
|
|
11
10
|
## 特性
|
|
12
11
|
|
|
13
12
|
- **Hook 系统**:事件驱动的 Hook 机制,扩展 Agent 行为
|
|
@@ -51,7 +50,7 @@ commands.register({
|
|
|
51
50
|
description: '打招呼',
|
|
52
51
|
execute: async (args, session) => {
|
|
53
52
|
await session.send('你好!');
|
|
54
|
-
}
|
|
53
|
+
},
|
|
55
54
|
});
|
|
56
55
|
```
|
|
57
56
|
|
|
@@ -64,11 +63,11 @@ const tool = createTool({
|
|
|
64
63
|
name: 'my-tool',
|
|
65
64
|
description: '自定义工具',
|
|
66
65
|
parameters: z.object({
|
|
67
|
-
input: z.string()
|
|
66
|
+
input: z.string(),
|
|
68
67
|
}),
|
|
69
68
|
execute: async ({ input }) => {
|
|
70
69
|
return { result: input.toUpperCase() };
|
|
71
|
-
}
|
|
70
|
+
},
|
|
72
71
|
});
|
|
73
72
|
```
|
|
74
73
|
|
|
@@ -76,28 +75,28 @@ const tool = createTool({
|
|
|
76
75
|
|
|
77
76
|
### HookRegistry
|
|
78
77
|
|
|
79
|
-
| 方法
|
|
80
|
-
|
|
81
|
-
| `register(event, handler)`
|
|
82
|
-
| `unregister(event, handler)` | 移除 Hook 处理器
|
|
83
|
-
| `clear(event)`
|
|
78
|
+
| 方法 | 说明 |
|
|
79
|
+
| ---------------------------- | -------------------- |
|
|
80
|
+
| `register(event, handler)` | 注册 Hook 处理器 |
|
|
81
|
+
| `unregister(event, handler)` | 移除 Hook 处理器 |
|
|
82
|
+
| `clear(event)` | 清除事件的所有处理器 |
|
|
84
83
|
|
|
85
84
|
### CommandRegistry
|
|
86
85
|
|
|
87
|
-
| 方法
|
|
88
|
-
|
|
89
|
-
| `register(command)`
|
|
90
|
-
| `get(name)`
|
|
86
|
+
| 方法 | 说明 |
|
|
87
|
+
| --------------------- | -------- |
|
|
88
|
+
| `register(command)` | 注册命令 |
|
|
89
|
+
| `get(name)` | 获取命令 |
|
|
91
90
|
| `execute(name, args)` | 执行命令 |
|
|
92
91
|
|
|
93
92
|
### createTool
|
|
94
93
|
|
|
95
|
-
| 属性
|
|
96
|
-
|
|
97
|
-
| name
|
|
98
|
-
| description | string
|
|
99
|
-
| parameters
|
|
100
|
-
| execute
|
|
94
|
+
| 属性 | 类型 | 说明 |
|
|
95
|
+
| ----------- | --------- | -------- |
|
|
96
|
+
| name | string | 工具名称 |
|
|
97
|
+
| description | string | 工具描述 |
|
|
98
|
+
| parameters | ZodSchema | 参数模式 |
|
|
99
|
+
| execute | function | 工具实现 |
|
|
101
100
|
|
|
102
101
|
## 开发
|
|
103
102
|
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var M=require('zod'),types=require('@easbot/types');require('@easbot/sdk');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var M__default=/*#__PURE__*/_interopDefault(M);function w(s){return {description:s.description,args:s.args,execute:s.execute}}w.schema=M__default.default;var c={Command:"command",Prompt:"prompt",Http:"http",Agent:"agent",Function:"function"},o={SessionStart:"session.start",SessionEnd:"session.end",SessionCompacting:"session.compacting",SessionCompact:"session.compact",StepStart:"step.start",StepFinish:"step.finish",StepStop:"step.stop",StepStopFailure:"step.stop.failure",MessageReceive:"message.receive",MessageTransform:"message.transform",SystemTransform:"system.transform",ToolBefore:"tool.before",ToolAfter:"tool.after",ToolFailure:"tool.failure",ToolDefinition:"tool.definition",CommandBefore:"command.before",CommandAfter:"command.after",PermissionAsk:"permission.ask",PermissionDenied:"permission.denied",LlmParams:"llm.params",LlmHeaders:"llm.headers",ShellEnv:"shell.env",TextComplete:"text.complete",GatewayMessageReceive:"gateway.message.receive",GatewayMessageProcess:"gateway.message.process",GatewayMessageComplete:"gateway.message.complete",GatewayMessageSend:"gateway.message.send",GatewayMessageDelivered:"gateway.message.delivered",GatewayMessageRead:"gateway.message.read",HeartbeatTrigger:"scheduler.heartbeat.trigger",HeartbeatComplete:"scheduler.heartbeat.complete",ScheduledTaskTrigger:"scheduler.task.trigger",ScheduledTaskComplete:"scheduler.task.complete",CommandTrigger:"scheduler.command.trigger",CommandComplete:"scheduler.command.complete",ContextBuildBefore:"context.build.before",ContextBuildAfter:"context.build.after",TaskStart:"task.start",TaskRunning:"task.running",TaskProgress:"task.progress",TaskComplete:"task.complete",LoopStart:"loop.start",LoopEnd:"loop.end",CreationRequest:"creation.request",CreationComplete:"creation.complete",EvolutionRequest:"evolution.request",EvolutionComplete:"evolution.complete"},Ye=Object.values(o);var S=M.z.string().optional(),H=M.z.object({type:M.z.literal(c.Command),command:M.z.string(),if:S,shell:M.z.enum(["bash","powershell"]).optional(),timeout:M.z.number().positive().optional(),statusMessage:M.z.string().optional(),once:M.z.boolean().optional(),async:M.z.boolean().optional()}),E=M.z.object({type:M.z.literal(c.Prompt),if:S,timeout:M.z.number().positive().optional(),model:M.z.string().optional(),statusMessage:M.z.string().optional(),once:M.z.boolean().optional(),runMode:M.z.enum(["session","fork"]).optional(),system:M.z.string().optional(),parts:M.z.array(M.z.unknown())}),A=M.z.object({type:M.z.literal(c.Http),url:M.z.string(),if:S,timeout:M.z.number().positive().optional(),method:M.z.enum(["GET","POST","PUT","DELETE"]).optional(),headers:M.z.record(M.z.string(),M.z.string()).optional(),allowedEnvVars:M.z.array(M.z.string()).optional(),statusMessage:M.z.string().optional(),once:M.z.boolean().optional()}),j=M.z.object({type:M.z.literal(c.Agent),if:S,timeout:M.z.number().positive().optional(),agent:M.z.string().optional(),model:M.z.string().optional(),statusMessage:M.z.string().optional(),once:M.z.boolean().optional(),system:M.z.string().optional(),parts:M.z.array(M.z.unknown())}),D=M.z.object({type:M.z.literal(c.Function),handler:M.z.function()}),R=M.z.discriminatedUnion("type",[H,E,A,j,D]),z=M.z.object({event:M.z.string(),matcher:M.z.string().optional(),hooks:M.z.array(R)}),rt=M.z.record(M.z.string(),M.z.array(z)),n=M.z.string().min(1).describe("Session unique identifier"),a=M.z.string().min(1).describe("Message unique identifier"),f=M.z.string().min(1).describe("Tool call unique identifier"),u=M.z.string().optional().describe("Agent name"),b=M.z.string().optional().describe("Model identifier"),k=M.z.object({providerId:M.z.string().describe("Provider ID"),modelId:M.z.string().describe("Model ID"),api:M.z.object({id:M.z.string().describe("API ID"),npm:M.z.string().optional().describe("NPM package name")}).optional().describe("API information")}).optional().describe("Model object"),C=M.z.string().optional().describe("Working directory path"),F=M.z.enum(["user_request","max_tokens","stop","error","timeout","cancelled"]).describe("Session end reason"),O=M.z.enum(["stop","max_tokens","end_turn","stop_sequence"]).describe("Step finish reason"),G=M.z.object({sessionId:n,source:M.z.enum(["user","agent","system","scheduled"]).optional().describe("Session source"),model:b,agent:u,cwd:C}),W=M.z.object({sessionId:n,reason:F,duration:M.z.number().positive().optional().describe("Session duration in milliseconds")}),B=M.z.object({sessionId:n,trigger:M.z.enum(["manual","auto","threshold"]).describe("Compaction trigger"),contextLength:M.z.number().positive().describe("Current context length"),threshold:M.z.number().positive().describe("Trigger threshold")}),L=M.z.object({sessionId:n,summary:M.z.string().describe("Compaction summary"),previousLength:M.z.number().positive().describe("Previous context length"),newLength:M.z.number().positive().describe("New context length")}),q=M.z.object({sessionId:n,messageId:a,userMessageId:a.optional().describe("User message ID for the current step"),model:b,agent:u}),_=M.z.object({sessionId:n,messageId:a,userMessageId:a.optional().describe("User message ID for the current step"),model:b,agent:u,finishReason:O,tokens:M.z.object({input:M.z.number().int().nonnegative().optional(),output:M.z.number().int().nonnegative().optional(),total:M.z.number().int().nonnegative().optional()}).optional().describe("Token usage statistics")}),U=M.z.object({sessionId:n,reason:M.z.string().describe("Stop reason")}),N=M.z.object({sessionId:n,error:M.z.string().describe("Error message"),errorType:M.z.enum(["rate_limit","auth_error","network_error","timeout","invalid_request","server_error"]).describe("Error type")}),$=M.z.enum(["user","assistant","system","tool"]),T=M.z.discriminatedUnion("type",[M.z.object({type:M.z.literal("text"),text:M.z.string().describe("Text content")}),M.z.object({type:M.z.literal("image"),source:M.z.object({type:M.z.enum(["base64","url"]),mime:M.z.string().optional().describe("File mime type"),data:M.z.string().describe("File base64 encoding data or url")})}),M.z.object({type:M.z.literal("file"),url:M.z.string().describe("File path"),filename:M.z.string().describe("File name"),mime:M.z.string().optional().describe("File mime type")})]),v=M.z.object({id:a,role:$,content:M.z.union([M.z.string(),M.z.array(T)]),name:M.z.string().optional().describe("Message sender name"),tool_call_id:f.optional().describe("Related tool call ID")}),Z=M.z.object({sessionId:n,agent:u,model:b,messageId:a,message:M.z.object({id:a,role:M.z.literal("user"),content:M.z.union([M.z.string(),M.z.array(T)])}).describe("User message")}),V=M.z.object({sessionId:n,messages:M.z.array(v).describe("Messages to transform")}),K=M.z.object({sessionId:n,model:b,system:M.z.array(M.z.string()).describe("Current system prompt")}),I=M.z.record(M.z.string(),M.z.unknown()).describe("Tool call arguments"),J=M.z.object({title:M.z.string().optional().describe("Result title"),content:M.z.string().describe("Result content"),is_error:M.z.boolean().optional().describe("Is error result"),metadata:M.z.record(M.z.string(),M.z.unknown()).optional().describe("Extra metadata")}),Q=M.z.object({sessionId:n,userMessageId:a.optional().describe("User message ID for the current step"),tool:M.z.string().describe("Tool name"),callId:f,args:I}),X=M.z.object({sessionId:n,userMessageId:a.optional().describe("User message ID for the current step"),tool:M.z.string(),callId:f,args:I,result:J,duration:M.z.number().nonnegative().optional().describe("Execution duration in milliseconds")}),Y=M.z.object({sessionId:n,tool:M.z.string(),callId:f,args:I,error:M.z.string().describe("Error message"),errorType:M.z.enum(["timeout","invalid_args","execution_error","permission_denied"])}),ee=M.z.object({sessionId:n,toolID:M.z.string().describe("Tool ID"),definition:M.z.object({name:M.z.string(),description:M.z.string().optional(),parameters:M.z.record(M.z.string(),M.z.unknown()).optional()}).describe("Tool definition")}),te=M.z.object({sessionId:n,command:M.z.string().describe("Command name"),arguments:M.z.union([M.z.string(),M.z.record(M.z.string(),M.z.unknown())]).describe("Command arguments")}),oe=M.z.object({sessionId:n,command:M.z.string().describe("Command name"),arguments:M.z.union([M.z.string(),M.z.record(M.z.string(),M.z.unknown())]).optional(),result:M.z.object({info:M.z.unknown().optional().describe("Message info"),parts:M.z.array(M.z.unknown()).optional().describe("Message parts"),title:M.z.string().optional().describe("Result title"),metadata:M.z.record(M.z.string(),M.z.unknown()).optional().describe("Result metadata"),output:M.z.string().optional().describe("Result output"),success:M.z.boolean().optional().describe("Whether execution succeeded"),error:M.z.string().optional().describe("Error message if failed")}).describe("Command execution result")}),ne=M.z.enum(["read","write","exec","admin"]),re=M.z.object({tool:M.z.string().describe("Tool name requesting permission"),args:I.optional(),level:ne.optional(),reason:M.z.string().optional().describe("Reason for permission request")}),se=M.z.object({sessionId:n,request:re}),ie=M.z.object({sessionId:n,tool:M.z.string(),reason:M.z.string().optional()}),P=M.z.enum(["openai","anthropic","google","azure","custom"]),ae=M.z.object({temperature:M.z.number().min(0).max(2).optional(),topP:M.z.number().min(0).max(1).optional(),topK:M.z.number().int().positive().optional(),maxTokens:M.z.number().int().positive().optional(),stopSequences:M.z.array(M.z.string()).optional(),responseFormat:M.z.enum(["text","json_object"]).optional()}),pe=M.z.object({sessionId:n,agent:u,model:k,provider:P,params:ae.partial().optional()}),me=M.z.object({sessionId:n,agent:u,model:k,provider:P,headers:M.z.record(M.z.string(),M.z.string()).optional()}),ce=M.z.object({cwd:C.describe("Working directory"),sessionId:n.optional(),callId:f.optional()}),ue=M.z.object({sessionId:n,messageId:a,partId:M.z.string().describe("Text part ID"),text:M.z.string().describe("Completed text")}),le=M.z.object({sessionId:n,mode:M.z.enum(["agent","chat","query"]).describe("Build mode"),providerId:M.z.string().optional()}),de=M.z.object({sessionId:n,context:M.z.object({messages:M.z.array(v),system:M.z.array(M.z.string()),metadata:M.z.record(M.z.string(),M.z.unknown())}).describe("Built context")}),ge=M.z.object({gatewayID:M.z.string().describe("Gateway ID"),messageId:a,message:M.z.unknown().describe("Received message")}),fe=M.z.object({gatewayID:M.z.string(),messageId:a,message:M.z.unknown(),sessionId:n.optional()}),be=M.z.object({gatewayID:M.z.string(),messageId:a,result:M.z.unknown().optional()}),ye=M.z.object({gatewayID:M.z.string(),messageId:a,message:M.z.unknown(),target:M.z.string().optional().describe("Send target")}),Se=M.z.object({gatewayID:M.z.string(),messageId:a,sessionId:n.optional(),channel:M.z.object({platform:M.z.string(),channelId:M.z.string()}),timestamp:M.z.number().describe("Delivery timestamp")}),Ie=M.z.object({gatewayID:M.z.string(),messageId:a,sessionId:n.optional(),channel:M.z.object({platform:M.z.string(),channelId:M.z.string()}),timestamp:M.z.number().describe("Read timestamp")}),he=M.z.object({type:M.z.literal("command"),config:M.z.object({command:M.z.string(),arguments:M.z.union([M.z.string(),M.z.record(M.z.string(),M.z.unknown())]).optional()})}),xe=M.z.object({type:M.z.literal("heartbeat"),parts:M.z.array(M.z.unknown()),system:M.z.string().optional(),config:M.z.object({session:M.z.string().optional(),mode:M.z.enum(["session","fork"]).optional(),agent:M.z.string().optional(),model:M.z.string().optional(),tools:M.z.record(M.z.string(),M.z.boolean()).optional()}).optional()}),ke=M.z.object({type:M.z.literal("scheduler"),parts:M.z.array(M.z.unknown()),system:M.z.string().optional(),config:M.z.object({agentType:M.z.string().optional(),transport:M.z.enum(["stdio","http","websocket","cli"]).optional(),model:M.z.string().optional(),tools:M.z.record(M.z.string(),M.z.boolean()).optional()}).optional()}),Ce=M.z.object({taskId:M.z.string().describe("Heartbeat task ID"),timestamp:M.z.number().describe("Heartbeat timestamp"),name:M.z.string().optional().describe("Heartbeat name"),definition:xe.optional()}),Te=M.z.object({taskId:M.z.string().describe("Heartbeat task ID"),sessionId:n.optional(),timestamp:M.z.number(),duration:M.z.number().nonnegative().optional(),success:M.z.boolean().optional(),error:M.z.string().optional()}),ve=M.z.object({taskId:M.z.string().describe("Task ID"),taskName:M.z.string().optional(),timestamp:M.z.number(),payload:M.z.record(M.z.string(),M.z.unknown()).optional(),definition:ke.optional()}),Pe=M.z.object({taskId:M.z.string(),timestamp:M.z.number(),success:M.z.boolean(),result:M.z.record(M.z.string(),M.z.unknown()).optional(),error:M.z.string().optional()}),Me=M.z.object({taskId:M.z.string().describe("Command task unique identifier"),taskName:M.z.string().describe("Command task name"),command:M.z.string().describe("Command name"),arguments:M.z.union([M.z.string(),M.z.record(M.z.string(),M.z.unknown())]).optional().describe("Command arguments"),timestamp:M.z.number().describe("Trigger timestamp"),definition:he.optional()}),we=M.z.object({taskId:M.z.string(),timestamp:M.z.number(),success:M.z.boolean(),output:M.z.string().optional(),error:M.z.string().optional(),duration:M.z.number().describe("Execution duration in milliseconds")}),h=M.z.enum(["tool","scheduler","cli","api"]),He=M.z.object({taskId:M.z.string().describe("Task unique identifier"),sessionId:M.z.string().describe("Session ID for this task"),source:h.describe("Task source: tool, scheduler, cli, api"),agentType:M.z.string().describe("Agent type to execute this task"),description:M.z.string().describe("Task description"),prompt:M.z.string().describe("Task prompt content"),timeout:M.z.number().positive().optional().describe("Task timeout in milliseconds")}),Ee=M.z.object({taskId:M.z.string().describe("Task unique identifier"),sessionId:M.z.string().describe("Session ID for this task"),source:h.describe("Task source: tool, scheduler, cli, api")}),Ae=M.z.object({taskId:M.z.string(),sessionId:M.z.string(),source:h,step:M.z.number().describe("Current step number"),totalSteps:M.z.number().optional().describe("Total number of steps"),output:M.z.string().describe("Progress output content"),timestamp:M.z.number().describe("Progress timestamp")}),je=M.z.object({taskId:M.z.string(),sessionId:M.z.string(),source:h,result:M.z.string().describe("Task result content"),duration:M.z.number().nonnegative().describe("Task duration in milliseconds"),attachments:M.z.array(M.z.unknown()).optional().describe("Task result attachments"),error:M.z.string().optional().describe("Error message if task failed"),agentType:M.z.string().optional().describe("Agent type that executed the task"),metadata:M.z.record(M.z.string(),M.z.unknown()).optional().describe("Additional metadata for the task result")}),De=M.z.object({sessionId:M.z.string().describe("Session ID"),step:M.z.number().describe("Current step number"),lastUserId:M.z.string().describe("Last user message ID"),result:M.z.enum(["start","continue","stop"]).optional().describe("Loop result: start, continue, or stop")}),Re=M.z.object({sessionId:M.z.string().describe("Session ID"),step:M.z.number().describe("Current step number"),lastUserId:M.z.string().describe("Last user message ID"),result:M.z.enum(["stop","continue"]).describe("Loop result: stop or continue")}),ze=M.z.object({requestId:M.z.string(),kind:M.z.enum(["create-skill","create-workflow","create-bundle"]),requirement:M.z.string(),hints:M.z.array(M.z.string()),origin:M.z.object({source:M.z.enum(["human","tool","scheduler","namespace"]).optional(),timestamp:M.z.number().int().nonnegative()})}),Fe=M.z.object({requestId:M.z.string(),status:M.z.enum(["success","failed"]),specId:M.z.string().optional(),durationMs:M.z.number().int().nonnegative(),error:M.z.string().optional()}),Oe=M.z.object({dryRun:M.z.boolean()}),Ge=M.z.object({status:M.z.enum(["success","failed","awaiting-approval"]),applied:M.z.number().int().nonnegative().optional(),awaitingApproval:M.z.number().int().nonnegative().optional(),error:M.z.string().optional()}),x={[o.SessionStart]:G,[o.SessionEnd]:W,[o.SessionCompacting]:B,[o.SessionCompact]:L,[o.StepStart]:q,[o.StepFinish]:_,[o.StepStop]:U,[o.StepStopFailure]:N,[o.MessageReceive]:Z,[o.MessageTransform]:V,[o.SystemTransform]:K,[o.ToolBefore]:Q,[o.ToolAfter]:X,[o.ToolFailure]:Y,[o.ToolDefinition]:ee,[o.CommandBefore]:te,[o.CommandAfter]:oe,[o.PermissionAsk]:se,[o.PermissionDenied]:ie,[o.LlmParams]:pe,[o.LlmHeaders]:me,[o.ShellEnv]:ce,[o.TextComplete]:ue,[o.ContextBuildBefore]:le,[o.ContextBuildAfter]:de,[o.GatewayMessageReceive]:ge,[o.GatewayMessageProcess]:fe,[o.GatewayMessageComplete]:be,[o.GatewayMessageSend]:ye,[o.GatewayMessageDelivered]:Se,[o.GatewayMessageRead]:Ie,[o.HeartbeatTrigger]:Ce,[o.HeartbeatComplete]:Te,[o.ScheduledTaskTrigger]:ve,[o.ScheduledTaskComplete]:Pe,[o.CommandTrigger]:Me,[o.CommandComplete]:we,[o.TaskStart]:He,[o.TaskRunning]:Ee,[o.TaskProgress]:Ae,[o.TaskComplete]:je,[o.LoopStart]:De,[o.LoopEnd]:Re,[o.CreationRequest]:ze,[o.CreationComplete]:Fe,[o.EvolutionRequest]:Oe,[o.EvolutionComplete]:Ge};function st(s){return x[s]}function it(s,d){let g=x[s];if(!g)throw new Error(`No schema found for event: ${s}`);return g.parse(d)}function at(s,d){let g=x[s];return g?g.safeParse(d):{success:false,error:new M.z.ZodError([{code:"custom",path:[],message:`No schema found for event: ${s}`}])}}var bt=M.z.enum(["command","mcp","skill"]).describe("Command source"),We=M.z.union([M.z.string(),M.z.record(M.z.string(),M.z.unknown())]).describe("Command arguments"),Be=M.z.discriminatedUnion("type",[M.z.object({type:M.z.literal("text"),text:M.z.string().describe("Text content")}),M.z.object({type:M.z.literal("image"),source:M.z.object({type:M.z.enum(["base64","url"]),mime:M.z.string().describe("File mime type"),data:M.z.string().describe("File base64 encoding data or url")})}),M.z.object({type:M.z.literal("file"),url:M.z.string().describe("File path"),filename:M.z.string().describe("File name"),mime:M.z.string().optional().describe("File mime type")})]),yt=M.z.object({name:M.z.string().describe("Command name"),description:M.z.string().describe("Command description"),scope:M.z.enum(["general","coder","all"]).optional().describe("Context mode scope"),agent:M.z.string().optional().describe("Specified agent name"),model:M.z.string().optional().describe("Specified model"),hints:M.z.array(M.z.string()).optional().describe("Argument hints"),commandType:M.z.enum(["prompt","local"]).optional().describe("Command type"),hidden:M.z.boolean().optional().describe("Whether hidden")}),St=M.z.object({sessionId:M.z.string().describe("Session ID"),directory:M.z.string().describe("Working directory"),model:M.z.string().optional().describe("Model identifier"),agent:M.z.string().optional().describe("Agent name"),arguments:We.describe("Command arguments")}),Le=M.z.record(M.z.string(),M.z.unknown()).describe("Result metadata"),It=M.z.object({title:M.z.string().describe("Result title"),metadata:Le.describe("Result metadata"),output:M.z.string().describe("Result output"),parts:M.z.array(Be).optional().describe("Result parts"),success:M.z.boolean().describe("Whether execution succeeded"),error:M.z.string().optional().describe("Error message if failed")}),ht=M.z.object({agent:M.z.object({name:M.z.string().describe("Agent name"),model:M.z.string().optional().describe("Agent model")}).optional().describe("Agent context")}),xt=M.z.object({isEnabled:M.z.boolean().optional().describe("Is enabled check result")});var y=M.z.enum(["ask","allow","deny"]),i=M.z.union([y,M.z.record(M.z.string(),y)]),qe=M.z.object({read:i.optional(),edit:i.optional(),write:i.optional(),glob:i.optional(),grep:i.optional(),list:i.optional(),bash:i.optional(),webfetch:i.optional(),websearch:i.optional(),task:i.optional(),todo:y.optional(),question:y.optional(),skill:i.optional(),memory:i.optional(),note:i.optional(),pty_session:i.optional(),pty_manage:i.optional(),external_directory:i.optional(),doom_loop:y.optional()}).catchall(i),_e=M.z.enum(["subagent","primary","all"]),Ue=M.z.enum(["general","coder","all"]),Ne=M.z.object({providerId:M.z.string().min(1).describe("Model provider ID"),modelId:M.z.string().min(1).describe("Model ID")}),wt=M.z.object({name:M.z.string().min(1).describe("Unique agent name"),description:M.z.string().optional().describe("When to use this agent"),mode:_e.optional().describe("Agent mode"),hidden:M.z.boolean().optional().describe("Hide from @ autocomplete menu"),scope:Ue.optional().describe("Agent scope (general / coder / all)"),model:Ne.optional().describe("Default model"),variant:M.z.string().optional().describe("Default model variant"),temperature:M.z.number().min(0).max(2).optional().describe("Sampling temperature"),topP:M.z.number().min(0).max(1).optional().describe("Top-p sampling"),prompt:M.z.string().optional().describe("System prompt"),permission:qe.optional().describe("Tool permissions"),steps:M.z.number().int().positive().optional().describe("Maximum execution steps"),color:M.z.union([M.z.string().regex(/^#[0-9a-fA-F]{6}$/),M.z.enum(["primary","secondary","accent","success","warning","error","info"])]).optional().describe("UI color (hex code or theme name)"),options:M.z.record(M.z.string(),M.z.unknown()).optional().describe("Additional options")}).meta({ref:"PluginAgent"});var zt=M.z.object({name:M.z.string().min(1).describe("Unique skill name"),description:M.z.string().min(1).describe("When to use this skill"),scope:M.z.enum(["general","coder","all"]).optional().describe("Context mode scope")}),Ft=M.z.object({agent:M.z.object({name:M.z.string().describe("Agent name"),model:M.z.string().optional().describe("Agent model")}).optional().describe("Agent context")}),Ot=M.z.object({isEnabled:M.z.boolean().optional().describe("Is enabled check result")});var l=new Map;function Ut(s){if(l.has(s.id))throw new Error(`Marketplace with id "${s.id}" already registered`);l.set(s.id,s);}function Nt(s){return l.delete(s)}function $t(){return Array.from(l.values()).map(s=>s)}function Zt(s){return l.get(s)??null}function Vt(s){return Array.from(l.values()).filter(d=>d.category===s)}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=j;exports.AgentMetadataSchema=wt;exports.AgentModeSchema=_e;exports.AgentModelSchema=Ne;exports.AgentPermissionSchema=qe;exports.AgentSchema=u;exports.AgentScopeSchema=Ue;exports.CallIDSchema=f;exports.CommandAfterInputSchema=oe;exports.CommandArgumentsSchema=We;exports.CommandBeforeInputSchema=te;exports.CommandCompleteInputSchema=we;exports.CommandExecuteResultMetadataSchema=Le;exports.CommandExecuteResultSchema=It;exports.CommandExecutionContextSchema=St;exports.CommandExecutorSchema=H;exports.CommandInitContextSchema=ht;exports.CommandInitResultSchema=xt;exports.CommandMetadataSchema=yt;exports.CommandPromptPartSchema=Be;exports.CommandSourceSchema=bt;exports.CommandTaskDefinitionSchema=he;exports.CommandTriggerInputSchema=Me;exports.ContentPartSchema=T;exports.ContextBuildAfterInputSchema=de;exports.ContextBuildBeforeInputSchema=le;exports.CreationCompleteInputSchema=Fe;exports.CreationRequestInputSchema=ze;exports.CwdSchema=C;exports.EndReasonSchema=F;exports.EventInputSchemas=x;exports.EvolutionCompleteInputSchema=Ge;exports.EvolutionRequestInputSchema=Oe;exports.FinishReasonSchema=O;exports.FunctionExecutorSchema=D;exports.GatewayMessageCompleteInputSchema=be;exports.GatewayMessageDeliveredInputSchema=Se;exports.GatewayMessageProcessInputSchema=fe;exports.GatewayMessageReadInputSchema=Ie;exports.GatewayMessageReceiveInputSchema=ge;exports.GatewayMessageSendInputSchema=ye;exports.HOOK_EVENTS=Ye;exports.HeartbeatCompleteInputSchema=Te;exports.HeartbeatTaskDefinitionSchema=xe;exports.HeartbeatTriggerInputSchema=Ce;exports.HookEvent=o;exports.HookExecutorSchema=R;exports.HookMatcherSchema=z;exports.HookType=c;exports.HooksConfigSchema=rt;exports.HttpExecutorSchema=A;exports.LlmHeadersInputSchema=me;exports.LlmParamsInputSchema=pe;exports.LlmParamsSchema=ae;exports.LlmProviderSchema=P;exports.LoopEndInputSchema=Re;exports.LoopStartInputSchema=De;exports.MessageIDSchema=a;exports.MessageReceiveInputSchema=Z;exports.MessageRoleSchema=$;exports.MessageSchema=v;exports.MessageTransformInputSchema=V;exports.ModelObjectSchema=k;exports.ModelSchema=b;exports.PermissionActionSchema=y;exports.PermissionAskInputSchema=se;exports.PermissionDeniedInputSchema=ie;exports.PermissionLevelSchema=ne;exports.PermissionRequestSchema=re;exports.PermissionRuleSchema=i;exports.PromptExecutorSchema=E;exports.ScheduledTaskCompleteInputSchema=Pe;exports.ScheduledTaskTriggerInputSchema=ve;exports.SchedulerTaskDefinitionSchema=ke;exports.SessionCompactInputSchema=L;exports.SessionCompactingInputSchema=B;exports.SessionEndInputSchema=W;exports.SessionIDSchema=n;exports.SessionStartInputSchema=G;exports.ShellEnvInputSchema=ce;exports.SkillInitContextSchema=Ft;exports.SkillInitResultSchema=Ot;exports.SkillMetadataSchema=zt;exports.StepFinishInputSchema=_;exports.StepStartInputSchema=q;exports.StepStopFailureInputSchema=N;exports.StepStopInputSchema=U;exports.SystemTransformInputSchema=K;exports.TaskCompleteInputSchema=je;exports.TaskProgressInputSchema=Ae;exports.TaskRunningInputSchema=Ee;exports.TaskSourceSchema=h;exports.TaskStartInputSchema=He;exports.TextCompleteInputSchema=ue;exports.ToolAfterInputSchema=X;exports.ToolArgsSchema=I;exports.ToolBeforeInputSchema=Q;exports.ToolDefinitionInputSchema=ee;exports.ToolFailureInputSchema=Y;exports.ToolResultSchema=J;exports.findMarketplace=Zt;exports.findMarketplacesByCategory=Vt;exports.getEventInputSchema=st;exports.listMarketplaces=$t;exports.registerMarketplace=Ut;exports.safeValidateHookInput=at;exports.tool=w;exports.unregisterMarketplace=Nt;exports.validateHookInput=it;
|
|
1
|
+
'use strict';var H=require('zod'),types=require('@easbot/types');require('@easbot/sdk');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var H__default=/*#__PURE__*/_interopDefault(H);function M(r){return {description:r.description,args:r.args,execute:r.execute}}M.schema=H__default.default;var c={Command:"command",Prompt:"prompt",Http:"http",Agent:"agent",Function:"function"},o={SessionStart:"session.start",SessionEnd:"session.end",SessionCompacting:"session.compacting",SessionCompact:"session.compact",StepStart:"step.start",StepFinish:"step.finish",StepStop:"step.stop",StepStopFailure:"step.stop.failure",MessageReceive:"message.receive",MessageTransform:"message.transform",SystemTransform:"system.transform",ToolBefore:"tool.before",ToolAfter:"tool.after",ToolFailure:"tool.failure",ToolDefinition:"tool.definition",CommandBefore:"command.before",CommandAfter:"command.after",PermissionAsk:"permission.ask",PermissionDenied:"permission.denied",LlmParams:"llm.params",LlmHeaders:"llm.headers",ShellEnv:"shell.env",TextComplete:"text.complete",GatewayMessageReceive:"gateway.message.receive",GatewayMessageProcess:"gateway.message.process",GatewayMessageComplete:"gateway.message.complete",GatewayMessageSend:"gateway.message.send",GatewayMessageDelivered:"gateway.message.delivered",GatewayMessageRead:"gateway.message.read",HeartbeatTrigger:"scheduler.heartbeat.trigger",HeartbeatComplete:"scheduler.heartbeat.complete",ScheduledTaskTrigger:"scheduler.task.trigger",ScheduledTaskComplete:"scheduler.task.complete",CommandTrigger:"scheduler.command.trigger",CommandComplete:"scheduler.command.complete",ContextBuildBefore:"context.build.before",ContextBuildAfter:"context.build.after",TaskStart:"task.start",TaskRunning:"task.running",TaskProgress:"task.progress",TaskComplete:"task.complete",LoopStart:"loop.start",LoopEnd:"loop.end",CreationRequest:"creation.request",CreationComplete:"creation.complete",EvolutionRequest:"evolution.request",EvolutionComplete:"evolution.complete"},Xe=Object.values(o);var b=H.z.string().optional(),P=H.z.object({type:H.z.literal(c.Command),command:H.z.string(),if:b,shell:H.z.enum(["bash","powershell"]).optional(),timeout:H.z.number().positive().optional(),statusMessage:H.z.string().optional(),once:H.z.boolean().optional(),async:H.z.boolean().optional()}),w=H.z.object({type:H.z.literal(c.Prompt),if:b,timeout:H.z.number().positive().optional(),model:H.z.string().optional(),statusMessage:H.z.string().optional(),once:H.z.boolean().optional(),runMode:H.z.enum(["session","fork"]).optional(),system:H.z.string().optional(),parts:H.z.array(H.z.unknown()),onMessage:H.z.custom(r=>typeof r=="function").optional()}),E=H.z.object({type:H.z.literal(c.Http),url:H.z.string(),if:b,timeout:H.z.number().positive().optional(),method:H.z.enum(["GET","POST","PUT","DELETE"]).optional(),headers:H.z.record(H.z.string(),H.z.string()).optional(),allowedEnvVars:H.z.array(H.z.string()).optional(),statusMessage:H.z.string().optional(),once:H.z.boolean().optional()}),D=H.z.object({type:H.z.literal(c.Agent),if:b,timeout:H.z.number().positive().optional(),agent:H.z.string().optional(),model:H.z.string().optional(),statusMessage:H.z.string().optional(),once:H.z.boolean().optional(),system:H.z.string().optional(),parts:H.z.array(H.z.unknown()),onMessage:H.z.custom(r=>typeof r=="function").optional()}),A=H.z.object({type:H.z.literal(c.Function),handler:H.z.function()}),j=H.z.discriminatedUnion("type",[P,w,E,D,A]),R=H.z.object({event:H.z.string(),matcher:H.z.string().optional(),hooks:H.z.array(j)}),nt=H.z.record(H.z.string(),H.z.array(R)),n=H.z.string().min(1).describe("Session unique identifier"),x=H.z.string().min(1).describe("Part unique identifier"),i=H.z.string().min(1).describe("Message unique identifier"),g=H.z.string().min(1).describe("Tool call unique identifier"),m=H.z.string().optional().describe("Agent name"),f=H.z.string().optional().describe("Model identifier"),h=H.z.object({providerId:H.z.string().describe("Provider ID"),modelId:H.z.string().describe("Model ID"),api:H.z.object({id:H.z.string().describe("API ID"),npm:H.z.string().optional().describe("NPM package name")}).optional().describe("API information")}).optional().describe("Model object"),k=H.z.string().optional().describe("Working directory path"),z=H.z.enum(["user_request","max_tokens","stop","error","timeout","cancelled"]).describe("Session end reason"),O=H.z.enum(["stop","max_tokens","end_turn","stop_sequence"]).describe("Step finish reason"),F=H.z.object({sessionId:n,source:H.z.enum(["user","agent","system","scheduled"]).optional().describe("Session source"),model:f,agent:m,cwd:k}),W=H.z.object({sessionId:n,reason:z,duration:H.z.number().positive().optional().describe("Session duration in milliseconds")}),G=H.z.object({sessionId:n,trigger:H.z.enum(["manual","auto","threshold"]).describe("Compaction trigger"),contextLength:H.z.number().positive().describe("Current context length"),threshold:H.z.number().positive().describe("Trigger threshold")}),B=H.z.object({sessionId:n,summary:H.z.string().describe("Compaction summary"),previousLength:H.z.number().positive().describe("Previous context length"),newLength:H.z.number().positive().describe("New context length")}),L=H.z.object({sessionId:n,messageId:i,partId:x.optional().describe("step-start part ID (created by processor before hook trigger)"),userMessageId:i.optional().describe("User message ID for the current step"),model:f,agent:m}),q=H.z.object({sessionId:n,messageId:i,partId:x.optional().describe("step-finish part ID (created by processor before hook trigger)"),userMessageId:i.optional().describe("User message ID for the current step"),model:f,agent:m,finishReason:O,tokens:H.z.object({input:H.z.number().int().nonnegative().optional(),output:H.z.number().int().nonnegative().optional(),total:H.z.number().int().nonnegative().optional()}).optional().describe("Token usage statistics")}),_=H.z.object({sessionId:n,reason:H.z.string().describe("Stop reason")}),U=H.z.object({sessionId:n,error:H.z.string().describe("Error message"),errorType:H.z.enum(["rate_limit","auth_error","network_error","timeout","invalid_request","server_error"]).describe("Error type")}),N=H.z.enum(["user","assistant","system","tool"]),C=H.z.discriminatedUnion("type",[H.z.object({type:H.z.literal("text"),text:H.z.string().describe("Text content")}),H.z.object({type:H.z.literal("image"),source:H.z.object({type:H.z.enum(["base64","url"]),mime:H.z.string().optional().describe("File mime type"),data:H.z.string().describe("File base64 encoding data or url")})}),H.z.object({type:H.z.literal("file"),url:H.z.string().describe("File path"),filename:H.z.string().describe("File name"),mime:H.z.string().optional().describe("File mime type")})]),T=H.z.object({id:i,role:N,content:H.z.union([H.z.string(),H.z.array(C)]),name:H.z.string().optional().describe("Message sender name"),tool_call_id:g.optional().describe("Related tool call ID")}),$=H.z.object({sessionId:n,agent:m,model:f,messageId:i,message:H.z.object({id:i,role:H.z.literal("user"),content:H.z.union([H.z.string(),H.z.array(C)])}).describe("User message")}),Z=H.z.object({sessionId:n,messages:H.z.array(T).describe("Messages to transform")}),V=H.z.object({sessionId:n,model:f,system:H.z.array(H.z.string()).describe("Current system prompt")}),y=H.z.record(H.z.string(),H.z.unknown()).describe("Tool call arguments"),K=H.z.object({title:H.z.string().optional().describe("Result title"),content:H.z.string().describe("Result content"),is_error:H.z.boolean().optional().describe("Is error result"),metadata:H.z.record(H.z.string(),H.z.unknown()).optional().describe("Extra metadata")}),J=H.z.object({sessionId:n,userMessageId:i.optional().describe("User message ID for the current step"),tool:H.z.string().describe("Tool name"),callId:g,args:y}),Q=H.z.object({sessionId:n,userMessageId:i.optional().describe("User message ID for the current step"),tool:H.z.string(),callId:g,args:y,result:K,duration:H.z.number().nonnegative().optional().describe("Execution duration in milliseconds")}),X=H.z.object({sessionId:n,tool:H.z.string(),callId:g,args:y,error:H.z.string().describe("Error message"),errorType:H.z.enum(["timeout","invalid_args","execution_error","permission_denied"])}),Y=H.z.object({sessionId:n,toolID:H.z.string().describe("Tool ID"),definition:H.z.object({name:H.z.string(),description:H.z.string().optional(),parameters:H.z.record(H.z.string(),H.z.unknown()).optional()}).describe("Tool definition")}),ee=H.z.object({sessionId:n,command:H.z.string().describe("Command name"),arguments:H.z.union([H.z.string(),H.z.record(H.z.string(),H.z.unknown())]).describe("Command arguments")}),te=H.z.object({sessionId:n,command:H.z.string().describe("Command name"),arguments:H.z.union([H.z.string(),H.z.record(H.z.string(),H.z.unknown())]).optional(),result:H.z.object({info:H.z.unknown().optional().describe("Message info"),parts:H.z.array(H.z.unknown()).optional().describe("Message parts"),title:H.z.string().optional().describe("Result title"),metadata:H.z.record(H.z.string(),H.z.unknown()).optional().describe("Result metadata"),output:H.z.string().optional().describe("Result output"),success:H.z.boolean().optional().describe("Whether execution succeeded"),error:H.z.string().optional().describe("Error message if failed")}).describe("Command execution result")}),oe=H.z.enum(["read","write","exec","admin"]),ne=H.z.object({tool:H.z.string().describe("Tool name requesting permission"),args:y.optional(),level:oe.optional(),reason:H.z.string().optional().describe("Reason for permission request")}),re=H.z.object({sessionId:n,request:ne}),se=H.z.object({sessionId:n,tool:H.z.string(),reason:H.z.string().optional()}),v=H.z.enum(["openai","anthropic","google","azure","custom"]),ie=H.z.object({temperature:H.z.number().min(0).max(2).optional(),topP:H.z.number().min(0).max(1).optional(),topK:H.z.number().int().positive().optional(),maxTokens:H.z.number().int().positive().optional(),stopSequences:H.z.array(H.z.string()).optional(),responseFormat:H.z.enum(["text","json_object"]).optional()}),ae=H.z.object({sessionId:n,agent:m,model:h,provider:v,params:ie.partial().optional()}),pe=H.z.object({sessionId:n,agent:m,model:h,provider:v,headers:H.z.record(H.z.string(),H.z.string()).optional()}),ce=H.z.object({cwd:k.describe("Working directory"),sessionId:n.optional(),callId:g.optional()}),me=H.z.object({sessionId:n,messageId:i,partId:H.z.string().describe("Text part ID"),text:H.z.string().describe("Completed text")}),ue=H.z.object({sessionId:n,mode:H.z.enum(["agent","chat","query"]).describe("Build mode"),providerId:H.z.string().optional()}),le=H.z.object({sessionId:n,context:H.z.object({messages:H.z.array(T),system:H.z.array(H.z.string()),metadata:H.z.record(H.z.string(),H.z.unknown())}).describe("Built context")}),de=H.z.object({gatewayID:H.z.string().describe("Gateway ID"),messageId:i,message:H.z.unknown().describe("Received message")}),ge=H.z.object({gatewayID:H.z.string(),messageId:i,message:H.z.unknown(),sessionId:n.optional()}),fe=H.z.object({gatewayID:H.z.string(),messageId:i,result:H.z.unknown().optional()}),be=H.z.object({gatewayID:H.z.string(),messageId:i,message:H.z.unknown(),target:H.z.string().optional().describe("Send target")}),ye=H.z.object({gatewayID:H.z.string(),messageId:i,sessionId:n.optional(),channel:H.z.object({platform:H.z.string(),channelId:H.z.string()}),timestamp:H.z.number().describe("Delivery timestamp")}),Se=H.z.object({gatewayID:H.z.string(),messageId:i,sessionId:n.optional(),channel:H.z.object({platform:H.z.string(),channelId:H.z.string()}),timestamp:H.z.number().describe("Read timestamp")}),Ie=H.z.object({type:H.z.literal("command"),config:H.z.object({command:H.z.string(),arguments:H.z.union([H.z.string(),H.z.record(H.z.string(),H.z.unknown())]).optional()})}),xe=H.z.object({type:H.z.literal("heartbeat"),parts:H.z.array(H.z.unknown()),system:H.z.string().optional(),config:H.z.object({session:H.z.string().optional(),mode:H.z.enum(["session","fork"]).optional(),agent:H.z.string().optional(),model:H.z.string().optional(),tools:H.z.record(H.z.string(),H.z.boolean()).optional()}).optional()}),he=H.z.object({type:H.z.literal("scheduler"),parts:H.z.array(H.z.unknown()),system:H.z.string().optional(),config:H.z.object({agentType:H.z.string().optional(),transport:H.z.enum(["stdio","http","websocket","cli"]).optional(),model:H.z.string().optional(),tools:H.z.record(H.z.string(),H.z.boolean()).optional()}).optional()}),ke=H.z.object({taskId:H.z.string().describe("Heartbeat task ID"),timestamp:H.z.number().describe("Heartbeat timestamp"),name:H.z.string().optional().describe("Heartbeat name"),definition:xe.optional()}),Ce=H.z.object({taskId:H.z.string().describe("Heartbeat task ID"),sessionId:n.optional(),timestamp:H.z.number(),duration:H.z.number().nonnegative().optional(),success:H.z.boolean().optional(),error:H.z.string().optional()}),Te=H.z.object({taskId:H.z.string().describe("Task ID"),taskName:H.z.string().optional(),timestamp:H.z.number(),payload:H.z.record(H.z.string(),H.z.unknown()).optional(),definition:he.optional()}),ve=H.z.object({taskId:H.z.string(),timestamp:H.z.number(),success:H.z.boolean(),result:H.z.record(H.z.string(),H.z.unknown()).optional(),error:H.z.string().optional()}),He=H.z.object({taskId:H.z.string().describe("Command task unique identifier"),taskName:H.z.string().describe("Command task name"),command:H.z.string().describe("Command name"),arguments:H.z.union([H.z.string(),H.z.record(H.z.string(),H.z.unknown())]).optional().describe("Command arguments"),timestamp:H.z.number().describe("Trigger timestamp"),definition:Ie.optional()}),Me=H.z.object({taskId:H.z.string(),timestamp:H.z.number(),success:H.z.boolean(),output:H.z.string().optional(),error:H.z.string().optional(),duration:H.z.number().describe("Execution duration in milliseconds")}),S=H.z.enum(["tool","scheduler","cli","api"]),Pe=H.z.object({taskId:H.z.string().describe("Task unique identifier"),sessionId:H.z.string().describe("Session ID for this task"),source:S.describe("Task source: tool, scheduler, cli, api"),agentType:H.z.string().describe("Agent type to execute this task"),description:H.z.string().describe("Task description"),prompt:H.z.string().describe("Task prompt content"),timeout:H.z.number().positive().optional().describe("Task timeout in milliseconds")}),we=H.z.object({taskId:H.z.string().describe("Task unique identifier"),sessionId:H.z.string().describe("Session ID for this task"),source:S.describe("Task source: tool, scheduler, cli, api")}),Ee=H.z.object({taskId:H.z.string(),sessionId:H.z.string(),source:S,step:H.z.number().describe("Current step number"),totalSteps:H.z.number().optional().describe("Total number of steps"),output:H.z.string().describe("Progress output content"),timestamp:H.z.number().describe("Progress timestamp")}),De=H.z.object({taskId:H.z.string(),sessionId:H.z.string(),source:S,result:H.z.string().describe("Task result content"),duration:H.z.number().nonnegative().describe("Task duration in milliseconds"),attachments:H.z.array(H.z.unknown()).optional().describe("Task result attachments"),error:H.z.string().optional().describe("Error message if task failed"),agentType:H.z.string().optional().describe("Agent type that executed the task"),metadata:H.z.record(H.z.string(),H.z.unknown()).optional().describe("Additional metadata for the task result")}),Ae=H.z.object({sessionId:H.z.string().describe("Session ID"),step:H.z.number().describe("Current step number"),lastUserId:H.z.string().describe("Last user message ID"),result:H.z.enum(["start","continue","stop"]).optional().describe("Loop result: start, continue, or stop")}),je=H.z.object({sessionId:H.z.string().describe("Session ID"),step:H.z.number().describe("Current step number"),lastUserId:H.z.string().describe("Last user message ID"),result:H.z.enum(["stop","continue"]).describe("Loop result: stop or continue")}),Re=H.z.object({requestId:H.z.string(),kind:H.z.enum(["create-skill","create-workflow","create-bundle"]),requirement:H.z.string(),hints:H.z.array(H.z.string()),origin:H.z.object({source:H.z.enum(["human","tool","scheduler","namespace"]).optional(),timestamp:H.z.number().int().nonnegative()})}),ze=H.z.object({requestId:H.z.string(),status:H.z.enum(["success","failed"]),specId:H.z.string().optional(),durationMs:H.z.number().int().nonnegative(),error:H.z.string().optional()}),Oe=H.z.object({dryRun:H.z.boolean()}),Fe=H.z.object({status:H.z.enum(["success","failed","awaiting-approval"]),applied:H.z.number().int().nonnegative().optional(),awaitingApproval:H.z.number().int().nonnegative().optional(),error:H.z.string().optional()}),I={[o.SessionStart]:F,[o.SessionEnd]:W,[o.SessionCompacting]:G,[o.SessionCompact]:B,[o.StepStart]:L,[o.StepFinish]:q,[o.StepStop]:_,[o.StepStopFailure]:U,[o.MessageReceive]:$,[o.MessageTransform]:Z,[o.SystemTransform]:V,[o.ToolBefore]:J,[o.ToolAfter]:Q,[o.ToolFailure]:X,[o.ToolDefinition]:Y,[o.CommandBefore]:ee,[o.CommandAfter]:te,[o.PermissionAsk]:re,[o.PermissionDenied]:se,[o.LlmParams]:ae,[o.LlmHeaders]:pe,[o.ShellEnv]:ce,[o.TextComplete]:me,[o.ContextBuildBefore]:ue,[o.ContextBuildAfter]:le,[o.GatewayMessageReceive]:de,[o.GatewayMessageProcess]:ge,[o.GatewayMessageComplete]:fe,[o.GatewayMessageSend]:be,[o.GatewayMessageDelivered]:ye,[o.GatewayMessageRead]:Se,[o.HeartbeatTrigger]:ke,[o.HeartbeatComplete]:Ce,[o.ScheduledTaskTrigger]:Te,[o.ScheduledTaskComplete]:ve,[o.CommandTrigger]:He,[o.CommandComplete]:Me,[o.TaskStart]:Pe,[o.TaskRunning]:we,[o.TaskProgress]:Ee,[o.TaskComplete]:De,[o.LoopStart]:Ae,[o.LoopEnd]:je,[o.CreationRequest]:Re,[o.CreationComplete]:ze,[o.EvolutionRequest]:Oe,[o.EvolutionComplete]:Fe};function rt(r){return I[r]}function st(r,l){let d=I[r];if(!d)throw new Error(`No schema found for event: ${r}`);return d.parse(l)}function it(r,l){let d=I[r];return d?d.safeParse(l):{success:false,error:new H.z.ZodError([{code:"custom",path:[],message:`No schema found for event: ${r}`}])}}var ft=H.z.enum(["command","mcp","skill"]).describe("Command source"),We=H.z.union([H.z.string(),H.z.record(H.z.string(),H.z.unknown())]).describe("Command arguments"),Ge=H.z.discriminatedUnion("type",[H.z.object({type:H.z.literal("text"),text:H.z.string().describe("Text content")}),H.z.object({type:H.z.literal("image"),source:H.z.object({type:H.z.enum(["base64","url"]),mime:H.z.string().describe("File mime type"),data:H.z.string().describe("File base64 encoding data or url")})}),H.z.object({type:H.z.literal("file"),url:H.z.string().describe("File path"),filename:H.z.string().describe("File name"),mime:H.z.string().optional().describe("File mime type")})]),bt=H.z.object({name:H.z.string().describe("Command name"),description:H.z.string().describe("Command description"),scope:H.z.enum(["general","coder","all"]).optional().describe("Context mode scope"),agent:H.z.string().optional().describe("Specified agent name"),model:H.z.string().optional().describe("Specified model"),hints:H.z.array(H.z.string()).optional().describe("Argument hints"),commandType:H.z.enum(["prompt","local"]).optional().describe("Command type"),hidden:H.z.boolean().optional().describe("Whether hidden")}),yt=H.z.object({sessionId:H.z.string().describe("Session ID"),directory:H.z.string().describe("Working directory"),model:H.z.string().optional().describe("Model identifier"),agent:H.z.string().optional().describe("Agent name"),arguments:We.describe("Command arguments")}),Be=H.z.record(H.z.string(),H.z.unknown()).describe("Result metadata"),St=H.z.object({title:H.z.string().describe("Result title"),metadata:Be.describe("Result metadata"),output:H.z.string().describe("Result output"),parts:H.z.array(Ge).optional().describe("Result parts"),success:H.z.boolean().describe("Whether execution succeeded"),error:H.z.string().optional().describe("Error message if failed")}),It=H.z.object({agent:H.z.object({name:H.z.string().describe("Agent name"),model:H.z.string().optional().describe("Agent model")}).optional().describe("Agent context")}),xt=H.z.object({isEnabled:H.z.boolean().optional().describe("Is enabled check result")});var qe=H.z.enum(["subagent","primary","all"]),_e=H.z.enum(["general","coder","all"]),Ue=H.z.object({providerId:H.z.string().min(1).describe("Model provider ID"),modelId:H.z.string().min(1).describe("Model ID")}),Et=H.z.object({name:H.z.string().min(1).describe("Unique agent name"),description:H.z.string().optional().describe("When to use this agent"),mode:qe.optional().describe("Agent mode"),hidden:H.z.boolean().optional().describe("Hide from @ autocomplete menu"),scope:_e.optional().describe("Agent scope (general / coder / all)"),model:Ue.optional().describe("Default model"),variant:H.z.string().optional().describe("Default model variant"),temperature:H.z.number().min(0).max(2).optional().describe("Sampling temperature"),topP:H.z.number().min(0).max(1).optional().describe("Top-p sampling"),prompt:H.z.string().optional().describe("System prompt"),permission:types.AgentPermissionSchema.optional().describe("Tool permissions"),steps:H.z.number().int().positive().optional().describe("Maximum execution steps"),color:H.z.union([H.z.string().regex(/^#[0-9a-fA-F]{6}$/),H.z.enum(["primary","secondary","accent","success","warning","error","info"])]).optional().describe("UI color (hex code or theme name)"),options:H.z.record(H.z.string(),H.z.unknown()).optional().describe("Additional options")}).meta({ref:"PluginAgent"});var Ft=H.z.object({name:H.z.string().min(1).describe("Unique skill name"),description:H.z.string().min(1).describe("When to use this skill"),scope:H.z.enum(["general","coder","all"]).optional().describe("Context mode scope")}),Wt=H.z.object({agent:H.z.object({name:H.z.string().describe("Agent name"),model:H.z.string().optional().describe("Agent model")}).optional().describe("Agent context")}),Gt=H.z.object({isEnabled:H.z.boolean().optional().describe("Is enabled check result")});var u=new Map;function $t(r){if(u.has(r.id))throw new Error(`Marketplace with id "${r.id}" already registered`);u.set(r.id,r);}function Zt(r){return u.delete(r)}function Vt(){return Array.from(u.values()).map(r=>r)}function Kt(r){return u.get(r)??null}function Jt(r){return Array.from(u.values()).filter(l=>l.category===r)}Object.defineProperty(exports,"AgentPermissionSchema",{enumerable:true,get:function(){return types.AgentPermissionSchema}});Object.defineProperty(exports,"PermissionActionSchema",{enumerable:true,get:function(){return types.PermissionActionSchema}});Object.defineProperty(exports,"PermissionRuleSchema",{enumerable:true,get:function(){return types.PermissionRuleSchema}});Object.defineProperty(exports,"buildToolArgs",{enumerable:true,get:function(){return types.buildToolArgs}});Object.defineProperty(exports,"createTool",{enumerable:true,get:function(){return types.createTool}});Object.defineProperty(exports,"schema",{enumerable:true,get:function(){return types.toolSchema}});exports.AgentExecutorSchema=D;exports.AgentMetadataSchema=Et;exports.AgentModeSchema=qe;exports.AgentModelSchema=Ue;exports.AgentSchema=m;exports.AgentScopeSchema=_e;exports.CallIDSchema=g;exports.CommandAfterInputSchema=te;exports.CommandArgumentsSchema=We;exports.CommandBeforeInputSchema=ee;exports.CommandCompleteInputSchema=Me;exports.CommandExecuteResultMetadataSchema=Be;exports.CommandExecuteResultSchema=St;exports.CommandExecutionContextSchema=yt;exports.CommandExecutorSchema=P;exports.CommandInitContextSchema=It;exports.CommandInitResultSchema=xt;exports.CommandMetadataSchema=bt;exports.CommandPromptPartSchema=Ge;exports.CommandSourceSchema=ft;exports.CommandTaskDefinitionSchema=Ie;exports.CommandTriggerInputSchema=He;exports.ContentPartSchema=C;exports.ContextBuildAfterInputSchema=le;exports.ContextBuildBeforeInputSchema=ue;exports.CreationCompleteInputSchema=ze;exports.CreationRequestInputSchema=Re;exports.CwdSchema=k;exports.EndReasonSchema=z;exports.EventInputSchemas=I;exports.EvolutionCompleteInputSchema=Fe;exports.EvolutionRequestInputSchema=Oe;exports.FinishReasonSchema=O;exports.FunctionExecutorSchema=A;exports.GatewayMessageCompleteInputSchema=fe;exports.GatewayMessageDeliveredInputSchema=ye;exports.GatewayMessageProcessInputSchema=ge;exports.GatewayMessageReadInputSchema=Se;exports.GatewayMessageReceiveInputSchema=de;exports.GatewayMessageSendInputSchema=be;exports.HOOK_EVENTS=Xe;exports.HeartbeatCompleteInputSchema=Ce;exports.HeartbeatTaskDefinitionSchema=xe;exports.HeartbeatTriggerInputSchema=ke;exports.HookEvent=o;exports.HookExecutorSchema=j;exports.HookMatcherSchema=R;exports.HookType=c;exports.HooksConfigSchema=nt;exports.HttpExecutorSchema=E;exports.LlmHeadersInputSchema=pe;exports.LlmParamsInputSchema=ae;exports.LlmParamsSchema=ie;exports.LlmProviderSchema=v;exports.LoopEndInputSchema=je;exports.LoopStartInputSchema=Ae;exports.MessageIDSchema=i;exports.MessageReceiveInputSchema=$;exports.MessageRoleSchema=N;exports.MessageSchema=T;exports.MessageTransformInputSchema=Z;exports.ModelObjectSchema=h;exports.ModelSchema=f;exports.PartIDSchema=x;exports.PermissionAskInputSchema=re;exports.PermissionDeniedInputSchema=se;exports.PermissionLevelSchema=oe;exports.PermissionRequestSchema=ne;exports.PromptExecutorSchema=w;exports.ScheduledTaskCompleteInputSchema=ve;exports.ScheduledTaskTriggerInputSchema=Te;exports.SchedulerTaskDefinitionSchema=he;exports.SessionCompactInputSchema=B;exports.SessionCompactingInputSchema=G;exports.SessionEndInputSchema=W;exports.SessionIDSchema=n;exports.SessionStartInputSchema=F;exports.ShellEnvInputSchema=ce;exports.SkillInitContextSchema=Wt;exports.SkillInitResultSchema=Gt;exports.SkillMetadataSchema=Ft;exports.StepFinishInputSchema=q;exports.StepStartInputSchema=L;exports.StepStopFailureInputSchema=U;exports.StepStopInputSchema=_;exports.SystemTransformInputSchema=V;exports.TaskCompleteInputSchema=De;exports.TaskProgressInputSchema=Ee;exports.TaskRunningInputSchema=we;exports.TaskSourceSchema=S;exports.TaskStartInputSchema=Pe;exports.TextCompleteInputSchema=me;exports.ToolAfterInputSchema=Q;exports.ToolArgsSchema=y;exports.ToolBeforeInputSchema=J;exports.ToolDefinitionInputSchema=Y;exports.ToolFailureInputSchema=X;exports.ToolResultSchema=K;exports.findMarketplace=Kt;exports.findMarketplacesByCategory=Jt;exports.getEventInputSchema=rt;exports.listMarketplaces=Vt;exports.registerMarketplace=$t;exports.safeValidateHookInput=it;exports.tool=M;exports.unregisterMarketplace=Zt;exports.validateHookInput=st;
|