@ai-setting/roy-agent-cli 1.7.35 → 1.7.37

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.
@@ -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.35",
9464
+ version: "1.7.37",
9465
9465
  type: "module",
9466
9466
  description: "CLI for roy-agent - Non-interactive command execution",
9467
9467
  main: "./dist/index.js",
@@ -11613,12 +11613,7 @@ class EventHandler {
11613
11613
  }
11614
11614
  async processQueue() {
11615
11615
  this.isProcessing = true;
11616
- const sessionId = await this.ensureActiveSession();
11617
- if (this.isStopped) {
11618
- this.clearActiveSession();
11619
- this.isProcessing = false;
11620
- return;
11621
- }
11616
+ const chatSessionCache = new Map;
11622
11617
  while (!this.isStopped && this.queue.length > 0) {
11623
11618
  await this.waitForIdle();
11624
11619
  if (this.isStopped) {
@@ -11628,6 +11623,27 @@ class EventHandler {
11628
11623
  if (!item) {
11629
11624
  break;
11630
11625
  }
11626
+ let sessionId = null;
11627
+ if (item.chatId && this.sessionComponent) {
11628
+ const cached = chatSessionCache.get(item.chatId);
11629
+ if (cached) {
11630
+ sessionId = cached;
11631
+ } else {
11632
+ sessionId = await this.ensureChatSession(item.chatId);
11633
+ if (sessionId) {
11634
+ chatSessionCache.set(item.chatId, sessionId);
11635
+ }
11636
+ }
11637
+ if (!sessionId) {
11638
+ console.warn(`[EventHandler] Failed to ensure chat-keyed session (chatId=${item.chatId}), ` + `falling back to trigger_session_id path`);
11639
+ sessionId = await this.ensureActiveSession(item.triggerSessionId);
11640
+ }
11641
+ } else {
11642
+ sessionId = await this.ensureActiveSession(item.triggerSessionId);
11643
+ }
11644
+ if (this.isStopped) {
11645
+ break;
11646
+ }
11631
11647
  if (sessionId) {
11632
11648
  item.eventSessionId = sessionId;
11633
11649
  }
@@ -11643,24 +11659,13 @@ class EventHandler {
11643
11659
  }
11644
11660
  this.isProcessing = false;
11645
11661
  }
11646
- async ensureActiveSession() {
11662
+ async ensureActiveSession(triggerSessionIdOverride) {
11647
11663
  if (!this.sessionComponent)
11648
11664
  return null;
11649
- const queueChatId = this.queue.map((item) => item.chatId).find((id) => !!id);
11650
- if (queueChatId) {
11651
- const chatSessionId = await this.ensureChatSession(queueChatId);
11652
- if (chatSessionId) {
11653
- if (this.isStopped) {
11654
- return null;
11655
- }
11656
- return chatSessionId;
11657
- }
11658
- console.warn(`[EventHandler] Failed to ensure chat-keyed session (chatId=${queueChatId}), ` + `falling back to trigger_session_id path`);
11659
- }
11660
11665
  if (this.activeEventSessionId) {
11661
11666
  return this.activeEventSessionId;
11662
11667
  }
11663
- const triggerSessionId = this.queue.map((item) => item.triggerSessionId).find((id) => !!id);
11668
+ const triggerSessionId = triggerSessionIdOverride ?? this.queue.map((item) => item.triggerSessionId).find((id) => !!id);
11664
11669
  if (triggerSessionId) {
11665
11670
  try {
11666
11671
  const existing = await this.sessionComponent.get(triggerSessionId);
@@ -11776,7 +11781,9 @@ __legacyDecorateClassTS([
11776
11781
  __legacyDecorateClassTS([
11777
11782
  TracedAs5("cli.event-handler.ensureActiveSession", { recordParams: true }),
11778
11783
  __legacyMetadataTS("design:type", Function),
11779
- __legacyMetadataTS("design:paramtypes", []),
11784
+ __legacyMetadataTS("design:paramtypes", [
11785
+ String
11786
+ ]),
11780
11787
  __legacyMetadataTS("design:returntype", typeof Promise === "undefined" ? Object : Promise)
11781
11788
  ], EventHandler.prototype, "ensureActiveSession", null);
11782
11789
  __legacyDecorateClassTS([
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.35",
9463
+ version: "1.7.37",
9464
9464
  type: "module",
9465
9465
  description: "CLI for roy-agent - Non-interactive command execution",
9466
9466
  main: "./dist/index.js",
@@ -11612,12 +11612,7 @@ class EventHandler {
11612
11612
  }
11613
11613
  async processQueue() {
11614
11614
  this.isProcessing = true;
11615
- const sessionId = await this.ensureActiveSession();
11616
- if (this.isStopped) {
11617
- this.clearActiveSession();
11618
- this.isProcessing = false;
11619
- return;
11620
- }
11615
+ const chatSessionCache = new Map;
11621
11616
  while (!this.isStopped && this.queue.length > 0) {
11622
11617
  await this.waitForIdle();
11623
11618
  if (this.isStopped) {
@@ -11627,6 +11622,27 @@ class EventHandler {
11627
11622
  if (!item) {
11628
11623
  break;
11629
11624
  }
11625
+ let sessionId = null;
11626
+ if (item.chatId && this.sessionComponent) {
11627
+ const cached = chatSessionCache.get(item.chatId);
11628
+ if (cached) {
11629
+ sessionId = cached;
11630
+ } else {
11631
+ sessionId = await this.ensureChatSession(item.chatId);
11632
+ if (sessionId) {
11633
+ chatSessionCache.set(item.chatId, sessionId);
11634
+ }
11635
+ }
11636
+ if (!sessionId) {
11637
+ console.warn(`[EventHandler] Failed to ensure chat-keyed session (chatId=${item.chatId}), ` + `falling back to trigger_session_id path`);
11638
+ sessionId = await this.ensureActiveSession(item.triggerSessionId);
11639
+ }
11640
+ } else {
11641
+ sessionId = await this.ensureActiveSession(item.triggerSessionId);
11642
+ }
11643
+ if (this.isStopped) {
11644
+ break;
11645
+ }
11630
11646
  if (sessionId) {
11631
11647
  item.eventSessionId = sessionId;
11632
11648
  }
@@ -11642,24 +11658,13 @@ class EventHandler {
11642
11658
  }
11643
11659
  this.isProcessing = false;
11644
11660
  }
11645
- async ensureActiveSession() {
11661
+ async ensureActiveSession(triggerSessionIdOverride) {
11646
11662
  if (!this.sessionComponent)
11647
11663
  return null;
11648
- const queueChatId = this.queue.map((item) => item.chatId).find((id) => !!id);
11649
- if (queueChatId) {
11650
- const chatSessionId = await this.ensureChatSession(queueChatId);
11651
- if (chatSessionId) {
11652
- if (this.isStopped) {
11653
- return null;
11654
- }
11655
- return chatSessionId;
11656
- }
11657
- console.warn(`[EventHandler] Failed to ensure chat-keyed session (chatId=${queueChatId}), ` + `falling back to trigger_session_id path`);
11658
- }
11659
11664
  if (this.activeEventSessionId) {
11660
11665
  return this.activeEventSessionId;
11661
11666
  }
11662
- const triggerSessionId = this.queue.map((item) => item.triggerSessionId).find((id) => !!id);
11667
+ const triggerSessionId = triggerSessionIdOverride ?? this.queue.map((item) => item.triggerSessionId).find((id) => !!id);
11663
11668
  if (triggerSessionId) {
11664
11669
  try {
11665
11670
  const existing = await this.sessionComponent.get(triggerSessionId);
@@ -11775,7 +11780,9 @@ __legacyDecorateClassTS([
11775
11780
  __legacyDecorateClassTS([
11776
11781
  TracedAs5("cli.event-handler.ensureActiveSession", { recordParams: true }),
11777
11782
  __legacyMetadataTS("design:type", Function),
11778
- __legacyMetadataTS("design:paramtypes", []),
11783
+ __legacyMetadataTS("design:paramtypes", [
11784
+ String
11785
+ ]),
11779
11786
  __legacyMetadataTS("design:returntype", typeof Promise === "undefined" ? Object : Promise)
11780
11787
  ], EventHandler.prototype, "ensureActiveSession", null);
11781
11788
  __legacyDecorateClassTS([
@@ -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: 109570176 bytes
4
- sha256: 2f11e708ea2db8cc9df6f97cab346d49f8d6dd811fe8bd294898f693fb31451b
3
+ size: 109578368 bytes
4
+ sha256: ad7560c97b5e09248411d66d1355e7f4c0e9d6bfbbfdf7674bf6ca63635c4fe0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-setting/roy-agent-cli",
3
- "version": "1.7.35",
3
+ "version": "1.7.37",
4
4
  "type": "module",
5
5
  "description": "CLI for roy-agent - Non-interactive command execution",
6
6
  "main": "./dist/index.js",