@ai-setting/roy-agent-cli 1.5.97 → 1.5.98
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 +38 -4
- package/dist/index.js +38 -4
- package/dist/roy-agent-linux-x64/bin/roy-agent +0 -0
- package/package.json +1 -1
package/dist/bin/roy-agent.js
CHANGED
|
@@ -7427,7 +7427,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
7427
7427
|
var require_package = __commonJS((exports, module) => {
|
|
7428
7428
|
module.exports = {
|
|
7429
7429
|
name: "@ai-setting/roy-agent-cli",
|
|
7430
|
-
version: "1.5.
|
|
7430
|
+
version: "1.5.98",
|
|
7431
7431
|
type: "module",
|
|
7432
7432
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
7433
7433
|
main: "./dist/index.js",
|
|
@@ -9363,6 +9363,8 @@ class EventHandler {
|
|
|
9363
9363
|
isProcessing = false;
|
|
9364
9364
|
isStopped = false;
|
|
9365
9365
|
unsubscribe = null;
|
|
9366
|
+
sessionComponent = null;
|
|
9367
|
+
activeEventSessionId = null;
|
|
9366
9368
|
constructor(options) {
|
|
9367
9369
|
this.env = options.env;
|
|
9368
9370
|
this.eventTypes = options.eventTypes;
|
|
@@ -9371,6 +9373,7 @@ class EventHandler {
|
|
|
9371
9373
|
this.formatter = options.formatter ?? new EventMessageFormatter;
|
|
9372
9374
|
this.isIdle = options.isIdle ?? (() => true);
|
|
9373
9375
|
this.idleCheckInterval = options.idleCheckInterval ?? 100;
|
|
9376
|
+
this.sessionComponent = options.sessionComponent ?? null;
|
|
9374
9377
|
}
|
|
9375
9378
|
start() {
|
|
9376
9379
|
this.isStopped = false;
|
|
@@ -9406,6 +9409,7 @@ class EventHandler {
|
|
|
9406
9409
|
}
|
|
9407
9410
|
this.queue = [];
|
|
9408
9411
|
this.isProcessing = false;
|
|
9412
|
+
this.clearActiveSession();
|
|
9409
9413
|
}
|
|
9410
9414
|
handleEvent(event) {
|
|
9411
9415
|
if (this.isStopped) {
|
|
@@ -9431,6 +9435,7 @@ class EventHandler {
|
|
|
9431
9435
|
}
|
|
9432
9436
|
async processQueue() {
|
|
9433
9437
|
this.isProcessing = true;
|
|
9438
|
+
const sessionId = await this.ensureActiveSession();
|
|
9434
9439
|
while (!this.isStopped && this.queue.length > 0) {
|
|
9435
9440
|
await this.waitForIdle();
|
|
9436
9441
|
if (this.isStopped) {
|
|
@@ -9440,6 +9445,9 @@ class EventHandler {
|
|
|
9440
9445
|
if (!item) {
|
|
9441
9446
|
break;
|
|
9442
9447
|
}
|
|
9448
|
+
if (sessionId) {
|
|
9449
|
+
item.eventSessionId = sessionId;
|
|
9450
|
+
}
|
|
9443
9451
|
try {
|
|
9444
9452
|
if (this.onEventWithEnv) {
|
|
9445
9453
|
await this.onEventWithEnv(item);
|
|
@@ -9450,8 +9458,31 @@ class EventHandler {
|
|
|
9450
9458
|
console.error(`[EventHandler] 处理事件失败:`, error);
|
|
9451
9459
|
}
|
|
9452
9460
|
}
|
|
9461
|
+
this.clearActiveSession();
|
|
9453
9462
|
this.isProcessing = false;
|
|
9454
9463
|
}
|
|
9464
|
+
async ensureActiveSession() {
|
|
9465
|
+
if (!this.sessionComponent)
|
|
9466
|
+
return null;
|
|
9467
|
+
if (this.activeEventSessionId)
|
|
9468
|
+
return this.activeEventSessionId;
|
|
9469
|
+
try {
|
|
9470
|
+
const session = await this.sessionComponent.create({
|
|
9471
|
+
title: `Event Session - ${new Date().toLocaleString("zh-CN")}`
|
|
9472
|
+
});
|
|
9473
|
+
this.activeEventSessionId = session.id;
|
|
9474
|
+
return session.id;
|
|
9475
|
+
} catch (error) {
|
|
9476
|
+
console.error(`[EventHandler] 创建事件 session 失败:`, error);
|
|
9477
|
+
return null;
|
|
9478
|
+
}
|
|
9479
|
+
}
|
|
9480
|
+
clearActiveSession() {
|
|
9481
|
+
this.activeEventSessionId = null;
|
|
9482
|
+
}
|
|
9483
|
+
getActiveEventSessionId() {
|
|
9484
|
+
return this.activeEventSessionId;
|
|
9485
|
+
}
|
|
9455
9486
|
async waitForIdle() {
|
|
9456
9487
|
while (!this.isStopped && !this.isIdle()) {
|
|
9457
9488
|
await this.sleep(this.idleCheckInterval);
|
|
@@ -10076,7 +10107,7 @@ ${COLORS.system("[通知] ❯ " + message.replace(/\n/g, `
|
|
|
10076
10107
|
await this.executeInternal(message, { showPrompt: true });
|
|
10077
10108
|
}
|
|
10078
10109
|
async handleEventMessageWithEnv(formattedEvent) {
|
|
10079
|
-
const { message, envEvent } = formattedEvent;
|
|
10110
|
+
const { message, envEvent, eventSessionId } = formattedEvent;
|
|
10080
10111
|
console.log(`
|
|
10081
10112
|
${COLORS.system("[通知2] ❯ " + message.replace(/\n/g, `
|
|
10082
10113
|
` + COLORS.system("[通知2] ❯ ")))}
|
|
@@ -10096,7 +10127,8 @@ ${COLORS.system("[通知2] ❯ " + message.replace(/\n/g, `
|
|
|
10096
10127
|
agentType: agentFromEvent,
|
|
10097
10128
|
pluginEnabled,
|
|
10098
10129
|
envEvent,
|
|
10099
|
-
plugins
|
|
10130
|
+
plugins,
|
|
10131
|
+
eventSessionId
|
|
10100
10132
|
};
|
|
10101
10133
|
await this.executeInternal(message, { showPrompt: true });
|
|
10102
10134
|
}
|
|
@@ -10550,7 +10582,8 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
10550
10582
|
model: args.model,
|
|
10551
10583
|
...agentContext
|
|
10552
10584
|
};
|
|
10553
|
-
const
|
|
10585
|
+
const effectiveSessionId = mergedContext.eventSessionId ?? sessionId;
|
|
10586
|
+
const result = await queryExecutor.execute(message, effectiveSessionId, {
|
|
10554
10587
|
showReasoning: args.reasoning,
|
|
10555
10588
|
showToolCalls: args.toolCalls,
|
|
10556
10589
|
showToolResults: args.toolResults
|
|
@@ -10612,6 +10645,7 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
10612
10645
|
eventTypes: ["task.background.*", "event-source.event.*"],
|
|
10613
10646
|
formatter: new EventMessageFormatter({ prefix: "[通知]" }),
|
|
10614
10647
|
isIdle: () => repl.isIdle(),
|
|
10648
|
+
sessionComponent,
|
|
10615
10649
|
onEvent: async (message) => {
|
|
10616
10650
|
await repl.handleEventMessage(message);
|
|
10617
10651
|
},
|
package/dist/index.js
CHANGED
|
@@ -7426,7 +7426,7 @@ var require_dist = __commonJS((exports) => {
|
|
|
7426
7426
|
var require_package = __commonJS((exports, module) => {
|
|
7427
7427
|
module.exports = {
|
|
7428
7428
|
name: "@ai-setting/roy-agent-cli",
|
|
7429
|
-
version: "1.5.
|
|
7429
|
+
version: "1.5.98",
|
|
7430
7430
|
type: "module",
|
|
7431
7431
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
7432
7432
|
main: "./dist/index.js",
|
|
@@ -9362,6 +9362,8 @@ class EventHandler {
|
|
|
9362
9362
|
isProcessing = false;
|
|
9363
9363
|
isStopped = false;
|
|
9364
9364
|
unsubscribe = null;
|
|
9365
|
+
sessionComponent = null;
|
|
9366
|
+
activeEventSessionId = null;
|
|
9365
9367
|
constructor(options) {
|
|
9366
9368
|
this.env = options.env;
|
|
9367
9369
|
this.eventTypes = options.eventTypes;
|
|
@@ -9370,6 +9372,7 @@ class EventHandler {
|
|
|
9370
9372
|
this.formatter = options.formatter ?? new EventMessageFormatter;
|
|
9371
9373
|
this.isIdle = options.isIdle ?? (() => true);
|
|
9372
9374
|
this.idleCheckInterval = options.idleCheckInterval ?? 100;
|
|
9375
|
+
this.sessionComponent = options.sessionComponent ?? null;
|
|
9373
9376
|
}
|
|
9374
9377
|
start() {
|
|
9375
9378
|
this.isStopped = false;
|
|
@@ -9405,6 +9408,7 @@ class EventHandler {
|
|
|
9405
9408
|
}
|
|
9406
9409
|
this.queue = [];
|
|
9407
9410
|
this.isProcessing = false;
|
|
9411
|
+
this.clearActiveSession();
|
|
9408
9412
|
}
|
|
9409
9413
|
handleEvent(event) {
|
|
9410
9414
|
if (this.isStopped) {
|
|
@@ -9430,6 +9434,7 @@ class EventHandler {
|
|
|
9430
9434
|
}
|
|
9431
9435
|
async processQueue() {
|
|
9432
9436
|
this.isProcessing = true;
|
|
9437
|
+
const sessionId = await this.ensureActiveSession();
|
|
9433
9438
|
while (!this.isStopped && this.queue.length > 0) {
|
|
9434
9439
|
await this.waitForIdle();
|
|
9435
9440
|
if (this.isStopped) {
|
|
@@ -9439,6 +9444,9 @@ class EventHandler {
|
|
|
9439
9444
|
if (!item) {
|
|
9440
9445
|
break;
|
|
9441
9446
|
}
|
|
9447
|
+
if (sessionId) {
|
|
9448
|
+
item.eventSessionId = sessionId;
|
|
9449
|
+
}
|
|
9442
9450
|
try {
|
|
9443
9451
|
if (this.onEventWithEnv) {
|
|
9444
9452
|
await this.onEventWithEnv(item);
|
|
@@ -9449,8 +9457,31 @@ class EventHandler {
|
|
|
9449
9457
|
console.error(`[EventHandler] 处理事件失败:`, error);
|
|
9450
9458
|
}
|
|
9451
9459
|
}
|
|
9460
|
+
this.clearActiveSession();
|
|
9452
9461
|
this.isProcessing = false;
|
|
9453
9462
|
}
|
|
9463
|
+
async ensureActiveSession() {
|
|
9464
|
+
if (!this.sessionComponent)
|
|
9465
|
+
return null;
|
|
9466
|
+
if (this.activeEventSessionId)
|
|
9467
|
+
return this.activeEventSessionId;
|
|
9468
|
+
try {
|
|
9469
|
+
const session = await this.sessionComponent.create({
|
|
9470
|
+
title: `Event Session - ${new Date().toLocaleString("zh-CN")}`
|
|
9471
|
+
});
|
|
9472
|
+
this.activeEventSessionId = session.id;
|
|
9473
|
+
return session.id;
|
|
9474
|
+
} catch (error) {
|
|
9475
|
+
console.error(`[EventHandler] 创建事件 session 失败:`, error);
|
|
9476
|
+
return null;
|
|
9477
|
+
}
|
|
9478
|
+
}
|
|
9479
|
+
clearActiveSession() {
|
|
9480
|
+
this.activeEventSessionId = null;
|
|
9481
|
+
}
|
|
9482
|
+
getActiveEventSessionId() {
|
|
9483
|
+
return this.activeEventSessionId;
|
|
9484
|
+
}
|
|
9454
9485
|
async waitForIdle() {
|
|
9455
9486
|
while (!this.isStopped && !this.isIdle()) {
|
|
9456
9487
|
await this.sleep(this.idleCheckInterval);
|
|
@@ -10075,7 +10106,7 @@ ${COLORS.system("[通知] ❯ " + message.replace(/\n/g, `
|
|
|
10075
10106
|
await this.executeInternal(message, { showPrompt: true });
|
|
10076
10107
|
}
|
|
10077
10108
|
async handleEventMessageWithEnv(formattedEvent) {
|
|
10078
|
-
const { message, envEvent } = formattedEvent;
|
|
10109
|
+
const { message, envEvent, eventSessionId } = formattedEvent;
|
|
10079
10110
|
console.log(`
|
|
10080
10111
|
${COLORS.system("[通知2] ❯ " + message.replace(/\n/g, `
|
|
10081
10112
|
` + COLORS.system("[通知2] ❯ ")))}
|
|
@@ -10095,7 +10126,8 @@ ${COLORS.system("[通知2] ❯ " + message.replace(/\n/g, `
|
|
|
10095
10126
|
agentType: agentFromEvent,
|
|
10096
10127
|
pluginEnabled,
|
|
10097
10128
|
envEvent,
|
|
10098
|
-
plugins
|
|
10129
|
+
plugins,
|
|
10130
|
+
eventSessionId
|
|
10099
10131
|
};
|
|
10100
10132
|
await this.executeInternal(message, { showPrompt: true });
|
|
10101
10133
|
}
|
|
@@ -10549,7 +10581,8 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
10549
10581
|
model: args.model,
|
|
10550
10582
|
...agentContext
|
|
10551
10583
|
};
|
|
10552
|
-
const
|
|
10584
|
+
const effectiveSessionId = mergedContext.eventSessionId ?? sessionId;
|
|
10585
|
+
const result = await queryExecutor.execute(message, effectiveSessionId, {
|
|
10553
10586
|
showReasoning: args.reasoning,
|
|
10554
10587
|
showToolCalls: args.toolCalls,
|
|
10555
10588
|
showToolResults: args.toolResults
|
|
@@ -10611,6 +10644,7 @@ function createInteractiveCommand(externalEnvService) {
|
|
|
10611
10644
|
eventTypes: ["task.background.*", "event-source.event.*"],
|
|
10612
10645
|
formatter: new EventMessageFormatter({ prefix: "[通知]" }),
|
|
10613
10646
|
isIdle: () => repl.isIdle(),
|
|
10647
|
+
sessionComponent,
|
|
10614
10648
|
onEvent: async (message) => {
|
|
10615
10649
|
await repl.handleEventMessage(message);
|
|
10616
10650
|
},
|
|
Binary file
|