@ai-setting/roy-agent-core 1.7.50 → 1.7.52
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/event-source/index.js +6 -6
- package/dist/env/index.js +11 -11
- package/dist/env/prompt/index.js +2 -2
- package/dist/env/task/delegate/index.js +2 -2
- package/dist/env/task/index.js +3 -3
- package/dist/env/task/plugins/index.js +4 -4
- 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/utils/index.js +21 -1
- package/dist/index.js +12 -12
- package/dist/shared/@ai-setting/{roy-agent-core-rpwn590p.js → roy-agent-core-39xejr39.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-wxsgay02.js → roy-agent-core-brwzs8wf.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-rpnjzztt.js → roy-agent-core-ezgsem94.js} +566 -78
- package/dist/shared/@ai-setting/{roy-agent-core-cg9f4zch.js → roy-agent-core-gdsqp6j8.js} +73 -14
- package/dist/shared/@ai-setting/{roy-agent-core-zd077w51.js → roy-agent-core-j8e92gj8.js} +43 -1
- package/dist/shared/@ai-setting/roy-agent-core-na73mym1.js +367 -0
- package/dist/shared/@ai-setting/{roy-agent-core-gpf2059p.js → roy-agent-core-p2r27era.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-s7jpkfm1.js → roy-agent-core-pkpkctvf.js} +47 -16
- package/dist/shared/@ai-setting/{roy-agent-core-avyd65je.js → roy-agent-core-rcfewbzr.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-vy69rpxy.js → roy-agent-core-s214vmmd.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-f28va833.js → roy-agent-core-stnddvx9.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-q9gnnv6v.js → roy-agent-core-vvxb9522.js} +17 -4
- package/package.json +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-q6twb0df.js +0 -35
|
@@ -6,14 +6,14 @@ import {
|
|
|
6
6
|
} from "./roy-agent-core-1pg0fepg.js";
|
|
7
7
|
import {
|
|
8
8
|
WORKFLOW_EXTRACT_PROMPT
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-gdsqp6j8.js";
|
|
10
10
|
import {
|
|
11
11
|
LarkCardPatchNotifier,
|
|
12
12
|
humanizeValue
|
|
13
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-j8e92gj8.js";
|
|
14
14
|
import {
|
|
15
15
|
validateWorkflowDefinition
|
|
16
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-na73mym1.js";
|
|
17
17
|
import {
|
|
18
18
|
enqueueToAddFakeUserMessage
|
|
19
19
|
} from "./roy-agent-core-dv714bqh.js";
|
|
@@ -393,6 +393,17 @@ function extractPerTaskChatId(contextStr) {
|
|
|
393
393
|
return;
|
|
394
394
|
}
|
|
395
395
|
}
|
|
396
|
+
function extractPerTaskChatName(contextStr) {
|
|
397
|
+
if (!contextStr)
|
|
398
|
+
return;
|
|
399
|
+
try {
|
|
400
|
+
const obj = JSON.parse(contextStr);
|
|
401
|
+
const v = obj?.["larkPerTaskChatName"];
|
|
402
|
+
return typeof v === "string" && v.length > 0 ? v : undefined;
|
|
403
|
+
} catch {
|
|
404
|
+
return;
|
|
405
|
+
}
|
|
406
|
+
}
|
|
396
407
|
function extractPerTaskChatProfile(contextStr) {
|
|
397
408
|
if (!contextStr)
|
|
398
409
|
return;
|
|
@@ -507,7 +518,8 @@ function decideCardChatTarget(input) {
|
|
|
507
518
|
lineageChat,
|
|
508
519
|
triggerChatId,
|
|
509
520
|
triggerProfile,
|
|
510
|
-
triggerOwnership
|
|
521
|
+
triggerOwnership,
|
|
522
|
+
allowNewGroup
|
|
511
523
|
} = input;
|
|
512
524
|
const foreign = !!triggerChatId && !!triggerOwnership?.dedicated && triggerOwnership.ownerTaskIds.length > 0 && !triggerOwnership.ownerTaskIds.some((id) => lineageIds.includes(id));
|
|
513
525
|
if (triggerChatId && !foreign) {
|
|
@@ -538,16 +550,25 @@ function decideCardChatTarget(input) {
|
|
|
538
550
|
reason: "既没有触发群也没有 lineage 群(无法决定投递目标)"
|
|
539
551
|
};
|
|
540
552
|
}
|
|
553
|
+
if (allowNewGroup === true) {
|
|
554
|
+
return {
|
|
555
|
+
chatId: undefined,
|
|
556
|
+
source: "new-group",
|
|
557
|
+
profile: triggerProfile,
|
|
558
|
+
reroutedFrom: foreign ? {
|
|
559
|
+
chatId: triggerChatId,
|
|
560
|
+
ownerTaskIds: triggerOwnership.ownerTaskIds,
|
|
561
|
+
sources: triggerOwnership.sources
|
|
562
|
+
} : undefined,
|
|
563
|
+
reason: foreign ? `触发群 ${triggerChatId} 是 task ${triggerOwnership.ownerTaskIds.join(",")} 的专属群,且本 task 无群 → 需要新建(allowNewGroup=true)` : "无触发群且本 task 无群 → 需要新建(allowNewGroup=true)"
|
|
564
|
+
};
|
|
565
|
+
}
|
|
541
566
|
return {
|
|
542
|
-
chatId:
|
|
543
|
-
source: "new-group",
|
|
567
|
+
chatId: triggerChatId,
|
|
544
568
|
profile: triggerProfile,
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
sources: triggerOwnership.sources
|
|
549
|
-
} : undefined,
|
|
550
|
-
reason: foreign ? `触发群 ${triggerChatId} 是 task ${triggerOwnership.ownerTaskIds.join(",")} 的专属群,且本 task 无群 → 需要新建` : "无触发群且本 task 无群 → 需要新建"
|
|
569
|
+
source: "fallback-to-trigger",
|
|
570
|
+
reroutedFrom: undefined,
|
|
571
|
+
reason: foreign ? `触发群 ${triggerChatId} 是 task ${triggerOwnership.ownerTaskIds.join(",")} 的专属群,但默认不建群 → 退回触发群 ${triggerChatId}` : `默认不建群 → 退回触发群 ${triggerChatId}`
|
|
551
572
|
};
|
|
552
573
|
}
|
|
553
574
|
|
|
@@ -777,7 +798,8 @@ class LarkCliTaskNotifyHook {
|
|
|
777
798
|
lineageChat,
|
|
778
799
|
triggerChatId,
|
|
779
800
|
triggerProfile,
|
|
780
|
-
triggerOwnership
|
|
801
|
+
triggerOwnership,
|
|
802
|
+
allowNewGroup: this.config.allowNewGroup === true
|
|
781
803
|
});
|
|
782
804
|
if (decision.source === "new-group") {
|
|
783
805
|
if (this.cardRoutingPorts?.ensureTaskGroupChat) {
|
|
@@ -987,6 +1009,8 @@ class LarkCliTaskNotifyHook {
|
|
|
987
1009
|
return;
|
|
988
1010
|
}
|
|
989
1011
|
buildTaskMeta(task) {
|
|
1012
|
+
const recordedNames = extractRecordedChatNames(task.context);
|
|
1013
|
+
const matchedName = recordedNames.find((n) => new RegExp(`(?:Task\\s*#?\\s*|#)(?<![\\d])(?<!\\d)${task.id}(?!\\d)(?![\\d])`, "i").test(n));
|
|
990
1014
|
return {
|
|
991
1015
|
id: task.id,
|
|
992
1016
|
title: task.title,
|
|
@@ -997,7 +1021,9 @@ class LarkCliTaskNotifyHook {
|
|
|
997
1021
|
type: task.type,
|
|
998
1022
|
projectPath: task.project_path,
|
|
999
1023
|
context: task.context,
|
|
1000
|
-
currentStatus: task.current_status
|
|
1024
|
+
currentStatus: task.current_status,
|
|
1025
|
+
perTaskChatId: extractPerTaskChatId(task.context),
|
|
1026
|
+
perTaskChatName: matchedName
|
|
1001
1027
|
};
|
|
1002
1028
|
}
|
|
1003
1029
|
deriveTimelineFromOperation(operation) {
|
|
@@ -1119,6 +1145,7 @@ class PerTaskGroupChatPlugin {
|
|
|
1119
1145
|
sendWelcomeMessage: config.sendWelcomeMessage ?? true,
|
|
1120
1146
|
resolveToTriggerChatFallback: config.resolveToTriggerChatFallback ?? false,
|
|
1121
1147
|
cardInitialMessage: config.cardInitialMessage !== false,
|
|
1148
|
+
autoCreateGroup: config.autoCreateGroup === true,
|
|
1122
1149
|
cardNotifier: config.cardNotifier ?? new LarkCardPatchNotifier
|
|
1123
1150
|
};
|
|
1124
1151
|
this.cardNotifier = this.config.cardNotifier;
|
|
@@ -1263,7 +1290,11 @@ class PerTaskGroupChatPlugin {
|
|
|
1263
1290
|
console.error(`[DEBUG per-task-group-chat.onAfterCreate] env.messageId=${env.messageId}`);
|
|
1264
1291
|
console.error(`[DEBUG per-task-group-chat.onAfterCreate] env.sourceId=${env.sourceId}`);
|
|
1265
1292
|
}
|
|
1266
|
-
logger4.debug(`onAfterCreate[${this.pluginName}]: enter task=${task.id} "${task.title}" ` + `parent_task_id=${task.parent_task_id ?? "none"} ` + `requireReplyChannel=${this.config.requireReplyChannel} ` + `disableSubTaskSkip=${this.config.disableSubTaskSkip} ` + `sendWelcomeMessage=${this.config.sendWelcomeMessage}`);
|
|
1293
|
+
logger4.debug(`onAfterCreate[${this.pluginName}]: enter task=${task.id} "${task.title}" ` + `parent_task_id=${task.parent_task_id ?? "none"} ` + `requireReplyChannel=${this.config.requireReplyChannel} ` + `disableSubTaskSkip=${this.config.disableSubTaskSkip} ` + `sendWelcomeMessage=${this.config.sendWelcomeMessage} ` + `autoCreateGroup=${this.config.autoCreateGroup}`);
|
|
1294
|
+
if (!this.config.autoCreateGroup) {
|
|
1295
|
+
logger4.debug(`onAfterCreate[${this.pluginName}]: task #${task.id} autoCreateGroup=false ` + `→ skip group chat creation(按需建群:用户在卡片顶部按钮触发)`);
|
|
1296
|
+
return;
|
|
1297
|
+
}
|
|
1267
1298
|
const replyChannel = this.getReplyChannelFromCtx(ctx);
|
|
1268
1299
|
if (!replyChannel?.chatId && this.config.requireReplyChannel) {
|
|
1269
1300
|
logger4.debug(`onAfterCreate[${this.pluginName}]: no replyChannel.chatId for task #${task.id}, skip. ` + `修复:eventsource 收到 im.message.receive_v1 事件时 replyChannel 应有值;` + `或在 plugin config 设 requireReplyChannel=false 强制创建群聊(profile 降级到 fallbackProfile/无)`);
|
|
@@ -1714,4 +1745,4 @@ __legacyDecorateClassTS([
|
|
|
1714
1745
|
function createPerTaskGroupChatPlugin(config = {}) {
|
|
1715
1746
|
return new PerTaskGroupChatPlugin(config);
|
|
1716
1747
|
}
|
|
1717
|
-
export { createAutoTaskPlugin, WORKFLOW_EXTRACTOR_PROMPT, formatExtractorInput, formatExtractorInputFromDescription, parseExtractorOutput, TaskTagPlugin, mergeChatOwnership, NotifyType, LarkCliTaskNotifyHook, createLarkCliTaskNotifyHook, PerTaskGroupChatPlugin, createPerTaskGroupChatPlugin };
|
|
1748
|
+
export { createAutoTaskPlugin, WORKFLOW_EXTRACTOR_PROMPT, formatExtractorInput, formatExtractorInputFromDescription, parseExtractorOutput, TaskTagPlugin, extractPerTaskChatId, extractPerTaskChatName, mergeChatOwnership, NotifyType, LarkCliTaskNotifyHook, createLarkCliTaskNotifyHook, PerTaskGroupChatPlugin, createPerTaskGroupChatPlugin };
|
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
} from "./roy-agent-core-7evvpfwc.js";
|
|
8
8
|
import {
|
|
9
9
|
validateWorkflowDefinition
|
|
10
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-na73mym1.js";
|
|
11
11
|
import {
|
|
12
12
|
getCurrentBgTaskId
|
|
13
13
|
} from "./roy-agent-core-c1v263jn.js";
|
|
@@ -485,7 +485,7 @@ var WorkflowValidateInputSchema = z6.object({
|
|
|
485
485
|
function createWorkflowValidateTool(_workflowService) {
|
|
486
486
|
return {
|
|
487
487
|
name: "workflow_validate",
|
|
488
|
-
description: `Validate a workflow definition (YAML or JSON) without persisting it. ` + `Checks
|
|
488
|
+
description: `Validate a workflow definition (YAML or JSON) without persisting it. ` + `Checks (1) DAG structure: duplicate node IDs, missing dependencies, cycles, empty node IDs; ` + `(2) template-reference contracts: whether {{nodes.X.<field>}} matches node X's output shape ` + `(e.g. {{nodes.<toolNode>.result}} is an ERROR — tool nodes expose ".output", not ".result"). ` + `Returns { valid, errors: string[], warnings?: string[], infos?: string[], workflowName?, ` + `nodeCount, errorCount, warningCount }. ` + `Use this BEFORE workflow_add; fix EVERY error (and evaluate each warning) before registering.`,
|
|
489
489
|
parameters: WorkflowValidateInputSchema,
|
|
490
490
|
execute: async (args, _ctx) => {
|
|
491
491
|
try {
|
|
@@ -524,16 +524,29 @@ function createWorkflowValidateTool(_workflowService) {
|
|
|
524
524
|
}
|
|
525
525
|
const result = validateWorkflowDefinition(definition);
|
|
526
526
|
const nodeCount = Array.isArray(definition.nodes) ? definition.nodes.length : 0;
|
|
527
|
+
const warnings = result.warnings ?? [];
|
|
528
|
+
const infos = result.infos ?? [];
|
|
527
529
|
const output = {
|
|
528
530
|
valid: result.valid,
|
|
529
531
|
errors: result.errors,
|
|
532
|
+
warnings,
|
|
533
|
+
infos,
|
|
530
534
|
workflowName: definition.name,
|
|
531
|
-
nodeCount
|
|
535
|
+
nodeCount,
|
|
536
|
+
errorCount: result.errors.length,
|
|
537
|
+
warningCount: warnings.length
|
|
532
538
|
};
|
|
539
|
+
const errorText = result.valid ? undefined : `Validation failed (${result.errors.length} error(s)):
|
|
540
|
+
` + result.errors.map((e, i) => ` ${i + 1}. ${e}`).join(`
|
|
541
|
+
`) + (warnings.length > 0 ? `
|
|
542
|
+
|
|
543
|
+
Advisory warnings (${warnings.length}) — evaluate and fix where sensible:
|
|
544
|
+
` + warnings.map((w, i) => ` - ${w}`).join(`
|
|
545
|
+
`) : "");
|
|
533
546
|
return {
|
|
534
547
|
success: result.valid,
|
|
535
548
|
output: JSON.stringify(output, null, 2),
|
|
536
|
-
error:
|
|
549
|
+
error: errorText,
|
|
537
550
|
metadata: { execution_time_ms: 0 }
|
|
538
551
|
};
|
|
539
552
|
} catch (error) {
|
package/package.json
CHANGED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DAGManager,
|
|
3
|
-
init_dag_manager
|
|
4
|
-
} from "./roy-agent-core-8s9jd2qy.js";
|
|
5
|
-
|
|
6
|
-
// src/env/workflow/utils/validate-workflow-definition.ts
|
|
7
|
-
init_dag_manager();
|
|
8
|
-
function validateWorkflowDefinition(definition) {
|
|
9
|
-
if (!definition || typeof definition !== "object") {
|
|
10
|
-
return {
|
|
11
|
-
valid: false,
|
|
12
|
-
errors: ["Workflow definition must be an object"]
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
const def = definition;
|
|
16
|
-
if (!Array.isArray(def.nodes)) {
|
|
17
|
-
return {
|
|
18
|
-
valid: false,
|
|
19
|
-
errors: ["Workflow definition must have a 'nodes' array"]
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
try {
|
|
23
|
-
const dag = new DAGManager(definition, { allowCycles: false });
|
|
24
|
-
return dag.validate();
|
|
25
|
-
} catch (error) {
|
|
26
|
-
return {
|
|
27
|
-
valid: false,
|
|
28
|
-
errors: [
|
|
29
|
-
`Validation error: ${error instanceof Error ? error.message : String(error)}`
|
|
30
|
-
]
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export { validateWorkflowDefinition };
|