@ai-setting/roy-agent-cli 1.7.38 → 1.7.39
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 +70 -11
- package/dist/index.js +70 -11
- 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.39",
|
|
9465
9465
|
type: "module",
|
|
9466
9466
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
9467
9467
|
main: "./dist/index.js",
|
|
@@ -11535,6 +11535,18 @@ import { EventStoreImpl, setSharedEventStore } from "@ai-setting/roy-agent-core/
|
|
|
11535
11535
|
|
|
11536
11536
|
// src/commands/shared/event-handler.ts
|
|
11537
11537
|
import { TracedAs as TracedAs5 } from "@ai-setting/roy-agent-core";
|
|
11538
|
+
function parseLarkPerTaskChatId(contextJson) {
|
|
11539
|
+
if (!contextJson)
|
|
11540
|
+
return;
|
|
11541
|
+
try {
|
|
11542
|
+
const obj = JSON.parse(contextJson);
|
|
11543
|
+
const id = obj?.larkPerTaskChatId;
|
|
11544
|
+
return typeof id === "string" && id.length > 0 ? id : undefined;
|
|
11545
|
+
} catch {
|
|
11546
|
+
return;
|
|
11547
|
+
}
|
|
11548
|
+
}
|
|
11549
|
+
|
|
11538
11550
|
class EventHandler {
|
|
11539
11551
|
env;
|
|
11540
11552
|
eventTypes;
|
|
@@ -11549,6 +11561,7 @@ class EventHandler {
|
|
|
11549
11561
|
unsubscribe = null;
|
|
11550
11562
|
sessionComponent = null;
|
|
11551
11563
|
activeEventSessionId = null;
|
|
11564
|
+
resolvedSessionByTrigger = new Map;
|
|
11552
11565
|
eventStore = null;
|
|
11553
11566
|
getHandlerForEsType = null;
|
|
11554
11567
|
constructor(options) {
|
|
@@ -11655,13 +11668,17 @@ class EventHandler {
|
|
|
11655
11668
|
error: typeof payload?.error === "string" ? payload.error : undefined
|
|
11656
11669
|
};
|
|
11657
11670
|
setTimeout(() => {
|
|
11658
|
-
|
|
11659
|
-
|
|
11660
|
-
|
|
11661
|
-
|
|
11662
|
-
|
|
11663
|
-
|
|
11664
|
-
|
|
11671
|
+
(async () => {
|
|
11672
|
+
const resolvedChatIds = await this.resolveNotifyChatIds(notifyEventForHook.taskId);
|
|
11673
|
+
await handler.postProcessNotifyEvent({
|
|
11674
|
+
notifyEvent: notifyEventForHook,
|
|
11675
|
+
triggerEvent,
|
|
11676
|
+
subAgentResult,
|
|
11677
|
+
formattedPrompt: prompt.promptText,
|
|
11678
|
+
profile,
|
|
11679
|
+
resolvedChatIds
|
|
11680
|
+
});
|
|
11681
|
+
})().catch((err) => {
|
|
11665
11682
|
console.error(`[EventHandler] postProcessNotifyEvent hook failed (swallowed)`, err);
|
|
11666
11683
|
});
|
|
11667
11684
|
}, 0);
|
|
@@ -11677,6 +11694,33 @@ class EventHandler {
|
|
|
11677
11694
|
...triggerMessageId ? { triggerMessageId } : {}
|
|
11678
11695
|
};
|
|
11679
11696
|
}
|
|
11697
|
+
async resolveNotifyChatIds(taskId) {
|
|
11698
|
+
if (!taskId)
|
|
11699
|
+
return [];
|
|
11700
|
+
const taskComp = this.env.getComponent("task");
|
|
11701
|
+
if (!taskComp?.getTask)
|
|
11702
|
+
return [];
|
|
11703
|
+
const seen = new Set;
|
|
11704
|
+
let id = taskId;
|
|
11705
|
+
while (id !== undefined && id !== null && !seen.has(id) && seen.size < 8) {
|
|
11706
|
+
seen.add(id);
|
|
11707
|
+
let task;
|
|
11708
|
+
try {
|
|
11709
|
+
task = await taskComp.getTask(id);
|
|
11710
|
+
} catch (err) {
|
|
11711
|
+
console.error(`[EventHandler] resolveNotifyChatIds: getTask(${id}) failed`, err);
|
|
11712
|
+
return [];
|
|
11713
|
+
}
|
|
11714
|
+
if (!task)
|
|
11715
|
+
return [];
|
|
11716
|
+
const chatId = parseLarkPerTaskChatId(task.context);
|
|
11717
|
+
if (chatId)
|
|
11718
|
+
return [chatId];
|
|
11719
|
+
const parent = task.parent_task_id;
|
|
11720
|
+
id = typeof parent === "number" && parent > 0 ? parent : undefined;
|
|
11721
|
+
}
|
|
11722
|
+
return [];
|
|
11723
|
+
}
|
|
11680
11724
|
async handleNotifyEventForTest(event) {
|
|
11681
11725
|
if (this.isStopped)
|
|
11682
11726
|
return;
|
|
@@ -11753,7 +11797,12 @@ class EventHandler {
|
|
|
11753
11797
|
async ensureActiveSession(triggerSessionIdOverride) {
|
|
11754
11798
|
if (!this.sessionComponent)
|
|
11755
11799
|
return null;
|
|
11756
|
-
if (
|
|
11800
|
+
if (triggerSessionIdOverride) {
|
|
11801
|
+
const cached = this.resolvedSessionByTrigger.get(triggerSessionIdOverride);
|
|
11802
|
+
if (cached) {
|
|
11803
|
+
return cached;
|
|
11804
|
+
}
|
|
11805
|
+
} else if (this.activeEventSessionId) {
|
|
11757
11806
|
return this.activeEventSessionId;
|
|
11758
11807
|
}
|
|
11759
11808
|
const triggerSessionId = triggerSessionIdOverride ?? this.queue.map((item) => item.triggerSessionId).find((id) => !!id);
|
|
@@ -11765,6 +11814,7 @@ class EventHandler {
|
|
|
11765
11814
|
return null;
|
|
11766
11815
|
}
|
|
11767
11816
|
this.activeEventSessionId = existing.id;
|
|
11817
|
+
this.cacheResolvedSession(triggerSessionIdOverride, existing.id);
|
|
11768
11818
|
await this.sessionComponent.setActiveSession(existing.id);
|
|
11769
11819
|
return existing.id;
|
|
11770
11820
|
}
|
|
@@ -11782,13 +11832,16 @@ class EventHandler {
|
|
|
11782
11832
|
return null;
|
|
11783
11833
|
}
|
|
11784
11834
|
this.activeEventSessionId = existing.id;
|
|
11835
|
+
this.cacheResolvedSession(triggerSessionIdOverride, existing.id);
|
|
11785
11836
|
return existing.id;
|
|
11786
11837
|
}
|
|
11787
11838
|
}
|
|
11788
11839
|
} catch (error) {
|
|
11789
11840
|
console.error(`[EventHandler] Failed to lookup global active session:`, error);
|
|
11790
11841
|
}
|
|
11791
|
-
|
|
11842
|
+
const created = await this.createNewEventSession();
|
|
11843
|
+
this.cacheResolvedSession(triggerSessionIdOverride, created);
|
|
11844
|
+
return created;
|
|
11792
11845
|
}
|
|
11793
11846
|
async ensureChatSession(chatId) {
|
|
11794
11847
|
if (!this.sessionComponent)
|
|
@@ -11848,6 +11901,12 @@ class EventHandler {
|
|
|
11848
11901
|
}
|
|
11849
11902
|
clearActiveSession() {
|
|
11850
11903
|
this.activeEventSessionId = null;
|
|
11904
|
+
this.resolvedSessionByTrigger.clear();
|
|
11905
|
+
}
|
|
11906
|
+
cacheResolvedSession(triggerSessionIdOverride, sessionId) {
|
|
11907
|
+
if (triggerSessionIdOverride && sessionId) {
|
|
11908
|
+
this.resolvedSessionByTrigger.set(triggerSessionIdOverride, sessionId);
|
|
11909
|
+
}
|
|
11851
11910
|
}
|
|
11852
11911
|
getActiveEventSessionId() {
|
|
11853
11912
|
return this.activeEventSessionId;
|
|
@@ -11886,7 +11945,7 @@ __legacyDecorateClassTS([
|
|
|
11886
11945
|
__legacyMetadataTS("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
11887
11946
|
], EventHandler.prototype, "formatEventViaESPluginV2", null);
|
|
11888
11947
|
__legacyDecorateClassTS([
|
|
11889
|
-
TracedAs5("cli.event-handler.ensureActiveSession", { recordParams: true }),
|
|
11948
|
+
TracedAs5("cli.event-handler.ensureActiveSession", { recordParams: true, recordResult: true }),
|
|
11890
11949
|
__legacyMetadataTS("design:type", Function),
|
|
11891
11950
|
__legacyMetadataTS("design:paramtypes", [
|
|
11892
11951
|
String
|
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.39",
|
|
9464
9464
|
type: "module",
|
|
9465
9465
|
description: "CLI for roy-agent - Non-interactive command execution",
|
|
9466
9466
|
main: "./dist/index.js",
|
|
@@ -11534,6 +11534,18 @@ import { EventStoreImpl, setSharedEventStore } from "@ai-setting/roy-agent-core/
|
|
|
11534
11534
|
|
|
11535
11535
|
// src/commands/shared/event-handler.ts
|
|
11536
11536
|
import { TracedAs as TracedAs5 } from "@ai-setting/roy-agent-core";
|
|
11537
|
+
function parseLarkPerTaskChatId(contextJson) {
|
|
11538
|
+
if (!contextJson)
|
|
11539
|
+
return;
|
|
11540
|
+
try {
|
|
11541
|
+
const obj = JSON.parse(contextJson);
|
|
11542
|
+
const id = obj?.larkPerTaskChatId;
|
|
11543
|
+
return typeof id === "string" && id.length > 0 ? id : undefined;
|
|
11544
|
+
} catch {
|
|
11545
|
+
return;
|
|
11546
|
+
}
|
|
11547
|
+
}
|
|
11548
|
+
|
|
11537
11549
|
class EventHandler {
|
|
11538
11550
|
env;
|
|
11539
11551
|
eventTypes;
|
|
@@ -11548,6 +11560,7 @@ class EventHandler {
|
|
|
11548
11560
|
unsubscribe = null;
|
|
11549
11561
|
sessionComponent = null;
|
|
11550
11562
|
activeEventSessionId = null;
|
|
11563
|
+
resolvedSessionByTrigger = new Map;
|
|
11551
11564
|
eventStore = null;
|
|
11552
11565
|
getHandlerForEsType = null;
|
|
11553
11566
|
constructor(options) {
|
|
@@ -11654,13 +11667,17 @@ class EventHandler {
|
|
|
11654
11667
|
error: typeof payload?.error === "string" ? payload.error : undefined
|
|
11655
11668
|
};
|
|
11656
11669
|
setTimeout(() => {
|
|
11657
|
-
|
|
11658
|
-
|
|
11659
|
-
|
|
11660
|
-
|
|
11661
|
-
|
|
11662
|
-
|
|
11663
|
-
|
|
11670
|
+
(async () => {
|
|
11671
|
+
const resolvedChatIds = await this.resolveNotifyChatIds(notifyEventForHook.taskId);
|
|
11672
|
+
await handler.postProcessNotifyEvent({
|
|
11673
|
+
notifyEvent: notifyEventForHook,
|
|
11674
|
+
triggerEvent,
|
|
11675
|
+
subAgentResult,
|
|
11676
|
+
formattedPrompt: prompt.promptText,
|
|
11677
|
+
profile,
|
|
11678
|
+
resolvedChatIds
|
|
11679
|
+
});
|
|
11680
|
+
})().catch((err) => {
|
|
11664
11681
|
console.error(`[EventHandler] postProcessNotifyEvent hook failed (swallowed)`, err);
|
|
11665
11682
|
});
|
|
11666
11683
|
}, 0);
|
|
@@ -11676,6 +11693,33 @@ class EventHandler {
|
|
|
11676
11693
|
...triggerMessageId ? { triggerMessageId } : {}
|
|
11677
11694
|
};
|
|
11678
11695
|
}
|
|
11696
|
+
async resolveNotifyChatIds(taskId) {
|
|
11697
|
+
if (!taskId)
|
|
11698
|
+
return [];
|
|
11699
|
+
const taskComp = this.env.getComponent("task");
|
|
11700
|
+
if (!taskComp?.getTask)
|
|
11701
|
+
return [];
|
|
11702
|
+
const seen = new Set;
|
|
11703
|
+
let id = taskId;
|
|
11704
|
+
while (id !== undefined && id !== null && !seen.has(id) && seen.size < 8) {
|
|
11705
|
+
seen.add(id);
|
|
11706
|
+
let task;
|
|
11707
|
+
try {
|
|
11708
|
+
task = await taskComp.getTask(id);
|
|
11709
|
+
} catch (err) {
|
|
11710
|
+
console.error(`[EventHandler] resolveNotifyChatIds: getTask(${id}) failed`, err);
|
|
11711
|
+
return [];
|
|
11712
|
+
}
|
|
11713
|
+
if (!task)
|
|
11714
|
+
return [];
|
|
11715
|
+
const chatId = parseLarkPerTaskChatId(task.context);
|
|
11716
|
+
if (chatId)
|
|
11717
|
+
return [chatId];
|
|
11718
|
+
const parent = task.parent_task_id;
|
|
11719
|
+
id = typeof parent === "number" && parent > 0 ? parent : undefined;
|
|
11720
|
+
}
|
|
11721
|
+
return [];
|
|
11722
|
+
}
|
|
11679
11723
|
async handleNotifyEventForTest(event) {
|
|
11680
11724
|
if (this.isStopped)
|
|
11681
11725
|
return;
|
|
@@ -11752,7 +11796,12 @@ class EventHandler {
|
|
|
11752
11796
|
async ensureActiveSession(triggerSessionIdOverride) {
|
|
11753
11797
|
if (!this.sessionComponent)
|
|
11754
11798
|
return null;
|
|
11755
|
-
if (
|
|
11799
|
+
if (triggerSessionIdOverride) {
|
|
11800
|
+
const cached = this.resolvedSessionByTrigger.get(triggerSessionIdOverride);
|
|
11801
|
+
if (cached) {
|
|
11802
|
+
return cached;
|
|
11803
|
+
}
|
|
11804
|
+
} else if (this.activeEventSessionId) {
|
|
11756
11805
|
return this.activeEventSessionId;
|
|
11757
11806
|
}
|
|
11758
11807
|
const triggerSessionId = triggerSessionIdOverride ?? this.queue.map((item) => item.triggerSessionId).find((id) => !!id);
|
|
@@ -11764,6 +11813,7 @@ class EventHandler {
|
|
|
11764
11813
|
return null;
|
|
11765
11814
|
}
|
|
11766
11815
|
this.activeEventSessionId = existing.id;
|
|
11816
|
+
this.cacheResolvedSession(triggerSessionIdOverride, existing.id);
|
|
11767
11817
|
await this.sessionComponent.setActiveSession(existing.id);
|
|
11768
11818
|
return existing.id;
|
|
11769
11819
|
}
|
|
@@ -11781,13 +11831,16 @@ class EventHandler {
|
|
|
11781
11831
|
return null;
|
|
11782
11832
|
}
|
|
11783
11833
|
this.activeEventSessionId = existing.id;
|
|
11834
|
+
this.cacheResolvedSession(triggerSessionIdOverride, existing.id);
|
|
11784
11835
|
return existing.id;
|
|
11785
11836
|
}
|
|
11786
11837
|
}
|
|
11787
11838
|
} catch (error) {
|
|
11788
11839
|
console.error(`[EventHandler] Failed to lookup global active session:`, error);
|
|
11789
11840
|
}
|
|
11790
|
-
|
|
11841
|
+
const created = await this.createNewEventSession();
|
|
11842
|
+
this.cacheResolvedSession(triggerSessionIdOverride, created);
|
|
11843
|
+
return created;
|
|
11791
11844
|
}
|
|
11792
11845
|
async ensureChatSession(chatId) {
|
|
11793
11846
|
if (!this.sessionComponent)
|
|
@@ -11847,6 +11900,12 @@ class EventHandler {
|
|
|
11847
11900
|
}
|
|
11848
11901
|
clearActiveSession() {
|
|
11849
11902
|
this.activeEventSessionId = null;
|
|
11903
|
+
this.resolvedSessionByTrigger.clear();
|
|
11904
|
+
}
|
|
11905
|
+
cacheResolvedSession(triggerSessionIdOverride, sessionId) {
|
|
11906
|
+
if (triggerSessionIdOverride && sessionId) {
|
|
11907
|
+
this.resolvedSessionByTrigger.set(triggerSessionIdOverride, sessionId);
|
|
11908
|
+
}
|
|
11850
11909
|
}
|
|
11851
11910
|
getActiveEventSessionId() {
|
|
11852
11911
|
return this.activeEventSessionId;
|
|
@@ -11885,7 +11944,7 @@ __legacyDecorateClassTS([
|
|
|
11885
11944
|
__legacyMetadataTS("design:returntype", typeof Promise === "undefined" ? Object : Promise)
|
|
11886
11945
|
], EventHandler.prototype, "formatEventViaESPluginV2", null);
|
|
11887
11946
|
__legacyDecorateClassTS([
|
|
11888
|
-
TracedAs5("cli.event-handler.ensureActiveSession", { recordParams: true }),
|
|
11947
|
+
TracedAs5("cli.event-handler.ensureActiveSession", { recordParams: true, recordResult: true }),
|
|
11889
11948
|
__legacyMetadataTS("design:type", Function),
|
|
11890
11949
|
__legacyMetadataTS("design:paramtypes", [
|
|
11891
11950
|
String
|
|
@@ -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: 109615232 bytes
|
|
4
|
+
sha256: bc11a701a8e4abd25b0b9ba8acc34523b56c936f17885321dd6ad9f4b331cf85
|