@ai-setting/roy-agent-core 1.7.76 → 1.7.85

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 (82) hide show
  1. package/dist/config/config-protection.d.ts +89 -0
  2. package/dist/config/index.d.ts +1 -0
  3. package/dist/config/index.js +16 -0
  4. package/dist/env/agent/agent-component.d.ts +42 -21
  5. package/dist/env/agent/agent-component.js +3 -3
  6. package/dist/env/agent/index.js +3 -3
  7. package/dist/env/agent/types.d.ts +32 -12
  8. package/dist/env/error-reply.d.ts +6 -0
  9. package/dist/env/error-reply.js +1 -1
  10. package/dist/env/event-source/bounty-im-handler.d.ts +8 -0
  11. package/dist/env/event-source/es-command.d.ts +39 -0
  12. package/dist/env/event-source/es-plugins.d.ts +68 -0
  13. package/dist/env/event-source/event-source-component.d.ts +15 -0
  14. package/dist/env/event-source/event-source-handlers.d.ts +68 -0
  15. package/dist/env/event-source/event-source-handlers.js +22 -10
  16. package/dist/env/event-source/index.d.ts +5 -1
  17. package/dist/env/event-source/index.js +59 -10
  18. package/dist/env/event-source/types.d.ts +101 -1
  19. package/dist/env/event-source/wecom-card-action-handler.d.ts +141 -0
  20. package/dist/env/event-source/wecom-card-builder.d.ts +220 -0
  21. package/dist/env/event-source/wecom-cli-handler.d.ts +266 -0
  22. package/dist/env/event-source/wecom-cli-sender.d.ts +88 -0
  23. package/dist/env/event-source/wecom-media.d.ts +130 -0
  24. package/dist/env/event-source/wecom-respond-registry.d.ts +151 -0
  25. package/dist/env/event-source/wecom-ws-bridge.d.ts +213 -0
  26. package/dist/env/index.js +19 -17
  27. package/dist/env/task/backend/index.js +37 -1
  28. package/dist/env/task/backend/task-store-backend.d.ts +12 -0
  29. package/dist/env/task/backend/types.d.ts +19 -0
  30. package/dist/env/task/delegate/delegate-tool.d.ts +62 -2
  31. package/dist/env/task/delegate/delegate-tool.js +3 -1
  32. package/dist/env/task/delegate/index.js +1 -1
  33. package/dist/env/task/index.js +4 -4
  34. package/dist/env/task/mcp/index.js +3 -0
  35. package/dist/env/task/mcp/task-mcp-server.d.ts +1 -1
  36. package/dist/env/task/plugins/fake-user-message-helper.d.ts +10 -2
  37. package/dist/env/task/plugins/index.d.ts +3 -0
  38. package/dist/env/task/plugins/index.js +36 -4
  39. package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +41 -2
  40. package/dist/env/task/plugins/lark-card-patch-notifier.js +1 -1
  41. package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +16 -0
  42. package/dist/env/task/plugins/task-op-watermark-plugin.d.ts +112 -0
  43. package/dist/env/task/plugins/wecom-card-state-store.d.ts +121 -0
  44. package/dist/env/task/plugins/wecom-task-notify-plugin.d.ts +224 -0
  45. package/dist/env/task/storage/index.js +2 -2
  46. package/dist/env/task/storage/sqlite-task-store.d.ts +54 -0
  47. package/dist/env/task/task-component.d.ts +16 -0
  48. package/dist/env/task/tools/operation/operation-types.d.ts +13 -13
  49. package/dist/env/tool/built-in/index.d.ts +2 -0
  50. package/dist/env/tool/built-in/index.js +6 -1
  51. package/dist/env/tool/index.js +3 -2
  52. package/dist/env/workflow/index.js +3 -3
  53. package/dist/env/workflow/plugins/index.js +2 -2
  54. package/dist/env/workflow/tools/index.js +2 -2
  55. package/dist/env/workflow/types/event.d.ts +4 -4
  56. package/dist/index.d.ts +1 -1
  57. package/dist/index.js +71 -20
  58. package/dist/shared/@ai-setting/{roy-agent-core-v87njmq7.js → roy-agent-core-0dh8npnz.js} +1 -1
  59. package/dist/shared/@ai-setting/roy-agent-core-2stt4rp5.js +134 -0
  60. package/dist/shared/@ai-setting/{roy-agent-core-mww0mnd9.js → roy-agent-core-7bpj859q.js} +1 -1
  61. package/dist/shared/@ai-setting/{roy-agent-core-nmx9934r.js → roy-agent-core-7dd0s3xb.js} +15 -5
  62. package/dist/shared/@ai-setting/{roy-agent-core-ghnagzrh.js → roy-agent-core-b31v3qpv.js} +853 -48
  63. package/dist/shared/@ai-setting/{roy-agent-core-cxy143m4.js → roy-agent-core-begm7ytz.js} +63 -2
  64. package/dist/shared/@ai-setting/{roy-agent-core-aa2j7bk9.js → roy-agent-core-cha0jc7n.js} +40 -26
  65. package/dist/shared/@ai-setting/{roy-agent-core-p3zv1mx5.js → roy-agent-core-d1n4jbza.js} +1 -1
  66. package/dist/shared/@ai-setting/{roy-agent-core-q5r75vev.js → roy-agent-core-dkrvmjsh.js} +17 -75
  67. package/dist/shared/@ai-setting/{roy-agent-core-abqhkbn3.js → roy-agent-core-ezvpreqz.js} +23 -0
  68. package/dist/shared/@ai-setting/{roy-agent-core-99nwgj84.js → roy-agent-core-fzw9xzm1.js} +1 -1
  69. package/dist/shared/@ai-setting/roy-agent-core-h21gngxf.js +247 -0
  70. package/dist/shared/@ai-setting/roy-agent-core-m3vjepzz.js +544 -0
  71. package/dist/shared/@ai-setting/{roy-agent-core-zycadbpx.js → roy-agent-core-p6ks90tb.js} +1 -1
  72. package/dist/shared/@ai-setting/{roy-agent-core-ntq0gz7q.js → roy-agent-core-q813vafd.js} +1 -1
  73. package/dist/shared/@ai-setting/{roy-agent-core-z43aj03k.js → roy-agent-core-qk9hd89p.js} +21 -2
  74. package/dist/shared/@ai-setting/{roy-agent-core-6cy43nss.js → roy-agent-core-rykf7c04.js} +49 -9
  75. package/dist/shared/@ai-setting/{roy-agent-core-8ez6mccb.js → roy-agent-core-tk98f92b.js} +4 -0
  76. package/dist/shared/@ai-setting/{roy-agent-core-bxkjk7zx.js → roy-agent-core-vx8zc847.js} +4 -1
  77. package/dist/shared/@ai-setting/roy-agent-core-vyr6svt6.js +31 -0
  78. package/dist/shared/@ai-setting/{roy-agent-core-t3rrb959.js → roy-agent-core-xf6z96qy.js} +2086 -163
  79. package/package.json +10 -1
  80. package/dist/shared/@ai-setting/roy-agent-core-f77k3gqt.js +0 -71
  81. /package/dist/shared/@ai-setting/{roy-agent-core-b4x6x4k2.js → roy-agent-core-m1fgtnrc.js} +0 -0
  82. /package/dist/shared/@ai-setting/{roy-agent-core-v85n42ve.js → roy-agent-core-ze5cqpf2.js} +0 -0
