team-anya-cli 0.1.8 → 1.0.1

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 (168) hide show
  1. package/README.md +1 -37
  2. package/package.json +6 -37
  3. package/anya/prompts/execution-guides/git-delivery.md +0 -38
  4. package/anya/prompts/execution-guides/testing-and-self-heal.md +0 -28
  5. package/anya/prompts/protocols/brief-assembly.md +0 -55
  6. package/anya/prompts/protocols/report.md +0 -175
  7. package/anya/prompts/protocols/review.md +0 -90
  8. package/anya/prompts/task-claude-md.template.md +0 -32
  9. package/apps/server/dist/broker/cc-broker.js +0 -261
  10. package/apps/server/dist/cli.js +0 -296
  11. package/apps/server/dist/config.js +0 -76
  12. package/apps/server/dist/daemon.js +0 -51
  13. package/apps/server/dist/franky/context-builder.js +0 -160
  14. package/apps/server/dist/franky/franky-mcp-server.js +0 -107
  15. package/apps/server/dist/franky/franky-orchestrator.js +0 -450
  16. package/apps/server/dist/franky/index.js +0 -5
  17. package/apps/server/dist/franky/topic-router.js +0 -16
  18. package/apps/server/dist/gateway/chat-sync.js +0 -135
  19. package/apps/server/dist/gateway/command-router.js +0 -114
  20. package/apps/server/dist/gateway/commands/cancel.js +0 -32
  21. package/apps/server/dist/gateway/commands/help.js +0 -16
  22. package/apps/server/dist/gateway/commands/index.js +0 -26
  23. package/apps/server/dist/gateway/commands/restart.js +0 -34
  24. package/apps/server/dist/gateway/commands/status.js +0 -34
  25. package/apps/server/dist/gateway/commands/tasks.js +0 -33
  26. package/apps/server/dist/gateway/feishu-sender.js +0 -410
  27. package/apps/server/dist/gateway/feishu-ws.js +0 -256
  28. package/apps/server/dist/gateway/http.js +0 -1019
  29. package/apps/server/dist/gateway/media-downloader.js +0 -149
  30. package/apps/server/dist/gateway/message-events.js +0 -10
  31. package/apps/server/dist/gateway/message-intake.js +0 -67
  32. package/apps/server/dist/gateway/message-queue.js +0 -118
  33. package/apps/server/dist/gateway/session-reader.js +0 -142
  34. package/apps/server/dist/gateway/ws-push.js +0 -115
  35. package/apps/server/dist/loid/brain.js +0 -105
  36. package/apps/server/dist/loid/clarifier.js +0 -162
  37. package/apps/server/dist/loid/context-builder.js +0 -413
  38. package/apps/server/dist/loid/mcp-server.js +0 -106
  39. package/apps/server/dist/loid/memory-settler.js +0 -189
  40. package/apps/server/dist/loid/opportunity-manager.js +0 -148
  41. package/apps/server/dist/loid/profile-updater.js +0 -179
  42. package/apps/server/dist/loid/reporter.js +0 -148
  43. package/apps/server/dist/loid/schemas.js +0 -117
  44. package/apps/server/dist/loid/self-calibrator.js +0 -314
  45. package/apps/server/dist/loid/session-manager.js +0 -301
  46. package/apps/server/dist/loid/session.js +0 -271
  47. package/apps/server/dist/loid/worktree-manager.js +0 -191
  48. package/apps/server/dist/main.js +0 -393
  49. package/apps/server/dist/tracing/index.js +0 -2
  50. package/apps/server/dist/tracing/trace-context.js +0 -92
  51. package/apps/server/dist/types/message.js +0 -2
  52. package/apps/server/dist/yor/yor-mcp-server.js +0 -104
  53. package/apps/server/dist/yor/yor-orchestrator.js +0 -233
  54. package/apps/web/dist/assets/index-BiiEB0qZ.css +0 -1
  55. package/apps/web/dist/assets/index-D1AK5ZEE.js +0 -798
  56. package/apps/web/dist/index.html +0 -13
  57. package/packages/cc-client/dist/claude-code-backend.js +0 -664
  58. package/packages/cc-client/dist/index.js +0 -2
  59. package/packages/cc-client/package.json +0 -11
  60. package/packages/core/dist/constants.js +0 -59
  61. package/packages/core/dist/errors.js +0 -35
  62. package/packages/core/dist/index.js +0 -7
  63. package/packages/core/dist/office-init.js +0 -101
  64. package/packages/core/dist/scope/checker.js +0 -114
  65. package/packages/core/dist/scope/defaults.js +0 -55
  66. package/packages/core/dist/scope/index.js +0 -3
  67. package/packages/core/dist/state-machine.js +0 -85
  68. package/packages/core/dist/types/audit.js +0 -12
  69. package/packages/core/dist/types/backend.js +0 -2
  70. package/packages/core/dist/types/commitment.js +0 -17
  71. package/packages/core/dist/types/communication.js +0 -18
  72. package/packages/core/dist/types/index.js +0 -8
  73. package/packages/core/dist/types/opportunity.js +0 -27
  74. package/packages/core/dist/types/org.js +0 -26
  75. package/packages/core/dist/types/task.js +0 -46
  76. package/packages/core/package.json +0 -10
  77. package/packages/db/dist/client.js +0 -69
  78. package/packages/db/dist/index.js +0 -691
  79. package/packages/db/dist/schema/audit-events.js +0 -13
  80. package/packages/db/dist/schema/cc-sessions.js +0 -14
  81. package/packages/db/dist/schema/chats.js +0 -33
  82. package/packages/db/dist/schema/commitments.js +0 -18
  83. package/packages/db/dist/schema/communication-events.js +0 -14
  84. package/packages/db/dist/schema/index.js +0 -13
  85. package/packages/db/dist/schema/message-log.js +0 -20
  86. package/packages/db/dist/schema/opportunities.js +0 -23
  87. package/packages/db/dist/schema/org.js +0 -36
  88. package/packages/db/dist/schema/projects.js +0 -23
  89. package/packages/db/dist/schema/tasks.js +0 -48
  90. package/packages/db/dist/schema/topics.js +0 -20
  91. package/packages/db/dist/schema/trace-spans.js +0 -19
  92. package/packages/db/package.json +0 -12
  93. package/packages/db/src/migrations/0000_baseline.sql +0 -251
  94. package/packages/db/src/migrations/meta/_journal.json +0 -13
  95. package/packages/mcp-tools/dist/index.js +0 -41
  96. package/packages/mcp-tools/dist/layer1/audit-append.js +0 -38
  97. package/packages/mcp-tools/dist/layer1/audit-query.js +0 -51
  98. package/packages/mcp-tools/dist/layer1/memory-brief.js +0 -168
  99. package/packages/mcp-tools/dist/layer1/memory-context.js +0 -124
  100. package/packages/mcp-tools/dist/layer1/memory-digest.js +0 -126
  101. package/packages/mcp-tools/dist/layer1/memory-forget.js +0 -108
  102. package/packages/mcp-tools/dist/layer1/memory-learn.js +0 -63
  103. package/packages/mcp-tools/dist/layer1/memory-recall.js +0 -287
  104. package/packages/mcp-tools/dist/layer1/memory-reflect.js +0 -80
  105. package/packages/mcp-tools/dist/layer1/memory-remember.js +0 -119
  106. package/packages/mcp-tools/dist/layer1/memory-search.js +0 -263
  107. package/packages/mcp-tools/dist/layer1/memory-write.js +0 -21
  108. package/packages/mcp-tools/dist/layer1/org-lookup.js +0 -47
  109. package/packages/mcp-tools/dist/layer1/project-get.js +0 -28
  110. package/packages/mcp-tools/dist/layer1/project-list.js +0 -20
  111. package/packages/mcp-tools/dist/layer1/report-daily.js +0 -68
  112. package/packages/mcp-tools/dist/layer1/task-get.js +0 -29
  113. package/packages/mcp-tools/dist/layer1/task-update.js +0 -34
  114. package/packages/mcp-tools/dist/layer2/franky/topic-checkpoint.js +0 -43
  115. package/packages/mcp-tools/dist/layer2/franky/topic-escalate.js +0 -19
  116. package/packages/mcp-tools/dist/layer2/loid/decision-log.js +0 -15
  117. package/packages/mcp-tools/dist/layer2/loid/decision-no-action.js +0 -15
  118. package/packages/mcp-tools/dist/layer2/loid/delivery-create-pr.js +0 -30
  119. package/packages/mcp-tools/dist/layer2/loid/delivery-share.js +0 -12
  120. package/packages/mcp-tools/dist/layer2/loid/delivery-submit.js +0 -77
  121. package/packages/mcp-tools/dist/layer2/loid/delivery-upload.js +0 -18
  122. package/packages/mcp-tools/dist/layer2/loid/project-remove.js +0 -16
  123. package/packages/mcp-tools/dist/layer2/loid/project-upsert.js +0 -33
  124. package/packages/mcp-tools/dist/layer2/loid/task-dispatch.js +0 -196
  125. package/packages/mcp-tools/dist/layer2/loid/task-lookup.js +0 -38
  126. package/packages/mcp-tools/dist/layer2/loid/topic-close.js +0 -22
  127. package/packages/mcp-tools/dist/layer2/loid/topic-create.js +0 -56
  128. package/packages/mcp-tools/dist/layer2/loid/yor-approve.js +0 -8
  129. package/packages/mcp-tools/dist/layer2/loid/yor-kill.js +0 -7
  130. package/packages/mcp-tools/dist/layer2/loid/yor-rework.js +0 -7
  131. package/packages/mcp-tools/dist/layer2/loid/yor-spawn.js +0 -15
  132. package/packages/mcp-tools/dist/layer2/loid/yor-status.js +0 -8
  133. package/packages/mcp-tools/dist/layer2/yor/task-block.js +0 -11
  134. package/packages/mcp-tools/dist/layer2/yor/task-deliver.js +0 -35
  135. package/packages/mcp-tools/dist/layer2/yor/task-progress.js +0 -21
  136. package/packages/mcp-tools/dist/layer3/adapters/feishu-adapter.js +0 -192
  137. package/packages/mcp-tools/dist/layer3/adapters/types.js +0 -28
  138. package/packages/mcp-tools/dist/layer3/channel-receive.js +0 -11
  139. package/packages/mcp-tools/dist/layer3/channel-send.js +0 -91
  140. package/packages/mcp-tools/dist/layer3/file-upload.js +0 -44
  141. package/packages/mcp-tools/dist/registry.js +0 -871
  142. package/packages/mcp-tools/package.json +0 -13
  143. package/workspace/.claude/settings.local.json +0 -9
  144. package/workspace/.mcp.json +0 -12
  145. package/workspace/CHARTER.md +0 -76
  146. package/workspace/CLAUDE.md +0 -58
  147. package/workspace/PROTOCOL.md +0 -160
  148. package/workspace/TOOLS.md +0 -470
  149. package/workspace/audit/.gitkeep +0 -0
  150. package/workspace/franky/CLAUDE.md +0 -37
  151. package/workspace/franky/PLAYBOOK.md +0 -215
  152. package/workspace/franky/PROFILE.md +0 -80
  153. package/workspace/loid/CLAUDE.md +0 -12
  154. package/workspace/loid/PLAYBOOK.md +0 -198
  155. package/workspace/loid/PROFILE.md +0 -78
  156. package/workspace/memory/commitments/.gitkeep +0 -0
  157. package/workspace/memory/execution/.gitkeep +0 -0
  158. package/workspace/memory/people/.gitkeep +0 -0
  159. package/workspace/memory/projects/.gitkeep +0 -0
  160. package/workspace/memory/self/.gitkeep +0 -0
  161. package/workspace/reference/identity/.gitkeep +0 -0
  162. package/workspace/reference/org/escalation.yaml +0 -24
  163. package/workspace/reference/org/ownership.yaml +0 -28
  164. package/workspace/reports/.gitkeep +0 -0
  165. package/workspace/yor/CLAUDE.md +0 -22
  166. package/workspace/yor/PLAYBOOK.md +0 -73
  167. package/workspace/yor/PROFILE.md +0 -52
  168. package/workspace/yor/SELF-HEAL.md +0 -39
