@easbot/plugin 0.3.29 → 0.3.32
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 +32 -17
- package/README.md +32 -17
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +697 -515
- package/dist/index.d.ts +697 -515
- package/dist/index.mjs +1 -1
- package/package.json +3 -3
package/README.en.md
CHANGED
|
@@ -6,7 +6,7 @@ EASBot Plugin System - Hooks, Commands, and Tool Management
|
|
|
6
6
|
|
|
7
7
|
## Version
|
|
8
8
|
|
|
9
|
-
v0.3.
|
|
9
|
+
v0.3.32
|
|
10
10
|
## Features
|
|
11
11
|
|
|
12
12
|
- **Hook System**: Event-driven hook mechanism for extending Agent behavior
|
|
@@ -39,21 +39,30 @@ hooks.register(HOOK_EVENTS.BEFORE_TOOL_CALL, async (tool, context) => {
|
|
|
39
39
|
|
|
40
40
|
### Command System
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
import { createCommandRegistry } from '@easbot/plugin';
|
|
44
|
-
|
|
45
|
-
const commands = createCommandRegistry();
|
|
42
|
+
The **contract types** for commands (`CommandDefinition` / `CommandInfo` / `CommandArguments` / `CommandExecutionContext` / `CommandExecuteResult` …) have their **single source of truth in `@easbot/types`** (`native/command.ts`); this package only re-exports them (public API surface unchanged).
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
```typescript
|
|
45
|
+
import type { CommandDefinition } from '@easbot/plugin';
|
|
46
|
+
|
|
47
|
+
// Declare commands inside PluginDefinition.commands (map shape, key = command id)
|
|
48
|
+
const myPlugin = async (): Promise<PluginDefinition> => ({
|
|
49
|
+
commands: {
|
|
50
|
+
hello: {
|
|
51
|
+
name: 'hello',
|
|
52
|
+
description: 'Say hello',
|
|
53
|
+
execute: async (args, ctx) => ({
|
|
54
|
+
title: 'hello',
|
|
55
|
+
metadata: { sessionId: ctx.sessionId },
|
|
56
|
+
output: 'Hello!',
|
|
57
|
+
success: true,
|
|
58
|
+
}),
|
|
59
|
+
},
|
|
53
60
|
},
|
|
54
61
|
});
|
|
55
62
|
```
|
|
56
63
|
|
|
64
|
+
> ⚠️ The command **registry** (`register` / `unregister` / `list`) lives in `CommandRegistry` of `@easbot/agent`; this package only provides the type declarations.
|
|
65
|
+
|
|
57
66
|
### Tool System
|
|
58
67
|
|
|
59
68
|
```typescript
|
|
@@ -81,13 +90,19 @@ const tool = createTool({
|
|
|
81
90
|
| `unregister(event, handler)` | Remove a hook handler |
|
|
82
91
|
| `clear(event)` | Clear all handlers for an event |
|
|
83
92
|
|
|
84
|
-
###
|
|
93
|
+
### Command types
|
|
94
|
+
|
|
95
|
+
The **contract types** for commands (`CommandDefinition` / `CommandInfo` / `CommandArguments` / `CommandExecutionContext` / `CommandExecuteResult` …) have their **single source of truth in `@easbot/types`** (`native/command.ts`); this package only re-exports them (public API surface unchanged).
|
|
85
96
|
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
97
|
+
| Type | Description |
|
|
98
|
+
| ------------------------- | -------------------------------------------------------------------- |
|
|
99
|
+
| `CommandDefinition` | Runtime command definition (`execute` required) |
|
|
100
|
+
| `CommandInfo` | Command registry entry / HTTP response contract (`execute` optional) |
|
|
101
|
+
| `CommandConfigInfo` | Config-shape command template (value of `config.command`) |
|
|
102
|
+
| `CommandMetadata` | Markdown frontmatter declaration shape |
|
|
103
|
+
| `CommandArguments` | Command arguments (string / record) |
|
|
104
|
+
| `CommandExecutionContext` | Command execution context (sessionId / directory / …) |
|
|
105
|
+
| `CommandExecuteResult` | Command execution result |
|
|
91
106
|
|
|
92
107
|
### createTool
|
|
93
108
|
|
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ EASBot 插件系统 - Hook、命令和工具管理
|
|
|
6
6
|
|
|
7
7
|
## 版本
|
|
8
8
|
|
|
9
|
-
v0.3.
|
|
9
|
+
v0.3.32
|
|
10
10
|
## 特性
|
|
11
11
|
|
|
12
12
|
- **Hook 系统**:事件驱动的 Hook 机制,扩展 Agent 行为
|
|
@@ -39,21 +39,30 @@ hooks.register(HOOK_EVENTS.BEFORE_TOOL_CALL, async (tool, context) => {
|
|
|
39
39
|
|
|
40
40
|
### 命令系统
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
import { createCommandRegistry } from '@easbot/plugin';
|
|
44
|
-
|
|
45
|
-
const commands = createCommandRegistry();
|
|
42
|
+
命令**契约类型**(`CommandDefinition` / `CommandInfo` / `CommandArguments` / `CommandExecutionContext` / `CommandExecuteResult` …)的**唯一真源是 `@easbot/types`**(`native/command.ts`),本包只做 re-export(对外 API 面不变)。
|
|
46
43
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
```typescript
|
|
45
|
+
import type { CommandDefinition } from '@easbot/plugin';
|
|
46
|
+
|
|
47
|
+
// 在 PluginDefinition.commands 里声明命令(map 形态,key = command id)
|
|
48
|
+
const myPlugin = async (): Promise<PluginDefinition> => ({
|
|
49
|
+
commands: {
|
|
50
|
+
hello: {
|
|
51
|
+
name: 'hello',
|
|
52
|
+
description: '打招呼',
|
|
53
|
+
execute: async (args, ctx) => ({
|
|
54
|
+
title: 'hello',
|
|
55
|
+
metadata: { sessionId: ctx.sessionId },
|
|
56
|
+
output: '你好!',
|
|
57
|
+
success: true,
|
|
58
|
+
}),
|
|
59
|
+
},
|
|
53
60
|
},
|
|
54
61
|
});
|
|
55
62
|
```
|
|
56
63
|
|
|
64
|
+
> ⚠️ 命令的**注册表**(`register` / `unregister` / `list`)在 `@easbot/agent` 的 `CommandRegistry`,本包只提供类型声明。
|
|
65
|
+
|
|
57
66
|
### 工具系统
|
|
58
67
|
|
|
59
68
|
```typescript
|
|
@@ -81,13 +90,19 @@ const tool = createTool({
|
|
|
81
90
|
| `unregister(event, handler)` | 移除 Hook 处理器 |
|
|
82
91
|
| `clear(event)` | 清除事件的所有处理器 |
|
|
83
92
|
|
|
84
|
-
###
|
|
93
|
+
### Command 类型
|
|
94
|
+
|
|
95
|
+
命令**契约类型**(`CommandDefinition` / `CommandInfo` / `CommandArguments` / `CommandExecutionContext` / `CommandExecuteResult` …)的**唯一真源是 `@easbot/types`**(`native/command.ts`),本包只做 re-export(对外 API 面不变)。
|
|
85
96
|
|
|
86
|
-
|
|
|
87
|
-
|
|
|
88
|
-
| `
|
|
89
|
-
| `
|
|
90
|
-
| `
|
|
97
|
+
| 类型 | 说明 |
|
|
98
|
+
| ------------------------- | ------------------------------------------------ |
|
|
99
|
+
| `CommandDefinition` | 运行期命令定义(`execute` 必填) |
|
|
100
|
+
| `CommandInfo` | 命令注册表条目 / HTTP 响应契约(`execute` 可选) |
|
|
101
|
+
| `CommandConfigInfo` | 配置态命令模板(`config.command` 的值) |
|
|
102
|
+
| `CommandMetadata` | Markdown frontmatter 声明形态 |
|
|
103
|
+
| `CommandArguments` | 命令参数(字符串 / 对象) |
|
|
104
|
+
| `CommandExecutionContext` | 命令执行上下文(sessionId / directory / …) |
|
|
105
|
+
| `CommandExecuteResult` | 命令执行结果 |
|
|
91
106
|
|
|
92
107
|
### createTool
|
|
93
108
|
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
'use strict';var H=require('zod'),types=require('@easbot/types');require('@easbot/sdk');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var H__default=/*#__PURE__*/_interopDefault(H);function M(r){return {description:r.description,args:r.args,execute:r.execute}}M.schema=H__default.default;var c={Command:"command",Prompt:"prompt",Http:"http",Agent:"agent",Function:"function"},o={SessionStart:"session.start",SessionEnd:"session.end",SessionCompacting:"session.compacting",SessionCompact:"session.compact",StepStart:"step.start",StepFinish:"step.finish",StepStop:"step.stop",StepStopFailure:"step.stop.failure",MessageReceive:"message.receive",MessageTransform:"message.transform",SystemTransform:"system.transform",ToolBefore:"tool.before",ToolAfter:"tool.after",ToolFailure:"tool.failure",ToolDefinition:"tool.definition",CommandBefore:"command.before",CommandAfter:"command.after",PermissionAsk:"permission.ask",PermissionDenied:"permission.denied",LlmParams:"llm.params",LlmHeaders:"llm.headers",ShellEnv:"shell.env",TextComplete:"text.complete",GatewayMessageReceive:"gateway.message.receive",GatewayMessageProcess:"gateway.message.process",GatewayMessageComplete:"gateway.message.complete",GatewayMessageSend:"gateway.message.send",GatewayMessageDelivered:"gateway.message.delivered",GatewayMessageRead:"gateway.message.read",HeartbeatTrigger:"scheduler.heartbeat.trigger",HeartbeatComplete:"scheduler.heartbeat.complete",ScheduledTaskTrigger:"scheduler.task.trigger",ScheduledTaskComplete:"scheduler.task.complete",CommandTrigger:"scheduler.command.trigger",CommandComplete:"scheduler.command.complete",ContextBuildBefore:"context.build.before",ContextBuildAfter:"context.build.after",TaskStart:"task.start",TaskRunning:"task.running",TaskProgress:"task.progress",TaskComplete:"task.complete",LoopStart:"loop.start",LoopEnd:"loop.end",CreationRequest:"creation.request",CreationComplete:"creation.complete",EvolutionRequest:"evolution.request",EvolutionComplete:"evolution.complete"},Xe=Object.values(o);var b=H.z.string().optional(),P=H.z.object({type:H.z.literal(c.Command),command:H.z.string(),if:b,shell:H.z.enum(["bash","powershell"]).optional(),timeout:H.z.number().positive().optional(),statusMessage:H.z.string().optional(),once:H.z.boolean().optional(),async:H.z.boolean().optional()}),w=H.z.object({type:H.z.literal(c.Prompt),if:b,timeout:H.z.number().positive().optional(),model:H.z.string().optional(),statusMessage:H.z.string().optional(),once:H.z.boolean().optional(),runMode:H.z.enum(["session","fork"]).optional(),system:H.z.string().optional(),parts:H.z.array(H.z.unknown()),onMessage:H.z.custom(r=>typeof r=="function").optional()}),E=H.z.object({type:H.z.literal(c.Http),url:H.z.string(),if:b,timeout:H.z.number().positive().optional(),method:H.z.enum(["GET","POST","PUT","DELETE"]).optional(),headers:H.z.record(H.z.string(),H.z.string()).optional(),allowedEnvVars:H.z.array(H.z.string()).optional(),statusMessage:H.z.string().optional(),once:H.z.boolean().optional()}),D=H.z.object({type:H.z.literal(c.Agent),if:b,timeout:H.z.number().positive().optional(),agent:H.z.string().optional(),model:H.z.string().optional(),statusMessage:H.z.string().optional(),once:H.z.boolean().optional(),system:H.z.string().optional(),parts:H.z.array(H.z.unknown()),onMessage:H.z.custom(r=>typeof r=="function").optional()}),A=H.z.object({type:H.z.literal(c.Function),handler:H.z.function()}),j=H.z.discriminatedUnion("type",[P,w,E,D,A]),R=H.z.object({event:H.z.string(),matcher:H.z.string().optional(),hooks:H.z.array(j)}),nt=H.z.record(H.z.string(),H.z.array(R)),n=H.z.string().min(1).describe("Session unique identifier"),x=H.z.string().min(1).describe("Part unique identifier"),i=H.z.string().min(1).describe("Message unique identifier"),g=H.z.string().min(1).describe("Tool call unique identifier"),m=H.z.string().optional().describe("Agent name"),f=H.z.string().optional().describe("Model identifier"),h=H.z.object({providerId:H.z.string().describe("Provider ID"),modelId:H.z.string().describe("Model ID"),api:H.z.object({id:H.z.string().describe("API ID"),npm:H.z.string().optional().describe("NPM package name")}).optional().describe("API information")}).optional().describe("Model object"),k=H.z.string().optional().describe("Working directory path"),z=H.z.enum(["user_request","max_tokens","stop","error","timeout","cancelled"]).describe("Session end reason"),O=H.z.enum(["stop","max_tokens","end_turn","stop_sequence"]).describe("Step finish reason"),F=H.z.object({sessionId:n,source:H.z.enum(["user","agent","system","scheduled"]).optional().describe("Session source"),model:f,agent:m,cwd:k}),W=H.z.object({sessionId:n,reason:z,duration:H.z.number().positive().optional().describe("Session duration in milliseconds")}),G=H.z.object({sessionId:n,trigger:H.z.enum(["manual","auto","threshold"]).describe("Compaction trigger"),contextLength:H.z.number().positive().describe("Current context length"),threshold:H.z.number().positive().describe("Trigger threshold")}),B=H.z.object({sessionId:n,summary:H.z.string().describe("Compaction summary"),previousLength:H.z.number().positive().describe("Previous context length"),newLength:H.z.number().positive().describe("New context length")}),L=H.z.object({sessionId:n,messageId:i,partId:x.optional().describe("step-start part ID (created by processor before hook trigger)"),userMessageId:i.optional().describe("User message ID for the current step"),model:f,agent:m}),q=H.z.object({sessionId:n,messageId:i,partId:x.optional().describe("step-finish part ID (created by processor before hook trigger)"),userMessageId:i.optional().describe("User message ID for the current step"),model:f,agent:m,finishReason:O,tokens:H.z.object({input:H.z.number().int().nonnegative().optional(),output:H.z.number().int().nonnegative().optional(),total:H.z.number().int().nonnegative().optional()}).optional().describe("Token usage statistics")}),_=H.z.object({sessionId:n,reason:H.z.string().describe("Stop reason")}),U=H.z.object({sessionId:n,error:H.z.string().describe("Error message"),errorType:H.z.enum(["rate_limit","auth_error","network_error","timeout","invalid_request","server_error"]).describe("Error type")}),N=H.z.enum(["user","assistant","system","tool"]),C=H.z.discriminatedUnion("type",[H.z.object({type:H.z.literal("text"),text:H.z.string().describe("Text content")}),H.z.object({type:H.z.literal("image"),source:H.z.object({type:H.z.enum(["base64","url"]),mime:H.z.string().optional().describe("File mime type"),data:H.z.string().describe("File base64 encoding data or url")})}),H.z.object({type:H.z.literal("file"),url:H.z.string().describe("File path"),filename:H.z.string().describe("File name"),mime:H.z.string().optional().describe("File mime type")})]),T=H.z.object({id:i,role:N,content:H.z.union([H.z.string(),H.z.array(C)]),name:H.z.string().optional().describe("Message sender name"),tool_call_id:g.optional().describe("Related tool call ID")}),$=H.z.object({sessionId:n,agent:m,model:f,messageId:i,message:H.z.object({id:i,role:H.z.literal("user"),content:H.z.union([H.z.string(),H.z.array(C)])}).describe("User message")}),Z=H.z.object({sessionId:n,messages:H.z.array(T).describe("Messages to transform")}),V=H.z.object({sessionId:n,model:f,system:H.z.array(H.z.string()).describe("Current system prompt")}),y=H.z.record(H.z.string(),H.z.unknown()).describe("Tool call arguments"),K=H.z.object({title:H.z.string().optional().describe("Result title"),content:H.z.string().describe("Result content"),is_error:H.z.boolean().optional().describe("Is error result"),metadata:H.z.record(H.z.string(),H.z.unknown()).optional().describe("Extra metadata")}),J=H.z.object({sessionId:n,userMessageId:i.optional().describe("User message ID for the current step"),tool:H.z.string().describe("Tool name"),callId:g,args:y}),Q=H.z.object({sessionId:n,userMessageId:i.optional().describe("User message ID for the current step"),tool:H.z.string(),callId:g,args:y,result:K,duration:H.z.number().nonnegative().optional().describe("Execution duration in milliseconds")}),X=H.z.object({sessionId:n,tool:H.z.string(),callId:g,args:y,error:H.z.string().describe("Error message"),errorType:H.z.enum(["timeout","invalid_args","execution_error","permission_denied"])}),Y=H.z.object({sessionId:n,toolID:H.z.string().describe("Tool ID"),definition:H.z.object({name:H.z.string(),description:H.z.string().optional(),parameters:H.z.record(H.z.string(),H.z.unknown()).optional()}).describe("Tool definition")}),ee=H.z.object({sessionId:n,command:H.z.string().describe("Command name"),arguments:H.z.union([H.z.string(),H.z.record(H.z.string(),H.z.unknown())]).describe("Command arguments")}),te=H.z.object({sessionId:n,command:H.z.string().describe("Command name"),arguments:H.z.union([H.z.string(),H.z.record(H.z.string(),H.z.unknown())]).optional(),result:H.z.object({info:H.z.unknown().optional().describe("Message info"),parts:H.z.array(H.z.unknown()).optional().describe("Message parts"),title:H.z.string().optional().describe("Result title"),metadata:H.z.record(H.z.string(),H.z.unknown()).optional().describe("Result metadata"),output:H.z.string().optional().describe("Result output"),success:H.z.boolean().optional().describe("Whether execution succeeded"),error:H.z.string().optional().describe("Error message if failed")}).describe("Command execution result")}),oe=H.z.enum(["read","write","exec","admin"]),ne=H.z.object({tool:H.z.string().describe("Tool name requesting permission"),args:y.optional(),level:oe.optional(),reason:H.z.string().optional().describe("Reason for permission request")}),re=H.z.object({sessionId:n,request:ne}),se=H.z.object({sessionId:n,tool:H.z.string(),reason:H.z.string().optional()}),v=H.z.enum(["openai","anthropic","google","azure","custom"]),ie=H.z.object({temperature:H.z.number().min(0).max(2).optional(),topP:H.z.number().min(0).max(1).optional(),topK:H.z.number().int().positive().optional(),maxTokens:H.z.number().int().positive().optional(),stopSequences:H.z.array(H.z.string()).optional(),responseFormat:H.z.enum(["text","json_object"]).optional()}),ae=H.z.object({sessionId:n,agent:m,model:h,provider:v,params:ie.partial().optional()}),pe=H.z.object({sessionId:n,agent:m,model:h,provider:v,headers:H.z.record(H.z.string(),H.z.string()).optional()}),ce=H.z.object({cwd:k.describe("Working directory"),sessionId:n.optional(),callId:g.optional()}),me=H.z.object({sessionId:n,messageId:i,partId:H.z.string().describe("Text part ID"),text:H.z.string().describe("Completed text")}),ue=H.z.object({sessionId:n,mode:H.z.enum(["agent","chat","query"]).describe("Build mode"),providerId:H.z.string().optional()}),le=H.z.object({sessionId:n,context:H.z.object({messages:H.z.array(T),system:H.z.array(H.z.string()),metadata:H.z.record(H.z.string(),H.z.unknown())}).describe("Built context")}),de=H.z.object({gatewayID:H.z.string().describe("Gateway ID"),messageId:i,message:H.z.unknown().describe("Received message")}),ge=H.z.object({gatewayID:H.z.string(),messageId:i,message:H.z.unknown(),sessionId:n.optional()}),fe=H.z.object({gatewayID:H.z.string(),messageId:i,result:H.z.unknown().optional()}),be=H.z.object({gatewayID:H.z.string(),messageId:i,message:H.z.unknown(),target:H.z.string().optional().describe("Send target")}),ye=H.z.object({gatewayID:H.z.string(),messageId:i,sessionId:n.optional(),channel:H.z.object({platform:H.z.string(),channelId:H.z.string()}),timestamp:H.z.number().describe("Delivery timestamp")}),Se=H.z.object({gatewayID:H.z.string(),messageId:i,sessionId:n.optional(),channel:H.z.object({platform:H.z.string(),channelId:H.z.string()}),timestamp:H.z.number().describe("Read timestamp")}),Ie=H.z.object({type:H.z.literal("command"),config:H.z.object({command:H.z.string(),arguments:H.z.union([H.z.string(),H.z.record(H.z.string(),H.z.unknown())]).optional()})}),xe=H.z.object({type:H.z.literal("heartbeat"),parts:H.z.array(H.z.unknown()),system:H.z.string().optional(),config:H.z.object({session:H.z.string().optional(),mode:H.z.enum(["session","fork"]).optional(),agent:H.z.string().optional(),model:H.z.string().optional(),tools:H.z.record(H.z.string(),H.z.boolean()).optional()}).optional()}),he=H.z.object({type:H.z.literal("scheduler"),parts:H.z.array(H.z.unknown()),system:H.z.string().optional(),config:H.z.object({agentType:H.z.string().optional(),transport:H.z.enum(["stdio","http","websocket","cli"]).optional(),model:H.z.string().optional(),tools:H.z.record(H.z.string(),H.z.boolean()).optional()}).optional()}),ke=H.z.object({taskId:H.z.string().describe("Heartbeat task ID"),timestamp:H.z.number().describe("Heartbeat timestamp"),name:H.z.string().optional().describe("Heartbeat name"),definition:xe.optional()}),Ce=H.z.object({taskId:H.z.string().describe("Heartbeat task ID"),sessionId:n.optional(),timestamp:H.z.number(),duration:H.z.number().nonnegative().optional(),success:H.z.boolean().optional(),error:H.z.string().optional()}),Te=H.z.object({taskId:H.z.string().describe("Task ID"),taskName:H.z.string().optional(),timestamp:H.z.number(),payload:H.z.record(H.z.string(),H.z.unknown()).optional(),definition:he.optional()}),ve=H.z.object({taskId:H.z.string(),timestamp:H.z.number(),success:H.z.boolean(),result:H.z.record(H.z.string(),H.z.unknown()).optional(),error:H.z.string().optional()}),He=H.z.object({taskId:H.z.string().describe("Command task unique identifier"),taskName:H.z.string().describe("Command task name"),command:H.z.string().describe("Command name"),arguments:H.z.union([H.z.string(),H.z.record(H.z.string(),H.z.unknown())]).optional().describe("Command arguments"),timestamp:H.z.number().describe("Trigger timestamp"),definition:Ie.optional()}),Me=H.z.object({taskId:H.z.string(),timestamp:H.z.number(),success:H.z.boolean(),output:H.z.string().optional(),error:H.z.string().optional(),duration:H.z.number().describe("Execution duration in milliseconds")}),S=H.z.enum(["tool","scheduler","cli","api"]),Pe=H.z.object({taskId:H.z.string().describe("Task unique identifier"),sessionId:H.z.string().describe("Session ID for this task"),source:S.describe("Task source: tool, scheduler, cli, api"),agentType:H.z.string().describe("Agent type to execute this task"),description:H.z.string().describe("Task description"),prompt:H.z.string().describe("Task prompt content"),timeout:H.z.number().positive().optional().describe("Task timeout in milliseconds")}),we=H.z.object({taskId:H.z.string().describe("Task unique identifier"),sessionId:H.z.string().describe("Session ID for this task"),source:S.describe("Task source: tool, scheduler, cli, api")}),Ee=H.z.object({taskId:H.z.string(),sessionId:H.z.string(),source:S,step:H.z.number().describe("Current step number"),totalSteps:H.z.number().optional().describe("Total number of steps"),output:H.z.string().describe("Progress output content"),timestamp:H.z.number().describe("Progress timestamp")}),De=H.z.object({taskId:H.z.string(),sessionId:H.z.string(),source:S,result:H.z.string().describe("Task result content"),duration:H.z.number().nonnegative().describe("Task duration in milliseconds"),attachments:H.z.array(H.z.unknown()).optional().describe("Task result attachments"),error:H.z.string().optional().describe("Error message if task failed"),agentType:H.z.string().optional().describe("Agent type that executed the task"),metadata:H.z.record(H.z.string(),H.z.unknown()).optional().describe("Additional metadata for the task result")}),Ae=H.z.object({sessionId:H.z.string().describe("Session ID"),step:H.z.number().describe("Current step number"),lastUserId:H.z.string().describe("Last user message ID"),result:H.z.enum(["start","continue","stop"]).optional().describe("Loop result: start, continue, or stop")}),je=H.z.object({sessionId:H.z.string().describe("Session ID"),step:H.z.number().describe("Current step number"),lastUserId:H.z.string().describe("Last user message ID"),result:H.z.enum(["stop","continue"]).describe("Loop result: stop or continue")}),Re=H.z.object({requestId:H.z.string(),kind:H.z.enum(["create-skill","create-workflow","create-bundle"]),requirement:H.z.string(),hints:H.z.array(H.z.string()),origin:H.z.object({source:H.z.enum(["human","tool","scheduler","namespace"]).optional(),timestamp:H.z.number().int().nonnegative()})}),ze=H.z.object({requestId:H.z.string(),status:H.z.enum(["success","failed"]),specId:H.z.string().optional(),durationMs:H.z.number().int().nonnegative(),error:H.z.string().optional()}),Oe=H.z.object({dryRun:H.z.boolean()}),Fe=H.z.object({status:H.z.enum(["success","failed","awaiting-approval"]),applied:H.z.number().int().nonnegative().optional(),awaitingApproval:H.z.number().int().nonnegative().optional(),error:H.z.string().optional()}),I={[o.SessionStart]:F,[o.SessionEnd]:W,[o.SessionCompacting]:G,[o.SessionCompact]:B,[o.StepStart]:L,[o.StepFinish]:q,[o.StepStop]:_,[o.StepStopFailure]:U,[o.MessageReceive]:$,[o.MessageTransform]:Z,[o.SystemTransform]:V,[o.ToolBefore]:J,[o.ToolAfter]:Q,[o.ToolFailure]:X,[o.ToolDefinition]:Y,[o.CommandBefore]:ee,[o.CommandAfter]:te,[o.PermissionAsk]:re,[o.PermissionDenied]:se,[o.LlmParams]:ae,[o.LlmHeaders]:pe,[o.ShellEnv]:ce,[o.TextComplete]:me,[o.ContextBuildBefore]:ue,[o.ContextBuildAfter]:le,[o.GatewayMessageReceive]:de,[o.GatewayMessageProcess]:ge,[o.GatewayMessageComplete]:fe,[o.GatewayMessageSend]:be,[o.GatewayMessageDelivered]:ye,[o.GatewayMessageRead]:Se,[o.HeartbeatTrigger]:ke,[o.HeartbeatComplete]:Ce,[o.ScheduledTaskTrigger]:Te,[o.ScheduledTaskComplete]:ve,[o.CommandTrigger]:He,[o.CommandComplete]:Me,[o.TaskStart]:Pe,[o.TaskRunning]:we,[o.TaskProgress]:Ee,[o.TaskComplete]:De,[o.LoopStart]:Ae,[o.LoopEnd]:je,[o.CreationRequest]:Re,[o.CreationComplete]:ze,[o.EvolutionRequest]:Oe,[o.EvolutionComplete]:Fe};function rt(r){return I[r]}function st(r,l){let d=I[r];if(!d)throw new Error(`No schema found for event: ${r}`);return d.parse(l)}function it(r,l){let d=I[r];return d?d.safeParse(l):{success:false,error:new H.z.ZodError([{code:"custom",path:[],message:`No schema found for event: ${r}`}])}}var ft=H.z.enum(["command","mcp","skill"]).describe("Command source"),We=H.z.union([H.z.string(),H.z.record(H.z.string(),H.z.unknown())]).describe("Command arguments"),Ge=H.z.discriminatedUnion("type",[H.z.object({type:H.z.literal("text"),text:H.z.string().describe("Text content")}),H.z.object({type:H.z.literal("image"),source:H.z.object({type:H.z.enum(["base64","url"]),mime:H.z.string().describe("File mime type"),data:H.z.string().describe("File base64 encoding data or url")})}),H.z.object({type:H.z.literal("file"),url:H.z.string().describe("File path"),filename:H.z.string().describe("File name"),mime:H.z.string().optional().describe("File mime type")})]),bt=H.z.object({name:H.z.string().describe("Command name"),description:H.z.string().describe("Command description"),scope:H.z.enum(["general","coder","all"]).optional().describe("Context mode scope"),agent:H.z.string().optional().describe("Specified agent name"),model:H.z.string().optional().describe("Specified model"),hints:H.z.array(H.z.string()).optional().describe("Argument hints"),commandType:H.z.enum(["prompt","local"]).optional().describe("Command type"),hidden:H.z.boolean().optional().describe("Whether hidden")}),yt=H.z.object({sessionId:H.z.string().describe("Session ID"),directory:H.z.string().describe("Working directory"),model:H.z.string().optional().describe("Model identifier"),agent:H.z.string().optional().describe("Agent name"),arguments:We.describe("Command arguments")}),Be=H.z.record(H.z.string(),H.z.unknown()).describe("Result metadata"),St=H.z.object({title:H.z.string().describe("Result title"),metadata:Be.describe("Result metadata"),output:H.z.string().describe("Result output"),parts:H.z.array(Ge).optional().describe("Result parts"),success:H.z.boolean().describe("Whether execution succeeded"),error:H.z.string().optional().describe("Error message if failed")}),It=H.z.object({agent:H.z.object({name:H.z.string().describe("Agent name"),model:H.z.string().optional().describe("Agent model")}).optional().describe("Agent context")}),xt=H.z.object({isEnabled:H.z.boolean().optional().describe("Is enabled check result")});var qe=H.z.enum(["subagent","primary","all"]),_e=H.z.enum(["general","coder","all"]),Ue=H.z.object({providerId:H.z.string().min(1).describe("Model provider ID"),modelId:H.z.string().min(1).describe("Model ID")}),Et=H.z.object({name:H.z.string().min(1).describe("Unique agent name"),description:H.z.string().optional().describe("When to use this agent"),mode:qe.optional().describe("Agent mode"),hidden:H.z.boolean().optional().describe("Hide from @ autocomplete menu"),scope:_e.optional().describe("Agent scope (general / coder / all)"),model:Ue.optional().describe("Default model"),variant:H.z.string().optional().describe("Default model variant"),temperature:H.z.number().min(0).max(2).optional().describe("Sampling temperature"),topP:H.z.number().min(0).max(1).optional().describe("Top-p sampling"),prompt:H.z.string().optional().describe("System prompt"),permission:types.AgentPermissionSchema.optional().describe("Tool permissions"),steps:H.z.number().int().positive().optional().describe("Maximum execution steps"),color:H.z.union([H.z.string().regex(/^#[0-9a-fA-F]{6}$/),H.z.enum(["primary","secondary","accent","success","warning","error","info"])]).optional().describe("UI color (hex code or theme name)"),options:H.z.record(H.z.string(),H.z.unknown()).optional().describe("Additional options")}).meta({ref:"PluginAgent"});var Ft=H.z.object({name:H.z.string().min(1).describe("Unique skill name"),description:H.z.string().min(1).describe("When to use this skill"),scope:H.z.enum(["general","coder","all"]).optional().describe("Context mode scope")}),Wt=H.z.object({agent:H.z.object({name:H.z.string().describe("Agent name"),model:H.z.string().optional().describe("Agent model")}).optional().describe("Agent context")}),Gt=H.z.object({isEnabled:H.z.boolean().optional().describe("Is enabled check result")});var u=new Map;function $t(r){if(u.has(r.id))throw new Error(`Marketplace with id "${r.id}" already registered`);u.set(r.id,r);}function Zt(r){return u.delete(r)}function Vt(){return Array.from(u.values()).map(r=>r)}function Kt(r){return u.get(r)??null}function Jt(r){return Array.from(u.values()).filter(l=>l.category===r)}Object.defineProperty(exports,"AgentPermissionSchema",{enumerable:true,get:function(){return types.AgentPermissionSchema}});Object.defineProperty(exports,"PermissionActionSchema",{enumerable:true,get:function(){return types.PermissionActionSchema}});Object.defineProperty(exports,"PermissionRuleSchema",{enumerable:true,get:function(){return types.PermissionRuleSchema}});Object.defineProperty(exports,"buildToolArgs",{enumerable:true,get:function(){return types.buildToolArgs}});Object.defineProperty(exports,"createTool",{enumerable:true,get:function(){return types.createTool}});Object.defineProperty(exports,"schema",{enumerable:true,get:function(){return types.toolSchema}});exports.AgentExecutorSchema=D;exports.AgentMetadataSchema=Et;exports.AgentModeSchema=qe;exports.AgentModelSchema=Ue;exports.AgentSchema=m;exports.AgentScopeSchema=_e;exports.CallIDSchema=g;exports.CommandAfterInputSchema=te;exports.CommandArgumentsSchema=We;exports.CommandBeforeInputSchema=ee;exports.CommandCompleteInputSchema=Me;exports.CommandExecuteResultMetadataSchema=Be;exports.CommandExecuteResultSchema=St;exports.CommandExecutionContextSchema=yt;exports.CommandExecutorSchema=P;exports.CommandInitContextSchema=It;exports.CommandInitResultSchema=xt;exports.CommandMetadataSchema=bt;exports.CommandPromptPartSchema=Ge;exports.CommandSourceSchema=ft;exports.CommandTaskDefinitionSchema=Ie;exports.CommandTriggerInputSchema=He;exports.ContentPartSchema=C;exports.ContextBuildAfterInputSchema=le;exports.ContextBuildBeforeInputSchema=ue;exports.CreationCompleteInputSchema=ze;exports.CreationRequestInputSchema=Re;exports.CwdSchema=k;exports.EndReasonSchema=z;exports.EventInputSchemas=I;exports.EvolutionCompleteInputSchema=Fe;exports.EvolutionRequestInputSchema=Oe;exports.FinishReasonSchema=O;exports.FunctionExecutorSchema=A;exports.GatewayMessageCompleteInputSchema=fe;exports.GatewayMessageDeliveredInputSchema=ye;exports.GatewayMessageProcessInputSchema=ge;exports.GatewayMessageReadInputSchema=Se;exports.GatewayMessageReceiveInputSchema=de;exports.GatewayMessageSendInputSchema=be;exports.HOOK_EVENTS=Xe;exports.HeartbeatCompleteInputSchema=Ce;exports.HeartbeatTaskDefinitionSchema=xe;exports.HeartbeatTriggerInputSchema=ke;exports.HookEvent=o;exports.HookExecutorSchema=j;exports.HookMatcherSchema=R;exports.HookType=c;exports.HooksConfigSchema=nt;exports.HttpExecutorSchema=E;exports.LlmHeadersInputSchema=pe;exports.LlmParamsInputSchema=ae;exports.LlmParamsSchema=ie;exports.LlmProviderSchema=v;exports.LoopEndInputSchema=je;exports.LoopStartInputSchema=Ae;exports.MessageIDSchema=i;exports.MessageReceiveInputSchema=$;exports.MessageRoleSchema=N;exports.MessageSchema=T;exports.MessageTransformInputSchema=Z;exports.ModelObjectSchema=h;exports.ModelSchema=f;exports.PartIDSchema=x;exports.PermissionAskInputSchema=re;exports.PermissionDeniedInputSchema=se;exports.PermissionLevelSchema=oe;exports.PermissionRequestSchema=ne;exports.PromptExecutorSchema=w;exports.ScheduledTaskCompleteInputSchema=ve;exports.ScheduledTaskTriggerInputSchema=Te;exports.SchedulerTaskDefinitionSchema=he;exports.SessionCompactInputSchema=B;exports.SessionCompactingInputSchema=G;exports.SessionEndInputSchema=W;exports.SessionIDSchema=n;exports.SessionStartInputSchema=F;exports.ShellEnvInputSchema=ce;exports.SkillInitContextSchema=Wt;exports.SkillInitResultSchema=Gt;exports.SkillMetadataSchema=Ft;exports.StepFinishInputSchema=q;exports.StepStartInputSchema=L;exports.StepStopFailureInputSchema=U;exports.StepStopInputSchema=_;exports.SystemTransformInputSchema=V;exports.TaskCompleteInputSchema=De;exports.TaskProgressInputSchema=Ee;exports.TaskRunningInputSchema=we;exports.TaskSourceSchema=S;exports.TaskStartInputSchema=Pe;exports.TextCompleteInputSchema=me;exports.ToolAfterInputSchema=Q;exports.ToolArgsSchema=y;exports.ToolBeforeInputSchema=J;exports.ToolDefinitionInputSchema=Y;exports.ToolFailureInputSchema=X;exports.ToolResultSchema=K;exports.findMarketplace=Kt;exports.findMarketplacesByCategory=Jt;exports.getEventInputSchema=rt;exports.listMarketplaces=Vt;exports.registerMarketplace=$t;exports.safeValidateHookInput=it;exports.tool=M;exports.unregisterMarketplace=Zt;exports.validateHookInput=st;
|
|
1
|
+
'use strict';var v=require('zod'),types=require('@easbot/types');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var v__default=/*#__PURE__*/_interopDefault(v);function E(o){return {description:o.description,args:o.args,execute:o.execute}}E.schema=v__default.default;var m={Command:"command",Prompt:"prompt",Http:"http",Agent:"agent",Function:"function"},t={SessionStart:"session.start",SessionEnd:"session.end",SessionCompacting:"session.compacting",SessionCompact:"session.compact",MessageReceive:"message.receive",MessageTransform:"message.transform",SystemTransform:"system.transform",ToolBefore:"tool.before",ToolAfter:"tool.after",ToolFailure:"tool.failure",ToolDefinition:"tool.definition",CommandBefore:"command.before",CommandAfter:"command.after",PermissionAsk:"permission.ask",PermissionDenied:"permission.denied",LlmParams:"llm.params",LlmHeaders:"llm.headers",ShellEnv:"shell.env",GatewayMessageReceive:"gateway.message.receive",GatewayMessageProcess:"gateway.message.process",GatewayMessageComplete:"gateway.message.complete",GatewayMessageSend:"gateway.message.send",GatewayMessageDelivered:"gateway.message.delivered",GatewayMessageRead:"gateway.message.read",HeartbeatTrigger:"scheduler.heartbeat.trigger",HeartbeatComplete:"scheduler.heartbeat.complete",ScheduledTaskTrigger:"scheduler.task.trigger",ScheduledTaskComplete:"scheduler.task.complete",CommandTrigger:"scheduler.command.trigger",CommandComplete:"scheduler.command.complete",ContextBuildBefore:"context.build.before",ContextBuildAfter:"context.build.after",TaskStart:"task.start",TaskRunning:"task.running",TaskProgress:"task.progress",TaskComplete:"task.complete",LoopStart:"loop.start",LoopEnd:"loop.end",ProcessorStart:"processor.start",ProcessorStepStart:"processor.step.start",ProcessorReasoningStart:"processor.reasoning.start",ProcessorReasoningDelta:"processor.reasoning.delta",ProcessorReasoningEnd:"processor.reasoning.end",ProcessorToolInputStart:"processor.tool.input.start",ProcessorToolCall:"processor.tool.call",ProcessorToolResult:"processor.tool.result",ProcessorToolError:"processor.tool.error",ProcessorStepFinish:"processor.step.finish",ProcessorTextStart:"processor.text.start",ProcessorTextDelta:"processor.text.delta",ProcessorTextEnd:"processor.text.end",ProcessorError:"processor.error",ProcessorFinish:"processor.finish",CreationRequest:"creation.request",CreationComplete:"creation.complete",EvolutionRequest:"evolution.request",EvolutionComplete:"evolution.complete"},nt=Object.values(t);var f=v.z.string().optional(),M=v.z.object({type:v.z.literal(m.Command),command:v.z.string(),if:f,shell:v.z.enum(["bash","powershell"]).optional(),timeout:v.z.number().positive().optional(),statusMessage:v.z.string().optional(),once:v.z.boolean().optional(),async:v.z.boolean().optional(),allowedEnvVars:v.z.array(v.z.string()).optional()}),w=v.z.object({type:v.z.literal(m.Prompt),if:f,timeout:v.z.number().positive().optional(),model:v.z.string().optional().describe("Model identifier in provider/model format"),statusMessage:v.z.string().optional(),once:v.z.boolean().optional(),runMode:v.z.enum(["session","fork"]).optional(),system:v.z.string().optional(),parts:v.z.array(v.z.unknown()),onMessage:v.z.custom(o=>typeof o=="function").optional()}),R=v.z.object({type:v.z.literal(m.Http),url:v.z.string(),if:f,timeout:v.z.number().positive().optional(),method:v.z.enum(["GET","POST","PUT","DELETE"]).optional(),headers:v.z.record(v.z.string(),v.z.string()).optional(),allowedEnvVars:v.z.array(v.z.string()).optional(),statusMessage:v.z.string().optional(),once:v.z.boolean().optional()}),D=v.z.object({type:v.z.literal(m.Agent),if:f,timeout:v.z.number().positive().optional(),agent:v.z.string().optional(),model:v.z.string().optional().describe("Model identifier in provider/model format"),statusMessage:v.z.string().optional(),once:v.z.boolean().optional(),system:v.z.string().optional(),parts:v.z.array(v.z.unknown()),onMessage:v.z.custom(o=>typeof o=="function").optional()}),A=v.z.object({type:v.z.literal(m.Function),handler:v.z.function()}),z=v.z.discriminatedUnion("type",[M,w,R,D,A]),j=v.z.object({event:v.z.string(),matcher:v.z.string().optional(),hooks:v.z.array(z)}),ct=v.z.record(v.z.string(),v.z.array(j)),n=v.z.string().min(1).describe("Session unique identifier"),O=v.z.string().min(1).describe("Part unique identifier"),i=v.z.string().min(1).describe("Message unique identifier"),c=v.z.string().min(1).describe("Tool call unique identifier"),b=v.z.string().optional().describe("Agent name"),y=v.z.string().optional().describe("Model identifier"),h=v.z.object({providerId:v.z.string().describe("Provider ID"),modelId:v.z.string().describe("Model ID"),api:v.z.object({id:v.z.string().describe("API ID"),npm:v.z.string().optional().describe("NPM package name")}).optional().describe("API information")}).optional().describe("Model object"),S=v.z.string().optional().describe("Working directory path"),G=v.z.enum(["user_request","max_tokens","stop","error","timeout","cancelled"]).describe("Session end reason"),ut=v.z.enum(["stop","max_tokens","end_turn","stop_sequence"]).describe("Step finish reason"),B=v.z.object({sessionId:n,source:v.z.enum(["user","agent","system","scheduled"]).optional().describe("Session source"),model:y,agent:b,cwd:S}),F=v.z.object({sessionId:n,reason:G,duration:v.z.number().positive().optional().describe("Session duration in milliseconds")}),W=v.z.object({sessionId:n,trigger:v.z.enum(["manual","auto","threshold"]).describe("Compaction trigger"),contextLength:v.z.number().positive().describe("Current context length"),threshold:v.z.number().positive().describe("Trigger threshold")}),L=v.z.object({sessionId:n,summary:v.z.string().describe("Compaction summary"),previousLength:v.z.number().positive().describe("Previous context length"),newLength:v.z.number().positive().describe("New context length")}),q=v.z.enum(["user","assistant","system","tool"]),k=v.z.discriminatedUnion("type",[v.z.object({type:v.z.literal("text"),text:v.z.string().describe("Text content")}),v.z.object({type:v.z.literal("image"),source:v.z.object({type:v.z.enum(["base64","url"]),mime:v.z.string().optional().describe("File mime type"),data:v.z.string().describe("File base64 encoding data or url")})}),v.z.object({type:v.z.literal("file"),url:v.z.string().describe("File path"),filename:v.z.string().describe("File name"),mime:v.z.string().optional().describe("File mime type")})]),T=v.z.object({id:i,role:q,content:v.z.union([v.z.string(),v.z.array(k)]),name:v.z.string().optional().describe("Message sender name"),tool_call_id:c.optional().describe("Related tool call ID")}),N=v.z.object({sessionId:n,agent:b,model:y,messageId:i,message:v.z.object({id:i,role:v.z.literal("user"),content:v.z.union([v.z.string(),v.z.array(k)])}).describe("User message")}),U=v.z.object({sessionId:n,messages:v.z.array(T).describe("Messages to transform")}),_=v.z.object({sessionId:n,model:y,system:v.z.array(v.z.string()).describe("Current system prompt")}),u=v.z.record(v.z.string(),v.z.unknown()).describe("Tool call arguments"),V=v.z.object({title:v.z.string().optional().describe("Result title"),content:v.z.string().describe("Result content"),is_error:v.z.boolean().optional().describe("Is error result"),metadata:v.z.record(v.z.string(),v.z.unknown()).optional().describe("Extra metadata")}),Z=v.z.object({sessionId:n,userMessageId:i.optional().describe("User message ID for the current step"),tool:v.z.string().describe("Tool name"),callId:c,args:u}),$=v.z.object({sessionId:n,userMessageId:i.optional().describe("User message ID for the current step"),tool:v.z.string(),callId:c,args:u,result:V,duration:v.z.number().nonnegative().optional().describe("Execution duration in milliseconds")}),K=v.z.object({sessionId:n,tool:v.z.string(),callId:c,args:u,error:v.z.string().describe("Error message"),errorType:v.z.enum(["timeout","invalid_args","execution_error","permission_denied"])}),J=v.z.object({sessionId:n,toolID:v.z.string().describe("Tool ID"),definition:v.z.object({name:v.z.string(),description:v.z.string().optional(),parameters:v.z.record(v.z.string(),v.z.unknown()).optional()}).describe("Tool definition")}),Q=v.z.object({sessionId:n,command:v.z.string().describe("Command name"),arguments:v.z.union([v.z.string(),v.z.record(v.z.string(),v.z.unknown())]).describe("Command arguments")}),X=v.z.object({sessionId:n,command:v.z.string().describe("Command name"),arguments:v.z.union([v.z.string(),v.z.record(v.z.string(),v.z.unknown())]).optional(),result:v.z.object({info:v.z.unknown().optional().describe("Message info"),parts:v.z.array(v.z.unknown()).optional().describe("Message parts"),title:v.z.string().optional().describe("Result title"),metadata:v.z.record(v.z.string(),v.z.unknown()).optional().describe("Result metadata"),output:v.z.string().optional().describe("Result output"),success:v.z.boolean().optional().describe("Whether execution succeeded"),error:v.z.string().optional().describe("Error message if failed")}).describe("Command execution result")}),Y=v.z.enum(["read","write","exec","admin"]),ee=v.z.object({tool:v.z.string().describe("Tool name requesting permission"),args:u.optional(),level:Y.optional(),reason:v.z.string().optional().describe("Reason for permission request")}),te=v.z.object({sessionId:n,request:ee}),oe=v.z.object({sessionId:n,tool:v.z.string(),reason:v.z.string().optional()}),C=v.z.enum(["openai","anthropic","google","azure","custom"]),ne=v.z.object({temperature:v.z.number().min(0).max(2).optional(),topP:v.z.number().min(0).max(1).optional(),topK:v.z.number().int().positive().optional(),maxTokens:v.z.number().int().positive().optional(),stopSequences:v.z.array(v.z.string()).optional(),responseFormat:v.z.enum(["text","json_object"]).optional()}),re=v.z.object({sessionId:n,agent:b,model:h,provider:C,params:ne.partial().optional()}),se=v.z.object({sessionId:n,agent:b,model:h,provider:C,headers:v.z.record(v.z.string(),v.z.string()).optional()}),ie=v.z.object({cwd:S.describe("Working directory"),sessionId:n.optional(),callId:c.optional()}),ae=v.z.object({sessionId:n,mode:v.z.enum(["agent","chat","query"]).describe("Build mode"),providerId:v.z.string().optional()}),pe=v.z.object({sessionId:n,context:v.z.object({messages:v.z.array(T),system:v.z.array(v.z.string()),metadata:v.z.record(v.z.string(),v.z.unknown())}).describe("Built context")}),ce=v.z.object({gatewayID:v.z.string().describe("Gateway ID"),messageId:i,message:v.z.unknown().describe("Received message")}),ue=v.z.object({gatewayID:v.z.string(),messageId:i,message:v.z.unknown(),sessionId:n.optional()}),me=v.z.object({gatewayID:v.z.string(),messageId:i,result:v.z.unknown().optional()}),le=v.z.object({gatewayID:v.z.string(),messageId:i,message:v.z.unknown(),target:v.z.string().optional().describe("Send target")}),de=v.z.object({gatewayID:v.z.string(),messageId:i,sessionId:n.optional(),channel:v.z.object({platform:v.z.string(),channelId:v.z.string()}),timestamp:v.z.number().describe("Delivery timestamp")}),ge=v.z.object({gatewayID:v.z.string(),messageId:i,sessionId:n.optional(),channel:v.z.object({platform:v.z.string(),channelId:v.z.string()}),timestamp:v.z.number().describe("Read timestamp")}),fe=v.z.object({type:v.z.literal("command"),config:v.z.object({command:v.z.string(),arguments:v.z.union([v.z.string(),v.z.record(v.z.string(),v.z.unknown())]).optional()})}),be=v.z.object({type:v.z.literal("heartbeat"),parts:v.z.array(v.z.unknown()),system:v.z.string().optional(),config:v.z.object({session:v.z.string().optional(),mode:v.z.enum(["session","fork"]).optional(),agent:v.z.string().optional(),model:v.z.string().optional().describe("Model identifier in provider/model format"),tools:v.z.record(v.z.string(),v.z.boolean()).optional()}).optional()}),ye=v.z.object({type:v.z.literal("scheduler"),parts:v.z.array(v.z.unknown()),system:v.z.string().optional(),config:v.z.object({agentType:v.z.string().optional(),transport:v.z.enum(["stdio","http","websocket","cli"]).optional(),model:v.z.string().optional(),tools:v.z.record(v.z.string(),v.z.boolean()).optional()}).optional()}),Ie=v.z.object({taskId:v.z.string().describe("Heartbeat task ID"),timestamp:v.z.number().describe("Heartbeat timestamp"),name:v.z.string().optional().describe("Heartbeat name"),definition:be.optional()}),xe=v.z.object({taskId:v.z.string().describe("Heartbeat task ID"),sessionId:n.optional(),timestamp:v.z.number(),duration:v.z.number().nonnegative().optional(),success:v.z.boolean().optional(),error:v.z.string().optional()}),he=v.z.object({taskId:v.z.string().describe("Task ID"),taskName:v.z.string().optional(),timestamp:v.z.number(),payload:v.z.record(v.z.string(),v.z.unknown()).optional(),definition:ye.optional()}),Se=v.z.object({taskId:v.z.string(),timestamp:v.z.number(),success:v.z.boolean(),result:v.z.record(v.z.string(),v.z.unknown()).optional(),error:v.z.string().optional()}),ke=v.z.object({taskId:v.z.string().describe("Command task unique identifier"),taskName:v.z.string().describe("Command task name"),command:v.z.string().describe("Command name"),arguments:v.z.union([v.z.string(),v.z.record(v.z.string(),v.z.unknown())]).optional().describe("Command arguments"),timestamp:v.z.number().describe("Trigger timestamp"),definition:fe.optional()}),Te=v.z.object({taskId:v.z.string(),timestamp:v.z.number(),success:v.z.boolean(),output:v.z.string().optional(),error:v.z.string().optional(),duration:v.z.number().describe("Execution duration in milliseconds")}),I=v.z.enum(["tool","scheduler","cli","api"]),Ce=v.z.object({taskId:v.z.string().describe("Task unique identifier"),sessionId:v.z.string().describe("Session ID for this task"),source:I.describe("Task source: tool, scheduler, cli, api"),agentType:v.z.string().describe("Agent type to execute this task"),description:v.z.string().describe("Task description"),prompt:v.z.string().describe("Task prompt content"),timeout:v.z.number().positive().optional().describe("Task timeout in milliseconds")}),Pe=v.z.object({taskId:v.z.string().describe("Task unique identifier"),sessionId:v.z.string().describe("Session ID for this task"),source:I.describe("Task source: tool, scheduler, cli, api")}),ve=v.z.object({taskId:v.z.string(),sessionId:v.z.string(),source:I,step:v.z.number().describe("Current step number"),totalSteps:v.z.number().optional().describe("Total number of steps"),output:v.z.string().describe("Progress output content"),timestamp:v.z.number().describe("Progress timestamp")}),Ee=v.z.object({taskId:v.z.string(),sessionId:v.z.string(),source:I,result:v.z.string().describe("Task result content"),duration:v.z.number().nonnegative().describe("Task duration in milliseconds"),attachments:v.z.array(v.z.unknown()).optional().describe("Task result attachments"),error:v.z.string().optional().describe("Error message if task failed"),agentType:v.z.string().optional().describe("Agent type that executed the task"),metadata:v.z.record(v.z.string(),v.z.unknown()).optional().describe("Additional metadata for the task result")}),He=v.z.object({sessionId:v.z.string().describe("Session ID"),step:v.z.number().describe("Current step number"),lastUserId:v.z.string().describe("Last user message ID"),result:v.z.enum(["start","continue","stop"]).optional().describe("Loop result: start, continue, or stop")}),Me=v.z.object({sessionId:v.z.string().describe("Session ID"),step:v.z.number().describe("Current step number"),lastUserId:v.z.string().describe("Last user message ID"),result:v.z.enum(["stop","continue"]).describe("Loop result: stop or continue")}),we=v.z.object({requestId:v.z.string(),kind:v.z.enum(["create-skill","create-workflow","create-bundle"]),requirement:v.z.string(),hints:v.z.array(v.z.string()),origin:v.z.object({source:v.z.enum(["human","tool","scheduler","namespace"]).optional(),timestamp:v.z.number().int().nonnegative()})}),Re=v.z.object({requestId:v.z.string(),status:v.z.enum(["success","failed"]),specId:v.z.string().optional(),durationMs:v.z.number().int().nonnegative(),error:v.z.string().optional()}),De=v.z.object({dryRun:v.z.boolean()}),Ae=v.z.object({status:v.z.enum(["success","failed","awaiting-approval"]),applied:v.z.number().int().nonnegative().optional(),awaitingApproval:v.z.number().int().nonnegative().optional(),error:v.z.string().optional()}),r=v.z.object({streamId:v.z.string().describe("Unique id of one stream invocation"),step:v.z.number().int().nonnegative().describe("Step index (1-based, 0 before first step)"),agent:v.z.string().describe("Agent name that initiated this stream invocation"),sessionId:v.z.string().describe("Session id passed in by the application layer"),messageId:i.describe("Assistant message id created by the processor, constant within one process() call"),userMessageId:i.describe("User message id that triggered this response, equals assistant.parentId"),model:y}),a={partId:O.describe("Part id allocated and maintained by the processor")},ze=r,je=r.extend(a),Oe=r.extend({...a,reasoningId:v.z.string().describe("Provider-side reasoning block id"),text:v.z.string().describe("Reasoning text so far (empty at start)")}),Ge=r.extend({...a,reasoningId:v.z.string().describe("Provider-side reasoning block id"),delta:v.z.string().describe("Incremental reasoning text"),text:v.z.string().describe("Accumulated reasoning text")}),Be=r.extend({...a,reasoningId:v.z.string().describe("Provider-side reasoning block id"),text:v.z.string().describe("Accumulated reasoning text (trimmed)")}),Fe=r.extend({...a,callId:c,tool:v.z.string().describe("Tool name")}),We=r.extend({...a,callId:c,tool:v.z.string().describe("Tool name"),args:u}),Le=r.extend({...a,callId:c,tool:v.z.string().describe("Tool name"),args:u,title:v.z.string().optional().describe("Result title"),output:v.z.unknown().describe("Tool output payload"),metadata:v.z.record(v.z.string(),v.z.unknown()).optional(),durationMs:v.z.number().nonnegative().describe("Tool execution duration")}),qe=r.extend({...a,callId:c,tool:v.z.string().describe("Tool name"),args:u,error:v.z.string().describe("Error message"),errorName:v.z.string().optional().describe("Named error name"),durationMs:v.z.number().nonnegative().describe("Tool execution duration")}),Ne=r.extend({...a,reason:v.z.string().optional().describe("Finish reason reported by provider"),tokens:types.UsageSchema.optional().describe("Normalized token usage"),cost:v.z.number().nonnegative().optional().describe("Estimated cost of this step")}),Ue=r.extend({...a,text:v.z.string().describe("Text so far (empty at start)")}),_e=r.extend({...a,delta:v.z.string().describe("Incremental text"),text:v.z.string().describe("Accumulated text")}),Ve=r.extend({...a,text:v.z.string().describe("Accumulated text (trimmed)")}),Ze=r.extend({error:v.z.string().describe("Error message"),errorName:v.z.string().optional().describe("Named error name"),aborted:v.z.boolean().optional().describe("Whether aborted by signal")}),$e=r.extend({result:v.z.enum(["stop","continue","compact"]).describe("Processor loop verdict"),cost:v.z.number().nonnegative().optional().describe("Accumulated cost of this stream"),tokens:v.z.number().nonnegative().optional().describe("Accumulated tokens of this stream")}),x={[t.SessionStart]:B,[t.SessionEnd]:F,[t.SessionCompacting]:W,[t.SessionCompact]:L,[t.MessageReceive]:N,[t.MessageTransform]:U,[t.SystemTransform]:_,[t.ToolBefore]:Z,[t.ToolAfter]:$,[t.ToolFailure]:K,[t.ToolDefinition]:J,[t.CommandBefore]:Q,[t.CommandAfter]:X,[t.PermissionAsk]:te,[t.PermissionDenied]:oe,[t.LlmParams]:re,[t.LlmHeaders]:se,[t.ShellEnv]:ie,[t.ContextBuildBefore]:ae,[t.ContextBuildAfter]:pe,[t.GatewayMessageReceive]:ce,[t.GatewayMessageProcess]:ue,[t.GatewayMessageComplete]:me,[t.GatewayMessageSend]:le,[t.GatewayMessageDelivered]:de,[t.GatewayMessageRead]:ge,[t.HeartbeatTrigger]:Ie,[t.HeartbeatComplete]:xe,[t.ScheduledTaskTrigger]:he,[t.ScheduledTaskComplete]:Se,[t.CommandTrigger]:ke,[t.CommandComplete]:Te,[t.TaskStart]:Ce,[t.TaskRunning]:Pe,[t.TaskProgress]:ve,[t.TaskComplete]:Ee,[t.LoopStart]:He,[t.LoopEnd]:Me,[t.ProcessorStart]:ze,[t.ProcessorStepStart]:je,[t.ProcessorReasoningStart]:Oe,[t.ProcessorReasoningDelta]:Ge,[t.ProcessorReasoningEnd]:Be,[t.ProcessorToolInputStart]:Fe,[t.ProcessorToolCall]:We,[t.ProcessorToolResult]:Le,[t.ProcessorToolError]:qe,[t.ProcessorStepFinish]:Ne,[t.ProcessorTextStart]:Ue,[t.ProcessorTextDelta]:_e,[t.ProcessorTextEnd]:Ve,[t.ProcessorError]:Ze,[t.ProcessorFinish]:$e,[t.CreationRequest]:we,[t.CreationComplete]:Re,[t.EvolutionRequest]:De,[t.EvolutionComplete]:Ae};function mt(o){return x[o]}function lt(o,d){let g=x[o];if(!g)throw new Error(`No schema found for event: ${o}`);return g.parse(d)}function dt(o,d){let g=x[o];return g?g.safeParse(d):{success:false,error:new v.z.ZodError([{code:"custom",path:[],message:`No schema found for event: ${o}`}])}}var Nt=v.z.enum(["subagent","primary","all"]),Ut=v.z.enum(["general","coder","all"]),_t=types.AgentInfoSchema;var Xt=v.z.object({name:v.z.string().min(1).describe("Unique skill name"),description:v.z.string().min(1).describe("When to use this skill"),scope:v.z.enum(["general","coder","all"]).optional().describe("Context mode scope")}),Yt=v.z.object({agent:v.z.object({name:v.z.string().describe("Agent name"),model:v.z.string().optional().describe("Agent model in provider/model format")}).optional().describe("Agent context")}),eo=v.z.object({isEnabled:v.z.boolean().optional().describe("Is enabled check result")});var l=new Map;function ao(o){if(l.has(o.id))throw new Error(`Marketplace with id "${o.id}" already registered`);l.set(o.id,o);}function po(o){return l.delete(o)}function co(){return Array.from(l.values()).map(o=>o)}function uo(o){return l.get(o)??null}function mo(o){return Array.from(l.values()).filter(d=>d.category===o)}Object.defineProperty(exports,"AgentInfoSchema",{enumerable:true,get:function(){return types.AgentInfoSchema}});Object.defineProperty(exports,"AgentModelSchema",{enumerable:true,get:function(){return types.AgentModelSchema}});Object.defineProperty(exports,"AgentPermissionSchema",{enumerable:true,get:function(){return types.AgentPermissionSchema}});Object.defineProperty(exports,"CommandArgumentsSchema",{enumerable:true,get:function(){return types.CommandArgumentsSchema}});Object.defineProperty(exports,"CommandConfigInfoSchema",{enumerable:true,get:function(){return types.CommandConfigInfoSchema}});Object.defineProperty(exports,"CommandExecuteResultMetadataSchema",{enumerable:true,get:function(){return types.CommandExecuteResultMetadataSchema}});Object.defineProperty(exports,"CommandExecuteResultSchema",{enumerable:true,get:function(){return types.CommandExecuteResultSchema}});Object.defineProperty(exports,"CommandExecutionContextSchema",{enumerable:true,get:function(){return types.CommandExecutionContextSchema}});Object.defineProperty(exports,"CommandInfoSchema",{enumerable:true,get:function(){return types.CommandInfoSchema}});Object.defineProperty(exports,"CommandInitContextSchema",{enumerable:true,get:function(){return types.CommandInitContextSchema}});Object.defineProperty(exports,"CommandInitResultSchema",{enumerable:true,get:function(){return types.CommandInitResultSchema}});Object.defineProperty(exports,"CommandMetadataSchema",{enumerable:true,get:function(){return types.CommandMetadataSchema}});Object.defineProperty(exports,"CommandPromptPartSchema",{enumerable:true,get:function(){return types.CommandPromptPartSchema}});Object.defineProperty(exports,"CommandSourceSchema",{enumerable:true,get:function(){return types.CommandSourceSchema}});Object.defineProperty(exports,"PermissionActionSchema",{enumerable:true,get:function(){return types.PermissionActionSchema}});Object.defineProperty(exports,"PermissionRuleSchema",{enumerable:true,get:function(){return types.PermissionRuleSchema}});Object.defineProperty(exports,"buildToolArgs",{enumerable:true,get:function(){return types.buildToolArgs}});Object.defineProperty(exports,"createTool",{enumerable:true,get:function(){return types.createTool}});Object.defineProperty(exports,"schema",{enumerable:true,get:function(){return types.toolSchema}});exports.AgentExecutorSchema=D;exports.AgentMetadataSchema=_t;exports.AgentModeSchema=Nt;exports.AgentSchema=b;exports.AgentScopeSchema=Ut;exports.CallIDSchema=c;exports.CommandAfterInputSchema=X;exports.CommandBeforeInputSchema=Q;exports.CommandCompleteInputSchema=Te;exports.CommandExecutorSchema=M;exports.CommandTaskDefinitionSchema=fe;exports.CommandTriggerInputSchema=ke;exports.ContentPartSchema=k;exports.ContextBuildAfterInputSchema=pe;exports.ContextBuildBeforeInputSchema=ae;exports.CreationCompleteInputSchema=Re;exports.CreationRequestInputSchema=we;exports.CwdSchema=S;exports.EndReasonSchema=G;exports.EventInputSchemas=x;exports.EvolutionCompleteInputSchema=Ae;exports.EvolutionRequestInputSchema=De;exports.FinishReasonSchema=ut;exports.FunctionExecutorSchema=A;exports.GatewayMessageCompleteInputSchema=me;exports.GatewayMessageDeliveredInputSchema=de;exports.GatewayMessageProcessInputSchema=ue;exports.GatewayMessageReadInputSchema=ge;exports.GatewayMessageReceiveInputSchema=ce;exports.GatewayMessageSendInputSchema=le;exports.HOOK_EVENTS=nt;exports.HeartbeatCompleteInputSchema=xe;exports.HeartbeatTaskDefinitionSchema=be;exports.HeartbeatTriggerInputSchema=Ie;exports.HookEvent=t;exports.HookExecutorSchema=z;exports.HookMatcherSchema=j;exports.HookType=m;exports.HooksConfigSchema=ct;exports.HttpExecutorSchema=R;exports.LlmHeadersInputSchema=se;exports.LlmParamsInputSchema=re;exports.LlmParamsSchema=ne;exports.LlmProviderSchema=C;exports.LoopEndInputSchema=Me;exports.LoopStartInputSchema=He;exports.MessageIDSchema=i;exports.MessageReceiveInputSchema=N;exports.MessageRoleSchema=q;exports.MessageSchema=T;exports.MessageTransformInputSchema=U;exports.ModelObjectSchema=h;exports.ModelSchema=y;exports.PartIDSchema=O;exports.PermissionAskInputSchema=te;exports.PermissionDeniedInputSchema=oe;exports.PermissionLevelSchema=Y;exports.PermissionRequestSchema=ee;exports.ProcessorErrorInputSchema=Ze;exports.ProcessorFinishInputSchema=$e;exports.ProcessorReasoningDeltaInputSchema=Ge;exports.ProcessorReasoningEndInputSchema=Be;exports.ProcessorReasoningStartInputSchema=Oe;exports.ProcessorStartInputSchema=ze;exports.ProcessorStepFinishInputSchema=Ne;exports.ProcessorStepStartInputSchema=je;exports.ProcessorTextDeltaInputSchema=_e;exports.ProcessorTextEndInputSchema=Ve;exports.ProcessorTextStartInputSchema=Ue;exports.ProcessorToolCallInputSchema=We;exports.ProcessorToolErrorInputSchema=qe;exports.ProcessorToolInputStartInputSchema=Fe;exports.ProcessorToolResultInputSchema=Le;exports.PromptExecutorSchema=w;exports.ScheduledTaskCompleteInputSchema=Se;exports.ScheduledTaskTriggerInputSchema=he;exports.SchedulerTaskDefinitionSchema=ye;exports.SessionCompactInputSchema=L;exports.SessionCompactingInputSchema=W;exports.SessionEndInputSchema=F;exports.SessionIDSchema=n;exports.SessionStartInputSchema=B;exports.ShellEnvInputSchema=ie;exports.SkillInitContextSchema=Yt;exports.SkillInitResultSchema=eo;exports.SkillMetadataSchema=Xt;exports.SystemTransformInputSchema=_;exports.TaskCompleteInputSchema=Ee;exports.TaskProgressInputSchema=ve;exports.TaskRunningInputSchema=Pe;exports.TaskSourceSchema=I;exports.TaskStartInputSchema=Ce;exports.ToolAfterInputSchema=$;exports.ToolArgsSchema=u;exports.ToolBeforeInputSchema=Z;exports.ToolDefinitionInputSchema=J;exports.ToolFailureInputSchema=K;exports.ToolResultSchema=V;exports.findMarketplace=uo;exports.findMarketplacesByCategory=mo;exports.getEventInputSchema=mt;exports.listMarketplaces=co;exports.registerMarketplace=ao;exports.safeValidateHookInput=dt;exports.tool=E;exports.unregisterMarketplace=po;exports.validateHookInput=lt;
|