@@ -1,7 +1,10 @@
1
1
  import {
2
+ LARK_CHANNEL_PROMPT_SECTION_TITLE,
3
+ LARK_PROMPT_LENGTH_BUDGET,
2
4
  LarkCliInstance,
3
5
  bountyCliHandler,
4
6
  bountyIMHandler,
7
+ buildLarkChannelSystemPrompt,
5
8
  buildLarkRecommendedAction,
6
9
  builtInHandlers,
7
10
  extractCommandText,
@@ -10,29 +13,33 @@ import {
10
13
  larkCliHandler,
11
14
  patchCardByLarkCli,
12
15
  renderRuleNoticeSection,
13
- timerHandler
14
- } from "../../shared/@ai-setting/roy-agent-core-t3rrb959.js";
15
- import"../../shared/@ai-setting/roy-agent-core-bxkjk7zx.js";
16
+ resolveLarkChannelSystemPrompt,
17
+ timerHandler,
18
+ wecomCliHandler
19
+ } from "../../shared/@ai-setting/roy-agent-core-xf6z96qy.js";
20
+ import"../../shared/@ai-setting/roy-agent-core-vx8zc847.js";
16
21
  import {
17
22
  cliCommandHandler
18
23
  } from "../../shared/@ai-setting/roy-agent-core-v0hf14bj.js";
19
24
  import"../../shared/@ai-setting/roy-agent-core-tm1mxttk.js";
20
- import"../../shared/@ai-setting/roy-agent-core-ghnagzrh.js";
25
+ import"../../shared/@ai-setting/roy-agent-core-2stt4rp5.js";
26
+ import"../../shared/@ai-setting/roy-agent-core-b31v3qpv.js";
27
+ import"../../shared/@ai-setting/roy-agent-core-m3vjepzz.js";
21
28
  import"../../shared/@ai-setting/roy-agent-core-na18zwj0.js";
22
29
  import"../../shared/@ai-setting/roy-agent-core-9vxh6f8h.js";
23
- import"../../shared/@ai-setting/roy-agent-core-abqhkbn3.js";
30
+ import"../../shared/@ai-setting/roy-agent-core-ezvpreqz.js";
24
31
  import"../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
25
32
  import"../../shared/@ai-setting/roy-agent-core-tr3ep81v.js";
26
33
  import"../../shared/@ai-setting/roy-agent-core-m46fe3x4.js";
27
34
  import"../../shared/@ai-setting/roy-agent-core-4rtg69cn.js";