@@ -1,192 +0,0 @@
1
- // ── 媒体类型检测 ──
2
- const IMAGE_EXTS = new Set(['.png', '.jpg', '.jpeg', '.gif', '.bmp', '.webp', '.ico', '.tiff', '.tif']);
3
- const AUDIO_EXTS = new Set(['.opus']);
4
- const FILE_TYPE_MAP = {
5
- '.opus': 'opus', '.mp4': 'mp4', '.pdf': 'pdf',
6
- '.doc': 'doc', '.docx': 'doc', '.xls': 'xls', '.xlsx': 'xls',
7
- '.ppt': 'ppt', '.pptx': 'ppt',
8
- };
9
- /**
10
- * 根据文件扩展名检测媒体类型
11
- */
12
- export function detectMediaKind(filePath) {
13
- const dot = filePath.lastIndexOf('.');
14
- if (dot === -1)
15
- return 'file';
16
- const ext = filePath.slice(dot).toLowerCase();
17
- if (IMAGE_EXTS.has(ext))
18
- return 'image';
19
- if (AUDIO_EXTS.has(ext))
20
- return 'audio';
21
- return 'file';
22
- }
23
- /**
24
- * 根据文件扩展名获取飞书 file_type 参数
25
- */
26
- export function resolveFileType(filePath) {
27
- const dot = filePath.lastIndexOf('.');
28
- if (dot === -1)
29
- return 'stream';
30
- const ext = filePath.slice(dot).toLowerCase();
31
- return FILE_TYPE_MAP[ext] ?? 'stream';
32
- }
33
- // ── Markdown 检测 ──
34
- /**
35
- * 检测文本是否包含 Markdown 语法
36
- *
37
- * 匹配常见 Markdown 元素:标题、粗体、斜体、代码块、链接、列表、引用、分割线、表格等。
38
- * 短文本(<50 字符)且仅含单个 markdown 元素时倾向纯文本,避免误判。
39
- */
40
- const MD_PATTERNS = [
41
- /^#{1,6}\s/m, // 标题: # / ## / ###
42
- /\*\*[^*]+\*\*/, // 粗体: **text**
43
- /\*[^*]+\*/, // 斜体: *text*
44
- /`[^`]+`/, // 行内代码: `code`
45
- /```[\s\S]*?```/, // 代码块: ```...```
46
- /\[.+?\]\(.+?\)/, // 链接: [text](url)
47
- /^\s*[-*+]\s/m, // 无序列表: - item / * item
48
- /^\s*\d+\.\s/m, // 有序列表: 1. item
49
- /^\s*>/m, // 引用: > text
50
- /^-{3,}$/m, // 分割线: ---
51
- /^\|.+\|$/m, // 表格: | col | col |
52
- ];
53
- export function isMarkdown(text) {
54
- let matchCount = 0;
55
- for (const pattern of MD_PATTERNS) {
56
- if (pattern.test(text))
57
- matchCount++;
58
- if (matchCount >= 2)
59
- return true;
60
- }
61
- // 单个匹配:仅当文本较长时才认为是 markdown
62
- return matchCount === 1 && text.length >= 80;
63
- }
64
- /**
65
- * 将 markdown 内容转换为飞书交互式卡片格式
66
- */
67
- function markdownToFeishuCard(content) {
68
- return {
69
- schema: '2.0',
70
- config: { wide_screen_mode: true },
71
- body: {
72
- elements: [
73
- { tag: 'markdown', content },
74
- ],
75
- },
76
- };
77
- }
78
- /**
79
- * 飞书通道适配器
80
- *
81
- * 将 FeishuSender 包装为 ChannelAdapter 接口。
82
- * target 格式:
83
- * - "chat_id" → sendText to chat
84
- * - "reply/msg_id" → sendReply(向后兼容)
85
- */
86
- export class FeishuAdapter {
87
- scheme = 'feishu';
88
- sender;
89
- constructor(sender) {
90
- this.sender = sender;
91
- }
92
- /**
93
- * 将 mentions 注入到文本中(飞书 @ 格式)
94
- */
95
- injectMentions(text, mentions) {
96
- if (!mentions || mentions.length === 0)
97
- return text;
98
- const atTags = mentions.map(uid => `<at user_id="${uid}"></at>`).join(' ');
99
- return `${atTags} ${text}`;
100
- }
101
- async send(target, message, options) {
102
- const text = this.injectMentions(message, options?.mentions);
103
- // 检测是否为 markdown 内容,且 sender 支持卡片发送
104
- const useCard = isMarkdown(text) && !!this.sender.sendCard;
105
- // 优先使用 options.replyTo
106
- const replyTo = options?.replyTo;
107
- // 向后兼容:target 以 "reply/" 开头
108
- const resolvedReplyTo = replyTo || (target.startsWith('reply/') ? target.slice('reply/'.length) : undefined);
109
- const chatTarget = target.startsWith('reply/') ? undefined : target;
110
- if (useCard) {
111
- const card = markdownToFeishuCard(text);
112
- const id = await this.sender.sendCard({
113
- receiveIdType: 'chat_id',
114
- receiveId: chatTarget ?? '',
115
- card,
116
- replyToMessageId: resolvedReplyTo,
117
- });
118
- return { id };
119
- }
120
- // 纯文本发送
121
- if (resolvedReplyTo) {
122
- const id = await this.sender.sendReply({
123
- text,
124
- replyToMessageId: resolvedReplyTo,
125
- replyInThread: options?.replyInThread,
126
- });
127
- return { id };
128
- }
129
- const id = await this.sender.sendText({
130
- receiveIdType: 'chat_id',
131
- receiveId: chatTarget ?? target,
132
- text,
133
- });
134
- return { id };
135
- }
136
- async sendFile(target, file, message, options) {
137
- const path = await import('node:path');
138
- const fileName = file.fileName || path.basename(file.filePath);
139
- // 确定回复目标
140
- const replyTo = options?.replyTo || (target.startsWith('reply/') ? target.slice('reply/'.length) : undefined);
141
- const chatTarget = target.startsWith('reply/') ? undefined : target;
142
- // 自动检测媒体类型
143
- const mediaKind = detectMediaKind(file.filePath);
144
- let mediaMessageId;
145
- if (mediaKind === 'image') {
146
- // 图片:走 image.create 上传 → image 消息
147
- if (!this.sender.uploadImage || !this.sender.sendImage) {
148
- throw new Error('FeishuSender 未实现图片上传能力');
149
- }
150
- const imageKey = await this.sender.uploadImage(file.filePath);
151
- mediaMessageId = await this.sender.sendImage({
152
- receiveIdType: 'chat_id',
153
- receiveId: chatTarget ?? '',
154
- imageKey,
155
- replyToMessageId: replyTo,
156
- });
157
- }
158
- else {
159
- // 文件/音频:走 file.create 上传 → file/audio 消息
160
- if (!this.sender.uploadFile || !this.sender.sendFile) {
161
- throw new Error('FeishuSender 未实现文件上传能力');
162
- }
163
- const fileType = file.fileType || resolveFileType(file.filePath);
164
- const fileKey = await this.sender.uploadFile({
165
- filePath: file.filePath,
166
- fileName,
167
- fileType,
168
- duration: file.duration,
169
- });
170
- const msgType = mediaKind === 'audio' ? 'audio' : 'file';
171
- mediaMessageId = await this.sender.sendFile({
172
- receiveIdType: 'chat_id',
173
- receiveId: chatTarget ?? '',
174
- fileKey,
175
- msgType,
176
- replyToMessageId: replyTo,
177
- });
178
- }
179
- // 如果有附带文本,额外发一条文本消息
180
- if (message) {
181
- const text = this.injectMentions(message, options?.mentions);
182
- if (replyTo) {
183
- await this.sender.sendReply({ text, replyToMessageId: replyTo });
184
- }
185
- else if (chatTarget) {
186
- await this.sender.sendText({ receiveIdType: 'chat_id', receiveId: chatTarget, text });
187
- }
188
- }
189
- return { id: mediaMessageId };
190
- }
191
- }
192
- //# sourceMappingURL=feishu-adapter.js.map
@@ -1,28 +0,0 @@
1
- /**
2
- * 通道适配器接口
3
- *
4
- * 统一飞书/Slack/Web/CLI 等不同通道的消息发送。
5
- * channel.send 根据 channel 字段路由到对应 adapter。
6
- */
7
- /**
8
- * 通道注册表
9
- *
10
- * 管理所有已注册的通道适配器。
11
- * channel.send 通过 channel 字段查找对应的 adapter。
12
- */
13
- export class ChannelRegistry {
14
- adapters = new Map();
15
- register(adapter) {
16
- this.adapters.set(adapter.scheme, adapter);
17
- }
18
- get(scheme) {
19
- return this.adapters.get(scheme);
20
- }
21
- has(scheme) {
22
- return this.adapters.has(scheme);
23
- }
24
- getSchemes() {
25
- return Array.from(this.adapters.keys());
26
- }
27
- }
28
- //# sourceMappingURL=types.js.map
@@ -1,11 +0,0 @@
1
- /**
2
- * 拉取新消息(暂不实现)
3
- *
4
- * 当前消息通过 gateway 推送,Loid 不需要主动拉取。
5
- * 保留接口定义,后续版本实现。
6
- */
7
- export async function channelReceive(_input) {
8
- // 消息通过 gateway 推送,暂不实现拉取
9
- return { messages: [] };
10
- }
11
- //# sourceMappingURL=channel-receive.js.map
@@ -1,91 +0,0 @@
1
- import { insertAuditEvent, insertMessageLog } from '@team-anya/db';
2
- /** 默认通道(当前只支持飞书) */
3
- const DEFAULT_SCHEME = 'feishu';
4
- /**
5
- * 向飞书群发消息
6
- *
7
- * target 直接填群聊 ID(如 oc_xxx)。
8
- * 支持发送文件、@ 用户和回复消息。
9
- */
10
- export async function channelSend(deps, input) {
11
- const { db, channelRegistry, logger } = deps;
12
- const scheme = DEFAULT_SCHEME;
13
- const chatTarget = input.target;
14
- const adapter = channelRegistry.get(scheme);
15
- if (!adapter) {
16
- const error = `通道 ${scheme} 未注册(已注册: ${channelRegistry.getSchemes().join(', ')})`;
17
- logger?.error(`[anya:pipeline] channel.send: ${error}`);
18
- return { sent: false, error };
19
- }
20
- const sendOptions = {
21
- replyTo: input.reply_to,
22
- replyInThread: input.reply_in_thread,
23
- mentions: input.mentions,
24
- };
25
- try {
26
- let result;
27
- if (input.file) {
28
- if (!adapter.sendFile) {
29
- const error = `通道 ${scheme} 不支持发送文件`;
30
- logger?.error(`[anya:pipeline] channel.send: ${error}`);
31
- return { sent: false, error };
32
- }
33
- result = await adapter.sendFile(chatTarget, {
34
- filePath: input.file.file_path,
35
- fileName: input.file.file_name,
36
- fileType: input.file.file_type,
37
- duration: input.file.duration,
38
- }, input.message, sendOptions);
39
- }
40
- else {
41
- result = await adapter.send(chatTarget, input.message, sendOptions);
42
- }
43
- // 记录出站消息
44
- try {
45
- insertMessageLog(db, {
46
- direction: 'outbound',
47
- source_type: scheme,
48
- source_ref: result.id,
49
- sender: 'anya',
50
- receiver: chatTarget,
51
- chat_id: chatTarget,
52
- chat_type: 'group',
53
- content: input.file ? `[文件] ${input.file.file_name ?? input.file.file_path} ${input.message}` : input.message,
54
- message_type: 'message',
55
- related_task_id: input.task_id ?? null,
56
- });
57
- }
58
- catch (err) {
59
- logger?.error('[anya:pipeline] channel.send: 记录 message_log 失败:', err);
60
- }
61
- // 审计日志
62
- insertAuditEvent(db, {
63
- event_type: 'channel_send',
64
- actor: 'loid',
65
- task_id: input.task_id ?? undefined,
66
- summary: `通过 ${scheme} 发消息: ${input.message.slice(0, 100)}`,
67
- detail: JSON.stringify({
68
- target: chatTarget,
69
- has_file: !!input.file,
70
- has_mentions: !!input.mentions?.length,
71
- reply_to: input.reply_to ?? null,
72
- sent: true,
73
- }),
74
- });
75
- deps.onMessageSent?.(chatTarget);
76
- logger?.info(`[anya:pipeline] [Loid] channel.send (${scheme}${input.file ? ', file' : ''}): "${input.message.slice(0, 80)}"`);
77
- return { sent: true, message_id: result.id };
78
- }
79
- catch (err) {
80
- logger?.error(`[anya:pipeline] channel.send 失败:`, err);
81
- insertAuditEvent(db, {
82
- event_type: 'channel_send_failed',
83
- actor: 'loid',
84
- task_id: input.task_id ?? undefined,
85
- summary: `通道发送失败: ${String(err)}`,
86
- detail: JSON.stringify({ target: chatTarget, error: String(err) }),
87
- });
88
- return { sent: false, error: String(err) };
89
- }
90
- }
91
- //# sourceMappingURL=channel-send.js.map
@@ -1,44 +0,0 @@
1
- import { insertAuditEvent } from '@team-anya/db';
2
- /**
3
- * file.upload - 通用文件上传
4
- *
5
- * 与通道无关。当前使用本地文件复制实现。
6
- * 上传到 $ANYA_HOME/uploads/ 目录,返回本地路径作为 URL。
7
- */
8
- export async function fileUpload(deps, input) {
9
- const fs = await import('node:fs');
10
- const path = await import('node:path');
11
- const srcPath = input.file_path;
12
- const fileName = input.file_name || path.basename(srcPath);
13
- // 检查源文件是否存在
14
- if (!fs.existsSync(srcPath)) {
15
- throw new Error(`文件不存在: ${srcPath}`);
16
- }
17
- const stat = fs.statSync(srcPath);
18
- if (!stat.isFile()) {
19
- throw new Error(`路径不是文件: ${srcPath}`);
20
- }
21
- // 确保上传目录存在
22
- fs.mkdirSync(deps.uploadDir, { recursive: true });
23
- // 生成唯一文件名避免冲突
24
- const timestamp = Date.now();
25
- const uniqueName = `${timestamp}-${fileName}`;
26
- const destPath = path.join(deps.uploadDir, uniqueName);
27
- // 复制文件
28
- fs.copyFileSync(srcPath, destPath);
29
- const url = destPath; // 本地路径即 URL
30
- deps.logger?.info(`[anya:pipeline] file.upload: ${fileName} (${stat.size} bytes) → ${destPath}`);
31
- // 审计日志
32
- insertAuditEvent(deps.db, {
33
- event_type: 'file_upload',
34
- actor: 'loid',
35
- summary: `上传文件: ${fileName} (${stat.size} bytes)`,
36
- detail: JSON.stringify({ src: srcPath, dest: destPath, size: stat.size }),
37
- });
38
- return {
39
- url,
40
- file_name: fileName,
41
- file_size: stat.size,
42
- };
43
- }
44
- //# sourceMappingURL=file-upload.js.map