mirror of
https://github.com/kennethnym/freya
synced 2026-07-03 14:51:13 +01:00
feat: sendMessage rpc returns created entry
This commit is contained in:
@@ -6,5 +6,8 @@
|
||||
"types": "src/index.ts",
|
||||
"scripts": {
|
||||
"test": "bun test ./src"
|
||||
},
|
||||
"dependencies": {
|
||||
"@freya/core": "workspace:*"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,12 +1,30 @@
|
||||
import { describe, expect, test } from "bun:test"
|
||||
|
||||
import { ConversationEntryKind, ConversationEntryVisibility } from "@freya/core"
|
||||
|
||||
import type { AgentEvent, AgentServerApi } from "./index"
|
||||
|
||||
describe("agent protocol", () => {
|
||||
test("defines server methods and agent events", () => {
|
||||
const server: AgentServerApi = {
|
||||
async sendMessage(message) {
|
||||
return { message, conversationId: "conversation-1" }
|
||||
return {
|
||||
id: "entry-1",
|
||||
conversationId: "conversation-1",
|
||||
sequence: 1,
|
||||
kind: ConversationEntryKind.UserMessage,
|
||||
visibility: ConversationEntryVisibility.UserVisible,
|
||||
fileId: null,
|
||||
payload: {
|
||||
role: "user",
|
||||
parts: [{ type: "text", text: message }],
|
||||
},
|
||||
metadata: {},
|
||||
createdAt: "2026-07-03T00:00:00.000Z",
|
||||
}
|
||||
},
|
||||
notify() {
|
||||
// no-op for protocol shape test
|
||||
},
|
||||
ping() {
|
||||
return "pong"
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
import type { ConversationEntry } from "@freya/core"
|
||||
|
||||
export type AgentEvent =
|
||||
| { type: "conversation_started"; conversationId: string }
|
||||
| { type: "message_created"; text: string }
|
||||
@@ -9,7 +11,7 @@ export type AgentEvent =
|
||||
export type UserEvent = { type: "typing" }
|
||||
|
||||
export interface AgentServerApi {
|
||||
sendMessage(message: string): Promise<boolean>
|
||||
sendMessage(message: string): Promise<ConversationEntry>
|
||||
notify(event: UserEvent): void
|
||||
ping(): "pong"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user