28
- import"../../shared/@ai-setting/roy-agent-core-p3zv1mx5.js";
29
- import"../../shared/@ai-setting/roy-agent-core-nmx9934r.js";
30
- import"../../shared/@ai-setting/roy-agent-core-6cy43nss.js";
35
+ import"../../shared/@ai-setting/roy-agent-core-d1n4jbza.js";
36
+ import"../../shared/@ai-setting/roy-agent-core-7dd0s3xb.js";
37
+ import"../../shared/@ai-setting/roy-agent-core-rykf7c04.js";
31
38
  import"../../shared/@ai-setting/roy-agent-core-c2gbt68e.js";
32
39
  import"../../shared/@ai-setting/roy-agent-core-1v4g0d4x.js";
33
40
  import"../../shared/@ai-setting/roy-agent-core-cgtq6427.js";
34
41
  import"../../shared/@ai-setting/roy-agent-core-er070zjq.js";
35
- import"../../shared/@ai-setting/roy-agent-core-f77k3gqt.js";
42
+ import"../../shared/@ai-setting/roy-agent-core-h21gngxf.js";
36
43
  import"../../shared/@ai-setting/roy-agent-core-ntn32q7j.js";
37
44
  import"../../shared/@ai-setting/roy-agent-core-mkc3zshb.js";
38
45
  import"../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
@@ -48,7 +55,9 @@ import"../../shared/@ai-setting/roy-agent-core-7f7t9wwp.js";
48
55
  import"../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
49
56
  import"../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
