@autotest/agent 0.0.6 → 0.0.7

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.
Files changed (153) hide show
  1. package/README.md +7 -0
  2. package/dist/api/agent_api.d.ts +2 -2
  3. package/dist/autotest-cli.js +1 -397
  4. package/dist/common/config/config.yaml +4 -0
  5. package/dist/common/config/manager.d.ts +4 -4
  6. package/dist/common/config/types.d.ts +5 -0
  7. package/dist/common/dfx/index.d.ts +1 -1
  8. package/dist/core/agent/single_agent/agent.d.ts +1 -0
  9. package/dist/core/device/device_protocol.d.ts +1 -1
  10. package/dist/core/knowledge/knowledge_manager.d.ts +3 -3
  11. package/dist/core/knowledge/vectordb.d.ts +5 -5
  12. package/dist/core/mcp/harmony_hdc_adapter.d.ts +1 -0
  13. package/dist/core/mcp/mcp_tools.d.ts +1 -0
  14. package/dist/core/mcp/verify_tool.d.ts +12 -0
  15. package/dist/core/prompt/templates/single/single_v2.0.md +15 -0
  16. package/dist/data_types/device.d.ts +1 -1
  17. package/dist/data_types/index.d.ts +1 -1
  18. package/dist/index.d.ts +4 -4
  19. package/dist/index.js +1 -163
  20. package/dist/tools/batch_runner.js +1 -745
  21. package/dist/tools/case_runner/runner.js +1 -410
  22. package/dist/tools/config/config_tool.js +1 -339
  23. package/dist/tools/prompt_compare/compare_runner.js +1 -360
  24. package/package.json +2 -2
  25. package/dist/api/agent_api.js +0 -550
  26. package/dist/api/autotest_agent.js +0 -205
  27. package/dist/api/types.js +0 -11
  28. package/dist/common/case_manager.js +0 -91
  29. package/dist/common/collect_case.js +0 -128
  30. package/dist/common/common_errors.js +0 -66
  31. package/dist/common/config/config_validator.js +0 -28
  32. package/dist/common/config/manager.js +0 -257
  33. package/dist/common/config/output.js +0 -59
  34. package/dist/common/config/types.js +0 -185
  35. package/dist/common/dfx/client_factory.js +0 -62
  36. package/dist/common/dfx/context.js +0 -23
  37. package/dist/common/dfx/index.js +0 -15
  38. package/dist/common/dfx/recorder.js +0 -191
  39. package/dist/common/dfx/recording_fetch.js +0 -228
  40. package/dist/common/dfx/source.js +0 -13
  41. package/dist/common/image_cacher.js +0 -36
  42. package/dist/common/image_helper.js +0 -128
  43. package/dist/common/image_similarity.js +0 -171
  44. package/dist/common/llm_cache/cache_transport.js +0 -102
  45. package/dist/common/llm_cache/prompt_cache.js +0 -113
  46. package/dist/common/logger.js +0 -158
  47. package/dist/common/model/custom_model.js +0 -487
  48. package/dist/common/model/index.js +0 -5
  49. package/dist/common/path_utils.js +0 -88
  50. package/dist/common/result_parser.js +0 -49
  51. package/dist/common/usage/token_usage.js +0 -117
  52. package/dist/common/utils.js +0 -125
  53. package/dist/core/agent/layered_agent/ability_helper.js +0 -125
  54. package/dist/core/agent/layered_agent/agent.js +0 -37
  55. package/dist/core/agent/layered_agent/agent_registry.js +0 -82
  56. package/dist/core/agent/layered_agent/decision.js +0 -518
  57. package/dist/core/agent/layered_agent/execute_agent/action_handler.js +0 -155
  58. package/dist/core/agent/layered_agent/execute_agent/agent_factory.js +0 -41
  59. package/dist/core/agent/layered_agent/execute_agent/base_agent.js +0 -112
  60. package/dist/core/agent/layered_agent/execute_agent/general_agent.js +0 -207
  61. package/dist/core/agent/layered_agent/execute_agent/glm_agent.js +0 -241
  62. package/dist/core/agent/layered_agent/execute_agent/i18n.js +0 -34
  63. package/dist/core/agent/layered_agent/execute_agent/index.js +0 -67
  64. package/dist/core/agent/layered_agent/execute_agent/mai_ui_agent.js +0 -316
  65. package/dist/core/agent/layered_agent/execute_agent/mcp_prompts.js +0 -154
  66. package/dist/core/agent/layered_agent/execute_agent/parser/general_parser.js +0 -243
  67. package/dist/core/agent/layered_agent/execute_agent/parser/glm_parser.js +0 -139
  68. package/dist/core/agent/layered_agent/execute_agent/parser/index.js +0 -9
  69. package/dist/core/agent/layered_agent/execute_agent/parser/mai_ui_parser.js +0 -94
  70. package/dist/core/agent/layered_agent/execute_agent/prompts.js +0 -109
  71. package/dist/core/agent/layered_agent/execute_agent/simple_reporter.js +0 -33
  72. package/dist/core/agent/layered_agent/execute_agent/utils.js +0 -52
  73. package/dist/core/agent/report_analyzer_agent/agent.js +0 -565
  74. package/dist/core/agent/report_analyzer_agent/config.js +0 -22
  75. package/dist/core/agent/report_analyzer_agent/data_loader.js +0 -255
  76. package/dist/core/agent/report_analyzer_agent/guardrails.js +0 -99
  77. package/dist/core/agent/report_analyzer_agent/hooks.js +0 -31
  78. package/dist/core/agent/report_analyzer_agent/index.js +0 -52
  79. package/dist/core/agent/report_analyzer_agent/key_steps_builder.js +0 -42
  80. package/dist/core/agent/report_analyzer_agent/mapping.js +0 -133
  81. package/dist/core/agent/report_analyzer_agent/parse.js +0 -375
  82. package/dist/core/agent/report_analyzer_agent/prompt.js +0 -300
  83. package/dist/core/agent/report_analyzer_agent/report_writer.js +0 -558
  84. package/dist/core/agent/report_analyzer_agent/tools.js +0 -150
  85. package/dist/core/agent/report_analyzer_agent/types.js +0 -274
  86. package/dist/core/agent/rewrite_agent/agent.js +0 -209
  87. package/dist/core/agent/rewrite_agent/guardrails.js +0 -95
  88. package/dist/core/agent/rewrite_agent/mapping.js +0 -56
  89. package/dist/core/agent/rewrite_agent/parse.js +0 -121
  90. package/dist/core/agent/rewrite_agent/types.js +0 -37
  91. package/dist/core/agent/single_agent/agent.js +0 -801
  92. package/dist/core/agent/single_agent/hook_manager.js +0 -59
  93. package/dist/core/agent/single_agent/hooks.js +0 -288
  94. package/dist/core/agent/single_agent/image_utils.js +0 -158
  95. package/dist/core/agent/single_agent/scroll_search_agent.js +0 -405
  96. package/dist/core/agent/single_agent/subagent_manager.js +0 -72
  97. package/dist/core/agent/single_agent/tool_recorder_hook.js +0 -42
  98. package/dist/core/agent/types.js +0 -2
  99. package/dist/core/agent/utils/message_builder.js +0 -138
  100. package/dist/core/device/device_protocol.js +0 -2
  101. package/dist/core/device/hdc/apps.js +0 -437
  102. package/dist/core/device/hdc/device.js +0 -219
  103. package/dist/core/device/hdc/index.js +0 -31
  104. package/dist/core/device/hdc/input.js +0 -74
  105. package/dist/core/device/hdc/screenshot.js +0 -171
  106. package/dist/core/device/index.js +0 -70
  107. package/dist/core/device/types.js +0 -2
  108. package/dist/core/knowledge/knowledge_manager.js +0 -70
  109. package/dist/core/knowledge/vectordb.js +0 -283
  110. package/dist/core/mcp/adapter_factory.js +0 -99
  111. package/dist/core/mcp/android_adapter.js +0 -286
  112. package/dist/core/mcp/base_adapter.js +0 -86
  113. package/dist/core/mcp/harmony_hdc_adapter.js +0 -798
  114. package/dist/core/mcp/ios_adapter.js +0 -286
  115. package/dist/core/mcp/local_tools.js +0 -41
  116. package/dist/core/mcp/mcp_tools.js +0 -473
  117. package/dist/core/mcp/types.js +0 -6
  118. package/dist/core/memory/_utils.js +0 -140
  119. package/dist/core/memory/compressed_session.js +0 -182
  120. package/dist/core/memory/context_compressor.js +0 -176
  121. package/dist/core/memory/index.js +0 -22
  122. package/dist/core/memory/memory_manager.js +0 -28
  123. package/dist/core/memory/reflector.js +0 -95
  124. package/dist/core/memory/replan_manager.js +0 -12
  125. package/dist/core/memory/session_factory.js +0 -29
  126. package/dist/core/memory/tool_player.js +0 -225
  127. package/dist/core/memory/tool_player_popup.js +0 -276
  128. package/dist/core/memory/tool_player_replan.js +0 -226
  129. package/dist/core/memory/tool_player_xpath.js +0 -139
  130. package/dist/core/memory/tool_recorder.js +0 -126
  131. package/dist/core/preprocessor/task_splitter.js +0 -112
  132. package/dist/core/prompt/prompt_loader.js +0 -315
  133. package/dist/core/skill/skill_manager.js +0 -302
  134. package/dist/data_types/action.js +0 -2
  135. package/dist/data_types/agent.js +0 -2
  136. package/dist/data_types/case.js +0 -57
  137. package/dist/data_types/device.js +0 -2
  138. package/dist/data_types/index.js +0 -11
  139. package/dist/data_types/report.js +0 -6
  140. package/dist/data_types/screen.js +0 -23
  141. package/dist/data_types/task.js +0 -2
  142. package/dist/loop/cli.js +0 -127
  143. package/dist/loop/orchestrator.js +0 -314
  144. package/dist/loop/result_writer.js +0 -260
  145. package/dist/loop/types.js +0 -82
  146. package/dist/mcp-server/server.js +0 -341
  147. package/dist/mcp-server/types.js +0 -224
  148. package/dist/reporter/batch_summary.js +0 -197
  149. package/dist/reporter/generator.js +0 -286
  150. package/dist/reporter/html_template/index.js +0 -529
  151. package/dist/reporter/json_report.js +0 -6
  152. package/dist/reporter/types.js +0 -45
  153. package/dist/tools/case_runner/report.js +0 -264
