@ai-setting/roy-agent-core 1.5.58 → 1.5.59
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 +2 -2
- package/dist/env/index.js +7 -7
- package/dist/env/llm/index.js +2 -2
- package/dist/env/task/delegate/index.js +1 -1
- package/dist/env/task/index.js +2 -2
- package/dist/env/task/plugins/index.js +1 -1
- package/dist/index.js +8 -8
- package/dist/shared/@ai-setting/{roy-agent-core-skaha0yj.js → roy-agent-core-1pfxbpp2.js} +14 -2
- package/dist/shared/@ai-setting/{roy-agent-core-0hhxwz5f.js → roy-agent-core-dkevkmas.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-6ph5va4n.js → roy-agent-core-hg3q4f82.js} +19 -9
- package/dist/shared/@ai-setting/{roy-agent-core-65yjzwv5.js → roy-agent-core-nd3amf4x.js} +5 -2
- package/dist/shared/@ai-setting/{roy-agent-core-6s3vec2y.js → roy-agent-core-qqhbxq56.js} +72 -5
- package/dist/shared/@ai-setting/{roy-agent-core-zkwe508t.js → roy-agent-core-s2zz85a9.js} +19 -2
- package/dist/shared/@ai-setting/{roy-agent-core-5c2mfq1q.js → roy-agent-core-t3367jkk.js} +2 -0
- package/dist/shared/@ai-setting/{roy-agent-core-sfqx98j6.js → roy-agent-core-xztzw1yb.js} +1 -1
- package/package.json +1 -1
package/dist/env/agent/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AgentComponent,
|
|
3
3
|
AgentComponentConfigSchema
|
|
4
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
5
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
4
|
+
} from "../../shared/@ai-setting/roy-agent-core-hg3q4f82.js";
|
|
5
|
+
import"../../shared/@ai-setting/roy-agent-core-nd3amf4x.js";
|
|
6
6
|
import"../../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
7
7
|
import"../../shared/@ai-setting/roy-agent-core-nx3c3ce2.js";
|
|
8
8
|
import"../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
builtInHandlers,
|
|
5
5
|
getBuiltInHandler,
|
|
6
6
|
larkCliHandler
|
|
7
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
7
|
+
} from "../../shared/@ai-setting/roy-agent-core-s2zz85a9.js";
|
|
8
8
|
import {
|
|
9
9
|
BUILT_IN_EVENT_SOURCE_TYPES,
|
|
10
10
|
BUILT_IN_EVENT_SOURCE_TYPE_LIST,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
validateEventSourceConfig
|
|
16
16
|
} from "../../shared/@ai-setting/roy-agent-core-xb4hvk1m.js";
|
|
17
17
|
import"../../shared/@ai-setting/roy-agent-core-v8xa6vs8.js";
|
|
18
|
-
import"../../shared/@ai-setting/roy-agent-core-
|
|
18
|
+
import"../../shared/@ai-setting/roy-agent-core-qqhbxq56.js";
|
|
19
19
|
import"../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
20
20
|
import"../../shared/@ai-setting/roy-agent-core-92z6t4he.js";
|
|
21
21
|
import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
|
package/dist/env/index.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BaseEnvironment
|
|
3
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
3
|
+
} from "../shared/@ai-setting/roy-agent-core-t3367jkk.js";
|
|
4
4
|
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-s2zz85a9.js";
|
|
9
9
|
import {
|
|
10
10
|
EventSourceInitHooks,
|
|
11
11
|
getDefaultConfigForType,
|
|
@@ -17,7 +17,7 @@ import"../shared/@ai-setting/roy-agent-core-v8xa6vs8.js";
|
|
|
17
17
|
import {
|
|
18
18
|
PluginComponent
|
|
19
19
|
} from "../shared/@ai-setting/roy-agent-core-ap59dpve.js";
|
|
20
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
20
|
+
import"../shared/@ai-setting/roy-agent-core-qqhbxq56.js";
|
|
21
21
|
import"../shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
22
22
|
import {
|
|
23
23
|
WorkflowComponent
|
|
@@ -38,14 +38,14 @@ import"../shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
|
38
38
|
import {
|
|
39
39
|
AgentComponent,
|
|
40
40
|
AgentComponentConfigSchema
|
|
41
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
42
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
41
|
+
} from "../shared/@ai-setting/roy-agent-core-hg3q4f82.js";
|
|
42
|
+
import"../shared/@ai-setting/roy-agent-core-nd3amf4x.js";
|
|
43
43
|
import"../shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
44
44
|
import {
|
|
45
45
|
TaskComponent
|
|
46
|
-
} from "../shared/@ai-setting/roy-agent-core-
|
|
46
|
+
} from "../shared/@ai-setting/roy-agent-core-1pfxbpp2.js";
|
|
47
47
|
import"../shared/@ai-setting/roy-agent-core-8gxth0eh.js";
|
|
48
|
-
import"../shared/@ai-setting/roy-agent-core-
|
|
48
|
+
import"../shared/@ai-setting/roy-agent-core-dkevkmas.js";
|
|
49
49
|
import"../shared/@ai-setting/roy-agent-core-w4f871e2.js";
|
|
50
50
|
import"../shared/@ai-setting/roy-agent-core-nx3c3ce2.js";
|
|
51
51
|
import {
|
package/dist/env/llm/index.js
CHANGED
|
@@ -8,13 +8,13 @@ import {
|
|
|
8
8
|
ProviderCapabilitiesSchema,
|
|
9
9
|
ProviderConfigSchema,
|
|
10
10
|
ProviderManager
|
|
11
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
11
|
+
} from "../../shared/@ai-setting/roy-agent-core-xztzw1yb.js";
|
|
12
12
|
import {
|
|
13
13
|
createInvokeConfig,
|
|
14
14
|
invoke,
|
|
15
15
|
invokeNonStream,
|
|
16
16
|
parseModelString
|
|
17
|
-
} from "../../shared/@ai-setting/roy-agent-core-
|
|
17
|
+
} from "../../shared/@ai-setting/roy-agent-core-nd3amf4x.js";
|
|
18
18
|
import"../../shared/@ai-setting/roy-agent-core-ctdhjv68.js";
|
|
19
19
|
import"../../shared/@ai-setting/roy-agent-core-qxhq8ven.js";
|
|
20
20
|
import"../../shared/@ai-setting/roy-agent-core-rgckng3p.js";
|
|
@@ -3,7 +3,7 @@ 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-dkevkmas.js";
|
|
7
7
|
import"../../../shared/@ai-setting/roy-agent-core-nx3c3ce2.js";
|
|
8
8
|
import"../../../shared/@ai-setting/roy-agent-core-qxnbvgwe.js";
|
|
9
9
|
import"../../../shared/@ai-setting/roy-agent-core-92z6t4he.js";
|
package/dist/env/task/index.js
CHANGED
|
@@ -5,11 +5,11 @@ 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-1pfxbpp2.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-dkevkmas.js";
|
|
13
13
|
import {
|
|
14
14
|
SQLiteTaskStore,
|
|
15
15
|
getDefaultTaskDbPath
|
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
formatExtractorInput,
|
|
9
9
|
formatExtractorInputFromDescription,
|
|
10
10
|
parseExtractorOutput
|
|
11
|
-
} from "../../../shared/@ai-setting/roy-agent-core-
|
|
11
|
+
} from "../../../shared/@ai-setting/roy-agent-core-qqhbxq56.js";
|
|
12
12
|
import"../../../shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
13
13
|
import"../../../shared/@ai-setting/roy-agent-core-92z6t4he.js";
|
|
14
14
|
import"../../../shared/@ai-setting/roy-agent-core-qg4rma4c.js";
|
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import {
|
|
|
11
11
|
ModelLimitsSchema,
|
|
12
12
|
ProviderCapabilitiesSchema,
|
|
13
13
|
ProviderConfigSchema
|
|
14
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
14
|
+
} from "./shared/@ai-setting/roy-agent-core-xztzw1yb.js";
|
|
15
15
|
import {
|
|
16
16
|
ConfigComponent
|
|
17
17
|
} from "./shared/@ai-setting/roy-agent-core-prdngx28.js";
|
|
@@ -57,13 +57,13 @@ import {
|
|
|
57
57
|
BaseEnvironment,
|
|
58
58
|
generateDescendingId,
|
|
59
59
|
generateId
|
|
60
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
60
|
+
} from "./shared/@ai-setting/roy-agent-core-t3367jkk.js";
|
|
61
61
|
import {
|
|
62
62
|
EventSourceComponent,
|
|
63
63
|
builtInHandlers,
|
|
64
64
|
getBuiltInHandler,
|
|
65
65
|
larkCliHandler
|
|
66
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
66
|
+
} from "./shared/@ai-setting/roy-agent-core-s2zz85a9.js";
|
|
67
67
|
import {
|
|
68
68
|
BUILT_IN_EVENT_SOURCE_TYPES,
|
|
69
69
|
BUILT_IN_EVENT_SOURCE_TYPE_LIST,
|
|
@@ -82,7 +82,7 @@ import {
|
|
|
82
82
|
} from "./shared/@ai-setting/roy-agent-core-ap59dpve.js";
|
|
83
83
|
import {
|
|
84
84
|
TaskTagPlugin
|
|
85
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
85
|
+
} from "./shared/@ai-setting/roy-agent-core-qqhbxq56.js";
|
|
86
86
|
import {
|
|
87
87
|
BasePlugin
|
|
88
88
|
} from "./shared/@ai-setting/roy-agent-core-az13yzmc.js";
|
|
@@ -114,22 +114,22 @@ import"./shared/@ai-setting/roy-agent-core-1ce3fqrk.js";
|
|
|
114
114
|
import {
|
|
115
115
|
AgentComponent,
|
|
116
116
|
AgentComponentConfigSchema
|
|
117
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
117
|
+
} from "./shared/@ai-setting/roy-agent-core-hg3q4f82.js";
|
|
118
118
|
import {
|
|
119
119
|
createInvokeConfig,
|
|
120
120
|
invoke,
|
|
121
121
|
invokeNonStream,
|
|
122
122
|
parseModelString
|
|
123
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
123
|
+
} from "./shared/@ai-setting/roy-agent-core-nd3amf4x.js";
|
|
124
124
|
import {
|
|
125
125
|
AskUserError,
|
|
126
126
|
init_workflow_hil
|
|
127
127
|
} from "./shared/@ai-setting/roy-agent-core-e25xkv53.js";
|
|
128
128
|
import {
|
|
129
129
|
TaskComponent
|
|
130
|
-
} from "./shared/@ai-setting/roy-agent-core-
|
|
130
|
+
} from "./shared/@ai-setting/roy-agent-core-1pfxbpp2.js";
|
|
131
131
|
import"./shared/@ai-setting/roy-agent-core-8gxth0eh.js";
|
|
132
|
-
import"./shared/@ai-setting/roy-agent-core-
|
|
132
|
+
import"./shared/@ai-setting/roy-agent-core-dkevkmas.js";
|
|
133
133
|
import {
|
|
134
134
|
SQLiteTaskStore,
|
|
135
135
|
getDefaultTaskDbPath
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
BackgroundTaskManager,
|
|
6
6
|
createDelegateTool,
|
|
7
7
|
createStopTool
|
|
8
|
-
} from "./roy-agent-core-
|
|
8
|
+
} from "./roy-agent-core-dkevkmas.js";
|
|
9
9
|
import {
|
|
10
10
|
SQLiteTaskStore,
|
|
11
11
|
getDefaultTaskDbPath
|
|
@@ -348,7 +348,7 @@ class TaskComponent extends BaseComponent {
|
|
|
348
348
|
phase: hookPoint.includes("before") ? "before" : "after",
|
|
349
349
|
hookPoint
|
|
350
350
|
};
|
|
351
|
-
await globalHookManager.execute(hookPoint,
|
|
351
|
+
await globalHookManager.execute(hookPoint, data, metadata);
|
|
352
352
|
}
|
|
353
353
|
async createTask(options) {
|
|
354
354
|
const sessionId = options.sessionId;
|
|
@@ -500,6 +500,18 @@ class TaskComponent extends BaseComponent {
|
|
|
500
500
|
__legacyDecorateClassTS([
|
|
501
501
|
TracedAs("task.component.executeHook", { recordParams: true })
|
|
502
502
|
], TaskComponent.prototype, "executeHook", null);
|
|
503
|
+
__legacyDecorateClassTS([
|
|
504
|
+
TracedAs("task.component.createTask", { recordParams: true, recordResult: true, log: true })
|
|
505
|
+
], TaskComponent.prototype, "createTask", null);
|
|
506
|
+
__legacyDecorateClassTS([
|
|
507
|
+
TracedAs("task.component.updateTask", { recordParams: true, recordResult: true, log: true })
|
|
508
|
+
], TaskComponent.prototype, "updateTask", null);
|
|
509
|
+
__legacyDecorateClassTS([
|
|
510
|
+
TracedAs("task.component.completeTask", { recordParams: true, recordResult: true, log: true })
|
|
511
|
+
], TaskComponent.prototype, "completeTask", null);
|
|
512
|
+
__legacyDecorateClassTS([
|
|
513
|
+
TracedAs("task.component.createOperation", { recordParams: true, recordResult: true, log: true })
|
|
514
|
+
], TaskComponent.prototype, "createOperation", null);
|
|
503
515
|
// src/env/task/types.ts
|
|
504
516
|
import { z } from "zod";
|
|
505
517
|
var TaskStatusEnum = z.enum(["todo", "active", "completed", "paused", "cancelled"]);
|
|
@@ -642,7 +642,7 @@ No need to poll — just wait for the notification and use \`task_get\` with the
|
|
|
642
642
|
phase: "before",
|
|
643
643
|
hookPoint: TaskHookPoints.DELEGATE_BEFORE
|
|
644
644
|
};
|
|
645
|
-
await globalHookManager.execute(TaskHookPoints.DELEGATE_BEFORE,
|
|
645
|
+
await globalHookManager.execute(TaskHookPoints.DELEGATE_BEFORE, delegateCtx, { sessionId: parentSessionId });
|
|
646
646
|
promptWithTaskInfo = delegateCtx.prompt;
|
|
647
647
|
return await handleBackgroundTask(backgroundTaskManager, parentSessionId, description, promptWithTaskInfo, delegateCtx.subagentType, delegateCtx.timeout);
|
|
648
648
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
withTimeout
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-nd3amf4x.js";
|
|
4
4
|
import {
|
|
5
5
|
AskUserError,
|
|
6
6
|
init_workflow_hil
|
|
@@ -575,14 +575,14 @@ class AgentComponent extends BaseComponent {
|
|
|
575
575
|
agentContext: parentEnvContext?.agentContext ?? {},
|
|
576
576
|
traceId: effectiveContext.metadata?.traceId,
|
|
577
577
|
sessionId: effectiveContext.sessionId,
|
|
578
|
-
userId: effectiveContext.metadata?.userId ?? "",
|
|
578
|
+
userId: parentEnvContext?.userId ?? (effectiveContext.metadata?.userId ?? ""),
|
|
579
579
|
messageId: effectiveContext.metadata?.messageId,
|
|
580
|
-
pluginEnabled: effectiveContext.pluginEnabled,
|
|
580
|
+
pluginEnabled: { ...parentEnvContext?.pluginEnabled ?? {}, ...effectiveContext.pluginEnabled ?? {} },
|
|
581
581
|
plugins: effectiveContext.plugins,
|
|
582
|
-
envEvent: effectiveContext.envEvent,
|
|
583
|
-
replyChannel: effectiveContext.envEvent?.metadata?.replyChannel,
|
|
584
|
-
sourceId: effectiveContext.envEvent?.metadata?.sourceId,
|
|
585
|
-
sourceType: effectiveContext.envEvent?.metadata?.sourceType,
|
|
582
|
+
envEvent: effectiveContext.envEvent ?? parentEnvContext?.envEvent,
|
|
583
|
+
replyChannel: parentEnvContext?.replyChannel ?? effectiveContext.envEvent?.metadata?.replyChannel,
|
|
584
|
+
sourceId: parentEnvContext?.sourceId ?? effectiveContext.envEvent?.metadata?.sourceId,
|
|
585
|
+
sourceType: parentEnvContext?.sourceType ?? effectiveContext.envEvent?.metadata?.sourceType,
|
|
586
586
|
metadata: { ...effectiveContext.metadata }
|
|
587
587
|
};
|
|
588
588
|
return await runWithEnvContextAsync(envContext, async () => {
|
|
@@ -647,9 +647,19 @@ class AgentComponent extends BaseComponent {
|
|
|
647
647
|
break;
|
|
648
648
|
}
|
|
649
649
|
finalText = llmOutput.content;
|
|
650
|
+
const assistantParts = [
|
|
651
|
+
{ type: "text", text: llmOutput.content }
|
|
652
|
+
];
|
|
653
|
+
if (llmOutput.reasoning) {
|
|
654
|
+
assistantParts.push({
|
|
655
|
+
type: "reasoning",
|
|
656
|
+
text: llmOutput.reasoning,
|
|
657
|
+
reasoningType: "core"
|
|
658
|
+
});
|
|
659
|
+
}
|
|
650
660
|
this.pushMessage(hookCtx, {
|
|
651
661
|
role: "assistant",
|
|
652
|
-
content:
|
|
662
|
+
content: assistantParts
|
|
653
663
|
});
|
|
654
664
|
break;
|
|
655
665
|
}
|
|
@@ -1030,7 +1040,7 @@ ${additionInfo}`
|
|
|
1030
1040
|
},
|
|
1031
1041
|
abortSignal: ctx.context.abort
|
|
1032
1042
|
});
|
|
1033
|
-
const result = await withTimeout(llmPromise,
|
|
1043
|
+
const result = await withTimeout(llmPromise, 300000, "LLM invocation timeout after 300s");
|
|
1034
1044
|
logger.debug("[invokeLLM] LLMComponent.invoke returned successfully");
|
|
1035
1045
|
return {
|
|
1036
1046
|
content: result.output?.content || "",
|
|
@@ -384,6 +384,7 @@ async function invoke(config, options, ctx) {
|
|
|
384
384
|
};
|
|
385
385
|
const result = await streamText(streamTextOptions);
|
|
386
386
|
let fullContent = "";
|
|
387
|
+
let rawFullContent = "";
|
|
387
388
|
let reasoningContent = "";
|
|
388
389
|
const toolCalls = [];
|
|
389
390
|
let usageInfo;
|
|
@@ -405,6 +406,7 @@ async function invoke(config, options, ctx) {
|
|
|
405
406
|
isThinkingTagOpen = thinkingResult.isThinkingTagOpen;
|
|
406
407
|
currentThinkingContent = thinkingResult.currentThinkingContent;
|
|
407
408
|
fullContent += thinkingResult.cleanedText;
|
|
409
|
+
rawFullContent += textDelta;
|
|
408
410
|
for (const reasoningSnapshot of thinkingResult.reasoningEvents) {
|
|
409
411
|
const delta = reasoningSnapshot.slice(reasoningContent.length);
|
|
410
412
|
reasoningContent = reasoningSnapshot;
|
|
@@ -417,6 +419,7 @@ async function invoke(config, options, ctx) {
|
|
|
417
419
|
}
|
|
418
420
|
} else {
|
|
419
421
|
fullContent += textDelta;
|
|
422
|
+
rawFullContent += textDelta;
|
|
420
423
|
if (emitToEnv) {
|
|
421
424
|
emitToEnv({ type: "text", content: fullContent, delta: textDelta });
|
|
422
425
|
}
|
|
@@ -477,7 +480,7 @@ async function invoke(config, options, ctx) {
|
|
|
477
480
|
return {
|
|
478
481
|
toolCallId: firstToolCall.id,
|
|
479
482
|
result: JSON.stringify({
|
|
480
|
-
content:
|
|
483
|
+
content: rawFullContent,
|
|
481
484
|
reasoning: reasoningContent || undefined,
|
|
482
485
|
tool_calls: toolCalls.map((tc) => ({
|
|
483
486
|
id: tc.id,
|
|
@@ -492,7 +495,7 @@ async function invoke(config, options, ctx) {
|
|
|
492
495
|
return {
|
|
493
496
|
toolCallId: "invoke-" + Date.now(),
|
|
494
497
|
result: JSON.stringify({
|
|
495
|
-
content:
|
|
498
|
+
content: rawFullContent,
|
|
496
499
|
reasoning: reasoningContent || undefined,
|
|
497
500
|
usage: usageInfo,
|
|
498
501
|
model
|
|
@@ -402,6 +402,7 @@ var NotifyType;
|
|
|
402
402
|
NotifyType2["TASK_COMPLETED"] = "task_completed";
|
|
403
403
|
NotifyType2["TASK_UPDATED"] = "task_updated";
|
|
404
404
|
NotifyType2["TASK_FAILED"] = "task_failed";
|
|
405
|
+
NotifyType2["OPERATION_CREATED"] = "operation_created";
|
|
405
406
|
})(NotifyType ||= {});
|
|
406
407
|
|
|
407
408
|
class LarkCliTaskNotifyHook {
|
|
@@ -411,6 +412,7 @@ class LarkCliTaskNotifyHook {
|
|
|
411
412
|
pluginName;
|
|
412
413
|
sourceId;
|
|
413
414
|
config;
|
|
415
|
+
lastNotifyTimestamps = new Map;
|
|
414
416
|
constructor(config = {}) {
|
|
415
417
|
this.name = config.pluginName || "LarkCliTaskNotifyHook";
|
|
416
418
|
this.priority = config.priority ?? 5;
|
|
@@ -420,7 +422,12 @@ class LarkCliTaskNotifyHook {
|
|
|
420
422
|
this.config = {
|
|
421
423
|
enabled: true,
|
|
422
424
|
priority: 5,
|
|
423
|
-
notifyTypes: [
|
|
425
|
+
notifyTypes: [
|
|
426
|
+
"task_created" /* TASK_CREATED */,
|
|
427
|
+
"task_updated" /* TASK_UPDATED */,
|
|
428
|
+
"task_completed" /* TASK_COMPLETED */,
|
|
429
|
+
"operation_created" /* OPERATION_CREATED */
|
|
430
|
+
],
|
|
424
431
|
...config
|
|
425
432
|
};
|
|
426
433
|
}
|
|
@@ -443,6 +450,9 @@ class LarkCliTaskNotifyHook {
|
|
|
443
450
|
case TaskHookPoints.AFTER_UPDATE:
|
|
444
451
|
await this.onAfterUpdate(ctx);
|
|
445
452
|
break;
|
|
453
|
+
case TaskHookPoints.OPERATION_AFTER_CREATE:
|
|
454
|
+
await this.onAfterOperationCreate(ctx);
|
|
455
|
+
break;
|
|
446
456
|
}
|
|
447
457
|
}
|
|
448
458
|
async onAfterCreate(ctx) {
|
|
@@ -456,12 +466,11 @@ class LarkCliTaskNotifyHook {
|
|
|
456
466
|
});
|
|
457
467
|
}
|
|
458
468
|
async onAfterUpdate(ctx) {
|
|
459
|
-
const
|
|
460
|
-
|
|
461
|
-
if (!innerData) {
|
|
469
|
+
const data = ctx.data;
|
|
470
|
+
if (!data) {
|
|
462
471
|
return;
|
|
463
472
|
}
|
|
464
|
-
const { task, changes } =
|
|
473
|
+
const { task, changes } = data;
|
|
465
474
|
if (!task) {
|
|
466
475
|
return;
|
|
467
476
|
}
|
|
@@ -489,6 +498,25 @@ class LarkCliTaskNotifyHook {
|
|
|
489
498
|
_hookContext: ctx
|
|
490
499
|
});
|
|
491
500
|
}
|
|
501
|
+
async onAfterOperationCreate(ctx) {
|
|
502
|
+
const { operation } = ctx.data;
|
|
503
|
+
if (!operation) {
|
|
504
|
+
logger2.debug("onAfterOperationCreate: operation is missing, skip");
|
|
505
|
+
return;
|
|
506
|
+
}
|
|
507
|
+
if (!this.shouldNotify("operation_created" /* OPERATION_CREATED */)) {
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
if (this.shouldThrottleOperation(operation)) {
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
await this.sendNotify({
|
|
514
|
+
type: "operation_created" /* OPERATION_CREATED */,
|
|
515
|
+
title: this.getNotifyTitle("operation_created" /* OPERATION_CREATED */),
|
|
516
|
+
content: this.formatOperationCreated(operation),
|
|
517
|
+
_hookContext: ctx
|
|
518
|
+
});
|
|
519
|
+
}
|
|
492
520
|
async sendNotify(options) {
|
|
493
521
|
const { type, title, content, _hookContext } = options;
|
|
494
522
|
const env = getEnvContextOrEmpty();
|
|
@@ -594,6 +622,8 @@ ${content}`;
|
|
|
594
622
|
return "\uD83D\uDCCB 任务已更新";
|
|
595
623
|
case "task_failed" /* TASK_FAILED */:
|
|
596
624
|
return "❌ 任务执行失败";
|
|
625
|
+
case "operation_created" /* OPERATION_CREATED */:
|
|
626
|
+
return "\uD83D\uDCCC 操作记录";
|
|
597
627
|
default:
|
|
598
628
|
return "\uD83D\uDCEC 任务通知";
|
|
599
629
|
}
|
|
@@ -633,6 +663,43 @@ ${content}`;
|
|
|
633
663
|
lines.push(`- **变更**: ${changeKeys.join(", ")}`);
|
|
634
664
|
}
|
|
635
665
|
return lines.join(`
|
|
666
|
+
`);
|
|
667
|
+
}
|
|
668
|
+
shouldThrottleOperation(operation) {
|
|
669
|
+
const throttleMs = this.config.operationThrottleMs ?? 5000;
|
|
670
|
+
if (throttleMs <= 0) {
|
|
671
|
+
return false;
|
|
672
|
+
}
|
|
673
|
+
const key = `op:${operation.taskId}`;
|
|
674
|
+
const now = Date.now();
|
|
675
|
+
const lastTime = this.lastNotifyTimestamps.get(key);
|
|
676
|
+
if (lastTime && now - lastTime < throttleMs) {
|
|
677
|
+
logger2.debug(`[throttle] Skipping OPERATION_CREATED notify for task #${operation.taskId}, last notified ${now - lastTime}ms ago`);
|
|
678
|
+
return true;
|
|
679
|
+
}
|
|
680
|
+
this.lastNotifyTimestamps.set(key, now);
|
|
681
|
+
return false;
|
|
682
|
+
}
|
|
683
|
+
formatOperationCreated(operation) {
|
|
684
|
+
const lines = [];
|
|
685
|
+
if (operation.taskId !== undefined && operation.taskId !== null) {
|
|
686
|
+
lines.push(`- **任务 ID**: #${operation.taskId}`);
|
|
687
|
+
}
|
|
688
|
+
if (operation.actionType) {
|
|
689
|
+
lines.push(`- **操作类型**: ${operation.actionType}`);
|
|
690
|
+
}
|
|
691
|
+
if (operation.actionTitle) {
|
|
692
|
+
lines.push(`- **标题**: ${operation.actionTitle}`);
|
|
693
|
+
}
|
|
694
|
+
if (operation.actionDescription) {
|
|
695
|
+
const desc = String(operation.actionDescription);
|
|
696
|
+
const truncated = desc.substring(0, 200) + (desc.length > 200 ? "..." : "");
|
|
697
|
+
lines.push(`- **描述**: ${truncated}`);
|
|
698
|
+
}
|
|
699
|
+
if (operation.sessionId) {
|
|
700
|
+
lines.push(`- **Session**: \`${operation.sessionId}\``);
|
|
701
|
+
}
|
|
702
|
+
return lines.join(`
|
|
636
703
|
`);
|
|
637
704
|
}
|
|
638
705
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TaskTagPlugin,
|
|
3
3
|
createLarkCliTaskNotifyHook
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-qqhbxq56.js";
|
|
5
5
|
import {
|
|
6
6
|
envKeyToConfigKey
|
|
7
7
|
} from "./roy-agent-core-qxhq8ven.js";
|
|
@@ -19,6 +19,9 @@ import {
|
|
|
19
19
|
createEnvContext,
|
|
20
20
|
runWithEnvContext
|
|
21
21
|
} from "./roy-agent-core-y5d04fm3.js";
|
|
22
|
+
import {
|
|
23
|
+
TracedAs
|
|
24
|
+
} from "./roy-agent-core-k05v31rc.js";
|
|
22
25
|
import {
|
|
23
26
|
createLogger,
|
|
24
27
|
init_logger
|
|
@@ -27,6 +30,7 @@ import {
|
|
|
27
30
|
getTracerProvider
|
|
28
31
|
} from "./roy-agent-core-7z9b1fm8.js";
|
|
29
32
|
import {
|
|
33
|
+
__legacyDecorateClassTS,
|
|
30
34
|
__require
|
|
31
35
|
} from "./roy-agent-core-fs0mn2jk.js";
|
|
32
36
|
|
|
@@ -223,7 +227,11 @@ class LarkCliInstance {
|
|
|
223
227
|
return [plugin.hookPoint];
|
|
224
228
|
}
|
|
225
229
|
if (plugin.name && typeof plugin.execute === "function") {
|
|
226
|
-
return [
|
|
230
|
+
return [
|
|
231
|
+
"task:after.create",
|
|
232
|
+
"task:after.update",
|
|
233
|
+
"task:operation:after.create"
|
|
234
|
+
];
|
|
227
235
|
}
|
|
228
236
|
return [];
|
|
229
237
|
}
|
|
@@ -510,6 +518,15 @@ class LarkCliInstance {
|
|
|
510
518
|
});
|
|
511
519
|
}
|
|
512
520
|
}
|
|
521
|
+
__legacyDecorateClassTS([
|
|
522
|
+
TracedAs("lark-cli.loadPlugins", { recordParams: true, log: true })
|
|
523
|
+
], LarkCliInstance.prototype, "loadPlugins", null);
|
|
524
|
+
__legacyDecorateClassTS([
|
|
525
|
+
TracedAs("lark-cli.registerPluginHooks", { recordParams: true, log: true })
|
|
526
|
+
], LarkCliInstance.prototype, "registerPluginHooks", null);
|
|
527
|
+
__legacyDecorateClassTS([
|
|
528
|
+
TracedAs("lark-cli.handleEvent", { recordParams: true, log: true })
|
|
529
|
+
], LarkCliInstance.prototype, "handleEvent", null);
|
|
513
530
|
var larkCliHandler = {
|
|
514
531
|
type: "lark-cli",
|
|
515
532
|
validateConfig(config) {
|
|
@@ -98,6 +98,8 @@ class BaseEnvironment extends BaseComponent {
|
|
|
98
98
|
envEvent: context || { type: "workflow" },
|
|
99
99
|
sourceId: "workflow",
|
|
100
100
|
userId: context?.metadata?.userId || "",
|
|
101
|
+
replyChannel: existingCtx?.replyChannel,
|
|
102
|
+
pluginEnabled: existingCtx?.pluginEnabled,
|
|
101
103
|
agentContext: existingCtx?.agentContext ?? {}
|
|
102
104
|
};
|
|
103
105
|
return await runWithEnvContextAsync(workflowEnvContext, async () => {
|