@ai-setting/roy-agent-cli 1.5.44 → 1.5.46
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/bin/roy-agent.js +84 -64
- package/dist/index.js +84 -64
- package/dist/roy-agent-linux-x64/bin/roy-agent +0 -0
- package/package.json +4 -4
package/dist/bin/roy-agent.js
CHANGED
|
@@ -81,6 +81,7 @@ function abortStream() {
|
|
|
81
81
|
|
|
82
82
|
class StreamOutputService {
|
|
83
83
|
fullText = "";
|
|
84
|
+
fullReasoning = "";
|
|
84
85
|
options;
|
|
85
86
|
usageInfo;
|
|
86
87
|
contextWindow;
|
|
@@ -91,6 +92,9 @@ class StreamOutputService {
|
|
|
91
92
|
constructor(options = {}) {
|
|
92
93
|
this.options = options;
|
|
93
94
|
}
|
|
95
|
+
setOptions(options) {
|
|
96
|
+
this.options = { ...this.options, ...options };
|
|
97
|
+
}
|
|
94
98
|
setContextInfo(window, threshold) {
|
|
95
99
|
this.contextWindow = window;
|
|
96
100
|
this.contextThreshold = threshold;
|
|
@@ -119,9 +123,15 @@ ${COLORS.system("[已中断]")}
|
|
|
119
123
|
case "llm.reasoning":
|
|
120
124
|
this.handleReasoning(payload);
|
|
121
125
|
break;
|
|
122
|
-
case "
|
|
126
|
+
case "tool.call":
|
|
123
127
|
this.handleToolCall(payload);
|
|
124
128
|
break;
|
|
129
|
+
case "tool.result":
|
|
130
|
+
this.handleToolResult(payload);
|
|
131
|
+
break;
|
|
132
|
+
case "tool.error":
|
|
133
|
+
this.handleToolError(payload);
|
|
134
|
+
break;
|
|
125
135
|
case "llm.completed":
|
|
126
136
|
this.handleCompleted(payload);
|
|
127
137
|
break;
|
|
@@ -130,11 +140,23 @@ ${COLORS.system("[已中断]")}
|
|
|
130
140
|
handleStart(payload) {
|
|
131
141
|
if (payload.metadata?.model) {}
|
|
132
142
|
}
|
|
133
|
-
|
|
143
|
+
clearThinkingPlaceholder() {
|
|
134
144
|
if (!this.thinkingPrinted) {
|
|
135
145
|
this.thinkingPrinted = true;
|
|
136
146
|
process.stdout.write("\r" + " ".repeat(20) + "\r");
|
|
137
147
|
}
|
|
148
|
+
}
|
|
149
|
+
closeReasoningBlock() {
|
|
150
|
+
if (this.reasoningStarted) {
|
|
151
|
+
process.stdout.write(COLORS.reasoning(`
|
|
152
|
+
└` + "─".repeat(20) + `
|
|
153
|
+
`));
|
|
154
|
+
this.reasoningStarted = false;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
handleText(payload) {
|
|
158
|
+
this.clearThinkingPlaceholder();
|
|
159
|
+
this.closeReasoningBlock();
|
|
138
160
|
const text = payload.delta ?? payload.content ?? "";
|
|
139
161
|
if (!text)
|
|
140
162
|
return;
|
|
@@ -147,11 +169,16 @@ ${COLORS.system("[已中断]")}
|
|
|
147
169
|
this.fullText += text;
|
|
148
170
|
}
|
|
149
171
|
handleReasoning(payload) {
|
|
172
|
+
if (payload.phase === "end") {
|
|
173
|
+
this.closeReasoningBlock();
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
150
176
|
if (!this.options.showReasoning)
|
|
151
177
|
return;
|
|
152
|
-
const
|
|
153
|
-
if (!
|
|
178
|
+
const delta = payload.delta ?? this.extractReasoningDelta(payload.content);
|
|
179
|
+
if (!delta)
|
|
154
180
|
return;
|
|
181
|
+
this.clearThinkingPlaceholder();
|
|
155
182
|
if (!this.reasoningStarted) {
|
|
156
183
|
this.reasoningStarted = true;
|
|
157
184
|
process.stdout.write(`
|
|
@@ -159,26 +186,48 @@ ${COLORS.system("[已中断]")}
|
|
|
159
186
|
` + COLORS.reasoning("┌─ 思考过程 ─") + `
|
|
160
187
|
`);
|
|
161
188
|
}
|
|
162
|
-
process.stdout.write(COLORS.reasoning(
|
|
189
|
+
process.stdout.write(COLORS.reasoning(delta));
|
|
190
|
+
this.fullReasoning += delta;
|
|
191
|
+
}
|
|
192
|
+
extractReasoningDelta(content) {
|
|
193
|
+
if (!content)
|
|
194
|
+
return "";
|
|
195
|
+
if (content.startsWith(this.fullReasoning)) {
|
|
196
|
+
return content.slice(this.fullReasoning.length);
|
|
197
|
+
}
|
|
198
|
+
return "";
|
|
163
199
|
}
|
|
164
200
|
handleToolCall(payload) {
|
|
165
201
|
if (!this.options.showToolCalls)
|
|
166
202
|
return;
|
|
167
|
-
const
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
203
|
+
const name = payload.name ?? "unknown";
|
|
204
|
+
const argsStr = payload.arguments ? JSON.stringify(payload.arguments) : "";
|
|
205
|
+
this.clearThinkingPlaceholder();
|
|
206
|
+
this.closeReasoningBlock();
|
|
207
|
+
process.stdout.write(`
|
|
208
|
+
` + COLORS.toolCall(`\uD83D\uDD27 [Tool] ${name}${argsStr ? ` ${argsStr}` : ""}`) + `
|
|
209
|
+
`);
|
|
210
|
+
}
|
|
211
|
+
handleToolResult(payload) {
|
|
212
|
+
if (!this.options.showToolResults)
|
|
213
|
+
return;
|
|
214
|
+
const name = payload.name ?? "unknown";
|
|
215
|
+
const result = payload.result?.output ?? payload.result?.error ?? "无输出";
|
|
216
|
+
process.stdout.write(`
|
|
217
|
+
` + COLORS.toolResult(`\uD83D\uDCE4 ${name}: ${String(result).substring(0, 200)}`) + `
|
|
218
|
+
`);
|
|
219
|
+
}
|
|
220
|
+
handleToolError(payload) {
|
|
221
|
+
if (!this.options.showToolCalls && !this.options.showToolResults)
|
|
222
|
+
return;
|
|
223
|
+
process.stdout.write(`
|
|
224
|
+
` + COLORS.error(`❌ ${payload.toolName ?? "unknown"}: ${payload.error ?? "unknown error"}`) + `
|
|
171
225
|
`);
|
|
172
|
-
}
|
|
173
226
|
}
|
|
174
227
|
handleCompleted(payload) {
|
|
175
228
|
process.stdout.write(`
|
|
176
229
|
`);
|
|
177
|
-
|
|
178
|
-
process.stdout.write(COLORS.reasoning("└" + "─".repeat(20) + `
|
|
179
|
-
`));
|
|
180
|
-
this.reasoningStarted = false;
|
|
181
|
-
}
|
|
230
|
+
this.closeReasoningBlock();
|
|
182
231
|
const metadata = payload.metadata;
|
|
183
232
|
if (metadata?.model || metadata?.usage) {
|
|
184
233
|
let modelName = metadata.model || "";
|
|
@@ -221,6 +270,7 @@ ${COLORS.system("[已中断]")}
|
|
|
221
270
|
}
|
|
222
271
|
reset() {
|
|
223
272
|
this.fullText = "";
|
|
273
|
+
this.fullReasoning = "";
|
|
224
274
|
this.usageInfo = undefined;
|
|
225
275
|
this.isFirstText = true;
|
|
226
276
|
this.reasoningStarted = false;
|
|
@@ -7240,7 +7290,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
7240
7290
|
var require_package = __commonJS((exports, module) => {
|
|
7241
7291
|
module.exports = {
|
|
7242
7292
|
name: "@ai-setting/roy-agent-cli",
|
|
7243
|
-
version: "1.5.
|
|
7293
|
+
version: "1.5.46",
|
|
7244
7294
|
type: "module",
|
|
7245
7295
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
7246
7296
|
main: "./dist/index.js",
|
|
@@ -7266,9 +7316,9 @@ var require_package = __commonJS((exports, module) => {
|
|
|
7266
7316
|
typecheck: "npx tsc --noEmit --skipLibCheck"
|
|
7267
7317
|
},
|
|
7268
7318
|
dependencies: {
|
|
7269
|
-
"@ai-setting/roy-agent-coder-harness": "^1.5.
|
|
7270
|
-
"@ai-setting/roy-agent-core": "^1.5.
|
|
7271
|
-
"@ai-setting/roy-agent-ontology-harness": "^1.5.
|
|
7319
|
+
"@ai-setting/roy-agent-coder-harness": "^1.5.46",
|
|
7320
|
+
"@ai-setting/roy-agent-core": "^1.5.46",
|
|
7321
|
+
"@ai-setting/roy-agent-ontology-harness": "^1.5.46",
|
|
7272
7322
|
chalk: "^5.6.2",
|
|
7273
7323
|
commander: "^14.0.3",
|
|
7274
7324
|
effect: "^3.21.2",
|
|
@@ -8256,11 +8306,11 @@ function createActCommand(externalEnvService) {
|
|
|
8256
8306
|
alias: "r",
|
|
8257
8307
|
describe: "显示 AI 思考过程",
|
|
8258
8308
|
type: "boolean",
|
|
8259
|
-
default:
|
|
8309
|
+
default: true
|
|
8260
8310
|
}).option("tool-calls", {
|
|
8261
8311
|
describe: "显示工具调用",
|
|
8262
8312
|
type: "boolean",
|
|
8263
|
-
default:
|
|
8313
|
+
default: true
|
|
8264
8314
|
}).option("tool-results", {
|
|
8265
8315
|
describe: "显示工具执行结果",
|
|
8266
8316
|
type: "boolean",
|
|
@@ -8446,32 +8496,15 @@ function createActCommand(externalEnvService) {
|
|
|
8446
8496
|
"llm.start",
|
|
8447
8497
|
"llm.text",
|
|
8448
8498
|
"llm.reasoning",
|
|
8449
|
-
"llm.tool_call",
|
|
8450
8499
|
"llm.completed",
|
|
8451
8500
|
"llm.error",
|
|
8501
|
+
"tool.call",
|
|
8452
8502
|
"tool.result",
|
|
8453
8503
|
"tool.error",
|
|
8454
8504
|
"context.threshold_exceeded",
|
|
8455
8505
|
"context.compacting",
|
|
8456
8506
|
"context.compacted"
|
|
8457
8507
|
], (event) => {
|
|
8458
|
-
if (event.type === "llm.tool_call" && args.toolCalls) {
|
|
8459
|
-
const payload = event.payload;
|
|
8460
|
-
output.log(`\uD83D\uDD27 ${payload.toolCall.name}`);
|
|
8461
|
-
output.log(` ${payload.toolCall.arguments}`);
|
|
8462
|
-
return;
|
|
8463
|
-
}
|
|
8464
|
-
if (event.type === "tool.result" && args.toolResults) {
|
|
8465
|
-
const payload = event.payload;
|
|
8466
|
-
const result2 = payload.result?.output ?? payload.result?.error ?? "无输出";
|
|
8467
|
-
output.log(`\uD83D\uDCE4 ${payload.name}: ${String(result2).substring(0, 200)}`);
|
|
8468
|
-
return;
|
|
8469
|
-
}
|
|
8470
|
-
if (event.type === "tool.error") {
|
|
8471
|
-
const payload = event.payload;
|
|
8472
|
-
output.error(`❌ ${payload.toolName ?? "unknown"}: ${payload.error ?? "unknown error"}`);
|
|
8473
|
-
return;
|
|
8474
|
-
}
|
|
8475
8508
|
if (event.type === "context.threshold_exceeded" && !quiet) {
|
|
8476
8509
|
const payload = event.payload;
|
|
8477
8510
|
output.warn(`⚙ 上下文阈值 (${payload.totalTokens}/${payload.contextWindow})`);
|
|
@@ -8635,8 +8668,8 @@ class QueryExecutor {
|
|
|
8635
8668
|
streamService = null;
|
|
8636
8669
|
unsubscribe = null;
|
|
8637
8670
|
streamOptions = {
|
|
8638
|
-
showReasoning:
|
|
8639
|
-
showToolCalls:
|
|
8671
|
+
showReasoning: true,
|
|
8672
|
+
showToolCalls: true,
|
|
8640
8673
|
showToolResults: false
|
|
8641
8674
|
};
|
|
8642
8675
|
_pendingContextConfig = null;
|
|
@@ -8656,10 +8689,13 @@ class QueryExecutor {
|
|
|
8656
8689
|
}
|
|
8657
8690
|
}
|
|
8658
8691
|
subscribeToEvents(options) {
|
|
8692
|
+
this.streamOptions = options;
|
|
8693
|
+
if (this.streamService) {
|
|
8694
|
+
this.streamService.setOptions(options);
|
|
8695
|
+
}
|
|
8659
8696
|
if (this.unsubscribe) {
|
|
8660
8697
|
return;
|
|
8661
8698
|
}
|
|
8662
|
-
this.streamOptions = options;
|
|
8663
8699
|
this.streamService = new StreamOutputService(options);
|
|
8664
8700
|
if (this._pendingContextConfig) {
|
|
8665
8701
|
this.streamService.setContextInfo(this._pendingContextConfig.contextWindow, this._pendingContextConfig.contextWindow * this._pendingContextConfig.thresholdRatio);
|
|
@@ -8669,9 +8705,9 @@ class QueryExecutor {
|
|
|
8669
8705
|
"llm.start",
|
|
8670
8706
|
"llm.text",
|
|
8671
8707
|
"llm.reasoning",
|
|
8672
|
-
"llm.tool_call",
|
|
8673
8708
|
"llm.completed",
|
|
8674
8709
|
"llm.error",
|
|
8710
|
+
"tool.call",
|
|
8675
8711
|
"tool.result",
|
|
8676
8712
|
"tool.error",
|
|
8677
8713
|
"context.threshold_exceeded",
|
|
@@ -8680,21 +8716,6 @@ class QueryExecutor {
|
|
|
8680
8716
|
], (event) => this.handleEvent(event));
|
|
8681
8717
|
}
|
|
8682
8718
|
handleEvent(event) {
|
|
8683
|
-
if (event.type === "llm.tool_call" && this.streamOptions.showToolCalls) {
|
|
8684
|
-
const payload = event.payload;
|
|
8685
|
-
this.output.log(`\uD83D\uDD27 ${payload.toolCall.name}`);
|
|
8686
|
-
return;
|
|
8687
|
-
}
|
|
8688
|
-
if (event.type === "tool.result" && this.streamOptions.showToolResults) {
|
|
8689
|
-
const payload = event.payload;
|
|
8690
|
-
const result = payload.result?.output ?? payload.result?.error ?? "无输出";
|
|
8691
|
-
this.output.log(`\uD83D\uDCE4 ${payload.name}: ${String(result).substring(0, 200)}`);
|
|
8692
|
-
return;
|
|
8693
|
-
}
|
|
8694
|
-
if (event.type === "tool.error") {
|
|
8695
|
-
this.output.error(`❌ ${event.payload.toolName}: ${event.payload.error}`);
|
|
8696
|
-
return;
|
|
8697
|
-
}
|
|
8698
8719
|
if (event.type === "context.threshold_exceeded" && !this.quiet) {
|
|
8699
8720
|
const payload = event.payload;
|
|
8700
8721
|
this.output.warn(`⚙ 上下文阈值 (${payload.totalTokens}/${payload.contextWindow})`);
|
|
@@ -8713,9 +8734,8 @@ class QueryExecutor {
|
|
|
8713
8734
|
showToolCalls: streamOptions?.showToolCalls ?? this.streamOptions.showToolCalls,
|
|
8714
8735
|
showToolResults: streamOptions?.showToolResults ?? this.streamOptions.showToolResults
|
|
8715
8736
|
};
|
|
8716
|
-
|
|
8717
|
-
|
|
8718
|
-
}
|
|
8737
|
+
this.subscribeToEvents(options);
|
|
8738
|
+
this.streamService?.reset();
|
|
8719
8739
|
if (!this.quiet) {
|
|
8720
8740
|
this.output.info(`执行: ${message}`);
|
|
8721
8741
|
}
|
|
@@ -9583,11 +9603,11 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
9583
9603
|
alias: "r",
|
|
9584
9604
|
describe: "显示 AI 思考过程",
|
|
9585
9605
|
type: "boolean",
|
|
9586
|
-
default:
|
|
9606
|
+
default: true
|
|
9587
9607
|
}).option("tool-calls", {
|
|
9588
9608
|
describe: "显示工具调用",
|
|
9589
9609
|
type: "boolean",
|
|
9590
|
-
default:
|
|
9610
|
+
default: true
|
|
9591
9611
|
}).option("tool-results", {
|
|
9592
9612
|
describe: "显示工具执行结果",
|
|
9593
9613
|
type: "boolean",
|
|
@@ -17454,7 +17474,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
17454
17474
|
try {
|
|
17455
17475
|
input = JSON.parse(args.input);
|
|
17456
17476
|
} catch {
|
|
17457
|
-
input = undefined;
|
|
17477
|
+
input = args.sessionId ? args.input : undefined;
|
|
17458
17478
|
}
|
|
17459
17479
|
}
|
|
17460
17480
|
const runOptions = {
|
package/dist/index.js
CHANGED
|
@@ -80,6 +80,7 @@ function abortStream() {
|
|
|
80
80
|
|
|
81
81
|
class StreamOutputService {
|
|
82
82
|
fullText = "";
|
|
83
|
+
fullReasoning = "";
|
|
83
84
|
options;
|
|
84
85
|
usageInfo;
|
|
85
86
|
contextWindow;
|
|
@@ -90,6 +91,9 @@ class StreamOutputService {
|
|
|
90
91
|
constructor(options = {}) {
|
|
91
92
|
this.options = options;
|
|
92
93
|
}
|
|
94
|
+
setOptions(options) {
|
|
95
|
+
this.options = { ...this.options, ...options };
|
|
96
|
+
}
|
|
93
97
|
setContextInfo(window, threshold) {
|
|
94
98
|
this.contextWindow = window;
|
|
95
99
|
this.contextThreshold = threshold;
|
|
@@ -118,9 +122,15 @@ ${COLORS.system("[已中断]")}
|
|
|
118
122
|
case "llm.reasoning":
|
|
119
123
|
this.handleReasoning(payload);
|
|
120
124
|
break;
|
|
121
|
-
case "
|
|
125
|
+
case "tool.call":
|
|
122
126
|
this.handleToolCall(payload);
|
|
123
127
|
break;
|
|
128
|
+
case "tool.result":
|
|
129
|
+
this.handleToolResult(payload);
|
|
130
|
+
break;
|
|
131
|
+
case "tool.error":
|
|
132
|
+
this.handleToolError(payload);
|
|
133
|
+
break;
|
|
124
134
|
case "llm.completed":
|
|
125
135
|
this.handleCompleted(payload);
|
|
126
136
|
break;
|
|
@@ -129,11 +139,23 @@ ${COLORS.system("[已中断]")}
|
|
|
129
139
|
handleStart(payload) {
|
|
130
140
|
if (payload.metadata?.model) {}
|
|
131
141
|
}
|
|
132
|
-
|
|
142
|
+
clearThinkingPlaceholder() {
|
|
133
143
|
if (!this.thinkingPrinted) {
|
|
134
144
|
this.thinkingPrinted = true;
|
|
135
145
|
process.stdout.write("\r" + " ".repeat(20) + "\r");
|
|
136
146
|
}
|
|
147
|
+
}
|
|
148
|
+
closeReasoningBlock() {
|
|
149
|
+
if (this.reasoningStarted) {
|
|
150
|
+
process.stdout.write(COLORS.reasoning(`
|
|
151
|
+
└` + "─".repeat(20) + `
|
|
152
|
+
`));
|
|
153
|
+
this.reasoningStarted = false;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
handleText(payload) {
|
|
157
|
+
this.clearThinkingPlaceholder();
|
|
158
|
+
this.closeReasoningBlock();
|
|
137
159
|
const text = payload.delta ?? payload.content ?? "";
|
|
138
160
|
if (!text)
|
|
139
161
|
return;
|
|
@@ -146,11 +168,16 @@ ${COLORS.system("[已中断]")}
|
|
|
146
168
|
this.fullText += text;
|
|
147
169
|
}
|
|
148
170
|
handleReasoning(payload) {
|
|
171
|
+
if (payload.phase === "end") {
|
|
172
|
+
this.closeReasoningBlock();
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
149
175
|
if (!this.options.showReasoning)
|
|
150
176
|
return;
|
|
151
|
-
const
|
|
152
|
-
if (!
|
|
177
|
+
const delta = payload.delta ?? this.extractReasoningDelta(payload.content);
|
|
178
|
+
if (!delta)
|
|
153
179
|
return;
|
|
180
|
+
this.clearThinkingPlaceholder();
|
|
154
181
|
if (!this.reasoningStarted) {
|
|
155
182
|
this.reasoningStarted = true;
|
|
156
183
|
process.stdout.write(`
|
|
@@ -158,26 +185,48 @@ ${COLORS.system("[已中断]")}
|
|
|
158
185
|
` + COLORS.reasoning("┌─ 思考过程 ─") + `
|
|
159
186
|
`);
|
|
160
187
|
}
|
|
161
|
-
process.stdout.write(COLORS.reasoning(
|
|
188
|
+
process.stdout.write(COLORS.reasoning(delta));
|
|
189
|
+
this.fullReasoning += delta;
|
|
190
|
+
}
|
|
191
|
+
extractReasoningDelta(content) {
|
|
192
|
+
if (!content)
|
|
193
|
+
return "";
|
|
194
|
+
if (content.startsWith(this.fullReasoning)) {
|
|
195
|
+
return content.slice(this.fullReasoning.length);
|
|
196
|
+
}
|
|
197
|
+
return "";
|
|
162
198
|
}
|
|
163
199
|
handleToolCall(payload) {
|
|
164
200
|
if (!this.options.showToolCalls)
|
|
165
201
|
return;
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
202
|
+
const name = payload.name ?? "unknown";
|
|
203
|
+
const argsStr = payload.arguments ? JSON.stringify(payload.arguments) : "";
|
|
204
|
+
this.clearThinkingPlaceholder();
|
|
205
|
+
this.closeReasoningBlock();
|
|
206
|
+
process.stdout.write(`
|
|
207
|
+
` + COLORS.toolCall(`\uD83D\uDD27 [Tool] ${name}${argsStr ? ` ${argsStr}` : ""}`) + `
|
|
208
|
+
`);
|
|
209
|
+
}
|
|
210
|
+
handleToolResult(payload) {
|
|
211
|
+
if (!this.options.showToolResults)
|
|
212
|
+
return;
|
|
213
|
+
const name = payload.name ?? "unknown";
|
|
214
|
+
const result = payload.result?.output ?? payload.result?.error ?? "无输出";
|
|
215
|
+
process.stdout.write(`
|
|
216
|
+
` + COLORS.toolResult(`\uD83D\uDCE4 ${name}: ${String(result).substring(0, 200)}`) + `
|
|
217
|
+
`);
|
|
218
|
+
}
|
|
219
|
+
handleToolError(payload) {
|
|
220
|
+
if (!this.options.showToolCalls && !this.options.showToolResults)
|
|
221
|
+
return;
|
|
222
|
+
process.stdout.write(`
|
|
223
|
+
` + COLORS.error(`❌ ${payload.toolName ?? "unknown"}: ${payload.error ?? "unknown error"}`) + `
|
|
170
224
|
`);
|
|
171
|
-
}
|
|
172
225
|
}
|
|
173
226
|
handleCompleted(payload) {
|
|
174
227
|
process.stdout.write(`
|
|
175
228
|
`);
|
|
176
|
-
|
|
177
|
-
process.stdout.write(COLORS.reasoning("└" + "─".repeat(20) + `
|
|
178
|
-
`));
|
|
179
|
-
this.reasoningStarted = false;
|
|
180
|
-
}
|
|
229
|
+
this.closeReasoningBlock();
|
|
181
230
|
const metadata = payload.metadata;
|
|
182
231
|
if (metadata?.model || metadata?.usage) {
|
|
183
232
|
let modelName = metadata.model || "";
|
|
@@ -220,6 +269,7 @@ ${COLORS.system("[已中断]")}
|
|
|
220
269
|
}
|
|
221
270
|
reset() {
|
|
222
271
|
this.fullText = "";
|
|
272
|
+
this.fullReasoning = "";
|
|
223
273
|
this.usageInfo = undefined;
|
|
224
274
|
this.isFirstText = true;
|
|
225
275
|
this.reasoningStarted = false;
|
|
@@ -7239,7 +7289,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
7239
7289
|
var require_package = __commonJS((exports, module) => {
|
|
7240
7290
|
module.exports = {
|
|
7241
7291
|
name: "@ai-setting/roy-agent-cli",
|
|
7242
|
-
version: "1.5.
|
|
7292
|
+
version: "1.5.46",
|
|
7243
7293
|
type: "module",
|
|
7244
7294
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
7245
7295
|
main: "./dist/index.js",
|
|
@@ -7265,9 +7315,9 @@ var require_package = __commonJS((exports, module) => {
|
|
|
7265
7315
|
typecheck: "npx tsc --noEmit --skipLibCheck"
|
|
7266
7316
|
},
|
|
7267
7317
|
dependencies: {
|
|
7268
|
-
"@ai-setting/roy-agent-coder-harness": "^1.5.
|
|
7269
|
-
"@ai-setting/roy-agent-core": "^1.5.
|
|
7270
|
-
"@ai-setting/roy-agent-ontology-harness": "^1.5.
|
|
7318
|
+
"@ai-setting/roy-agent-coder-harness": "^1.5.46",
|
|
7319
|
+
"@ai-setting/roy-agent-core": "^1.5.46",
|
|
7320
|
+
"@ai-setting/roy-agent-ontology-harness": "^1.5.46",
|
|
7271
7321
|
chalk: "^5.6.2",
|
|
7272
7322
|
commander: "^14.0.3",
|
|
7273
7323
|
effect: "^3.21.2",
|
|
@@ -8255,11 +8305,11 @@ function createActCommand(externalEnvService) {
|
|
|
8255
8305
|
alias: "r",
|
|
8256
8306
|
describe: "显示 AI 思考过程",
|
|
8257
8307
|
type: "boolean",
|
|
8258
|
-
default:
|
|
8308
|
+
default: true
|
|
8259
8309
|
}).option("tool-calls", {
|
|
8260
8310
|
describe: "显示工具调用",
|
|
8261
8311
|
type: "boolean",
|
|
8262
|
-
default:
|
|
8312
|
+
default: true
|
|
8263
8313
|
}).option("tool-results", {
|
|
8264
8314
|
describe: "显示工具执行结果",
|
|
8265
8315
|
type: "boolean",
|
|
@@ -8445,32 +8495,15 @@ function createActCommand(externalEnvService) {
|
|
|
8445
8495
|
"llm.start",
|
|
8446
8496
|
"llm.text",
|
|
8447
8497
|
"llm.reasoning",
|
|
8448
|
-
"llm.tool_call",
|
|
8449
8498
|
"llm.completed",
|
|
8450
8499
|
"llm.error",
|
|
8500
|
+
"tool.call",
|
|
8451
8501
|
"tool.result",
|
|
8452
8502
|
"tool.error",
|
|
8453
8503
|
"context.threshold_exceeded",
|
|
8454
8504
|
"context.compacting",
|
|
8455
8505
|
"context.compacted"
|
|
8456
8506
|
], (event) => {
|
|
8457
|
-
if (event.type === "llm.tool_call" && args.toolCalls) {
|
|
8458
|
-
const payload = event.payload;
|
|
8459
|
-
output.log(`\uD83D\uDD27 ${payload.toolCall.name}`);
|
|
8460
|
-
output.log(` ${payload.toolCall.arguments}`);
|
|
8461
|
-
return;
|
|
8462
|
-
}
|
|
8463
|
-
if (event.type === "tool.result" && args.toolResults) {
|
|
8464
|
-
const payload = event.payload;
|
|
8465
|
-
const result2 = payload.result?.output ?? payload.result?.error ?? "无输出";
|
|
8466
|
-
output.log(`\uD83D\uDCE4 ${payload.name}: ${String(result2).substring(0, 200)}`);
|
|
8467
|
-
return;
|
|
8468
|
-
}
|
|
8469
|
-
if (event.type === "tool.error") {
|
|
8470
|
-
const payload = event.payload;
|
|
8471
|
-
output.error(`❌ ${payload.toolName ?? "unknown"}: ${payload.error ?? "unknown error"}`);
|
|
8472
|
-
return;
|
|
8473
|
-
}
|
|
8474
8507
|
if (event.type === "context.threshold_exceeded" && !quiet) {
|
|
8475
8508
|
const payload = event.payload;
|
|
8476
8509
|
output.warn(`⚙ 上下文阈值 (${payload.totalTokens}/${payload.contextWindow})`);
|
|
@@ -8634,8 +8667,8 @@ class QueryExecutor {
|
|
|
8634
8667
|
streamService = null;
|
|
8635
8668
|
unsubscribe = null;
|
|
8636
8669
|
streamOptions = {
|
|
8637
|
-
showReasoning:
|
|
8638
|
-
showToolCalls:
|
|
8670
|
+
showReasoning: true,
|
|
8671
|
+
showToolCalls: true,
|
|
8639
8672
|
showToolResults: false
|
|
8640
8673
|
};
|
|
8641
8674
|
_pendingContextConfig = null;
|
|
@@ -8655,10 +8688,13 @@ class QueryExecutor {
|
|
|
8655
8688
|
}
|
|
8656
8689
|
}
|
|
8657
8690
|
subscribeToEvents(options) {
|
|
8691
|
+
this.streamOptions = options;
|
|
8692
|
+
if (this.streamService) {
|
|
8693
|
+
this.streamService.setOptions(options);
|
|
8694
|
+
}
|
|
8658
8695
|
if (this.unsubscribe) {
|
|
8659
8696
|
return;
|
|
8660
8697
|
}
|
|
8661
|
-
this.streamOptions = options;
|
|
8662
8698
|
this.streamService = new StreamOutputService(options);
|
|
8663
8699
|
if (this._pendingContextConfig) {
|
|
8664
8700
|
this.streamService.setContextInfo(this._pendingContextConfig.contextWindow, this._pendingContextConfig.contextWindow * this._pendingContextConfig.thresholdRatio);
|
|
@@ -8668,9 +8704,9 @@ class QueryExecutor {
|
|
|
8668
8704
|
"llm.start",
|
|
8669
8705
|
"llm.text",
|
|
8670
8706
|
"llm.reasoning",
|
|
8671
|
-
"llm.tool_call",
|
|
8672
8707
|
"llm.completed",
|
|
8673
8708
|
"llm.error",
|
|
8709
|
+
"tool.call",
|
|
8674
8710
|
"tool.result",
|
|
8675
8711
|
"tool.error",
|
|
8676
8712
|
"context.threshold_exceeded",
|
|
@@ -8679,21 +8715,6 @@ class QueryExecutor {
|
|
|
8679
8715
|
], (event) => this.handleEvent(event));
|
|
8680
8716
|
}
|
|
8681
8717
|
handleEvent(event) {
|
|
8682
|
-
if (event.type === "llm.tool_call" && this.streamOptions.showToolCalls) {
|
|
8683
|
-
const payload = event.payload;
|
|
8684
|
-
this.output.log(`\uD83D\uDD27 ${payload.toolCall.name}`);
|
|
8685
|
-
return;
|
|
8686
|
-
}
|
|
8687
|
-
if (event.type === "tool.result" && this.streamOptions.showToolResults) {
|
|
8688
|
-
const payload = event.payload;
|
|
8689
|
-
const result = payload.result?.output ?? payload.result?.error ?? "无输出";
|
|
8690
|
-
this.output.log(`\uD83D\uDCE4 ${payload.name}: ${String(result).substring(0, 200)}`);
|
|
8691
|
-
return;
|
|
8692
|
-
}
|
|
8693
|
-
if (event.type === "tool.error") {
|
|
8694
|
-
this.output.error(`❌ ${event.payload.toolName}: ${event.payload.error}`);
|
|
8695
|
-
return;
|
|
8696
|
-
}
|
|
8697
8718
|
if (event.type === "context.threshold_exceeded" && !this.quiet) {
|
|
8698
8719
|
const payload = event.payload;
|
|
8699
8720
|
this.output.warn(`⚙ 上下文阈值 (${payload.totalTokens}/${payload.contextWindow})`);
|
|
@@ -8712,9 +8733,8 @@ class QueryExecutor {
|
|
|
8712
8733
|
showToolCalls: streamOptions?.showToolCalls ?? this.streamOptions.showToolCalls,
|
|
8713
8734
|
showToolResults: streamOptions?.showToolResults ?? this.streamOptions.showToolResults
|
|
8714
8735
|
};
|
|
8715
|
-
|
|
8716
|
-
|
|
8717
|
-
}
|
|
8736
|
+
this.subscribeToEvents(options);
|
|
8737
|
+
this.streamService?.reset();
|
|
8718
8738
|
if (!this.quiet) {
|
|
8719
8739
|
this.output.info(`执行: ${message}`);
|
|
8720
8740
|
}
|
|
@@ -9582,11 +9602,11 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
9582
9602
|
alias: "r",
|
|
9583
9603
|
describe: "显示 AI 思考过程",
|
|
9584
9604
|
type: "boolean",
|
|
9585
|
-
default:
|
|
9605
|
+
default: true
|
|
9586
9606
|
}).option("tool-calls", {
|
|
9587
9607
|
describe: "显示工具调用",
|
|
9588
9608
|
type: "boolean",
|
|
9589
|
-
default:
|
|
9609
|
+
default: true
|
|
9590
9610
|
}).option("tool-results", {
|
|
9591
9611
|
describe: "显示工具执行结果",
|
|
9592
9612
|
type: "boolean",
|
|
@@ -17453,7 +17473,7 @@ var runWorkflow = wrapFunction(async function runWorkflowImpl(args) {
|
|
|
17453
17473
|
try {
|
|
17454
17474
|
input = JSON.parse(args.input);
|
|
17455
17475
|
} catch {
|
|
17456
|
-
input = undefined;
|
|
17476
|
+
input = args.sessionId ? args.input : undefined;
|
|
17457
17477
|
}
|
|
17458
17478
|
}
|
|
17459
17479
|
const runOptions = {
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-setting/roy-agent-cli",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.46",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI for roy-agent - Non-interactive command execution",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -26,9 +26,9 @@
|
|
|
26
26
|
"typecheck": "npx tsc --noEmit --skipLibCheck"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@ai-setting/roy-agent-coder-harness": "^1.5.
|
|
30
|
-
"@ai-setting/roy-agent-core": "^1.5.
|
|
31
|
-
"@ai-setting/roy-agent-ontology-harness": "^1.5.
|
|
29
|
+
"@ai-setting/roy-agent-coder-harness": "^1.5.46",
|
|
30
|
+
"@ai-setting/roy-agent-core": "^1.5.46",
|
|
31
|
+
"@ai-setting/roy-agent-ontology-harness": "^1.5.46",
|
|
32
32
|
"chalk": "^5.6.2",
|
|
33
33
|
"commander": "^14.0.3",
|
|
34
34
|
"effect": "^3.21.2",
|