@@ -1,95 +0,0 @@
1
- "use strict";
2
- /**
3
- * 改写 Agent 输出校验 guardrail —
4
- *
5
- * validateRewriteOutput(output, originalTask) 校验 RewriteOutput 字段一致性和合理性。
6
- * tripwireTriggered=true 表示校验失败,reason 含失败原因。
7
- */
8
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.validateRewriteOutput = validateRewriteOutput;
10
- const logger_1 = require("../../../common/logger");
11
- const types_1 = require("./types");
12
- const MAX_REWRITE_REASON_LENGTH = 200;
13
- const MIN_REWRITTEN_TASK_LENGTH = 10;
14
- const MIN_KNOWLEDGE_TEXT_LENGTH = 20;
15
- function validateRewrittenTask(output, originalTask, issues) {
16
- const task = output.rewrittenTask;
17
- if (task === null || task === undefined) {
18
- issues.push('action 需要 rewritten_task,但值为空');
19
- return;
20
- }
21
- const taskStripped = task.trim();
22
- if (!taskStripped) {
23
- issues.push('rewritten_task 为空字符串');
24
- return;
25
- }
26
- if (taskStripped.toUpperCase() === 'N/A') {
27
- issues.push('rewritten_task 为 N/A(LLM 误填)');
28
- return;
29
- }
30
- if (taskStripped === originalTask.trim()) {
31
- issues.push('rewritten_task 与 original_task 相同(假改写)');
32
- return;
33
- }
34
- if (taskStripped.length < MIN_REWRITTEN_TASK_LENGTH) {
35
- issues.push(`rewritten_task 过短(当前 ${taskStripped.length} 字,需要 ≥ ${MIN_REWRITTEN_TASK_LENGTH} 字)`);
36
- }
37
- }
38
- function validateKnowledgeText(output, issues) {
39
- const text = output.knowledgeText ?? '';
40
- if (!text || !text.trim()) {
41
- issues.push('action 需要 knowledge_text,但值为空');
42
- return;
43
- }
44
- const textStripped = text.trim();
45
- if (textStripped.length <= MIN_KNOWLEDGE_TEXT_LENGTH) {
46
- issues.push(`knowledge_text 过短(当前 ${textStripped.length} 字,需要 > ${MIN_KNOWLEDGE_TEXT_LENGTH} 字)`);
47
- }
48
- }
49
- /** 校验 RewriteOutput 字段一致性和合理性。 */
50
- function validateRewriteOutput(output, originalTask) {
51
- const issues = [];
52
- // 校验 confidence 范围
53
- const confidence = output.confidence ?? 0.0;
54
- if (!(confidence >= 0.0 && confidence <= 1.0)) {
55
- issues.push(`confidence 越界(当前 ${confidence},需要 0.0-1.0)`);
56
- }
57
- // 校验 rewrite_reason
58
- const reasonStripped = (output.rewriteReason ?? '').trim();
59
- if (!reasonStripped) {
60
- issues.push('rewrite_reason 为空');
61
- }
62
- else if (reasonStripped.length > MAX_REWRITE_REASON_LENGTH) {
63
- issues.push(`rewrite_reason 过长(当前 ${reasonStripped.length} 字,需要 ≤ ${MAX_REWRITE_REASON_LENGTH} 字)`);
64
- }
65
- // 按 action 分类校验
66
- switch (output.action) {
67
- case types_1.RewriteAction.NO_REWRITE:
68
- if (output.rewrittenTask && output.rewrittenTask.trim()) {
69
- issues.push(`action=NO_REWRITE 不应有 rewritten_task(当前 ${JSON.stringify(output.rewrittenTask)})`);
70
- }
71
- if (output.knowledgeText && output.knowledgeText.trim()) {
72
- issues.push(`action=NO_REWRITE 不应有 knowledge_text(当前长度 ${output.knowledgeText.length})`);
73
- }
74
- break;
75
- case types_1.RewriteAction.REWRITE_TASK:
76
- validateRewrittenTask(output, originalTask, issues);
77
- if (output.knowledgeText && output.knowledgeText.trim()) {
78
- issues.push(`action=REWRITE_TASK 不应有 knowledge_text(当前长度 ${output.knowledgeText.length})`);
79
- }
80
- break;
81
- case types_1.RewriteAction.ADD_KNOWLEDGE:
82
- validateKnowledgeText(output, issues);
83
- break;
84
- case types_1.RewriteAction.BOTH:
85
- validateRewrittenTask(output, originalTask, issues);
86
- validateKnowledgeText(output, issues);
87
- break;
88
- }
89
- if (issues.length > 0) {
90
- const reason = issues.join('; ');
91
- logger_1.logger.warn(`[Guardrail] validateRewriteOutput tripwire: ${reason}`);
92
- return { tripwireTriggered: true, outputInfo: { reason } };
93
- }
94
- return { tripwireTriggered: false, outputInfo: {} };
95
- }
@@ -1,56 +0,0 @@
1
- "use strict";
2
- /**
3
- * 根因→改写决策的二元门判定 —
4
- *
5
- * decideAction(rootCauseCategory, subCategory) -> RewriteDecision
6
- * 根据归因 Agent 输出的一级根因,执行二元门判定:是否进入改写路径。
7
- * 进入 REWRITE 侧后,由 LLM 自决子动作(rewrite_task/add_knowledge/both)。
8
- *
9
- * 二元门决策表:
10
- * - 应用问题/环境问题/无问题 → NO_REWRITE(真 bug / 需人工介入 / 已通过)
11
- * - 用例问题/Agent问题(任意 sub_category) → REWRITE(进入改写路径)
12
- * - 未知 category / None / 空 → NO_REWRITE(保守终止安全门)
13
- */
14
- Object.defineProperty(exports, "__esModule", { value: true });
15
- exports.decideAction = decideAction;
16
- const types_1 = require("./types");
17
- /**
18
- * 不可改写的根因 category 集合。
19
- * Node.js ReportAnalyzerAgent 使用英文标签(RootCauseCategory enum 值),
20
- * 对应 的 {应用问题, 环境问题, 无问题}。Node.js 无独立 "No Issue" 类别
21
- * (通过/无问题在 loop Step 3 PASS 检查先行拦截)。
22
- */
23
- const _CATEGORY_CN_TO_EN = {
24
- '应用问题': 'Application Issue',
25
- 'Agent问题': 'Agent Issue',
26
- '用例问题': 'Test Case Issue',
27
- '环境问题': 'Environment Issue',
28
- '无问题': 'No Issue',
29
- };
30
- function normalizeCategory(cat) {
31
- return _CATEGORY_CN_TO_EN[cat] ?? cat;
32
- }
33
- const NO_REWRITE_CATEGORIES = new Set(['Application Issue', 'Environment Issue', 'No Issue']);
34
- /** 触发改写的根因 category 集合(对应 {用例问题, Agent问题})。 */
35
- const REWRITE_CATEGORIES = new Set(['Test Case Issue', 'Agent Issue']);
36
- /**
37
- * 二元门:根因 → 改写决策(NO_REWRITE vs REWRITE)。
38
- *
39
- * 输入为 Node.js ReportAnalyzerAgent 的英文 category 标签。
40
- * None-safe:所有输入统一 strip,null/空字符串均安全处理。
41
- * 保守终止安全门:未知 category → NO_REWRITE,防止对未知根因盲目改写。
42
- *
43
- * @param rootCauseCategory 一级根因分类(英文标签:Application/Agent/Test Case/Environment Issue)
44
- * @param _subCategory 二级根因分类(二元门不依赖此字段,保留以兼容调用方签名)
45
- */
46
- function decideAction(rootCauseCategory, _subCategory) {
47
- const cat = normalizeCategory((rootCauseCategory ?? '').trim());
48
- if (NO_REWRITE_CATEGORIES.has(cat)) {
49
- return types_1.RewriteDecision.NO_REWRITE;
50
- }
51
- if (REWRITE_CATEGORIES.has(cat)) {
52
- return types_1.RewriteDecision.REWRITE;
53
- }
54
- // 未知 category / None / 空 → NO_REWRITE(保守终止安全门)
55
- return types_1.RewriteDecision.NO_REWRITE;
56
- }
@@ -1,121 +0,0 @@
1
- "use strict";
2
- /**
3
- * LLM 文本输出 -> RewriteOutput 解析(内容驱动) —
4
- *
5
- * 从 LLM 的 Markdown 文本(## 分节)提取结构化数据并映射为 RewriteOutput。
6
- * 动作由内容推断(非 LLM 显式声明):
7
- * - rewritten_task 非空 + knowledge_text 非空 -> BOTH
8
- * - 仅 rewritten_task 非空 -> REWRITE_TASK
9
- * - 仅 knowledge_text 非空 -> ADD_KNOWLEDGE
10
- * - 两者均空 -> null(无可用内容,解析失败触发重试)
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.parseRewriteResult = parseRewriteResult;
14
- const logger_1 = require("../../../common/logger");
15
- const types_1 = require("./types");
16
- const CONFIDENCE_TEXT_MAP = { 高: 0.85, 中: 0.6, 低: 0.3 };
17
- const NA_TOKENS = new Set(['N/A', 'NA', '无', '(无)', 'NONE']);
18
- function parseConfidence(text) {
19
- if (!text)
20
- return 0.0;
21
- let firstLine = '';
22
- for (const raw of text.split('\n')) {
23
- const stripped = raw.trim();
24
- if (stripped) {
25
- firstLine = stripped;
26
- break;
27
- }
28
- }
29
- if (!firstLine)
30
- return 0.0;
31
- if (firstLine in CONFIDENCE_TEXT_MAP)
32
- return CONFIDENCE_TEXT_MAP[firstLine];
33
- if (firstLine.endsWith('%')) {
34
- const n = Number(firstLine.slice(0, -1));
35
- if (!Number.isNaN(n))
36
- return n / 100.0;
37
- return 0.0;
38
- }
39
- const val = Number(firstLine);
40
- if (Number.isNaN(val))
41
- return 0.0;
42
- if (val >= 0.0 && val <= 1.0)
43
- return val;
44
- if (val >= 0.0 && val <= 100.0)
45
- return val / 100.0;
46
- return 0.0;
47
- }
48
- function parseKnowledgeText(text) {
49
- const t = text.trim();
50
- if (!t || NA_TOKENS.has(t.toUpperCase()))
51
- return '';
52
- return t;
53
- }
54
- function extractSections(text) {
55
- const sections = {};
56
- // 按 ## 分节(行首)
57
- const parts = text.split(/^## /m);
58
- for (let i = 1; i < parts.length; i++) {
59
- const part = parts[i];
60
- const lines = part.split('\n');
61
- const heading = lines[0].trim();
62
- const body = lines.slice(1).join('\n').trim();
63
- sections[heading] = body;
64
- }
65
- return sections;
66
- }
67
- function inferAction(rewrittenTask, knowledgeText) {
68
- const hasTask = rewrittenTask !== null;
69
- const hasKnowledge = !!knowledgeText;
70
- if (hasTask && hasKnowledge)
71
- return types_1.RewriteAction.BOTH;
72
- if (hasTask)
73
- return types_1.RewriteAction.REWRITE_TASK;
74
- if (hasKnowledge)
75
- return types_1.RewriteAction.ADD_KNOWLEDGE;
76
- return null;
77
- }
78
- /** 从 LLM Markdown 输出解析 RewriteOutput。失败返回 null(触发重试)。 */
79
- function parseRewriteResult(finalText) {
80
- if (!finalText || !finalText.trim()) {
81
- logger_1.logger.debug('[parseRewriteResult] 空输入');
82
- return null;
83
- }
84
- const sections = extractSections(finalText);
85
- if (Object.keys(sections).length === 0) {
86
- logger_1.logger.debug('[parseRewriteResult] 无 ## 分节,不是 Markdown 格式');
87
- return null;
88
- }
89
- // 1. 改写后的任务(N/A / 空 -> null)
90
- const rewrittenTaskText = (sections['改写后的任务'] ?? '').trim();
91
- let rewrittenTask = null;
92
- if (rewrittenTaskText && !NA_TOKENS.has(rewrittenTaskText.toUpperCase())) {
93
- rewrittenTask = rewrittenTaskText;
94
- }
95
- // 2. 知识库文本(兼容旧 section 名"知识库条目")
96
- let knowledgeSection = (sections['知识库文本'] ?? '').trim();
97
- if (!knowledgeSection)
98
- knowledgeSection = (sections['知识库条目'] ?? '').trim();
99
- const knowledgeText = parseKnowledgeText(knowledgeSection);
100
- // 3. 据内容推断动作;两者均空 -> null(触发重试)
101
- const action = inferAction(rewrittenTask, knowledgeText);
102
- if (action === null) {
103
- logger_1.logger.debug('[parseRewriteResult] 改写后的任务与知识库文本均为空,无可用内容');
104
- return null;
105
- }
106
- // 4. 改写理由
107
- const rewriteReason = (sections['改写理由'] ?? '').trim();
108
- // 5. 置信度
109
- const confidence = parseConfidence((sections['置信度'] ?? '').trim());
110
- logger_1.logger.info(`[parseRewriteResult] 解析成功: action=${action}(推断), ` +
111
- `rewritten_task=${rewrittenTask ? 'yes' : 'no'}, ` +
112
- `knowledge_text_len=${knowledgeText.length}, confidence=${confidence}`);
113
- return {
114
- action,
115
- rewrittenTask,
116
- knowledgeText,
117
- rewriteReason,
118
- confidence,
119
- rawLlmOutput: finalText,
120
- };
121
- }
@@ -1,37 +0,0 @@
1
- "use strict";
2
- /**
3
- * 改写 Agent 类型定义 —
4
- */
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.RewriteAction = exports.RewriteDecision = void 0;
7
- exports.rewriteOutputToDict = rewriteOutputToDict;
8
- /** 二元门决策枚举(代码硬门,基于归因 category)。由 mapping.decideAction() 返回。 */
9
- var RewriteDecision;
10
- (function (RewriteDecision) {
11
- /** 不改写(应用问题/环境问题/无问题/未知 category/None/空) */
12
- RewriteDecision["NO_REWRITE"] = "no_rewrite";
13
- /** 需要改写(用例问题/Agent问题,任意 sub_category) */
14
- RewriteDecision["REWRITE"] = "rewrite";
15
- })(RewriteDecision || (exports.RewriteDecision = RewriteDecision = {}));
16
- /** 改写动作枚举(由 LLM 在 REWRITE 路径自决)。 */
17
- var RewriteAction;
18
- (function (RewriteAction) {
19
- /** 无需改写(二元门 early-return 路径使用) */
20
- RewriteAction["NO_REWRITE"] = "no_rewrite";
21
- /** 改写 task 字符串(用例问题倾向) */
22
- RewriteAction["REWRITE_TASK"] = "rewrite_task";
23
- /** 追加知识文本到 task(Agent 执行性问题倾向) */
24
- RewriteAction["ADD_KNOWLEDGE"] = "add_knowledge";
25
- /** 同时改写 task + 追加知识文本(Agent 理解性问题倾向) */
26
- RewriteAction["BOTH"] = "both";
27
- })(RewriteAction || (exports.RewriteAction = RewriteAction = {}));
28
- /** 序列化 RewriteOutput 为普通对象(写入 LoopResult JSON,不含 rawLlmOutput)。 */
29
- function rewriteOutputToDict(out) {
30
- return {
31
- action: out.action,
32
- rewritten_task: out.rewrittenTask ?? null,
33
- knowledge_text: out.knowledgeText ?? '',
34
- rewrite_reason: out.rewriteReason ?? '',
35
- confidence: out.confidence ?? 0,
36
- };
37
- }