@downcity/agent 1.1.152 → 1.1.157
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/bin/agent/local/services/AgentAssemblyService.d.ts.map +1 -1
- package/bin/agent/local/services/AgentAssemblyService.js +1 -0
- package/bin/agent/local/services/AgentAssemblyService.js.map +1 -1
- package/bin/executor/composer/system/default/assets/plugin.prompt.d.ts +1 -1
- package/bin/executor/composer/system/default/assets/plugin.prompt.d.ts.map +1 -1
- package/bin/executor/composer/system/default/assets/plugin.prompt.js +1 -1
- package/bin/executor/composer/system/default/assets/plugin.prompt.js.map +1 -1
- package/bin/executor/tools/plugin/PluginToolBridge.d.ts +6 -2
- package/bin/executor/tools/plugin/PluginToolBridge.d.ts.map +1 -1
- package/bin/executor/tools/plugin/PluginToolBridge.js +71 -17
- package/bin/executor/tools/plugin/PluginToolBridge.js.map +1 -1
- package/bin/executor/tools/plugin/PluginToolDefinition.d.ts +11 -0
- package/bin/executor/tools/plugin/PluginToolDefinition.d.ts.map +1 -1
- package/bin/executor/tools/plugin/PluginToolDefinition.js +12 -3
- package/bin/executor/tools/plugin/PluginToolDefinition.js.map +1 -1
- package/bin/executor/tools/plugin/PluginToolSchemas.d.ts +4 -0
- package/bin/executor/tools/plugin/PluginToolSchemas.d.ts.map +1 -1
- package/bin/executor/tools/plugin/PluginToolSchemas.js +11 -1
- package/bin/executor/tools/plugin/PluginToolSchemas.js.map +1 -1
- package/bin/executor/tools/plugin/types/PluginTool.d.ts +37 -0
- package/bin/executor/tools/plugin/types/PluginTool.d.ts.map +1 -1
- package/bin/index.d.ts +3 -1
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +1 -0
- package/bin/index.js.map +1 -1
- package/bin/plugin/core/PluginActionFactory.d.ts +99 -0
- package/bin/plugin/core/PluginActionFactory.d.ts.map +1 -0
- package/bin/plugin/core/PluginActionFactory.js +59 -0
- package/bin/plugin/core/PluginActionFactory.js.map +1 -0
- package/bin/plugin/core/PluginActionRunner.d.ts.map +1 -1
- package/bin/plugin/core/PluginActionRunner.js +14 -1
- package/bin/plugin/core/PluginActionRunner.js.map +1 -1
- package/bin/plugin/core/PluginLocalExecution.d.ts.map +1 -1
- package/bin/plugin/core/PluginLocalExecution.js +15 -1
- package/bin/plugin/core/PluginLocalExecution.js.map +1 -1
- package/bin/plugin/core/PluginRegistry.d.ts +18 -1
- package/bin/plugin/core/PluginRegistry.d.ts.map +1 -1
- package/bin/plugin/core/PluginRegistry.js +74 -1
- package/bin/plugin/core/PluginRegistry.js.map +1 -1
- package/bin/plugin/types/Plugin.d.ts +2 -2
- package/bin/plugin/types/Plugin.d.ts.map +1 -1
- package/bin/types/plugin/PluginAction.d.ts +40 -2
- package/bin/types/plugin/PluginAction.d.ts.map +1 -1
- package/bin/types/plugin/PluginRuntime.d.ts +44 -0
- package/bin/types/plugin/PluginRuntime.d.ts.map +1 -1
- package/package.json +3 -3
- package/scripts/image-plugin-job.test.mjs +308 -32
- package/scripts/plugin-tool-bridge.test.mjs +199 -0
- package/src/agent/local/services/AgentAssemblyService.ts +1 -0
- package/src/executor/composer/system/default/assets/plugin.prompt.ts +1 -1
- package/src/executor/composer/system/default/assets/plugin.prompt.ts.txt +3 -2
- package/src/executor/tools/plugin/PluginToolBridge.ts +84 -18
- package/src/executor/tools/plugin/PluginToolDefinition.ts +25 -4
- package/src/executor/tools/plugin/PluginToolSchemas.ts +12 -1
- package/src/executor/tools/plugin/types/PluginTool.ts +40 -0
- package/src/index.ts +11 -0
- package/src/plugin/core/PluginActionFactory.ts +185 -0
- package/src/plugin/core/PluginActionRunner.ts +14 -1
- package/src/plugin/core/PluginLocalExecution.ts +15 -1
- package/src/plugin/core/PluginRegistry.ts +89 -1
- package/src/plugin/types/Plugin.ts +5 -0
- package/src/types/plugin/PluginAction.ts +43 -2
- package/src/types/plugin/PluginRuntime.ts +44 -0
- package/tsconfig.tsbuildinfo +1 -1
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
|
|
9
9
|
import type { Command } from "commander";
|
|
10
10
|
import type { Context as HonoContext } from "hono";
|
|
11
|
+
import type { z } from "zod";
|
|
11
12
|
import type { AgentContext } from "@/types/runtime/agent/AgentContext.js";
|
|
12
|
-
import type { JsonValue } from "@/types/common/Json.js";
|
|
13
|
+
import type { JsonObject, JsonValue } from "@/types/common/Json.js";
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Plugin action 调用参数。
|
|
@@ -93,13 +94,51 @@ export interface PluginActionApi<P extends JsonValue = JsonValue> {
|
|
|
93
94
|
mapInput?: (ctx: HonoContext) => P | Promise<P>;
|
|
94
95
|
}
|
|
95
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Plugin Action 示例。
|
|
99
|
+
*/
|
|
100
|
+
export interface PluginActionExample<P extends JsonValue = JsonValue> {
|
|
101
|
+
/** 示例标题。 */
|
|
102
|
+
title: string;
|
|
103
|
+
/** 示例说明。 */
|
|
104
|
+
description?: string;
|
|
105
|
+
/** 示例 payload。 */
|
|
106
|
+
payload: P;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* Plugin Action 输入 schema。
|
|
111
|
+
*
|
|
112
|
+
* 关键点(中文)
|
|
113
|
+
* - 优先支持 Zod,运行时用 safeParse 做校验。
|
|
114
|
+
* - `json_schema` 用于给模型或 UI 读取;没有时仍可依赖 description/examples。
|
|
115
|
+
*/
|
|
116
|
+
export interface PluginActionInputSchema<P extends JsonValue = JsonValue> {
|
|
117
|
+
/** Zod schema,负责运行时校验与 TypeScript 推导。 */
|
|
118
|
+
zod?: z.ZodTypeAny;
|
|
119
|
+
/** 面向模型和 UI 的 JSON Schema 描述。 */
|
|
120
|
+
json_schema?: JsonObject;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Plugin Action 元数据。
|
|
125
|
+
*/
|
|
126
|
+
export interface PluginActionMetadata<P extends JsonValue = JsonValue> {
|
|
127
|
+
/** Action 用途说明。 */
|
|
128
|
+
description?: string;
|
|
129
|
+
/** Action 输入 schema。 */
|
|
130
|
+
input_schema?: PluginActionInputSchema<P>;
|
|
131
|
+
/** Action 调用示例。 */
|
|
132
|
+
examples?: PluginActionExample<P>[];
|
|
133
|
+
}
|
|
134
|
+
|
|
96
135
|
/**
|
|
97
136
|
* Plugin Action 定义。
|
|
98
137
|
*/
|
|
99
138
|
export interface PluginAction<
|
|
100
139
|
P extends JsonValue = JsonValue,
|
|
101
140
|
R extends JsonValue = JsonValue,
|
|
102
|
-
> {
|
|
141
|
+
> extends PluginActionMetadata<P> {
|
|
103
142
|
/**
|
|
104
143
|
* disabled 状态下是否仍允许执行。
|
|
105
144
|
*
|
|
@@ -118,6 +157,8 @@ export interface PluginAction<
|
|
|
118
157
|
context: AgentContext;
|
|
119
158
|
/** 输入 payload。 */
|
|
120
159
|
payload: P;
|
|
160
|
+
/** 已通过 schema 校验后的输入。 */
|
|
161
|
+
input: P;
|
|
121
162
|
/** 当前插件名称。 */
|
|
122
163
|
pluginName: string;
|
|
123
164
|
/** 当前 Action 名称。 */
|
|
@@ -12,6 +12,7 @@ import type {
|
|
|
12
12
|
} from "@/types/runtime/agent/AgentContext.js";
|
|
13
13
|
import type { JsonValue } from "@/types/common/Json.js";
|
|
14
14
|
import type { PluginActionResult } from "@/types/plugin/PluginAction.js";
|
|
15
|
+
import type { PluginActionExample } from "@/types/plugin/PluginAction.js";
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Plugin 概览视图。
|
|
@@ -39,6 +40,42 @@ export interface PluginView {
|
|
|
39
40
|
hasAvailability: boolean;
|
|
40
41
|
}
|
|
41
42
|
|
|
43
|
+
/**
|
|
44
|
+
* Plugin Action 读取视图。
|
|
45
|
+
*/
|
|
46
|
+
export interface PluginActionReadView {
|
|
47
|
+
/** Action 名称。 */
|
|
48
|
+
name: string;
|
|
49
|
+
/** Action 用途说明。 */
|
|
50
|
+
description: string;
|
|
51
|
+
/** 是否声明输入 schema。 */
|
|
52
|
+
has_input_schema: boolean;
|
|
53
|
+
/** JSON Schema 形式的输入说明。 */
|
|
54
|
+
input_schema?: JsonValue;
|
|
55
|
+
/** Action 调用示例。 */
|
|
56
|
+
examples?: PluginActionExample[];
|
|
57
|
+
/** disabled 状态下是否仍允许执行。 */
|
|
58
|
+
allow_when_disabled: boolean;
|
|
59
|
+
/** 是否声明 CLI command。 */
|
|
60
|
+
has_command: boolean;
|
|
61
|
+
/** 是否声明 HTTP API。 */
|
|
62
|
+
has_api: boolean;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Plugin 读取视图。
|
|
67
|
+
*/
|
|
68
|
+
export interface PluginReadView {
|
|
69
|
+
/** Plugin 稳定名称。 */
|
|
70
|
+
name: string;
|
|
71
|
+
/** Plugin 展示标题。 */
|
|
72
|
+
title: string;
|
|
73
|
+
/** Plugin 用途说明。 */
|
|
74
|
+
description: string;
|
|
75
|
+
/** Action 列表或指定 action。 */
|
|
76
|
+
actions: PluginActionReadView[];
|
|
77
|
+
}
|
|
78
|
+
|
|
42
79
|
/**
|
|
43
80
|
* Plugin 可用性结果。
|
|
44
81
|
*/
|
|
@@ -57,6 +94,13 @@ export interface PluginAvailability {
|
|
|
57
94
|
export interface AgentPlugins {
|
|
58
95
|
/** 列出全部已注册 plugin。 */
|
|
59
96
|
list(): PluginView[];
|
|
97
|
+
/** 读取 plugin / action metadata。 */
|
|
98
|
+
read(params: {
|
|
99
|
+
/** Plugin 名称。 */
|
|
100
|
+
plugin?: string;
|
|
101
|
+
/** Action 名称。 */
|
|
102
|
+
action?: string;
|
|
103
|
+
}): PluginReadView | { plugins: PluginView[] };
|
|
60
104
|
/** 检查指定 plugin 可用性。 */
|
|
61
105
|
availability(pluginName: string): Promise<PluginAvailability>;
|
|
62
106
|
/** 运行指定 plugin action。 */
|