@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.
- package/dist/config/config-protection.d.ts +89 -0
- package/dist/config/index.d.ts +1 -0
- package/dist/config/index.js +16 -0
- package/dist/env/agent/agent-component.d.ts +42 -21
- package/dist/env/agent/agent-component.js +3 -3
- package/dist/env/agent/index.js +3 -3
- package/dist/env/agent/types.d.ts +32 -12
- package/dist/env/error-reply.d.ts +6 -0
- package/dist/env/error-reply.js +1 -1
- package/dist/env/event-source/bounty-im-handler.d.ts +8 -0
- package/dist/env/event-source/es-command.d.ts +39 -0
- package/dist/env/event-source/es-plugins.d.ts +68 -0
- package/dist/env/event-source/event-source-component.d.ts +15 -0
- package/dist/env/event-source/event-source-handlers.d.ts +68 -0
- package/dist/env/event-source/event-source-handlers.js +22 -10
- package/dist/env/event-source/index.d.ts +5 -1
- package/dist/env/event-source/index.js +59 -10
- package/dist/env/event-source/types.d.ts +101 -1
- package/dist/env/event-source/wecom-card-action-handler.d.ts +141 -0
- package/dist/env/event-source/wecom-card-builder.d.ts +220 -0
- package/dist/env/event-source/wecom-cli-handler.d.ts +266 -0
- package/dist/env/event-source/wecom-cli-sender.d.ts +88 -0
- package/dist/env/event-source/wecom-media.d.ts +130 -0
- package/dist/env/event-source/wecom-respond-registry.d.ts +151 -0
- package/dist/env/event-source/wecom-ws-bridge.d.ts +213 -0
- package/dist/env/index.js +19 -17
- package/dist/env/task/backend/index.js +37 -1
- package/dist/env/task/backend/task-store-backend.d.ts +12 -0
- package/dist/env/task/backend/types.d.ts +19 -0
- package/dist/env/task/delegate/delegate-tool.d.ts +62 -2
- package/dist/env/task/delegate/delegate-tool.js +3 -1
- package/dist/env/task/delegate/index.js +1 -1
- package/dist/env/task/index.js +4 -4
- package/dist/env/task/mcp/index.js +3 -0
- package/dist/env/task/mcp/task-mcp-server.d.ts +1 -1
- package/dist/env/task/plugins/fake-user-message-helper.d.ts +10 -2
- package/dist/env/task/plugins/index.d.ts +3 -0
- package/dist/env/task/plugins/index.js +36 -4
- package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +41 -2
- package/dist/env/task/plugins/lark-card-patch-notifier.js +1 -1
- package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +16 -0
- package/dist/env/task/plugins/task-op-watermark-plugin.d.ts +112 -0
- package/dist/env/task/plugins/wecom-card-state-store.d.ts +121 -0
- package/dist/env/task/plugins/wecom-task-notify-plugin.d.ts +224 -0
- package/dist/env/task/storage/index.js +2 -2
- package/dist/env/task/storage/sqlite-task-store.d.ts +54 -0
- package/dist/env/task/task-component.d.ts +16 -0
- package/dist/env/task/tools/operation/operation-types.d.ts +13 -13
- package/dist/env/tool/built-in/index.d.ts +2 -0
- package/dist/env/tool/built-in/index.js +6 -1
- package/dist/env/tool/index.js +3 -2
- package/dist/env/workflow/index.js +3 -3
- package/dist/env/workflow/plugins/index.js +2 -2
- package/dist/env/workflow/tools/index.js +2 -2
- package/dist/env/workflow/types/event.d.ts +4 -4
- package/dist/index.d.ts +1 -1
- package/dist/index.js +71 -20
- package/dist/shared/@ai-setting/{roy-agent-core-v87njmq7.js → roy-agent-core-0dh8npnz.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-2stt4rp5.js +134 -0
- package/dist/shared/@ai-setting/{roy-agent-core-mww0mnd9.js → roy-agent-core-7bpj859q.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-nmx9934r.js → roy-agent-core-7dd0s3xb.js} +15 -5
- package/dist/shared/@ai-setting/{roy-agent-core-ghnagzrh.js → roy-agent-core-b31v3qpv.js} +853 -48
- package/dist/shared/@ai-setting/{roy-agent-core-cxy143m4.js → roy-agent-core-begm7ytz.js} +63 -2
- package/dist/shared/@ai-setting/{roy-agent-core-aa2j7bk9.js → roy-agent-core-cha0jc7n.js} +40 -26
- package/dist/shared/@ai-setting/{roy-agent-core-p3zv1mx5.js → roy-agent-core-d1n4jbza.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-q5r75vev.js → roy-agent-core-dkrvmjsh.js} +17 -75
- package/dist/shared/@ai-setting/{roy-agent-core-abqhkbn3.js → roy-agent-core-ezvpreqz.js} +23 -0
- package/dist/shared/@ai-setting/{roy-agent-core-99nwgj84.js → roy-agent-core-fzw9xzm1.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-h21gngxf.js +247 -0
- package/dist/shared/@ai-setting/roy-agent-core-m3vjepzz.js +544 -0
- package/dist/shared/@ai-setting/{roy-agent-core-zycadbpx.js → roy-agent-core-p6ks90tb.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-ntq0gz7q.js → roy-agent-core-q813vafd.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-z43aj03k.js → roy-agent-core-qk9hd89p.js} +21 -2
- package/dist/shared/@ai-setting/{roy-agent-core-6cy43nss.js → roy-agent-core-rykf7c04.js} +49 -9
- package/dist/shared/@ai-setting/{roy-agent-core-8ez6mccb.js → roy-agent-core-tk98f92b.js} +4 -0
- package/dist/shared/@ai-setting/{roy-agent-core-bxkjk7zx.js → roy-agent-core-vx8zc847.js} +4 -1
- package/dist/shared/@ai-setting/roy-agent-core-vyr6svt6.js +31 -0
- package/dist/shared/@ai-setting/{roy-agent-core-t3rrb959.js → roy-agent-core-xf6z96qy.js} +2086 -163
- package/package.json +10 -1
- package/dist/shared/@ai-setting/roy-agent-core-f77k3gqt.js +0 -71
- /package/dist/shared/@ai-setting/{roy-agent-core-b4x6x4k2.js → roy-agent-core-m1fgtnrc.js} +0 -0
- /package/dist/shared/@ai-setting/{roy-agent-core-v85n42ve.js → roy-agent-core-ze5cqpf2.js} +0 -0
|
@@ -8,6 +8,9 @@ import {
|
|
|
8
8
|
createLogger,
|
|
9
9
|
init_logger
|
|
10
10
|
} from "./roy-agent-core-7f7t9wwp.js";
|
|
11
|
+
import {
|
|
12
|
+
__require
|
|
13
|
+
} from "./roy-agent-core-fs0mn2jk.js";
|
|
11
14
|
|
|
12
15
|
// src/env/error-reply.ts
|
|
13
16
|
init_logger();
|
|
@@ -361,9 +364,10 @@ function isUsableChannel(ch) {
|
|
|
361
364
|
return false;
|
|
362
365
|
if (!ch.chatId && !ch.messageId)
|
|
363
366
|
return false;
|
|
364
|
-
if (
|
|
365
|
-
return
|
|
366
|
-
|
|
367
|
+
if (!ch.type)
|
|
368
|
+
return true;
|
|
369
|
+
const t = ch.type.toLowerCase();
|
|
370
|
+
return t.includes("lark") || t.startsWith("wecom");
|
|
367
371
|
}
|
|
368
372
|
var repliedTriggers = new Map;
|
|
369
373
|
var CHAT_DEDUP_WINDOW_MS = 5 * 60000;
|
|
@@ -501,6 +505,32 @@ function spawnLarkReply(options) {
|
|
|
501
505
|
proc.on("error", (err) => finish(err));
|
|
502
506
|
});
|
|
503
507
|
}
|
|
508
|
+
async function spawnWecomReply(options) {
|
|
509
|
+
const { chatId, content, params } = options;
|
|
510
|
+
if (!chatId) {
|
|
511
|
+
throw new Error("No chatId specified for wecom failure reply");
|
|
512
|
+
}
|
|
513
|
+
try {
|
|
514
|
+
const { sendWecomReply } = await import("./roy-agent-core-vyr6svt6.js");
|
|
515
|
+
const result = await sendWecomReply({
|
|
516
|
+
sourceId: typeof params?.sourceId === "string" && params.sourceId || "unknown",
|
|
517
|
+
rawChatId: chatId,
|
|
518
|
+
reqId: typeof params?.reqId === "string" ? params.reqId : undefined,
|
|
519
|
+
content
|
|
520
|
+
});
|
|
521
|
+
if (!result.ok) {
|
|
522
|
+
throw new Error(result.error ?? "sendWecomReply failed");
|
|
523
|
+
}
|
|
524
|
+
} catch (err) {
|
|
525
|
+
throw err instanceof Error ? err : new Error(String(err));
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
function pickSender(channel) {
|
|
529
|
+
const t = (channel.type ?? "").toLowerCase();
|
|
530
|
+
if (t.startsWith("wecom"))
|
|
531
|
+
return spawnWecomReply;
|
|
532
|
+
return spawnLarkReply;
|
|
533
|
+
}
|
|
504
534
|
async function notifyReactFailure(options) {
|
|
505
535
|
const info = classifyReactFailure(options.error);
|
|
506
536
|
if (!info.notify) {
|
|
@@ -510,7 +540,12 @@ async function notifyReactFailure(options) {
|
|
|
510
540
|
const channel = (isUsableChannel(options.replyChannel) ? options.replyChannel : undefined) ?? extractReplyChannelFromEvent(options.envEvent);
|
|
511
541
|
if (!isUsableChannel(channel)) {
|
|
512
542
|
const hasTrigger = Boolean(options.envEvent);
|
|
513
|
-
const
|
|
543
|
+
const hasChannelObj = !hasTrigger || (() => {
|
|
544
|
+
const e = options.envEvent;
|
|
545
|
+
const rc = e?.metadata?.replyChannel ?? e?.payload?.replyChannel ?? options.replyChannel;
|
|
546
|
+
return Boolean(rc && typeof rc === "object");
|
|
547
|
+
})();
|
|
548
|
+
const noChannelMsg = hasChannelObj ? `[#4418] React 中断(${info.kind}/${info.ruleId})replyChannel.type 不在支持列表(lark*/wecom*),` + `触发方收不到失败说明` + (hasTrigger ? ` —— channel 存在但 type=${String(options.envEvent?.metadata?.replyChannel?.type ?? options.envEvent?.payload?.replyChannel?.type ?? options.replyChannel?.type ?? "unknown")} 未被放行` : "") + (options.sessionId ? ` (session=${options.sessionId})` : "") : `[#4418] React 中断(${info.kind}/${info.ruleId})无法定位 replyChannel,` + `触发方收不到失败说明` + (hasTrigger ? " —— triggerEvent 存在但缺少 metadata.replyChannel" : "(本地执行,无 triggerEvent)") + (options.sessionId ? ` (session=${options.sessionId})` : "");
|
|
514
549
|
if (hasTrigger)
|
|
515
550
|
logger.warn(noChannelMsg);
|
|
516
551
|
else
|
|
@@ -523,21 +558,26 @@ async function notifyReactFailure(options) {
|
|
|
523
558
|
return { sent: false, kind: info.kind, info, skipped: "duplicate" };
|
|
524
559
|
}
|
|
525
560
|
rememberTrigger(dedupKey);
|
|
526
|
-
const
|
|
561
|
+
const isWecom = (channel.type ?? "").toLowerCase().startsWith("wecom");
|
|
562
|
+
const baseContent = buildFailureReplyMarkdown(info, { query: options.query });
|
|
563
|
+
const content = isWecom ? `⚠️ 系统失败通知
|
|
564
|
+
|
|
565
|
+
${baseContent}` : baseContent;
|
|
527
566
|
try {
|
|
528
|
-
await
|
|
567
|
+
await pickSender(channel)({
|
|
529
568
|
chatId: channel.chatId,
|
|
530
569
|
messageId: channel.messageId,
|
|
531
570
|
content,
|
|
532
571
|
profile: channel.profile,
|
|
533
|
-
timeoutMs: options.replyTimeoutMs
|
|
572
|
+
timeoutMs: options.replyTimeoutMs,
|
|
573
|
+
params: channel.params
|
|
534
574
|
});
|
|
535
|
-
logger.info(`[#4418] React 中断(${info.kind}/${info.ruleId}
|
|
575
|
+
logger.info(`[#4418] React 中断(${info.kind}/${info.ruleId})已回${isWecom ? "企微" : "飞书"} (${channel.messageId ?? channel.chatId})`);
|
|
536
576
|
return { sent: true, kind: info.kind, info };
|
|
537
577
|
} catch (err) {
|
|
538
578
|
const errorMsg = err instanceof Error ? err.message : String(err);
|
|
539
579
|
repliedTriggers.delete(dedupKey);
|
|
540
|
-
logger.warn(`[#4418] React 中断(${info.kind}/${info.ruleId}
|
|
580
|
+
logger.warn(`[#4418] React 中断(${info.kind}/${info.ruleId})回${isWecom ? "企微" : "飞书"}失败(已忽略): ${errorMsg}`);
|
|
541
581
|
return { sent: false, kind: info.kind, info, error: errorMsg };
|
|
542
582
|
}
|
|
543
583
|
}
|
|
@@ -9,6 +9,9 @@ import {
|
|
|
9
9
|
getCurrentProcessRegistry,
|
|
10
10
|
killProcessTree
|
|
11
11
|
} from "./roy-agent-core-fttgm52a.js";
|
|
12
|
+
import {
|
|
13
|
+
wecomRespondTool
|
|
14
|
+
} from "./roy-agent-core-m3vjepzz.js";
|
|
12
15
|
import {
|
|
13
16
|
init_decorator,
|
|
14
17
|
init_trace_filters,
|
|
@@ -940,6 +943,7 @@ function getAllBuiltInTools() {
|
|
|
940
943
|
editFileTool,
|
|
941
944
|
grepTool,
|
|
942
945
|
understandImageTool,
|
|
946
|
+
wecomRespondTool,
|
|
943
947
|
queryBackgroundProcessTool,
|
|
944
948
|
compactSessionTool
|
|
945
949
|
];
|
|
@@ -7,7 +7,8 @@ var BUILT_IN_EVENT_SOURCE_TYPES = {
|
|
|
7
7
|
LARK_CLI: "lark-cli",
|
|
8
8
|
TIMER: "timer",
|
|
9
9
|
BOUNTY_IM: "bounty-im",
|
|
10
|
-
CLI_COMMAND: "cli-command"
|
|
10
|
+
CLI_COMMAND: "cli-command",
|
|
11
|
+
WECOM_CLI: "wecom-cli"
|
|
11
12
|
};
|
|
12
13
|
var BUILT_IN_EVENT_SOURCE_TYPE_LIST = Object.values(BUILT_IN_EVENT_SOURCE_TYPES);
|
|
13
14
|
var defaultLarkCliRunner = {
|
|
@@ -60,6 +61,8 @@ function getDefaultConfigForType(type) {
|
|
|
60
61
|
switch (type) {
|
|
61
62
|
case BUILT_IN_EVENT_SOURCE_TYPES.LARK_CLI:
|
|
62
63
|
return { command: "lark-cli event consume im.message.receive_v1 --as bot" };
|
|
64
|
+
case BUILT_IN_EVENT_SOURCE_TYPES.WECOM_CLI:
|
|
65
|
+
return { command: "wecom-cli event consume" };
|
|
63
66
|
default:
|
|
64
67
|
return {};
|
|
65
68
|
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__resetWecomReplySentForTest,
|
|
3
|
+
__resetWecomRespondRegistryForTest,
|
|
4
|
+
autoReplyWecomTurn,
|
|
5
|
+
getWecomRespondTarget,
|
|
6
|
+
markWecomReplySent,
|
|
7
|
+
registerWecomRespondTarget,
|
|
8
|
+
sendWecomReply,
|
|
9
|
+
sendWecomTemplateCard,
|
|
10
|
+
unregisterWecomRespondTarget,
|
|
11
|
+
wasWecomReplySent,
|
|
12
|
+
wecomRespondTool
|
|
13
|
+
} from "./roy-agent-core-m3vjepzz.js";
|
|
14
|
+
import"./roy-agent-core-7cbpmk4q.js";
|
|
15
|
+
import"./roy-agent-core-qq96p0tj.js";
|
|
16
|
+
import"./roy-agent-core-7f7t9wwp.js";
|
|
17
|
+
import"./roy-agent-core-85xyctnb.js";
|
|
18
|
+
import"./roy-agent-core-fs0mn2jk.js";
|
|
19
|
+
export {
|
|
20
|
+
wecomRespondTool,
|
|
21
|
+
wasWecomReplySent,
|
|
22
|
+
unregisterWecomRespondTarget,
|
|
23
|
+
sendWecomTemplateCard,
|
|
24
|
+
sendWecomReply,
|
|
25
|
+
registerWecomRespondTarget,
|
|
26
|
+
markWecomReplySent,
|
|
27
|
+
getWecomRespondTarget,
|
|
28
|
+
autoReplyWecomTurn,
|
|
29
|
+
__resetWecomRespondRegistryForTest,
|
|
30
|
+
__resetWecomReplySentForTest
|
|
31
|
+
};
|