@downcity/agent 1.1.195 → 1.1.198

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.
Files changed (36) hide show
  1. package/bin/agent/local/Agent.d.ts.map +1 -1
  2. package/bin/agent/local/Agent.js +5 -2
  3. package/bin/agent/local/Agent.js.map +1 -1
  4. package/bin/agent/local/services/AgentAssemblyService.d.ts.map +1 -1
  5. package/bin/agent/local/services/AgentAssemblyService.js +2 -2
  6. package/bin/agent/local/services/AgentAssemblyService.js.map +1 -1
  7. package/bin/agent/local/services/AgentSessionManager.d.ts +5 -0
  8. package/bin/agent/local/services/AgentSessionManager.d.ts.map +1 -1
  9. package/bin/agent/local/services/AgentSessionManager.js +3 -0
  10. package/bin/agent/local/services/AgentSessionManager.js.map +1 -1
  11. package/bin/executor/tools/plugin/PluginToolBridge.d.ts +4 -8
  12. package/bin/executor/tools/plugin/PluginToolBridge.d.ts.map +1 -1
  13. package/bin/executor/tools/plugin/PluginToolBridge.js +6 -21
  14. package/bin/executor/tools/plugin/PluginToolBridge.js.map +1 -1
  15. package/bin/executor/tools/plugin/PluginToolDefinition.d.ts +7 -19
  16. package/bin/executor/tools/plugin/PluginToolDefinition.d.ts.map +1 -1
  17. package/bin/executor/tools/plugin/PluginToolDefinition.js +29 -18
  18. package/bin/executor/tools/plugin/PluginToolDefinition.js.map +1 -1
  19. package/bin/plugin/core/PluginRegistry.d.ts.map +1 -1
  20. package/bin/plugin/core/PluginRegistry.js +0 -4
  21. package/bin/plugin/core/PluginRegistry.js.map +1 -1
  22. package/bin/types/plugin/PluginToolRuntime.d.ts +75 -0
  23. package/bin/types/plugin/PluginToolRuntime.d.ts.map +1 -0
  24. package/bin/types/plugin/PluginToolRuntime.js +9 -0
  25. package/bin/types/plugin/PluginToolRuntime.js.map +1 -0
  26. package/package.json +3 -3
  27. package/scripts/agent-ready.test.mjs +168 -0
  28. package/scripts/plugin-tool-bridge.test.mjs +114 -10
  29. package/src/agent/local/Agent.ts +5 -2
  30. package/src/agent/local/services/AgentAssemblyService.ts +2 -3
  31. package/src/agent/local/services/AgentSessionManager.ts +8 -0
  32. package/src/executor/tools/plugin/PluginToolBridge.ts +10 -26
  33. package/src/executor/tools/plugin/PluginToolDefinition.ts +39 -22
  34. package/src/plugin/core/PluginRegistry.ts +0 -4
  35. package/src/types/plugin/PluginToolRuntime.ts +86 -0
  36. package/tsconfig.tsbuildinfo +1 -1
@@ -12,42 +12,59 @@ import type {
12
12
  PluginCallInput,
13
13
  PluginReadInput,
14
14
  } from "@/executor/tools/plugin/types/PluginTool.js";
15
+ import type {
16
+ AgentPluginTools,
17
+ CreatePluginToolsOptions,
18
+ } from "@/types/plugin/PluginToolRuntime.js";
15
19
  import {
16
20
  invokePluginCallTool,
17
21
  invokePluginReadTool,
18
- setPluginToolRuntime,
19
22
  } from "./PluginToolBridge.js";
20
23
  import {
21
24
  plugin_call_input_schema,
22
25
  plugin_read_input_schema,
23
26
  } from "./PluginToolSchemas.js";
24
27
 
25
- export { setPluginToolRuntime } from "./PluginToolBridge.js";
26
-
27
28
  /**
28
- * `plugin_call`:调用已注册 plugin action。
29
+ * 创建 `plugin_call`:调用当前 Agent 已注册 plugin action。
29
30
  */
30
- export const plugin_call = tool({
31
- description:
32
- "Call a registered agent plugin action. Use plugin_read first when you need the action list, input schema, or examples. Generated files may be attached to the final assistant message automatically.",
33
- inputSchema: plugin_call_input_schema,
34
- execute: async (input) => await invokePluginCallTool(input as PluginCallInput),
35
- });
31
+ export function createPluginCallTool(options: CreatePluginToolsOptions) {
32
+ return tool({
33
+ description:
34
+ "Call a registered agent plugin action. Use plugin_read first when you need the action list, input schema, or examples. Generated files may be attached to the final assistant message automatically.",
35
+ inputSchema: plugin_call_input_schema,
36
+ execute: async (input) =>
37
+ await invokePluginCallTool({
38
+ plugins: options.plugins,
39
+ input: input as PluginCallInput,
40
+ }),
41
+ });
42
+ }
36
43
 
37
44
  /**
38
- * `plugin_read`:读取已注册 plugin / action metadata。
45
+ * 创建 `plugin_read`:读取当前 Agent 已注册 plugin / action metadata。
39
46
  */
