@downcity/agent 1.1.100 → 1.1.104
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/Agent.d.ts +2 -2
- package/bin/agent/local/Agent.d.ts.map +1 -1
- package/bin/agent/local/Agent.js.map +1 -1
- package/bin/agent/local/AgentPluginFactory.d.ts +1 -6
- package/bin/agent/local/AgentPluginFactory.d.ts.map +1 -1
- package/bin/agent/local/AgentPluginFactory.js +1 -19
- package/bin/agent/local/AgentPluginFactory.js.map +1 -1
- package/bin/agent/local/AgentRuntimeFactory.d.ts +2 -2
- package/bin/agent/local/AgentRuntimeFactory.d.ts.map +1 -1
- package/bin/agent/local/services/AgentAssemblyService.d.ts +4 -4
- package/bin/agent/local/services/AgentAssemblyService.d.ts.map +1 -1
- package/bin/agent/local/services/AgentAssemblyService.js +5 -6
- package/bin/agent/local/services/AgentAssemblyService.js.map +1 -1
- package/bin/config/AgentInitializer.d.ts.map +1 -1
- package/bin/config/AgentInitializer.js +6 -12
- package/bin/config/AgentInitializer.js.map +1 -1
- package/bin/config/DowncitySchema.d.ts.map +1 -1
- package/bin/config/DowncitySchema.js +0 -8
- package/bin/config/DowncitySchema.js.map +1 -1
- package/bin/executor/composer/system/default/assets/core.prompt.d.ts +1 -1
- package/bin/executor/composer/system/default/assets/core.prompt.d.ts.map +1 -1
- package/bin/executor/composer/system/default/assets/core.prompt.js +1 -1
- package/bin/executor/composer/system/default/assets/core.prompt.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/composer/system/default/assets/task.prompt.d.ts +1 -1
- package/bin/executor/composer/system/default/assets/task.prompt.d.ts.map +1 -1
- package/bin/executor/composer/system/default/assets/task.prompt.js +1 -1
- package/bin/executor/composer/system/default/assets/task.prompt.js.map +1 -1
- package/bin/executor/messages/AssistantFileResource.d.ts +3 -2
- package/bin/executor/messages/AssistantFileResource.d.ts.map +1 -1
- package/bin/executor/messages/AssistantFileResource.js +88 -20
- package/bin/executor/messages/AssistantFileResource.js.map +1 -1
- package/bin/executor/tools/plugin/PluginToolBridge.d.ts +3 -3
- package/bin/executor/tools/plugin/PluginToolBridge.d.ts.map +1 -1
- package/bin/executor/tools/plugin/PluginToolBridge.js +1 -1
- package/bin/executor/tools/plugin/PluginToolBridge.js.map +1 -1
- package/bin/index.d.ts +1 -3
- package/bin/index.d.ts.map +1 -1
- package/bin/index.js +0 -1
- package/bin/index.js.map +1 -1
- package/bin/plugin/core/BasePlugin.d.ts +0 -14
- package/bin/plugin/core/BasePlugin.d.ts.map +1 -1
- package/bin/plugin/core/BasePlugin.js +0 -22
- package/bin/plugin/core/BasePlugin.js.map +1 -1
- package/bin/plugin/core/Manager.d.ts +1 -1
- package/bin/plugin/core/Manager.d.ts.map +1 -1
- package/bin/plugin/core/Manager.js +1 -1
- package/bin/plugin/core/Manager.js.map +1 -1
- package/bin/plugin/core/PluginRegistry.d.ts +2 -2
- package/bin/plugin/core/PluginRegistry.d.ts.map +1 -1
- package/bin/plugin/core/PluginRegistry.js.map +1 -1
- package/bin/plugin/core/PluginStateController.d.ts +1 -9
- package/bin/plugin/core/PluginStateController.d.ts.map +1 -1
- package/bin/plugin/core/PluginStateController.js +0 -12
- package/bin/plugin/core/PluginStateController.js.map +1 -1
- package/bin/plugin/types/Plugin.d.ts +1 -1
- package/bin/plugin/types/Plugin.d.ts.map +1 -1
- package/bin/types/config/DowncityConfig.d.ts +2 -23
- package/bin/types/config/DowncityConfig.d.ts.map +1 -1
- package/bin/types/plugin/PluginRuntime.d.ts +2 -2
- package/bin/types/plugin/PluginRuntime.d.ts.map +1 -1
- package/bin/types/runtime/agent/AgentContext.d.ts +2 -2
- package/bin/types/runtime/agent/AgentContext.d.ts.map +1 -1
- package/package.json +2 -2
- package/scripts/image-plugin-job.test.mjs +21 -9
- package/src/agent/local/Agent.ts +2 -2
- package/src/agent/local/AgentPluginFactory.ts +1 -33
- package/src/agent/local/AgentRuntimeFactory.ts +2 -2
- package/src/agent/local/services/AgentAssemblyService.ts +6 -9
- package/src/config/AgentInitializer.ts +6 -12
- package/src/config/DowncitySchema.ts +0 -8
- package/src/executor/composer/system/default/assets/core.prompt.ts +1 -1
- package/src/executor/composer/system/default/assets/core.prompt.ts.txt +3 -3
- package/src/executor/composer/system/default/assets/plugin.prompt.ts +1 -1
- package/src/executor/composer/system/default/assets/plugin.prompt.ts.txt +12 -22
- package/src/executor/composer/system/default/assets/task.prompt.ts +1 -1
- package/src/executor/composer/system/default/assets/task.prompt.ts.txt +1 -1
- package/src/executor/messages/AssistantFileResource.ts +111 -22
- package/src/executor/tools/plugin/PluginToolBridge.ts +5 -5
- package/src/index.ts +1 -11
- package/src/plugin/core/BasePlugin.ts +0 -27
- package/src/plugin/core/Manager.ts +0 -2
- package/src/plugin/core/PluginRegistry.ts +2 -1
- package/src/plugin/core/PluginStateController.ts +0 -15
- package/src/plugin/types/Plugin.ts +1 -1
- package/src/types/config/DowncityConfig.ts +1 -24
- package/src/types/plugin/PluginRuntime.ts +2 -2
- package/src/types/runtime/agent/AgentContext.ts +2 -2
- package/tsconfig.tsbuildinfo +1 -1
- package/bin/plugin/core/ImagePlugin.d.ts +0 -57
- package/bin/plugin/core/ImagePlugin.d.ts.map +0 -1
- package/bin/plugin/core/ImagePlugin.js +0 -112
- package/bin/plugin/core/ImagePlugin.js.map +0 -1
- package/bin/types/plugin/ImagePlugin.d.ts +0 -94
- package/bin/types/plugin/ImagePlugin.d.ts.map +0 -1
- package/bin/types/plugin/ImagePlugin.js +0 -10
- package/bin/types/plugin/ImagePlugin.js.map +0 -1
- package/src/plugin/core/ImagePlugin.ts +0 -132
- package/src/types/plugin/ImagePlugin.ts +0 -103
|
@@ -3,13 +3,14 @@
|
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
5
|
* - 只处理运行期产生的 assistant file part,不参与 user 附件注入。
|
|
6
|
-
* - 将
|
|
6
|
+
* - 将 data URL、远程 URL 与本地文件统一写入 `.downcity/resources`。
|
|
7
|
+
* - 历史中只保留 `resources://<project-relative-path>`,避免暴露本机绝对路径。
|
|
7
8
|
* - 资源文件按内容 hash 命名,天然去重并避免重复写入大文件。
|
|
8
9
|
*/
|
|
9
10
|
|
|
10
11
|
import crypto from "node:crypto";
|
|
11
12
|
import path from "node:path";
|
|
12
|
-
import {
|
|
13
|
+
import { fileURLToPath } from "node:url";
|
|
13
14
|
import fs from "fs-extra";
|
|
14
15
|
import type { FileUIPart } from "ai";
|
|
15
16
|
import { getDowncityResourcesDirPath } from "@/config/Paths.js";
|
|
@@ -92,6 +93,23 @@ function extension_from_filename(filename: string | undefined): string {
|
|
|
92
93
|
return /^[.][a-z0-9]+$/u.test(ext) ? ext : "";
|
|
93
94
|
}
|
|
94
95
|
|
|
96
|
+
function filename_from_url(raw_url: string): string | undefined {
|
|
97
|
+
try {
|
|
98
|
+
const parsed = new URL(raw_url);
|
|
99
|
+
return path.basename(decodeURIComponent(parsed.pathname)) || undefined;
|
|
100
|
+
} catch {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function to_resources_url(projectRoot: string, filePath: string): string {
|
|
106
|
+
const relative = path
|
|
107
|
+
.relative(projectRoot, filePath)
|
|
108
|
+
.split(path.sep)
|
|
109
|
+
.join("/");
|
|
110
|
+
return `resources://${relative}`;
|
|
111
|
+
}
|
|
112
|
+
|
|
95
113
|
async function write_resource_file(params: {
|
|
96
114
|
projectRoot: string;
|
|
97
115
|
mediaType: string;
|
|
@@ -117,8 +135,97 @@ async function write_resource_file(params: {
|
|
|
117
135
|
return file_path;
|
|
118
136
|
}
|
|
119
137
|
|
|
138
|
+
async function read_remote_resource(raw_url: string): Promise<{
|
|
139
|
+
mediaType?: string;
|
|
140
|
+
filename?: string;
|
|
141
|
+
bytes: Buffer;
|
|
142
|
+
}> {
|
|
143
|
+
const response = await fetch(raw_url);
|
|
144
|
+
if (!response.ok) {
|
|
145
|
+
throw new Error(`Failed to download assistant file resource: ${response.status}`);
|
|
146
|
+
}
|
|
147
|
+
const array_buffer = await response.arrayBuffer();
|
|
148
|
+
const bytes = Buffer.from(array_buffer);
|
|
149
|
+
if (bytes.length === 0) {
|
|
150
|
+
throw new Error("Downloaded assistant file resource is empty");
|
|
151
|
+
}
|
|
152
|
+
return {
|
|
153
|
+
mediaType: response.headers.get("content-type")?.split(";")[0]?.trim(),
|
|
154
|
+
filename: filename_from_url(raw_url),
|
|
155
|
+
bytes,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
async function read_local_resource(
|
|
160
|
+
projectRoot: string,
|
|
161
|
+
raw_url: string,
|
|
162
|
+
): Promise<{
|
|
163
|
+
mediaType?: string;
|
|
164
|
+
filename?: string;
|
|
165
|
+
bytes: Buffer;
|
|
166
|
+
}> {
|
|
167
|
+
const raw = String(raw_url || "").trim();
|
|
168
|
+
const file_path = raw.startsWith("file://")
|
|
169
|
+
? fileURLToPath(raw)
|
|
170
|
+
: path.isAbsolute(raw)
|
|
171
|
+
? raw
|
|
172
|
+
: path.resolve(projectRoot, raw);
|
|
173
|
+
const bytes = await fs.readFile(file_path);
|
|
174
|
+
if (bytes.length === 0) {
|
|
175
|
+
throw new Error(`Assistant file resource is empty: ${file_path}`);
|
|
176
|
+
}
|
|
177
|
+
return {
|
|
178
|
+
filename: path.basename(file_path),
|
|
179
|
+
bytes,
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async function materialize_file_part(params: {
|
|
184
|
+
projectRoot: string;
|
|
185
|
+
part: FileUIPart;
|
|
186
|
+
}): Promise<FileUIPart> {
|
|
187
|
+
const raw_url = String(params.part.url || "").trim();
|
|
188
|
+
if (!raw_url) {
|
|
189
|
+
throw new Error("Assistant file part url is required");
|
|
190
|
+
}
|
|
191
|
+
if (raw_url.startsWith("resources://")) return params.part;
|
|
192
|
+
|
|
193
|
+
const parsed_data_url = parse_data_url(raw_url);
|
|
194
|
+
const source = parsed_data_url
|
|
195
|
+
? {
|
|
196
|
+
mediaType: parsed_data_url.media_type,
|
|
197
|
+
filename:
|
|
198
|
+
typeof params.part.filename === "string"
|
|
199
|
+
? params.part.filename
|
|
200
|
+
: undefined,
|
|
201
|
+
bytes: parsed_data_url.bytes,
|
|
202
|
+
}
|
|
203
|
+
: raw_url.startsWith("http://") || raw_url.startsWith("https://")
|
|
204
|
+
? await read_remote_resource(raw_url)
|
|
205
|
+
: await read_local_resource(params.projectRoot, raw_url);
|
|
206
|
+
|
|
207
|
+
const media_type =
|
|
208
|
+
String(params.part.mediaType || source.mediaType || "").trim() ||
|
|
209
|
+
"application/octet-stream";
|
|
210
|
+
const file_path = await write_resource_file({
|
|
211
|
+
projectRoot: params.projectRoot,
|
|
212
|
+
mediaType: media_type,
|
|
213
|
+
filename:
|
|
214
|
+
typeof params.part.filename === "string"
|
|
215
|
+
? params.part.filename
|
|
216
|
+
: source.filename,
|
|
217
|
+
bytes: source.bytes,
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
return {
|
|
221
|
+
...params.part,
|
|
222
|
+
mediaType: media_type,
|
|
223
|
+
url: to_resources_url(params.projectRoot, file_path),
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
|
|
120
227
|
/**
|
|
121
|
-
* 将 assistant file part
|
|
228
|
+
* 将 assistant file part 中的资源统一落盘为 `resources://` 相对 URL。
|
|
122
229
|
*/
|
|
123
230
|
export async function materializeAssistantFileParts(
|
|
124
231
|
params: MaterializeAssistantFilePartsParams,
|
|
@@ -130,25 +237,7 @@ export async function materializeAssistantFileParts(
|
|
|
130
237
|
const out: FileUIPart[] = [];
|
|
131
238
|
|
|
132
239
|
for (const part of parts) {
|
|
133
|
-
|
|
134
|
-
if (!parsed) {
|
|
135
|
-
out.push(part);
|
|
136
|
-
continue;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
const media_type = String(part.mediaType || parsed.media_type || "").trim();
|
|
140
|
-
const file_path = await write_resource_file({
|
|
141
|
-
projectRoot: project_root,
|
|
142
|
-
mediaType: media_type || parsed.media_type,
|
|
143
|
-
filename: typeof part.filename === "string" ? part.filename : undefined,
|
|
144
|
-
bytes: parsed.bytes,
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
out.push({
|
|
148
|
-
...part,
|
|
149
|
-
mediaType: media_type || parsed.media_type,
|
|
150
|
-
url: pathToFileURL(file_path).href,
|
|
151
|
-
});
|
|
240
|
+
out.push(await materialize_file_part({ projectRoot: project_root, part }));
|
|
152
241
|
}
|
|
153
242
|
|
|
154
243
|
return out;
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* Plugin tool 运行时桥接。
|
|
3
3
|
*
|
|
4
4
|
* 关键点(中文)
|
|
5
|
-
* - tool 层不直接持有 agent 或 plugin registry,只通过装配期注入的
|
|
5
|
+
* - tool 层不直接持有 agent 或 plugin registry,只通过装配期注入的 AgentPlugins 调用 action。
|
|
6
6
|
* - 如果 action 返回 AI SDK UIMessage,则抽取 file parts 并入最终 assistant 消息。
|
|
7
7
|
* - 返回给模型的 tool result 只保留短摘要,避免 data URL 等大内容污染上下文。
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { FileUIPart } from "ai";
|
|
11
11
|
import type { JsonObject, JsonValue } from "@/types/common/Json.js";
|
|
12
|
-
import type {
|
|
12
|
+
import type { AgentPlugins } from "@/plugin/types/Plugin.js";
|
|
13
13
|
import type {
|
|
14
14
|
PluginCallInput,
|
|
15
15
|
PluginCallToolResult,
|
|
@@ -20,19 +20,19 @@ import {
|
|
|
20
20
|
getSessionRunContext,
|
|
21
21
|
} from "@executor/SessionRunScope.js";
|
|
22
22
|
|
|
23
|
-
let plugin_tool_runtime:
|
|
23
|
+
let plugin_tool_runtime: AgentPlugins | null = null;
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
26
|
* 注入 plugin tool 运行时。
|
|
27
27
|
*/
|
|
28
|
-
export function setPluginToolRuntime(next:
|
|
28
|
+
export function setPluginToolRuntime(next: AgentPlugins): void {
|
|
29
29
|
plugin_tool_runtime = next;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
/**
|
|
33
33
|
* 读取已注入的 plugin tool 运行时。
|
|
34
34
|
*/
|
|
35
|
-
function require_plugin_tool_runtime():
|
|
35
|
+
function require_plugin_tool_runtime(): AgentPlugins {
|
|
36
36
|
if (plugin_tool_runtime) return plugin_tool_runtime;
|
|
37
37
|
throw new Error(
|
|
38
38
|
"Plugin tool runtime is not initialized. Ensure agent assembly completed before using plugin_call.",
|
package/src/index.ts
CHANGED
|
@@ -69,7 +69,6 @@ export type {
|
|
|
69
69
|
|
|
70
70
|
// Plugin 作者 API
|
|
71
71
|
export { BasePlugin } from "./plugin/core/BasePlugin.js";
|
|
72
|
-
export { ImagePlugin } from "./plugin/core/ImagePlugin.js";
|
|
73
72
|
|
|
74
73
|
// Session 与即时执行集成
|
|
75
74
|
export { Executor } from "./executor/Executor.js";
|
|
@@ -225,15 +224,6 @@ export type {
|
|
|
225
224
|
} from "./types/runtime/http/InlineInstant.js";
|
|
226
225
|
|
|
227
226
|
// Plugin 作者与控制面类型
|
|
228
|
-
export type {
|
|
229
|
-
ImagePluginContent,
|
|
230
|
-
ImagePluginFileContent,
|
|
231
|
-
ImagePluginInput,
|
|
232
|
-
ImagePluginMessage,
|
|
233
|
-
ImagePluginOptions,
|
|
234
|
-
ImagePluginTextContent,
|
|
235
|
-
} from "./types/plugin/ImagePlugin.js";
|
|
236
|
-
|
|
237
227
|
export type {
|
|
238
228
|
Plugin,
|
|
239
229
|
PluginAction,
|
|
@@ -249,7 +239,7 @@ export type {
|
|
|
249
239
|
PluginHooks,
|
|
250
240
|
PluginHttpDefinition,
|
|
251
241
|
PluginPipelineHook,
|
|
252
|
-
|
|
242
|
+
AgentPlugins,
|
|
253
243
|
PluginResolveHook,
|
|
254
244
|
PluginHttpRegistration,
|
|
255
245
|
PluginActionInvokeParams,
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
10
|
import type { AgentContext } from "@/types/runtime/agent/AgentContext.js";
|
|
11
|
-
import type { AgentRuntime } from "@/types/runtime/agent/AgentRuntime.js";
|
|
12
11
|
import type {
|
|
13
12
|
Plugin,
|
|
14
13
|
PluginActions,
|
|
@@ -38,15 +37,6 @@ export abstract class BasePlugin implements Plugin {
|
|
|
38
37
|
chain: Promise.resolve(),
|
|
39
38
|
};
|
|
40
39
|
|
|
41
|
-
/**
|
|
42
|
-
* 当前 plugin 所属的 agent 宿主。
|
|
43
|
-
*/
|
|
44
|
-
protected agent: AgentRuntime | null;
|
|
45
|
-
|
|
46
|
-
constructor(agent: AgentRuntime | null = null) {
|
|
47
|
-
this.agent = agent;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
40
|
/**
|
|
51
41
|
* 当前 plugin 名称。
|
|
52
42
|
*/
|
|
@@ -114,21 +104,4 @@ export abstract class BasePlugin implements Plugin {
|
|
|
114
104
|
*/
|
|
115
105
|
system?(context: AgentContext): Promise<string> | string;
|
|
116
106
|
|
|
117
|
-
/**
|
|
118
|
-
* 绑定当前 plugin 所属的 agent 宿主。
|
|
119
|
-
*/
|
|
120
|
-
bindAgent(agent: AgentRuntime | null): this {
|
|
121
|
-
this.agent = agent;
|
|
122
|
-
return this;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* 读取绑定的 agent 宿主。
|
|
127
|
-
*/
|
|
128
|
-
protected requireAgent(): AgentRuntime {
|
|
129
|
-
if (this.agent) return this.agent;
|
|
130
|
-
throw new Error(
|
|
131
|
-
`Plugin "${this.name}" is not bound to an agent instance.`,
|
|
132
|
-
);
|
|
133
|
-
}
|
|
134
107
|
}
|
|
@@ -12,6 +12,7 @@ import type { HookRegistry } from "@/plugin/core/HookRegistry.js";
|
|
|
12
12
|
import type {
|
|
13
13
|
Plugin,
|
|
14
14
|
PluginActionResult,
|
|
15
|
+
AgentPlugins,
|
|
15
16
|
PluginAvailability,
|
|
16
17
|
PluginView,
|
|
17
18
|
} from "@/plugin/types/Plugin.js";
|
|
@@ -23,7 +24,7 @@ type ContextResolver = () => AgentContext;
|
|
|
23
24
|
/**
|
|
24
25
|
* PluginRegistry:plugin 注册与调度实现。
|
|
25
26
|
*/
|
|
26
|
-
export class PluginRegistry {
|
|
27
|
+
export class PluginRegistry implements AgentPlugins {
|
|
27
28
|
private readonly contextResolver: ContextResolver;
|
|
28
29
|
|
|
29
30
|
private readonly hookRegistry: HookRegistry;
|
|
@@ -5,7 +5,6 @@
|
|
|
5
5
|
import type { AgentContext } from "@/types/runtime/agent/AgentContext.js";
|
|
6
6
|
import type { AgentRuntime } from "@/types/runtime/agent/AgentRuntime.js";
|
|
7
7
|
import type {
|
|
8
|
-
Plugin,
|
|
9
8
|
PluginLifecycle,
|
|
10
9
|
PluginState,
|
|
11
10
|
PluginStateControlAction,
|
|
@@ -132,20 +131,6 @@ export function markPluginCommand(
|
|
|
132
131
|
record.updatedAt = nowMs();
|
|
133
132
|
}
|
|
134
133
|
|
|
135
|
-
/**
|
|
136
|
-
* 返回静态主动型 plugin 定义清单。
|
|
137
|
-
*/
|
|
138
|
-
export function getStaticPlugins(): Plugin[] {
|
|
139
|
-
return [];
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* 返回主动型 plugin 根命令名清单。
|
|
144
|
-
*/
|
|
145
|
-
export function getPluginRootCommandNames(): string[] {
|
|
146
|
-
return [];
|
|
147
|
-
}
|
|
148
|
-
|
|
149
134
|
/**
|
|
150
135
|
* 列出全部主动型 plugin 状态快照。
|
|
151
136
|
*/
|
|
@@ -107,24 +107,6 @@ export interface DowncityChatPluginConfig {
|
|
|
107
107
|
channels?: DowncityChatPluginChannelsConfig;
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
-
/**
|
|
111
|
-
* skill 插件配置。
|
|
112
|
-
*/
|
|
113
|
-
export interface DowncitySkillPluginConfig {
|
|
114
|
-
/**
|
|
115
|
-
* 当前插件是否启用。
|
|
116
|
-
*/
|
|
117
|
-
enabled?: boolean;
|
|
118
|
-
/**
|
|
119
|
-
* 技能目录列表。
|
|
120
|
-
*/
|
|
121
|
-
paths?: string[];
|
|
122
|
-
/**
|
|
123
|
-
* 是否允许读取项目外部技能目录。
|
|
124
|
-
*/
|
|
125
|
-
allowExternalPaths?: boolean;
|
|
126
|
-
}
|
|
127
|
-
|
|
128
110
|
/**
|
|
129
111
|
* downcity.json 中的插件配置映射。
|
|
130
112
|
*/
|
|
@@ -133,17 +115,12 @@ export interface DowncityPluginConfigMap {
|
|
|
133
115
|
* chat 插件配置。
|
|
134
116
|
*/
|
|
135
117
|
chat?: DowncityChatPluginConfig;
|
|
136
|
-
/**
|
|
137
|
-
* skill 插件配置。
|
|
138
|
-
*/
|
|
139
|
-
skill?: DowncitySkillPluginConfig;
|
|
140
118
|
/**
|
|
141
119
|
* 其他插件配置。
|
|
142
120
|
*/
|
|
143
121
|
[pluginName: string]:
|
|
144
122
|
| JsonObject
|
|
145
123
|
| DowncityChatPluginConfig
|
|
146
|
-
| DowncitySkillPluginConfig
|
|
147
124
|
| undefined;
|
|
148
125
|
}
|
|
149
126
|
|
|
@@ -171,7 +148,7 @@ export interface DowncityConfig {
|
|
|
171
148
|
*
|
|
172
149
|
* 关键点(中文)
|
|
173
150
|
* - 所有可配置能力统一收敛到 `plugins`,不再保留独立 `services` 域。
|
|
174
|
-
* - plugin
|
|
151
|
+
* - 需要持久化到项目文件的 plugin 配置(例如 `plugins.chat.channels`)放在这里。
|
|
175
152
|
* - key 为 plugin 名称,value 为对应插件的结构化配置对象。
|
|
176
153
|
* - 当前阶段允许各 plugin 自定义字段,但必须保持 JSON 可序列化。
|
|
177
154
|
*/
|
|
@@ -19,7 +19,7 @@ import type {
|
|
|
19
19
|
} from "@/types/agent/AgentRuntimeAssembly.js";
|
|
20
20
|
import type { DowncityConfig } from "@/types/config/DowncityConfig.js";
|
|
21
21
|
import type { JsonObject, JsonValue } from "@/types/common/Json.js";
|
|
22
|
-
import type {
|
|
22
|
+
import type { AgentPlugins } from "@/plugin/types/Plugin.js";
|
|
23
23
|
import type {
|
|
24
24
|
SessionMetadataV1,
|
|
25
25
|
SessionMessageV1,
|
|
@@ -261,7 +261,7 @@ export interface AgentContext {
|
|
|
261
261
|
/**
|
|
262
262
|
* Plugin 调用入口。
|
|
263
263
|
*/
|
|
264
|
-
plugins:
|
|
264
|
+
plugins: AgentPlugins;
|
|
265
265
|
}
|
|
266
266
|
|
|
267
267
|
/**
|