@ai-setting/roy-agent-cli 1.5.37 → 1.5.38
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 +58 -14
- package/dist/index.js +58 -14
- package/dist/roy-agent-linux-x64/bin/roy-agent +0 -0
- package/package.json +2 -2
package/dist/bin/roy-agent.js
CHANGED
|
@@ -7220,7 +7220,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
7220
7220
|
var require_package = __commonJS((exports, module) => {
|
|
7221
7221
|
module.exports = {
|
|
7222
7222
|
name: "@ai-setting/roy-agent-cli",
|
|
7223
|
-
version: "1.5.
|
|
7223
|
+
version: "1.5.38",
|
|
7224
7224
|
type: "module",
|
|
7225
7225
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
7226
7226
|
main: "./dist/index.js",
|
|
@@ -7247,7 +7247,7 @@ var require_package = __commonJS((exports, module) => {
|
|
|
7247
7247
|
},
|
|
7248
7248
|
dependencies: {
|
|
7249
7249
|
"@ai-setting/roy-agent-coder-harness": "^1.5.36",
|
|
7250
|
-
"@ai-setting/roy-agent-core": "^1.5.
|
|
7250
|
+
"@ai-setting/roy-agent-core": "^1.5.36",
|
|
7251
7251
|
chalk: "^5.6.2",
|
|
7252
7252
|
commander: "^14.0.3",
|
|
7253
7253
|
effect: "^3.21.2",
|
|
@@ -8736,7 +8736,7 @@ class QueryExecutor {
|
|
|
8736
8736
|
}
|
|
8737
8737
|
this.streamService?.handleEvent(event);
|
|
8738
8738
|
}
|
|
8739
|
-
async execute(message, sessionId, streamOptions, traceId) {
|
|
8739
|
+
async execute(message, sessionId, streamOptions, traceId, agentContext) {
|
|
8740
8740
|
const options = {
|
|
8741
8741
|
showReasoning: streamOptions?.showReasoning ?? this.streamOptions.showReasoning,
|
|
8742
8742
|
showToolCalls: streamOptions?.showToolCalls ?? this.streamOptions.showToolCalls,
|
|
@@ -8754,7 +8754,8 @@ class QueryExecutor {
|
|
|
8754
8754
|
metadata: {
|
|
8755
8755
|
originalQuery: message,
|
|
8756
8756
|
traceId
|
|
8757
|
-
}
|
|
8757
|
+
},
|
|
8758
|
+
...agentContext
|
|
8758
8759
|
};
|
|
8759
8760
|
let span;
|
|
8760
8761
|
const tracer = getTracerProvider3().getTracer("roy-tracer");
|
|
@@ -8960,6 +8961,12 @@ class EventMessageFormatter {
|
|
|
8960
8961
|
const seconds = Math.floor(ms % 60000 / 1000);
|
|
8961
8962
|
return `${minutes}分${seconds}秒`;
|
|
8962
8963
|
}
|
|
8964
|
+
formatWithEvent(event) {
|
|
8965
|
+
return {
|
|
8966
|
+
message: this.format(event),
|
|
8967
|
+
envEvent: event
|
|
8968
|
+
};
|
|
8969
|
+
}
|
|
8963
8970
|
}
|
|
8964
8971
|
|
|
8965
8972
|
// src/commands/shared/event-handler.ts
|
|
@@ -8967,6 +8974,7 @@ class EventHandler {
|
|
|
8967
8974
|
env;
|
|
8968
8975
|
eventTypes;
|
|
8969
8976
|
onEvent;
|
|
8977
|
+
onEventWithEnv;
|
|
8970
8978
|
formatter;
|
|
8971
8979
|
isIdle;
|
|
8972
8980
|
idleCheckInterval;
|
|
@@ -8978,6 +8986,7 @@ class EventHandler {
|
|
|
8978
8986
|
this.env = options.env;
|
|
8979
8987
|
this.eventTypes = options.eventTypes;
|
|
8980
8988
|
this.onEvent = options.onEvent;
|
|
8989
|
+
this.onEventWithEnv = options.onEventWithEnv;
|
|
8981
8990
|
this.formatter = options.formatter ?? new EventMessageFormatter;
|
|
8982
8991
|
this.isIdle = options.isIdle ?? (() => true);
|
|
8983
8992
|
this.idleCheckInterval = options.idleCheckInterval ?? 100;
|
|
@@ -9021,14 +9030,14 @@ class EventHandler {
|
|
|
9021
9030
|
if (this.isStopped) {
|
|
9022
9031
|
return;
|
|
9023
9032
|
}
|
|
9024
|
-
const
|
|
9025
|
-
this.enqueue(
|
|
9033
|
+
const formatted = this.formatter.formatWithEvent(event);
|
|
9034
|
+
this.enqueue(formatted);
|
|
9026
9035
|
}
|
|
9027
|
-
enqueue(
|
|
9036
|
+
enqueue(formattedEvent) {
|
|
9028
9037
|
if (this.isStopped) {
|
|
9029
9038
|
return;
|
|
9030
9039
|
}
|
|
9031
|
-
this.queue.push(
|
|
9040
|
+
this.queue.push(formattedEvent);
|
|
9032
9041
|
if (!this.isProcessing) {
|
|
9033
9042
|
this.processQueue();
|
|
9034
9043
|
}
|
|
@@ -9046,12 +9055,16 @@ class EventHandler {
|
|
|
9046
9055
|
if (this.isStopped) {
|
|
9047
9056
|
break;
|
|
9048
9057
|
}
|
|
9049
|
-
const
|
|
9050
|
-
if (!
|
|
9058
|
+
const item = this.queue.shift();
|
|
9059
|
+
if (!item) {
|
|
9051
9060
|
break;
|
|
9052
9061
|
}
|
|
9053
9062
|
try {
|
|
9054
|
-
|
|
9063
|
+
if (this.onEventWithEnv) {
|
|
9064
|
+
await this.onEventWithEnv(item);
|
|
9065
|
+
continue;
|
|
9066
|
+
}
|
|
9067
|
+
await this.onEvent(item.message);
|
|
9055
9068
|
} catch (error) {
|
|
9056
9069
|
console.error(`[EventHandler] 处理事件失败:`, error);
|
|
9057
9070
|
}
|
|
@@ -9323,11 +9336,34 @@ ${COLORS.system("[通知] ❯ " + message.replace(/\n/g, `
|
|
|
9323
9336
|
`);
|
|
9324
9337
|
await this.executeInternal(message, { showPrompt: true });
|
|
9325
9338
|
}
|
|
9339
|
+
async handleEventMessageWithEnv(formattedEvent) {
|
|
9340
|
+
const { message, envEvent } = formattedEvent;
|
|
9341
|
+
console.log(`
|
|
9342
|
+
${COLORS.system("[通知2] ❯ " + message.replace(/\n/g, `
|
|
9343
|
+
` + COLORS.system("[通知2] ❯ ")))}
|
|
9344
|
+
`);
|
|
9345
|
+
const sourceId = envEvent.metadata?.sourceId;
|
|
9346
|
+
const plugins = envEvent.metadata?.plugins || [];
|
|
9347
|
+
const pluginEnabled = {};
|
|
9348
|
+
for (const pluginName of plugins) {
|
|
9349
|
+
const key = `${sourceId}:${pluginName}`;
|
|
9350
|
+
pluginEnabled[key] = true;
|
|
9351
|
+
}
|
|
9352
|
+
this.currentAgentContext = {
|
|
9353
|
+
pluginEnabled,
|
|
9354
|
+
envEvent,
|
|
9355
|
+
plugins
|
|
9356
|
+
};
|
|
9357
|
+
await this.executeInternal(message, { showPrompt: true });
|
|
9358
|
+
}
|
|
9359
|
+
currentAgentContext = undefined;
|
|
9326
9360
|
isIdle() {
|
|
9327
9361
|
return !this.isExecuting;
|
|
9328
9362
|
}
|
|
9329
9363
|
async executeInternal(message, options) {
|
|
9330
9364
|
this.isExecuting = true;
|
|
9365
|
+
const agentContext = this.currentAgentContext;
|
|
9366
|
+
this.currentAgentContext = undefined;
|
|
9331
9367
|
resetStreamAbort();
|
|
9332
9368
|
const provider = getTracerProvider4();
|
|
9333
9369
|
const tracer = provider.getTracer("roy-tracer");
|
|
@@ -9337,7 +9373,7 @@ ${COLORS.system("[通知] ❯ " + message.replace(/\n/g, `
|
|
|
9337
9373
|
console.log(`${COLORS.system("[Trace] " + traceId)}`);
|
|
9338
9374
|
console.log(`${COLORS.progress("[thinking...]")}`);
|
|
9339
9375
|
try {
|
|
9340
|
-
await this.options.onExecute(message, traceId);
|
|
9376
|
+
await this.options.onExecute(message, traceId, agentContext);
|
|
9341
9377
|
} catch (error) {
|
|
9342
9378
|
const askUserError = this.parseAskUserError(error);
|
|
9343
9379
|
if (askUserError) {
|
|
@@ -9730,16 +9766,21 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
9730
9766
|
output.error(`❌ 加载 coder-harness 插件失败: ${error}`);
|
|
9731
9767
|
}
|
|
9732
9768
|
}
|
|
9769
|
+
let currentAgentContext = undefined;
|
|
9733
9770
|
const repl = new REPL({
|
|
9734
9771
|
sessionId,
|
|
9735
9772
|
sessionTitle,
|
|
9736
|
-
onExecute: async (message, traceId) => {
|
|
9773
|
+
onExecute: async (message, traceId, agentContext) => {
|
|
9737
9774
|
resetStreamAbort();
|
|
9775
|
+
const mergedContext = {
|
|
9776
|
+
...currentAgentContext,
|
|
9777
|
+
...agentContext
|
|
9778
|
+
};
|
|
9738
9779
|
return queryExecutor.execute(message, sessionId, {
|
|
9739
9780
|
showReasoning: args.reasoning,
|
|
9740
9781
|
showToolCalls: args.toolCalls,
|
|
9741
9782
|
showToolResults: args.toolResults
|
|
9742
|
-
}, traceId);
|
|
9783
|
+
}, traceId, mergedContext);
|
|
9743
9784
|
},
|
|
9744
9785
|
onStatus: async () => {
|
|
9745
9786
|
const session = await sessionComponent.get(sessionId);
|
|
@@ -9811,6 +9852,9 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
9811
9852
|
isIdle: () => repl.isIdle(),
|
|
9812
9853
|
onEvent: async (message) => {
|
|
9813
9854
|
await repl.handleEventMessage(message);
|
|
9855
|
+
},
|
|
9856
|
+
onEventWithEnv: async (formattedEvent) => {
|
|
9857
|
+
await repl.handleEventMessageWithEnv(formattedEvent);
|
|
9814
9858
|
}
|
|
9815
9859
|
});
|
|
9816
9860
|
const stopEventHandler = eventHandler.start();
|
package/dist/index.js
CHANGED
|
@@ -7219,7 +7219,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
7219
7219
|
var require_package = __commonJS((exports, module) => {
|
|
7220
7220
|
module.exports = {
|
|
7221
7221
|
name: "@ai-setting/roy-agent-cli",
|
|
7222
|
-
version: "1.5.
|
|
7222
|
+
version: "1.5.38",
|
|
7223
7223
|
type: "module",
|
|
7224
7224
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
7225
7225
|
main: "./dist/index.js",
|
|
@@ -7246,7 +7246,7 @@ var require_package = __commonJS((exports, module) => {
|
|
|
7246
7246
|
},
|
|
7247
7247
|
dependencies: {
|
|
7248
7248
|
"@ai-setting/roy-agent-coder-harness": "^1.5.36",
|
|
7249
|
-
"@ai-setting/roy-agent-core": "^1.5.
|
|
7249
|
+
"@ai-setting/roy-agent-core": "^1.5.36",
|
|
7250
7250
|
chalk: "^5.6.2",
|
|
7251
7251
|
commander: "^14.0.3",
|
|
7252
7252
|
effect: "^3.21.2",
|
|
@@ -8735,7 +8735,7 @@ class QueryExecutor {
|
|
|
8735
8735
|
}
|
|
8736
8736
|
this.streamService?.handleEvent(event);
|
|
8737
8737
|
}
|
|
8738
|
-
async execute(message, sessionId, streamOptions, traceId) {
|
|
8738
|
+
async execute(message, sessionId, streamOptions, traceId, agentContext) {
|
|
8739
8739
|
const options = {
|
|
8740
8740
|
showReasoning: streamOptions?.showReasoning ?? this.streamOptions.showReasoning,
|
|
8741
8741
|
showToolCalls: streamOptions?.showToolCalls ?? this.streamOptions.showToolCalls,
|
|
@@ -8753,7 +8753,8 @@ class QueryExecutor {
|
|
|
8753
8753
|
metadata: {
|
|
8754
8754
|
originalQuery: message,
|
|
8755
8755
|
traceId
|
|
8756
|
-
}
|
|
8756
|
+
},
|
|
8757
|
+
...agentContext
|
|
8757
8758
|
};
|
|
8758
8759
|
let span;
|
|
8759
8760
|
const tracer = getTracerProvider3().getTracer("roy-tracer");
|
|
@@ -8959,6 +8960,12 @@ class EventMessageFormatter {
|
|
|
8959
8960
|
const seconds = Math.floor(ms % 60000 / 1000);
|
|
8960
8961
|
return `${minutes}分${seconds}秒`;
|
|
8961
8962
|
}
|
|
8963
|
+
formatWithEvent(event) {
|
|
8964
|
+
return {
|
|
8965
|
+
message: this.format(event),
|
|
8966
|
+
envEvent: event
|
|
8967
|
+
};
|
|
8968
|
+
}
|
|
8962
8969
|
}
|
|
8963
8970
|
|
|
8964
8971
|
// src/commands/shared/event-handler.ts
|
|
@@ -8966,6 +8973,7 @@ class EventHandler {
|
|
|
8966
8973
|
env;
|
|
8967
8974
|
eventTypes;
|
|
8968
8975
|
onEvent;
|
|
8976
|
+
onEventWithEnv;
|
|
8969
8977
|
formatter;
|
|
8970
8978
|
isIdle;
|
|
8971
8979
|
idleCheckInterval;
|
|
@@ -8977,6 +8985,7 @@ class EventHandler {
|
|
|
8977
8985
|
this.env = options.env;
|
|
8978
8986
|
this.eventTypes = options.eventTypes;
|
|
8979
8987
|
this.onEvent = options.onEvent;
|
|
8988
|
+
this.onEventWithEnv = options.onEventWithEnv;
|
|
8980
8989
|
this.formatter = options.formatter ?? new EventMessageFormatter;
|
|
8981
8990
|
this.isIdle = options.isIdle ?? (() => true);
|
|
8982
8991
|
this.idleCheckInterval = options.idleCheckInterval ?? 100;
|
|
@@ -9020,14 +9029,14 @@ class EventHandler {
|
|
|
9020
9029
|
if (this.isStopped) {
|
|
9021
9030
|
return;
|
|
9022
9031
|
}
|
|
9023
|
-
const
|
|
9024
|
-
this.enqueue(
|
|
9032
|
+
const formatted = this.formatter.formatWithEvent(event);
|
|
9033
|
+
this.enqueue(formatted);
|
|
9025
9034
|
}
|
|
9026
|
-
enqueue(
|
|
9035
|
+
enqueue(formattedEvent) {
|
|
9027
9036
|
if (this.isStopped) {
|
|
9028
9037
|
return;
|
|
9029
9038
|
}
|
|
9030
|
-
this.queue.push(
|
|
9039
|
+
this.queue.push(formattedEvent);
|
|
9031
9040
|
if (!this.isProcessing) {
|
|
9032
9041
|
this.processQueue();
|
|
9033
9042
|
}
|
|
@@ -9045,12 +9054,16 @@ class EventHandler {
|
|
|
9045
9054
|
if (this.isStopped) {
|
|
9046
9055
|
break;
|
|
9047
9056
|
}
|
|
9048
|
-
const
|
|
9049
|
-
if (!
|
|
9057
|
+
const item = this.queue.shift();
|
|
9058
|
+
if (!item) {
|
|
9050
9059
|
break;
|
|
9051
9060
|
}
|
|
9052
9061
|
try {
|
|
9053
|
-
|
|
9062
|
+
if (this.onEventWithEnv) {
|
|
9063
|
+
await this.onEventWithEnv(item);
|
|
9064
|
+
continue;
|
|
9065
|
+
}
|
|
9066
|
+
await this.onEvent(item.message);
|
|
9054
9067
|
} catch (error) {
|
|
9055
9068
|
console.error(`[EventHandler] 处理事件失败:`, error);
|
|
9056
9069
|
}
|
|
@@ -9322,11 +9335,34 @@ ${COLORS.system("[通知] ❯ " + message.replace(/\n/g, `
|
|
|
9322
9335
|
`);
|
|
9323
9336
|
await this.executeInternal(message, { showPrompt: true });
|
|
9324
9337
|
}
|
|
9338
|
+
async handleEventMessageWithEnv(formattedEvent) {
|
|
9339
|
+
const { message, envEvent } = formattedEvent;
|
|
9340
|
+
console.log(`
|
|
9341
|
+
${COLORS.system("[通知2] ❯ " + message.replace(/\n/g, `
|
|
9342
|
+
` + COLORS.system("[通知2] ❯ ")))}
|
|
9343
|
+
`);
|
|
9344
|
+
const sourceId = envEvent.metadata?.sourceId;
|
|
9345
|
+
const plugins = envEvent.metadata?.plugins || [];
|
|
9346
|
+
const pluginEnabled = {};
|
|
9347
|
+
for (const pluginName of plugins) {
|
|
9348
|
+
const key = `${sourceId}:${pluginName}`;
|
|
9349
|
+
pluginEnabled[key] = true;
|
|
9350
|
+
}
|
|
9351
|
+
this.currentAgentContext = {
|
|
9352
|
+
pluginEnabled,
|
|
9353
|
+
envEvent,
|
|
9354
|
+
plugins
|
|
9355
|
+
};
|
|
9356
|
+
await this.executeInternal(message, { showPrompt: true });
|
|
9357
|
+
}
|
|
9358
|
+
currentAgentContext = undefined;
|
|
9325
9359
|
isIdle() {
|
|
9326
9360
|
return !this.isExecuting;
|
|
9327
9361
|
}
|
|
9328
9362
|
async executeInternal(message, options) {
|
|
9329
9363
|
this.isExecuting = true;
|
|
9364
|
+
const agentContext = this.currentAgentContext;
|
|
9365
|
+
this.currentAgentContext = undefined;
|
|
9330
9366
|
resetStreamAbort();
|
|
9331
9367
|
const provider = getTracerProvider4();
|
|
9332
9368
|
const tracer = provider.getTracer("roy-tracer");
|
|
@@ -9336,7 +9372,7 @@ ${COLORS.system("[通知] ❯ " + message.replace(/\n/g, `
|
|
|
9336
9372
|
console.log(`${COLORS.system("[Trace] " + traceId)}`);
|
|
9337
9373
|
console.log(`${COLORS.progress("[thinking...]")}`);
|
|
9338
9374
|
try {
|
|
9339
|
-
await this.options.onExecute(message, traceId);
|
|
9375
|
+
await this.options.onExecute(message, traceId, agentContext);
|
|
9340
9376
|
} catch (error) {
|
|
9341
9377
|
const askUserError = this.parseAskUserError(error);
|
|
9342
9378
|
if (askUserError) {
|
|
@@ -9729,16 +9765,21 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
9729
9765
|
output.error(`❌ 加载 coder-harness 插件失败: ${error}`);
|
|
9730
9766
|
}
|
|
9731
9767
|
}
|
|
9768
|
+
let currentAgentContext = undefined;
|
|
9732
9769
|
const repl = new REPL({
|
|
9733
9770
|
sessionId,
|
|
9734
9771
|
sessionTitle,
|
|
9735
|
-
onExecute: async (message, traceId) => {
|
|
9772
|
+
onExecute: async (message, traceId, agentContext) => {
|
|
9736
9773
|
resetStreamAbort();
|
|
9774
|
+
const mergedContext = {
|
|
9775
|
+
...currentAgentContext,
|
|
9776
|
+
...agentContext
|
|
9777
|
+
};
|
|
9737
9778
|
return queryExecutor.execute(message, sessionId, {
|
|
9738
9779
|
showReasoning: args.reasoning,
|
|
9739
9780
|
showToolCalls: args.toolCalls,
|
|
9740
9781
|
showToolResults: args.toolResults
|
|
9741
|
-
}, traceId);
|
|
9782
|
+
}, traceId, mergedContext);
|
|
9742
9783
|
},
|
|
9743
9784
|
onStatus: async () => {
|
|
9744
9785
|
const session = await sessionComponent.get(sessionId);
|
|
@@ -9810,6 +9851,9 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
9810
9851
|
isIdle: () => repl.isIdle(),
|
|
9811
9852
|
onEvent: async (message) => {
|
|
9812
9853
|
await repl.handleEventMessage(message);
|
|
9854
|
+
},
|
|
9855
|
+
onEventWithEnv: async (formattedEvent) => {
|
|
9856
|
+
await repl.handleEventMessageWithEnv(formattedEvent);
|
|
9813
9857
|
}
|
|
9814
9858
|
});
|
|
9815
9859
|
const stopEventHandler = eventHandler.start();
|
|
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.38",
|
|
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.36",
|
|
30
|
-
"@ai-setting/roy-agent-core": "^1.5.
|
|
30
|
+
"@ai-setting/roy-agent-core": "^1.5.36",
|
|
31
31
|
"chalk": "^5.6.2",
|
|
32
32
|
"commander": "^14.0.3",
|
|
33
33
|
"effect": "^3.21.2",
|