fix: scope proposals to chat users
This commit is contained in:
+13
-5
@@ -37,6 +37,7 @@ class FakeRuntime implements ConversationRuntime {
|
||||
confirmResult = true;
|
||||
stopResult = true;
|
||||
proposals: Proposal[] = [];
|
||||
commandUsers: Record<string, string | undefined> = {};
|
||||
|
||||
async prompt(request: ConversationRequest) {
|
||||
return new Promise<{ text: string; botId: string; agentId: string }>((resolve, reject) => {
|
||||
@@ -47,12 +48,13 @@ class FakeRuntime implements ConversationRuntime {
|
||||
});
|
||||
});
|
||||
}
|
||||
async cancel() { this.cancelled++; return this.cancelResult; }
|
||||
async confirm() { this.confirmed++; return this.confirmResult; }
|
||||
async stop() { this.stopped++; return this.stopResult; }
|
||||
listProposals() { this.listed++; return this.proposals; }
|
||||
async cancel(_platform: string, _chatId: string, userId: string) { this.cancelled++; this.commandUsers.cancel = userId; return this.cancelResult; }
|
||||
async confirm(_platform: string, _chatId: string, userId: string) { this.confirmed++; this.commandUsers.confirm = userId; return this.confirmResult; }
|
||||
async stop(_platform: string, _chatId: string, userId: string) { this.stopped++; this.commandUsers.stop = userId; return this.stopResult; }
|
||||
listProposals(_platform: string, _chatId: string, userId: string) { this.listed++; this.commandUsers.list = userId; return this.proposals; }
|
||||
async reset() {}
|
||||
status() {
|
||||
status(_platform?: string, _chatId?: string, userId?: string) {
|
||||
this.commandUsers.status = userId;
|
||||
return {
|
||||
bot: "test-bot", agent: "kimi", workspace: "/tmp",
|
||||
running: this.turns.length > 0, phase: "processing"
|
||||
@@ -228,6 +230,7 @@ test("status and help reach the runtime or reply directly", async () => {
|
||||
|
||||
const status = await gateway.receive(message("/status"), adapter, { synchronous: true });
|
||||
assert.match(status.reply || "", /running=true/);
|
||||
assert.equal(runtime.commandUsers.status, "user");
|
||||
const help = await gateway.receive(message("/help"), adapter, { synchronous: true });
|
||||
assert.match(help.reply || "", /自然语言/);
|
||||
assert.match(help.reply || "", /\/confirm/);
|
||||
@@ -262,6 +265,11 @@ test("list, confirm, stop, and cancel forward to the runtime with the chat ident
|
||||
assert.equal(runtime.cancelled, 1);
|
||||
assert.equal(cancel.reply, "已取消最近的提案。");
|
||||
|
||||
assert.equal(runtime.commandUsers.list, "user");
|
||||
assert.equal(runtime.commandUsers.confirm, "user");
|
||||
assert.equal(runtime.commandUsers.stop, "user");
|
||||
assert.equal(runtime.commandUsers.cancel, "user");
|
||||
|
||||
runtime.confirmResult = false;
|
||||
runtime.stopResult = false;
|
||||
runtime.cancelResult = false;
|
||||
|
||||
Reference in New Issue
Block a user