dsh-ta 0.1.0 → 0.2.0

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/im/say.js ADDED
@@ -0,0 +1,24 @@
1
+ import { randomUUID } from 'node:crypto'
2
+ import { findSayTarget } from './bindings.js'
3
+
4
+ export async function sayToFeishu(ctx, config, currentSessionId, text) {
5
+ const target = findSayTarget(config, currentSessionId)
6
+ if (!target) throw new Error('没有可用的飞书私聊绑定')
7
+ const controller = ctx.get('sessionController')
8
+ if (!controller?.resolveAgent) throw new Error('会话控制器不可用')
9
+ const resolved = await controller.resolveAgent(target.sessionId)
10
+ const agent = resolved?.agent
11
+ if (!agent) throw new Error('飞书会话当前不可用')
12
+ if (agent.status === 'running') return '目标会话正在运行,已跳过'
13
+ await agent.followup({
14
+ id: randomUUID(),
15
+ role: 'user',
16
+ content: [{
17
+ type: 'text',
18
+ text: `这是你主动想对博士说的一句话。不要调用 ta_say、不要调用任何工具,也不要解释;直接输出这句要发给博士的文本,im-connect 会负责投递:\n${text}`,
19
+ }],
20
+ source: { kind: 'ta-say', form: 'notice', summary: '主动对Ta说一句' },
21
+ })
22
+ return `已交给飞书会话 ${target.sessionId}`
23
+ }
24
+