feat(platform-service): allow memory-items to store blob media refs

This commit is contained in:
Saravana Dhandapani 2026-02-15 03:50:51 -08:00
parent 759fd78f3e
commit e64bba258f
3 changed files with 32 additions and 2 deletions

View File

@ -40,6 +40,21 @@ describe('CreateMemoryItemSchema', () => {
expect(result.data.captureSurface).toBe('app');
}
});
it('accepts media refs', () => {
const result = CreateMemoryItemSchema.safeParse({
rawContent: 'voice transcript',
sourceType: 'voice',
media: {
audio: {
container: 'audio',
blobName: 'lysnrai/usr_1/audio/test.caf',
contentType: 'audio/x-caf',
},
},
});
expect(result.success).toBe(true);
});
});
describe('ReassignMemoryItemSchema', () => {
@ -60,4 +75,3 @@ describe('PatchMemoryItemSchema', () => {
expect(result.success).toBe(false);
});
});

View File

@ -85,6 +85,7 @@ export async function memoryRoutes(app: FastifyInstance) {
rawContent: input.rawContent,
triageResult: triage,
brainIds,
...(input.media && { media: input.media }),
...(input.reminderAt && { reminderAt: input.reminderAt }),
actedOn: false,
actedOnAt: null,

View File

@ -33,6 +33,18 @@ export const TriageResultSchema = z.object({
suggestedActions: z.array(z.string().min(1).max(256)).default([]),
});
export const BlobRefSchema = z.object({
container: z.string().min(1).max(64),
blobName: z.string().min(1).max(1024),
contentType: z.string().min(1).max(128).optional(),
size: z.number().int().min(0).optional(),
});
export const MediaRefsSchema = z.object({
audio: BlobRefSchema.optional(),
image: BlobRefSchema.optional(),
});
export const ListMemoryItemsQuerySchema = z.object({
productId: z.string().min(1).max(64).optional(),
brainId: z.string().min(1).max(128).optional(),
@ -48,6 +60,7 @@ export const CreateMemoryItemSchema = z.object({
rawContent: z.string().min(1).max(50_000),
triageResult: TriageResultSchema.optional(),
brainIds: z.array(z.string().min(1).max(128)).optional(),
media: MediaRefsSchema.optional(),
isSensitive: z.boolean().optional(),
reminderAt: z
.string()
@ -68,6 +81,8 @@ export const PatchMemoryItemSchema = z.object({
});
export type TriageResult = z.infer<typeof TriageResultSchema>;
export type BlobRef = z.infer<typeof BlobRefSchema>;
export type MediaRefs = z.infer<typeof MediaRefsSchema>;
export type MemoryItemDoc = {
id: string;
@ -78,6 +93,7 @@ export type MemoryItemDoc = {
rawContent: string;
triageResult: TriageResult;
brainIds: string[];
media?: MediaRefs;
reminderAt?: string;
actedOn: boolean;
actedOnAt: string | null;
@ -87,4 +103,3 @@ export type MemoryItemDoc = {
createdAt: string;
updatedAt: string;
};