@downcity/plugins 1.0.96 → 1.0.108

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 (56) hide show
  1. package/bin/asr/Plugin.d.ts +1 -15
  2. package/bin/asr/Plugin.d.ts.map +1 -1
  3. package/bin/asr/Plugin.js +36 -5
  4. package/bin/asr/Plugin.js.map +1 -1
  5. package/bin/chat/runtime/ChatAuthorizationRuntime.d.ts.map +1 -1
  6. package/bin/chat/runtime/ChatAuthorizationRuntime.js +53 -12
  7. package/bin/chat/runtime/ChatAuthorizationRuntime.js.map +1 -1
  8. package/bin/chat/runtime/ChatPluginActionRegistry.d.ts.map +1 -1
  9. package/bin/chat/runtime/ChatPluginActionRegistry.js +114 -42
  10. package/bin/chat/runtime/ChatPluginActionRegistry.js.map +1 -1
  11. package/bin/contact/Action.d.ts.map +1 -1
  12. package/bin/contact/Action.js +159 -37
  13. package/bin/contact/Action.js.map +1 -1
  14. package/bin/image/ImagePlugin.d.ts +14 -67
  15. package/bin/image/ImagePlugin.d.ts.map +1 -1
  16. package/bin/image/ImagePlugin.js +432 -151
  17. package/bin/image/ImagePlugin.js.map +1 -1
  18. package/bin/image/types/ImagePlugin.d.ts +87 -32
  19. package/bin/image/types/ImagePlugin.d.ts.map +1 -1
  20. package/bin/image/types/ImagePlugin.js +1 -1
  21. package/bin/index.d.ts +1 -1
  22. package/bin/index.d.ts.map +1 -1
  23. package/bin/memory/MemoryPlugin.d.ts.map +1 -1
  24. package/bin/memory/MemoryPlugin.js +130 -17
  25. package/bin/memory/MemoryPlugin.js.map +1 -1
  26. package/bin/skill/Plugin.d.ts.map +1 -1
  27. package/bin/skill/Plugin.js +90 -11
  28. package/bin/skill/Plugin.js.map +1 -1
  29. package/bin/task/runtime/TaskPluginActionRegistry.d.ts.map +1 -1
  30. package/bin/task/runtime/TaskPluginActionRegistry.js +202 -24
  31. package/bin/task/runtime/TaskPluginActionRegistry.js.map +1 -1
  32. package/bin/tts/Plugin.d.ts +1 -15
  33. package/bin/tts/Plugin.d.ts.map +1 -1
  34. package/bin/tts/Plugin.js +38 -5
  35. package/bin/tts/Plugin.js.map +1 -1
  36. package/bin/web/Plugin.d.ts +2 -19
  37. package/bin/web/Plugin.d.ts.map +1 -1
  38. package/bin/web/Plugin.js +39 -5
  39. package/bin/web/Plugin.js.map +1 -1
  40. package/bin/workboard/Plugin.d.ts.map +1 -1
  41. package/bin/workboard/Plugin.js +10 -2
  42. package/bin/workboard/Plugin.js.map +1 -1
  43. package/package.json +3 -3
  44. package/src/asr/Plugin.ts +37 -5
  45. package/src/chat/runtime/ChatAuthorizationRuntime.ts +53 -12
  46. package/src/chat/runtime/ChatPluginActionRegistry.ts +114 -42
  47. package/src/contact/Action.ts +159 -37
  48. package/src/image/ImagePlugin.ts +477 -222
  49. package/src/image/types/ImagePlugin.ts +91 -32
  50. package/src/index.ts +3 -1
  51. package/src/memory/MemoryPlugin.ts +130 -17
  52. package/src/skill/Plugin.ts +101 -21
  53. package/src/task/runtime/TaskPluginActionRegistry.ts +209 -24
  54. package/src/tts/Plugin.ts +39 -5
  55. package/src/web/Plugin.ts +39 -5
  56. package/src/workboard/Plugin.ts +10 -2
@@ -8,6 +8,8 @@
8
8
 
9
9
  import type { Command } from "commander";
