@ai-setting/roy-agent-core 1.7.53 → 1.7.55
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 +3 -3
- package/dist/env/error-reply.d.ts +184 -0
- package/dist/env/event-source/event-source-handlers.d.ts +9 -23
- package/dist/env/event-source/index.js +6 -6
- package/dist/env/index.js +18 -18
- package/dist/env/llm/adapter-pi-ai.d.ts +147 -2
- package/dist/env/llm/adapter.d.ts +21 -1
- package/dist/env/llm/index.js +2 -2
- package/dist/env/llm/invoke.d.ts +41 -1
- package/dist/env/llm/llm.d.ts +25 -0
- package/dist/env/llm/reasoning-defense.d.ts +104 -0
- package/dist/env/llm/types.d.ts +26 -0
- package/dist/env/prompt/index.js +2 -2
- package/dist/env/prompt/prompts-index.d.ts +1 -1
- package/dist/env/session/index.js +4 -4
- package/dist/env/session/storage/index.js +3 -3
- package/dist/env/task/backend/index.js +0 -2
- package/dist/env/task/backend/types.d.ts +0 -11
- package/dist/env/task/delegate/index.js +2 -2
- package/dist/env/task/index.js +3 -3
- package/dist/env/task/plugins/card-chat-routing.d.ts +42 -89
- package/dist/env/task/plugins/index.js +4 -4
- package/dist/env/task/plugins/lark-card-patch-notifier.d.ts +0 -51
- package/dist/env/task/plugins/lark-cli-task-notify-plugin.d.ts +14 -31
- package/dist/env/task/plugins/per-task-group-chat-plugin.d.ts +4 -4
- package/dist/env/workflow/engine/engine.d.ts +65 -0
- package/dist/env/workflow/engine/index.js +2 -2
- package/dist/env/workflow/index.js +9 -9
- package/dist/env/workflow/nodes/index.js +1 -1
- package/dist/env/workflow/nodes/tool-node.d.ts +6 -0
- package/dist/env/workflow/plugins/index.js +2 -2
- package/dist/env/workflow/tools/index.js +6 -6
- package/dist/env/workflow/tools/workflow-validate-tool.d.ts +11 -2
- package/dist/env/workflow/types/run.d.ts +19 -0
- package/dist/env/workflow/utils/agent-session-metadata.d.ts +13 -0
- package/dist/env/workflow/utils/index.js +1 -1
- package/dist/env/workflow/utils/redact-command-secrets.d.ts +70 -0
- package/dist/env/workflow/utils/shell-dialect-lint.d.ts +75 -0
- package/dist/env/workflow/utils/validate-workflow-definition.d.ts +22 -0
- package/dist/index.js +20 -20
- package/dist/shared/@ai-setting/{roy-agent-core-stnddvx9.js → roy-agent-core-12d2xap8.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-pk1b3kvf.js → roy-agent-core-2b8jtv7m.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-x8n1r7h4.js → roy-agent-core-2bscfrr1.js} +188 -7
- package/dist/shared/@ai-setting/{roy-agent-core-gdsqp6j8.js → roy-agent-core-6masakz4.js} +45 -0
- package/dist/shared/@ai-setting/{roy-agent-core-vvxb9522.js → roy-agent-core-6qxh4xrm.js} +67 -6
- package/dist/shared/@ai-setting/{roy-agent-core-h93v6p6y.js → roy-agent-core-7qy3nffr.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-4vpk40ss.js → roy-agent-core-8eqngasy.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-brwzs8wf.js → roy-agent-core-9h72sk1n.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-na73mym1.js → roy-agent-core-a4vzsn0g.js} +212 -1
- package/dist/shared/@ai-setting/{roy-agent-core-35s1w7tc.js → roy-agent-core-aer5kw1j.js} +142 -70
- package/dist/shared/@ai-setting/{roy-agent-core-j8e92gj8.js → roy-agent-core-b5ew8t0k.js} +0 -59
- package/dist/shared/@ai-setting/{roy-agent-core-4sx6sdb2.js → roy-agent-core-cd62e9p1.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-39xejr39.js → roy-agent-core-e2z1etk4.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-hch2geta.js → roy-agent-core-g36jevrk.js} +14 -183
- package/dist/shared/@ai-setting/{roy-agent-core-ph5qbqcx.js → roy-agent-core-j2nvedt6.js} +465 -128
- package/dist/shared/@ai-setting/{roy-agent-core-p2r27era.js → roy-agent-core-mxdc756a.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-p8ak03s0.js → roy-agent-core-w527pcpe.js} +293 -42
- package/dist/shared/@ai-setting/{roy-agent-core-3tv1q6f2.js → roy-agent-core-ytr2w0vb.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-yd21n6c7.js → roy-agent-core-zvemdfx5.js} +1 -1
- package/dist/test-utils/child-process-mock.d.ts +73 -0
- package/package.json +2 -2
- /package/dist/shared/@ai-setting/{roy-agent-core-zy3hqfwg.js → roy-agent-core-0hq21px2.js} +0 -0
|
@@ -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-6masakz4.js";
|
|
10
10
|
import {
|
|
11
11
|
LarkCardPatchNotifier,
|
|
12
12
|
humanizeValue
|
|
13
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-b5ew8t0k.js";
|
|
14
14
|
import {
|
|
15
15
|
validateWorkflowDefinition
|
|
16
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-a4vzsn0g.js";
|
|
17
17
|
import {
|
|
18
18
|
enqueueToAddFakeUserMessage
|
|
19
19
|
} from "./roy-agent-core-dv714bqh.js";
|
|
@@ -378,9 +378,6 @@ init_logger();
|
|
|
378
378
|
init_context();
|
|
379
379
|
|
|
380
380
|
// src/env/task/plugins/card-chat-routing.ts
|
|
381
|
-
var GROUP_NAME_TASK_ID_RE = /(?:Task\s*#?\s*|#)(\d{1,7})\b/i;
|
|
382
|
-
var DEDICATED_CHAT_ID_FIELD_RE = /^(larkPerTaskChatId|[a-z0-9_]*(followup|group|per_?task)[a-z0-9_]*chat[_]?id)$/i;
|
|
383
|
-
var CONVERSATION_CHAT_ID_FIELD_RE = /^(feishu_chat_id|chat_id|message_?chat_?id)$/i;
|
|
384
381
|
var CTX_FIELD_LARK_PER_TASK_CHAT_ID = "larkPerTaskChatId";
|
|
385
382
|
function extractPerTaskChatId(contextStr) {
|
|
386
383
|
if (!contextStr)
|
|
@@ -431,103 +428,14 @@ function extractRecordedChatNames(contextStr) {
|
|
|
431
428
|
}
|
|
432
429
|
return out;
|
|
433
430
|
}
|
|
434
|
-
function analyzeContextOwnership(contextStr, chatId) {
|
|
435
|
-
const sources = [];
|
|
436
|
-
const impliedTaskIds = [];
|
|
437
|
-
if (!contextStr)
|
|
438
|
-
return { owned: false, sources, impliedTaskIds };
|
|
439
|
-
let obj;
|
|
440
|
-
try {
|
|
441
|
-
const parsed = JSON.parse(contextStr);
|
|
442
|
-
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
443
|
-
obj = parsed;
|
|
444
|
-
}
|
|
445
|
-
} catch {
|
|
446
|
-
obj = undefined;
|
|
447
|
-
}
|
|
448
|
-
if (!obj)
|
|
449
|
-
return { owned: false, sources, impliedTaskIds };
|
|
450
|
-
for (const [k, v] of Object.entries(obj)) {
|
|
451
|
-
if (typeof v !== "string" || v.length === 0)
|
|
452
|
-
continue;
|
|
453
|
-
const isDedicatedField = DEDICATED_CHAT_ID_FIELD_RE.test(k);
|
|
454
|
-
const isConversationField = CONVERSATION_CHAT_ID_FIELD_RE.test(k);
|
|
455
|
-
if (isDedicatedField && !isConversationField && v === chatId) {
|
|
456
|
-
sources.push(k);
|
|
457
|
-
continue;
|
|
458
|
-
}
|
|
459
|
-
if (/chat_?name$/i.test(k)) {
|
|
460
|
-
const m = v.match(GROUP_NAME_TASK_ID_RE);
|
|
461
|
-
if (m) {
|
|
462
|
-
const id = Number(m[1]);
|
|
463
|
-
if (Number.isFinite(id) && id > 0)
|
|
464
|
-
impliedTaskIds.push(id);
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
return { owned: sources.length > 0, sources, impliedTaskIds };
|
|
469
|
-
}
|
|
470
|
-
function mergeChatOwnership(chatId, candidates, extra = {}) {
|
|
471
|
-
const ownerTaskIds = new Set;
|
|
472
|
-
const sources = [];
|
|
473
|
-
let chatName = extra.chatName;
|
|
474
|
-
if (typeof extra.boundTaskId === "number" && extra.boundTaskId > 0) {
|
|
475
|
-
ownerTaskIds.add(extra.boundTaskId);
|
|
476
|
-
sources.push("chat-binding");
|
|
477
|
-
}
|
|
478
|
-
for (const c of candidates) {
|
|
479
|
-
const r = analyzeContextOwnership(c.context, chatId);
|
|
480
|
-
if (r.owned) {
|
|
481
|
-
ownerTaskIds.add(c.id);
|
|
482
|
-
sources.push(`#${c.id}:${r.sources.join("+")}`);
|
|
483
|
-
}
|
|
484
|
-
if (!chatName) {
|
|
485
|
-
const names = extractRecordedChatNames(c.context);
|
|
486
|
-
const matched = names.find((n) => n.includes(chatId) || GROUP_NAME_TASK_ID_RE.test(n));
|
|
487
|
-
if (matched)
|
|
488
|
-
chatName = matched;
|
|
489
|
-
}
|
|
490
|
-
for (const implied of r.impliedTaskIds) {
|
|
491
|
-
if (implied === c.id) {
|
|
492
|
-
ownerTaskIds.add(c.id);
|
|
493
|
-
sources.push(`#${c.id}:chat-name`);
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
if (chatName) {
|
|
498
|
-
const m = chatName.match(GROUP_NAME_TASK_ID_RE);
|
|
499
|
-
if (m) {
|
|
500
|
-
const id = Number(m[1]);
|
|
501
|
-
if (Number.isFinite(id) && id > 0) {
|
|
502
|
-
ownerTaskIds.add(id);
|
|
503
|
-
sources.push("chat-name");
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
return {
|
|
508
|
-
chatId,
|
|
509
|
-
ownerTaskIds: [...ownerTaskIds],
|
|
510
|
-
sources,
|
|
511
|
-
chatName,
|
|
512
|
-
dedicated: ownerTaskIds.size > 0
|
|
513
|
-
};
|
|
514
|
-
}
|
|
515
431
|
function decideCardChatTarget(input) {
|
|
516
|
-
const {
|
|
517
|
-
|
|
518
|
-
lineageChat,
|
|
519
|
-
triggerChatId,
|
|
520
|
-
triggerProfile,
|
|
521
|
-
triggerOwnership,
|
|
522
|
-
allowNewGroup
|
|
523
|
-
} = input;
|
|
524
|
-
const foreign = !!triggerChatId && !!triggerOwnership?.dedicated && triggerOwnership.ownerTaskIds.length > 0 && !triggerOwnership.ownerTaskIds.some((id) => lineageIds.includes(id));
|
|
525
|
-
if (triggerChatId && !foreign) {
|
|
432
|
+
const { lineageChat, triggerChatId, triggerProfile } = input;
|
|
433
|
+
if (triggerChatId) {
|
|
526
434
|
return {
|
|
527
435
|
chatId: triggerChatId,
|
|
528
436
|
profile: triggerProfile,
|
|
529
437
|
source: "trigger-chat",
|
|
530
|
-
reason:
|
|
438
|
+
reason: `触发群 ${triggerChatId} 直接用(Task #4394:卡片只发触发群,不改投)`
|
|
531
439
|
};
|
|
532
440
|
}
|
|
533
441
|
if (lineageChat) {
|
|
@@ -535,40 +443,13 @@ function decideCardChatTarget(input) {
|
|
|
535
443
|
chatId: lineageChat.chatId,
|
|
536
444
|
profile: lineageChat.profile,
|
|
537
445
|
source: lineageChat.isSelf ? "own-group" : "ancestor-group",
|
|
538
|
-
|
|
539
|
-
chatId: triggerChatId,
|
|
540
|
-
ownerTaskIds: triggerOwnership.ownerTaskIds,
|
|
541
|
-
sources: triggerOwnership.sources
|
|
542
|
-
} : undefined,
|
|
543
|
-
reason: foreign ? `触发群 ${triggerChatId} 是 task ${triggerOwnership.ownerTaskIds.join(",")} 的专属群,改投 lineage 群 ${lineageChat.chatId}` : `无触发群,用 lineage 群 ${lineageChat.chatId}`
|
|
544
|
-
};
|
|
545
|
-
}
|
|
546
|
-
if (!triggerChatId) {
|
|
547
|
-
return {
|
|
548
|
-
chatId: undefined,
|
|
549
|
-
source: "none",
|
|
550
|
-
reason: "既没有触发群也没有 lineage 群(无法决定投递目标)"
|
|
551
|
-
};
|
|
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)"
|
|
446
|
+
reason: `无触发群 → 用 ${lineageChat.isSelf ? "本 task" : "祖先"} 专属群 ${lineageChat.chatId} 兜底`
|
|
564
447
|
};
|
|
565
448
|
}
|
|
566
449
|
return {
|
|
567
|
-
chatId:
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
reroutedFrom: undefined,
|
|
571
|
-
reason: foreign ? `触发群 ${triggerChatId} 是 task ${triggerOwnership.ownerTaskIds.join(",")} 的专属群,但默认不建群 → 退回触发群 ${triggerChatId}` : `默认不建群 → 退回触发群 ${triggerChatId}`
|
|
450
|
+
chatId: undefined,
|
|
451
|
+
source: "none",
|
|
452
|
+
reason: "既没有触发群也没有本 task 的群(无法决定投递目标)"
|
|
572
453
|
};
|
|
573
454
|
}
|
|
574
455
|
|
|
@@ -643,7 +524,7 @@ class LarkCliTaskNotifyHook {
|
|
|
643
524
|
}
|
|
644
525
|
setCardRoutingPorts(ports) {
|
|
645
526
|
this.cardRoutingPorts = ports;
|
|
646
|
-
logger3.debug(`CardRoutingPorts injected:
|
|
527
|
+
logger3.debug(`CardRoutingPorts injected: getTask=${typeof ports.getTask}`);
|
|
647
528
|
}
|
|
648
529
|
hasCardRoutingPorts() {
|
|
649
530
|
return this.cardRoutingPorts !== undefined;
|
|
@@ -784,50 +665,13 @@ class LarkCliTaskNotifyHook {
|
|
|
784
665
|
isSelf: true
|
|
785
666
|
};
|
|
786
667
|
}
|
|
787
|
-
|
|
788
|
-
if (triggerChatId && this.cardRoutingPorts?.lookupChatOwnership) {
|
|
789
|
-
try {
|
|
790
|
-
triggerOwnership = await this.cardRoutingPorts.lookupChatOwnership(triggerChatId);
|
|
791
|
-
} catch (err) {
|
|
792
|
-
logger3.warn(`lookupChatOwnership failed for ${triggerChatId} (degrade to trigger chat): ${err.message}`);
|
|
793
|
-
}
|
|
794
|
-
}
|
|
795
|
-
const decision = decideCardChatTarget({
|
|
668
|
+
return decideCardChatTarget({
|
|
796
669
|
taskId: task.id,
|
|
797
670
|
lineageIds,
|
|
798
671
|
lineageChat,
|
|
799
672
|
triggerChatId,
|
|
800
|
-
triggerProfile
|
|
801
|
-
triggerOwnership,
|
|
802
|
-
allowNewGroup: this.config.allowNewGroup === true
|
|
673
|
+
triggerProfile
|
|
803
674
|
});
|
|
804
|
-
if (decision.source === "new-group") {
|
|
805
|
-
if (this.cardRoutingPorts?.ensureTaskGroupChat) {
|
|
806
|
-
try {
|
|
807
|
-
const created = await this.cardRoutingPorts.ensureTaskGroupChat(task);
|
|
808
|
-
if (created?.chatId) {
|
|
809
|
-
return {
|
|
810
|
-
...decision,
|
|
811
|
-
chatId: created.chatId,
|
|
812
|
-
profile: created.profile ?? decision.profile,
|
|
813
|
-
chatName: created.name,
|
|
814
|
-
reason: `${decision.reason};已新建专属群 ${created.chatId}`
|
|
815
|
-
};
|
|
816
|
-
}
|
|
817
|
-
} catch (err) {
|
|
818
|
-
logger3.warn(`ensureTaskGroupChat failed for task #${task.id}: ${err.message}`);
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
return {
|
|
822
|
-
...decision,
|
|
823
|
-
chatId: triggerChatId,
|
|
824
|
-
profile: triggerProfile,
|
|
825
|
-
source: triggerChatId ? "trigger-chat" : "none",
|
|
826
|
-
reroutedFrom: undefined,
|
|
827
|
-
reason: `${decision.reason};但建群失败/不可用 → 退回触发群`
|
|
828
|
-
};
|
|
829
|
-
}
|
|
830
|
-
return decision;
|
|
831
675
|
}
|
|
832
676
|
async collectLineage(task) {
|
|
833
677
|
const out = [
|
|
@@ -887,17 +731,6 @@ class LarkCliTaskNotifyHook {
|
|
|
887
731
|
});
|
|
888
732
|
this.cardMessageIds.set(task.id, messageId);
|
|
889
733
|
logger3.debug(`sendCardStart: task #${task.id} → message ${messageId} (pinned=${pinned}) ` + `chat=${chatId} source=${target.source} reason=${target.reason}`);
|
|
890
|
-
if (target.reroutedFrom) {
|
|
891
|
-
await this.cardNotifier.sendRedirectNotice({
|
|
892
|
-
chatId: target.reroutedFrom.chatId,
|
|
893
|
-
profile: target.profile,
|
|
894
|
-
taskId: task.id,
|
|
895
|
-
taskTitle: task.title,
|
|
896
|
-
targetChatId: chatId,
|
|
897
|
-
targetChatName: target.chatName,
|
|
898
|
-
reason: target.reason
|
|
899
|
-
});
|
|
900
|
-
}
|
|
901
734
|
} catch (err) {
|
|
902
735
|
this.cardMessageIds.set(task.id, LarkCliTaskNotifyHook.CARD_START_FAILED_SENTINEL);
|
|
903
736
|
logger3.error(`sendCardStart failed for task #${task.id}: ${err.message}`);
|
|
@@ -1089,8 +922,6 @@ __legacyDecorateClassTS([
|
|
|
1089
922
|
source: r?.source,
|
|
1090
923
|
chatId: r?.chatId,
|
|
1091
924
|
chatName: r?.chatName,
|
|
1092
|
-
reroutedFrom: r?.reroutedFrom?.chatId,
|
|
1093
|
-
rerouteOwners: r?.reroutedFrom?.ownerTaskIds?.join(","),
|
|
1094
925
|
reason: r?.reason?.slice(0, 200)
|
|
1095
926
|
})
|
|
1096
927
|
})
|
|
@@ -1745,4 +1576,4 @@ __legacyDecorateClassTS([
|
|
|
1745
1576
|
function createPerTaskGroupChatPlugin(config = {}) {
|
|
1746
1577
|
return new PerTaskGroupChatPlugin(config);
|
|
1747
1578
|
}
|
|
1748
|
-
export { createAutoTaskPlugin, WORKFLOW_EXTRACTOR_PROMPT, formatExtractorInput, formatExtractorInputFromDescription, parseExtractorOutput, TaskTagPlugin, extractPerTaskChatId, extractPerTaskChatName,
|
|
1579
|
+
export { createAutoTaskPlugin, WORKFLOW_EXTRACTOR_PROMPT, formatExtractorInput, formatExtractorInputFromDescription, parseExtractorOutput, TaskTagPlugin, extractPerTaskChatId, extractPerTaskChatName, NotifyType, LarkCliTaskNotifyHook, createLarkCliTaskNotifyHook, PerTaskGroupChatPlugin, createPerTaskGroupChatPlugin };
|