@downcity/plugins 1.0.95 → 1.0.103
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/asr/Plugin.d.ts +1 -15
- package/bin/asr/Plugin.d.ts.map +1 -1
- package/bin/asr/Plugin.js +36 -5
- package/bin/asr/Plugin.js.map +1 -1
- package/bin/chat/runtime/ChatAuthorizationRuntime.d.ts.map +1 -1
- package/bin/chat/runtime/ChatAuthorizationRuntime.js +53 -12
- package/bin/chat/runtime/ChatAuthorizationRuntime.js.map +1 -1
- package/bin/chat/runtime/ChatPluginActionRegistry.d.ts.map +1 -1
- package/bin/chat/runtime/ChatPluginActionRegistry.js +114 -42
- package/bin/chat/runtime/ChatPluginActionRegistry.js.map +1 -1
- package/bin/contact/Action.d.ts.map +1 -1
- package/bin/contact/Action.js +159 -37
- package/bin/contact/Action.js.map +1 -1
- package/bin/image/ImagePlugin.d.ts +12 -55
- package/bin/image/ImagePlugin.d.ts.map +1 -1
- package/bin/image/ImagePlugin.js +374 -138
- package/bin/image/ImagePlugin.js.map +1 -1
- package/bin/image/types/ImagePlugin.d.ts +94 -31
- package/bin/image/types/ImagePlugin.d.ts.map +1 -1
- package/bin/image/types/ImagePlugin.js +1 -1
- package/bin/index.d.ts +1 -1
- package/bin/index.d.ts.map +1 -1
- package/bin/memory/MemoryPlugin.d.ts.map +1 -1
- package/bin/memory/MemoryPlugin.js +130 -17
- package/bin/memory/MemoryPlugin.js.map +1 -1
- package/bin/skill/Plugin.d.ts.map +1 -1
- package/bin/skill/Plugin.js +90 -11
- package/bin/skill/Plugin.js.map +1 -1
- package/bin/task/runtime/TaskPluginActionRegistry.d.ts.map +1 -1
- package/bin/task/runtime/TaskPluginActionRegistry.js +202 -24
- package/bin/task/runtime/TaskPluginActionRegistry.js.map +1 -1
- package/bin/tts/Plugin.d.ts +1 -15
- package/bin/tts/Plugin.d.ts.map +1 -1
- package/bin/tts/Plugin.js +38 -5
- package/bin/tts/Plugin.js.map +1 -1
- package/bin/web/Plugin.d.ts +2 -19
- package/bin/web/Plugin.d.ts.map +1 -1
- package/bin/web/Plugin.js +39 -5
- package/bin/web/Plugin.js.map +1 -1
- package/bin/workboard/Plugin.d.ts.map +1 -1
- package/bin/workboard/Plugin.js +10 -2
- package/bin/workboard/Plugin.js.map +1 -1
- package/package.json +3 -3
- package/src/asr/Plugin.ts +37 -5
- package/src/chat/runtime/ChatAuthorizationRuntime.ts +53 -12
- package/src/chat/runtime/ChatPluginActionRegistry.ts +114 -42
- package/src/contact/Action.ts +159 -37
- package/src/image/ImagePlugin.ts +412 -211
- package/src/image/types/ImagePlugin.ts +100 -31
- package/src/index.ts +5 -1
- package/src/memory/MemoryPlugin.ts +130 -17
- package/src/skill/Plugin.ts +101 -21
- package/src/task/runtime/TaskPluginActionRegistry.ts +209 -24
- package/src/tts/Plugin.ts +39 -5
- package/src/web/Plugin.ts +39 -5
- package/src/workboard/Plugin.ts +10 -2
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
|
|
10
10
|
import type { Command } from "commander";
|
|
11
11
|
import type { PluginActions } from "@downcity/agent/internal/plugin/types/Plugin.js";
|
|
12
|
+
import { createAction } from "@downcity/agent/internal/plugin/core/PluginActionFactory.js";
|
|
13
|
+
import { z } from "zod";
|
|
12
14
|
import type {
|
|
13
15
|
ChatCloseActionPayload,
|
|
14
16
|
ChatConfigurationActionPayload,
|
|
@@ -101,7 +103,12 @@ export function createChatPluginActions(params: {
|
|
|
101
103
|
channelState: ChatChannelState;
|
|
102
104
|
}): PluginActions {
|
|
103
105
|
return {
|
|
104
|
-
status: {
|
|
106
|
+
status: createAction({
|
|
107
|
+
description: "查看 chat 渠道连接状态。",
|
|
108
|
+
input_schema: {
|
|
109
|
+
zod: z.object({}).passthrough(),
|
|
110
|
+
json_schema: { type: "object", properties: {}, additionalProperties: true },
|
|
111
|
+
},
|
|
105
112
|
command: {
|
|
106
113
|
description: "查看 chat 渠道连接状态",
|
|
107
114
|
configure(command: Command) {
|
|
@@ -113,11 +120,16 @@ export function createChatPluginActions(params: {
|
|
|
113
120
|
return executeChatStatusAction({
|
|
114
121
|
state: params.channelState,
|
|
115
122
|
context: actionParams.context,
|
|
116
|
-
payload: actionParams.
|
|
123
|
+
payload: actionParams.input as ChatStatusActionPayload,
|
|
117
124
|
});
|
|
118
125
|
},
|
|
119
|
-
},
|
|
120
|
-
test: {
|
|
126
|
+
}),
|
|
127
|
+
test: createAction({
|
|
128
|
+
description: "测试 chat 渠道连通性。",
|
|
129
|
+
input_schema: {
|
|
130
|
+
zod: z.object({}).passthrough(),
|
|
131
|
+
json_schema: { type: "object", properties: {}, additionalProperties: true },
|
|
132
|
+
},
|
|
121
133
|
command: {
|
|
122
134
|
description: "测试 chat 渠道连通性",
|
|
123
135
|
configure(command: Command) {
|
|
@@ -129,11 +141,16 @@ export function createChatPluginActions(params: {
|
|
|
129
141
|
return executeChatTestAction({
|
|
130
142
|
state: params.channelState,
|
|
131
143
|
context: actionParams.context,
|
|
132
|
-
payload: actionParams.
|
|
144
|
+
payload: actionParams.input as ChatTestActionPayload,
|
|
133
145
|
});
|
|
134
146
|
},
|
|
135
|
-
},
|
|
136
|
-
reconnect: {
|
|
147
|
+
}),
|
|
148
|
+
reconnect: createAction({
|
|
149
|
+
description: "重连 chat 渠道(默认全部)。",
|
|
150
|
+
input_schema: {
|
|
151
|
+
zod: z.object({}).passthrough(),
|
|
152
|
+
json_schema: { type: "object", properties: {}, additionalProperties: true },
|
|
153
|
+
},
|
|
137
154
|
command: {
|
|
138
155
|
description: "重连 chat 渠道(默认全部)",
|
|
139
156
|
configure(command: Command) {
|
|
@@ -145,11 +162,16 @@ export function createChatPluginActions(params: {
|
|
|
145
162
|
return executeChatReconnectAction({
|
|
146
163
|
state: params.channelState,
|
|
147
164
|
context: actionParams.context,
|
|
148
|
-
payload: actionParams.
|
|
165
|
+
payload: actionParams.input as ChatReconnectActionPayload,
|
|
149
166
|
});
|
|
150
167
|
},
|
|
151
|
-
},
|
|
152
|
-
open: {
|
|
168
|
+
}),
|
|
169
|
+
open: createAction({
|
|
170
|
+
description: "打开(启用)指定 chat 渠道。",
|
|
171
|
+
input_schema: {
|
|
172
|
+
zod: z.object({}).passthrough(),
|
|
173
|
+
json_schema: { type: "object", properties: {}, additionalProperties: true },
|
|
174
|
+
},
|
|
153
175
|
command: {
|
|
154
176
|
description: "打开 chat 渠道(enabled=true,已配置则尝试启动)",
|
|
155
177
|
configure(command: Command) {
|
|
@@ -161,11 +183,16 @@ export function createChatPluginActions(params: {
|
|
|
161
183
|
return executeChatOpenAction({
|
|
162
184
|
state: params.channelState,
|
|
163
185
|
context: actionParams.context,
|
|
164
|
-
payload: actionParams.
|
|
186
|
+
payload: actionParams.input as ChatOpenActionPayload,
|
|
165
187
|
});
|
|
166
188
|
},
|
|
167
|
-
},
|
|
168
|
-
close: {
|
|
189
|
+
}),
|
|
190
|
+
close: createAction({
|
|
191
|
+
description: "关闭(禁用)指定 chat 渠道。",
|
|
192
|
+
input_schema: {
|
|
193
|
+
zod: z.object({}).passthrough(),
|
|
194
|
+
json_schema: { type: "object", properties: {}, additionalProperties: true },
|
|
195
|
+
},
|
|
169
196
|
command: {
|
|
170
197
|
description: "关闭 chat 渠道(enabled=false,并停止运行)",
|
|
171
198
|
configure(command: Command) {
|
|
@@ -177,11 +204,16 @@ export function createChatPluginActions(params: {
|
|
|
177
204
|
return executeChatCloseAction({
|
|
178
205
|
state: params.channelState,
|
|
179
206
|
context: actionParams.context,
|
|
180
|
-
payload: actionParams.
|
|
207
|
+
payload: actionParams.input as ChatCloseActionPayload,
|
|
181
208
|
});
|
|
182
209
|
},
|
|
183
|
-
},
|
|
184
|
-
configuration: {
|
|
210
|
+
}),
|
|
211
|
+
configuration: createAction({
|
|
212
|
+
description: "查看 chat 渠道配置元信息。",
|
|
213
|
+
input_schema: {
|
|
214
|
+
zod: z.object({}).passthrough(),
|
|
215
|
+
json_schema: { type: "object", properties: {}, additionalProperties: true },
|
|
216
|
+
},
|
|
185
217
|
command: {
|
|
186
218
|
description: "查看 chat 渠道配置元信息(字段、类型、说明)",
|
|
187
219
|
configure(command: Command) {
|
|
@@ -192,11 +224,16 @@ export function createChatPluginActions(params: {
|
|
|
192
224
|
execute: async (actionParams) => {
|
|
193
225
|
return executeChatConfigurationAction({
|
|
194
226
|
context: actionParams.context,
|
|
195
|
-
payload: actionParams.
|
|
227
|
+
payload: actionParams.input as ChatConfigurationActionPayload,
|
|
196
228
|
});
|
|
197
229
|
},
|
|
198
|
-
},
|
|
199
|
-
configure: {
|
|
230
|
+
}),
|
|
231
|
+
configure: createAction({
|
|
232
|
+
description: "更新 chat 渠道运行态参数。",
|
|
233
|
+
input_schema: {
|
|
234
|
+
zod: z.object({}).passthrough(),
|
|
235
|
+
json_schema: { type: "object", properties: {}, additionalProperties: true },
|
|
236
|
+
},
|
|
200
237
|
command: {
|
|
201
238
|
description: "更新 chat 渠道运行态参数(可选立即重载)",
|
|
202
239
|
configure(command: Command) {
|
|
@@ -214,11 +251,16 @@ export function createChatPluginActions(params: {
|
|
|
214
251
|
return executeChatConfigureAction({
|
|
215
252
|
state: params.channelState,
|
|
216
253
|
context: actionParams.context,
|
|
217
|
-
payload: actionParams.
|
|
254
|
+
payload: actionParams.input as ChatConfigureActionPayload,
|
|
218
255
|
});
|
|
219
256
|
},
|
|
220
|
-
},
|
|
221
|
-
list: {
|
|
257
|
+
}),
|
|
258
|
+
list: createAction({
|
|
259
|
+
description: "列出当前 agent 已记录的 chat 会话。",
|
|
260
|
+
input_schema: {
|
|
261
|
+
zod: z.object({}).passthrough(),
|
|
262
|
+
json_schema: { type: "object", properties: {}, additionalProperties: true },
|
|
263
|
+
},
|
|
222
264
|
command: {
|
|
223
265
|
description: "列出当前 agent 已记录的 chat 会话(chatTitle/chatKey)",
|
|
224
266
|
configure(command: Command) {
|
|
@@ -232,11 +274,16 @@ export function createChatPluginActions(params: {
|
|
|
232
274
|
execute: async (actionParams) => {
|
|
233
275
|
return executeChatListAction({
|
|
234
276
|
context: actionParams.context,
|
|
235
|
-
payload: actionParams.
|
|
277
|
+
payload: actionParams.input as ChatListActionPayload,
|
|
236
278
|
});
|
|
237
279
|
},
|
|
238
|
-
},
|
|
239
|
-
info: {
|
|
280
|
+
}),
|
|
281
|
+
info: createAction({
|
|
282
|
+
description: "查看指定 chat 会话的路由/路径/上下文快照。",
|
|
283
|
+
input_schema: {
|
|
284
|
+
zod: z.object({}).passthrough(),
|
|
285
|
+
json_schema: { type: "object", properties: {}, additionalProperties: true },
|
|
286
|
+
},
|
|
240
287
|
command: {
|
|
241
288
|
description: "查看指定 chat 会话信息(路由/本地路径/上下文快照)",
|
|
242
289
|
configure(command: Command) {
|
|
@@ -249,11 +296,16 @@ export function createChatPluginActions(params: {
|
|
|
249
296
|
execute: async (actionParams) => {
|
|
250
297
|
return executeChatInfoAction({
|
|
251
298
|
context: actionParams.context,
|
|
252
|
-
payload: actionParams.
|
|
299
|
+
payload: actionParams.input as ChatInfoActionPayload,
|
|
253
300
|
});
|
|
254
301
|
},
|
|
255
|
-
},
|
|
256
|
-
send: {
|
|
302
|
+
}),
|
|
303
|
+
send: createAction({
|
|
304
|
+
description: "向目标 chatKey 发送消息(支持文本/附件/延迟)。",
|
|
305
|
+
input_schema: {
|
|
306
|
+
zod: z.object({}).passthrough(),
|
|
307
|
+
json_schema: { type: "object", properties: {}, additionalProperties: true },
|
|
308
|
+
},
|
|
257
309
|
command: {
|
|
258
310
|
description: "发送消息到目标 chatKey",
|
|
259
311
|
configure(command: Command) {
|
|
@@ -274,11 +326,16 @@ export function createChatPluginActions(params: {
|
|
|
274
326
|
execute: async (actionParams) => {
|
|
275
327
|
return executeChatSendAction({
|
|
276
328
|
context: actionParams.context,
|
|
277
|
-
payload: actionParams.
|
|
329
|
+
payload: actionParams.input as ChatSendActionPayload,
|
|
278
330
|
});
|
|
279
331
|
},
|
|
280
|
-
},
|
|
281
|
-
react: {
|
|
332
|
+
}),
|
|
333
|
+
react: createAction({
|
|
334
|
+
description: "给目标消息贴表情(当前仅 Telegram 支持)。",
|
|
335
|
+
input_schema: {
|
|
336
|
+
zod: z.object({}).passthrough(),
|
|
337
|
+
json_schema: { type: "object", properties: {}, additionalProperties: true },
|
|
338
|
+
},
|
|
282
339
|
command: {
|
|
283
340
|
description: "给目标消息贴表情(当前仅 Telegram 支持)",
|
|
284
341
|
configure(command: Command) {
|
|
@@ -297,11 +354,16 @@ export function createChatPluginActions(params: {
|
|
|
297
354
|
execute: async (actionParams) => {
|
|
298
355
|
return executeChatReactAction({
|
|
299
356
|
context: actionParams.context,
|
|
300
|
-
payload: actionParams.
|
|
357
|
+
payload: actionParams.input as ChatReactActionPayload,
|
|
301
358
|
});
|
|
302
359
|
},
|
|
303
|
-
},
|
|
304
|
-
context: {
|
|
360
|
+
}),
|
|
361
|
+
context: createAction({
|
|
362
|
+
description: "查看当前会话上下文快照。",
|
|
363
|
+
input_schema: {
|
|
364
|
+
zod: z.object({}).passthrough(),
|
|
365
|
+
json_schema: { type: "object", properties: {}, additionalProperties: true },
|
|
366
|
+
},
|
|
305
367
|
command: {
|
|
306
368
|
description: "查看当前会话上下文快照",
|
|
307
369
|
configure(command: Command) {
|
|
@@ -318,11 +380,16 @@ export function createChatPluginActions(params: {
|
|
|
318
380
|
execute: async (actionParams) => {
|
|
319
381
|
return executeChatContextAction({
|
|
320
382
|
context: actionParams.context,
|
|
321
|
-
payload: actionParams.
|
|
383
|
+
payload: actionParams.input as ChatSessionActionPayload,
|
|
322
384
|
});
|
|
323
385
|
},
|
|
324
|
-
},
|
|
325
|
-
delete: {
|
|
386
|
+
}),
|
|
387
|
+
delete: createAction({
|
|
388
|
+
description: "彻底删除指定 chat 会话(映射+历史+context)。",
|
|
389
|
+
input_schema: {
|
|
390
|
+
zod: z.object({}).passthrough(),
|
|
391
|
+
json_schema: { type: "object", properties: {}, additionalProperties: true },
|
|
392
|
+
},
|
|
326
393
|
command: {
|
|
327
394
|
description: "彻底删除指定 chat 会话(映射+历史+context)",
|
|
328
395
|
configure(command: Command) {
|
|
@@ -335,11 +402,16 @@ export function createChatPluginActions(params: {
|
|
|
335
402
|
execute: async (actionParams) => {
|
|
336
403
|
return executeChatDeleteAction({
|
|
337
404
|
context: actionParams.context,
|
|
338
|
-
payload: actionParams.
|
|
405
|
+
payload: actionParams.input as ChatDeleteActionPayload,
|
|
339
406
|
});
|
|
340
407
|
},
|
|
341
|
-
},
|
|
342
|
-
history: {
|
|
408
|
+
}),
|
|
409
|
+
history: createAction({
|
|
410
|
+
description: "读取 chat 历史消息。",
|
|
411
|
+
input_schema: {
|
|
412
|
+
zod: z.object({}).passthrough(),
|
|
413
|
+
json_schema: { type: "object", properties: {}, additionalProperties: true },
|
|
414
|
+
},
|
|
343
415
|
command: {
|
|
344
416
|
description: "读取 chat 历史消息(默认最近 30 条)",
|
|
345
417
|
configure(command: Command) {
|
|
@@ -359,9 +431,9 @@ export function createChatPluginActions(params: {
|
|
|
359
431
|
execute: async (actionParams) => {
|
|
360
432
|
return executeChatHistoryAction({
|
|
361
433
|
context: actionParams.context,
|
|
362
|
-
payload: actionParams.
|
|
434
|
+
payload: actionParams.input as ChatHistoryActionPayload,
|
|
363
435
|
});
|
|
364
436
|
},
|
|
365
|
-
},
|
|
437
|
+
}),
|
|
366
438
|
};
|
|
367
439
|
}
|
package/src/contact/Action.ts
CHANGED
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
import type { AgentContext } from "@downcity/agent/internal/types/runtime/agent/AgentContext.js";
|
|
10
10
|
import type { JsonObject, JsonValue } from "@downcity/agent/internal/types/common/Json.js";
|
|
11
11
|
import type { PluginActions } from "@downcity/agent/internal/plugin/types/Plugin.js";
|
|
12
|
+
import { createAction } from "@downcity/agent/internal/plugin/core/PluginActionFactory.js";
|
|
13
|
+
import { z } from "zod";
|
|
12
14
|
import type {
|
|
13
15
|
ContactApproveCommandPayload,
|
|
14
16
|
ContactChatCommandPayload,
|
|
@@ -94,7 +96,18 @@ export type ContactActionHandlers = {
|
|
|
94
96
|
*/
|
|
95
97
|
export function createContactActions(handlers: ContactActionHandlers): PluginActions {
|
|
96
98
|
return {
|
|
97
|
-
link: {
|
|
99
|
+
link: createAction({
|
|
100
|
+
description: "生成一次性 contact link code,供其他 agent approve。",
|
|
101
|
+
input_schema: {
|
|
102
|
+
zod: z.object({ ttlSeconds: z.number().optional() }),
|
|
103
|
+
json_schema: {
|
|
104
|
+
type: "object",
|
|
105
|
+
properties: {
|
|
106
|
+
ttlSeconds: { type: "number", description: "link 过期秒数,默认 600" },
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
examples: [{ title: "生成默认 link", payload: {} }],
|
|
98
111
|
command: {
|
|
99
112
|
description: "生成一次性 contact link code,交给另一个 agent approve",
|
|
100
113
|
configure(command) {
|
|
@@ -110,11 +123,29 @@ export function createContactActions(handlers: ContactActionHandlers): PluginAct
|
|
|
110
123
|
success: true,
|
|
111
124
|
data: await handlers.link(
|
|
112
125
|
params.context,
|
|
113
|
-
params.
|
|
126
|
+
params.input as ContactLinkCommandPayload,
|
|
114
127
|
),
|
|
115
128
|
}),
|
|
116
|
-
},
|
|
117
|
-
approve: {
|
|
129
|
+
}),
|
|
130
|
+
approve: createAction({
|
|
131
|
+
description: "使用 contact link code 建立点对点联系。",
|
|
132
|
+
input_schema: {
|
|
133
|
+
zod: z.object({
|
|
134
|
+
code: z.string(),
|
|
135
|
+
name: z.string().optional(),
|
|
136
|
+
}),
|
|
137
|
+
json_schema: {
|
|
138
|
+
type: "object",
|
|
139
|
+
required: ["code"],
|
|
140
|
+
properties: {
|
|
141
|
+
code: { type: "string", description: "link code" },
|
|
142
|
+
name: { type: "string", description: "本地 contact 别名" },
|
|
143
|
+
},
|
|
144
|
+
},
|
|
145
|
+
},
|
|
146
|
+
examples: [
|
|
147
|
+
{ title: "approve link", payload: { code: "abc123", name: "alice" } },
|
|
148
|
+
],
|
|
118
149
|
command: {
|
|
119
150
|
description: "使用 contact link code 建立点对点联系",
|
|
120
151
|
configure(command) {
|
|
@@ -134,11 +165,17 @@ export function createContactActions(handlers: ContactActionHandlers): PluginAct
|
|
|
134
165
|
success: true,
|
|
135
166
|
data: await handlers.approve(
|
|
136
167
|
params.context,
|
|
137
|
-
params.
|
|
168
|
+
params.input as unknown as ContactApproveCommandPayload,
|
|
138
169
|
),
|
|
139
170
|
}),
|
|
140
|
-
},
|
|
141
|
-
list: {
|
|
171
|
+
}),
|
|
172
|
+
list: createAction({
|
|
173
|
+
description: "列出已建立的 contact。",
|
|
174
|
+
input_schema: {
|
|
175
|
+
zod: z.object({}).passthrough(),
|
|
176
|
+
json_schema: { type: "object", properties: {} },
|
|
177
|
+
},
|
|
178
|
+
examples: [{ title: "列出 contact", payload: {} }],
|
|
142
179
|
command: {
|
|
143
180
|
description: "列出已建立的 contact",
|
|
144
181
|
mapInput() {
|
|
@@ -151,8 +188,26 @@ export function createContactActions(handlers: ContactActionHandlers): PluginAct
|
|
|
151
188
|
contacts: await listContacts(params.context.rootPath),
|
|
152
189
|
} as unknown as JsonValue,
|
|
153
190
|
}),
|
|
154
|
-
},
|
|
155
|
-
check: {
|
|
191
|
+
}),
|
|
192
|
+
check: createAction({
|
|
193
|
+
description: "检查 contact 或 endpoint 当前是否在线可用。",
|
|
194
|
+
input_schema: {
|
|
195
|
+
zod: z.object({
|
|
196
|
+
target: z.string().optional(),
|
|
197
|
+
endpoint: z.string().optional(),
|
|
198
|
+
}),
|
|
199
|
+
json_schema: {
|
|
200
|
+
type: "object",
|
|
201
|
+
properties: {
|
|
202
|
+
target: { type: "string", description: "已保存的 contact 名" },
|
|
203
|
+
endpoint: { type: "string", description: "直接检查的 endpoint" },
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
examples: [
|
|
208
|
+
{ title: "检查 contact", payload: { target: "alice" } },
|
|
209
|
+
{ title: "检查 endpoint", payload: { endpoint: "https://example.com" } },
|
|
210
|
+
],
|
|
156
211
|
command: {
|
|
157
212
|
description: "检查 contact 或 endpoint 当前是否在线可用",
|
|
158
213
|
configure(command) {
|
|
@@ -172,11 +227,30 @@ export function createContactActions(handlers: ContactActionHandlers): PluginAct
|
|
|
172
227
|
success: true,
|
|
173
228
|
data: await handlers.check(
|
|
174
229
|
params.context,
|
|
175
|
-
params.
|
|
230
|
+
params.input as ContactCheckCommandPayload,
|
|
176
231
|
),
|
|
177
232
|
}),
|
|
178
|
-
},
|
|
179
|
-
chat: {
|
|
233
|
+
}),
|
|
234
|
+
chat: createAction({
|
|
235
|
+
description: "和某个 contact 的长期对话线聊天,或读取对话历史。",
|
|
236
|
+
input_schema: {
|
|
237
|
+
zod: z.object({
|
|
238
|
+
to: z.string(),
|
|
239
|
+
message: z.string().optional(),
|
|
240
|
+
}),
|
|
241
|
+
json_schema: {
|
|
242
|
+
type: "object",
|
|
243
|
+
required: ["to"],
|
|
244
|
+
properties: {
|
|
245
|
+
to: { type: "string", description: "目标 contact" },
|
|
246
|
+
message: { type: "string", description: "要发送的消息" },
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
examples: [
|
|
251
|
+
{ title: "发送消息", payload: { to: "alice", message: "hello" } },
|
|
252
|
+
{ title: "读取历史", payload: { to: "alice" } },
|
|
253
|
+
],
|
|
180
254
|
command: {
|
|
181
255
|
description: "和某个 contact 的长期对话线聊天",
|
|
182
256
|
configure(command) {
|
|
@@ -195,11 +269,36 @@ export function createContactActions(handlers: ContactActionHandlers): PluginAct
|
|
|
195
269
|
success: true,
|
|
196
270
|
data: await handlers.chat(
|
|
197
271
|
params.context,
|
|
198
|
-
params.
|
|
272
|
+
params.input as unknown as ContactChatCommandPayload,
|
|
199
273
|
),
|
|
200
274
|
}),
|
|
201
|
-
},
|
|
202
|
-
share: {
|
|
275
|
+
}),
|
|
276
|
+
share: createAction({
|
|
277
|
+
description: "向 contact 分享文本、链接、文件或目录。",
|
|
278
|
+
input_schema: {
|
|
279
|
+
zod: z.object({
|
|
280
|
+
to: z.string(),
|
|
281
|
+
text: z.string().optional(),
|
|
282
|
+
links: z.array(z.string()).optional(),
|
|
283
|
+
paths: z.array(z.string()).optional(),
|
|
284
|
+
}),
|
|
285
|
+
json_schema: {
|
|
286
|
+
type: "object",
|
|
287
|
+
required: ["to"],
|
|
288
|
+
properties: {
|
|
289
|
+
to: { type: "string", description: "目标 contact" },
|
|
290
|
+
text: { type: "string", description: "分享文本" },
|
|
291
|
+
links: { type: "array", items: { type: "string" }, description: "分享链接" },
|
|
292
|
+
paths: { type: "array", items: { type: "string" }, description: "分享文件/目录路径" },
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
},
|
|
296
|
+
examples: [
|
|
297
|
+
{
|
|
298
|
+
title: "分享一段文本",
|
|
299
|
+
payload: { to: "alice", text: "看看这个" },
|
|
300
|
+
},
|
|
301
|
+
],
|
|
203
302
|
command: {
|
|
204
303
|
description: "向 contact 分享文本、链接、文件或目录",
|
|
205
304
|
configure(command) {
|
|
@@ -227,11 +326,17 @@ export function createContactActions(handlers: ContactActionHandlers): PluginAct
|
|
|
227
326
|
success: true,
|
|
228
327
|
data: await handlers.share(
|
|
229
328
|
params.context,
|
|
230
|
-
params.
|
|
329
|
+
params.input as unknown as ContactShareCommandPayload,
|
|
231
330
|
),
|
|
232
331
|
}),
|
|
233
|
-
},
|
|
234
|
-
inbox: {
|
|
332
|
+
}),
|
|
333
|
+
inbox: createAction({
|
|
334
|
+
description: "查看 contact inbox。",
|
|
335
|
+
input_schema: {
|
|
336
|
+
zod: z.object({}).passthrough(),
|
|
337
|
+
json_schema: { type: "object", properties: {} },
|
|
338
|
+
},
|
|
339
|
+
examples: [{ title: "查看 inbox", payload: {} }],
|
|
235
340
|
command: {
|
|
236
341
|
description: "查看 contact inbox",
|
|
237
342
|
mapInput() {
|
|
@@ -244,8 +349,20 @@ export function createContactActions(handlers: ContactActionHandlers): PluginAct
|
|
|
244
349
|
shares: await listContactInboxShares(params.context.rootPath),
|
|
245
350
|
} as unknown as JsonValue,
|
|
246
351
|
}),
|
|
247
|
-
},
|
|
248
|
-
receive: {
|
|
352
|
+
}),
|
|
353
|
+
receive: createAction({
|
|
354
|
+
description: "接收 inbox 中的 share。",
|
|
355
|
+
input_schema: {
|
|
356
|
+
zod: z.object({ shareId: z.string() }),
|
|
357
|
+
json_schema: {
|
|
358
|
+
type: "object",
|
|
359
|
+
required: ["shareId"],
|
|
360
|
+
properties: {
|
|
361
|
+
shareId: { type: "string", description: "inbox 中的 shareId" },
|
|
362
|
+
},
|
|
363
|
+
},
|
|
364
|
+
},
|
|
365
|
+
examples: [{ title: "接收 share", payload: { shareId: "share_1" } }],
|
|
249
366
|
command: {
|
|
250
367
|
description: "接收 inbox 中的 share",
|
|
251
368
|
configure(command) {
|
|
@@ -261,40 +378,44 @@ export function createContactActions(handlers: ContactActionHandlers): PluginAct
|
|
|
261
378
|
success: true,
|
|
262
379
|
data: (await receiveShare({
|
|
263
380
|
projectRoot: params.context.rootPath,
|
|
264
|
-
shareId: (params.
|
|
381
|
+
shareId: (params.input as unknown as ContactReceiveCommandPayload).shareId,
|
|
265
382
|
})) as unknown as JsonValue,
|
|
266
383
|
}),
|
|
267
|
-
},
|
|
268
|
-
remoteping: {
|
|
384
|
+
}),
|
|
385
|
+
remoteping: createAction({
|
|
386
|
+
description: "处理远端 ping 请求(内部 endpoint)。",
|
|
269
387
|
execute: async (params) => ({
|
|
270
388
|
success: true,
|
|
271
389
|
data: (await handlers.remotePing(
|
|
272
390
|
params.context,
|
|
273
|
-
params.
|
|
391
|
+
params.input as unknown as { token?: string },
|
|
274
392
|
)) as unknown as JsonValue,
|
|
275
393
|
}),
|
|
276
|
-
},
|
|
277
|
-
remoteapprove: {
|
|
394
|
+
}),
|
|
395
|
+
remoteapprove: createAction({
|
|
396
|
+
description: "处理远端 approve 请求(内部 endpoint)。",
|
|
278
397
|
execute: async (params) => ({
|
|
279
398
|
success: true,
|
|
280
399
|
data: (await handlers.remoteApprove(
|
|
281
400
|
params.context,
|
|
282
|
-
readContactObject(params.
|
|
401
|
+
readContactObject(params.input) as unknown as ContactApproveLinkRequest,
|
|
283
402
|
)) as unknown as JsonValue,
|
|
284
403
|
}),
|
|
285
|
-
},
|
|
286
|
-
remoteconfirm: {
|
|
404
|
+
}),
|
|
405
|
+
remoteconfirm: createAction({
|
|
406
|
+
description: "处理远端 confirm 请求(内部 endpoint)。",
|
|
287
407
|
execute: async (params) => ({
|
|
288
408
|
success: true,
|
|
289
409
|
data: (await handlers.remoteConfirm(
|
|
290
410
|
params.context,
|
|
291
|
-
readContactObject(params.
|
|
411
|
+
readContactObject(params.input) as unknown as ContactConfirmRequest,
|
|
292
412
|
)) as unknown as JsonValue,
|
|
293
413
|
}),
|
|
294
|
-
},
|
|
295
|
-
remotechat: {
|
|
414
|
+
}),
|
|
415
|
+
remotechat: createAction({
|
|
416
|
+
description: "处理远端 chat 请求(内部 endpoint)。",
|
|
296
417
|
execute: async (params) => {
|
|
297
|
-
const payload = readContactObject(params.
|
|
418
|
+
const payload = readContactObject(params.input);
|
|
298
419
|
const body = readContactObject(payload.body);
|
|
299
420
|
return {
|
|
300
421
|
success: true,
|
|
@@ -305,12 +426,13 @@ export function createContactActions(handlers: ContactActionHandlers): PluginAct
|
|
|
305
426
|
})) as unknown as JsonValue,
|
|
306
427
|
};
|
|
307
428
|
},
|
|
308
|
-
},
|
|
309
|
-
remoteshare: {
|
|
429
|
+
}),
|
|
430
|
+
remoteshare: createAction({
|
|
431
|
+
description: "处理远端 share 请求(内部 endpoint)。",
|
|
310
432
|
execute: async (params) => ({
|
|
311
433
|
success: true,
|
|
312
|
-
data: (await handlers.remoteShare(params.context, params.
|
|
434
|
+
data: (await handlers.remoteShare(params.context, params.input)) as unknown as JsonValue,
|
|
313
435
|
}),
|
|
314
|
-
},
|
|
436
|
+
}),
|
|
315
437
|
};
|
|
316
438
|
}
|