10
10
  import type { PluginActions } from "@downcity/agent/internal/plugin/types/Plugin.js";
11
+ import { createAction } from "@downcity/agent/internal/plugin/core/PluginActionFactory.js";
12
+ import { z } from "zod";
11
13
  import type { TaskListActionPayload } from "@/task/types/TaskPluginTypes.js";
12
14
  import type {
13
15
  TaskCreateRequest,
@@ -36,6 +38,53 @@ import {
36
38
  mapTaskUpdateCommandPayload,
37
39
  } from "./TaskActionInput.js";
38
40
 
41
+ const TASK_STATUS_SCHEMA = z.enum(["enabled", "paused", "disabled"]);
42
+ const TASK_KIND_SCHEMA = z.enum(["agent", "script"]);
43
+
44
+ const TASK_LIST_SCHEMA = z.object({
45
+ status: TASK_STATUS_SCHEMA.optional(),
46
+ });
47
+
48
+ const TASK_CREATE_SCHEMA = z.object({
49
+ title: z.string(),
50
+ when: z.string(),
51
+ description: z.string(),
52
+ sessionId: z.string(),
53
+ kind: TASK_KIND_SCHEMA.optional(),
54
+ review: z.boolean().optional(),
55
+ status: TASK_STATUS_SCHEMA.optional(),
56
+ body: z.string().optional(),
57
+ overwrite: z.boolean().optional(),
58
+ });
59
+
60
+ const TASK_UPDATE_SCHEMA = z.object({
61
+ title: z.string(),
62
+ titleNext: z.string().optional(),
63
+ when: z.string().optional(),
64
+ clearWhen: z.boolean().optional(),
65
+ description: z.string().optional(),
66
+ sessionId: z.string().optional(),
67
+ kind: TASK_KIND_SCHEMA.optional(),
68
+ review: z.boolean().optional(),
69
+ status: TASK_STATUS_SCHEMA.optional(),
70
+ body: z.string().optional(),
71
+ clearBody: z.boolean().optional(),
72
+ });
73
+
74
+ const TASK_RUN_SCHEMA = z.object({
75
+ title: z.string(),
76
+ reason: z.string().optional(),
77
+ });
78
+
79
+ const TASK_DELETE_SCHEMA = z.object({
80
+ title: z.string(),
81
+ });
82
+
83
+ const TASK_STATUS_REQ_SCHEMA = z.object({
84
+ title: z.string(),
85
+ status: TASK_STATUS_SCHEMA,
86
+ });
87
+
39
88
  /**
40
89
  * 创建 task plugin runtime 的 action 定义表。
41
90
  */
@@ -43,7 +92,25 @@ export function createTaskPluginActions(params: {
43
92
  reloadSchedulerAfterMutation: TaskSchedulerReloadPort;
44
93
  }): PluginActions {
45
94
  return {
46
- list: {
95
+ list: createAction({
96
+ description: "列出任务定义;可按状态过滤。",
97
+ input_schema: {
98
+ zod: TASK_LIST_SCHEMA,
99
+ json_schema: {
100
+ type: "object",
101
+ properties: {
102
+ status: {
103
+ type: "string",
104
+ enum: ["enabled", "paused", "disabled"],
105
+ description: "按任务状态过滤",
106
+ },
107
+ },
108
+ },
109
+ },
110
+ examples: [
111
+ { title: "全部任务", payload: {} },
112
+ { title: "只看已启用", payload: { status: "enabled" } },
113
+ ],
47
114
  command: {
48
115
  description: "列出任务",
49
116
  configure(command: Command) {
@@ -57,11 +124,42 @@ export function createTaskPluginActions(params: {
57
124
  execute: async (actionParams) => {
58
125
  return executeTaskListAction({
59
126
  context: actionParams.context,
60
- payload: actionParams.payload as TaskListActionPayload,
127
+ payload: actionParams.input as TaskListActionPayload,
61
128
  });
62
129
  },
63
- },
64
- create: {
130
+ }),
131
+ create: createAction({
132
+ description: "创建任务定义。",
133
+ input_schema: {
134
+ zod: TASK_CREATE_SCHEMA,
135
+ json_schema: {
136
+ type: "object",
137
+ required: ["title", "when", "description", "sessionId"],
138
+ properties: {
139
+ title: { type: "string", description: "任务名称(唯一语义标识)" },
140
+ when: { type: "string", description: "触发条件(@manual | cron | time:ISO8601)" },
141
+ description: { type: "string", description: "任务描述" },
142
+ sessionId: { type: "string", description: "任务执行 sessionId" },
143
+ kind: { type: "string", enum: ["agent", "script"], description: "执行类型" },
144
+ review: { type: "boolean", description: "是否启用 review 多轮复核" },
145
+ status: { type: "string", enum: ["enabled", "paused", "disabled"], description: "任务状态" },
146
+ body: { type: "string", description: "任务正文" },
147
+ overwrite: { type: "boolean", description: "是否覆盖已有 task.md" },
148
+ },
149
+ },
150
+ },
151
+ examples: [
152
+ {
153
+ title: "创建一个手动任务",
154
+ payload: {
155
+ title: "daily-report",
156
+ when: "@manual",
157
+ description: "每天生成报告",
158
+ sessionId: "session-1",
159
+ status: "enabled",
160
+ },
161
+ },
162
+ ],
65
163
  command: {
66
164
  description: "创建任务定义",
67
165
  configure(command: Command) {
@@ -92,12 +190,25 @@ export function createTaskPluginActions(params: {
92
190
  execute: async (actionParams) => {
93
191
  return executeTaskCreateAction({
94
192
  context: actionParams.context,
95
- payload: actionParams.payload as TaskCreateRequest,
193
+ payload: actionParams.input as TaskCreateRequest,
96
194
  reloadSchedulerAfterMutation: params.reloadSchedulerAfterMutation,
97
195
  });
98
196
  },
99
- },
100
- run: {
197
+ }),
198
+ run: createAction({
199
+ description: "手动运行任务。",
200
+ input_schema: {
201
+ zod: TASK_RUN_SCHEMA,
202
+ json_schema: {
203
+ type: "object",
204
+ required: ["title"],
205
+ properties: {
206
+ title: { type: "string", description: "任务名称" },
207
+ reason: { type: "string", description: "手动运行原因" },
208
+ },
209
+ },
210
+ },
211
+ examples: [{ title: "手动运行", payload: { title: "daily-report" } }],
101
212
  command: {
102
213
  description: "手动运行任务",
103
214
  configure(command: Command) {
@@ -110,11 +221,23 @@ export function createTaskPluginActions(params: {
110
221
  execute: async (actionParams) => {
111
222
  return executeTaskRunAction({
112
223
  context: actionParams.context,
113
- payload: actionParams.payload as TaskRunRequest,
224
+ payload: actionParams.input as TaskRunRequest,
114
225
  });
115
226
  },
116
- },
117
- delete: {
227
+ }),
228
+ delete: createAction({
229
+ description: "删除任务定义与历史运行目录。",
230
+ input_schema: {
231
+ zod: TASK_DELETE_SCHEMA,
232
+ json_schema: {
233
+ type: "object",
234
+ required: ["title"],
235
+ properties: {
236
+ title: { type: "string", description: "任务名称" },
237
+ },
238
+ },
239
+ },
240
+ examples: [{ title: "删除任务", payload: { title: "daily-report" } }],
118
241
  command: {
119
242
  description: "删除任务定义与历史运行目录",
120
243
  configure(command: Command) {
@@ -125,12 +248,39 @@ export function createTaskPluginActions(params: {
125
248
  execute: async (actionParams) => {
126
249
  return executeTaskDeleteAction({
127
250
  context: actionParams.context,
128
- payload: actionParams.payload as TaskDeleteRequest,
251
+ payload: actionParams.input as TaskDeleteRequest,
129
252
  reloadSchedulerAfterMutation: params.reloadSchedulerAfterMutation,
130
253
  });
131
254
  },
132
- },
133
- update: {
255
+ }),
256
+ update: createAction({
257
+ description: "更新任务定义。",
258
+ input_schema: {
259
+ zod: TASK_UPDATE_SCHEMA,
260
+ json_schema: {
261
+ type: "object",
262
+ required: ["title"],
263
+ properties: {
264
+ title: { type: "string", description: "当前任务名称" },
265
+ titleNext: { type: "string", description: "新任务名称" },
266
+ when: { type: "string", description: "新触发条件" },
267
+ clearWhen: { type: "boolean", description: "是否清空触发条件" },
268
+ description: { type: "string", description: "新描述" },
269
+ sessionId: { type: "string", description: "新 sessionId" },
270
+ kind: { type: "string", enum: ["agent", "script"] },
271
+ review: { type: "boolean" },
272
+ status: { type: "string", enum: ["enabled", "paused", "disabled"] },
273
+ body: { type: "string", description: "新正文" },
274
+ clearBody: { type: "boolean", description: "是否清空正文" },
275
+ },
276
+ },
277
+ },
278
+ examples: [
279
+ {
280
+ title: "更新触发器",
281
+ payload: { title: "daily-report", when: "cron:0 9 * * *" },
282
+ },
283
+ ],
134
284
  command: {
135
285
  description: "更新任务定义",
136
286
  configure(command: Command) {
@@ -157,12 +307,27 @@ export function createTaskPluginActions(params: {
157
307
  execute: async (actionParams) => {
158
308
  return executeTaskUpdateAction({
159
309
  context: actionParams.context,
160
- payload: actionParams.payload as TaskUpdateRequest,
310
+ payload: actionParams.input as TaskUpdateRequest,
161
311
  reloadSchedulerAfterMutation: params.reloadSchedulerAfterMutation,
162
312
  });
163
313
  },
164
- },
165
- status: {
314
+ }),
315
+ status: createAction({
316
+ description: "设置任务状态(enabled|paused|disabled)。",
317
+ input_schema: {
318
+ zod: TASK_STATUS_REQ_SCHEMA,
319
+ json_schema: {
320
+ type: "object",
321
+ required: ["title", "status"],
322
+ properties: {
323
+ title: { type: "string", description: "任务名称" },
324
+ status: { type: "string", enum: ["enabled", "paused", "disabled"] },
325
+ },
326
+ },
327
+ },
328
+ examples: [
329
+ { title: "暂停任务", payload: { title: "daily-report", status: "paused" } },
330
+ ],
166
331
  command: {
167
332
  description: "设置任务状态(enabled|paused|disabled)",
168
333
  configure(command: Command) {
@@ -173,12 +338,22 @@ export function createTaskPluginActions(params: {
173
338
  execute: async (actionParams) => {
174
339
  return executeTaskStatusAction({
175
340
  context: actionParams.context,
176
- payload: actionParams.payload as TaskSetStatusRequest,
341
+ payload: actionParams.input as TaskSetStatusRequest,
177
342
  reloadSchedulerAfterMutation: params.reloadSchedulerAfterMutation,
178
343
  });
179
344
  },
180
- },
181
- enable: {
345
+ }),
346
+ enable: createAction({
347
+ description: "启用任务(status=enabled)。",
348
+ input_schema: {
349
+ zod: z.object({ title: z.string() }),
350
+ json_schema: {
351
+ type: "object",
352
+ required: ["title"],
353
+ properties: { title: { type: "string", description: "任务名称" } },
354
+ },
355
+ },
356
+ examples: [{ title: "启用", payload: { title: "daily-report" } }],
182
357
  command: {
183
358
  description: "启用任务(status=enabled)",
184
359
  configure(command: Command) {
@@ -189,12 +364,22 @@ export function createTaskPluginActions(params: {
189
364
  execute: async (actionParams) => {
190
365
  return executeTaskStatusAction({
191
366
  context: actionParams.context,
192
- payload: actionParams.payload as TaskSetStatusRequest,
367
+ payload: actionParams.input as TaskSetStatusRequest,
193
368
  reloadSchedulerAfterMutation: params.reloadSchedulerAfterMutation,
194
369
  });
195
370
  },
196
- },
197
- disable: {
371
+ }),
372
+ disable: createAction({
373
+ description: "禁用任务(status=disabled)。",
374
+ input_schema: {
375
+ zod: z.object({ title: z.string() }),
376
+ json_schema: {
377
+ type: "object",
378
+ required: ["title"],
379
+ properties: { title: { type: "string", description: "任务名称" } },
380
+ },
381
+ },
382
+ examples: [{ title: "禁用", payload: { title: "daily-report" } }],
198
383
  command: {
199
384
  description: "禁用任务(status=disabled)",
200
385
  configure(command: Command) {
@@ -205,10 +390,10 @@ export function createTaskPluginActions(params: {
205
390
  execute: async (actionParams) => {
206
391
  return executeTaskStatusAction({
207
392
  context: actionParams.context,
208
- payload: actionParams.payload as TaskSetStatusRequest,
393
+ payload: actionParams.input as TaskSetStatusRequest,
209
394
  reloadSchedulerAfterMutation: params.reloadSchedulerAfterMutation,
210
395
  });
211
396
  },
212
- },
397
+ }),
213
398
  };
214
399
  }
package/src/tts/Plugin.ts CHANGED
@@ -8,6 +8,8 @@
8
8
  */
9
9
 
10
10
  import { BasePlugin } from "@downcity/agent/internal/plugin/core/BasePlugin.js";
11
+ import { createAction } from "@downcity/agent/internal/plugin/core/PluginActionFactory.js";
12
+ import { z } from "zod";
11
13
  import type { AgentContext } from "@downcity/agent/internal/types/runtime/agent/AgentContext.js";
12
14
  import type {
13
15
  JsonObject,
@@ -227,11 +229,43 @@ export class TtsPlugin extends BasePlugin {
227
229
  * 显式 action 集合。
228
230
  */
229
231
  readonly actions = {
230
- synthesize: {
231
- execute: async ({ payload }: { payload: JsonValue }) => {
232
+ synthesize: createAction({
233
+ description:
234
+ "Synthesize speech from text. Returns a UIMessage whose audio file part is auto-saved under the project resources directory.",
235
+ input_schema: {
236
+ zod: z
237
+ .object({
238
+ text: z.string(),
239
+ language: z.string().optional(),
240
+ voice: z.string().optional(),
241
+ format: z.string().optional(),
242
+ speed: z.number().optional(),
243
+ provider_options: z.record(z.string(), z.unknown()).optional(),
244
+ })
245
+ .passthrough(),
246
+ json_schema: {
247
+ type: "object",
248
+ required: ["text"],
249
+ properties: {
250
+ text: { type: "string", description: "需要合成的文本" },
251
+ language: { type: "string", description: "语言代码(可选)" },
252
+ voice: { type: "string", description: "音色(可选)" },
253
+ format: { type: "string", description: "音频格式(可选)" },
254
+ speed: { type: "number", description: "语速(可选)" },
255
+ },
256
+ },
257
+ },
258
+ examples: [
259
+ { title: "默认音色", payload: { text: "你好,世界" } },
260
+ {
261
+ title: "指定音色",
262
+ payload: { text: "Welcome back", voice: "alloy", format: "mp3" },
263
+ },
264
+ ],
265
+ execute: async ({ input }: { input: JsonValue }) => {
232
266
  try {
233
- const input = normalize_tts_payload(payload);
234
- const message = await this.synthesize(input);
267
+ const synth_input = normalize_tts_payload(input);
268
+ const message = await this.synthesize(synth_input);
235
269
  return {
236
270
  success: true,
237
271
  data: message as unknown as JsonObject,
@@ -245,6 +279,6 @@ export class TtsPlugin extends BasePlugin {
245
279
  };
246
280
  }
247
281
  },
248
- },
282
+ }),
249
283
  };
250
284
  }
package/src/web/Plugin.ts CHANGED
@@ -9,6 +9,8 @@
9
9
  */
10
10
 
11
11
  import { BasePlugin } from "@downcity/agent/internal/plugin/core/BasePlugin.js";
12
+ import { createAction } from "@downcity/agent/internal/plugin/core/PluginActionFactory.js";
13
+ import { z } from "zod";
12
14
  import type { AgentContext } from "@downcity/agent/internal/types/runtime/agent/AgentContext.js";
13
15
  import type {
14
16
  JsonObject,
@@ -136,7 +138,39 @@ export class WebPlugin extends BasePlugin {
136
138
  * WebPlugin 对外 action。
137
139
  */
138
140
  readonly actions = {
139
- install: {
141
+ install: createAction({
142
+ description: "安装联网相关 skill / CLI 依赖(web-access、agent-browser)。",
143
+ input_schema: {
144
+ zod: z.object({
145
+ target: z.enum(["web-access", "agent-browser", "all"]).optional(),
146
+ scope: z.enum(["user", "project"]).optional(),
147
+ yes: z.boolean().optional(),
148
+ agent: z.string().optional(),
149
+ }),
150
+ json_schema: {
151
+ type: "object",
152
+ properties: {
153
+ target: {
154
+ type: "string",
155
+ enum: ["web-access", "agent-browser", "all"],
156
+ description: "要安装的联网能力",
157
+ },
158
+ scope: {
159
+ type: "string",
160
+ enum: ["user", "project"],
161
+ description: "安装作用域",
162
+ },
163
+ yes: { type: "boolean", description: "跳过确认" },
164
+ agent: { type: "string", description: "skill installer 目标 agent" },
165
+ },
166
+ },
167
+ },
168
+ examples: [
169
+ {
170
+ title: "用户级安装全部联网能力",
171
+ payload: { target: "all", scope: "user" },
172
+ },
173
+ ],
140
174
  allowWhenDisabled: true,
141
175
  command: {
142
176
  description: "安装联网相关 skill / CLI 依赖",
@@ -162,12 +196,12 @@ export class WebPlugin extends BasePlugin {
162
196
  } satisfies JsonObject;
163
197
  },
164
198
  },
165
- execute: async ({ context, payload }) => {
199
+ execute: async ({ context, input }) => {
166
200
  const data = await installWebPluginTargets({
167
201
  context,
168
202
  payload:
169
- payload && typeof payload === "object" && !Array.isArray(payload)
170
- ? (payload as WebPluginInstallPayload)
203
+ input && typeof input === "object" && !Array.isArray(input)
204
+ ? (input as WebPluginInstallPayload)
171
205
  : undefined,
172
206
  });
173
207
  return {
@@ -176,7 +210,7 @@ export class WebPlugin extends BasePlugin {
176
210
  message: "web dependencies installed",
177
211
  };
178
212
  },
179
- },
213
+ }),
180
214
  };
181
215
 
182
216
  /**
@@ -8,6 +8,8 @@
8
8
  */
9
9
 
10
10
  import { BasePlugin } from "@downcity/agent/internal/plugin/core/BasePlugin.js";
11
+ import { createAction } from "@downcity/agent/internal/plugin/core/PluginActionFactory.js";
12
+ import { z } from "zod";
11
13
  import type {
12
14
  PluginActions,
13
15
  PluginHttpDefinition,
@@ -56,7 +58,13 @@ export class WorkboardPlugin extends BasePlugin {
56
58
  * Workboard 对外 action。
57
59
  */
58
60
  readonly actions: PluginActions = {
59
- snapshot: {
61
+ snapshot: createAction({
62
+ description: "读取 workboard 当前的结构化运行态快照。",
63
+ input_schema: {
64
+ zod: z.object({}).passthrough(),
65
+ json_schema: { type: "object", properties: {} },
66
+ },
67
+ examples: [{ title: "读取快照", payload: {} }],
60
68
  execute: async ({ context }) => {
61
69
  const response = await readWorkboardSnapshot(context);
62
70
  return {
@@ -66,7 +74,7 @@ export class WorkboardPlugin extends BasePlugin {
66
74
  } as unknown as JsonValue,
67
75
  };
68
76
  },
69
- },
77
+ }),
70
78
  };
71
79
 
72
80
  /**