40
- export const plugin_read = tool({
41
- description:
42
- "Read registered agent plugin metadata, including action names, descriptions, input schemas, and examples. Use this before plugin_call when the payload shape is unclear.",
43
- inputSchema: plugin_read_input_schema,
44
- execute: async (input) => await invokePluginReadTool(input as PluginReadInput),
45
- });
47
+ export function createPluginReadTool(options: CreatePluginToolsOptions) {
48
+ return tool({
49
+ description:
50
+ "Read registered agent plugin metadata, including action names, descriptions, input schemas, and examples. Use this before plugin_call when the payload shape is unclear.",
51
+ inputSchema: plugin_read_input_schema,
52
+ execute: async (input) =>
53
+ await invokePluginReadTool({
54
+ plugins: options.plugins,
55
+ input: input as PluginReadInput,
56
+ }),
57
+ });
58
+ }
46
59
 
47
60
  /**
48
- * Plugin 工具导出集合。
61
+ * 创建当前 Agent 专属 Plugin 工具集合。
49
62
  */
50
- export const plugin_tools = {
51
- plugin_call,
52
- plugin_read,
53
- };
63
+ export function createPluginTools(
64
+ options: CreatePluginToolsOptions,
65
+ ): AgentPluginTools {
66
+ return {
67
+ plugin_call: createPluginCallTool(options),
68
+ plugin_read: createPluginReadTool(options),
69
+ };
70
+ }
@@ -522,12 +522,8 @@ export class PluginRegistry implements AgentPlugins {
522
522
  pluginName: record.plugin.name,
523
523
  actionName,
524
524
  });
525
- if (!result.success) {
526
- update_record_state(record, "error", result.error || result.message);
527
- }
528
525
  return result;
529
526
  } catch (error) {
530
- update_record_state(record, "error", String(error));
531
527
  return {
532
528
  success: false,
533
529
  error: String(error),
@@ -0,0 +1,86 @@
1
+ /**
2
+ * Plugin tool runtime 绑定类型。
3
+ *
4
+ * 关键点(中文)
5
+ * - plugin_call / plugin_read 必须绑定当前 Agent 自己的 plugin registry。
6
+ * - 这些类型描述 tool 工厂与 bridge 调用时需要的显式 runtime 依赖。
7
+ */
8
+
9
+ import type { Tool } from "ai";
10
+ import type { AgentPlugins } from "@/types/plugin/PluginRuntime.js";
11
+ import type {
12
+ PluginCallInput,
13
+ PluginReadInput,
14
+ } from "@/executor/tools/plugin/types/PluginTool.js";
15
+
16
+ /**
17
+ * 创建 plugin tools 的参数。
18
+ */
19
+ export interface CreatePluginToolsOptions {
20
+ /**
21
+ * 当前 Agent 自己的 plugin 调用面。
22
+ *
23
+ * 关键点(中文)
24
+ * - 该引用必须来自当前 Agent 装配出的 plugin registry。
25
+ * - tool 执行时只能通过它访问 plugin,避免跨 Agent 读到其他 registry。
26
+ */
27
+ plugins: AgentPlugins;
28
+ }
29
+
30
+ /**
31
+ * 当前 Agent 专属 plugin tools。
32
+ */
33
+ export interface AgentPluginTools {
34
+ /**
35
+ * 读取 plugin metadata 的模型工具。
36
+ *
37
+ * 关键点(中文)
38
+ * - 该 tool 通过闭包绑定当前 Agent 的 `plugins`。
39
+ * - 不读取任何模块级全局 runtime。
40
+ */
41
+ plugin_read: Tool;
42
+
43
+ /**
44
+ * 执行 plugin action 的模型工具。
45
+ *
46
+ * 关键点(中文)
47
+ * - 该 tool 通过闭包绑定当前 Agent 的 `plugins`。
48
+ * - 多 Agent 并发时,每个 Agent 都有自己的 tool 实例。
49
+ */
50
+ plugin_call: Tool;
51
+ }
52
+
53
+ /**
54
+ * 调用 plugin_call bridge 的参数。
55
+ */
56
+ export interface InvokePluginCallToolOptions {
57
+ /**
58
+ * 当前 Agent 自己的 plugin 调用面。
59
+ *
60
+ * 关键点(中文)
61
+ * - 由 Agent 级 tool 工厂注入。
62
+ * - 不能在 bridge 内通过全局变量读取。
63
+ */
64
+ plugins: AgentPlugins;
65
+
66
+ /**
67
+ * 模型提交给 plugin_call 的结构化输入。
68
+ */
69
+ input: PluginCallInput;
70
+ }
71
+
72
+ /**
73
+ * 调用 plugin_read bridge 的参数。
74
+ */
75
+ export interface InvokePluginReadToolOptions {
76
+ /**
77
+ * 当前 Agent 自己的 plugin 调用面。
78
+ */
79
+ plugins: AgentPlugins;
80
+
81
+ /**
82
+ * 模型提交给 plugin_read 的结构化输入。
83
+ */
84
+ input: PluginReadInput;
85
+ }
86
+