mirror of
https://github.com/shumaiOne/shumai.git
synced 2026-11-24 05:27:38 +00:00
feat(agent): refactor database session storage to normalized DAG entries and lazy thread sync
This commit is contained in:
@@ -546,13 +546,72 @@ describe('Agent Database Activities Integration', () => {
|
||||
|
||||
// Verify historical comment is converted and saved to entries (mentions replaced, prefixes added)
|
||||
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
|
||||
const parsedEntry = agentSession?.entries[0].entry as any
|
||||
// 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].data as any
|
||||
expect(parsedEntry.message.content[0].text).toContain(
|
||||
`[${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 () => {
|
||||
const info = await getUserTeamInfoActivity({
|
||||
userId: user.id,
|
||||
|
||||
@@ -490,19 +490,117 @@ export async function initializeAgentSessionActivity(params: {
|
||||
include: { creator: true },
|
||||
})
|
||||
|
||||
// Create a new AgentSession
|
||||
const newSession = await prisma.agentSession.create({
|
||||
data: {
|
||||
agentId,
|
||||
userId: params.userId || null,
|
||||
cwd: process.cwd(),
|
||||
assetId: userComment ? userComment.assetId : null,
|
||||
userCommentId: params.userCommentId,
|
||||
if (!userComment) {
|
||||
throw new Error(`User comment ${params.userCommentId} not found`)
|
||||
}
|
||||
|
||||
const isThread = !!userComment.replyToId
|
||||
const rootCommentId = userComment.replyToId || userComment.id
|
||||
const targetUserCommentId = isThread ? rootCommentId : null
|
||||
|
||||
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<{
|
||||
id: string
|
||||
message: string | null
|
||||
@@ -510,36 +608,51 @@ export async function initializeAgentSessionActivity(params: {
|
||||
creatorId: string | null
|
||||
creator: { type: string; name: string } | null
|
||||
sessionId: string | null
|
||||
replyToId: string | null
|
||||
}> = []
|
||||
|
||||
if (userComment) {
|
||||
if (!userComment.replyToId) {
|
||||
// Rule 1: outside of a reply, add all other comments on that asset
|
||||
existingComments = await prisma.assetComment.findMany({
|
||||
if (!isThread) {
|
||||
// Main Session: Only fetch top-level comments (replyToId: null)
|
||||
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: {
|
||||
assetId: userComment.assetId,
|
||||
replyToId: rootCommentId,
|
||||
id: { not: userComment.id },
|
||||
},
|
||||
orderBy: { id: 'asc' },
|
||||
orderBy: { createdAt: 'asc' },
|
||||
include: { creator: true },
|
||||
})
|
||||
} else {
|
||||
// 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 },
|
||||
})
|
||||
if (rootComment) {
|
||||
const replies = await prisma.assetComment.findMany({
|
||||
where: {
|
||||
replyToId: rootComment.id,
|
||||
id: { not: userComment.id },
|
||||
},
|
||||
orderBy: { id: 'asc' },
|
||||
include: { creator: true },
|
||||
})
|
||||
existingComments = [rootComment, ...replies]
|
||||
}
|
||||
existingComments = [rootComment, ...replies]
|
||||
}
|
||||
}
|
||||
|
||||
// Check which top-level comments have reply threads (for prompt tagging)
|
||||
const commentIdsWithThreads = new Set<string>()
|
||||
if (!isThread && existingComments.length > 0) {
|
||||
const threadCounts = await prisma.assetComment.groupBy({
|
||||
by: ['replyToId'],
|
||||
where: {
|
||||
assetId: userComment.assetId,
|
||||
replyToId: { in: existingComments.map((c) => c.id) },
|
||||
},
|
||||
})
|
||||
for (const tc of threadCounts) {
|
||||
if (tc.replyToId) commentIdsWithThreads.add(tc.replyToId)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -594,9 +707,19 @@ export async function initializeAgentSessionActivity(params: {
|
||||
}
|
||||
}
|
||||
|
||||
// Save context as AgentSessionEntry records
|
||||
let prevId: string | null = null
|
||||
// Save context as AgentSessionEntry records (with parent pointers)
|
||||
let prevId: string | null = session.leafId
|
||||
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
|
||||
let messageContent = c.message || ''
|
||||
|
||||
@@ -614,33 +737,33 @@ export async function initializeAgentSessionActivity(params: {
|
||||
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 = {
|
||||
role: 'user',
|
||||
content: [{ type: 'text', text: messageContent }],
|
||||
timestamp: c.createdAt.getTime(),
|
||||
}
|
||||
|
||||
const entryJson: SessionTreeEntry = {
|
||||
type: 'message',
|
||||
id: entryId,
|
||||
parentId: prevId,
|
||||
timestamp: c.createdAt.toISOString(),
|
||||
message,
|
||||
}
|
||||
|
||||
await prisma.agentSessionEntry.create({
|
||||
data: {
|
||||
id: entryId,
|
||||
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
|
||||
}
|
||||
|
||||
// Update leafId of the session
|
||||
if (prevId) {
|
||||
if (prevId && prevId !== session.leafId) {
|
||||
await prisma.agentSession.update({
|
||||
where: { id: sessionId },
|
||||
data: { leafId: prevId },
|
||||
|
||||
@@ -234,10 +234,10 @@ describe('DatabaseSessionStorage', () => {
|
||||
|
||||
await storage.appendEntry(entry)
|
||||
|
||||
// Record entry is generic Json
|
||||
// Record data is generic Json
|
||||
const record = await prisma.agentSessionEntry.findUnique({ where: { id: 'msg-1' } })
|
||||
// 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__')
|
||||
|
||||
// Verify retrieval reinjects data
|
||||
@@ -281,7 +281,7 @@ describe('DatabaseSessionStorage', () => {
|
||||
// Verify saved entry is stripped
|
||||
const record = await prisma.agentSessionEntry.findUnique({ where: { id: 'msg-skill' } })
|
||||
// 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__')
|
||||
|
||||
// Verify retrieval reinjects data
|
||||
|
||||
@@ -6,7 +6,6 @@ import {
|
||||
type SessionMetadata,
|
||||
type SessionStorage,
|
||||
type SessionTreeEntry,
|
||||
type SessionTreeEntryBase,
|
||||
} from '@earendil-works/pi-agent-core'
|
||||
import { agentService } from '@shumai/core/src/agent/agent'
|
||||
|
||||
@@ -76,6 +75,23 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
|
||||
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> {
|
||||
const strippedEntry = structuredClone(entry)
|
||||
|
||||
@@ -118,12 +134,28 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
|
||||
|
||||
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([
|
||||
prisma.agentSessionEntry.create({
|
||||
data: {
|
||||
id: entry.id,
|
||||
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({
|
||||
@@ -138,7 +170,7 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
|
||||
where: { id },
|
||||
})
|
||||
if (!record) return undefined
|
||||
const entry = record.entry as unknown as SessionTreeEntry
|
||||
const entry = this.recordToEntry(record)
|
||||
await this.reinjectImageDataAsync(entry)
|
||||
await this.reinjectSkillContentAsync(entry)
|
||||
return entry
|
||||
@@ -150,14 +182,11 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
|
||||
const records = await prisma.agentSessionEntry.findMany({
|
||||
where: {
|
||||
sessionId: this.sessionId,
|
||||
entry: {
|
||||
path: ['type'],
|
||||
equals: type,
|
||||
},
|
||||
type,
|
||||
},
|
||||
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 }>
|
||||
>
|
||||
for (const entry of entries) {
|
||||
@@ -168,43 +197,49 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
|
||||
}
|
||||
|
||||
async getLabel(id: string): Promise<string | undefined> {
|
||||
const record = await prisma.agentSessionEntry.findFirst({
|
||||
where: {
|
||||
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
|
||||
const entry = await this.getEntry(id)
|
||||
return (entry as { label?: string } | undefined)?.label
|
||||
}
|
||||
|
||||
async getPathToRoot(leafId: string | null): Promise<SessionTreeEntry[]> {
|
||||
if (!leafId) return []
|
||||
|
||||
// Fetch all entries for this session in a single query to avoid N+1 problem
|
||||
const records = await prisma.agentSessionEntry.findMany({
|
||||
where: { sessionId: this.sessionId },
|
||||
})
|
||||
|
||||
// Build a map for fast lookup
|
||||
const entryMap = new Map<string, SessionTreeEntry>()
|
||||
for (const record of records) {
|
||||
entryMap.set(record.id, record.entry as unknown as SessionTreeEntry)
|
||||
interface EntryRow {
|
||||
id: string
|
||||
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 pathEntries: SessionTreeEntry[] = []
|
||||
let currentId: string | null = leafId
|
||||
const rows = await prisma.$queryRaw<EntryRow[]>`
|
||||
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) {
|
||||
const entry = entryMap.get(currentId)
|
||||
if (!entry) break
|
||||
pathEntries.unshift(entry)
|
||||
currentId = (entry as SessionTreeEntryBase).parentId
|
||||
}
|
||||
UNION ALL
|
||||
|
||||
SELECT e.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, 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
|
||||
for (const entry of pathEntries) {
|
||||
@@ -220,7 +255,7 @@ export class DatabaseSessionStorage implements SessionStorage<DatabaseSessionMet
|
||||
where: { sessionId: this.sessionId },
|
||||
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) {
|
||||
await this.reinjectImageDataAsync(entry)
|
||||
await this.reinjectSkillContentAsync(entry)
|
||||
|
||||
@@ -20,6 +20,7 @@ import { createCreateVersionTool } from './tools/create-version'
|
||||
import { createListAssetsTool } from './tools/list-assets'
|
||||
import { createReadPdfPagesTool } from './tools/read-pdf-pages'
|
||||
import { createReadSkillTool } from './tools/read-skill'
|
||||
import { createReadThreadTool } from './tools/read-thread'
|
||||
import { createSandboxedBashTool } from './tools/sandboxed-bash'
|
||||
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 deniedTools = agentConfig?.deniedTools || []
|
||||
|
||||
const allTools = [...mediaTools, readSkill, sandboxedBash, ...systemTools, ...customTools]
|
||||
const readThread = createReadThreadTool()
|
||||
const allTools = [
|
||||
...mediaTools,
|
||||
readSkill,
|
||||
readThread,
|
||||
sandboxedBash,
|
||||
...systemTools,
|
||||
...customTools,
|
||||
]
|
||||
const enabledTools = allTools.filter((tool) => !deniedTools.includes(tool.name))
|
||||
|
||||
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')
|
||||
})
|
||||
})
|
||||
@@ -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 },
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -286,5 +286,57 @@ describe('AgentService', () => {
|
||||
expect(agents[0].provider).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)
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
@@ -330,9 +330,62 @@ export class AgentService {
|
||||
}
|
||||
|
||||
async getSessionEntries(params: { sessionId: string }) {
|
||||
return this.prismaClient.agentSessionEntry.findMany({
|
||||
where: { sessionId: params.sessionId },
|
||||
orderBy: { id: 'asc' },
|
||||
const session = await this.prismaClient.agentSession.findUnique({
|
||||
where: { id: params.sessionId },
|
||||
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,
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@@ -299,20 +299,23 @@ describe('ChatService', () => {
|
||||
data: {
|
||||
id: 'test-entry-id',
|
||||
sessionId,
|
||||
entry: {
|
||||
type: 'message',
|
||||
id: 'test-entry-id',
|
||||
parentId: null,
|
||||
timestamp: new Date().toISOString(),
|
||||
type: 'message',
|
||||
parentId: null,
|
||||
data: {
|
||||
message: {
|
||||
role: 'user',
|
||||
content: [{ type: 'text', text: 'hello' }],
|
||||
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)
|
||||
expect(messages).toHaveLength(1)
|
||||
// Casting to any to access properties of union in test assertions
|
||||
@@ -336,68 +339,65 @@ describe('ChatService', () => {
|
||||
data: {
|
||||
id: 'test-entry-1-user',
|
||||
sessionId,
|
||||
entry: {
|
||||
type: 'message',
|
||||
id: 'test-entry-1-user',
|
||||
parentId: null,
|
||||
timestamp: new Date().toISOString(),
|
||||
type: 'message',
|
||||
parentId: null,
|
||||
data: {
|
||||
message: {
|
||||
role: 'user',
|
||||
content: [{ type: 'text', text: 'hello' }],
|
||||
timestamp: Date.now(),
|
||||
},
|
||||
} as unknown as PrismaJson.PiSessionEntry,
|
||||
} as unknown as PrismaJson.PiSessionEntryData,
|
||||
},
|
||||
})
|
||||
|
||||
// 2. Manually insert a test entry representing a custom context message
|
||||
await prisma.agentSessionEntry.create({
|
||||
data: {
|
||||
id: 'test-entry-2-context',
|
||||
sessionId,
|
||||
entry: {
|
||||
type: 'custom_message',
|
||||
// 2. Manually insert a test entry representing a custom context message
|
||||
await prisma.agentSessionEntry.create({
|
||||
data: {
|
||||
id: 'test-entry-2-context',
|
||||
sessionId,
|
||||
type: 'custom_message',
|
||||
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: {
|
||||
assets: [{ id: 'a1', name: 'File A', type: 'file' }],
|
||||
},
|
||||
} as unknown as PrismaJson.PiSessionEntry,
|
||||
},
|
||||
customType: 'context',
|
||||
content: 'some context',
|
||||
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
|
||||
@@ -539,16 +539,14 @@ describe('ChatService', () => {
|
||||
data: {
|
||||
id: 'entry-id-1',
|
||||
sessionId,
|
||||
entry: {
|
||||
type: 'message',
|
||||
id: 'entry-id-1',
|
||||
parentId: null,
|
||||
timestamp: new Date().toISOString(),
|
||||
type: 'message',
|
||||
parentId: null,
|
||||
data: {
|
||||
message: {
|
||||
role: 'user',
|
||||
content: [{ type: 'text', text: 'msg 1' }],
|
||||
},
|
||||
} as unknown as PrismaJson.PiSessionEntry,
|
||||
} as unknown as PrismaJson.PiSessionEntryData,
|
||||
},
|
||||
})
|
||||
|
||||
@@ -556,16 +554,14 @@ describe('ChatService', () => {
|
||||
data: {
|
||||
id: 'entry-id-2',
|
||||
sessionId,
|
||||
entry: {
|
||||
type: 'message',
|
||||
id: 'entry-id-2',
|
||||
parentId: 'entry-id-1',
|
||||
timestamp: new Date().toISOString(),
|
||||
type: 'message',
|
||||
parentId: 'entry-id-1',
|
||||
data: {
|
||||
message: {
|
||||
role: 'assistant',
|
||||
content: [{ type: 'text', text: 'msg 2' }],
|
||||
},
|
||||
} as unknown as PrismaJson.PiSessionEntry,
|
||||
} as unknown as PrismaJson.PiSessionEntryData,
|
||||
},
|
||||
})
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import { paginateQuery, type PaginatedData } from '@shumai/core/src/pagination'
|
||||
import type { ChatRequest, ChatSessionInfo, ChatMessage } from '@shumai/dtos'
|
||||
import type { SessionTreeEntry } from '@earendil-works/pi-agent-core'
|
||||
import { workflowService } from '@shumai/workflow-core'
|
||||
import { agentService } from '@shumai/core/src/agent/agent'
|
||||
|
||||
type User = Prisma.UserGetPayload<Record<string, never>>
|
||||
|
||||
@@ -100,14 +101,22 @@ export function buildSessionMessages(pathEntries: PathEntry[]): ChatMessage[] {
|
||||
export function mapEntryToMessage(
|
||||
entryRecord: Prisma.AgentSessionEntryGetPayload<Record<string, never>>,
|
||||
): 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 (
|
||||
entryObj.type === 'custom_message' &&
|
||||
(entryObj as { customType?: string }).customType === 'context'
|
||||
) {
|
||||
return null
|
||||
}
|
||||
const pathEntries = [{ ...entryObj, id: entryRecord.id }]
|
||||
const pathEntries = [entryObj]
|
||||
const messages = buildSessionMessages(pathEntries)
|
||||
if (messages.length > 0) {
|
||||
return messages[0]
|
||||
@@ -116,6 +125,7 @@ export function mapEntryToMessage(
|
||||
id: entryRecord.id,
|
||||
role: 'user',
|
||||
content: '',
|
||||
timestamp: entryRecord.createdAt.getTime(),
|
||||
} as unknown as ChatMessage
|
||||
}
|
||||
|
||||
@@ -382,18 +392,26 @@ export class ChatService {
|
||||
throw new Error('Unauthorized session access')
|
||||
}
|
||||
|
||||
const entries = await this.prismaClient.agentSessionEntry.findMany({
|
||||
where: { sessionId },
|
||||
orderBy: { id: 'asc' },
|
||||
})
|
||||
const entries = await agentService.getSessionEntries({ sessionId })
|
||||
|
||||
const pathEntries = entries.map((e) => {
|
||||
const entryObj = e.entry as unknown as SessionTreeEntry
|
||||
return {
|
||||
...entryObj,
|
||||
id: e.id,
|
||||
}
|
||||
})
|
||||
const pathEntries = entries.map(
|
||||
(e: {
|
||||
id: string
|
||||
type: string | null
|
||||
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)
|
||||
}
|
||||
|
||||
+14
@@ -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");
|
||||
+12
@@ -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;
|
||||
+8
@@ -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";
|
||||
@@ -722,14 +722,20 @@ model AgentSession {
|
||||
}
|
||||
|
||||
model AgentSessionEntry {
|
||||
id String @id // Uses ULID generated by pi-coding-agent
|
||||
sessionId String @map("session_id")
|
||||
session AgentSession @relation(fields: [sessionId], references: [id], onDelete: Cascade)
|
||||
/// [PiSessionEntry]
|
||||
entry Json
|
||||
id String @id // Uses ULID generated by pi-coding-agent
|
||||
sessionId String? @map("session_id")
|
||||
session AgentSession? @relation(fields: [sessionId], references: [id], onDelete: Cascade)
|
||||
assetId String? @map("asset_id")
|
||||
type String?
|
||||
parentId String? @map("parent_id")
|
||||
/// [PiSessionEntryData]
|
||||
data Json?
|
||||
createdAt DateTime @default(now()) @map("created_at")
|
||||
|
||||
@@map("agent_session_entries")
|
||||
@@index([sessionId])
|
||||
@@index([parentId])
|
||||
@@index([assetId])
|
||||
@@map("agent_session_entries")
|
||||
}
|
||||
|
||||
model UserMetadata {
|
||||
|
||||
+4
-4
File diff suppressed because one or more lines are too long
@@ -3397,7 +3397,11 @@ export type AgentSessionScalarFieldEnum = (typeof AgentSessionScalarFieldEnum)[k
|
||||
export const AgentSessionEntryScalarFieldEnum = {
|
||||
id: 'id',
|
||||
sessionId: 'sessionId',
|
||||
entry: 'entry'
|
||||
assetId: 'assetId',
|
||||
type: 'type',
|
||||
parentId: 'parentId',
|
||||
data: 'data',
|
||||
createdAt: 'createdAt'
|
||||
} as const
|
||||
|
||||
export type AgentSessionEntryScalarFieldEnum = (typeof AgentSessionEntryScalarFieldEnum)[keyof typeof AgentSessionEntryScalarFieldEnum]
|
||||
|
||||
@@ -508,7 +508,11 @@ export type AgentSessionScalarFieldEnum = (typeof AgentSessionScalarFieldEnum)[k
|
||||
export const AgentSessionEntryScalarFieldEnum = {
|
||||
id: 'id',
|
||||
sessionId: 'sessionId',
|
||||
entry: 'entry'
|
||||
assetId: 'assetId',
|
||||
type: 'type',
|
||||
parentId: 'parentId',
|
||||
data: 'data',
|
||||
createdAt: 'createdAt'
|
||||
} as const
|
||||
|
||||
export type AgentSessionEntryScalarFieldEnum = (typeof AgentSessionEntryScalarFieldEnum)[keyof typeof AgentSessionEntryScalarFieldEnum]
|
||||
|
||||
+3
-6
@@ -474,11 +474,6 @@ export type AgentSessionMinOrderByAggregateInput = {
|
||||
updatedAt?: Prisma.SortOrder
|
||||
}
|
||||
|
||||
export type AgentSessionScalarRelationFilter = {
|
||||
is?: Prisma.AgentSessionWhereInput
|
||||
isNot?: Prisma.AgentSessionWhereInput
|
||||
}
|
||||
|
||||
export type AgentSessionCreateNestedManyWithoutUserInput = {
|
||||
create?: Prisma.XOR<Prisma.AgentSessionCreateWithoutUserInput, Prisma.AgentSessionUncheckedCreateWithoutUserInput> | Prisma.AgentSessionCreateWithoutUserInput[] | Prisma.AgentSessionUncheckedCreateWithoutUserInput[]
|
||||
connectOrCreate?: Prisma.AgentSessionCreateOrConnectWithoutUserInput | Prisma.AgentSessionCreateOrConnectWithoutUserInput[]
|
||||
@@ -631,10 +626,12 @@ export type AgentSessionCreateNestedOneWithoutEntriesInput = {
|
||||
connect?: Prisma.AgentSessionWhereUniqueInput
|
||||
}
|
||||
|
||||
export type AgentSessionUpdateOneRequiredWithoutEntriesNestedInput = {
|
||||
export type AgentSessionUpdateOneWithoutEntriesNestedInput = {
|
||||
create?: Prisma.XOR<Prisma.AgentSessionCreateWithoutEntriesInput, Prisma.AgentSessionUncheckedCreateWithoutEntriesInput>
|
||||
connectOrCreate?: Prisma.AgentSessionCreateOrConnectWithoutEntriesInput
|
||||
upsert?: Prisma.AgentSessionUpsertWithoutEntriesInput
|
||||
disconnect?: Prisma.AgentSessionWhereInput | boolean
|
||||
delete?: Prisma.AgentSessionWhereInput | boolean
|
||||
connect?: Prisma.AgentSessionWhereUniqueInput
|
||||
update?: Prisma.XOR<Prisma.XOR<Prisma.AgentSessionUpdateToOneWithWhereWithoutEntriesInput, Prisma.AgentSessionUpdateWithoutEntriesInput>, Prisma.AgentSessionUncheckedUpdateWithoutEntriesInput>
|
||||
}
|
||||
|
||||
+214
-55
@@ -29,17 +29,29 @@ export type AggregateAgentSessionEntry = {
|
||||
export type AgentSessionEntryMinAggregateOutputType = {
|
||||
id: string | null
|
||||
sessionId: string | null
|
||||
assetId: string | null
|
||||
type: string | null
|
||||
parentId: string | null
|
||||
createdAt: Date | null
|
||||
}
|
||||
|
||||
export type AgentSessionEntryMaxAggregateOutputType = {
|
||||
id: string | null
|
||||
sessionId: string | null
|
||||
assetId: string | null
|
||||
type: string | null
|
||||
parentId: string | null
|
||||
createdAt: Date | null
|
||||
}
|
||||
|
||||
export type AgentSessionEntryCountAggregateOutputType = {
|
||||
id: number
|
||||
sessionId: number
|
||||
entry:PrismaJson.PiSessionEntry
|
||||
assetId: number
|
||||
type: number
|
||||
parentId: number
|
||||
data:PrismaJson.PiSessionEntryData
|
||||
createdAt: number
|
||||
_all: number
|
||||
}
|
||||
|
||||
@@ -47,17 +59,29 @@ export type AgentSessionEntryCountAggregateOutputType = {
|
||||
export type AgentSessionEntryMinAggregateInputType = {
|
||||
id?: true
|
||||
sessionId?: true
|
||||
assetId?: true
|
||||
type?: true
|
||||
parentId?: true
|
||||
createdAt?: true
|
||||
}
|
||||
|
||||
export type AgentSessionEntryMaxAggregateInputType = {
|
||||
id?: true
|
||||
sessionId?: true
|
||||
assetId?: true
|
||||
type?: true
|
||||
parentId?: true
|
||||
createdAt?: true
|
||||
}
|
||||
|
||||
export type AgentSessionEntryCountAggregateInputType = {
|
||||
id?: true
|
||||
sessionId?: true
|
||||
entry?: true
|
||||
assetId?: true
|
||||
type?: true
|
||||
parentId?: true
|
||||
data?: true
|
||||
createdAt?: true
|
||||
_all?: true
|
||||
}
|
||||
|
||||
@@ -135,8 +159,12 @@ export type AgentSessionEntryGroupByArgs<ExtArgs extends runtime.Types.Extension
|
||||
|
||||
export type AgentSessionEntryGroupByOutputType = {
|
||||
id: string
|
||||
sessionId: string
|
||||
entry:PrismaJson.PiSessionEntry
|
||||
sessionId: string | null
|
||||
assetId: string | null
|
||||
type: string | null
|
||||
parentId: string | null
|
||||
data:PrismaJson.PiSessionEntryData | null
|
||||
createdAt: Date
|
||||
_count: AgentSessionEntryCountAggregateOutputType | null
|
||||
_min: AgentSessionEntryMinAggregateOutputType | null
|
||||
_max: AgentSessionEntryMaxAggregateOutputType | null
|
||||
@@ -162,15 +190,23 @@ export type AgentSessionEntryWhereInput = {
|
||||
OR?: Prisma.AgentSessionEntryWhereInput[]
|
||||
NOT?: Prisma.AgentSessionEntryWhereInput | Prisma.AgentSessionEntryWhereInput[]
|
||||
id?: Prisma.StringFilter<"AgentSessionEntry"> | string
|
||||
sessionId?: Prisma.StringFilter<"AgentSessionEntry"> | string
|
||||
entry?: Prisma.JsonFilter<"AgentSessionEntry">
|
||||
session?: Prisma.XOR<Prisma.AgentSessionScalarRelationFilter, Prisma.AgentSessionWhereInput>
|
||||
sessionId?: Prisma.StringNullableFilter<"AgentSessionEntry"> | string | null
|
||||
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
|
||||
session?: Prisma.XOR<Prisma.AgentSessionNullableScalarRelationFilter, Prisma.AgentSessionWhereInput> | null
|
||||
}
|
||||
|
||||
export type AgentSessionEntryOrderByWithRelationInput = {
|
||||
id?: Prisma.SortOrder
|
||||
sessionId?: Prisma.SortOrder
|
||||
entry?: Prisma.SortOrder
|
||||
sessionId?: Prisma.SortOrderInput | 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
|
||||
}
|
||||
|
||||
@@ -179,15 +215,23 @@ export type AgentSessionEntryWhereUniqueInput = Prisma.AtLeast<{
|
||||
AND?: Prisma.AgentSessionEntryWhereInput | Prisma.AgentSessionEntryWhereInput[]
|
||||
OR?: Prisma.AgentSessionEntryWhereInput[]
|
||||
NOT?: Prisma.AgentSessionEntryWhereInput | Prisma.AgentSessionEntryWhereInput[]
|
||||
sessionId?: Prisma.StringFilter<"AgentSessionEntry"> | string
|
||||
entry?: Prisma.JsonFilter<"AgentSessionEntry">
|
||||
session?: Prisma.XOR<Prisma.AgentSessionScalarRelationFilter, Prisma.AgentSessionWhereInput>
|
||||
sessionId?: Prisma.StringNullableFilter<"AgentSessionEntry"> | string | null
|
||||
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
|
||||
session?: Prisma.XOR<Prisma.AgentSessionNullableScalarRelationFilter, Prisma.AgentSessionWhereInput> | null
|
||||
}, "id">
|
||||
|
||||
export type AgentSessionEntryOrderByWithAggregationInput = {
|
||||
id?: Prisma.SortOrder
|
||||
sessionId?: Prisma.SortOrder
|
||||
entry?: Prisma.SortOrder
|
||||
sessionId?: Prisma.SortOrderInput | 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
|
||||
_max?: Prisma.AgentSessionEntryMaxOrderByAggregateInput
|
||||
_min?: Prisma.AgentSessionEntryMinOrderByAggregateInput
|
||||
@@ -198,49 +242,81 @@ export type AgentSessionEntryScalarWhereWithAggregatesInput = {
|
||||
OR?: Prisma.AgentSessionEntryScalarWhereWithAggregatesInput[]
|
||||
NOT?: Prisma.AgentSessionEntryScalarWhereWithAggregatesInput | Prisma.AgentSessionEntryScalarWhereWithAggregatesInput[]
|
||||
id?: Prisma.StringWithAggregatesFilter<"AgentSessionEntry"> | string
|
||||
sessionId?: Prisma.StringWithAggregatesFilter<"AgentSessionEntry"> | string
|
||||
entry?: Prisma.JsonWithAggregatesFilter<"AgentSessionEntry">
|
||||
sessionId?: Prisma.StringNullableWithAggregatesFilter<"AgentSessionEntry"> | string | null
|
||||
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 = {
|
||||
id: string
|
||||
entry:PrismaJson.PiSessionEntry
|
||||
session: Prisma.AgentSessionCreateNestedOneWithoutEntriesInput
|
||||
assetId?: string | null
|
||||
type?: string | null
|
||||
parentId?: string | null
|
||||
data?:PrismaJson.PiSessionEntryData | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
session?: Prisma.AgentSessionCreateNestedOneWithoutEntriesInput
|
||||
}
|
||||
|
||||
export type AgentSessionEntryUncheckedCreateInput = {
|
||||
id: string
|
||||
sessionId: string
|
||||
entry:PrismaJson.PiSessionEntry
|
||||
sessionId?: string | null
|
||||
assetId?: string | null
|
||||
type?: string | null
|
||||
parentId?: string | null
|
||||
data?:PrismaJson.PiSessionEntryData | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
}
|
||||
|
||||
export type AgentSessionEntryUpdateInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
entry?:PrismaJson.PiSessionEntry
|
||||
session?: Prisma.AgentSessionUpdateOneRequiredWithoutEntriesNestedInput
|
||||
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
|
||||
session?: Prisma.AgentSessionUpdateOneWithoutEntriesNestedInput
|
||||
}
|
||||
|
||||
export type AgentSessionEntryUncheckedUpdateInput = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
sessionId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
entry?:PrismaJson.PiSessionEntry
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
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 = {
|
||||
id: string
|
||||
sessionId: string
|
||||
entry:PrismaJson.PiSessionEntry
|
||||
sessionId?: string | null
|
||||
assetId?: string | null
|
||||
type?: string | null
|
||||
parentId?: string | null
|
||||
data?:PrismaJson.PiSessionEntryData | Prisma.NullableJsonNullValueInput
|
||||
createdAt?: Date | string
|
||||
}
|
||||
|
||||
export type AgentSessionEntryUpdateManyMutationInput = {
|
||||
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 = {
|
||||
id?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
sessionId?: Prisma.StringFieldUpdateOperationsInput | string
|
||||
entry?:PrismaJson.PiSessionEntry
|
||||
sessionId?: Prisma.NullableStringFieldUpdateOperationsInput | string | null
|
||||
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 = {
|
||||
@@ -256,17 +332,29 @@ export type AgentSessionEntryOrderByRelationAggregateInput = {
|
||||
export type AgentSessionEntryCountOrderByAggregateInput = {
|
||||
id?: 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 = {
|
||||
id?: Prisma.SortOrder
|
||||
sessionId?: Prisma.SortOrder
|
||||
assetId?: Prisma.SortOrder
|
||||
type?: Prisma.SortOrder
|
||||
parentId?: Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
}
|
||||
|
||||
export type AgentSessionEntryMinOrderByAggregateInput = {
|
||||
id?: Prisma.SortOrder
|
||||
sessionId?: Prisma.SortOrder
|
||||
assetId?: Prisma.SortOrder
|
||||
type?: Prisma.SortOrder
|
||||
parentId?: Prisma.SortOrder
|
||||
createdAt?: Prisma.SortOrder
|
||||
}
|
||||
|
||||
export type AgentSessionEntryCreateNestedManyWithoutSessionInput = {
|
||||
@@ -313,12 +401,20 @@ export type AgentSessionEntryUncheckedUpdateManyWithoutSessionNestedInput = {
|
||||
|
||||
export type AgentSessionEntryCreateWithoutSessionInput = {
|
||||
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 = {
|
||||
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 = {
|
||||
@@ -352,28 +448,48 @@ export type AgentSessionEntryScalarWhereInput = {
|
||||
OR?: Prisma.AgentSessionEntryScalarWhereInput[]
|
||||
NOT?: Prisma.AgentSessionEntryScalarWhereInput | Prisma.AgentSessionEntryScalarWhereInput[]
|
||||
id?: Prisma.StringFilter<"AgentSessionEntry"> | string
|
||||
sessionId?: Prisma.StringFilter<"AgentSessionEntry"> | string
|
||||
entry?: Prisma.JsonFilter<"AgentSessionEntry">
|
||||
sessionId?: Prisma.StringNullableFilter<"AgentSessionEntry"> | string | null
|
||||
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 = {
|
||||
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 = {
|
||||
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 = {
|
||||
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 = {
|
||||
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<{
|
||||
id?: boolean
|
||||
sessionId?: boolean
|
||||
entry?: boolean
|
||||
session?: boolean | Prisma.AgentSessionDefaultArgs<ExtArgs>
|
||||
assetId?: boolean
|
||||
type?: boolean
|
||||
parentId?: boolean
|
||||
data?: boolean
|
||||
createdAt?: boolean
|
||||
session?: boolean | Prisma.AgentSessionEntry$sessionArgs<ExtArgs>
|
||||
}, ExtArgs["result"]["agentSessionEntry"]>
|
||||
|
||||
export type AgentSessionEntrySelectCreateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
|
||||
id?: boolean
|
||||
sessionId?: boolean
|
||||
entry?: boolean
|
||||
session?: boolean | Prisma.AgentSessionDefaultArgs<ExtArgs>
|
||||
assetId?: boolean
|
||||
type?: boolean
|
||||
parentId?: boolean
|
||||
data?: boolean
|
||||
createdAt?: boolean
|
||||
session?: boolean | Prisma.AgentSessionEntry$sessionArgs<ExtArgs>
|
||||
}, ExtArgs["result"]["agentSessionEntry"]>
|
||||
|
||||
export type AgentSessionEntrySelectUpdateManyAndReturn<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = runtime.Types.Extensions.GetSelect<{
|
||||
id?: boolean
|
||||
sessionId?: boolean
|
||||
entry?: boolean
|
||||
session?: boolean | Prisma.AgentSessionDefaultArgs<ExtArgs>
|
||||
assetId?: boolean
|
||||
type?: boolean
|
||||
parentId?: boolean
|
||||
data?: boolean
|
||||
createdAt?: boolean
|
||||
session?: boolean | Prisma.AgentSessionEntry$sessionArgs<ExtArgs>
|
||||
}, ExtArgs["result"]["agentSessionEntry"]>
|
||||
|
||||
export type AgentSessionEntrySelectScalar = {
|
||||
id?: 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> = {
|
||||
session?: boolean | Prisma.AgentSessionDefaultArgs<ExtArgs>
|
||||
session?: boolean | Prisma.AgentSessionEntry$sessionArgs<ExtArgs>
|
||||
}
|
||||
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> = {
|
||||
session?: boolean | Prisma.AgentSessionDefaultArgs<ExtArgs>
|
||||
session?: boolean | Prisma.AgentSessionEntry$sessionArgs<ExtArgs>
|
||||
}
|
||||
|
||||
export type $AgentSessionEntryPayload<ExtArgs extends runtime.Types.Extensions.InternalArgs = runtime.Types.Extensions.DefaultArgs> = {
|
||||
name: "AgentSessionEntry"
|
||||
objects: {
|
||||
session: Prisma.$AgentSessionPayload<ExtArgs>
|
||||
session: Prisma.$AgentSessionPayload<ExtArgs> | null
|
||||
}
|
||||
scalars: runtime.Types.Extensions.GetPayloadResult<{
|
||||
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"]>
|
||||
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> {
|
||||
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.
|
||||
* @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 {
|
||||
readonly id: 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
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
export {}
|
||||
|
||||
import { SessionTreeEntry } from '@earendil-works/pi-agent-core'
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line @typescript-eslint/no-namespace
|
||||
namespace PrismaJson {
|
||||
// ----------------------------------------------------------------------
|
||||
// Agent Session Entry
|
||||
// ----------------------------------------------------------------------
|
||||
export type PiSessionEntry = SessionTreeEntry
|
||||
export type PiSessionEntryData = Record<string, unknown>
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// User Agent Settings
|
||||
|
||||
Reference in New Issue
Block a user