@ai-setting/roy-agent-cli 1.7.30 → 1.7.32
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 +92 -4
- package/dist/index.js +92 -4
- package/dist/roy-agent-linux-x64/bin/roy-agent +2 -2
- package/package.json +1 -1
package/dist/bin/roy-agent.js
CHANGED
|
@@ -9461,7 +9461,7 @@ class CliQuietModeService {
|
|
|
9461
9461
|
// package.json
|
|
9462
9462
|
var package_default = {
|
|
9463
9463
|
name: "@ai-setting/roy-agent-cli",
|
|
9464
|
-
version: "1.7.
|
|
9464
|
+
version: "1.7.32",
|
|
9465
9465
|
type: "module",
|
|
9466
9466
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
9467
9467
|
main: "./dist/index.js",
|
|
@@ -11498,10 +11498,12 @@ subSessionId: ${payload.subSessionId}`;
|
|
|
11498
11498
|
}
|
|
11499
11499
|
formatWithEvent(event) {
|
|
11500
11500
|
const triggerSessionId = extractTriggerSessionId(event);
|
|
11501
|
+
const chatId = extractChatId(event);
|
|
11501
11502
|
return {
|
|
11502
11503
|
message: this.format(event),
|
|
11503
11504
|
envEvent: event,
|
|
11504
|
-
triggerSessionId
|
|
11505
|
+
triggerSessionId,
|
|
11506
|
+
chatId
|
|
11505
11507
|
};
|
|
11506
11508
|
}
|
|
11507
11509
|
}
|
|
@@ -11512,6 +11514,18 @@ function extractTriggerSessionId(event) {
|
|
|
11512
11514
|
}
|
|
11513
11515
|
return;
|
|
11514
11516
|
}
|
|
11517
|
+
function extractChatId(event) {
|
|
11518
|
+
const metaChannel = event?.metadata?.replyChannel;
|
|
11519
|
+
if (metaChannel?.chatId && typeof metaChannel.chatId === "string" && metaChannel.chatId.length > 0) {
|
|
11520
|
+
return metaChannel.chatId;
|
|
11521
|
+
}
|
|
11522
|
+
const payload = event?.payload;
|
|
11523
|
+
const payloadChannel = payload?.replyChannel;
|
|
11524
|
+
if (payloadChannel?.chatId && typeof payloadChannel.chatId === "string" && payloadChannel.chatId.length > 0) {
|
|
11525
|
+
return payloadChannel.chatId;
|
|
11526
|
+
}
|
|
11527
|
+
return;
|
|
11528
|
+
}
|
|
11515
11529
|
|
|
11516
11530
|
// src/commands/shared/event-handler.ts
|
|
11517
11531
|
import { TracedAs as TracedAs5 } from "@ai-setting/roy-agent-core";
|
|
@@ -11529,6 +11543,7 @@ class EventHandler {
|
|
|
11529
11543
|
unsubscribe = null;
|
|
11530
11544
|
sessionComponent = null;
|
|
11531
11545
|
activeEventSessionId = null;
|
|
11546
|
+
activeEventSessionChatId = null;
|
|
11532
11547
|
constructor(options) {
|
|
11533
11548
|
this.env = options.env;
|
|
11534
11549
|
this.eventTypes = options.eventTypes;
|
|
@@ -11632,8 +11647,27 @@ class EventHandler {
|
|
|
11632
11647
|
async ensureActiveSession() {
|
|
11633
11648
|
if (!this.sessionComponent)
|
|
11634
11649
|
return null;
|
|
11635
|
-
|
|
11636
|
-
|
|
11650
|
+
const queueChatId = this.queue.map((item) => item.chatId).find((id) => !!id);
|
|
11651
|
+
if (this.activeEventSessionId) {
|
|
11652
|
+
const isChatSwitch = this.activeEventSessionChatId !== null && queueChatId !== undefined && this.activeEventSessionChatId !== queueChatId;
|
|
11653
|
+
if (!isChatSwitch) {
|
|
11654
|
+
return this.activeEventSessionId;
|
|
11655
|
+
}
|
|
11656
|
+
this.activeEventSessionId = null;
|
|
11657
|
+
this.activeEventSessionChatId = null;
|
|
11658
|
+
}
|
|
11659
|
+
if (queueChatId) {
|
|
11660
|
+
const chatSessionId = await this.ensureChatSession(queueChatId);
|
|
11661
|
+
if (chatSessionId) {
|
|
11662
|
+
if (this.isStopped) {
|
|
11663
|
+
return null;
|
|
11664
|
+
}
|
|
11665
|
+
this.activeEventSessionId = chatSessionId;
|
|
11666
|
+
this.activeEventSessionChatId = queueChatId;
|
|
11667
|
+
return chatSessionId;
|
|
11668
|
+
}
|
|
11669
|
+
console.warn(`[EventHandler] Failed to ensure chat-keyed session (chatId=${queueChatId}), ` + `falling back to trigger_session_id path`);
|
|
11670
|
+
}
|
|
11637
11671
|
const triggerSessionId = this.queue.map((item) => item.triggerSessionId).find((id) => !!id);
|
|
11638
11672
|
if (triggerSessionId) {
|
|
11639
11673
|
try {
|
|
@@ -11668,6 +11702,45 @@ class EventHandler {
|
|
|
11668
11702
|
}
|
|
11669
11703
|
return this.createNewEventSession();
|
|
11670
11704
|
}
|
|
11705
|
+
async ensureChatSession(chatId) {
|
|
11706
|
+
if (!this.sessionComponent)
|
|
11707
|
+
return null;
|
|
11708
|
+
try {
|
|
11709
|
+
const existing = await this.sessionComponent.list({
|
|
11710
|
+
filter: { metadata: { chatId, type: "lark-chat" } },
|
|
11711
|
+
limit: 1
|
|
11712
|
+
});
|
|
11713
|
+
if (existing.length > 0) {
|
|
11714
|
+
return existing[0].id;
|
|
11715
|
+
}
|
|
11716
|
+
} catch (error) {
|
|
11717
|
+
console.error(`[EventHandler] Failed to list chat-keyed sessions (chatId=${chatId}):`, error);
|
|
11718
|
+
}
|
|
11719
|
+
try {
|
|
11720
|
+
const created = await this.sessionComponent.create({
|
|
11721
|
+
id: chatId,
|
|
11722
|
+
title: `Lark Chat ${chatId}`,
|
|
11723
|
+
metadata: {
|
|
11724
|
+
chatId,
|
|
11725
|
+
type: "lark-chat"
|
|
11726
|
+
}
|
|
11727
|
+
});
|
|
11728
|
+
if (this.isStopped) {
|
|
11729
|
+
return null;
|
|
11730
|
+
}
|
|
11731
|
+
return created.id;
|
|
11732
|
+
} catch (createErr) {
|
|
11733
|
+
console.warn(`[EventHandler] Failed to create chat-keyed session (chatId=${chatId}), ` + `trying get(): ${String(createErr)}`);
|
|
11734
|
+
try {
|
|
11735
|
+
const fallback = await this.sessionComponent.get(chatId);
|
|
11736
|
+
if (fallback)
|
|
11737
|
+
return fallback.id;
|
|
11738
|
+
} catch (getErr) {
|
|
11739
|
+
console.error(`[EventHandler] get() fallback also failed (chatId=${chatId}):`, getErr);
|
|
11740
|
+
}
|
|
11741
|
+
return null;
|
|
11742
|
+
}
|
|
11743
|
+
}
|
|
11671
11744
|
async createNewEventSession() {
|
|
11672
11745
|
try {
|
|
11673
11746
|
const session = await this.sessionComponent.create({
|
|
@@ -11687,6 +11760,7 @@ class EventHandler {
|
|
|
11687
11760
|
}
|
|
11688
11761
|
clearActiveSession() {
|
|
11689
11762
|
this.activeEventSessionId = null;
|
|
11763
|
+
this.activeEventSessionChatId = null;
|
|
11690
11764
|
}
|
|
11691
11765
|
getActiveEventSessionId() {
|
|
11692
11766
|
return this.activeEventSessionId;
|
|
@@ -11708,6 +11782,20 @@ __legacyDecorateClassTS([
|
|
|
11708
11782
|
]),
|
|
11709
11783
|
__legacyMetadataTS("design:returntype", undefined)
|
|
11710
11784
|
], EventHandler.prototype, "handleEvent", null);
|
|
11785
|
+
__legacyDecorateClassTS([
|
|
11786
|
+
TracedAs5("cli.event-handler.ensureActiveSession", { recordParams: true }),
|
|
11787
|
+
__legacyMetadataTS("design:type", Function),
|
|
11788
|
+
__legacyMetadataTS("design:paramtypes", []),
|
|
11789
|
+
__legacyMetadataTS("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
11790
|
+
], EventHandler.prototype, "ensureActiveSession", null);
|
|
11791
|
+
__legacyDecorateClassTS([
|
|
11792
|
+
TracedAs5("cli.event-handler.ensureChatSession", { recordParams: true }),
|
|
11793
|
+
__legacyMetadataTS("design:type", Function),
|
|
11794
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
11795
|
+
String
|
|
11796
|
+
]),
|
|
11797
|
+
__legacyMetadataTS("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
11798
|
+
], EventHandler.prototype, "ensureChatSession", null);
|
|
11711
11799
|
|
|
11712
11800
|
// src/commands/shared/esc-active-descendant.ts
|
|
11713
11801
|
function hasActiveDescendants(env, parentSessionId) {
|
package/dist/index.js
CHANGED
|
@@ -9460,7 +9460,7 @@ class CliQuietModeService {
|
|
|
9460
9460
|
// package.json
|
|
9461
9461
|
var package_default = {
|
|
9462
9462
|
name: "@ai-setting/roy-agent-cli",
|
|
9463
|
-
version: "1.7.
|
|
9463
|
+
version: "1.7.32",
|
|
9464
9464
|
type: "module",
|
|
9465
9465
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
9466
9466
|
main: "./dist/index.js",
|
|
@@ -11497,10 +11497,12 @@ subSessionId: ${payload.subSessionId}`;
|
|
|
11497
11497
|
}
|
|
11498
11498
|
formatWithEvent(event) {
|
|
11499
11499
|
const triggerSessionId = extractTriggerSessionId(event);
|
|
11500
|
+
const chatId = extractChatId(event);
|
|
11500
11501
|
return {
|
|
11501
11502
|
message: this.format(event),
|
|
11502
11503
|
envEvent: event,
|
|
11503
|
-
triggerSessionId
|
|
11504
|
+
triggerSessionId,
|
|
11505
|
+
chatId
|
|
11504
11506
|
};
|
|
11505
11507
|
}
|
|
11506
11508
|
}
|
|
@@ -11511,6 +11513,18 @@ function extractTriggerSessionId(event) {
|
|
|
11511
11513
|
}
|
|
11512
11514
|
return;
|
|
11513
11515
|
}
|
|
11516
|
+
function extractChatId(event) {
|
|
11517
|
+
const metaChannel = event?.metadata?.replyChannel;
|
|
11518
|
+
if (metaChannel?.chatId && typeof metaChannel.chatId === "string" && metaChannel.chatId.length > 0) {
|
|
11519
|
+
return metaChannel.chatId;
|
|
11520
|
+
}
|
|
11521
|
+
const payload = event?.payload;
|
|
11522
|
+
const payloadChannel = payload?.replyChannel;
|
|
11523
|
+
if (payloadChannel?.chatId && typeof payloadChannel.chatId === "string" && payloadChannel.chatId.length > 0) {
|
|
11524
|
+
return payloadChannel.chatId;
|
|
11525
|
+
}
|
|
11526
|
+
return;
|
|
11527
|
+
}
|
|
11514
11528
|
|
|
11515
11529
|
// src/commands/shared/event-handler.ts
|
|
11516
11530
|
import { TracedAs as TracedAs5 } from "@ai-setting/roy-agent-core";
|
|
@@ -11528,6 +11542,7 @@ class EventHandler {
|
|
|
11528
11542
|
unsubscribe = null;
|
|
11529
11543
|
sessionComponent = null;
|
|
11530
11544
|
activeEventSessionId = null;
|
|
11545
|
+
activeEventSessionChatId = null;
|
|
11531
11546
|
constructor(options) {
|
|
11532
11547
|
this.env = options.env;
|
|
11533
11548
|
this.eventTypes = options.eventTypes;
|
|
@@ -11631,8 +11646,27 @@ class EventHandler {
|
|
|
11631
11646
|
async ensureActiveSession() {
|
|
11632
11647
|
if (!this.sessionComponent)
|
|
11633
11648
|
return null;
|
|
11634
|
-
|
|
11635
|
-
|
|
11649
|
+
const queueChatId = this.queue.map((item) => item.chatId).find((id) => !!id);
|
|
11650
|
+
if (this.activeEventSessionId) {
|
|
11651
|
+
const isChatSwitch = this.activeEventSessionChatId !== null && queueChatId !== undefined && this.activeEventSessionChatId !== queueChatId;
|
|
11652
|
+
if (!isChatSwitch) {
|
|
11653
|
+
return this.activeEventSessionId;
|
|
11654
|
+
}
|
|
11655
|
+
this.activeEventSessionId = null;
|
|
11656
|
+
this.activeEventSessionChatId = null;
|
|
11657
|
+
}
|
|
11658
|
+
if (queueChatId) {
|
|
11659
|
+
const chatSessionId = await this.ensureChatSession(queueChatId);
|
|
11660
|
+
if (chatSessionId) {
|
|
11661
|
+
if (this.isStopped) {
|
|
11662
|
+
return null;
|
|
11663
|
+
}
|
|
11664
|
+
this.activeEventSessionId = chatSessionId;
|
|
11665
|
+
this.activeEventSessionChatId = queueChatId;
|
|
11666
|
+
return chatSessionId;
|
|
11667
|
+
}
|
|
11668
|
+
console.warn(`[EventHandler] Failed to ensure chat-keyed session (chatId=${queueChatId}), ` + `falling back to trigger_session_id path`);
|
|
11669
|
+
}
|
|
11636
11670
|
const triggerSessionId = this.queue.map((item) => item.triggerSessionId).find((id) => !!id);
|
|
11637
11671
|
if (triggerSessionId) {
|
|
11638
11672
|
try {
|
|
@@ -11667,6 +11701,45 @@ class EventHandler {
|
|
|
11667
11701
|
}
|
|
11668
11702
|
return this.createNewEventSession();
|
|
11669
11703
|
}
|
|
11704
|
+
async ensureChatSession(chatId) {
|
|
11705
|
+
if (!this.sessionComponent)
|
|
11706
|
+
return null;
|
|
11707
|
+
try {
|
|
11708
|
+
const existing = await this.sessionComponent.list({
|
|
11709
|
+
filter: { metadata: { chatId, type: "lark-chat" } },
|
|
11710
|
+
limit: 1
|
|
11711
|
+
});
|
|
11712
|
+
if (existing.length > 0) {
|
|
11713
|
+
return existing[0].id;
|
|
11714
|
+
}
|
|
11715
|
+
} catch (error) {
|
|
11716
|
+
console.error(`[EventHandler] Failed to list chat-keyed sessions (chatId=${chatId}):`, error);
|
|
11717
|
+
}
|
|
11718
|
+
try {
|
|
11719
|
+
const created = await this.sessionComponent.create({
|
|
11720
|
+
id: chatId,
|
|
11721
|
+
title: `Lark Chat ${chatId}`,
|
|
11722
|
+
metadata: {
|
|
11723
|
+
chatId,
|
|
11724
|
+
type: "lark-chat"
|
|
11725
|
+
}
|
|
11726
|
+
});
|
|
11727
|
+
if (this.isStopped) {
|
|
11728
|
+
return null;
|
|
11729
|
+
}
|
|
11730
|
+
return created.id;
|
|
11731
|
+
} catch (createErr) {
|
|
11732
|
+
console.warn(`[EventHandler] Failed to create chat-keyed session (chatId=${chatId}), ` + `trying get(): ${String(createErr)}`);
|
|
11733
|
+
try {
|
|
11734
|
+
const fallback = await this.sessionComponent.get(chatId);
|
|
11735
|
+
if (fallback)
|
|
11736
|
+
return fallback.id;
|
|
11737
|
+
} catch (getErr) {
|
|
11738
|
+
console.error(`[EventHandler] get() fallback also failed (chatId=${chatId}):`, getErr);
|
|
11739
|
+
}
|
|
11740
|
+
return null;
|
|
11741
|
+
}
|
|
11742
|
+
}
|
|
11670
11743
|
async createNewEventSession() {
|
|
11671
11744
|
try {
|
|
11672
11745
|
const session = await this.sessionComponent.create({
|
|
@@ -11686,6 +11759,7 @@ class EventHandler {
|
|
|
11686
11759
|
}
|
|
11687
11760
|
clearActiveSession() {
|
|
11688
11761
|
this.activeEventSessionId = null;
|
|
11762
|
+
this.activeEventSessionChatId = null;
|
|
11689
11763
|
}
|
|
11690
11764
|
getActiveEventSessionId() {
|
|
11691
11765
|
return this.activeEventSessionId;
|
|
@@ -11707,6 +11781,20 @@ __legacyDecorateClassTS([
|
|
|
11707
11781
|
]),
|
|
11708
11782
|
__legacyMetadataTS("design:returntype", undefined)
|
|
11709
11783
|
], EventHandler.prototype, "handleEvent", null);
|
|
11784
|
+
__legacyDecorateClassTS([
|
|
11785
|
+
TracedAs5("cli.event-handler.ensureActiveSession", { recordParams: true }),
|
|
11786
|
+
__legacyMetadataTS("design:type", Function),
|
|
11787
|
+
__legacyMetadataTS("design:paramtypes", []),
|
|
11788
|
+
__legacyMetadataTS("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
11789
|
+
], EventHandler.prototype, "ensureActiveSession", null);
|
|
11790
|
+
__legacyDecorateClassTS([
|
|
11791
|
+
TracedAs5("cli.event-handler.ensureChatSession", { recordParams: true }),
|
|
11792
|
+
__legacyMetadataTS("design:type", Function),
|
|
11793
|
+
__legacyMetadataTS("design:paramtypes", [
|
|
11794
|
+
String
|
|
11795
|
+
]),
|
|
11796
|
+
__legacyMetadataTS("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
11797
|
+
], EventHandler.prototype, "ensureChatSession", null);
|
|
11710
11798
|
|
|
11711
11799
|
// src/commands/shared/esc-active-descendant.ts
|
|
11712
11800
|
function hasActiveDescendants(env, parentSessionId) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
[diffend] Oversized file quarantined before diffing.
|
|
2
2
|
name: package/dist/roy-agent-linux-x64/bin/roy-agent
|
|
3
|
-
size:
|
|
4
|
-
sha256:
|
|
3
|
+
size: 109566080 bytes
|
|
4
|
+
sha256: fafb83fff1f9f1e3c89084bd1e8c561bbc2e8f8d9653b81710947fc9d55198d5
|