50
57
  export {
58
+ wecomCliHandler,
51
59
  timerHandler,
60
+ resolveLarkChannelSystemPrompt,
52
61
  renderRuleNoticeSection,
53
62
  patchCardByLarkCli,
54
63
  larkCliHandler,
@@ -58,7 +67,10 @@ export {
58
67
  cliCommandHandler,
59
68
  builtInHandlers,
60
69
  buildLarkRecommendedAction,
70
+ buildLarkChannelSystemPrompt,
61
71
  bountyIMHandler,
62
72
  bountyCliHandler,
63
- LarkCliInstance
73
+ LarkCliInstance,
74
+ LARK_PROMPT_LENGTH_BUDGET,
75
+ LARK_CHANNEL_PROMPT_SECTION_TITLE
64
76
  };
@@ -9,6 +9,7 @@ export { BUILT_IN_EVENT_SOURCE_TYPES, BUILT_IN_EVENT_SOURCE_TYPE_LIST } from "./
9
9
  export { isBuiltInEventSourceType, isValidEventSourceType, getDefaultConfigForType, validateEventSourceConfig, } from "./types";
10
10
  export { EventSourceComponent } from "./event-source-component";
11
11
  export { COMMAND_PREFIX, isCommandMessage, extractCommandInvocation, CommandRegistry, getGlobalCommandRegistry, handleCommandMessage, } from "./command-registry";
12
+ export { esCommand, resolveEsFilePath } from "./es-command";
12
13
  export type { CommandInvocation, CommandContext, CommandOutput, CommandTextOutput, CommandCardOutput, CommandResult, CommandDefinition, } from "./command-registry";
13
14
  export { renderTextCard, renderFallbackModelCard, isFallbackModelCard, FALLBACK_MODEL_ACTIONS, FALLBACK_MODEL_ACTION_NS, } from "./command-cards";
14
15
  export type { LarkCard } from "./command-types";
@@ -17,7 +18,10 @@ export type { CommandCardActionEvent, CommandCardActionPorts, CommandCardActionR
17
18
  export { fallbackModelCommand, listCommand, readFallbackModelList, readRawFallbackModelArray, writeFallbackModelList, DEFAULT_CONFIG_PATH, } from "./fallback-model-command";
18
19
  export { EventStoreImpl, setSharedEventStore, getSharedEventStore, resetSharedEventStore, } from "./event-store";
19
20
  export type { EventStore, TriggerEventInput, TriggerEventMetadata, PersistedEvent, EventStoreOptions, } from "./event-store";
20
- export { larkCliHandler, timerHandler, bountyIMHandler, cliCommandHandler, builtInHandlers, getBuiltInHandler, extractMetadata, } from "./event-source-handlers";
21
+ export { larkCliHandler, timerHandler, bountyIMHandler, cliCommandHandler, wecomCliHandler, builtInHandlers, getBuiltInHandler, extractMetadata, buildLarkRecommendedAction, buildLarkChannelSystemPrompt, resolveLarkChannelSystemPrompt, LARK_CHANNEL_PROMPT_SECTION_TITLE, LARK_PROMPT_LENGTH_BUDGET, } from "./event-source-handlers";
22
+ export { WECOM_CLI_ES_TYPE, WECOM_CHAT_ID_PREFIX, WECOM_WS_DEFAULT_URL, wecomCliHandler as wecomCliHandlerDirect, buildWecomReplyChannel, buildWecomNotifyPrompt, buildWecomChannelSystemPrompt, WECOM_CHANNEL_PROMPT_SECTION_TITLE, parseWecomFrame, readWecomCredentialsFile, resolveWecomCredentials, WECOM_CREDENTIALS_DEFAULT_PATH, resolveWecomBinary, probeCommandBinary, readWecomCliConfig, } from "./wecom-cli-handler";
23
+ export type { WecomReplyChannelInput, WecomNotifyPromptInput, WecomChannelSystemPromptInput, WecomCredentials, ParsedWecomFrame, } from "./wecom-cli-handler";
24
+ export { sanitizeWecomFrame } from "./wecom-ws-bridge";
21
25
  export { CLI_COMMAND_ES_TYPE, CLI_SESSION_CHAT_ID_PREFIX, buildCliReplyChannel, parseCliSessionChatId, } from "./cli-command-handler";
22
26
  export type { CliReplyChannel, CliNoticeSink } from "./cli-command-handler";
23
27
  export { TimerInstance } from "./timer-handler";
@@ -1,7 +1,7 @@
1
- import"../../shared/@ai-setting/roy-agent-core-b4x6x4k2.js";
1
+ import"../../shared/@ai-setting/roy-agent-core-m1fgtnrc.js";
2
2
  import {
3
3
  EventSourceComponent
4
- } from "../../shared/@ai-setting/roy-agent-core-cxy143m4.js";
4
+ } from "../../shared/@ai-setting/roy-agent-core-begm7ytz.js";
5
5
  import {
6
6
  BountyIMInstance,
7
7
  COMMAND_PREFIX,
@@ -9,10 +9,23 @@ import {
9
9
  DEFAULT_CONFIG_PATH,
10
10
  FALLBACK_MODEL_ACTIONS,
11
11
  FALLBACK_MODEL_ACTION_NS,
12
+ LARK_CHANNEL_PROMPT_SECTION_TITLE,
13
+ LARK_PROMPT_LENGTH_BUDGET,
12
14
  TimerInstance,
15
+ WECOM_CHANNEL_PROMPT_SECTION_TITLE,
16
+ WECOM_CHAT_ID_PREFIX,
17
+ WECOM_CLI_ES_TYPE,
18
+ WECOM_CREDENTIALS_DEFAULT_PATH,
19
+ WECOM_WS_DEFAULT_URL,
13
20
  bountyIMHandler,
14
21
  buildDefaultBountyIMSystemPrompt,
22
+ buildLarkChannelSystemPrompt,
23
+ buildLarkRecommendedAction,
24
+ buildWecomChannelSystemPrompt,
25
+ buildWecomNotifyPrompt,
26
+ buildWecomReplyChannel,
15
27
  builtInHandlers,
28
+ esCommand,
16
29
  extractCommandInvocation,
17
30
  extractMetadata,
18
31
  fallbackModelCommand,
@@ -25,15 +38,25 @@ import {
25
38
  isFallbackModelCard,
26
39
  larkCliHandler,
27
40
  listCommand,
41
+ parseWecomFrame,
42
+ probeCommandBinary,
28
43
  readFallbackModelList,
29
44
  readRawFallbackModelArray,
45
+ readWecomCliConfig,
46
+ readWecomCredentialsFile,
30
47
  renderFallbackModelCard,
31
48
  renderTextCard,
32
49
  resolveBountyIMSystemPrompt,
50
+ resolveEsFilePath,
51
+ resolveLarkChannelSystemPrompt,
52
+ resolveWecomBinary,
53
+ resolveWecomCredentials,
54
+ sanitizeWecomFrame,
33
55
  timerHandler,
34
56
  translateCardActionToCommand,
57
+ wecomCliHandler,
35
58
  writeFallbackModelList
36
- } from "../../shared/@ai-setting/roy-agent-core-t3rrb959.js";
59
+ } from "../../shared/@ai-setting/roy-agent-core-xf6z96qy.js";
37
60
  import {
38
61
  BUILT_IN_EVENT_SOURCE_TYPES,
39
62
  BUILT_IN_EVENT_SOURCE_TYPE_LIST,
@@ -42,7 +65,7 @@ import {
42
65
  isBuiltInEventSourceType,
43
66
  isValidEventSourceType,
44
67
  validateEventSourceConfig
45
- } from "../../shared/@ai-setting/roy-agent-core-bxkjk7zx.js";
68
+ } from "../../shared/@ai-setting/roy-agent-core-vx8zc847.js";
46
69
  import {
47
70
  CLI_COMMAND_ES_TYPE,
48
71
  CLI_SESSION_CHAT_ID_PREFIX,
@@ -51,7 +74,9 @@ import {
51
74
  parseCliSessionChatId
52
75
  } from "../../shared/@ai-setting/roy-agent-core-v0hf14bj.js";
53
76
  import"../../shared/@ai-setting/roy-agent-core-tm1mxttk.js";
54
- import"../../shared/@ai-setting/roy-agent-core-ghnagzrh.js";
77
+ import"../../shared/@ai-setting/roy-agent-core-2stt4rp5.js";
78
+ import"../../shared/@ai-setting/roy-agent-core-b31v3qpv.js";
79
+ import"../../shared/@ai-setting/roy-agent-core-m3vjepzz.js";
55
80
  import {
56
81
  EventStoreImpl,
57
82
  getSharedEventStore,
@@ -59,19 +84,19 @@ import {
59
84
  setSharedEventStore
60
85
  } from "../../shared/@ai-setting/roy-agent-core-na18zwj0.js";
61
86
  import"../../shared/@ai-setting/roy-agent-core-9vxh6f8h.js";
62
- import"../../shared/@ai-setting/roy-agent-core-abqhkbn3.js";
87
+ import"../../shared/@ai-setting/roy-agent-core-ezvpreqz.js";
63
88
  import"../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
64
89
  import"../../shared/@ai-setting/roy-agent-core-tr3ep81v.js";
65
90
  import"../../shared/@ai-setting/roy-agent-core-m46fe3x4.js";
66
91
  import"../../shared/@ai-setting/roy-agent-core-4rtg69cn.js";
67
- import"../../shared/@ai-setting/roy-agent-core-p3zv1mx5.js";
68
- import"../../shared/@ai-setting/roy-agent-core-nmx9934r.js";
69
- import"../../shared/@ai-setting/roy-agent-core-6cy43nss.js";
92
+ import"../../shared/@ai-setting/roy-agent-core-d1n4jbza.js";
93
+ import"../../shared/@ai-setting/roy-agent-core-7dd0s3xb.js";
94
+ import"../../shared/@ai-setting/roy-agent-core-rykf7c04.js";
70
95
  import"../../shared/@ai-setting/roy-agent-core-c2gbt68e.js";
71
96
  import"../../shared/@ai-setting/roy-agent-core-1v4g0d4x.js";
72
97
  import"../../shared/@ai-setting/roy-agent-core-cgtq6427.js";
73
98
  import"../../shared/@ai-setting/roy-agent-core-er070zjq.js";
74
- import"../../shared/@ai-setting/roy-agent-core-f77k3gqt.js";
99
+ import"../../shared/@ai-setting/roy-agent-core-h21gngxf.js";
75
100
  import"../../shared/@ai-setting/roy-agent-core-ntn32q7j.js";
76
101
  import"../../shared/@ai-setting/roy-agent-core-mkc3zshb.js";
77
102
  import"../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
@@ -88,16 +113,27 @@ import"../../shared/@ai-setting/roy-agent-core-85xyctnb.js";
88
113
  import"../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
89
114
  export {
90
115
  writeFallbackModelList,
116
+ wecomCliHandler as wecomCliHandlerDirect,
117
+ wecomCliHandler,
91
118
  validateEventSourceConfig,
92
119
  translateCardActionToCommand,
93
120
  timerHandler,
94
121
  setSharedEventStore,
122
+ sanitizeWecomFrame,
123
+ resolveWecomCredentials,
124
+ resolveWecomBinary,
125
+ resolveLarkChannelSystemPrompt,
126
+ resolveEsFilePath,
95
127
  resolveBountyIMSystemPrompt,
96
128
  resetSharedEventStore,
97
129
  renderTextCard,
98
130
  renderFallbackModelCard,
131
+ readWecomCredentialsFile,
132
+ readWecomCliConfig,
99
133
  readRawFallbackModelArray,
100
134
  readFallbackModelList,
135
+ probeCommandBinary,
136
+ parseWecomFrame,
101
137
  parseCliSessionChatId,
102
138
  listCommand,
103
139
  larkCliHandler,
@@ -115,12 +151,25 @@ export {
115
151
  fallbackModelCommand,
116
152
  extractMetadata,
117
153
  extractCommandInvocation,
154
+ esCommand,
118
155
  cliCommandHandler,
119
156
  builtInHandlers,
157
+ buildWecomReplyChannel,
158
+ buildWecomNotifyPrompt,
159
+ buildWecomChannelSystemPrompt,
160
+ buildLarkRecommendedAction,
161
+ buildLarkChannelSystemPrompt,
120
162
  buildDefaultBountyIMSystemPrompt,
121
163
  buildCliReplyChannel,
122
164
  bountyIMHandler,
165
+ WECOM_WS_DEFAULT_URL,
166
+ WECOM_CREDENTIALS_DEFAULT_PATH,
167
+ WECOM_CLI_ES_TYPE,
168
+ WECOM_CHAT_ID_PREFIX,
169
+ WECOM_CHANNEL_PROMPT_SECTION_TITLE,
123
170
  TimerInstance,
171
+ LARK_PROMPT_LENGTH_BUDGET,
172
+ LARK_CHANNEL_PROMPT_SECTION_TITLE,
124
173
  FALLBACK_MODEL_ACTION_NS,
125
174
  FALLBACK_MODEL_ACTIONS,
126
175
  EventStoreImpl,
@@ -40,11 +40,22 @@ export declare const BUILT_IN_EVENT_SOURCE_TYPES: {
40
40
  * 「CLI 没有 IM 通道,输出到 stdout」的 prompt(而不是套用飞书模板)。
41
41
  */
42
42
  readonly CLI_COMMAND: "cli-command";
43
+ /**
44
+ * ★ Task #5142:企业微信(WeCom)也是一个事件源。
45
+ *
46
+ * 走企微官方 CLI `wecom-cli`(npm: `@wecom/cli`)。
47
+ *
48
+ * ⚠️ **必须是新类型名 `wecom-cli`,不能抄 `lark-cli`**:
49
+ * `getHandlerForEsType(esType)` 是 v2 notify prompt 的唯一分派 key,
50
+ * 抄成 lark-cli 会让 agent 拿到「用 lark-cli 发到 oc_xxx」的 prompt,
51
+ * 而企微根本没有 oc_xxx。
52
+ */
53
+ readonly WECOM_CLI: "wecom-cli";
43
54
  };
44
55
  /**
45
56
  * 内置事件源类型列表
46
57
  */
47
- export declare const BUILT_IN_EVENT_SOURCE_TYPE_LIST: ("lark-cli" | "timer" | "bounty-im" | "cli-command")[];
58
+ export declare const BUILT_IN_EVENT_SOURCE_TYPE_LIST: ("lark-cli" | "timer" | "bounty-im" | "cli-command" | "wecom-cli")[];
48
59
  /**
49
60
  * HandleRuleConfig
50
61
  *
@@ -161,8 +172,27 @@ export interface EventSourceConfig {
161
172
  *
162
173
  * 内置 bounty-im handler 在 config.systemPrompt 未设置时使用默认 prompt;
163
174
  * 用户可显式覆盖。
175
+ *
176
+ * ★ ES-M1(Task #5144):lark-cli 渠道在 lean 模式下,未配置本字段时
177
+ * 也会注入渠道静态 prompt(buildLarkChannelSystemPrompt),规则文本
178
+ * 前置到 system prompt;配置了则用户值在前 + 渠道 prompt 在后。
164
179
  */
165
180
  systemPrompt?: string;
181
+ /**
182
+ * 渠道 prompt 模式(ES-M1,Task #5144;默认 "lean")
183
+ *
184
+ * - "lean"(默认):渠道静态回复规则(关键 0/1/2/3、30KB 上限、禁分段、
185
+ * --as bot、mktemp+jq 模板,~1566 tok)前置注入 system prompt;
186
+ * per-event recommendedAction 压缩为动态小卡片(action 一句话 +
187
+ * replyTo 四元组)。
188
+ * - "legacy":per-source 回退开关 —— 行为与旧版完全一致
189
+ * (recommendedAction 4.4KB 长模板、无渠道 systemPrompt 注入)。
190
+ *
191
+ * 用途:灰度期如果 sub-agent / 第三方 consumer 依赖
192
+ * `payload.message` 里 JSON 的长模板规则文本,可将该 source
193
+ * 回退为 legacy。
194
+ */
195
+ channelPromptMode?: "legacy" | "lean";
166
196
  /**
167
197
  * Agent IM 地址(bounty-im 类型用,格式:agent-id@host)
168
198
  *
@@ -244,6 +274,30 @@ export interface EventMetadata {
244
274
  senderEmail?: string;
245
275
  /** 租户 key */
246
276
  tenantKey?: string;
277
+ /**
278
+ * ★ Task #5212:lark 引用消息上下文
279
+ *
280
+ * lark-cli `im.message.receive_v1` 事件的引用字段归一化:
281
+ * - rootId: 根消息 id(root_id)
282
+ * - parentId: 直接回复的父消息 id(reply_to / parent_id)
283
+ * - threadId: thread id(thread_id),仅 thread 场景存在
284
+ *
285
+ * 无任何引用字段(普通消息)时为 undefined。
286
+ * agent 据此知道当前消息是对哪条消息的回复。
287
+ */
288
+ replyContext?: {
289
+ rootId?: string;
290
+ parentId?: string;
291
+ threadId?: string;
292
+ /**
293
+ * ★ Task #5251:企微引用内容(quote 内嵌原文归一文本)
294
+ *
295
+ * 企微长连接协议直接内嵌被引用内容(SDK BaseMessage.quote),
296
+ * 无被引用消息 id —— 因此企微侧只有 quotedText,
297
+ * 无 rootId/parentId/threadId(那些是 lark 侧字段)。
298
+ */
299
+ quotedText?: string;
300
+ };
247
301
  /**
248
302
  * 事件源注入到 agent systemPrompt 的专属 prompt
249
303
  *
@@ -262,6 +316,45 @@ export interface EventMetadata {
262
316
  export interface RecommendedAction {
263
317
  /** 动作描述 */
264
318
  action: string;
319
+ /**
320
+ * ★ ES-M1(Task #5144):静态规则是否已前置到渠道 system prompt。
321
+ *
322
+ * lean 模式(默认)下 extractMetadata 会置 `true`:
323
+ * 规则文本(关键 0/1/2/3、30KB 上限、禁分段、--as bot、mktemp+jq
324
+ * 模板)不再出现在 `action` 里,而是注入了渠道 system prompt
325
+ * (EventMetadata.systemPrompt)。旧 consumer / 灰度观察者可据此
326
+ * 识别"卡片已瘦身"这一新形态。
327
+ *
328
+ * legacy 模式不设置该字段(保持旧版形态识别)。
329
+ */
330
+ staticRulesInSystemPrompt?: true;
331
+ /**
332
+ * ★ Task #5212(DS review MAJOR-2):lark 引用消息上下文
333
+ *
334
+ * 当前消息「是对哪条消息的回复」的定位信息(rootId / parentId / threadId)。
335
+ *
336
+ * ⚠️ 为什么挂在 recommendedAction 而不是只挂 metadata:
337
+ * agent 实际收到的 user message = `payload.message` =
338
+ * `JSON.stringify({ rawData, recommendedAction, triggerEventId? })`
339
+ * —— **不含 metadata 键**。只写进 evt.metadata / evt.payload.metadata
340
+ * 的话,agent 读不到任何 parentId 值,需求(「让 agent LLM 看到是对某
341
+ * 消息 id 的回复」)无法闭环。
342
+ *
343
+ * 无引用字段(普通消息)时为 undefined(不产生空对象)。
344
+ */
345
+ replyContext?: {
346
+ rootId?: string;
347
+ parentId?: string;
348
+ threadId?: string;
349
+ /**
350
+ * ★ Task #5251:企微引用内容(quote 内嵌原文归一文本)
351
+ *
352
+ * 企微长连接协议直接内嵌被引用内容(SDK BaseMessage.quote),
353
+ * 无被引用消息 id —— 因此企微侧只有 quotedText,
354
+ * 无 rootId/parentId/threadId(那些是 lark 侧字段)。
355
+ */
356
+ quotedText?: string;
357
+ };
265
358
  /** 回复目标(如果有) */
266
359
  replyTo?: {
267
360
  appId?: string;
@@ -346,6 +439,13 @@ export interface EventSourceEventPayload {
346
439
  * 反查原始 chatId。
347
440
  */
348
441
  triggerEventId?: string;
442
+ /**
443
+ * Task #5199:已落盘媒体文件的本地路径(image/file/video/voice)。
444
+ *
445
+ * WecomCliInstance.handleWsFrame 异步下载解密后写入;
446
+ * agent 用 understand_image(image_source=<path>) 读图。
447
+ */
448
+ mediaFiles?: string[];
349
449
  }
350
450
  /**
351
451
  * EventSource 事件
@@ -0,0 +1,141 @@
1
+ /**
2
+ * @fileoverview Task #5203 — 企微卡片按钮点击处理
3
+ *
4
+ * ## 触发链路
5
+ *
6
+ * 用户点 button_interaction 卡片按钮
7
+ * → 企微推 `template_card_event`(aibot_event_callback,5 秒窗口)
8
+ * → WecomCliInstance.handleWsFrame 分流(不走 Agent)
9
+ * → 本模块 handleWecomCardAction:
10
+ * 1. 解析 event_key / task_id(反解出 roy 任务号)
11
+ * 2. 触发对应 task 操作(mark_done → taskComponent.updateTask(status=completed))
12
+ * 3. 经 aibot_respond_update_msg(透传回调 req_id)更新卡片按钮态
13
+ *
14
+ * ## 设计原则(对齐 lark-card-action-handler.ts)
15
+ *
16
+ * - 纯函数 + IO 端口注入(markTaskDone / reopenTask / updateCard)
17
+ * - 失败明确返回 ok=false,不静默成功
18
+ * - 并发去重:同 (cardTaskId, action) 处理中 → 后到的拒绝
19
+ * (用户双击会产生两条独立回调)
20
+ *
21
+ * ## task_id 反解
22
+ *
23
+ * 发卡时 task_id 形如 `roy-task-<taskId>-<seq>-<rand>`(wecom-card-builder);
24
+ * 回调原样带回 → 用前缀 `roy-task-` 反解出数字任务号。
25
+ * 非 roy-task 前缀(外部卡片)→ taskId=null,动作不执行。
26
+ */
27
+ import { type WecomMilestoneLite } from "./wecom-card-builder";
28
+ /** 卡片动作类型 */
29
+ export type WecomCardAction = "view" | "mark_done" | "reopen";
30
+ /** 解析出的卡片动作事件 */
31
+ export interface WecomCardActionEvent {
32
+ /** 用户点的按钮 key(WecomCardActionKey 之一或外部自定义) */
33
+ eventKey: string;
34
+ /** 回调带回的原始 task_id(原样回填更新帧) */
35
+ cardTaskId: string;
36
+ /** 反解出的任务号;非 roy-task 前缀 → null */
37
+ taskId: number | null;
38
+ /** 操作者 userid */
39
+ userId: string;
40
+ /** 回调帧 req_id(更新帧必须原样透传) */
41
+ reqId: string;
42
+ }
43
+ /** IO 端口(caller 注入;本模块保持纯函数) */
44
+ export interface WecomCardActionPorts {
45
+ /** 标记任务完成(status=completed) */
46
+ markTaskDone: (taskId: number) => Promise<void>;
47
+ /** 重新打开任务(status=active) */
48
+ reopenTask: (taskId: number) => Promise<void>;
49
+ /**
50
+ * 更新卡片(aibot_respond_update_msg,5 秒窗口内)
51
+ * @param cardTaskId 回调带回的原始 task_id
52
+ * @param timeline view 动作时携带的操作时间线(可选)
53
+ * @param action ★ Task #5250:触发动作(决定更新后的按钮:
54
+ * view/reopen → 可点击「刷新详情」;mark_done → 「已处理」)
55
+ */
56
+ updateCard: (reqId: string, cardTaskId: string, statusLabel: string, note?: string, timeline?: WecomMilestoneLite[], action?: WecomCardAction,
57
+ /**
58
+ * ★ Task #5273:任务号+标题(可选,渲染进更新卡 main_title)
59
+ */
60
+ extra?: {
61
+ taskNumber?: number;
62
+ taskTitle?: string;
63
+ }) => Promise<void>;
64
+ /**
65
+ * ★ Task #5203:读任务的操作时间线(milestones + processSteps)。
66
+ *
67
+ * view 动作用它把完整操作记录刷进卡片正文。
68
+ * 无记录 / 读取失败 → 返回 [](降级为简单按钮态更新)。
69
+ */
70
+ loadTimeline?: (taskId: number) => WecomMilestoneLite[];
71
+ /**
72
+ * ★ Task #5273:读任务号+标题(渲染进更新卡 main_title,
73
+ * 修复「卡片缺 Task #ID 和 title」)。
74
+ *
75
+ * ★ CV-B1(Task #5273 返工):生产实现(wecom-cli-handler)
76
+ * 从 taskComponent 读任务,返回 **Promise** —— 端口签名必须
77
+ * 允许 Promise,消费端 doHandle 必须 await。
78
+ * 返回 undefined / reject / 抛错 → 降级为无标题(卡片更新不阻断)。
79
+ */
80
+ loadTaskTitle?: (taskId: number) => {
81
+ title?: string;
82
+ number?: number;
83
+ } | undefined | Promise<{
84
+ title?: string;
85
+ number?: number;
86
+ } | undefined>;
87
+ }
88
+ /** 处理结果 */
89
+ export interface WecomCardActionResult {
90
+ ok: boolean;
91
+ /** 执行的动作(解析失败时缺省) */
92
+ action?: WecomCardAction;
93
+ error?: string;
94
+ }
95
+ /** 测试钩子:清空 in-flight 去重表(仅供单测 beforeEach 使用) */
96
+ export declare function __resetWecomCardActionInflightForTest(): void;
97
+ /**
98
+ * 从 WS 帧解析 template_card_event。
99
+ *
100
+ * 非 template_card_event(消息帧 / 其他事件)→ null。
101
+ */
102
+ export declare function extractWecomCardAction(frame: unknown): WecomCardActionEvent | null;
103
+ /**
104
+ * 处理卡片按钮点击。
105
+ *
106
+ * @returns 处理结果(ok=true 表示动作已执行 + 卡片已更新)
107
+ */
108
+ export declare function handleWecomCardAction(frame: unknown, ports: WecomCardActionPorts): Promise<WecomCardActionResult>;
109
+ /**
110
+ * 构造卡片更新帧(aibot_respond_update_msg)。
111
+ *
112
+ * 供 caller(WecomCliInstance)把 ports.updateCard 接到 bridge.respond:
113
+ * bridge.respond(reqId, buildWecomCardUpdateBody(...).body)。
114
+ *
115
+ * 独立导出是为了单测不依赖 bridge。
116
+ */
117
+ export declare function buildWecomCardUpdateBody(input: {
118
+ cardTaskId: string;
119
+ statusLabel: string;
120
+ note?: string;
121
+ /** ★ Task #5203:view 动作携带的操作时间线 */
122
+ timeline?: WecomMilestoneLite[];
123
+ /**
124
+ * ★ Task #5250:触发更新的动作(决定更新后的按钮)。
125
+ *
126
+ * - view / reopen → 保留可点击的「刷新详情」(key=task_view):
127
+ * 用户可**重复点击**刷新最新里程碑/操作记录
128
+ * - mark_done / 缺省(旧调用方)→ 死按钮「已处理」
129
+ * (key=task_done_ack,终态确认,向后兼容 #5203 行为)
130
+ */
131
+ action?: WecomCardAction;
132
+ /**
133
+ * ★ Task #5273:任务号+标题(可选,渲染进 main_title,
134
+ * 修复「更新卡缺 Task #ID 和 title」)
135
+ */
136
+ taskTitle?: string;
137
+ taskNumber?: number;
138
+ }): {
139
+ cmd: string;
140
+ body: Record<string, unknown>;
141
+ };