@ai-setting/roy-agent-cli 1.5.88 → 1.5.90

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.
@@ -7320,7 +7320,7 @@ var require_dist = __commonJS((exports) => {
7320
7320
  var require_package = __commonJS((exports, module) => {
7321
7321
  module.exports = {
7322
7322
  name: "@ai-setting/roy-agent-cli",
7323
- version: "1.5.88",
7323
+ version: "1.5.90",
7324
7324
  type: "module",
7325
7325
  description: "CLI for roy-agent - Non-interactive command execution",
7326
7326
  main: "./dist/index.js",
@@ -8092,8 +8092,8 @@ class ContextHandlerService {
8092
8092
  }
8093
8093
  throw error;
8094
8094
  }
8095
- if (!compactResult.newQuery || compactResult.newQuery === query) {
8096
- logger3.error("Compact succeeded but produced no new query, terminating to avoid silent retry loop", {
8095
+ if (!compactResult.newQuery) {
8096
+ logger3.error("Compact succeeded but produced undefined query, terminating", {
8097
8097
  compactCount,
8098
8098
  query
8099
8099
  });
@@ -8185,36 +8185,14 @@ class ContextHandlerService {
8185
8185
  async compactSession(sessionId, originalQuery) {
8186
8186
  return this.compactSessionWithTwoPhases(sessionId, originalQuery);
8187
8187
  }
8188
- constructQueryWithCheckpoint(checkpoint, originalQuery) {
8189
- const parts = [];
8190
- parts.push("【会话历史摘要】");
8191
- parts.push(checkpoint.summary);
8192
- if (checkpoint.processKeyPoints.length > 0) {
8193
- parts.push("");
8194
- parts.push("【已完成的工作】");
8195
- checkpoint.processKeyPoints.forEach((point, i) => {
8196
- parts.push(`${i + 1}. ${point}`);
8197
- });
8198
- }
8199
- if (checkpoint.currentState) {
8200
- parts.push("");
8201
- parts.push("【当前状态】");
8202
- parts.push(checkpoint.currentState);
8203
- }
8204
- if (checkpoint.nextSteps.length > 0) {
8205
- parts.push("");
8206
- parts.push("【待完成的任务】");
8207
- checkpoint.nextSteps.forEach((step, i) => {
8208
- parts.push(`${i + 1}. ${step}`);
8209
- });
8210
- }
8211
- if (originalQuery) {
8212
- parts.push("");
8213
- parts.push("【用户新输入】");
8214
- parts.push(originalQuery);
8188
+ constructQueryWithCheckpoint(_checkpoint, originalQuery) {
8189
+ const MAX_QUERY_LENGTH = 4000;
8190
+ if (originalQuery && originalQuery.trim().length > 0) {
8191
+ const trimmedQuery = originalQuery.length > MAX_QUERY_LENGTH ? originalQuery.substring(0, MAX_QUERY_LENGTH) + `
8192
+ ... (原始输入共 ${originalQuery.length} 字符,已截断至 ${MAX_QUERY_LENGTH})` : originalQuery;
8193
+ return trimmedQuery;
8215
8194
  }
8216
- return parts.join(`
8217
- `);
8195
+ return "Please continue to work on the current task.";
8218
8196
  }
8219
8197
  }
8220
8198
  __legacyDecorateClassTS([
@@ -8532,10 +8510,6 @@ function createActCommand(externalEnvService) {
8532
8510
  output.error("Environment not available");
8533
8511
  process.exit(1);
8534
8512
  }
8535
- const promptComponent = env.getComponent("prompt");
8536
- if (llmComponent && promptComponent) {
8537
- sessionComponent.setSummaryComponents(promptComponent, llmComponent);
8538
- }
8539
8513
  if (coderPluginNames.includes("lsp")) {
8540
8514
  try {
8541
8515
  const enabledPlugins = coderPluginNames.filter((p) => CODER_HARNESS_PLUGINS.has(p.split(":")[0]));
@@ -8803,9 +8777,7 @@ class QueryExecutor {
8803
8777
  this.output = options.output;
8804
8778
  this.quiet = options.quiet;
8805
8779
  }
8806
- initSummaryAgent(llmComponent, promptComponent) {
8807
- this.sessionComponent.setSummaryComponents(promptComponent, llmComponent);
8808
- }
8780
+ initSummaryAgent(_llmComponent, _promptComponent) {}
8809
8781
  initStreamOutput(llmComponent, providerId = "minimax") {
8810
8782
  if (llmComponent) {
8811
8783
  const contextConfig = llmComponent.getContextThresholdConfig(providerId);
@@ -10012,9 +9984,6 @@ function createInteractiveCommand(externalEnvService) {
10012
9984
  });
10013
9985
  const sessionResult = await sessionManager.init(args.session, args.continue);
10014
9986
  const { sessionId, sessionTitle } = sessionResult;
10015
- if (llmComponent && promptComponent) {
10016
- sessionComponent.setSummaryComponents(promptComponent, llmComponent);
10017
- }
10018
9987
  const queryExecutor = new QueryExecutor({
10019
9988
  env,
10020
9989
  sessionComponent,
@@ -11049,9 +11018,7 @@ var CompactCommand = {
11049
11018
  }
11050
11019
  const llmComponent = env.getComponent("llm");
11051
11020
  const promptComponent = env.getComponent("prompt");
11052
- if (llmComponent && promptComponent) {
11053
- sessionComponent.setSummaryComponents(promptComponent, llmComponent);
11054
- } else {
11021
+ if (!llmComponent || !promptComponent) {
11055
11022
  output.error("LLMComponent or PromptComponent not available. Cannot generate checkpoint.");
11056
11023
  process.exit(1);
11057
11024
  }
@@ -12119,8 +12086,7 @@ var CreateCommand = {
12119
12086
  description: "项目路径"
12120
12087
  }).option("parent-id", {
12121
12088
  type: "number",
12122
- description: "父任务 ID(必填)。所有新任务都必须挂载到某个父任务下。使用 task_list(depth=0) 查看根任务列表。",
12123
- demandOption: true
12089
+ description: "父任务 ID(可选)。不传则创建根任务(root task)。使用 task_list(depth=0) 查看已有根任务列表。"
12124
12090
  }).option("context", {
12125
12091
  type: "string",
12126
12092
  description: "任务上下文 (JSON 字符串)"
@@ -18007,10 +17973,10 @@ class WorkflowValidator {
18007
17973
  }
18008
17974
 
18009
17975
  // src/commands/workflow/commands/add.ts
17976
+ import { validateWorkflowDefinition } from "@ai-setting/roy-agent-core/env/workflow/utils/validate-workflow-definition";
18010
17977
  import chalk63 from "chalk";
18011
17978
  import fs3 from "fs";
18012
17979
  import path6 from "path";
18013
- import { createWorkflowExtractorAgent } from "@ai-setting/roy-agent-core/env/task/plugins";
18014
17980
  async function parseWorkflowContent(content, filename) {
18015
17981
  const isYaml = filename.endsWith(".yaml") || filename.endsWith(".yml");
18016
17982
  const isJson = filename.endsWith(".json");
@@ -18151,6 +18117,15 @@ var WorkflowAddCommand = {
18151
18117
  workflowName = a.name || definition.name || path6.basename(filePath);
18152
18118
  if (a.validate) {
18153
18119
  output.log(chalk63.blue("\uD83D\uDD0D Validating workflow..."));
18120
+ const dagResult = validateWorkflowDefinition(definition);
18121
+ if (!dagResult.valid) {
18122
+ output.error(`
18123
+ ❌ Workflow validation FAILED (${dagResult.errors.length} errors found)`);
18124
+ dagResult.errors.forEach((msg, i) => {
18125
+ output.error(`[Error ${i + 1}/${dagResult.errors.length}] ${msg}`);
18126
+ });
18127
+ process.exit(1);
18128
+ }
18154
18129
  const validator = new WorkflowValidator;
18155
18130
  const result = validator.validate(definition);
18156
18131
  if (!result.valid) {
@@ -18176,12 +18151,9 @@ var WorkflowAddCommand = {
18176
18151
  output.error("AgentComponent not available");
18177
18152
  process.exit(1);
18178
18153
  }
18179
- if (!agentComponent.getAgent("workflow-extractor")) {
18180
- output.log(chalk63.gray("Auto-registering workflow-extractor agent..."));
18181
- const extractorConfig = createWorkflowExtractorAgent();
18182
- agentComponent.registerAgent(extractorConfig.name, extractorConfig);
18183
- output.log(chalk63.green(`✅ workflow-extractor agent registered
18184
- `));
18154
+ if (!agentComponent.getAgent("workflow-extract")) {
18155
+ output.error("Built-in 'workflow-extract' agent is not available. This usually means the environment was not fully initialized.");
18156
+ process.exit(1);
18185
18157
  }
18186
18158
  const prompt = `## 任务
18187
18159
  请根据以下描述,构建一个可复用的 Workflow。
@@ -18194,8 +18166,8 @@ ${a.desc}
18194
18166
  1. 先用 \`roy-agent workflow nodes\` 查看可用的节点类型
18195
18167
  2. 生成的 YAML 必须通过 \`roy-agent workflow validate --yaml "<yaml>"\` 验证
18196
18168
  3. 验证通过后才输出最终 YAML`;
18197
- output.log(chalk63.gray("Running workflow-extractor agent..."));
18198
- const result = await agentComponent.run("workflow-extractor", prompt);
18169
+ output.log(chalk63.gray("Running workflow-extract agent..."));
18170
+ const result = await agentComponent.run("workflow-extract", prompt);
18199
18171
  const agentOutput = result.finalText || "";
18200
18172
  definition = parseYamlFromAgentOutput(agentOutput);
18201
18173
  if (definition === null) {
@@ -18209,6 +18181,16 @@ Agent output:
18209
18181
  if (a.validate) {
18210
18182
  output.log(chalk63.blue(`
18211
18183
  \uD83D\uDD0D Validating generated workflow...`));
18184
+ const dagResult = validateWorkflowDefinition(definition);
18185
+ if (!dagResult.valid) {
18186
+ output.error(`
18187
+ ❌ Generated workflow validation FAILED (${dagResult.errors.length} errors found)`);
18188
+ dagResult.errors.forEach((msg, i) => {
18189
+ output.error(`[Error ${i + 1}/${dagResult.errors.length}] ${msg}`);
18190
+ });
18191
+ output.log(chalk63.yellow("请修正描述后重新尝试,或使用 --file 选项直接提供 YAML"));
18192
+ process.exit(1);
18193
+ }
18212
18194
  const validator = new WorkflowValidator;
18213
18195
  const result2 = validator.validate(definition);
18214
18196
  if (!result2.valid) {
package/dist/index.js CHANGED
@@ -7319,7 +7319,7 @@ var require_dist = __commonJS((exports) => {
7319
7319
  var require_package = __commonJS((exports, module) => {
7320
7320
  module.exports = {
7321
7321
  name: "@ai-setting/roy-agent-cli",
7322
- version: "1.5.88",
7322
+ version: "1.5.90",
7323
7323
  type: "module",
7324
7324
  description: "CLI for roy-agent - Non-interactive command execution",
7325
7325
  main: "./dist/index.js",
@@ -8091,8 +8091,8 @@ class ContextHandlerService {
8091
8091
  }
8092
8092
  throw error;
8093
8093
  }
8094
- if (!compactResult.newQuery || compactResult.newQuery === query) {
8095
- logger3.error("Compact succeeded but produced no new query, terminating to avoid silent retry loop", {
8094
+ if (!compactResult.newQuery) {
8095
+ logger3.error("Compact succeeded but produced undefined query, terminating", {
8096
8096
  compactCount,
8097
8097
  query
8098
8098
  });
@@ -8184,36 +8184,14 @@ class ContextHandlerService {
8184
8184
  async compactSession(sessionId, originalQuery) {
8185
8185
  return this.compactSessionWithTwoPhases(sessionId, originalQuery);
8186
8186
  }
8187
- constructQueryWithCheckpoint(checkpoint, originalQuery) {
8188
- const parts = [];
8189
- parts.push("【会话历史摘要】");
8190
- parts.push(checkpoint.summary);
8191
- if (checkpoint.processKeyPoints.length > 0) {
8192
- parts.push("");
8193
- parts.push("【已完成的工作】");
8194
- checkpoint.processKeyPoints.forEach((point, i) => {
8195
- parts.push(`${i + 1}. ${point}`);
8196
- });
8197
- }
8198
- if (checkpoint.currentState) {
8199
- parts.push("");
8200
- parts.push("【当前状态】");
8201
- parts.push(checkpoint.currentState);
8202
- }
8203
- if (checkpoint.nextSteps.length > 0) {
8204
- parts.push("");
8205
- parts.push("【待完成的任务】");
8206
- checkpoint.nextSteps.forEach((step, i) => {
8207
- parts.push(`${i + 1}. ${step}`);
8208
- });
8209
- }
8210
- if (originalQuery) {
8211
- parts.push("");
8212
- parts.push("【用户新输入】");
8213
- parts.push(originalQuery);
8187
+ constructQueryWithCheckpoint(_checkpoint, originalQuery) {
8188
+ const MAX_QUERY_LENGTH = 4000;
8189
+ if (originalQuery && originalQuery.trim().length > 0) {
8190
+ const trimmedQuery = originalQuery.length > MAX_QUERY_LENGTH ? originalQuery.substring(0, MAX_QUERY_LENGTH) + `
8191
+ ... (原始输入共 ${originalQuery.length} 字符,已截断至 ${MAX_QUERY_LENGTH})` : originalQuery;
8192
+ return trimmedQuery;
8214
8193
  }
8215
- return parts.join(`
8216
- `);
8194
+ return "Please continue to work on the current task.";
8217
8195
  }
8218
8196
  }
8219
8197
  __legacyDecorateClassTS([
@@ -8531,10 +8509,6 @@ function createActCommand(externalEnvService) {
8531
8509
  output.error("Environment not available");
8532
8510
  process.exit(1);
8533
8511
  }
8534
- const promptComponent = env.getComponent("prompt");
8535
- if (llmComponent && promptComponent) {
8536
- sessionComponent.setSummaryComponents(promptComponent, llmComponent);
8537
- }
8538
8512
  if (coderPluginNames.includes("lsp")) {
8539
8513
  try {
8540
8514
  const enabledPlugins = coderPluginNames.filter((p) => CODER_HARNESS_PLUGINS.has(p.split(":")[0]));
@@ -8802,9 +8776,7 @@ class QueryExecutor {
8802
8776
  this.output = options.output;
8803
8777
  this.quiet = options.quiet;
8804
8778
  }
8805
- initSummaryAgent(llmComponent, promptComponent) {
8806
- this.sessionComponent.setSummaryComponents(promptComponent, llmComponent);
8807
- }
8779
+ initSummaryAgent(_llmComponent, _promptComponent) {}
8808
8780
  initStreamOutput(llmComponent, providerId = "minimax") {
8809
8781
  if (llmComponent) {
8810
8782
  const contextConfig = llmComponent.getContextThresholdConfig(providerId);
@@ -10011,9 +9983,6 @@ function createInteractiveCommand(externalEnvService) {
10011
9983
  });
10012
9984
  const sessionResult = await sessionManager.init(args.session, args.continue);
10013
9985
  const { sessionId, sessionTitle } = sessionResult;
10014
- if (llmComponent && promptComponent) {
10015
- sessionComponent.setSummaryComponents(promptComponent, llmComponent);
10016
- }
10017
9986
  const queryExecutor = new QueryExecutor({
10018
9987
  env,
10019
9988
  sessionComponent,
@@ -11048,9 +11017,7 @@ var CompactCommand = {
11048
11017
  }
11049
11018
  const llmComponent = env.getComponent("llm");
11050
11019
  const promptComponent = env.getComponent("prompt");
11051
- if (llmComponent && promptComponent) {
11052
- sessionComponent.setSummaryComponents(promptComponent, llmComponent);
11053
- } else {
11020
+ if (!llmComponent || !promptComponent) {
11054
11021
  output.error("LLMComponent or PromptComponent not available. Cannot generate checkpoint.");
11055
11022
  process.exit(1);
11056
11023
  }
@@ -12118,8 +12085,7 @@ var CreateCommand = {
12118
12085
  description: "项目路径"
12119
12086
  }).option("parent-id", {
12120
12087
  type: "number",
12121
- description: "父任务 ID(必填)。所有新任务都必须挂载到某个父任务下。使用 task_list(depth=0) 查看根任务列表。",
12122
- demandOption: true
12088
+ description: "父任务 ID(可选)。不传则创建根任务(root task)。使用 task_list(depth=0) 查看已有根任务列表。"
12123
12089
  }).option("context", {
12124
12090
  type: "string",
12125
12091
  description: "任务上下文 (JSON 字符串)"
@@ -18006,10 +17972,10 @@ class WorkflowValidator {
18006
17972
  }
18007
17973
 
18008
17974
  // src/commands/workflow/commands/add.ts
17975
+ import { validateWorkflowDefinition } from "@ai-setting/roy-agent-core/env/workflow/utils/validate-workflow-definition";
18009
17976
  import chalk63 from "chalk";
18010
17977
  import fs3 from "fs";
18011
17978
  import path6 from "path";
18012
- import { createWorkflowExtractorAgent } from "@ai-setting/roy-agent-core/env/task/plugins";
18013
17979
  async function parseWorkflowContent(content, filename) {
18014
17980
  const isYaml = filename.endsWith(".yaml") || filename.endsWith(".yml");
18015
17981
  const isJson = filename.endsWith(".json");
@@ -18150,6 +18116,15 @@ var WorkflowAddCommand = {
18150
18116
  workflowName = a.name || definition.name || path6.basename(filePath);
18151
18117
  if (a.validate) {
18152
18118
  output.log(chalk63.blue("\uD83D\uDD0D Validating workflow..."));
18119
+ const dagResult = validateWorkflowDefinition(definition);
18120
+ if (!dagResult.valid) {
18121
+ output.error(`
18122
+ ❌ Workflow validation FAILED (${dagResult.errors.length} errors found)`);
18123
+ dagResult.errors.forEach((msg, i) => {
18124
+ output.error(`[Error ${i + 1}/${dagResult.errors.length}] ${msg}`);
18125
+ });
18126
+ process.exit(1);
18127
+ }
18153
18128
  const validator = new WorkflowValidator;
18154
18129
  const result = validator.validate(definition);
18155
18130
  if (!result.valid) {
@@ -18175,12 +18150,9 @@ var WorkflowAddCommand = {
18175
18150
  output.error("AgentComponent not available");
18176
18151
  process.exit(1);
18177
18152
  }
18178
- if (!agentComponent.getAgent("workflow-extractor")) {
18179
- output.log(chalk63.gray("Auto-registering workflow-extractor agent..."));
18180
- const extractorConfig = createWorkflowExtractorAgent();
18181
- agentComponent.registerAgent(extractorConfig.name, extractorConfig);
18182
- output.log(chalk63.green(`✅ workflow-extractor agent registered
18183
- `));
18153
+ if (!agentComponent.getAgent("workflow-extract")) {
18154
+ output.error("Built-in 'workflow-extract' agent is not available. This usually means the environment was not fully initialized.");
18155
+ process.exit(1);
18184
18156
  }
18185
18157
  const prompt = `## 任务
18186
18158
  请根据以下描述,构建一个可复用的 Workflow。
@@ -18193,8 +18165,8 @@ ${a.desc}
18193
18165
  1. 先用 \`roy-agent workflow nodes\` 查看可用的节点类型
18194
18166
  2. 生成的 YAML 必须通过 \`roy-agent workflow validate --yaml "<yaml>"\` 验证
18195
18167
  3. 验证通过后才输出最终 YAML`;
18196
- output.log(chalk63.gray("Running workflow-extractor agent..."));
18197
- const result = await agentComponent.run("workflow-extractor", prompt);
18168
+ output.log(chalk63.gray("Running workflow-extract agent..."));
18169
+ const result = await agentComponent.run("workflow-extract", prompt);
18198
18170
  const agentOutput = result.finalText || "";
18199
18171
  definition = parseYamlFromAgentOutput(agentOutput);
18200
18172
  if (definition === null) {
@@ -18208,6 +18180,16 @@ Agent output:
18208
18180
  if (a.validate) {
18209
18181
  output.log(chalk63.blue(`
18210
18182
  \uD83D\uDD0D Validating generated workflow...`));
18183
+ const dagResult = validateWorkflowDefinition(definition);
18184
+ if (!dagResult.valid) {
18185
+ output.error(`
18186
+ ❌ Generated workflow validation FAILED (${dagResult.errors.length} errors found)`);
18187
+ dagResult.errors.forEach((msg, i) => {
18188
+ output.error(`[Error ${i + 1}/${dagResult.errors.length}] ${msg}`);
18189
+ });
18190
+ output.log(chalk63.yellow("请修正描述后重新尝试,或使用 --file 选项直接提供 YAML"));
18191
+ process.exit(1);
18192
+ }
18211
18193
  const validator = new WorkflowValidator;
18212
18194
  const result2 = validator.validate(definition);
18213
18195
  if (!result2.valid) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-cli",
3
- "version": "1.5.88",
3
+ "version": "1.5.90",
4
4
  "type": "module",
5
5
  "description": "CLI for roy-agent - Non-interactive command execution",
6
6
  "main": "./dist/index.js",