@ai-setting/roy-agent-cli 1.5.51 → 1.5.53
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 +49 -18
- package/dist/index.js +49 -18
- package/dist/roy-agent-linux-x64/bin/roy-agent +0 -0
- package/package.json +2 -2
package/dist/bin/roy-agent.js
CHANGED
|
@@ -89,6 +89,8 @@ class StreamOutputService {
|
|
|
89
89
|
isFirstText = true;
|
|
90
90
|
reasoningStarted = false;
|
|
91
91
|
thinkingPrinted = false;
|
|
92
|
+
reasoningBuffer = "";
|
|
93
|
+
reasoningClosedByText = false;
|
|
92
94
|
constructor(options = {}) {
|
|
93
95
|
this.options = options;
|
|
94
96
|
}
|
|
@@ -138,28 +140,52 @@ ${COLORS.system("[已中断]")}
|
|
|
138
140
|
}
|
|
139
141
|
}
|
|
140
142
|
handleStart(payload) {
|
|
143
|
+
this.reasoningClosedByText = false;
|
|
144
|
+
this.reasoningBuffer = "";
|
|
145
|
+
this.fullReasoning = "";
|
|
146
|
+
this.isFirstText = true;
|
|
147
|
+
this.reasoningStarted = false;
|
|
148
|
+
this.thinkingPrinted = false;
|
|
141
149
|
if (payload.metadata?.model) {}
|
|
142
150
|
}
|
|
143
151
|
clearThinkingPlaceholder() {
|
|
144
152
|
if (!this.thinkingPrinted) {
|
|
145
153
|
this.thinkingPrinted = true;
|
|
146
|
-
process.stdout.write("\r" + " ".repeat(
|
|
154
|
+
process.stdout.write("\r" + " ".repeat(80) + "\r");
|
|
147
155
|
}
|
|
148
156
|
}
|
|
157
|
+
flushReasoningBuffer() {
|
|
158
|
+
if (!this.reasoningBuffer)
|
|
159
|
+
return;
|
|
160
|
+
if (this.reasoningStarted)
|
|
161
|
+
return;
|
|
162
|
+
this.clearThinkingPlaceholder();
|
|
163
|
+
this.reasoningStarted = true;
|
|
164
|
+
process.stdout.write(`
|
|
165
|
+
|
|
166
|
+
` + COLORS.reasoning("┌─ 思考过程 ─") + `
|
|
167
|
+
`);
|
|
168
|
+
process.stdout.write(COLORS.reasoning(this.reasoningBuffer));
|
|
169
|
+
this.reasoningBuffer = "";
|
|
170
|
+
}
|
|
149
171
|
closeReasoningBlock() {
|
|
172
|
+
this.flushReasoningBuffer();
|
|
150
173
|
if (this.reasoningStarted) {
|
|
174
|
+
const len = this.fullReasoning.length;
|
|
175
|
+
const dividerWidth = len === 0 ? 8 : Math.max(8, Math.min(40, len));
|
|
151
176
|
process.stdout.write(COLORS.reasoning(`
|
|
152
|
-
└` + "─".repeat(
|
|
177
|
+
└` + "─".repeat(dividerWidth) + `
|
|
153
178
|
`));
|
|
154
179
|
this.reasoningStarted = false;
|
|
155
180
|
}
|
|
156
181
|
}
|
|
157
182
|
handleText(payload) {
|
|
158
183
|
this.clearThinkingPlaceholder();
|
|
159
|
-
this.closeReasoningBlock();
|
|
160
184
|
const text = payload.delta ?? payload.content ?? "";
|
|
161
|
-
if (!text)
|
|
185
|
+
if (!text || !text.trim())
|
|
162
186
|
return;
|
|
187
|
+
this.closeReasoningBlock();
|
|
188
|
+
this.reasoningClosedByText = true;
|
|
163
189
|
if (this.isFirstText) {
|
|
164
190
|
process.stdout.write(`
|
|
165
191
|
`);
|
|
@@ -169,25 +195,24 @@ ${COLORS.system("[已中断]")}
|
|
|
169
195
|
this.fullText += text;
|
|
170
196
|
}
|
|
171
197
|
handleReasoning(payload) {
|
|
172
|
-
if (payload.phase === "end")
|
|
173
|
-
this.closeReasoningBlock();
|
|
198
|
+
if (payload.phase === "end")
|
|
174
199
|
return;
|
|
175
|
-
}
|
|
176
200
|
if (!this.options.showReasoning)
|
|
177
201
|
return;
|
|
178
202
|
const delta = payload.delta ?? this.extractReasoningDelta(payload.content);
|
|
179
203
|
if (!delta)
|
|
180
204
|
return;
|
|
181
|
-
this.clearThinkingPlaceholder();
|
|
182
|
-
if (!this.reasoningStarted) {
|
|
183
|
-
this.reasoningStarted = true;
|
|
184
|
-
process.stdout.write(`
|
|
185
|
-
|
|
186
|
-
` + COLORS.reasoning("┌─ 思考过程 ─") + `
|
|
187
|
-
`);
|
|
188
|
-
}
|
|
189
|
-
process.stdout.write(COLORS.reasoning(delta));
|
|
190
205
|
this.fullReasoning += delta;
|
|
206
|
+
if (this.reasoningStarted) {
|
|
207
|
+
process.stdout.write(COLORS.reasoning(delta));
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
if (this.reasoningClosedByText)
|
|
211
|
+
return;
|
|
212
|
+
this.reasoningBuffer += delta;
|
|
213
|
+
if (this.reasoningBuffer.length >= 15) {
|
|
214
|
+
this.flushReasoningBuffer();
|
|
215
|
+
}
|
|
191
216
|
}
|
|
192
217
|
extractReasoningDelta(content) {
|
|
193
218
|
if (!content)
|
|
@@ -211,6 +236,7 @@ ${COLORS.system("[已中断]")}
|
|
|
211
236
|
handleToolResult(payload) {
|
|
212
237
|
if (!this.options.showToolResults)
|
|
213
238
|
return;
|
|
239
|
+
this.closeReasoningBlock();
|
|
214
240
|
const name = payload.name ?? "unknown";
|
|
215
241
|
const result = payload.result?.output ?? payload.result?.error ?? "无输出";
|
|
216
242
|
process.stdout.write(`
|
|
@@ -220,6 +246,7 @@ ${COLORS.system("[已中断]")}
|
|
|
220
246
|
handleToolError(payload) {
|
|
221
247
|
if (!this.options.showToolCalls && !this.options.showToolResults)
|
|
222
248
|
return;
|
|
249
|
+
this.closeReasoningBlock();
|
|
223
250
|
process.stdout.write(`
|
|
224
251
|
` + COLORS.error(`❌ ${payload.toolName ?? "unknown"}: ${payload.error ?? "unknown error"}`) + `
|
|
225
252
|
`);
|
|
@@ -271,9 +298,11 @@ ${COLORS.system("[已中断]")}
|
|
|
271
298
|
reset() {
|
|
272
299
|
this.fullText = "";
|
|
273
300
|
this.fullReasoning = "";
|
|
301
|
+
this.reasoningBuffer = "";
|
|
274
302
|
this.usageInfo = undefined;
|
|
275
303
|
this.isFirstText = true;
|
|
276
304
|
this.reasoningStarted = false;
|
|
305
|
+
this.reasoningClosedByText = false;
|
|
277
306
|
this.thinkingPrinted = false;
|
|
278
307
|
}
|
|
279
308
|
}
|
|
@@ -7290,7 +7319,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
7290
7319
|
var require_package = __commonJS((exports, module) => {
|
|
7291
7320
|
module.exports = {
|
|
7292
7321
|
name: "@ai-setting/roy-agent-cli",
|
|
7293
|
-
version: "1.5.
|
|
7322
|
+
version: "1.5.53",
|
|
7294
7323
|
type: "module",
|
|
7295
7324
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
7296
7325
|
main: "./dist/index.js",
|
|
@@ -7317,7 +7346,7 @@ var require_package = __commonJS((exports, module) => {
|
|
|
7317
7346
|
},
|
|
7318
7347
|
dependencies: {
|
|
7319
7348
|
"@ai-setting/roy-agent-coder-harness": "^1.5.46",
|
|
7320
|
-
"@ai-setting/roy-agent-core": "^1.5.
|
|
7349
|
+
"@ai-setting/roy-agent-core": "^1.5.52",
|
|
7321
7350
|
"@ai-setting/roy-agent-ontology-harness": "^1.5.47",
|
|
7322
7351
|
chalk: "^5.6.2",
|
|
7323
7352
|
commander: "^14.0.3",
|
|
@@ -9382,7 +9411,9 @@ ${COLORS.system("[通知2] ❯ " + message.replace(/\n/g, `
|
|
|
9382
9411
|
pluginEnabled[key] = true;
|
|
9383
9412
|
}
|
|
9384
9413
|
}
|
|
9414
|
+
const agentFromEvent = envEvent.metadata?.agent;
|
|
9385
9415
|
this.currentAgentContext = {
|
|
9416
|
+
agentType: agentFromEvent,
|
|
9386
9417
|
pluginEnabled,
|
|
9387
9418
|
envEvent,
|
|
9388
9419
|
plugins
|
package/dist/index.js
CHANGED
|
@@ -88,6 +88,8 @@ class StreamOutputService {
|
|
|
88
88
|
isFirstText = true;
|
|
89
89
|
reasoningStarted = false;
|
|
90
90
|
thinkingPrinted = false;
|
|
91
|
+
reasoningBuffer = "";
|
|
92
|
+
reasoningClosedByText = false;
|
|
91
93
|
constructor(options = {}) {
|
|
92
94
|
this.options = options;
|
|
93
95
|
}
|
|
@@ -137,28 +139,52 @@ ${COLORS.system("[已中断]")}
|
|
|
137
139
|
}
|
|
138
140
|
}
|
|
139
141
|
handleStart(payload) {
|
|
142
|
+
this.reasoningClosedByText = false;
|
|
143
|
+
this.reasoningBuffer = "";
|
|
144
|
+
this.fullReasoning = "";
|
|
145
|
+
this.isFirstText = true;
|
|
146
|
+
this.reasoningStarted = false;
|
|
147
|
+
this.thinkingPrinted = false;
|
|
140
148
|
if (payload.metadata?.model) {}
|
|
141
149
|
}
|
|
142
150
|
clearThinkingPlaceholder() {
|
|
143
151
|
if (!this.thinkingPrinted) {
|
|
144
152
|
this.thinkingPrinted = true;
|
|
145
|
-
process.stdout.write("\r" + " ".repeat(
|
|
153
|
+
process.stdout.write("\r" + " ".repeat(80) + "\r");
|
|
146
154
|
}
|
|
147
155
|
}
|
|
156
|
+
flushReasoningBuffer() {
|
|
157
|
+
if (!this.reasoningBuffer)
|
|
158
|
+
return;
|
|
159
|
+
if (this.reasoningStarted)
|
|
160
|
+
return;
|
|
161
|
+
this.clearThinkingPlaceholder();
|
|
162
|
+
this.reasoningStarted = true;
|
|
163
|
+
process.stdout.write(`
|
|
164
|
+
|
|
165
|
+
` + COLORS.reasoning("┌─ 思考过程 ─") + `
|
|
166
|
+
`);
|
|
167
|
+
process.stdout.write(COLORS.reasoning(this.reasoningBuffer));
|
|
168
|
+
this.reasoningBuffer = "";
|
|
169
|
+
}
|
|
148
170
|
closeReasoningBlock() {
|
|
171
|
+
this.flushReasoningBuffer();
|
|
149
172
|
if (this.reasoningStarted) {
|
|
173
|
+
const len = this.fullReasoning.length;
|
|
174
|
+
const dividerWidth = len === 0 ? 8 : Math.max(8, Math.min(40, len));
|
|
150
175
|
process.stdout.write(COLORS.reasoning(`
|
|
151
|
-
└` + "─".repeat(
|
|
176
|
+
└` + "─".repeat(dividerWidth) + `
|
|
152
177
|
`));
|
|
153
178
|
this.reasoningStarted = false;
|
|
154
179
|
}
|
|
155
180
|
}
|
|
156
181
|
handleText(payload) {
|
|
157
182
|
this.clearThinkingPlaceholder();
|
|
158
|
-
this.closeReasoningBlock();
|
|
159
183
|
const text = payload.delta ?? payload.content ?? "";
|
|
160
|
-
if (!text)
|
|
184
|
+
if (!text || !text.trim())
|
|
161
185
|
return;
|
|
186
|
+
this.closeReasoningBlock();
|
|
187
|
+
this.reasoningClosedByText = true;
|
|
162
188
|
if (this.isFirstText) {
|
|
163
189
|
process.stdout.write(`
|
|
164
190
|
`);
|
|
@@ -168,25 +194,24 @@ ${COLORS.system("[已中断]")}
|
|
|
168
194
|
this.fullText += text;
|
|
169
195
|
}
|
|
170
196
|
handleReasoning(payload) {
|
|
171
|
-
if (payload.phase === "end")
|
|
172
|
-
this.closeReasoningBlock();
|
|
197
|
+
if (payload.phase === "end")
|
|
173
198
|
return;
|
|
174
|
-
}
|
|
175
199
|
if (!this.options.showReasoning)
|
|
176
200
|
return;
|
|
177
201
|
const delta = payload.delta ?? this.extractReasoningDelta(payload.content);
|
|
178
202
|
if (!delta)
|
|
179
203
|
return;
|
|
180
|
-
this.clearThinkingPlaceholder();
|
|
181
|
-
if (!this.reasoningStarted) {
|
|
182
|
-
this.reasoningStarted = true;
|
|
183
|
-
process.stdout.write(`
|
|
184
|
-
|
|
185
|
-
` + COLORS.reasoning("┌─ 思考过程 ─") + `
|
|
186
|
-
`);
|
|
187
|
-
}
|
|
188
|
-
process.stdout.write(COLORS.reasoning(delta));
|
|
189
204
|
this.fullReasoning += delta;
|
|
205
|
+
if (this.reasoningStarted) {
|
|
206
|
+
process.stdout.write(COLORS.reasoning(delta));
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
209
|
+
if (this.reasoningClosedByText)
|
|
210
|
+
return;
|
|
211
|
+
this.reasoningBuffer += delta;
|
|
212
|
+
if (this.reasoningBuffer.length >= 15) {
|
|
213
|
+
this.flushReasoningBuffer();
|
|
214
|
+
}
|
|
190
215
|
}
|
|
191
216
|
extractReasoningDelta(content) {
|
|
192
217
|
if (!content)
|
|
@@ -210,6 +235,7 @@ ${COLORS.system("[已中断]")}
|
|
|
210
235
|
handleToolResult(payload) {
|
|
211
236
|
if (!this.options.showToolResults)
|
|
212
237
|
return;
|
|
238
|
+
this.closeReasoningBlock();
|
|
213
239
|
const name = payload.name ?? "unknown";
|
|
214
240
|
const result = payload.result?.output ?? payload.result?.error ?? "无输出";
|
|
215
241
|
process.stdout.write(`
|
|
@@ -219,6 +245,7 @@ ${COLORS.system("[已中断]")}
|
|
|
219
245
|
handleToolError(payload) {
|
|
220
246
|
if (!this.options.showToolCalls && !this.options.showToolResults)
|
|
221
247
|
return;
|
|
248
|
+
this.closeReasoningBlock();
|
|
222
249
|
process.stdout.write(`
|
|
223
250
|
` + COLORS.error(`❌ ${payload.toolName ?? "unknown"}: ${payload.error ?? "unknown error"}`) + `
|
|
224
251
|
`);
|
|
@@ -270,9 +297,11 @@ ${COLORS.system("[已中断]")}
|
|
|
270
297
|
reset() {
|
|
271
298
|
this.fullText = "";
|
|
272
299
|
this.fullReasoning = "";
|
|
300
|
+
this.reasoningBuffer = "";
|
|
273
301
|
this.usageInfo = undefined;
|
|
274
302
|
this.isFirstText = true;
|
|
275
303
|
this.reasoningStarted = false;
|
|
304
|
+
this.reasoningClosedByText = false;
|
|
276
305
|
this.thinkingPrinted = false;
|
|
277
306
|
}
|
|
278
307
|
}
|
|
@@ -7289,7 +7318,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
7289
7318
|
var require_package = __commonJS((exports, module) => {
|
|
7290
7319
|
module.exports = {
|
|
7291
7320
|
name: "@ai-setting/roy-agent-cli",
|
|
7292
|
-
version: "1.5.
|
|
7321
|
+
version: "1.5.53",
|
|
7293
7322
|
type: "module",
|
|
7294
7323
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
7295
7324
|
main: "./dist/index.js",
|
|
@@ -7316,7 +7345,7 @@ var require_package = __commonJS((exports, module) => {
|
|
|
7316
7345
|
},
|
|
7317
7346
|
dependencies: {
|
|
7318
7347
|
"@ai-setting/roy-agent-coder-harness": "^1.5.46",
|
|
7319
|
-
"@ai-setting/roy-agent-core": "^1.5.
|
|
7348
|
+
"@ai-setting/roy-agent-core": "^1.5.52",
|
|
7320
7349
|
"@ai-setting/roy-agent-ontology-harness": "^1.5.47",
|
|
7321
7350
|
chalk: "^5.6.2",
|
|
7322
7351
|
commander: "^14.0.3",
|
|
@@ -9381,7 +9410,9 @@ ${COLORS.system("[通知2] ❯ " + message.replace(/\n/g, `
|
|
|
9381
9410
|
pluginEnabled[key] = true;
|
|
9382
9411
|
}
|
|
9383
9412
|
}
|
|
9413
|
+
const agentFromEvent = envEvent.metadata?.agent;
|
|
9384
9414
|
this.currentAgentContext = {
|
|
9415
|
+
agentType: agentFromEvent,
|
|
9385
9416
|
pluginEnabled,
|
|
9386
9417
|
envEvent,
|
|
9387
9418
|
plugins
|
|
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.53",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "CLI for roy-agent - Non-interactive command execution",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
29
|
"@ai-setting/roy-agent-coder-harness": "^1.5.46",
|
|
30
|
-
"@ai-setting/roy-agent-core": "^1.5.
|
|
30
|
+
"@ai-setting/roy-agent-core": "^1.5.52",
|
|
31
31
|
"@ai-setting/roy-agent-ontology-harness": "^1.5.47",
|
|
32
32
|
"chalk": "^5.6.2",
|
|
33
33
|
"commander": "^14.0.3",
|