feat(agent): refactor database session storage to normalized DAG entries and lazy thread sync

This commit is contained in:
yiling
2026-07-28 11:21:31 +08:00
parent b876af464e
commit 4e2694e2d9
21 changed files with 930 additions and 252 deletions
+61 -2
View File
@@ -546,13 +546,72 @@ describe('Agent Database Activities Integration', () => {
// Verify historical comment is converted and saved to entries (mentions replaced, prefixes added) // Verify historical comment is converted and saved to entries (mentions replaced, prefixes added)
expect(agentSession?.entries.length).toBe(1) expect(agentSession?.entries.length).toBe(1)
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- entry is stored as Json in DB and needs casting to check properties // eslint-disable-next-line @typescript-eslint/no-explicit-any -- entry data is stored as Json in DB and needs casting to check properties
const parsedEntry = agentSession?.entries[0].entry as any const parsedEntry = agentSession?.entries[0].data as any
expect(parsedEntry.message.content[0].text).toContain( expect(parsedEntry.message.content[0].text).toContain(
`[${user.name} (owner)]: Hello <@${user.name}> check this`, `[${user.name} (owner)]: Hello <@${user.name}> check this`,
) )
}) })
it('should distinguish Main Session (userCommentId: null) and Thread Session (userCommentId: rootId) during lazy sync', async () => {
// 1. Top-level comments
const mainComment1 = await prisma.assetComment.create({
data: { assetId: asset.id, message: 'Main Comment 1', creatorId: user.id },
})
const mainComment2 = await prisma.assetComment.create({
data: { assetId: asset.id, message: 'Main Comment 2', creatorId: user.id },
})
// 2. Thread reply under mainComment1
const threadReply1 = await prisma.assetComment.create({
data: {
assetId: asset.id,
message: 'Thread Reply 1',
creatorId: user.id,
replyToId: mainComment1.id,
},
})
// 3. Initialize session for mention on mainComment2 (Main Session)
const mainSessionId = await initializeAgentSessionActivity({
teamId: team.id,
agentId: 'test-agent-id',
userCommentId: mainComment2.id,
userId: user.id,
})
const mainSession = await prisma.agentSession.findUnique({
where: { id: mainSessionId },
})
expect(mainSession?.userCommentId).toBeNull() // Main Session has userCommentId = null
// Retrieve main session entries
const mainEntries = await prisma.agentSessionEntry.findMany({
where: { sessionId: mainSessionId },
orderBy: { createdAt: 'asc' },
})
// Main session contains mainComment1 (with [Thread ID: <id>] tag), but NOT threadReply1
expect(mainEntries.length).toBe(1)
expect(mainEntries[0].id).toBe(mainComment1.id)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const mainEntryJson = mainEntries[0].data as any
expect(mainEntryJson.message.content[0].text).toContain(`[Thread ID: ${mainComment1.id}]`)
// 4. Initialize session for mention on threadReply1 (Thread Session)
const threadSessionId = await initializeAgentSessionActivity({
teamId: team.id,
agentId: 'test-agent-id',
userCommentId: threadReply1.id,
userId: user.id,
})
const threadSession = await prisma.agentSession.findUnique({
where: { id: threadSessionId },
})
expect(threadSession?.userCommentId).toBe(mainComment1.id) // Thread Session has userCommentId = rootComment.id
})
it('should return user name and role for team member', async () => { it('should return user name and role for team member', async () => {
const info = await getUserTeamInfoActivity({ const info = await getUserTeamInfoActivity({
userId: user.id, userId: user.id,
+169 -46
View File
@@ -490,19 +490,117 @@ export async function initializeAgentSessionActivity(params: {
include: { creator: true }, include: { creator: true },
}) })
// Create a new AgentSession if (!userComment) {
const newSession = await prisma.agentSession.create({ throw new Error(`User comment ${params.userCommentId} not found`)
data: { }
agentId,
userId: params.userId || null, const isThread = !!userComment.replyToId
cwd: process.cwd(), const rootCommentId = userComment.replyToId || userComment.id
assetId: userComment ? userComment.assetId : null, const targetUserCommentId = isThread ? rootCommentId : null
userCommentId: params.userCommentId,
let session = await prisma.agentSession.findFirst({
where: {
assetId: userComment.assetId,
type: 'comment',
userCommentId: targetUserCommentId,
}, },
}) })
const sessionId = newSession.id
// Fetch existing comments as context if (!session) {
session = await prisma.agentSession.create({
data: {
agentId,
userId: params.userId || null,
cwd: process.cwd(),
assetId: userComment.assetId,
userCommentId: targetUserCommentId,
type: 'comment',
},
})
}
const sessionId = session.id
// If this is a Thread Session, ensure preceding top-level comments up to rootCommentId are synced in Main Session first
if (isThread) {
let mainSession = await prisma.agentSession.findFirst({
where: {
assetId: userComment.assetId,
type: 'comment',
userCommentId: null,
},
})
if (!mainSession) {
mainSession = await prisma.agentSession.create({
data: {
agentId,
userId: params.userId || null,
cwd: process.cwd(),
assetId: userComment.assetId,
userCommentId: null,
type: 'comment',
},
})
}
const topLevelComments = await prisma.assetComment.findMany({
where: {
assetId: userComment.assetId,
replyToId: null,
createdAt: { lte: userComment.createdAt },
},
orderBy: { createdAt: 'asc' },
include: { creator: true },
})
let mainPrevId: string | null = mainSession.leafId
for (const c of topLevelComments) {
const existingEntry = await prisma.agentSessionEntry.findUnique({
where: { id: c.id },
select: { id: true },
})
if (existingEntry) {
mainPrevId = existingEntry.id
continue
}
const isAgent = c.creator?.type === 'agent' || c.sessionId !== null
let messageContent = c.message || ''
if (isAgent) {
const agentName = c.creator?.name || 'Ai Agent'
messageContent = `[Agent Message][${agentName}]: ${messageContent}`
} else if (c.creator?.name) {
messageContent = `[${c.creator.name} (user)]: ${messageContent}`
}
const entryId = c.id
const message: AgentMessage = {
role: 'user',
content: [{ type: 'text', text: messageContent }],
timestamp: c.createdAt.getTime(),
}
await prisma.agentSessionEntry.create({
data: {
id: entryId,
sessionId: mainSession.id,
assetId: userComment.assetId,
type: 'message',
parentId: mainPrevId,
createdAt: c.createdAt,
data: { message } as unknown as PrismaJson.PiSessionEntryData,
},
})
mainPrevId = entryId
}
if (mainPrevId && mainPrevId !== mainSession.leafId) {
await prisma.agentSession.update({
where: { id: mainSession.id },
data: { leafId: mainPrevId },
})
}
}
// Fetch existing comments as context for current session
let existingComments: Array<{ let existingComments: Array<{
id: string id: string
message: string | null message: string | null
@@ -510,36 +608,51 @@ export async function initializeAgentSessionActivity(params: {
creatorId: string | null creatorId: string | null
creator: { type: string; name: string } | null creator: { type: string; name: string } | null
sessionId: string | null sessionId: string | null
replyToId: string | null
}> = [] }> = []
if (userComment) { if (!isThread) {
if (!userComment.replyToId) { // Main Session: Only fetch top-level comments (replyToId: null)
// Rule 1: outside of a reply, add all other comments on that asset existingComments = await prisma.assetComment.findMany({
existingComments = await prisma.assetComment.findMany({ where: {
assetId: userComment.assetId,
replyToId: null,
id: { not: userComment.id },
},
orderBy: { createdAt: 'asc' },
include: { creator: true },
})
} else {
// Thread Session: Fetch root comment + replies in this specific thread (replyToId: rootCommentId)
const rootComment = await prisma.assetComment.findUnique({
where: { id: rootCommentId },
include: { creator: true },
})
if (rootComment) {
const replies = await prisma.assetComment.findMany({
where: { where: {
assetId: userComment.assetId, replyToId: rootCommentId,
id: { not: userComment.id }, id: { not: userComment.id },
}, },
orderBy: { id: 'asc' }, orderBy: { createdAt: 'asc' },
include: { creator: true }, include: { creator: true },
}) })
} else { existingComments = [rootComment, ...replies]
// Rule 2: in a reply, add root comment + all other replies to it }
const rootComment = await prisma.assetComment.findUnique({ }
where: { id: userComment.replyToId },
include: { creator: true }, // Check which top-level comments have reply threads (for prompt tagging)
}) const commentIdsWithThreads = new Set<string>()
if (rootComment) { if (!isThread && existingComments.length > 0) {
const replies = await prisma.assetComment.findMany({ const threadCounts = await prisma.assetComment.groupBy({
where: { by: ['replyToId'],
replyToId: rootComment.id, where: {
id: { not: userComment.id }, assetId: userComment.assetId,
}, replyToId: { in: existingComments.map((c) => c.id) },
orderBy: { id: 'asc' }, },
include: { creator: true }, })
}) for (const tc of threadCounts) {
existingComments = [rootComment, ...replies] if (tc.replyToId) commentIdsWithThreads.add(tc.replyToId)
}
} }
} }
@@ -594,9 +707,19 @@ export async function initializeAgentSessionActivity(params: {
} }
} }
// Save context as AgentSessionEntry records // Save context as AgentSessionEntry records (with parent pointers)
let prevId: string | null = null let prevId: string | null = session.leafId
for (const c of existingComments) { for (const c of existingComments) {
// Check if entry already exists for this comment
const existingEntry = await prisma.agentSessionEntry.findUnique({
where: { id: c.id },
select: { id: true },
})
if (existingEntry) {
prevId = existingEntry.id
continue
}
const isAgent = c.creator?.type === 'agent' || c.sessionId !== null const isAgent = c.creator?.type === 'agent' || c.sessionId !== null
let messageContent = c.message || '' let messageContent = c.message || ''
@@ -614,33 +737,33 @@ export async function initializeAgentSessionActivity(params: {
messageContent = `[${c.creator.name} (${role})]: ${messageContent}` messageContent = `[${c.creator.name} (${role})]: ${messageContent}`
} }
const entryId = ulid() if (commentIdsWithThreads.has(c.id)) {
messageContent = `[Thread ID: ${c.id}] ${messageContent}`
}
const entryId = c.id
const message: AgentMessage = { const message: AgentMessage = {
role: 'user', role: 'user',
content: [{ type: 'text', text: messageContent }], content: [{ type: 'text', text: messageContent }],
timestamp: c.createdAt.getTime(), timestamp: c.createdAt.getTime(),
} }
const entryJson: SessionTreeEntry = {
type: 'message',
id: entryId,
parentId: prevId,
timestamp: c.createdAt.toISOString(),
message,
}
await prisma.agentSessionEntry.create({ await prisma.agentSessionEntry.create({
data: { data: {
id: entryId, id: entryId,
sessionId, sessionId,
entry: entryJson as unknown as PrismaJson.PiSessionEntry, assetId: userComment.assetId,
type: 'message',
parentId: prevId,
createdAt: c.createdAt,
data: { message } as unknown as PrismaJson.PiSessionEntryData,
}, },
}) })
prevId = entryId prevId = entryId
} }
// Update leafId of the session // Update leafId of the session
if (prevId) { if (prevId && prevId !== session.leafId) {
await prisma.agentSession.update({ await prisma.agentSession.update({
where: { id: sessionId }, where: { id: sessionId },
data: { leafId: prevId }, data: { leafId: prevId },
@@ -234,10 +234,10 @@ describe('DatabaseSessionStorage', () => {
await storage.appendEntry(entry) await storage.appendEntry(entry)
// Record entry is generic Json // Record data is generic Json
const record = await prisma.agentSessionEntry.findUnique({ where: { id: 'msg-1' } }) const record = await prisma.agentSessionEntry.findUnique({ where: { id: 'msg-1' } })
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
const savedEntry = record?.entry as any const savedEntry = record?.data as any
expect(savedEntry.message.content[0].data).toBe('__S3_DATA__') expect(savedEntry.message.content[0].data).toBe('__S3_DATA__')
// Verify retrieval reinjects data // Verify retrieval reinjects data
@@ -281,7 +281,7 @@ describe('DatabaseSessionStorage', () => {
// Verify saved entry is stripped // Verify saved entry is stripped
const record = await prisma.agentSessionEntry.findUnique({ where: { id: 'msg-skill' } }) const record = await prisma.agentSessionEntry.findUnique({ where: { id: 'msg-skill' } })
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
const savedEntry = record?.entry as any const savedEntry = record?.data as any
expect(savedEntry.message.content[0].text).toBe('__SKILL_CONTENT__') expect(savedEntry.message.content[0].text).toBe('__SKILL_CONTENT__')
// Verify retrieval reinjects data // Verify retrieval reinjects data
+73 -38
View File
@@ -6,7 +6,6 @@ import {
type SessionMetadata, type SessionMetadata,
type SessionStorage, type SessionStorage,
type SessionTreeEntry, type SessionTreeEntry,
type SessionTreeEntryBase,
} from '@earendil-works/pi-agent-core' } from '@earendil-works/pi-agent-core'
import { agentService } from '@shumai/core/src/agent/agent' import { agentService } from '@shumai/core/src/agent/agent'
@@ -76,6 +75,23 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
return ulid() return ulid()
} }
private recordToEntry(record: {
id: string
type: string | null
parentId: string | null
createdAt: Date
data: unknown
}): SessionTreeEntry {
const payload = (record.data as Record<string, unknown>) || {}
return {
id: record.id,
type: (record.type || 'message') as SessionTreeEntry['type'],
parentId: record.parentId,
timestamp: record.createdAt.toISOString(),
...payload,
} as unknown as SessionTreeEntry
}
async appendEntry(entry: SessionTreeEntry): Promise<void> { async appendEntry(entry: SessionTreeEntry): Promise<void> {
const strippedEntry = structuredClone(entry) const strippedEntry = structuredClone(entry)
@@ -118,12 +134,28 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
const targetLeafId = entry.type === 'leaf' ? entry.targetId : entry.id const targetLeafId = entry.type === 'leaf' ? entry.targetId : entry.id
// Extract base fields and store type-specific properties in data payload
const payload = { ...strippedEntry } as Record<string, unknown>
delete payload.id
delete payload.type
delete payload.parentId
delete payload.timestamp
const session = await prisma.agentSession.findUnique({
where: { id: this.sessionId },
select: { assetId: true },
})
await prisma.$transaction([ await prisma.$transaction([
prisma.agentSessionEntry.create({ prisma.agentSessionEntry.create({
data: { data: {
id: entry.id, id: entry.id,
sessionId: this.sessionId, sessionId: this.sessionId,
entry: strippedEntry, assetId: session?.assetId || null,
type: entry.type,
parentId: entry.parentId || null,
createdAt: entry.timestamp ? new Date(entry.timestamp) : new Date(),
data: payload as unknown as PrismaJson.PiSessionEntryData,
}, },
}), }),
prisma.agentSession.update({ prisma.agentSession.update({
@@ -138,7 +170,7 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
where: { id }, where: { id },
}) })
if (!record) return undefined if (!record) return undefined
const entry = record.entry as unknown as SessionTreeEntry const entry = this.recordToEntry(record)
await this.reinjectImageDataAsync(entry) await this.reinjectImageDataAsync(entry)
await this.reinjectSkillContentAsync(entry) await this.reinjectSkillContentAsync(entry)
return entry return entry
@@ -150,14 +182,11 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
const records = await prisma.agentSessionEntry.findMany({ const records = await prisma.agentSessionEntry.findMany({
where: { where: {
sessionId: this.sessionId, sessionId: this.sessionId,
entry: { type,
path: ['type'],
equals: type,
},
}, },
orderBy: { id: 'asc' }, orderBy: { id: 'asc' },
}) })
const entries = records.map((r) => r.entry as unknown as SessionTreeEntry) as Array< const entries = records.map((r) => this.recordToEntry(r)) as Array<
Extract<SessionTreeEntry, { type: TType }> Extract<SessionTreeEntry, { type: TType }>
> >
for (const entry of entries) { for (const entry of entries) {
@@ -168,43 +197,49 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
} }
async getLabel(id: string): Promise<string | undefined> { async getLabel(id: string): Promise<string | undefined> {
const record = await prisma.agentSessionEntry.findFirst({ const entry = await this.getEntry(id)
where: { return (entry as { label?: string } | undefined)?.label
sessionId: this.sessionId,
entry: {
path: ['id'],
equals: id,
},
},
})
// Entry is generic Json
// eslint-disable-next-line @typescript-eslint/no-explicit-any
return (record?.entry as any)?.label
} }
async getPathToRoot(leafId: string | null): Promise<SessionTreeEntry[]> { async getPathToRoot(leafId: string | null): Promise<SessionTreeEntry[]> {
if (!leafId) return [] if (!leafId) return []
// Fetch all entries for this session in a single query to avoid N+1 problem interface EntryRow {
const records = await prisma.agentSessionEntry.findMany({ id: string
where: { sessionId: this.sessionId }, type: string | null
}) // eslint-disable-next-line @typescript-eslint/naming-convention
parent_id: string | null
// Build a map for fast lookup // eslint-disable-next-line @typescript-eslint/naming-convention
const entryMap = new Map<string, SessionTreeEntry>() created_at: Date
for (const record of records) { data: unknown
entryMap.set(record.id, record.entry as unknown as SessionTreeEntry)
} }
const pathEntries: SessionTreeEntry[] = [] const rows = await prisma.$queryRaw<EntryRow[]>`
let currentId: string | null = leafId WITH RECURSIVE entry_path AS (
SELECT id, type, parent_id, created_at, data, 1 AS depth
FROM agent_session_entries
WHERE id = ${leafId}
while (currentId) { UNION ALL
const entry = entryMap.get(currentId)
if (!entry) break SELECT e.id, e.type, e.parent_id, e.created_at, e.data, ep.depth + 1
pathEntries.unshift(entry) FROM agent_session_entries e
currentId = (entry as SessionTreeEntryBase).parentId INNER JOIN entry_path ep ON e.id = ep.parent_id
} )
SELECT id, type, parent_id, created_at, data
FROM entry_path
ORDER BY depth DESC;
`
const pathEntries: SessionTreeEntry[] = rows.map((r) =>
this.recordToEntry({
id: r.id,
type: r.type,
parentId: r.parent_id,
createdAt: r.created_at,
data: r.data,
}),
)
// Only reinject image data (which may involve S3 calls) for the entries in the path // Only reinject image data (which may involve S3 calls) for the entries in the path
for (const entry of pathEntries) { for (const entry of pathEntries) {
@@ -220,7 +255,7 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
where: { sessionId: this.sessionId }, where: { sessionId: this.sessionId },
orderBy: { id: 'asc' }, orderBy: { id: 'asc' },
}) })
const entries = records.map((r) => r.entry as unknown as SessionTreeEntry) const entries = records.map((r) => this.recordToEntry(r))
for (const entry of entries) { for (const entry of entries) {
await this.reinjectImageDataAsync(entry) await this.reinjectImageDataAsync(entry)
await this.reinjectSkillContentAsync(entry) await this.reinjectSkillContentAsync(entry)
+10 -2
View File
@@ -20,6 +20,7 @@ import { createCreateVersionTool } from './tools/create-version'
import { createListAssetsTool } from './tools/list-assets' import { createListAssetsTool } from './tools/list-assets'
import { createReadPdfPagesTool } from './tools/read-pdf-pages' import { createReadPdfPagesTool } from './tools/read-pdf-pages'
import { createReadSkillTool } from './tools/read-skill' import { createReadSkillTool } from './tools/read-skill'
import { createReadThreadTool } from './tools/read-thread'
import { createSandboxedBashTool } from './tools/sandboxed-bash' import { createSandboxedBashTool } from './tools/sandboxed-bash'
import { createScreenshotTool } from './tools/screenshot' import { createScreenshotTool } from './tools/screenshot'
@@ -264,8 +265,15 @@ export async function createAgentSession(params: CreateAgentSessionParams) {
}) })
const agentConfig = agent?.config as PrismaJson.AgentConfig | null | undefined const agentConfig = agent?.config as PrismaJson.AgentConfig | null | undefined
const deniedTools = agentConfig?.deniedTools || [] const deniedTools = agentConfig?.deniedTools || []
const readThread = createReadThreadTool()
const allTools = [...mediaTools, readSkill, sandboxedBash, ...systemTools, ...customTools] const allTools = [
...mediaTools,
readSkill,
readThread,
sandboxedBash,
...systemTools,
...customTools,
]
const enabledTools = allTools.filter((tool) => !deniedTools.includes(tool.name)) const enabledTools = allTools.filter((tool) => !deniedTools.includes(tool.name))
const harness = new AgentHarness({ const harness = new AgentHarness({
@@ -0,0 +1,79 @@
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { createReadThreadTool } from './read-thread'
import { prisma } from '@shumai/db'
vi.mock('@shumai/db', async (importOriginal) => {
const actual = await importOriginal<typeof import('@shumai/db')>()
return {
...actual,
prisma: {
assetComment: {
findUnique: vi.fn(),
findMany: vi.fn(),
},
},
}
})
describe('createReadThreadTool', () => {
beforeEach(() => {
vi.clearAllMocks()
})
it('should return error text when thread root comment is not found', async () => {
vi.mocked(prisma.assetComment.findUnique).mockResolvedValue(null)
const tool = createReadThreadTool()
const result = await tool.execute('call-1', { threadId: 'non-existent' })
const textContent = (result.content[0] as { text: string }).text
expect(textContent).toContain('Comment thread with ID "non-existent" not found.')
})
it('should return thread root message and notice when there are no replies', async () => {
vi.mocked(prisma.assetComment.findUnique).mockResolvedValue({
id: 'root-1',
message: 'Initial top-level question',
creator: { name: 'Alice' },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any)
vi.mocked(prisma.assetComment.findMany).mockResolvedValue([])
const tool = createReadThreadTool()
const result = await tool.execute('call-2', { threadId: 'root-1' })
const textContent = (result.content[0] as { text: string }).text
expect(textContent).toContain('Thread Root [Alice] (root-1): Initial top-level question')
expect(textContent).toContain('(No replies in this thread yet)')
})
it('should return thread root message and formatted replies when replies exist', async () => {
vi.mocked(prisma.assetComment.findUnique).mockResolvedValue({
id: 'root-1',
message: 'Initial top-level question',
creator: { name: 'Alice' },
// eslint-disable-next-line @typescript-eslint/no-explicit-any
} as any)
vi.mocked(prisma.assetComment.findMany).mockResolvedValue([
{
id: 'reply-1',
message: 'First reply to thread',
creator: { name: 'Bob' },
},
{
id: 'reply-2',
message: 'Second reply to thread',
creator: { name: 'Charlie' },
},
// eslint-disable-next-line @typescript-eslint/no-explicit-any
] as any)
const tool = createReadThreadTool()
const result = await tool.execute('call-3', { threadId: 'root-1' })
const textContent = (result.content[0] as { text: string }).text
expect(textContent).toContain('Thread Root [Alice] (root-1): Initial top-level question')
expect(textContent).toContain('- [Bob]: First reply to thread')
expect(textContent).toContain('- [Charlie]: Second reply to thread')
})
})
+53
View File
@@ -0,0 +1,53 @@
import { prisma } from '@shumai/db'
import { Type } from '@sinclair/typebox'
import { type AgentTool } from '@earendil-works/pi-agent-core'
const readThreadSchema = Type.Object({
threadId: Type.String({ description: 'The comment ID of the thread root' }),
})
export const createReadThreadTool = (): AgentTool<
typeof readThreadSchema,
{ threadId: string }
> => ({
name: 'read_thread',
label: 'Read Comment Thread',
description: 'Reads all comments and replies inside a specific comment thread.',
parameters: readThreadSchema,
execute: async (_toolCallId, params) => {
const rootComment = await prisma.assetComment.findUnique({
where: { id: params.threadId },
include: { creator: true },
})
if (!rootComment) {
return {
content: [{ type: 'text', text: `Comment thread with ID "${params.threadId}" not found.` }],
details: { threadId: params.threadId },
}
}
const replies = await prisma.assetComment.findMany({
where: { replyToId: rootComment.id },
orderBy: { createdAt: 'asc' },
include: { creator: true },
})
const rootAuthor = rootComment.creator?.name || 'User'
let output = `Thread Root [${rootAuthor}] (${rootComment.id}): ${rootComment.message || ''}\n\nReplies (${replies.length}):`
if (replies.length === 0) {
output += '\n(No replies in this thread yet)'
} else {
for (const reply of replies) {
const author = reply.creator?.name || 'User'
output += `\n- [${author}]: ${reply.message || ''}`
}
}
return {
content: [{ type: 'text', text: output }],
details: { threadId: params.threadId },
}
},
})
+52
View File
@@ -286,5 +286,57 @@ describe('AgentService', () => {
expect(agents[0].provider).toBeDefined() expect(agents[0].provider).toBeDefined()
expect(agents[0].modelRef).toBeDefined() expect(agents[0].modelRef).toBeDefined()
}) })
test('getSessionEntries follows parentId across shared sessions', async () => {
const db = prisma
const svc = new AgentService()
const { agent } = await setupTestData(db)
const mainSession = await db.agentSession.create({
data: {
agentId: agent.id,
type: 'comment',
cwd: '/tmp',
},
})
const threadSession = await db.agentSession.create({
data: {
agentId: agent.id,
type: 'comment',
cwd: '/tmp',
},
})
const entry1 = await db.agentSessionEntry.create({
data: {
id: '01ENTRY0000000000000000001',
sessionId: mainSession.id,
type: 'message',
parentId: null,
data: { text: 'Main Entry 1' },
},
})
const entry2 = await db.agentSessionEntry.create({
data: {
id: '01ENTRY0000000000000000002',
sessionId: threadSession.id,
type: 'message',
parentId: entry1.id,
data: { text: 'Thread Entry 2' },
},
})
await db.agentSession.update({
where: { id: threadSession.id },
data: { leafId: entry2.id },
})
const entries = await svc.getSessionEntries({ sessionId: threadSession.id })
expect(entries).toHaveLength(2)
expect(entries[0].id).toBe(entry1.id)
expect(entries[1].id).toBe(entry2.id)
})
}) })
}) })
+56 -3
View File
@@ -330,9 +330,62 @@ export class AgentService {
} }
async getSessionEntries(params: { sessionId: string }) { async getSessionEntries(params: { sessionId: string }) {
return this.prismaClient.agentSessionEntry.findMany({ const session = await this.prismaClient.agentSession.findUnique({
where: { sessionId: params.sessionId }, where: { id: params.sessionId },
orderBy: { id: 'asc' }, select: { leafId: true },
})
if (!session?.leafId) {
return []
}
interface EntryRow {
id: string
// eslint-disable-next-line @typescript-eslint/naming-convention
session_id: string | null
type: string | null
// eslint-disable-next-line @typescript-eslint/naming-convention
parent_id: string | null
// eslint-disable-next-line @typescript-eslint/naming-convention
created_at: Date
data: unknown
}
const rows = await this.prismaClient.$queryRaw<EntryRow[]>`
WITH RECURSIVE entry_path AS (
SELECT id, session_id, type, parent_id, created_at, data, 1 AS depth
FROM agent_session_entries
WHERE id = ${session.leafId}
UNION ALL
SELECT e.id, e.session_id, e.type, e.parent_id, e.created_at, e.data, ep.depth + 1
FROM agent_session_entries e
INNER JOIN entry_path ep ON e.id = ep.parent_id
)
SELECT id, session_id, type, parent_id, created_at, data
FROM entry_path
ORDER BY depth DESC;
`
return rows.map((r) => {
const payload = (r.data as Record<string, unknown>) || {}
const entryObj = {
id: r.id,
type: r.type || 'message',
parentId: r.parent_id,
timestamp: r.created_at.toISOString(),
...payload,
}
return {
id: r.id,
sessionId: r.session_id || params.sessionId,
type: r.type,
parentId: r.parent_id,
data: r.data,
createdAt: r.created_at,
entry: entryObj,
}
}) })
} }
} }
+65 -69
View File
@@ -299,20 +299,23 @@ describe('ChatService', () => {
data: { data: {
id: 'test-entry-id', id: 'test-entry-id',
sessionId, sessionId,
entry: { type: 'message',
type: 'message', parentId: null,
id: 'test-entry-id', data: {
parentId: null,
timestamp: new Date().toISOString(),
message: { message: {
role: 'user', role: 'user',
content: [{ type: 'text', text: 'hello' }], content: [{ type: 'text', text: 'hello' }],
timestamp: Date.now(), timestamp: Date.now(),
}, },
}, } as unknown as PrismaJson.PiSessionEntryData,
}, },
}) })
await prisma.agentSession.update({
where: { id: sessionId },
data: { leafId: 'test-entry-id' },
})
const messages = await chatService.listMessages(user.id, team.id, sessionId) const messages = await chatService.listMessages(user.id, team.id, sessionId)
expect(messages).toHaveLength(1) expect(messages).toHaveLength(1)
// Casting to any to access properties of union in test assertions // Casting to any to access properties of union in test assertions
@@ -336,68 +339,65 @@ describe('ChatService', () => {
data: { data: {
id: 'test-entry-1-user', id: 'test-entry-1-user',
sessionId, sessionId,
entry: { type: 'message',
type: 'message', parentId: null,
id: 'test-entry-1-user', data: {
parentId: null,
timestamp: new Date().toISOString(),
message: { message: {
role: 'user', role: 'user',
content: [{ type: 'text', text: 'hello' }], content: [{ type: 'text', text: 'hello' }],
timestamp: Date.now(), timestamp: Date.now(),
}, },
} as unknown as PrismaJson.PiSessionEntry, } as unknown as PrismaJson.PiSessionEntryData,
}, },
}) })
// 2. Manually insert a test entry representing a custom context message // 2. Manually insert a test entry representing a custom context message
await prisma.agentSessionEntry.create({ await prisma.agentSessionEntry.create({
data: { data: {
id: 'test-entry-2-context',
sessionId,
entry: {
type: 'custom_message',
id: 'test-entry-2-context', id: 'test-entry-2-context',
sessionId,
type: 'custom_message',
parentId: 'test-entry-1-user', parentId: 'test-entry-1-user',
timestamp: new Date().toISOString(),
customType: 'context',
content: 'some context',
display: 'chat',
} as unknown as PrismaJson.PiSessionEntry,
},
})
// 3. Manually insert a test entry representing a custom thinking level change
await prisma.agentSessionEntry.create({
data: {
id: 'test-entry-3-thinking',
sessionId,
entry: {
type: 'thinking_level_change',
id: 'test-entry-3-thinking',
parentId: 'test-entry-2-context',
timestamp: new Date().toISOString(),
thinkingLevel: 'deep',
} as unknown as PrismaJson.PiSessionEntry,
},
})
// 4. Manually insert a test entry representing custom context_display_info entry
await prisma.agentSessionEntry.create({
data: {
id: 'test-entry-4-display',
sessionId,
entry: {
type: 'custom',
id: 'test-entry-4-display',
parentId: 'test-entry-3-thinking',
timestamp: new Date().toISOString(),
customType: 'context_display_info',
data: { data: {
assets: [{ id: 'a1', name: 'File A', type: 'file' }], customType: 'context',
}, content: 'some context',
} as unknown as PrismaJson.PiSessionEntry, display: 'chat',
}, } as unknown as PrismaJson.PiSessionEntryData,
},
})
// 3. Manually insert a test entry representing a custom thinking level change
await prisma.agentSessionEntry.create({
data: {
id: 'test-entry-3-thinking',
sessionId,
type: 'thinking_level_change',
parentId: 'test-entry-2-context',
data: {
thinkingLevel: 'deep',
} as unknown as PrismaJson.PiSessionEntryData,
},
})
// 4. Manually insert a test entry representing custom context_display_info entry
await prisma.agentSessionEntry.create({
data: {
id: 'test-entry-4-display',
sessionId,
type: 'custom',
parentId: 'test-entry-3-thinking',
data: {
customType: 'context_display_info',
data: {
assets: [{ id: 'a1', name: 'File A', type: 'file' }],
},
} as unknown as PrismaJson.PiSessionEntryData,
},
})
await prisma.agentSession.update({
where: { id: sessionId },
data: { leafId: 'test-entry-4-display' },
}) })
// Verify listMessages returns only the user, thinking level change and custom display entry message // Verify listMessages returns only the user, thinking level change and custom display entry message
@@ -539,16 +539,14 @@ describe('ChatService', () => {
data: { data: {
id: 'entry-id-1', id: 'entry-id-1',
sessionId, sessionId,
entry: { type: 'message',
type: 'message', parentId: null,
id: 'entry-id-1', data: {
parentId: null,
timestamp: new Date().toISOString(),
message: { message: {
role: 'user', role: 'user',
content: [{ type: 'text', text: 'msg 1' }], content: [{ type: 'text', text: 'msg 1' }],
}, },
} as unknown as PrismaJson.PiSessionEntry, } as unknown as PrismaJson.PiSessionEntryData,
}, },
}) })
@@ -556,16 +554,14 @@ describe('ChatService', () => {
data: { data: {
id: 'entry-id-2', id: 'entry-id-2',
sessionId, sessionId,
entry: { type: 'message',
type: 'message', parentId: 'entry-id-1',
id: 'entry-id-2', data: {
parentId: 'entry-id-1',
timestamp: new Date().toISOString(),
message: { message: {
role: 'assistant', role: 'assistant',
content: [{ type: 'text', text: 'msg 2' }], content: [{ type: 'text', text: 'msg 2' }],
}, },
} as unknown as PrismaJson.PiSessionEntry, } as unknown as PrismaJson.PiSessionEntryData,
}, },
}) })
+31 -13
View File
@@ -5,6 +5,7 @@ import { paginateQuery, type PaginatedData } from '@shumai/core/src/pagination'
import type { ChatRequest, ChatSessionInfo, ChatMessage } from '@shumai/dtos' import type { ChatRequest, ChatSessionInfo, ChatMessage } from '@shumai/dtos'
import type { SessionTreeEntry } from '@earendil-works/pi-agent-core' import type { SessionTreeEntry } from '@earendil-works/pi-agent-core'
import { workflowService } from '@shumai/workflow-core' import { workflowService } from '@shumai/workflow-core'
import { agentService } from '@shumai/core/src/agent/agent'
type User = Prisma.UserGetPayload<Record<string, never>> type User = Prisma.UserGetPayload<Record<string, never>>
@@ -100,14 +101,22 @@ export function buildSessionMessages(pathEntries: PathEntry[]): ChatMessage[] {
export function mapEntryToMessage( export function mapEntryToMessage(
entryRecord: Prisma.AgentSessionEntryGetPayload<Record<string, never>>, entryRecord: Prisma.AgentSessionEntryGetPayload<Record<string, never>>,
): ChatMessage | null { ): ChatMessage | null {
const entryObj = entryRecord.entry as unknown as SessionTreeEntry const payload = (entryRecord.data as Record<string, unknown>) || {}
const entryObj = {
id: entryRecord.id,
type: (entryRecord.type || 'message') as SessionTreeEntry['type'],
parentId: entryRecord.parentId,
timestamp: entryRecord.createdAt.toISOString(),
...payload,
} as unknown as SessionTreeEntry
if ( if (
entryObj.type === 'custom_message' && entryObj.type === 'custom_message' &&
(entryObj as { customType?: string }).customType === 'context' (entryObj as { customType?: string }).customType === 'context'
) { ) {
return null return null
} }
const pathEntries = [{ ...entryObj, id: entryRecord.id }] const pathEntries = [entryObj]
const messages = buildSessionMessages(pathEntries) const messages = buildSessionMessages(pathEntries)
if (messages.length > 0) { if (messages.length > 0) {
return messages[0] return messages[0]
@@ -116,6 +125,7 @@ export function mapEntryToMessage(
id: entryRecord.id, id: entryRecord.id,
role: 'user', role: 'user',
content: '', content: '',
timestamp: entryRecord.createdAt.getTime(),
} as unknown as ChatMessage } as unknown as ChatMessage
} }
@@ -382,18 +392,26 @@ export class ChatService {
throw new Error('Unauthorized session access') throw new Error('Unauthorized session access')
} }
const entries = await this.prismaClient.agentSessionEntry.findMany({ const entries = await agentService.getSessionEntries({ sessionId })
where: { sessionId },
orderBy: { id: 'asc' },
})
const pathEntries = entries.map((e) => { const pathEntries = entries.map(
const entryObj = e.entry as unknown as SessionTreeEntry (e: {
return { id: string
...entryObj, type: string | null
id: e.id, parentId: string | null
} createdAt: Date
}) data: unknown
}) => {
const payload = (e.data as Record<string, unknown>) || {}
return {
id: e.id,
type: (e.type || 'message') as SessionTreeEntry['type'],
parentId: e.parentId,
timestamp: e.createdAt.toISOString(),
...payload,
} as unknown as SessionTreeEntry
},
)
return buildSessionMessages(pathEntries) return buildSessionMessages(pathEntries)
} }
@@ -0,0 +1,14 @@
-- AlterTable
ALTER TABLE "agent_session_entries" ADD COLUMN "asset_id" TEXT,
ADD COLUMN "created_at" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,
ADD COLUMN "data" JSONB,
ADD COLUMN "parent_id" TEXT,
ADD COLUMN "type" TEXT,
ALTER COLUMN "session_id" DROP NOT NULL,
ALTER COLUMN "entry" DROP NOT NULL;
-- CreateIndex
CREATE INDEX "agent_session_entries_parent_id_idx" ON "agent_session_entries"("parent_id");
-- CreateIndex
CREATE INDEX "agent_session_entries_asset_id_idx" ON "agent_session_entries"("asset_id");
@@ -0,0 +1,12 @@
-- Migrate existing entry JSON data to new columns
UPDATE agent_session_entries
SET
type = entry->>'type',
parent_id = entry->>'parentId',
asset_id = (SELECT s.asset_id FROM agent_sessions s WHERE s.id = agent_session_entries.session_id),
created_at = CASE
WHEN entry->>'timestamp' IS NOT NULL THEN (entry->>'timestamp')::timestamptz
ELSE created_at
END,
data = (entry::jsonb - 'id' - 'type' - 'parentId' - 'timestamp')::text::json
WHERE entry IS NOT NULL;
@@ -0,0 +1,8 @@
/*
Warnings:
- You are about to drop the column `entry` on the `agent_session_entries` table. All the data in the column will be lost.
*/
-- AlterTable
ALTER TABLE "agent_session_entries" DROP COLUMN "entry";
+12 -6
View File
@@ -722,14 +722,20 @@ model AgentSession {
} }
model AgentSessionEntry { model AgentSessionEntry {
id String @id // Uses ULID generated by pi-coding-agent id String @id // Uses ULID generated by pi-coding-agent
sessionId String @map("session_id") sessionId String? @map("session_id")
session AgentSession @relation(fields: [sessionId], references: [id], onDelete: Cascade) session AgentSession? @relation(fields: [sessionId], references: [id], onDelete: Cascade)
/// [PiSessionEntry] assetId String? @map("asset_id")
entry Json type String?
parentId String? @map("parent_id")
/// [PiSessionEntryData]
data Json?
createdAt DateTime @default(now()) @map("created_at")
@@map("agent_session_entries")
@@index([sessionId]) @@index([sessionId])
@@index([parentId])
@@index([assetId])
@@map("agent_session_entries")
} }
model UserMetadata { model UserMetadata {
File diff suppressed because one or more lines are too long
@@ -3397,7 +3397,11 @@ export type AgentSessionScalarFieldEnum = (typeof AgentSessionScalarFieldEnum)[k
export const AgentSessionEntryScalarFieldEnum = { export const AgentSessionEntryScalarFieldEnum = {
id: 'id', id: 'id',
sessionId: 'sessionId', sessionId: 'sessionId',
entry: 'entry' assetId: 'assetId',
type: 'type',
parentId: 'parentId',
data: 'data',
createdAt: 'createdAt'
} as const } as const
export type AgentSessionEntryScalarFieldEnum = (typeof AgentSessionEntryScalarFieldEnum)[keyof typeof AgentSessionEntryScalarFieldEnum] export type AgentSessionEntryScalarFieldEnum = (typeof AgentSessionEntryScalarFieldEnum)[keyof typeof AgentSessionEntryScalarFieldEnum]
@@ -508,7 +508,11 @@ export type AgentSessionScalarFieldEnum = (typeof AgentSessionScalarFieldEnum)[k
export const AgentSessionEntryScalarFieldEnum = { export const AgentSessionEntryScalarFieldEnum = {
id: 'id', id: 'id',
sessionId: 'sessionId', sessionId: 'sessionId',
entry: 'entry' assetId: 'assetId',
type: 'type',
parentId: 'parentId',
data: 'data',
createdAt: 'createdAt'
} as const } as const
export type AgentSessionEntryScalarFieldEnum = (typeof AgentSessionEntryScalarFieldEnum)[keyof typeof AgentSessionEntryScalarFieldEnum] export type AgentSessionEntryScalarFieldEnum = (typeof AgentSessionEntryScalarFieldEnum)[keyof typeof AgentSessionEntryScalarFieldEnum]
+3 -6
View File
@@ -474,11 +474,6 @@ export type AgentSessionMinOrderByAggregateInput = {
updatedAt?: Prisma.SortOrder updatedAt?: Prisma.SortOrder
} }
export type AgentSessionScalarRelationFilter = {
is?: Prisma.AgentSessionWhereInput
isNot?: Prisma.AgentSessionWhereInput
}
export type AgentSessionCreateNestedManyWithoutUserInput = { export type AgentSessionCreateNestedManyWithoutUserInput = {
create?: Prisma.XOR<Prisma.AgentSessionCreateWithoutUserInput, Prisma.AgentSessionUncheckedCreateWithoutUserInput> | Prisma.AgentSessionCreateWithoutUserInput[] | Prisma.AgentSessionUncheckedCreateWithoutUserInput[] create?: Prisma.XOR<Prisma.AgentSessionCreateWithoutUserInput, Prisma.AgentSessionUncheckedCreateWithoutUserInput> | Prisma.AgentSessionCreateWithoutUserInput[] | Prisma.AgentSessionUncheckedCreateWithoutUserInput[]
connectOrCreate?: Prisma.AgentSessionCreateOrConnectWithoutUserInput | Prisma.AgentSessionCreateOrConnectWithoutUserInput[] connectOrCreate?: Prisma.AgentSessionCreateOrConnectWithoutUserInput | Prisma.AgentSessionCreateOrConnectWithoutUserInput[]
@@ -631,10 +626,12 @@ export type AgentSessionCreateNestedOneWithoutEntriesInput = {
connect?: Prisma.AgentSessionWhereUniqueInput connect?: Prisma.AgentSessionWhereUniqueInput
} }
export type AgentSessionUpdateOneRequiredWithoutEntriesNestedInput = { export type AgentSessionUpdateOneWithoutEntriesNestedInput = {
create?: Prisma.XOR<Prisma.AgentSessionCreateWithoutEntriesInput, Prisma.AgentSessionUncheckedCreateWithoutEntriesInput> create?: Prisma.XOR<Prisma.AgentSessionCreateWithoutEntriesInput, Prisma.AgentSessionUncheckedCreateWithoutEntriesInput>
connectOrCreate?: Prisma.AgentSessionCreateOrConnectWithoutEntriesInput connectOrCreate?: Prisma.AgentSessionCreateOrConnectWithoutEntriesInput
upsert?: Prisma.AgentSessionUpsertWithoutEntriesInput upsert?: Prisma.AgentSessionUpsertWithoutEntriesInput
disconnect?: Prisma.AgentSessionWhereInput | boolean
delete?: Prisma.AgentSessionWhereInput | boolean
connect?: Prisma.AgentSessionWhereUniqueInput connect?: Prisma.AgentSessionWhereUniqueInput
update?: Prisma.XOR<Prisma.XOR<Prisma.AgentSessionUpdateToOneWithWhereWithoutEntriesInput, Prisma.AgentSessionUpdateWithoutEntriesInput>, Prisma.AgentSessionUncheckedUpdateWithoutEntriesInput> update?: Prisma.XOR<Prisma.XOR<Prisma.AgentSessionUpdateToOneWithWhereWithoutEntriesInput, Prisma.AgentSessionUpdateWithoutEntriesInput>, Prisma.AgentSessionUncheckedUpdateWithoutEntriesInput>
} }
+214 -55
View File
@@ -29,17 +29,29 @@ export type AggregateAgentSessionEntry = {
export type AgentSessionEntryMinAggregateOutputType = { export type AgentSessionEntryMinAggregateOutputType = {
id: string | null id: string | null
sessionId: string | null sessionId: string | null
assetId: string | null
type: string | null
parentId: string | null
createdAt: Date | null
} }
export type AgentSessionEntryMaxAggregateOutputType = { export type AgentSessionEntryMaxAggregateOutputType = {
id: string | null id: string | null
sessionId: string | null sessionId: string | null
assetId: string | null
type: string | null
parentId: string | null
createdAt: Date | null
} }
export type AgentSessionEntryCountAggregateOutputType = { export type AgentSessionEntryCountAggregateOutputType = {
id: number id: number
sessionId: number sessionId: number
entry:PrismaJson.PiSessionEntry assetId: number
type: number
parentId: number
data:PrismaJson.PiSessionEntryData
createdAt: number
_all: number _all: number
} }
@@ -47,17 +59,29 @@ export type AgentSessionEntryCountAggregateOutputType = {
export type AgentSessionEntryMinAggregateInputType = { export type AgentSessionEntryMinAggregateInputType = {
id?: true id?: true
sessionId?: true sessionId?: true
assetId?: true
type?: true
parentId?: true
createdAt?: true
} }
export type AgentSessionEntryMaxAggregateInputType = { export type AgentSessionEntryMaxAggregateInputType = {
id?: true id?: true
sessionId?: true sessionId?: true
assetId?: true
type?: true
parentId?: true
createdAt?: true
} }
export type AgentSessionEntryCountAggregateInputType = { export type AgentSessionEntryCountAggregateInputType = {
id?: true id?: true
sessionId?: true sessionId?: true
entry?: true assetId?: true
type?: true
parentId?: true
data?: true
createdAt?: true
_all?: true _all?: true
} }
@@ -135,8 +159,12 @@ export type AgentSessionEntryGroupByArgs<ExtArgs extends runtime.Types.Extension
export type AgentSessionEntryGroupByOutputType = { export type AgentSessionEntryGroupByOutputType = {
id: string id: string
sessionId: string sessionId: string | null
entry:PrismaJson.PiSessionEntry assetId: string | null
type: string | null
parentId: string | null
data:PrismaJson.PiSessionEntryData | null
createdAt: Date
_count: AgentSessionEntryCountAggregateOutputType | null _count: AgentSessionEntryCountAggregateOutputType | null
_min: AgentSessionEntryMinAggregateOutputType | null _min: AgentSessionEntryMinAggregateOutputType | null
_max: AgentSessionEntryMaxAggregateOutputType | null _max: AgentSessionEntryMaxAggregateOutputType | null
@@ -162,15 +190,23 @@ export type AgentSessionEntryWhereInput = {
OR?: Prisma.AgentSessionEntryWhereInput[] OR?: Prisma.AgentSessionEntryWhereInput[]
NOT?: Prisma.AgentSessionEntryWhereInput | Prisma.AgentSessionEntryWhereInput[] NOT?: Prisma.AgentSessionEntryWhereInput | Prisma.AgentSessionEntryWhereInput[]
id?: Prisma.StringFilter<"AgentSessionEntry"> | string id?: Prisma.StringFilter<"AgentSessionEntry"> | string
sessionId?: Prisma.StringFilter<"AgentSessionEntry"> | string sessionId?: Prisma.StringNullableFilter<"AgentSessionEntry"> | string | null
entry?: Prisma.JsonFilter<"AgentSessionEntry"> assetId?: Prisma.StringNullableFilter<"AgentSessionEntry"> | string | null
session?: Prisma.XOR<Prisma.AgentSessionScalarRelationFilter, Prisma.AgentSessionWhereInput> type?: Prisma.StringNullableFilter<"AgentSessionEntry"> | string | null
parentId?: Prisma.StringNullableFilter<"AgentSessionEntry"> | string | null
data?: Prisma.JsonNullableFilter<"AgentSessionEntry">
createdAt?: Prisma.DateTimeFilter<"AgentSessionEntry"> | Date | string
session?: Prisma.XOR<Prisma.AgentSessionNullableScalarRelationFilter, Prisma.AgentSessionWhereInput> | null
} }
export type AgentSessionEntryOrderByWithRelationInput = { export type AgentSessionEntryOrderByWithRelationInput = {
id?: Prisma.SortOrder id?: Prisma.SortOrder
sessionId?: Prisma.SortOrder sessionId?: Prisma.SortOrderInput | Prisma.SortOrder
entry?: Prisma.SortOrder assetId?: Prisma.SortOrderInput | Prisma.SortOrder
type?: Prisma.SortOrderInput | Prisma.SortOrder
parentId?: Prisma.SortOrderInput | Prisma.SortOrder
data?: Prisma.SortOrderInput | Prisma.SortOrder
createdAt?: Prisma.SortOrder
session?: Prisma.AgentSessionOrderByWithRelationInput session?: Prisma.AgentSessionOrderByWithRelationInput
} }
@@ -179,15 +215,23 @@ export type AgentSessionEntryWhereUniqueInput = Prisma.AtLeast<{
AND?: Prisma.AgentSessionEntryWhereInput | Prisma.AgentSessionEntryWhereInput[] AND?: Prisma.AgentSessionEntryWhereInput | Prisma.AgentSessionEntryWhereInput[]
OR?: Prisma.AgentSessionEntryWhereInput[] OR?: Prisma.AgentSessionEntryWhereInput[]
NOT?: Prisma.AgentSessionEntryWhereInput | Prisma.AgentSessionEntryWhereInput[] NOT?: Prisma.AgentSessionEntryWhereInput | Prisma.AgentSessionEntryWhereInput[]
sessionId?: Prisma.StringFilter<"AgentSessionEntry"> | string sessionId?: Prisma.StringNullableFilter<"AgentSessionEntry"> | string | null
entry?: Prisma.JsonFilter<"AgentSessionEntry"> assetId?: Prisma.StringNullableFilter<"AgentSessionEntry"> | string | null
session?: Prisma.XOR<Prisma.AgentSessionScalarRelationFilter, Prisma.AgentSessionWhereInput> type?: Prisma.StringNullableFilter<"AgentSessionEntry"> | string | null
parentId?: Prisma.StringNullableFilter<"AgentSessionEntry"> | string | null
data?: Prisma.JsonNullableFilter<"AgentSessionEntry">
createdAt?: Prisma.DateTimeFilter<"AgentSessionEntry"> | Date | string
session?: Prisma.XOR<Prisma.AgentSessionNullableScalarRelationFilter, Prisma.AgentSessionWhereInput> | null
}, "id"> }, "id">
export type AgentSessionEntryOrderByWithAggregationInput = { export type AgentSessionEntryOrderByWithAggregationInput = {
id?: Prisma.SortOrder id?: Prisma.SortOrder
sessionId?: Prisma.SortOrder sessionId?: Prisma.SortOrderInput | Prisma.SortOrder
entry?: Prisma.SortOrder assetId?: Prisma.SortOrderInput | Prisma.SortOrder
type?: Prisma.SortOrderInput | Prisma.SortOrder
parentId?: Prisma.SortOrderInput | Prisma.SortOrder
data?: Prisma.SortOrderInput | Prisma.SortOrder
createdAt?: Prisma.SortOrder
_count?: Prisma.AgentSessionEntryCountOrderByAggregateInput _count?: Prisma.AgentSessionEntryCountOrderByAggregateInput
_max?: Prisma.AgentSessionEntryMaxOrderByAggregateInput _max?: Prisma.AgentSessionEntryMaxOrderByAggregateInput
_min?: Prisma.AgentSessionEntryMinOrderByAggregateInput _min?: Prisma.AgentSessionEntryMinOrderByAggregateInput
@@ -198,49 +242,81 @@ export type AgentSessionEntryScalarWhereWithAggregatesInput = {
OR?: Prisma.AgentSessionEntryScalarWhereWithAggregatesInput[] OR?: Prisma.AgentSessionEntryScalarWhereWithAggregatesInput[]
NOT?: Prisma.AgentSessionEntryScalarWhereWithAggregatesInput | Prisma.AgentSessionEntryScalarWhereWithAggregatesInput[] NOT?: Prisma.AgentSessionEntryScalarWhereWithAggregatesInput | Prisma.AgentSessionEntryScalarWhereWithAggregatesInput[]
id?: Prisma.StringWithAggregatesFilter<"AgentSessionEntry"> | string id?: Prisma.StringWithAggregatesFilter<"AgentSessionEntry"> | string
sessionId?: Prisma.StringWithAggregatesFilter<"AgentSessionEntry"> | string sessionId?: Prisma.StringNullableWithAggregatesFilter<"AgentSessionEntry"> | string | null
entry?: Prisma.JsonWithAggregatesFilter<"AgentSessionEntry"> assetId?: Prisma.StringNullableWithAggregatesFilter<"AgentSessionEntry"> | string | null
type?: Prisma.StringNullableWithAggregatesFilter<"AgentSessionEntry"> | string | null
parentId?: Prisma.StringNullableWithAggregatesFilter<"AgentSessionEntry"> | string | null
data?: Prisma.JsonNullableWithAggregatesFilter<"AgentSessionEntry">
createdAt?: Prisma.DateTimeWithAggregatesFilter<"AgentSessionEntry"> | Date | string
} }
export type AgentSessionEntryCreateInput = { export type AgentSessionEntryCreateInput = {
id: string id: string
entry:PrismaJson.PiSessionEntry assetId?: string | null
session: Prisma.AgentSessionCreateNestedOneWithoutEntriesInput type?: string | null
parentId?: string | null
data?:PrismaJson.PiSessionEntryData | Prisma.NullableJsonNullValueInput
createdAt?: Date | string
session?: Prisma.AgentSessionCreateNestedOneWithoutEntriesInput
} }
export type AgentSessionEntryUncheckedCreateInput = { export type AgentSessionEntryUncheckedCreateInput = {
id: string id: string
sessionId: string sessionId?: string | null
entry:PrismaJson.PiSessionEntry assetId?: string | null
type?: string | null
parentId?: string | null
data?:PrismaJson.PiSessionEntryData | Prisma.NullableJsonNullValueInput
createdAt?: Date | string
} }
export type AgentSessionEntryUpdateInput = { export type AgentSessionEntryUpdateInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string id?: Prisma.StringFieldUpdateOperationsInput | string
entry?:PrismaJson.PiSessionEntry assetId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
session?: Prisma.AgentSessionUpdateOneRequiredWithoutEntriesNestedInput type?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
parentId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
data?:PrismaJson.PiSessionEntryData | Prisma.NullableJsonNullValueInput
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
session?: Prisma.AgentSessionUpdateOneWithoutEntriesNestedInput
} }
export type AgentSessionEntryUncheckedUpdateInput = { export type AgentSessionEntryUncheckedUpdateInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string id?: Prisma.StringFieldUpdateOperationsInput | string
sessionId?: Prisma.StringFieldUpdateOperationsInput | string sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
entry?:PrismaJson.PiSessionEntry assetId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
type?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
parentId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
data?:PrismaJson.PiSessionEntryData | Prisma.NullableJsonNullValueInput
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
} }
export type AgentSessionEntryCreateManyInput = { export type AgentSessionEntryCreateManyInput = {
id: string id: string
sessionId: string sessionId?: string | null
entry:PrismaJson.PiSessionEntry assetId?: string | null
type?: string | null
parentId?: string | null
data?:PrismaJson.PiSessionEntryData | Prisma.NullableJsonNullValueInput
createdAt?: Date | string
} }
export type AgentSessionEntryUpdateManyMutationInput = { export type AgentSessionEntryUpdateManyMutationInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string id?: Prisma.StringFieldUpdateOperationsInput | string
entry?:PrismaJson.PiSessionEntry assetId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
type?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
parentId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
data?:PrismaJson.PiSessionEntryData | Prisma.NullableJsonNullValueInput
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
} }
export type AgentSessionEntryUncheckedUpdateManyInput = { export type AgentSessionEntryUncheckedUpdateManyInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string id?: Prisma.StringFieldUpdateOperationsInput | string
sessionId?: Prisma.StringFieldUpdateOperationsInput | string sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
entry?:PrismaJson.PiSessionEntry assetId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
type?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
parentId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
data?:PrismaJson.PiSessionEntryData | Prisma.NullableJsonNullValueInput
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
} }
export type AgentSessionEntryListRelationFilter = { export type AgentSessionEntryListRelationFilter = {
@@ -256,17 +332,29 @@ export type AgentSessionEntryOrderByRelationAggregateInput = {
export type AgentSessionEntryCountOrderByAggregateInput = { export type AgentSessionEntryCountOrderByAggregateInput = {
id?: Prisma.SortOrder id?: Prisma.SortOrder
sessionId?: Prisma.SortOrder sessionId?: Prisma.SortOrder
entry?: Prisma.SortOrder assetId?: Prisma.SortOrder
type?: Prisma.SortOrder
parentId?: Prisma.SortOrder
data?: Prisma.SortOrder
createdAt?: Prisma.SortOrder
} }
export type AgentSessionEntryMaxOrderByAggregateInput = { export type AgentSessionEntryMaxOrderByAggregateInput = {
id?: Prisma.SortOrder id?: Prisma.SortOrder
sessionId?: Prisma.SortOrder sessionId?: Prisma.SortOrder
assetId?: Prisma.SortOrder
type?: Prisma.SortOrder
parentId?: Prisma.SortOrder
createdAt?: Prisma.SortOrder
} }
export type AgentSessionEntryMinOrderByAggregateInput = { export type AgentSessionEntryMinOrderByAggregateInput = {
id?: Prisma.SortOrder id?: Prisma.SortOrder
sessionId?: Prisma.SortOrder sessionId?: Prisma.SortOrder
assetId?: Prisma.SortOrder
type?: Prisma.SortOrder
parentId?: Prisma.SortOrder
createdAt?: Prisma.SortOrder
} }
export type AgentSessionEntryCreateNestedManyWithoutSessionInput = { export type AgentSessionEntryCreateNestedManyWithoutSessionInput = {
@@ -313,12 +401,20 @@ export type AgentSessionEntryUncheckedUpdateManyWithoutSessionNestedInput = {
export type AgentSessionEntryCreateWithoutSessionInput = { export type AgentSessionEntryCreateWithoutSessionInput = {
id: string id: string
entry:PrismaJson.PiSessionEntry assetId?: string | null
type?: string | null
parentId?: string | null
data?:PrismaJson.PiSessionEntryData | Prisma.NullableJsonNullValueInput
createdAt?: Date | string
} }
export type AgentSessionEntryUncheckedCreateWithoutSessionInput = { export type AgentSessionEntryUncheckedCreateWithoutSessionInput = {
id: string id: string
entry:PrismaJson.PiSessionEntry assetId?: string | null
type?: string | null
parentId?: string | null
data?:PrismaJson.PiSessionEntryData | Prisma.NullableJsonNullValueInput
createdAt?: Date | string
} }
export type AgentSessionEntryCreateOrConnectWithoutSessionInput = { export type AgentSessionEntryCreateOrConnectWithoutSessionInput = {
@@ -352,28 +448,48 @@ export type AgentSessionEntryScalarWhereInput = {
OR?: Prisma.AgentSessionEntryScalarWhereInput[] OR?: Prisma.AgentSessionEntryScalarWhereInput[]
NOT?: Prisma.AgentSessionEntryScalarWhereInput | Prisma.AgentSessionEntryScalarWhereInput[] NOT?: Prisma.AgentSessionEntryScalarWhereInput | Prisma.AgentSessionEntryScalarWhereInput[]
id?: Prisma.StringFilter<"AgentSessionEntry"> | string id?: Prisma.StringFilter<"AgentSessionEntry"> | string
sessionId?: Prisma.StringFilter<"AgentSessionEntry"> | string sessionId?: Prisma.StringNullableFilter<"AgentSessionEntry"> | string | null
entry?: Prisma.JsonFilter<"AgentSessionEntry"> assetId?: Prisma.StringNullableFilter<"AgentSessionEntry"> | string | null
type?: Prisma.StringNullableFilter<"AgentSessionEntry"> | string | null
parentId?: Prisma.StringNullableFilter<"AgentSessionEntry"> | string | null
data?: Prisma.JsonNullableFilter<"AgentSessionEntry">
createdAt?: Prisma.DateTimeFilter<"AgentSessionEntry"> | Date | string
} }
export type AgentSessionEntryCreateManySessionInput = { export type AgentSessionEntryCreateManySessionInput = {
id: string id: string
entry:PrismaJson.PiSessionEntry assetId?: string | null
type?: string | null
parentId?: string | null
data?:PrismaJson.PiSessionEntryData | Prisma.NullableJsonNullValueInput
createdAt?: Date | string
} }
export type AgentSessionEntryUpdateWithoutSessionInput = { export type AgentSessionEntryUpdateWithoutSessionInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string id?: Prisma.StringFieldUpdateOperationsInput | string
entry?:PrismaJson.PiSessionEntry assetId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
type?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
parentId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
data?:PrismaJson.PiSessionEntryData | Prisma.NullableJsonNullValueInput
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
} }
export type AgentSessionEntryUncheckedUpdateWithoutSessionInput = { export type AgentSessionEntryUncheckedUpdateWithoutSessionInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string id?: Prisma.StringFieldUpdateOperationsInput | string
entry?:PrismaJson.PiSessionEntry assetId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
type?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
parentId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
data?:PrismaJson.PiSessionEntryData | Prisma.NullableJsonNullValueInput
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
} }
export type AgentSessionEntryUncheckedUpdateManyWithoutSessionInput = { export type AgentSessionEntryUncheckedUpdateManyWithoutSessionInput = {
id?: Prisma.StringFieldUpdateOperationsInput | string id?: Prisma.StringFieldUpdateOperationsInput | string
entry?:PrismaJson.PiSessionEntry assetId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
type?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
parentId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
data?:PrismaJson.PiSessionEntryData | Prisma.NullableJsonNullValueInput
createdAt?: Prisma.DateTimeFieldUpdateOperationsInput | Date | string
} }
@@ -381,53 +497,73 @@ export type AgentSessionEntryUncheckedUpdateManyWithoutSessionInput = {
export type AgentSessionEntrySelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{ export type AgentSessionEntrySelect<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean id?: boolean
sessionId?: boolean sessionId?: boolean
entry?: boolean assetId?: boolean
session?: boolean | Prisma.AgentSessionDefaultArgs<ExtArgs> type?: boolean
parentId?: boolean
data?: boolean
createdAt?: boolean
session?: boolean | Prisma.AgentSessionEntry$sessionArgs<ExtArgs>
}, ExtArgs["result"]["agentSessionEntry"]> }, ExtArgs["result"]["agentSessionEntry"]>
export type AgentSessionEntrySelectCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{ export type AgentSessionEntrySelectCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean id?: boolean
sessionId?: boolean sessionId?: boolean
entry?: boolean assetId?: boolean
session?: boolean | Prisma.AgentSessionDefaultArgs<ExtArgs> type?: boolean
parentId?: boolean
data?: boolean
createdAt?: boolean
session?: boolean | Prisma.AgentSessionEntry$sessionArgs<ExtArgs>
}, ExtArgs["result"]["agentSessionEntry"]> }, ExtArgs["result"]["agentSessionEntry"]>
export type AgentSessionEntrySelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{ export type AgentSessionEntrySelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
id?: boolean id?: boolean
sessionId?: boolean sessionId?: boolean
entry?: boolean assetId?: boolean
session?: boolean | Prisma.AgentSessionDefaultArgs<ExtArgs> type?: boolean
parentId?: boolean
data?: boolean
createdAt?: boolean
session?: boolean | Prisma.AgentSessionEntry$sessionArgs<ExtArgs>
}, ExtArgs["result"]["agentSessionEntry"]> }, ExtArgs["result"]["agentSessionEntry"]>
export type AgentSessionEntrySelectScalar = { export type AgentSessionEntrySelectScalar = {
id?: boolean id?: boolean
sessionId?: boolean sessionId?: boolean
entry?: boolean assetId?: boolean
type?: boolean
parentId?: boolean
data?: boolean
createdAt?: boolean
} }
export type AgentSessionEntryOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "sessionId" | "entry", ExtArgs["result"]["agentSessionEntry"]> export type AgentSessionEntryOmit<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetOmit<"id" | "sessionId" | "assetId" | "type" | "parentId" | "data" | "createdAt", ExtArgs["result"]["agentSessionEntry"]>
export type AgentSessionEntryInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = { export type AgentSessionEntryInclude<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
session?: boolean | Prisma.AgentSessionDefaultArgs<ExtArgs> session?: boolean | Prisma.AgentSessionEntry$sessionArgs<ExtArgs>
} }
export type AgentSessionEntryIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = { export type AgentSessionEntryIncludeCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
session?: boolean | Prisma.AgentSessionDefaultArgs<ExtArgs> session?: boolean | Prisma.AgentSessionEntry$sessionArgs<ExtArgs>
} }
export type AgentSessionEntryIncludeUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = { export type AgentSessionEntryIncludeUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
session?: boolean | Prisma.AgentSessionDefaultArgs<ExtArgs> session?: boolean | Prisma.AgentSessionEntry$sessionArgs<ExtArgs>
} }
export type $AgentSessionEntryPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = { export type $AgentSessionEntryPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
name: "AgentSessionEntry" name: "AgentSessionEntry"
objects: { objects: {
session: Prisma.$AgentSessionPayload<ExtArgs> session: Prisma.$AgentSessionPayload<ExtArgs> | null
} }
scalars: runtime.Types.Extensions.GetPayloadResult<{ scalars: runtime.Types.Extensions.GetPayloadResult<{
id: string id: string
sessionId: string sessionId: string | null
assetId: string | null
type: string | null
parentId: string | null
/** /**
* [PiSessionEntry] * [PiSessionEntryData]
*/ */
entry:PrismaJson.PiSessionEntry data:PrismaJson.PiSessionEntryData | null
createdAt: Date
}, ExtArgs["result"]["agentSessionEntry"]> }, ExtArgs["result"]["agentSessionEntry"]>
composites: {} composites: {}
} }
@@ -822,7 +958,7 @@ readonly fields: AgentSessionEntryFieldRefs;
*/ */
export interface Prisma__AgentSessionEntryClient<T, Null = never, ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs, GlobalOmitOptions = {}> extends Prisma.PrismaPromise<T> { export interface Prisma__AgentSessionEntryClient<T, Null = never, ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs, GlobalOmitOptions = {}> extends Prisma.PrismaPromise<T> {
readonly [Symbol.toStringTag]: "PrismaPromise" readonly [Symbol.toStringTag]: "PrismaPromise"
session<T extends Prisma.AgentSessionDefaultArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.AgentSessionDefaultArgs<ExtArgs>>): Prisma.Prisma__AgentSessionClient<runtime.Types.Result.GetResult<Prisma.$AgentSessionPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | Null, Null, ExtArgs, GlobalOmitOptions> session<T extends Prisma.AgentSessionEntry$sessionArgs<ExtArgs> = {}>(args?: Prisma.Subset<T, Prisma.AgentSessionEntry$sessionArgs<ExtArgs>>): Prisma.Prisma__AgentSessionClient<runtime.Types.Result.GetResult<Prisma.$AgentSessionPayload<ExtArgs>, T, "findUniqueOrThrow", GlobalOmitOptions> | null, null, ExtArgs, GlobalOmitOptions>
/** /**
* Attaches callbacks for the resolution and/or rejection of the Promise. * Attaches callbacks for the resolution and/or rejection of the Promise.
* @param onfulfilled The callback to execute when the Promise is resolved. * @param onfulfilled The callback to execute when the Promise is resolved.
@@ -854,7 +990,11 @@ export interface Prisma__AgentSessionEntryClient<T, Null = never, ExtArgs extend
export interface AgentSessionEntryFieldRefs { export interface AgentSessionEntryFieldRefs {
readonly id: Prisma.FieldRef<"AgentSessionEntry", 'String'> readonly id: Prisma.FieldRef<"AgentSessionEntry", 'String'>
readonly sessionId: Prisma.FieldRef<"AgentSessionEntry", 'String'> readonly sessionId: Prisma.FieldRef<"AgentSessionEntry", 'String'>
readonly entry: Prisma.FieldRef<"AgentSessionEntry", 'Json'> readonly assetId: Prisma.FieldRef<"AgentSessionEntry", 'String'>
readonly type: Prisma.FieldRef<"AgentSessionEntry", 'String'>
readonly parentId: Prisma.FieldRef<"AgentSessionEntry", 'String'>
readonly data: Prisma.FieldRef<"AgentSessionEntry", 'Json'>
readonly createdAt: Prisma.FieldRef<"AgentSessionEntry", 'DateTime'>
} }
@@ -1255,6 +1395,25 @@ export type AgentSessionEntryDeleteManyArgs<ExtArgs extends runtime.Types.Extens
limit?: number limit?: number
} }
/**
* AgentSessionEntry.session
*/
export type AgentSessionEntry$sessionArgs<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
/**
* Select specific fields to fetch from the AgentSession
*/
select?: Prisma.AgentSessionSelect<ExtArgs> | null
/**
* Omit specific fields from the AgentSession
*/
omit?: Prisma.AgentSessionOmit<ExtArgs> | null
/**
* Choose, which related nodes to fetch as well
*/
include?: Prisma.AgentSessionInclude<ExtArgs> | null
where?: Prisma.AgentSessionWhereInput
}
/** /**
* AgentSessionEntry without action * AgentSessionEntry without action
*/ */
+1 -3
View File
@@ -1,14 +1,12 @@
export {} export {}
import { SessionTreeEntry } from '@earendil-works/pi-agent-core'
declare global { declare global {
// eslint-disable-next-line @typescript-eslint/no-namespace // eslint-disable-next-line @typescript-eslint/no-namespace
namespace PrismaJson { namespace PrismaJson {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// Agent Session Entry // Agent Session Entry
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
export type PiSessionEntry = SessionTreeEntry export type PiSessionEntryData = Record<string, unknown>
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// User Agent Settings // User Agent Settings