@firtoz/chat-agent 1.0.1 → 2.0.0
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/README.md +99 -349
- package/package.json +13 -19
- package/src/chat-agent-base.ts +731 -303
- package/src/chat-messages.ts +81 -5
- package/src/index.ts +11 -22
- package/src/chat-agent-drizzle.ts +0 -227
- package/src/chat-agent-sql.ts +0 -199
- package/src/db/index.ts +0 -21
- package/src/db/schema.ts +0 -47
package/src/db/schema.ts
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { sqliteTable, text, integer } from "drizzle-orm/sqlite-core";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Chat messages table
|
|
5
|
-
* Stores the full conversation history for each agent session
|
|
6
|
-
* Messages are stored as JSON to support complex structures (tool calls, etc.)
|
|
7
|
-
*/
|
|
8
|
-
export const messagesTable = sqliteTable("messages", {
|
|
9
|
-
id: text("id").primaryKey(),
|
|
10
|
-
role: text("role", { enum: ["user", "assistant", "tool"] }).notNull(),
|
|
11
|
-
// JSON-serialized message data (content, toolCalls, toolCallId, etc.)
|
|
12
|
-
messageJson: text("message_json").notNull(),
|
|
13
|
-
createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Stream chunks table for resumable streaming
|
|
18
|
-
* Buffers streamed content so clients can resume mid-stream
|
|
19
|
-
*/
|
|
20
|
-
export const streamChunksTable = sqliteTable("stream_chunks", {
|
|
21
|
-
id: text("id").primaryKey(),
|
|
22
|
-
streamId: text("stream_id").notNull(),
|
|
23
|
-
content: text("content").notNull(),
|
|
24
|
-
chunkIndex: integer("chunk_index").notNull(),
|
|
25
|
-
createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Stream metadata table for tracking active/completed streams
|
|
30
|
-
*/
|
|
31
|
-
export const streamMetadataTable = sqliteTable("stream_metadata", {
|
|
32
|
-
id: text("id").primaryKey(),
|
|
33
|
-
messageId: text("message_id").notNull(), // The assistant message being streamed
|
|
34
|
-
status: text("status", {
|
|
35
|
-
enum: ["streaming", "completed", "error"],
|
|
36
|
-
}).notNull(),
|
|
37
|
-
createdAt: integer("created_at", { mode: "timestamp_ms" }).notNull(),
|
|
38
|
-
completedAt: integer("completed_at", { mode: "timestamp_ms" }),
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
// Type exports for use in the agent
|
|
42
|
-
export type Message = typeof messagesTable.$inferSelect;
|
|
43
|
-
export type NewMessage = typeof messagesTable.$inferInsert;
|
|
44
|
-
export type StreamChunk = typeof streamChunksTable.$inferSelect;
|
|
45
|
-
export type NewStreamChunk = typeof streamChunksTable.$inferInsert;
|
|
46
|
-
export type StreamMeta = typeof streamMetadataTable.$inferSelect;
|
|
47
|
-
export type NewStreamMeta = typeof streamMetadataTable.$inferInsert;
|