@ai-setting/roy-agent-core 1.7.49 → 1.7.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/index.js +7 -7
- package/dist/env/agent/index.js +10 -10
- package/dist/env/commands/index.js +7 -7
- package/dist/env/context/index.js +3 -3
- package/dist/env/debug/index.js +7 -7
- package/dist/env/event-source/index.js +17 -14
- package/dist/env/hook/index.js +9 -6
- package/dist/env/index.js +38 -34
- package/dist/env/llm/index.js +7 -7
- package/dist/env/log-trace/index.js +7 -7
- package/dist/env/mcp/index.js +7 -7
- package/dist/env/memory/index.js +11 -11
- package/dist/env/plugin/index.js +7 -7
- package/dist/env/prompt/index.js +8 -8
- package/dist/env/session/index.js +7 -7
- package/dist/env/skill/index.js +7 -7
- package/dist/env/task/delegate/index.js +8 -8
- package/dist/env/task/index.js +17 -17
- package/dist/env/task/plugins/index.js +10 -9
- package/dist/env/task/storage/index.js +2 -2
- package/dist/env/task/tools/index.js +3 -3
- package/dist/env/tool/built-in/index.js +2 -2
- package/dist/env/tool/index.js +8 -8
- package/dist/env/workflow/engine/index.js +12 -9
- package/dist/env/workflow/hooks/index.js +25 -0
- package/dist/env/workflow/index.js +19 -17
- package/dist/env/workflow/nodes/index.js +2 -2
- package/dist/env/workflow/plugins/index.js +18 -0
- package/dist/env/workflow/service/index.js +2 -2
- package/dist/env/workflow/storage/index.js +3 -3
- package/dist/env/workflow/tools/index.js +11 -11
- package/dist/env/workflow/utils/index.js +4 -4
- package/dist/index.js +79 -70
- package/dist/shared/@ai-setting/{roy-agent-core-3ajh3cdj.js → roy-agent-core-0cfaqnz9.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-trd6my5j.js → roy-agent-core-1cv9j4dg.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-48f17g3x.js → roy-agent-core-2gay3sjt.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-e302nvzt.js → roy-agent-core-2k4xffaa.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-1pjct4nj.js → roy-agent-core-35s1w7tc.js} +230 -96
- package/dist/shared/@ai-setting/{roy-agent-core-v6zdngr7.js → roy-agent-core-3tv1q6f2.js} +8 -8
- package/dist/shared/@ai-setting/{roy-agent-core-mqaht7mm.js → roy-agent-core-4z3rq5gw.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-fm77q3tn.js → roy-agent-core-5apmk4qw.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-xmfyt3dg.js → roy-agent-core-6167phd4.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-wt37tszm.js → roy-agent-core-7evvpfwc.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-azdsyhvx.js → roy-agent-core-7g03zkkb.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-v2d0bt7e.js → roy-agent-core-8s9jd2qy.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-8pqq9yjt.js → roy-agent-core-978b6wfx.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-9csa89jx.js +46 -0
- package/dist/shared/@ai-setting/{roy-agent-core-cnsjr3ws.js → roy-agent-core-9jzysq50.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-5ja22qkf.js → roy-agent-core-ak4dc3kg.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-ncaqkyfj.js → roy-agent-core-athdr2m0.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-x8ebdrtn.js → roy-agent-core-avyd65je.js} +9 -5
- package/dist/shared/@ai-setting/{roy-agent-core-223v204d.js → roy-agent-core-cg9f4zch.js} +69 -4
- package/dist/shared/@ai-setting/{roy-agent-core-bt6h398s.js → roy-agent-core-dsevjbck.js} +20 -7
- package/dist/shared/@ai-setting/{roy-agent-core-5hjtbvxf.js → roy-agent-core-dv714bqh.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-k0mx0tkh.js → roy-agent-core-dwx9hjwx.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-zc9k2n3c.js → roy-agent-core-f28va833.js} +4 -4
- package/dist/shared/@ai-setting/roy-agent-core-fs36xgcs.js +13 -0
- package/dist/shared/@ai-setting/{roy-agent-core-ydwtpzyf.js → roy-agent-core-fvs48d38.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-k0sy76cw.js → roy-agent-core-gpf2059p.js} +17 -13
- package/dist/shared/@ai-setting/{roy-agent-core-emjpkx9s.js → roy-agent-core-k8b440n3.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-j783tcqb.js → roy-agent-core-nde5gzta.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-e2569ptp.js → roy-agent-core-ne2t1pay.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-xvf97xs4.js → roy-agent-core-p8ak03s0.js} +3 -3
- package/dist/shared/@ai-setting/{roy-agent-core-98wwn2px.js → roy-agent-core-q6twb0df.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-kazn764f.js → roy-agent-core-q9gnnv6v.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-56j2q0w6.js → roy-agent-core-qamktze3.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-khx0h4j2.js → roy-agent-core-qcspfszy.js} +11 -4
- package/dist/shared/@ai-setting/{roy-agent-core-rqyxdrxg.js → roy-agent-core-qm9jda8p.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-yq45m8mm.js → roy-agent-core-rnwr39b0.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-vrj9c5y6.js → roy-agent-core-rpnjzztt.js} +14 -7
- package/dist/shared/@ai-setting/{roy-agent-core-hqtp5m8v.js → roy-agent-core-rpwn590p.js} +13 -13
- package/dist/shared/@ai-setting/{roy-agent-core-ed4tbkyj.js → roy-agent-core-rx16h2m1.js} +7 -3
- package/dist/shared/@ai-setting/{roy-agent-core-5vf48m39.js → roy-agent-core-s7jpkfm1.js} +75 -754
- package/dist/shared/@ai-setting/{roy-agent-core-ecb8am8s.js → roy-agent-core-skzjs973.js} +5 -5
- package/dist/shared/@ai-setting/{roy-agent-core-f51kwn6m.js → roy-agent-core-t37wbysj.js} +4 -4
- package/dist/shared/@ai-setting/{roy-agent-core-xn12d221.js → roy-agent-core-tdbv7ff4.js} +5 -3
- package/dist/shared/@ai-setting/{roy-agent-core-yes3mr8n.js → roy-agent-core-tjg71zqp.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-yge38dkn.js → roy-agent-core-vrsxhw9e.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-sea232w4.js → roy-agent-core-vy69rpxy.js} +13 -13
- package/dist/shared/@ai-setting/roy-agent-core-wxsgay02.js +302 -0
- package/dist/shared/@ai-setting/{roy-agent-core-c0mnxxck.js → roy-agent-core-x8n1r7h4.js} +1 -1
- package/dist/shared/@ai-setting/{roy-agent-core-m9drr1fd.js → roy-agent-core-yd21n6c7.js} +2 -2
- package/dist/shared/@ai-setting/{roy-agent-core-zff8vvs5.js → roy-agent-core-yhsssn86.js} +1 -1
- package/dist/shared/@ai-setting/roy-agent-core-zd077w51.js +1037 -0
- package/dist/shared/@ai-setting/{roy-agent-core-2bbj3jqd.js → roy-agent-core-zd3ddm4k.js} +1 -1
- package/package.json +1 -1
|
@@ -1,25 +1,28 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createAutoTaskPlugin
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-s7jpkfm1.js";
|
|
4
4
|
import {
|
|
5
5
|
ContextError,
|
|
6
6
|
ErrorCodes
|
|
7
7
|
} from "./roy-agent-core-ctdhjv68.js";
|
|
8
8
|
import {
|
|
9
9
|
BaseComponent
|
|
10
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-tdbv7ff4.js";
|
|
11
|
+
import {
|
|
12
|
+
init_hook
|
|
13
|
+
} from "./roy-agent-core-qcspfszy.js";
|
|
11
14
|
import {
|
|
12
15
|
init_context
|
|
13
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-k8b440n3.js";
|
|
14
17
|
import {
|
|
15
18
|
getEnvContext,
|
|
16
19
|
init_env_context,
|
|
17
20
|
runWithEnvContextAsync
|
|
18
|
-
} from "./roy-agent-core-
|
|
21
|
+
} from "./roy-agent-core-5apmk4qw.js";
|
|
19
22
|
import {
|
|
20
23
|
TracedAs,
|
|
21
24
|
init_decorator
|
|
22
|
-
} from "./roy-agent-core-
|
|
25
|
+
} from "./roy-agent-core-dsevjbck.js";
|
|
23
26
|
import {
|
|
24
27
|
createLogger,
|
|
25
28
|
init_logger
|
|
@@ -595,6 +598,7 @@ __legacyDecorateClassTS([
|
|
|
595
598
|
], BaseEnvironment.prototype, "handleWorkflowAgentQuery", null);
|
|
596
599
|
|
|
597
600
|
// src/env/index.ts
|
|
601
|
+
init_hook();
|
|
598
602
|
init_context();
|
|
599
603
|
|
|
600
604
|
export { generateId, generateDescendingId, BaseEnvironment };
|
|
@@ -1435,7 +1435,7 @@ outputs: [] # 输出定义(可空)
|
|
|
1435
1435
|
|
|
1436
1436
|
**你不是** primary mediator(不像老的 workflow-agent),你只是 sub-agent,**不要**自己去做用户面对面的对话澄清。
|
|
1437
1437
|
|
|
1438
|
-
## 你的工具 (
|
|
1438
|
+
## 你的工具 (10 个, 严格白名单)
|
|
1439
1439
|
|
|
1440
1440
|
| 工具 | 用途 |
|
|
1441
1441
|
|------|------|
|
|
@@ -1445,9 +1445,15 @@ outputs: [] # 输出定义(可空)
|
|
|
1445
1445
|
| \`workflow_tag_list\` | **查 tag 池,避免 tag 膨胀**(已有 \`code-review\` 时不要新增 \`review-workflow\`) |
|
|
1446
1446
|
| \`workflow_validate\` | **必须**在 \`workflow_add\` 之前调用,直到返回 valid |
|
|
1447
1447
|
| \`workflow_add\` | 注册新 workflow(需要 1-3 个 tags) |
|
|
1448
|
+
| \`bash\` | **仅用于契约真实性校验**(见阶段 4.5):\`ls\` 核对脚本真名、\`grep\` 核对输出标记、\`roy-agent debug trace/debug span\` 取证。**禁止**用它绕过 workflow 直接干活 |
|
|
1449
|
+
| \`read_file\` | 读脚本/测试文件内容,核对它真的输出你 grep 的标记 |
|
|
1450
|
+
| \`workflow_run\` | **构建后冒烟真跑**(见阶段 5.5,DoD 硬门槛) |
|
|
1451
|
+
| \`workflow_run_status\` | 轮询冒烟 run 的终态(completed / failed / timeout) |
|
|
1448
1452
|
|
|
1449
|
-
> ⚠️ **你只有这
|
|
1450
|
-
>
|
|
1453
|
+
> ⚠️ **你只有这 10 个工具**,不要使用 \`edit_file\` / \`write_file\` / \`delegate_task\` 等。
|
|
1454
|
+
> ⚠️ \`bash\` **只用于"核实事实"与"取证",绝不用于"替代 workflow 节点完成业务逻辑"** ——
|
|
1455
|
+
> 后者会让 workflow 变成一个空壳,是本 prompt 明令禁止的走捷径行为。
|
|
1456
|
+
> ⚠️ 不要直接读 \`*.workflow.yaml\` 文件自己 parse(用 \`workflow_get\`)。
|
|
1451
1457
|
|
|
1452
1458
|
## 多轮交互流程 (与 workflow-extract 的关键差异)
|
|
1453
1459
|
|
|
@@ -1481,6 +1487,24 @@ workflow-creator 是**多轮对话式**协作。每个阶段都可能需要 ask
|
|
|
1481
1487
|
|
|
1482
1488
|
输出完整 YAML draft,参考以下最小化模板。
|
|
1483
1489
|
|
|
1490
|
+
### 阶段 4.5: 输入契约真实性校验 (Contract Grounding) \uD83D\uDD0D
|
|
1491
|
+
|
|
1492
|
+
> 背景(真实事故):曾交付一个「validate 通过、注册成功,但一跑就假阳性 PASS」的 workflow ——
|
|
1493
|
+
> 脚本名拼接错(\`PY_TAG=312\` vs 磁盘 \`cp12\`)、回退脚本在容器内嵌套 docker 导致空跑、
|
|
1494
|
+
> 脚本硬编码 \`Total 99 PASS 99\` 被聚合节点当真值,最终 0/0/0 却报 PASS。
|
|
1495
|
+
> 根因:**validate 只看 DAG 结构,不看语义**。
|
|
1496
|
+
|
|
1497
|
+
在把任何**文件路径 / 命令名 / 输出标记**写进 YAML 之前,**用 \`bash\` / \`read_file\` 核实它真的存在、真的匹配**:
|
|
1498
|
+
|
|
1499
|
+
- **路径契约**:形如 \`/tmp/xxx_\${VAR}.sh\` 的路径,必须把**变量代入后的最终字符串**与磁盘真实文件逐一比对
|
|
1500
|
+
(例:\`for v in 3.12 3.13; do ls /tmp/..._cp\${v//./}.sh; done\`)。
|
|
1501
|
+
脚本名规律若是 \`cp12\` 而你拼出 \`cp312\` → 契约错误,必须改 YAML。
|
|
1502
|
+
- **输出标记契约**:workflow 里 grep 的标记(如 \`[PASS]\`)必须与测试脚本**真实输出**的标记完全一致
|
|
1503
|
+
(去脚本里核对它的输出格式,不要凭想象写标记)。
|
|
1504
|
+
- **执行环境契约**:确认脚本是「宿主机跑(内部 docker exec)」还是「容器内跑」——
|
|
1505
|
+
把「宿主机用 docker 驱动」的脚本 \`docker cp\` 进容器再跑 = **必然空跑**,禁止。
|
|
1506
|
+
- 校验结论写进设计报告「契约校验」小节,注明每条契约的**核实命令 + 实际结果**。
|
|
1507
|
+
|
|
1484
1508
|
### 阶段 5: 迭代验证 (Iterative Validate) \uD83D\uDD01
|
|
1485
1509
|
|
|
1486
1510
|
调用 \`workflow_validate\`:
|
|
@@ -1490,6 +1514,42 @@ workflow-creator 是**多轮对话式**协作。每个阶段都可能需要 ask
|
|
|
1490
1514
|
- **最多迭代 8 次**,超过则停止并报告失败原因
|
|
1491
1515
|
- ❌ 不要**跳过 validate** 直接 \`workflow_add\`
|
|
1492
1516
|
|
|
1517
|
+
### 阶段 5.5: 端到端冒烟验证 (Smoke Run) \uD83D\uDEA8 完成硬门槛
|
|
1518
|
+
|
|
1519
|
+
> ⚠️ **\`workflow_validate\` 通过 ≠ workflow 可用。** 它只校验 DAG 结构
|
|
1520
|
+
> (重复节点 / 缺依赖 / 环 / 空节点 ID),**不校验**脚本路径、变量拼接、输出契约、测试是否真执行。
|
|
1521
|
+
> 你**必须**让 workflow 真的跑一次并拿到证据,否则**不算完成**。
|
|
1522
|
+
|
|
1523
|
+
**执行路径(你有 \`workflow_run\`):**
|
|
1524
|
+
|
|
1525
|
+
1. \`workflow_run(name, input=<真实样例输入>)\` —— 用**真实输入**,不要用 \`echo ok\` 之类的桩
|
|
1526
|
+
2. \`workflow_run_status(run_id)\` 轮询到**终态**(completed / failed / timeout)
|
|
1527
|
+
3. **用 trace 取证**(这是判定"真的跑过"的唯一客观依据,不要只看工具返回值):
|
|
1528
|
+
- \`roy-agent debug trace <trace_id>\` —— 看整个 run 的 span 树:是否真的经过
|
|
1529
|
+
\`workflow.engine.runWorkflow → startNode → validateAndExecute → executeNode\`,
|
|
1530
|
+
每个节点是否都执行到,有没有节点被跳过 / 直接失败
|
|
1531
|
+
- \`roy-agent debug span <span_id>\` —— 看**单个节点**的完整输入输出与错误
|
|
1532
|
+
(节点级排障用:\`workflow.executor.executeNode\` / \`workflow.tool.execute\` 等)
|
|
1533
|
+
- 拿不到 trace_id 时,用 \`bash\` 查最近 trace:\`roy-agent debug trace --list -n 5\`
|
|
1534
|
+
4. 把 run 证据落盘并写 \`task_operation\`:\`run_id + trace_id + session_id + 各节点执行条数\`
|
|
1535
|
+
|
|
1536
|
+
**冒烟通过判据(全部满足才算通过):**
|
|
1537
|
+
|
|
1538
|
+
| 判据 | 说明 |
|
|
1539
|
+
|------|------|
|
|
1540
|
+
| ✅ run 终态 = completed | 不是 failed / timeout |
|
|
1541
|
+
| ✅ **每个节点都有 output 且非空** | 逐个检查;出现 \`command not found\` / \`Bad substitution\` / \`timeout\` 即失败 |
|
|
1542
|
+
| ✅ **真实执行条数 > 0** | 例:\`passed_count + failed_count + expected_count > 0\`;**严禁 0/0/0 判 PASS** |
|
|
1543
|
+
| ✅ 关键输入契约在运行中被**真实命中** | 例:日志出现 \`Test script: <真名>\`,而不是 fallback 警告分支 |
|
|
1544
|
+
| ✅ trace 里能看到**完整节点链路** | \`debug trace\` 中每个预期节点都出现且有耗时(非 0ms 跳过) |
|
|
1545
|
+
| ✅ run 证据落盘 | \`run_id + trace_id + session_id\` 写入 \`/tmp/<task>_smoke_evidence.json\` 与 task_operation |
|
|
1546
|
+
|
|
1547
|
+
**未通过冒烟 → 禁止 \`task_complete\`**:回到阶段 4 改 YAML,重跑,直到通过;或明确报告失败原因
|
|
1548
|
+
(**不得**用"应该没问题"之类的措辞声称通过)。
|
|
1549
|
+
|
|
1550
|
+
> \uD83D\uDEAB **绝不允许用 \`workflow update\` 绕过冒烟验证**(历史上真实节点版本 v1.1.0/v1.2.0 就是走
|
|
1551
|
+
> \`workflow update\` 注册的,完全绕过了 validate 与冒烟)。update 后**同样必须**重跑阶段 5 + 5.5。
|
|
1552
|
+
|
|
1493
1553
|
### 阶段 6: 注册 (Add) \uD83D\uDEA6
|
|
1494
1554
|
|
|
1495
1555
|
validate 通过后:
|
|
@@ -1653,13 +1713,18 @@ outputs: [] # 输出定义(可空)
|
|
|
1653
1713
|
|
|
1654
1714
|
## 严格约束
|
|
1655
1715
|
|
|
1656
|
-
- ✅ 只用
|
|
1716
|
+
- ✅ 只用 10 个被授予的工具(白名单强制)
|
|
1657
1717
|
- ✅ validate **必须**在 add 之前
|
|
1718
|
+
- ✅ **add / update 之后必须端到端冒烟跑一次**(阶段 5.5),并附 trace 证据;否则不算完成
|
|
1658
1719
|
- ✅ tags 1-3 个,优先复用已有 tag
|
|
1659
1720
|
- ✅ 注册前再次确认用户同意
|
|
1721
|
+
- ✅ run 证据(run_id + trace_id + session_id + 执行条数)**必须落盘 + 写 task_operation**
|
|
1660
1722
|
- ❌ 不要直接读 \`*.workflow.yaml\` 文件自己 parse(用 \`workflow_get\`)
|
|
1661
1723
|
- ❌ 不要 \`delegate_task\` / \`stop_task\`(deniedTools 已禁,禁止递归委托)
|
|
1662
1724
|
- ❌ 不要跳过 \`workflow_validate\`
|
|
1725
|
+
- ❌ 不要用 \`workflow update\` 绕过 validate / 冒烟
|
|
1726
|
+
- ❌ 不要用 \`bash\` 替代 workflow 节点完成业务逻辑(走捷径 = 交付空壳)
|
|
1727
|
+
- ❌ 不要凭"应该能跑"声称通过;**没有 trace / run 证据就不算跑过**
|
|
1663
1728
|
- ❌ 不要自动 merge / push / tag
|
|
1664
1729
|
- ❌ 不要硬编码大段 text(应引用 \`{{input.x}}\` 模板)`,
|
|
1665
1730
|
"task-organizer": `
|
|
@@ -89,6 +89,19 @@ function wrapFunction(fn, name, options) {
|
|
|
89
89
|
}
|
|
90
90
|
return maxLogSize > 0 && str.length > maxLogSize ? str.slice(0, maxLogSize) + " [TRUNCATED]" : str;
|
|
91
91
|
};
|
|
92
|
+
const toDbValue = (obj) => {
|
|
93
|
+
if (obj === undefined)
|
|
94
|
+
return;
|
|
95
|
+
if (obj === null)
|
|
96
|
+
return null;
|
|
97
|
+
if (typeof obj === "string")
|
|
98
|
+
return obj;
|
|
99
|
+
try {
|
|
100
|
+
return JSON.parse(JSON.stringify(obj));
|
|
101
|
+
} catch (e) {
|
|
102
|
+
return `[Object with circular reference: ${e instanceof Error ? e.message : String(e)}]`;
|
|
103
|
+
}
|
|
104
|
+
};
|
|
92
105
|
const TRACE_LOG_PREFIX = "[TRACE]";
|
|
93
106
|
const getCallerLocation = () => {
|
|
94
107
|
const originalLimit = Error.stackTraceLimit;
|
|
@@ -141,16 +154,16 @@ function wrapFunction(fn, name, options) {
|
|
|
141
154
|
if (options?.recordParams !== false) {
|
|
142
155
|
if (options?.paramFilter) {
|
|
143
156
|
const filtered = options.paramFilter(args);
|
|
144
|
-
attributes["params"] =
|
|
157
|
+
attributes["params"] = toDbValue(filtered);
|
|
145
158
|
if (options?.flattenParamFilter && filtered && typeof filtered === "object" && !Array.isArray(filtered)) {
|
|
146
159
|
for (const [key, value] of Object.entries(filtered)) {
|
|
147
160
|
if (!(key in attributes)) {
|
|
148
|
-
attributes[key] =
|
|
161
|
+
attributes[key] = toDbValue(value);
|
|
149
162
|
}
|
|
150
163
|
}
|
|
151
164
|
}
|
|
152
165
|
} else {
|
|
153
|
-
attributes["params"] =
|
|
166
|
+
attributes["params"] = toDbValue(args);
|
|
154
167
|
}
|
|
155
168
|
}
|
|
156
169
|
const callerLocation = getCallerLocation();
|
|
@@ -168,11 +181,11 @@ function wrapFunction(fn, name, options) {
|
|
|
168
181
|
const filtered = options.resultFilter(resolved);
|
|
169
182
|
if (filtered && typeof filtered === "object") {
|
|
170
183
|
for (const [key, value] of Object.entries(filtered)) {
|
|
171
|
-
span.setAttribute(key,
|
|
184
|
+
span.setAttribute(key, toDbValue(value));
|
|
172
185
|
}
|
|
173
186
|
}
|
|
174
187
|
}
|
|
175
|
-
span.setAttribute("result", JSON.stringify(
|
|
188
|
+
span.setAttribute("result", JSON.stringify(toDbValue(resolved)));
|
|
176
189
|
const resultError = options?.errorIf ? options.errorIf(resolved) : undefined;
|
|
177
190
|
if (resultError) {
|
|
178
191
|
const err = resultError instanceof Error ? resultError : new Error(String(resultError));
|
|
@@ -198,11 +211,11 @@ function wrapFunction(fn, name, options) {
|
|
|
198
211
|
const filtered = options.resultFilter(result);
|
|
199
212
|
if (filtered && typeof filtered === "object") {
|
|
200
213
|
for (const [key, value] of Object.entries(filtered)) {
|
|
201
|
-
span.setAttribute(key,
|
|
214
|
+
span.setAttribute(key, toDbValue(value));
|
|
202
215
|
}
|
|
203
216
|
}
|
|
204
217
|
}
|
|
205
|
-
span.setAttribute("result", JSON.stringify(
|
|
218
|
+
span.setAttribute("result", JSON.stringify(toDbValue(result)));
|
|
206
219
|
const syncResultError = options?.errorIf ? options.errorIf(result) : undefined;
|
|
207
220
|
if (syncResultError) {
|
|
208
221
|
const err = syncResultError instanceof Error ? syncResultError : new Error(String(syncResultError));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
builtInPrompts
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-cg9f4zch.js";
|
|
4
4
|
import {
|
|
5
5
|
getXDGPath
|
|
6
6
|
} from "./roy-agent-core-qxnbvgwe.js";
|
|
@@ -10,14 +10,14 @@ import {
|
|
|
10
10
|
} from "./roy-agent-core-7hh0brvs.js";
|
|
11
11
|
import {
|
|
12
12
|
BaseComponent
|
|
13
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-tdbv7ff4.js";
|
|
14
14
|
import {
|
|
15
15
|
createHook
|
|
16
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-qcspfszy.js";
|
|
17
17
|
import {
|
|
18
18
|
globalHookManager,
|
|
19
19
|
init_global_hook_manager
|
|
20
|
-
} from "./roy-agent-core-
|
|
20
|
+
} from "./roy-agent-core-4z3rq5gw.js";
|
|
21
21
|
import {
|
|
22
22
|
createLogger,
|
|
23
23
|
init_logger
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import {
|
|
2
|
+
init_workflow_hook_points
|
|
3
|
+
} from "./roy-agent-core-9csa89jx.js";
|
|
4
|
+
import {
|
|
5
|
+
__esm
|
|
6
|
+
} from "./roy-agent-core-fs0mn2jk.js";
|
|
7
|
+
|
|
8
|
+
// src/env/workflow/hooks/index.ts
|
|
9
|
+
var init_hooks = __esm(() => {
|
|
10
|
+
init_workflow_hook_points();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export { init_hooks };
|
|
@@ -11,20 +11,20 @@ import {
|
|
|
11
11
|
} from "./roy-agent-core-7hh0brvs.js";
|
|
12
12
|
import {
|
|
13
13
|
BaseComponent
|
|
14
|
-
} from "./roy-agent-core-
|
|
14
|
+
} from "./roy-agent-core-tdbv7ff4.js";
|
|
15
15
|
import {
|
|
16
16
|
ToolHookPoints,
|
|
17
17
|
globalHookManager,
|
|
18
18
|
init_global_hook_manager
|
|
19
|
-
} from "./roy-agent-core-
|
|
19
|
+
} from "./roy-agent-core-4z3rq5gw.js";
|
|
20
20
|
import {
|
|
21
21
|
getCurrentTaskId,
|
|
22
22
|
init_env_context
|
|
23
|
-
} from "./roy-agent-core-
|
|
23
|
+
} from "./roy-agent-core-5apmk4qw.js";
|
|
24
24
|
import {
|
|
25
25
|
TracedAs,
|
|
26
26
|
init_decorator
|
|
27
|
-
} from "./roy-agent-core-
|
|
27
|
+
} from "./roy-agent-core-dsevjbck.js";
|
|
28
28
|
import {
|
|
29
29
|
createLogger,
|
|
30
30
|
init_logger
|
|
@@ -4,35 +4,35 @@ import {
|
|
|
4
4
|
} from "./roy-agent-core-tbrn9wdm.js";
|
|
5
5
|
import {
|
|
6
6
|
getSharedEventStore
|
|
7
|
-
} from "./roy-agent-core-
|
|
7
|
+
} from "./roy-agent-core-yhsssn86.js";
|
|
8
8
|
import {
|
|
9
9
|
TaskHookPoints
|
|
10
10
|
} from "./roy-agent-core-1pg0fepg.js";
|
|
11
11
|
import {
|
|
12
12
|
builtInPrompts
|
|
13
|
-
} from "./roy-agent-core-
|
|
13
|
+
} from "./roy-agent-core-cg9f4zch.js";
|
|
14
14
|
import {
|
|
15
15
|
DEFAULT_SUBAGENT_PROMPT
|
|
16
|
-
} from "./roy-agent-core-
|
|
16
|
+
} from "./roy-agent-core-rx16h2m1.js";
|
|
17
17
|
import {
|
|
18
18
|
runWithBgTaskIdAsync
|
|
19
19
|
} from "./roy-agent-core-c1v263jn.js";
|
|
20
20
|
import {
|
|
21
21
|
globalHookManager,
|
|
22
22
|
init_global_hook_manager
|
|
23
|
-
} from "./roy-agent-core-
|
|
23
|
+
} from "./roy-agent-core-4z3rq5gw.js";
|
|
24
24
|
import {
|
|
25
25
|
init_context
|
|
26
|
-
} from "./roy-agent-core-
|
|
26
|
+
} from "./roy-agent-core-k8b440n3.js";
|
|
27
27
|
import {
|
|
28
28
|
getCurrentTaskId,
|
|
29
29
|
getEnvContext
|
|
30
|
-
} from "./roy-agent-core-
|
|
30
|
+
} from "./roy-agent-core-5apmk4qw.js";
|
|
31
31
|
import {
|
|
32
32
|
TracedAs,
|
|
33
33
|
init_decorator,
|
|
34
34
|
wrapFunction
|
|
35
|
-
} from "./roy-agent-core-
|
|
35
|
+
} from "./roy-agent-core-dsevjbck.js";
|
|
36
36
|
import {
|
|
37
37
|
createLogger,
|
|
38
38
|
init_logger
|
|
@@ -1129,13 +1129,13 @@ class BackgroundTaskManager {
|
|
|
1129
1129
|
if (!reusedSession) {
|
|
1130
1130
|
throw new Error(`Sub session not found for resume: ${existingSubSessionId}`);
|
|
1131
1131
|
}
|
|
1132
|
-
const createdBy = reusedSession?.
|
|
1132
|
+
const createdBy = reusedSession?.metadata?.created_by;
|
|
1133
1133
|
if (createdBy && createdBy !== "subagent") {
|
|
1134
1134
|
logger3.warn(`[BackgroundTaskManager] Session ${existingSubSessionId} was not created by a sub-agent (created_by=${createdBy}); reusing anyway`);
|
|
1135
1135
|
}
|
|
1136
1136
|
subSession = reusedSession;
|
|
1137
1137
|
try {
|
|
1138
|
-
const existingMeta = reusedSession?.
|
|
1138
|
+
const existingMeta = reusedSession?.metadata ?? {};
|
|
1139
1139
|
await sessionComponent.update(existingSubSessionId, {
|
|
1140
1140
|
metadata: {
|
|
1141
1141
|
...existingMeta,
|
|
@@ -1250,7 +1250,7 @@ class BackgroundTaskManager {
|
|
|
1250
1250
|
throw new Error(`Sub session not found: ${task.subSessionId}`);
|
|
1251
1251
|
}
|
|
1252
1252
|
const taskRegistry = this.processRegistries.get(taskId);
|
|
1253
|
-
const result = await this.executeWithAbort(subSession, prompt, timeoutMs, taskId, abortController?.signal, task.similarTaskIds, taskRegistry, () => abortController?.abort());
|
|
1253
|
+
const result = await this.executeWithAbort(subSession, prompt, timeoutMs, taskId, abortController?.signal, task.similarTaskIds, taskRegistry, () => abortController?.abort(), task.subagentType);
|
|
1254
1254
|
if (abortController?.signal.aborted) {
|
|
1255
1255
|
logger3.info(`[BackgroundTaskManager] Task was aborted`, { taskId });
|
|
1256
1256
|
return;
|
|
@@ -1416,12 +1416,16 @@ class BackgroundTaskManager {
|
|
|
1416
1416
|
this.progressTimers.delete(taskId);
|
|
1417
1417
|
}
|
|
1418
1418
|
}
|
|
1419
|
-
async executeWithAbort(subSession, prompt, timeoutMs, bgTaskId, signal, similarTaskIds, processRegistry, abortTask) {
|
|
1420
|
-
const metadata = subSession
|
|
1419
|
+
async executeWithAbort(subSession, prompt, timeoutMs, bgTaskId, signal, similarTaskIds, processRegistry, abortTask, explicitSubagentType) {
|
|
1420
|
+
const metadata = subSession?.metadata ?? {};
|
|
1421
1421
|
const taskId = metadata.task_id;
|
|
1422
1422
|
const taskDescription = metadata.task_description || "";
|
|
1423
1423
|
const sessionId = subSession.id;
|
|
1424
|
-
const
|
|
1424
|
+
const metaSubagentType = metadata.subagent_type;
|
|
1425
|
+
const subagentType = metaSubagentType || explicitSubagentType || "general";
|
|
1426
|
+
if (!metaSubagentType && !explicitSubagentType) {
|
|
1427
|
+
logger3.warn(`[delegate] subagent_type unresolved (no session metadata, no explicit value) — falling back to "general". sessionId=${sessionId}`);
|
|
1428
|
+
}
|
|
1425
1429
|
const agentComponent = this.env?.getComponent?.("agent");
|
|
1426
1430
|
const registry = agentComponent?.getRegistry?.();
|
|
1427
1431
|
const resolved = await resolveSubAgentConfig(subagentType, { registry });
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
TagRepository
|
|
3
|
-
} from "./roy-agent-core-
|
|
4
|
-
import"./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-nde5gzta.js";
|
|
4
|
+
import"./roy-agent-core-dsevjbck.js";
|
|
5
5
|
import"./roy-agent-core-8seq65bp.js";
|
|
6
6
|
import"./roy-agent-core-jnszp0jq.js";
|
|
7
7
|
import"./roy-agent-core-fs0mn2jk.js";
|
|
@@ -21,17 +21,17 @@ import {
|
|
|
21
21
|
} from "./roy-agent-core-7hh0brvs.js";
|
|
22
22
|
import {
|
|
23
23
|
BaseComponent
|
|
24
|
-
} from "./roy-agent-core-
|
|
24
|
+
} from "./roy-agent-core-tdbv7ff4.js";
|
|
25
25
|
import {
|
|
26
26
|
LLMHookPoints,
|
|
27
27
|
globalHookManager,
|
|
28
28
|
init_global_hook_manager
|
|
29
|
-
} from "./roy-agent-core-
|
|
29
|
+
} from "./roy-agent-core-4z3rq5gw.js";
|
|
30
30
|
import {
|
|
31
31
|
TracedAs,
|
|
32
32
|
init_decorator,
|
|
33
33
|
wrapFunction
|
|
34
|
-
} from "./roy-agent-core-
|
|
34
|
+
} from "./roy-agent-core-dsevjbck.js";
|
|
35
35
|
import {
|
|
36
36
|
createLogger,
|
|
37
37
|
init_logger
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isValidSessionId
|
|
3
|
-
} from "./roy-agent-core-
|
|
3
|
+
} from "./roy-agent-core-yd21n6c7.js";
|
|
4
4
|
import {
|
|
5
5
|
TAG_MAX_COUNT,
|
|
6
6
|
TAG_MIN_COUNT
|
|
7
|
-
} from "./roy-agent-core-
|
|
7
|
+
} from "./roy-agent-core-7evvpfwc.js";
|
|
8
8
|
import {
|
|
9
9
|
validateWorkflowDefinition
|
|
10
|
-
} from "./roy-agent-core-
|
|
10
|
+
} from "./roy-agent-core-q6twb0df.js";
|
|
11
11
|
import {
|
|
12
12
|
getCurrentBgTaskId
|
|
13
13
|
} from "./roy-agent-core-c1v263jn.js";
|
|
@@ -18,7 +18,7 @@ import {
|
|
|
18
18
|
import {
|
|
19
19
|
TracedAs,
|
|
20
20
|
init_decorator
|
|
21
|
-
} from "./roy-agent-core-
|
|
21
|
+
} from "./roy-agent-core-dsevjbck.js";
|
|
22
22
|
import {
|
|
23
23
|
createLogger,
|
|
24
24
|
init_logger
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
init_global_hook_manager,
|
|
3
3
|
init_hook_manager
|
|
4
|
-
} from "./roy-agent-core-
|
|
4
|
+
} from "./roy-agent-core-4z3rq5gw.js";
|
|
5
|
+
import {
|
|
6
|
+
__esm
|
|
7
|
+
} from "./roy-agent-core-fs0mn2jk.js";
|
|
5
8
|
|
|
6
9
|
// src/env/hook/types.ts
|
|
7
10
|
function createHook(meta, fn) {
|
|
@@ -13,9 +16,13 @@ function createHook(meta, fn) {
|
|
|
13
16
|
function createPriorityHook(name, fn, priority) {
|
|
14
17
|
return createHook({ name, priority }, fn);
|
|
15
18
|
}
|
|
19
|
+
var init_types = () => {};
|
|
16
20
|
|
|
17
21
|
// src/env/hook/index.ts
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
var init_hook = __esm(() => {
|
|
23
|
+
init_types();
|
|
24
|
+
init_hook_manager();
|
|
25
|
+
init_global_hook_manager();
|
|
26
|
+
});
|
|
20
27
|
|
|
21
|
-
export { createHook, createPriorityHook };
|
|
28
|
+
export { createHook, createPriorityHook, init_hook };
|
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
} from "./roy-agent-core-7hh0brvs.js";
|
|
4
4
|
import {
|
|
5
5
|
BaseComponent
|
|
6
|
-
} from "./roy-agent-core-
|
|
6
|
+
} from "./roy-agent-core-tdbv7ff4.js";
|
|
7
7
|
import {
|
|
8
8
|
init_decorator
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-dsevjbck.js";
|
|
10
10
|
import {
|
|
11
11
|
createLogger,
|
|
12
12
|
getTracerProvider,
|
|
@@ -6,10 +6,13 @@ import {
|
|
|
6
6
|
createLarkCliTaskNotifyHook,
|
|
7
7
|
createPerTaskGroupChatPlugin,
|
|
8
8
|
mergeChatOwnership
|
|
9
|
-
} from "./roy-agent-core-
|
|
9
|
+
} from "./roy-agent-core-s7jpkfm1.js";
|
|
10
10
|
import {
|
|
11
11
|
getSharedEventStore
|
|
12
|
-
} from "./roy-agent-core-
|
|
12
|
+
} from "./roy-agent-core-yhsssn86.js";
|
|
13
|
+
import {
|
|
14
|
+
createLarkCliWorkflowNotifyHook
|
|
15
|
+
} from "./roy-agent-core-wxsgay02.js";
|
|
13
16
|
import {
|
|
14
17
|
normalizeLarkAtMentions
|
|
15
18
|
} from "./roy-agent-core-64f22h1g.js";
|
|
@@ -18,24 +21,24 @@ import {
|
|
|
18
21
|
} from "./roy-agent-core-7hh0brvs.js";
|
|
19
22
|
import {
|
|
20
23
|
BaseComponent
|
|
21
|
-
} from "./roy-agent-core-
|
|
24
|
+
} from "./roy-agent-core-tdbv7ff4.js";
|
|
22
25
|
import {
|
|
23
26
|
globalHookManager,
|
|
24
27
|
init_global_hook_manager
|
|
25
|
-
} from "./roy-agent-core-
|
|
28
|
+
} from "./roy-agent-core-4z3rq5gw.js";
|
|
26
29
|
import {
|
|
27
30
|
init_context
|
|
28
|
-
} from "./roy-agent-core-
|
|
31
|
+
} from "./roy-agent-core-k8b440n3.js";
|
|
29
32
|
import {
|
|
30
33
|
createEnvContext,
|
|
31
34
|
normalizeParentTaskId,
|
|
32
35
|
runWithEnvContext
|
|
33
|
-
} from "./roy-agent-core-
|
|
36
|
+
} from "./roy-agent-core-5apmk4qw.js";
|
|
34
37
|
import {
|
|
35
38
|
TracedAs,
|
|
36
39
|
init_decorator,
|
|
37
40
|
wrapFunction
|
|
38
|
-
} from "./roy-agent-core-
|
|
41
|
+
} from "./roy-agent-core-dsevjbck.js";
|
|
39
42
|
import {
|
|
40
43
|
createLogger,
|
|
41
44
|
getTracerProvider,
|
|
@@ -846,6 +849,7 @@ function isPluginDebugEnabled() {
|
|
|
846
849
|
}
|
|
847
850
|
var BUILT_IN_PLUGIN_FACTORIES = {
|
|
848
851
|
LarkCliTaskNotifyPlugin: (cfg) => createLarkCliTaskNotifyHook(cfg),
|
|
852
|
+
LarkCliWorkflowNotifyPlugin: (cfg) => createLarkCliWorkflowNotifyHook(cfg),
|
|
849
853
|
PerTaskGroupChatPlugin: (cfg) => createPerTaskGroupChatPlugin(cfg),
|
|
850
854
|
"task-tag": () => new TaskTagPlugin
|
|
851
855
|
};
|
|
@@ -1208,6 +1212,9 @@ class LarkCliInstance {
|
|
|
1208
1212
|
if (Array.isArray(plugin.hooks)) {
|
|
1209
1213
|
return plugin.hooks.map((h) => h.point || h);
|
|
1210
1214
|
}
|
|
1215
|
+
if (Array.isArray(plugin.hookPoints)) {
|
|
1216
|
+
return plugin.hookPoints.map((h) => h.point || h);
|
|
1217
|
+
}
|
|
1211
1218
|
if (typeof plugin.execute === "function" && plugin.hookPoint) {
|
|
1212
1219
|
return [plugin.hookPoint];
|
|
1213
1220
|
}
|