@ai-setting/roy-agent-core 1.5.106 → 1.5.108
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/env/agent/index.js +2 -2
- package/dist/env/event-source/index.js +3 -3
- package/dist/env/index.js +11 -11
- package/dist/env/plugin/index.js +104 -2
- package/dist/env/prompt/index.js +2 -2
- package/dist/env/task/delegate/index.js +3 -3
- package/dist/env/task/index.js +4 -4
- package/dist/env/task/plugins/index.js +2 -2
- package/dist/env/workflow/index.js +3 -3
- package/dist/env/workflow/service/index.js +1 -1
- package/dist/env/workflow/tools/index.js +2 -2
- package/dist/index.js +12 -12
- package/dist/shared/@ai-setting/{roy-agent-core-1qbny05x.js → roy-agent-core-0z7wxga5.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-jy5hkjtb.js → roy-agent-core-7qtjwc6n.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-nz5wn9yc.js → roy-agent-core-adtaw927.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-k31c3kvz.js → roy-agent-core-as3phr7n.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-e7t3rj0e.js → roy-agent-core-b75jtybq.js} +39 -0
- package/dist/shared/@ai-setting/{roy-agent-core-gdhcj2x4.js → roy-agent-core-c91kajaz.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-hq4pqava.js → roy-agent-core-ezqr705j.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-gabw591f.js → roy-agent-core-ferwt92c.js} +20 -3
- package/dist/shared/@ai-setting/{roy-agent-core-8y4ccnfh.js → roy-agent-core-qcdh4t1j.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-g17zc2kf.js → roy-agent-core-seak6edf.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-ztjpg1p3.js → roy-agent-core-tshbggk8.js} +26 -13
- package/dist/shared/@ai-setting/{roy-agent-core-ws76avbn.js → roy-agent-core-z7dxedn6.js} +87 -2
- package/package.json +1 -1
package/dist/env/agent/index.js
CHANGED
|
@@ -2,13 +2,13 @@ import {
|
|
|
2
2
|
AgentComponent,
|
|
3
3
|
AgentComponentConfigSchema,
|
|
4
4
|
SummaryAgent
|
|
5
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
5
|
+
} from "../../shared/@ai-setting/roy-agent-core-adtaw927.js";
|
|
6
6
|
import"../../shared/@ai-setting/roy-agent-core-j7jeqxhd.js";
|
|
7
7
|
import"../../shared/@ai-setting/roy-agent-core-nbsw8k13.js";
|
|
8
8
|
import"../../shared/@ai-setting/roy-agent-core-5h49ct1a.js";
|
|
9
9
|
import"../../shared/@ai-setting/roy-agent-core-xjdcx45t.js";
|
|
10
10
|
import"../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
11
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
11
|
+
import"../../shared/@ai-setting/roy-agent-core-as3phr7n.js";
|
|
12
12
|
import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
13
13
|
import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
|
|
14
14
|
import"../../shared/@ai-setting/roy-agent-core-yfhgxh5a.js";
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
larkCliHandler,
|
|
11
11
|
resolveBountyIMSystemPrompt,
|
|
12
12
|
timerHandler
|
|
13
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
13
|
+
} from "../../shared/@ai-setting/roy-agent-core-ezqr705j.js";
|
|
14
14
|
import {
|
|
15
15
|
BUILT_IN_EVENT_SOURCE_TYPES,
|
|
16
16
|
BUILT_IN_EVENT_SOURCE_TYPE_LIST,
|
|
@@ -21,12 +21,12 @@ import {
|
|
|
21
21
|
validateEventSourceConfig
|
|
22
22
|
} from "../../shared/@ai-setting/roy-agent-core-ds5f75pg.js";
|
|
23
23
|
import"../../shared/@ai-setting/roy-agent-core-wmkx79b1.js";
|
|
24
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
24
|
+
import"../../shared/@ai-setting/roy-agent-core-c91kajaz.js";
|
|
25
25
|
import"../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
26
26
|
import"../../shared/@ai-setting/roy-agent-core-8wd3qwx5.js";
|
|
27
27
|
import"../../shared/@ai-setting/roy-agent-core-4yq23m5g.js";
|
|
28
28
|
import"../../shared/@ai-setting/roy-agent-core-xjdcx45t.js";
|
|
29
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
29
|
+
import"../../shared/@ai-setting/roy-agent-core-ferwt92c.js";
|
|
30
30
|
import"../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
|
|
31
31
|
import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
|
|
32
32
|
import"../../shared/@ai-setting/roy-agent-core-pf1c360e.js";
|
package/dist/env/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
EventSourceComponent,
|
|
6
6
|
builtInHandlers,
|
|
7
7
|
larkCliHandler
|
|
8
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
8
|
+
} from "../shared/@ai-setting/roy-agent-core-ezqr705j.js";
|
|
9
9
|
import {
|
|
10
10
|
EventSourceInitHooks,
|
|
11
11
|
getDefaultConfigForType,
|
|
@@ -16,12 +16,12 @@ import {
|
|
|
16
16
|
import"../shared/@ai-setting/roy-agent-core-wmkx79b1.js";
|
|
17
17
|
import {
|
|
18
18
|
PluginComponent
|
|
19
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
20
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
19
|
+
} from "../shared/@ai-setting/roy-agent-core-z7dxedn6.js";
|
|
20
|
+
import"../shared/@ai-setting/roy-agent-core-c91kajaz.js";
|
|
21
21
|
import"../shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
22
22
|
import {
|
|
23
23
|
WorkflowComponent
|
|
24
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
24
|
+
} from "../shared/@ai-setting/roy-agent-core-qcdh4t1j.js";
|
|
25
25
|
import"../shared/@ai-setting/roy-agent-core-xgnpr28w.js";
|
|
26
26
|
import"../shared/@ai-setting/roy-agent-core-kbasdf13.js";
|
|
27
27
|
import"../shared/@ai-setting/roy-agent-core-6atd905e.js";
|
|
@@ -31,9 +31,9 @@ import"../shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
|
|
|
31
31
|
import"../shared/@ai-setting/roy-agent-core-hhrg314p.js";
|
|
32
32
|
import"../shared/@ai-setting/roy-agent-core-g2mth323.js";
|
|
33
33
|
import"../shared/@ai-setting/roy-agent-core-qnrf2aw6.js";
|
|
34
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
34
|
+
import"../shared/@ai-setting/roy-agent-core-tshbggk8.js";
|
|
35
35
|
import"../shared/@ai-setting/roy-agent-core-1db4vpc6.js";
|
|
36
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
36
|
+
import"../shared/@ai-setting/roy-agent-core-b75jtybq.js";
|
|
37
37
|
import"../shared/@ai-setting/roy-agent-core-8wd3qwx5.js";
|
|
38
38
|
import"../shared/@ai-setting/roy-agent-core-4yq23m5g.js";
|
|
39
39
|
import"../shared/@ai-setting/roy-agent-core-h0x19xgn.js";
|
|
@@ -41,7 +41,7 @@ import"../shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
|
41
41
|
import {
|
|
42
42
|
AgentComponent,
|
|
43
43
|
AgentComponentConfigSchema
|
|
44
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
44
|
+
} from "../shared/@ai-setting/roy-agent-core-adtaw927.js";
|
|
45
45
|
import"../shared/@ai-setting/roy-agent-core-j7jeqxhd.js";
|
|
46
46
|
import"../shared/@ai-setting/roy-agent-core-nbsw8k13.js";
|
|
47
47
|
import"../shared/@ai-setting/roy-agent-core-5h49ct1a.js";
|
|
@@ -49,13 +49,13 @@ import"../shared/@ai-setting/roy-agent-core-xjdcx45t.js";
|
|
|
49
49
|
import"../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
50
50
|
import {
|
|
51
51
|
TaskComponent
|
|
52
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
52
|
+
} from "../shared/@ai-setting/roy-agent-core-seak6edf.js";
|
|
53
53
|
import"../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
|
|
54
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
54
|
+
import"../shared/@ai-setting/roy-agent-core-7qtjwc6n.js";
|
|
55
55
|
import"../shared/@ai-setting/roy-agent-core-pzeexnhf.js";
|
|
56
56
|
import"../shared/@ai-setting/roy-agent-core-9xby523m.js";
|
|
57
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
58
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
57
|
+
import"../shared/@ai-setting/roy-agent-core-ferwt92c.js";
|
|
58
|
+
import"../shared/@ai-setting/roy-agent-core-as3phr7n.js";
|
|
59
59
|
import {
|
|
60
60
|
XDG_PATHS,
|
|
61
61
|
getXDGPath,
|
package/dist/env/plugin/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
EventBusNotificationChannel,
|
|
2
3
|
PluginComponent
|
|
3
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
4
|
+
} from "../../shared/@ai-setting/roy-agent-core-z7dxedn6.js";
|
|
4
5
|
import {
|
|
5
6
|
BasePlugin
|
|
6
7
|
} from "../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
@@ -10,11 +11,112 @@ import"../../shared/@ai-setting/roy-agent-core-gp872e7m.js";
|
|
|
10
11
|
import"../../shared/@ai-setting/roy-agent-core-zttjq1h3.js";
|
|
11
12
|
import"../../shared/@ai-setting/roy-agent-core-scp0afxg.js";
|
|
12
13
|
import"../../shared/@ai-setting/roy-agent-core-cg146hmg.js";
|
|
13
|
-
import
|
|
14
|
+
import {
|
|
15
|
+
createLogger,
|
|
16
|
+
init_logger
|
|
17
|
+
} from "../../shared/@ai-setting/roy-agent-core-vyygk314.js";
|
|
14
18
|
import"../../shared/@ai-setting/roy-agent-core-7z9b1fm8.js";
|
|
15
19
|
import"../../shared/@ai-setting/roy-agent-core-c6592r3c.js";
|
|
16
20
|
import"../../shared/@ai-setting/roy-agent-core-fs0mn2jk.js";
|
|
21
|
+
// src/env/plugin/lark-cli-notification-channel.ts
|
|
22
|
+
init_logger();
|
|
23
|
+
import { spawn } from "node:child_process";
|
|
24
|
+
var logger = createLogger("plugin:notification:lark-cli");
|
|
25
|
+
|
|
26
|
+
class LarkCliNotificationChannel {
|
|
27
|
+
name = "lark-cli";
|
|
28
|
+
canRoute(_options, _extras, envContext) {
|
|
29
|
+
const channel = envContext.replyChannel;
|
|
30
|
+
if (!channel) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
if (!channel.type || !channel.type.toLowerCase().includes("lark")) {
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
if (!channel.chatId && !channel.messageId) {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
return true;
|
|
40
|
+
}
|
|
41
|
+
async send(options, extras, envContext) {
|
|
42
|
+
const replyChannel = envContext.replyChannel;
|
|
43
|
+
if (!replyChannel) {
|
|
44
|
+
logger.debug(`[lark-cli] No replyChannel for plugin '${extras.pluginName}', skip`);
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const chatId = replyChannel.chatId;
|
|
48
|
+
const messageId = replyChannel.messageId;
|
|
49
|
+
const profile = replyChannel.profile;
|
|
50
|
+
if (!chatId && !messageId) {
|
|
51
|
+
logger.debug(`[lark-cli] replyChannel has no chatId/messageId for plugin '${extras.pluginName}', skip`);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const message = `${options.title}
|
|
55
|
+
|
|
56
|
+
${options.content}`;
|
|
57
|
+
try {
|
|
58
|
+
await this.spawnLarkMessage({ chatId, messageId, content: message, profile });
|
|
59
|
+
logger.info(`[lark-cli] Notification sent for plugin '${extras.pluginName}': ${options.type}`);
|
|
60
|
+
} catch (err) {
|
|
61
|
+
logger.warn(`[lark-cli] Failed to send notification for plugin '${extras.pluginName}' (${options.type}): ${err}`);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
spawnLarkMessage(options) {
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
const { chatId, messageId, content, profile } = options;
|
|
67
|
+
let args;
|
|
68
|
+
if (messageId) {
|
|
69
|
+
args = [
|
|
70
|
+
"im",
|
|
71
|
+
"+messages-reply",
|
|
72
|
+
"--message-id",
|
|
73
|
+
messageId,
|
|
74
|
+
"--markdown",
|
|
75
|
+
content,
|
|
76
|
+
"--as",
|
|
77
|
+
"bot"
|
|
78
|
+
];
|
|
79
|
+
} else {
|
|
80
|
+
args = [
|
|
81
|
+
"im",
|
|
82
|
+
"+messages-send",
|
|
83
|
+
"--chat-id",
|
|
84
|
+
chatId,
|
|
85
|
+
"--markdown",
|
|
86
|
+
content
|
|
87
|
+
];
|
|
88
|
+
}
|
|
89
|
+
if (profile) {
|
|
90
|
+
args.unshift("--profile", profile);
|
|
91
|
+
}
|
|
92
|
+
const proc = spawn("lark-cli", args, {
|
|
93
|
+
shell: false,
|
|
94
|
+
stdio: ["pipe", "pipe", "pipe"]
|
|
95
|
+
});
|
|
96
|
+
let stdout = "";
|
|
97
|
+
let stderr = "";
|
|
98
|
+
proc.stdout?.on("data", (data) => {
|
|
99
|
+
stdout += data.toString();
|
|
100
|
+
});
|
|
101
|
+
proc.stderr?.on("data", (data) => {
|
|
102
|
+
stderr += data.toString();
|
|
103
|
+
});
|
|
104
|
+
proc.on("close", (code) => {
|
|
105
|
+
if (code === 0) {
|
|
106
|
+
resolve();
|
|
107
|
+
} else {
|
|
108
|
+
reject(new Error(`lark-cli exited with code ${code}: ${stderr}`));
|
|
109
|
+
}
|
|
110
|
+
});
|
|
111
|
+
proc.on("error", (error) => {
|
|
112
|
+
reject(error);
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
}
|
|
17
117
|
export {
|
|
18
118
|
PluginComponent,
|
|
119
|
+
LarkCliNotificationChannel,
|
|
120
|
+
EventBusNotificationChannel,
|
|
19
121
|
BasePlugin
|
|
20
122
|
};
|
package/dist/env/prompt/index.js
CHANGED
|
@@ -3,8 +3,8 @@ import {
|
|
|
3
3
|
PromptConfigSchema,
|
|
4
4
|
PromptPathSchema,
|
|
5
5
|
PromptRenderer
|
|
6
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
7
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
6
|
+
} from "../../shared/@ai-setting/roy-agent-core-0z7wxga5.js";
|
|
7
|
+
import"../../shared/@ai-setting/roy-agent-core-ferwt92c.js";
|
|
8
8
|
import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
9
9
|
import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
|
|
10
10
|
import"../../shared/@ai-setting/roy-agent-core-pf1c360e.js";
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
BackgroundTaskManager,
|
|
4
4
|
createDelegateTool,
|
|
5
5
|
createStopTool
|
|
6
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
6
|
+
} from "../../../shared/@ai-setting/roy-agent-core-7qtjwc6n.js";
|
|
7
7
|
import"../../../shared/@ai-setting/roy-agent-core-pzeexnhf.js";
|
|
8
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
9
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
8
|
+
import"../../../shared/@ai-setting/roy-agent-core-ferwt92c.js";
|
|
9
|
+
import"../../../shared/@ai-setting/roy-agent-core-as3phr7n.js";
|
|
10
10
|
import"../../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
11
11
|
import"../../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
|
|
12
12
|
import"../../../shared/@ai-setting/roy-agent-core-gp872e7m.js";
|
package/dist/env/task/index.js
CHANGED
|
@@ -5,18 +5,18 @@ import {
|
|
|
5
5
|
TaskPriorityEnum,
|
|
6
6
|
TaskStatusEnum,
|
|
7
7
|
TaskTypeEnum
|
|
8
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
8
|
+
} from "../../shared/@ai-setting/roy-agent-core-seak6edf.js";
|
|
9
9
|
import {
|
|
10
10
|
TaskEntityEventTypes
|
|
11
11
|
} from "../../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
|
|
12
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
12
|
+
import"../../shared/@ai-setting/roy-agent-core-7qtjwc6n.js";
|
|
13
13
|
import"../../shared/@ai-setting/roy-agent-core-pzeexnhf.js";
|
|
14
14
|
import {
|
|
15
15
|
SQLiteTaskStore,
|
|
16
16
|
getDefaultTaskDbPath
|
|
17
17
|
} from "../../shared/@ai-setting/roy-agent-core-9xby523m.js";
|
|
18
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
19
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
18
|
+
import"../../shared/@ai-setting/roy-agent-core-ferwt92c.js";
|
|
19
|
+
import"../../shared/@ai-setting/roy-agent-core-as3phr7n.js";
|
|
20
20
|
import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
21
21
|
import"../../shared/@ai-setting/roy-agent-core-0ye4q2jj.js";
|
|
22
22
|
import"../../shared/@ai-setting/roy-agent-core-t94ktchq.js";
|
|
@@ -7,14 +7,14 @@ import {
|
|
|
7
7
|
formatExtractorInput,
|
|
8
8
|
formatExtractorInputFromDescription,
|
|
9
9
|
parseExtractorOutput
|
|
10
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
10
|
+
} from "../../../shared/@ai-setting/roy-agent-core-c91kajaz.js";
|
|
11
11
|
import"../../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
12
12
|
import"../../../shared/@ai-setting/roy-agent-core-8wd3qwx5.js";
|
|
13
13
|
import"../../../shared/@ai-setting/roy-agent-core-4yq23m5g.js";
|
|
14
14
|
import {
|
|
15
15
|
createAutoTaskPlugin
|
|
16
16
|
} from "../../../shared/@ai-setting/roy-agent-core-xjdcx45t.js";
|
|
17
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
17
|
+
import"../../../shared/@ai-setting/roy-agent-core-ferwt92c.js";
|
|
18
18
|
import"../../../shared/@ai-setting/roy-agent-core-1pg0fepg.js";
|
|
19
19
|
import"../../../shared/@ai-setting/roy-agent-core-zttjq1h3.js";
|
|
20
20
|
import"../../../shared/@ai-setting/roy-agent-core-scp0afxg.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
WorkflowComponent
|
|
3
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
3
|
+
} from "../../shared/@ai-setting/roy-agent-core-qcdh4t1j.js";
|
|
4
4
|
import"../../shared/@ai-setting/roy-agent-core-xgnpr28w.js";
|
|
5
5
|
import"../../shared/@ai-setting/roy-agent-core-kbasdf13.js";
|
|
6
6
|
import"../../shared/@ai-setting/roy-agent-core-6atd905e.js";
|
|
@@ -60,9 +60,9 @@ import {
|
|
|
60
60
|
pathNotFound,
|
|
61
61
|
unresolvedVariable
|
|
62
62
|
} from "../../shared/@ai-setting/roy-agent-core-qnrf2aw6.js";
|
|
63
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
63
|
+
import"../../shared/@ai-setting/roy-agent-core-tshbggk8.js";
|
|
64
64
|
import"../../shared/@ai-setting/roy-agent-core-1db4vpc6.js";
|
|
65
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
65
|
+
import"../../shared/@ai-setting/roy-agent-core-b75jtybq.js";
|
|
66
66
|
import"../../shared/@ai-setting/roy-agent-core-8wd3qwx5.js";
|
|
67
67
|
import"../../shared/@ai-setting/roy-agent-core-4yq23m5g.js";
|
|
68
68
|
import {
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
} from "../../../shared/@ai-setting/roy-agent-core-hhrg314p.js";
|
|
6
6
|
import {
|
|
7
7
|
WorkflowService
|
|
8
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
8
|
+
} from "../../../shared/@ai-setting/roy-agent-core-b75jtybq.js";
|
|
9
9
|
import"../../../shared/@ai-setting/roy-agent-core-cg146hmg.js";
|
|
10
10
|
import"../../../shared/@ai-setting/roy-agent-core-vyygk314.js";
|
|
11
11
|
import"../../../shared/@ai-setting/roy-agent-core-7z9b1fm8.js";
|
|
@@ -24,7 +24,7 @@ import {
|
|
|
24
24
|
getRunWorkflowTool,
|
|
25
25
|
initRunWorkflowTool,
|
|
26
26
|
resetRunWorkflowTool
|
|
27
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
27
|
+
} from "../../../shared/@ai-setting/roy-agent-core-tshbggk8.js";
|
|
28
28
|
import {
|
|
29
29
|
WORKFLOW_SUBMIT_OUTPUT_TOOL_NAME,
|
|
30
30
|
WorkflowJsonOutputMarker,
|
|
@@ -32,7 +32,7 @@ import {
|
|
|
32
32
|
init_submit_json_output_tool,
|
|
33
33
|
parseWorkflowJsonOutput
|
|
34
34
|
} from "../../../shared/@ai-setting/roy-agent-core-1db4vpc6.js";
|
|
35
|
-
import"../../../shared/@ai-setting/roy-agent-core-
|
|
35
|
+
import"../../../shared/@ai-setting/roy-agent-core-b75jtybq.js";
|
|
36
36
|
import"../../../shared/@ai-setting/roy-agent-core-8wd3qwx5.js";
|
|
37
37
|
import"../../../shared/@ai-setting/roy-agent-core-4yq23m5g.js";
|
|
38
38
|
import"../../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PromptComponent,
|
|
3
3
|
PromptStore
|
|
4
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
4
|
+
} from "./shared/@ai-setting/roy-agent-core-0z7wxga5.js";
|
|
5
5
|
import {
|
|
6
6
|
LLMComponent,
|
|
7
7
|
LLMConfigSchema,
|
|
@@ -74,7 +74,7 @@ import {
|
|
|
74
74
|
larkCliHandler,
|
|
75
75
|
resolveBountyIMSystemPrompt,
|
|
76
76
|
timerHandler
|
|
77
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
77
|
+
} from "./shared/@ai-setting/roy-agent-core-ezqr705j.js";
|
|
78
78
|
import {
|
|
79
79
|
BUILT_IN_EVENT_SOURCE_TYPES,
|
|
80
80
|
BUILT_IN_EVENT_SOURCE_TYPE_LIST,
|
|
@@ -90,16 +90,16 @@ import {
|
|
|
90
90
|
} from "./shared/@ai-setting/roy-agent-core-wmkx79b1.js";
|
|
91
91
|
import {
|
|
92
92
|
PluginComponent
|
|
93
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
93
|
+
} from "./shared/@ai-setting/roy-agent-core-z7dxedn6.js";
|
|
94
94
|
import {
|
|
95
95
|
TaskTagPlugin
|
|
96
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
96
|
+
} from "./shared/@ai-setting/roy-agent-core-c91kajaz.js";
|
|
97
97
|
import {
|
|
98
98
|
BasePlugin
|
|
99
99
|
} from "./shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
100
100
|
import {
|
|
101
101
|
WorkflowComponent
|
|
102
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
102
|
+
} from "./shared/@ai-setting/roy-agent-core-qcdh4t1j.js";
|
|
103
103
|
import {
|
|
104
104
|
init_node_registry_helper,
|
|
105
105
|
registerDecoratorNodeType
|
|
@@ -112,9 +112,9 @@ import"./shared/@ai-setting/roy-agent-core-ddwa0n6h.js";
|
|
|
112
112
|
import"./shared/@ai-setting/roy-agent-core-hhrg314p.js";
|
|
113
113
|
import"./shared/@ai-setting/roy-agent-core-g2mth323.js";
|
|
114
114
|
import"./shared/@ai-setting/roy-agent-core-qnrf2aw6.js";
|
|
115
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
115
|
+
import"./shared/@ai-setting/roy-agent-core-tshbggk8.js";
|
|
116
116
|
import"./shared/@ai-setting/roy-agent-core-1db4vpc6.js";
|
|
117
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
117
|
+
import"./shared/@ai-setting/roy-agent-core-b75jtybq.js";
|
|
118
118
|
import"./shared/@ai-setting/roy-agent-core-8wd3qwx5.js";
|
|
119
119
|
import"./shared/@ai-setting/roy-agent-core-4yq23m5g.js";
|
|
120
120
|
import {
|
|
@@ -128,7 +128,7 @@ import"./shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
|
128
128
|
import {
|
|
129
129
|
AgentComponent,
|
|
130
130
|
AgentComponentConfigSchema
|
|
131
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
131
|
+
} from "./shared/@ai-setting/roy-agent-core-adtaw927.js";
|
|
132
132
|
import {
|
|
133
133
|
createInvokeConfig,
|
|
134
134
|
invoke,
|
|
@@ -150,9 +150,9 @@ import {
|
|
|
150
150
|
} from "./shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
151
151
|
import {
|
|
152
152
|
TaskComponent
|
|
153
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
153
|
+
} from "./shared/@ai-setting/roy-agent-core-seak6edf.js";
|
|
154
154
|
import"./shared/@ai-setting/roy-agent-core-8gxth0eh.js";
|
|
155
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
155
|
+
import"./shared/@ai-setting/roy-agent-core-7qtjwc6n.js";
|
|
156
156
|
import"./shared/@ai-setting/roy-agent-core-pzeexnhf.js";
|
|
157
157
|
import {
|
|
158
158
|
SQLiteTaskStore,
|
|
@@ -161,10 +161,10 @@ import {
|
|
|
161
161
|
import {
|
|
162
162
|
getBuiltInPrompt,
|
|
163
163
|
getBuiltInPromptNames
|
|
164
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
164
|
+
} from "./shared/@ai-setting/roy-agent-core-ferwt92c.js";
|
|
165
165
|
import {
|
|
166
166
|
AgentRegistry
|
|
167
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
167
|
+
} from "./shared/@ai-setting/roy-agent-core-as3phr7n.js";
|
|
168
168
|
import {
|
|
169
169
|
XDG_PATHS,
|
|
170
170
|
getXDGPath,
|
|
@@ -4,10 +4,10 @@ import {
|
|
|
4
4
|
} from "./roy-agent-core-pzeexnhf.js";
|
|
5
5
|
import {
|
|
6
6
|
builtInPrompts
|
|
7
|
-
} from "./roy-agent-core-
|
|
7
|
+
} from "./roy-agent-core-ferwt92c.js";
|
|
8
8
|
import {
|
|
9
9
|
DEFAULT_SUBAGENT_PROMPT
|
|
10
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-as3phr7n.js";
|
|
11
11
|
import {
|
|
12
12
|
TaskHookPoints
|
|
13
13
|
} from "./roy-agent-core-1pg0fepg.js";
|
|
@@ -254,7 +254,7 @@ ${originalPrompt}
|
|
|
254
254
|
`;
|
|
255
255
|
}
|
|
256
256
|
var DEFAULT_TIMEOUT = 1800000;
|
|
257
|
-
var PROGRESS_INTERVAL =
|
|
257
|
+
var PROGRESS_INTERVAL = 1200000;
|
|
258
258
|
|
|
259
259
|
class BackgroundTaskManager {
|
|
260
260
|
env;
|
|
@@ -270,6 +270,38 @@ class WorkflowService {
|
|
|
270
270
|
const engine = this.engineFactory(workflow);
|
|
271
271
|
await engine.stop(sessionId, reason);
|
|
272
272
|
}
|
|
273
|
+
async resumeSession(sessionId, options) {
|
|
274
|
+
if (!this.sessionComponent) {
|
|
275
|
+
throw new Error("SessionComponent not available");
|
|
276
|
+
}
|
|
277
|
+
const session = await this.sessionComponent.get(sessionId);
|
|
278
|
+
if (!session) {
|
|
279
|
+
throw new Error(`Session not found: ${sessionId}`);
|
|
280
|
+
}
|
|
281
|
+
const metadata = session.metadata;
|
|
282
|
+
if (metadata?.type !== "workflow") {
|
|
283
|
+
throw new Error(`Session is not a workflow session: ${sessionId}`);
|
|
284
|
+
}
|
|
285
|
+
const workflowName = metadata.workflowName;
|
|
286
|
+
if (!workflowName) {
|
|
287
|
+
throw new Error(`Workflow name not found in session metadata for ${sessionId}`);
|
|
288
|
+
}
|
|
289
|
+
const workflow = this.getWorkflowByName(workflowName);
|
|
290
|
+
if (!workflow) {
|
|
291
|
+
throw new Error(`Workflow not found: ${workflowName}`);
|
|
292
|
+
}
|
|
293
|
+
const engineOptions = {
|
|
294
|
+
...options ?? {},
|
|
295
|
+
sessionId
|
|
296
|
+
};
|
|
297
|
+
const engine = this.engineFactory(workflow, engineOptions);
|
|
298
|
+
const result = await engine.run(sessionId, engineOptions);
|
|
299
|
+
return {
|
|
300
|
+
...result,
|
|
301
|
+
runId: result.runId || result.sessionId || sessionId,
|
|
302
|
+
sessionId: result.sessionId || result.runId || sessionId
|
|
303
|
+
};
|
|
304
|
+
}
|
|
273
305
|
async getSession(sessionId) {
|
|
274
306
|
if (!this.sessionComponent) {
|
|
275
307
|
return null;
|
|
@@ -332,5 +364,12 @@ __legacyDecorateClassTS([
|
|
|
332
364
|
log: false
|
|
333
365
|
})
|
|
334
366
|
], WorkflowService.prototype, "getTag", null);
|
|
367
|
+
__legacyDecorateClassTS([
|
|
368
|
+
TracedAs("workflow.service.resumeSession", {
|
|
369
|
+
recordParams: true,
|
|
370
|
+
recordResult: false,
|
|
371
|
+
log: false
|
|
372
|
+
})
|
|
373
|
+
], WorkflowService.prototype, "resumeSession", null);
|
|
335
374
|
|
|
336
375
|
export { TAG_MIN_COUNT, TAG_MAX_COUNT, WorkflowService };
|
|
@@ -210,6 +210,12 @@ delegate_task(
|
|
|
210
210
|
5. **次选 strict-task-agent** — 需要严格 Plan→Execute→Verify 纪律时使用
|
|
211
211
|
6. **始终包含任务生命周期** — 每次委托时,指示子智能体使用 \`task_create\` → \`task_update\` → \`task_operation_create\` → \`task_complete\`
|
|
212
212
|
7. **简单回复** — 对于问候、简单问答或结果总结,可以直接回复
|
|
213
|
+
8. **⚠️ 不要 sleep 等待后台任务结果** — \`delegate_task\` 总是后台模式(参见下方"子代理通知自主处理规则"),委托后**立即返回**。**禁止**调用 \`sleep\`、\`wait\`、\`sleep N\` 等任何同步等待命令试图"等子智能体跑完"。原因:
|
|
214
|
+
- \`sleep\` 会阻塞当前 ReAct 循环,导致**无法及时接收**后台进程或子智能体的通知消息
|
|
215
|
+
- 后台任务完成后系统会**自动推送通知**(completed / failed / progress / timeout)
|
|
216
|
+
- 父 agent 收到通知后**自主处理**(见下一节),无需主动 sleep 轮询
|
|
217
|
+
- 错误做法:\`sleep 60 && task_get <id>\`、\`while !task_complete; do sleep 5; done\`
|
|
218
|
+
- 正确做法:\`delegate_task(...)\` → 立即返回 → 等待系统通知 → 收到通知后自主处理
|
|
213
219
|
|
|
214
220
|
## 子代理通知自主处理规则
|
|
215
221
|
|
|
@@ -1120,7 +1126,15 @@ workflow_run(workflow_name="strict-task-agent", input={"task_description": "修
|
|
|
1120
1126
|
- 通过 task_operation_create 记录里程碑`,
|
|
1121
1127
|
"json-extract": `# JSON Extract Agent
|
|
1122
1128
|
|
|
1123
|
-
你是一个 JSON 提取子智能体。**唯一职责**:从父 session 的对话历史中提取最终答案,通过 \`workflow_submit_output\`
|
|
1129
|
+
你是一个 JSON 提取子智能体。**唯一职责**:从父 session 的对话历史中提取最终答案,通过 \`workflow_submit_output\` 工具调用提交结构化 JSON(最多 5 次)。
|
|
1130
|
+
|
|
1131
|
+
## ✅ 关键行为:成功返回立即退出
|
|
1132
|
+
|
|
1133
|
+
\`workflow_submit_output\` 工具调用**成功返回后**(工具 result 表示 JSON 已写入),**立即停止**:
|
|
1134
|
+
- ❌ 不要继续思考
|
|
1135
|
+
- ❌ 不要输出额外文本
|
|
1136
|
+
- ❌ 不要再次调用工具(除非返回失败)
|
|
1137
|
+
- ✅ 成功 = 任务完成,立即退出(节省 maxIterations)
|
|
1124
1138
|
|
|
1125
1139
|
## ⚠️ Critical Override(防止被父 session 误导)
|
|
1126
1140
|
|
|
@@ -1156,12 +1170,15 @@ workflow_run(workflow_name="strict-task-agent", input={"task_description": "修
|
|
|
1156
1170
|
- 只调用一次,不要重复
|
|
1157
1171
|
- 不要使用其他任何工具(即使你"记得"父 agent 用了 echo)
|
|
1158
1172
|
|
|
1159
|
-
##
|
|
1173
|
+
## 行为(核心循环)
|
|
1160
1174
|
|
|
1161
1175
|
1. 读取 session 历史(通过 sessionId 自动加载)—— **只关注事实**:用户输入、最终答案是什么
|
|
1162
1176
|
2. 从对话中提取最终答案(**忽略**父 agent 的"echo workaround"叙述)
|
|
1163
1177
|
3. 调用 \`workflow_submit_output(参数 = 最终 JSON)\`
|
|
1164
|
-
4.
|
|
1178
|
+
4. **等待工具返回结果**:
|
|
1179
|
+
- ✅ 成功 → **立即退出**(不要继续思考/输出/调用其他工具)
|
|
1180
|
+
- ❌ 失败(如 schema 校验错误)→ 修正后重试,**最多 5 次**
|
|
1181
|
+
5. 退出(成功返回后**不要**做任何后续动作)
|
|
1165
1182
|
|
|
1166
1183
|
## 禁止
|
|
1167
1184
|
|
|
@@ -18,10 +18,10 @@ import {
|
|
|
18
18
|
createWorkflowSearchTool,
|
|
19
19
|
createWorkflowTagListTool,
|
|
20
20
|
createWorkflowValidateTool
|
|
21
|
-
} from "./roy-agent-core-
|
|
21
|
+
} from "./roy-agent-core-tshbggk8.js";
|
|
22
22
|
import {
|
|
23
23
|
WorkflowService
|
|
24
|
-
} from "./roy-agent-core-
|
|
24
|
+
} from "./roy-agent-core-b75jtybq.js";
|
|
25
25
|
import {
|
|
26
26
|
BaseComponent
|
|
27
27
|
} from "./roy-agent-core-pf1c360e.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TAG_MAX_COUNT,
|
|
3
3
|
TAG_MIN_COUNT
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-b75jtybq.js";
|
|
5
5
|
import {
|
|
6
6
|
validateWorkflowDefinition
|
|
7
7
|
} from "./roy-agent-core-8wd3qwx5.js";
|
|
@@ -619,12 +619,13 @@ var RunWorkflowInputSchema = z8.object({
|
|
|
619
619
|
workflow_name: z8.string().describe("Name of the workflow to run"),
|
|
620
620
|
input: z8.record(z8.any()).optional().describe("Input to pass to the workflow"),
|
|
621
621
|
sync: z8.boolean().default(true).describe("Wait for completion (default: true)"),
|
|
622
|
-
timeout: z8.number().positive().optional().describe("Timeout in milliseconds (default: 1800000 = 30 min)")
|
|
622
|
+
timeout: z8.number().positive().optional().describe("Timeout in milliseconds (default: 1800000 = 30 min)"),
|
|
623
|
+
session: z8.string().regex(/^workflow_/, { message: "session must start with 'workflow_'" }).optional().describe("Existing session ID (workflow_xxx) to resume from. Mutually exclusive with fresh `input` runs.")
|
|
623
624
|
});
|
|
624
625
|
function createRunWorkflowTool(workflowService) {
|
|
625
626
|
return {
|
|
626
627
|
name: "workflow_run",
|
|
627
|
-
description: "Run a workflow by name with optional input. Returns run_id, status, output, error, and duration_ms. Default timeout: 30 minutes.",
|
|
628
|
+
description: "Run a workflow by name with optional input, OR resume an existing session via the `session` field (must start with `workflow_`). Returns run_id, status, output, error, and duration_ms. Default timeout: 30 minutes.",
|
|
628
629
|
parameters: RunWorkflowInputSchema,
|
|
629
630
|
sandbox: {
|
|
630
631
|
enabled: false
|
|
@@ -640,8 +641,13 @@ function createRunWorkflowTool(workflowService) {
|
|
|
640
641
|
},
|
|
641
642
|
execute: async (args, ctx) => {
|
|
642
643
|
const startTime = Date.now();
|
|
643
|
-
const { workflow_name, input, sync = true, timeout = 1800000 } = args;
|
|
644
|
-
logger7.info(`Running workflow: ${workflow_name}`, {
|
|
644
|
+
const { workflow_name, input, session, sync = true, timeout = 1800000 } = args;
|
|
645
|
+
logger7.info(`Running workflow: ${workflow_name}`, {
|
|
646
|
+
input,
|
|
647
|
+
sync,
|
|
648
|
+
timeout,
|
|
649
|
+
...session ? { resumeSession: session } : {}
|
|
650
|
+
});
|
|
645
651
|
const ctxSessionId = typeof ctx?.session_id === "string" && isValidSessionId(ctx.session_id) ? ctx.session_id : undefined;
|
|
646
652
|
const envSessionId = typeof process.env.ROY_PARENT_SESSION_ID === "string" && isValidSessionId(process.env.ROY_PARENT_SESSION_ID) ? process.env.ROY_PARENT_SESSION_ID : undefined;
|
|
647
653
|
if (process.env.ROY_PARENT_SESSION_ID && !envSessionId) {
|
|
@@ -652,12 +658,22 @@ function createRunWorkflowTool(workflowService) {
|
|
|
652
658
|
let durationMs;
|
|
653
659
|
try {
|
|
654
660
|
let result;
|
|
661
|
+
const baseOptions = {
|
|
662
|
+
sync,
|
|
663
|
+
...parentSessionId ? { parentSessionId } : {}
|
|
664
|
+
};
|
|
665
|
+
const executeCall = async () => {
|
|
666
|
+
if (session) {
|
|
667
|
+
return workflowService.resumeSession(session, {
|
|
668
|
+
...baseOptions,
|
|
669
|
+
...input ? { input } : {}
|
|
670
|
+
});
|
|
671
|
+
}
|
|
672
|
+
return workflowService.runWorkflow(workflow_name, input, baseOptions);
|
|
673
|
+
};
|
|
655
674
|
if (timeout) {
|
|
656
675
|
result = await Promise.race([
|
|
657
|
-
|
|
658
|
-
sync,
|
|
659
|
-
...parentSessionId ? { parentSessionId } : {}
|
|
660
|
-
}),
|
|
676
|
+
executeCall(),
|
|
661
677
|
new Promise((_, reject) => {
|
|
662
678
|
timeoutHandle = setTimeout(() => {
|
|
663
679
|
reject(new Error("Workflow execution timed out"));
|
|
@@ -665,10 +681,7 @@ function createRunWorkflowTool(workflowService) {
|
|
|
665
681
|
})
|
|
666
682
|
]);
|
|
667
683
|
} else {
|
|
668
|
-
result = await
|
|
669
|
-
sync,
|
|
670
|
-
...parentSessionId ? { parentSessionId } : {}
|
|
671
|
-
});
|
|
684
|
+
result = await executeCall();
|
|
672
685
|
}
|
|
673
686
|
if (timeoutHandle) {
|
|
674
687
|
clearTimeout(timeoutHandle);
|
|
@@ -8,18 +8,71 @@ import {
|
|
|
8
8
|
globalHookManager,
|
|
9
9
|
init_global_hook_manager
|
|
10
10
|
} from "./roy-agent-core-gp872e7m.js";
|
|
11
|
+
import {
|
|
12
|
+
init_context
|
|
13
|
+
} from "./roy-agent-core-zttjq1h3.js";
|
|
14
|
+
import {
|
|
15
|
+
getEnvContextOrEmpty
|
|
16
|
+
} from "./roy-agent-core-scp0afxg.js";
|
|
11
17
|
import {
|
|
12
18
|
createLogger,
|
|
13
19
|
init_logger
|
|
14
20
|
} from "./roy-agent-core-vyygk314.js";
|
|
15
21
|
|
|
22
|
+
// src/env/plugin/event-bus-notification-channel.ts
|
|
23
|
+
init_logger();
|
|
24
|
+
var logger = createLogger("plugin:notification:event-bus");
|
|
25
|
+
|
|
26
|
+
class EventBusNotificationChannel {
|
|
27
|
+
name = "event-bus";
|
|
28
|
+
canRoute(_options, _extras, _envContext) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
async send(options, extras, _envContext) {
|
|
32
|
+
const envInstance = extras.envInstance;
|
|
33
|
+
if (!envInstance) {
|
|
34
|
+
logger.debug(`[event-bus] No envInstance for plugin '${extras.pluginName}', skip notification '${options.type}'`);
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
37
|
+
const pushFn = envInstance.pushEnvEvent;
|
|
38
|
+
if (typeof pushFn !== "function") {
|
|
39
|
+
logger.debug(`[event-bus] envInstance.pushEnvEvent is not a function for plugin '${extras.pluginName}', skip notification '${options.type}'`);
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
const eventType = `plugin.notification.${options.type}`;
|
|
43
|
+
const event = {
|
|
44
|
+
id: generateEventId(),
|
|
45
|
+
type: eventType,
|
|
46
|
+
timestamp: Date.now(),
|
|
47
|
+
metadata: {
|
|
48
|
+
source: `plugin:${extras.pluginName}`,
|
|
49
|
+
...options.metadata || {}
|
|
50
|
+
},
|
|
51
|
+
payload: {
|
|
52
|
+
title: options.title,
|
|
53
|
+
content: options.content
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
try {
|
|
57
|
+
pushFn.call(envInstance, event);
|
|
58
|
+
} catch (err) {
|
|
59
|
+
logger.warn(`[event-bus] pushEnvEvent threw for plugin '${extras.pluginName}' notification '${options.type}': ${err}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function generateEventId() {
|
|
64
|
+
const ts = Date.now().toString(36);
|
|
65
|
+
const rand = Math.random().toString(36).slice(2, 10);
|
|
66
|
+
return `${ts}-${rand}`;
|
|
67
|
+
}
|
|
68
|
+
|
|
16
69
|
// src/env/plugin/plugin-component.ts
|
|
17
70
|
init_global_hook_manager();
|
|
18
71
|
init_logger();
|
|
72
|
+
init_context();
|
|
19
73
|
import { existsSync, readFileSync } from "node:fs";
|
|
20
74
|
import { join } from "node:path";
|
|
21
75
|
import { homedir } from "node:os";
|
|
22
|
-
|
|
23
76
|
class PluginComponent extends BaseComponent {
|
|
24
77
|
name = "plugin";
|
|
25
78
|
version = "1.0.0";
|
|
@@ -27,6 +80,9 @@ class PluginComponent extends BaseComponent {
|
|
|
27
80
|
componentCache = new Map;
|
|
28
81
|
logger = createLogger("plugin");
|
|
29
82
|
configComponent;
|
|
83
|
+
notificationChannels = [
|
|
84
|
+
new EventBusNotificationChannel
|
|
85
|
+
];
|
|
30
86
|
constructor() {
|
|
31
87
|
super();
|
|
32
88
|
}
|
|
@@ -185,6 +241,27 @@ class PluginComponent extends BaseComponent {
|
|
|
185
241
|
await this.register(plugin);
|
|
186
242
|
}
|
|
187
243
|
}
|
|
244
|
+
setNotificationChannels(channels) {
|
|
245
|
+
this.notificationChannels = [...channels];
|
|
246
|
+
this.logger.info(`[PluginComponent] Notification channels updated: ${this.notificationChannels.map((c) => c.name).join(", ") || "(none)"}`);
|
|
247
|
+
}
|
|
248
|
+
getNotificationChannelNames() {
|
|
249
|
+
return this.notificationChannels.map((c) => c.name);
|
|
250
|
+
}
|
|
251
|
+
async routeNotification(options, extras, envContext) {
|
|
252
|
+
for (const channel of this.notificationChannels) {
|
|
253
|
+
try {
|
|
254
|
+
if (!channel.canRoute(options, extras, envContext)) {
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
await channel.send(options, extras, envContext);
|
|
258
|
+
return;
|
|
259
|
+
} catch (err) {
|
|
260
|
+
this.logger.warn(`[PluginComponent] Notification channel '${channel.name}' send threw: ${err}`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
this.logger.warn(`[PluginComponent] No notification channel can route '${options.type}' (plugin: ${extras.pluginName})`);
|
|
264
|
+
}
|
|
188
265
|
async stop() {
|
|
189
266
|
this.setStatus("stopping");
|
|
190
267
|
this.logger.info("[PluginComponent] Stopping...");
|
|
@@ -236,9 +313,17 @@ class PluginComponent extends BaseComponent {
|
|
|
236
313
|
});
|
|
237
314
|
self.logger.debug(`Registered hook: ${hook.point} (for plugin: ${plugin.name})`);
|
|
238
315
|
},
|
|
316
|
+
async notify(options) {
|
|
317
|
+
const envContext = getEnvContextOrEmpty();
|
|
318
|
+
const extras = {
|
|
319
|
+
pluginName: plugin.name,
|
|
320
|
+
envInstance: self.env
|
|
321
|
+
};
|
|
322
|
+
await self.routeNotification(options, extras, envContext);
|
|
323
|
+
},
|
|
239
324
|
logger: createLogger(`plugin:${plugin.name}`)
|
|
240
325
|
};
|
|
241
326
|
}
|
|
242
327
|
}
|
|
243
328
|
|
|
244
|
-
export { PluginComponent };
|
|
329
|
+
export { EventBusNotificationChannel, PluginComponent };
|