@dcrays/dcgchat 0.2.18 → 0.2.19
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/package.json +1 -1
- package/src/skill.ts +72 -72
package/package.json
CHANGED
package/src/skill.ts
CHANGED
|
@@ -36,75 +36,75 @@ function sendEvent(msgContent: Record<string, any>) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
async function sendNewSessionCommand(ctx: SkillContext) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
}
|
|
39
|
+
// async function sendNewSessionCommand(ctx: SkillContext) {
|
|
40
|
+
// try {
|
|
41
|
+
// const core = getDcgchatRuntime();
|
|
42
|
+
// const log = ctx.runtime?.log ?? console.log;
|
|
43
|
+
// const params = getMsgParams();
|
|
44
|
+
// const account = resolveAccount(ctx.cfg, ctx.accountId);
|
|
45
|
+
// const userId = String(params.userId);
|
|
46
|
+
|
|
47
|
+
// const route = core.channel.routing.resolveAgentRoute({
|
|
48
|
+
// cfg: ctx.cfg,
|
|
49
|
+
// channel: "dcgchat",
|
|
50
|
+
// accountId: account.accountId,
|
|
51
|
+
// peer: { kind: "direct", id: userId },
|
|
52
|
+
// });
|
|
53
|
+
|
|
54
|
+
// const envelopeOptions = core.channel.reply.resolveEnvelopeFormatOptions(ctx.cfg);
|
|
55
|
+
// const bodyFormatted = core.channel.reply.formatAgentEnvelope({
|
|
56
|
+
// channel: "书灵墨宝",
|
|
57
|
+
// from: userId,
|
|
58
|
+
// timestamp: new Date(),
|
|
59
|
+
// envelope: envelopeOptions,
|
|
60
|
+
// body: "/new",
|
|
61
|
+
// });
|
|
62
|
+
|
|
63
|
+
// const ctxPayload = core.channel.reply.finalizeInboundContext({
|
|
64
|
+
// Body: bodyFormatted,
|
|
65
|
+
// RawBody: "/new",
|
|
66
|
+
// CommandBody: "/new",
|
|
67
|
+
// From: userId,
|
|
68
|
+
// To: userId,
|
|
69
|
+
// SessionKey: route.sessionKey,
|
|
70
|
+
// AccountId: params.sessionId,
|
|
71
|
+
// ChatType: "direct",
|
|
72
|
+
// SenderName: userId,
|
|
73
|
+
// SenderId: userId,
|
|
74
|
+
// Provider: "dcgchat" as const,
|
|
75
|
+
// Surface: "dcgchat" as const,
|
|
76
|
+
// MessageSid: Date.now().toString(),
|
|
77
|
+
// Timestamp: Date.now(),
|
|
78
|
+
// WasMentioned: true,
|
|
79
|
+
// CommandAuthorized: true,
|
|
80
|
+
// OriginatingChannel: "dcgchat" as const,
|
|
81
|
+
// OriginatingTo: `user:${userId}`,
|
|
82
|
+
// });
|
|
83
|
+
|
|
84
|
+
// const noopDispatcher = {
|
|
85
|
+
// sendToolResult: () => false,
|
|
86
|
+
// sendBlockReply: () => false,
|
|
87
|
+
// sendFinalReply: () => false,
|
|
88
|
+
// waitForIdle: async () => {},
|
|
89
|
+
// getQueuedCounts: () => ({ tool: 0, block: 0, final: 0 }),
|
|
90
|
+
// markComplete: () => {},
|
|
91
|
+
// };
|
|
92
|
+
|
|
93
|
+
// await core.channel.reply.withReplyDispatcher({
|
|
94
|
+
// dispatcher: noopDispatcher,
|
|
95
|
+
// run: () =>
|
|
96
|
+
// core.channel.reply.dispatchReplyFromConfig({
|
|
97
|
+
// ctx: ctxPayload,
|
|
98
|
+
// cfg: ctx.cfg,
|
|
99
|
+
// dispatcher: noopDispatcher,
|
|
100
|
+
// }),
|
|
101
|
+
// });
|
|
102
|
+
|
|
103
|
+
// log(`dcgchat: /new command dispatched silently after skill install`);
|
|
104
|
+
// } catch (err) {
|
|
105
|
+
// logDcgchat.error(`sendNewSessionCommand failed: ${err}`);
|
|
106
|
+
// }
|
|
107
|
+
// }
|
|
108
108
|
|
|
109
109
|
export async function installSkill(params: ISkillParams, msgContent: Record<string, any>, ctx?: SkillContext) {
|
|
110
110
|
const { path: cdnUrl, code } = params;
|
|
@@ -208,9 +208,9 @@ export async function installSkill(params: ISkillParams, msgContent: Record<stri
|
|
|
208
208
|
});
|
|
209
209
|
});
|
|
210
210
|
sendEvent({ ...msgContent, status: 'ok' })
|
|
211
|
-
if (ctx) {
|
|
212
|
-
|
|
213
|
-
}
|
|
211
|
+
// if (ctx) {
|
|
212
|
+
// await sendNewSessionCommand(ctx);
|
|
213
|
+
// }
|
|
214
214
|
} catch (error) {
|
|
215
215
|
// 如果安装失败,清理目录
|
|
216
216
|
if (fs.existsSync(skillDir)) {
|