chore: import upstream snapshot with attribution
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
CI / Migrate Dev DB (push) Has been skipped
CI / Detect Version (push) Has been cancelled
CI / Migrate DB (push) Has been cancelled
CI / Build Dev ECR (./docker/app.Dockerfile, ECR_APP) (push) Has been cancelled
CI / Build Dev ECR (./docker/db.Dockerfile, ECR_MIGRATIONS) (push) Has been cancelled
CI / Build Dev ECR (./docker/pii.Dockerfile, ECR_PII) (push) Has been cancelled
CI / Build Dev ECR (./docker/realtime.Dockerfile, ECR_REALTIME) (push) Has been cancelled
CI / Deploy Trigger.dev (Dev) (push) Has been cancelled
CI / Build AMD64 (./docker/app.Dockerfile, ECR_APP, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build AMD64 (./docker/db.Dockerfile, ECR_MIGRATIONS, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build AMD64 (./docker/pii.Dockerfile, ECR_PII, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build AMD64 (./docker/realtime.Dockerfile, ECR_REALTIME, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/app.Dockerfile, ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/db.Dockerfile, ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/pii.Dockerfile, ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Build ARM64 (GHCR Only) (./docker/realtime.Dockerfile, ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/migrations) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/pii) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/realtime) (push) Has been cancelled
CI / Create GHCR Manifests (ghcr.io/simstudioai/simstudio) (push) Has been cancelled
CI / Check Docs Changes (push) Has been cancelled
CI / Process Docs (push) Has been cancelled
CI / Create GitHub Release (push) Has been cancelled
CI / Test and Build (push) Has been cancelled
Publish CLI Package / publish-npm (push) Has been cancelled
Publish Python SDK / publish-pypi (push) Has been cancelled
Publish TypeScript SDK / publish-npm (push) Has been cancelled
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
import type { MemoryResponse } from '@/tools/memory/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const memoryAddTool: ToolConfig<any, MemoryResponse> = {
|
||||
id: 'memory_add',
|
||||
name: 'Add Memory',
|
||||
description: 'Add a new memory to the database or append to existing memory with the same ID.',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
conversationId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'Conversation identifier (e.g., user-123, session-abc). If a memory with this conversationId already exists, the new message will be appended to it.',
|
||||
},
|
||||
id: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'Legacy parameter for conversation identifier. Use conversationId instead. Provided for backwards compatibility.',
|
||||
},
|
||||
role: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Role for agent memory (user, assistant, or system)',
|
||||
},
|
||||
content: {
|
||||
type: 'string',
|
||||
required: true,
|
||||
visibility: 'user-or-llm',
|
||||
description: 'Content for agent memory',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: '/api/memory',
|
||||
method: 'POST',
|
||||
headers: () => ({
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
body: (params) => {
|
||||
const workspaceId = params._context?.workspaceId
|
||||
if (!workspaceId) {
|
||||
throw new Error('workspaceId is required in execution context')
|
||||
}
|
||||
|
||||
const conversationId = params.conversationId || params.id
|
||||
if (!conversationId) {
|
||||
throw new Error('conversationId or id is required')
|
||||
}
|
||||
const key = conversationId
|
||||
|
||||
const body: Record<string, any> = {
|
||||
key,
|
||||
workspaceId,
|
||||
data: {
|
||||
role: params.role,
|
||||
content: params.content,
|
||||
},
|
||||
}
|
||||
|
||||
return body
|
||||
},
|
||||
},
|
||||
|
||||
transformResponse: async (response): Promise<MemoryResponse> => {
|
||||
const result = await response.json()
|
||||
const data = result.data || result
|
||||
|
||||
const memories = Array.isArray(data.data) ? data.data : [data.data]
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
memories,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the memory was added successfully' },
|
||||
memories: {
|
||||
type: 'array',
|
||||
description: 'Array of memory objects including the new or updated memory',
|
||||
},
|
||||
error: { type: 'string', description: 'Error message if operation failed' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
import type { MemoryResponse } from '@/tools/memory/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const memoryDeleteTool: ToolConfig<any, MemoryResponse> = {
|
||||
id: 'memory_delete',
|
||||
name: 'Delete Memory',
|
||||
description: 'Delete memories by conversationId.',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
conversationId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'Conversation identifier (e.g., user-123, session-abc). Deletes all memories for this conversation.',
|
||||
},
|
||||
id: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'Legacy parameter for conversation identifier. Use conversationId instead. Provided for backwards compatibility.',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const workspaceId = params._context?.workspaceId
|
||||
if (!workspaceId) {
|
||||
throw new Error('workspaceId is required in execution context')
|
||||
}
|
||||
|
||||
const conversationId = params.conversationId || params.id
|
||||
if (!conversationId) {
|
||||
throw new Error('conversationId or id is required')
|
||||
}
|
||||
|
||||
const url = new URL('/api/memory', 'http://dummy')
|
||||
url.searchParams.set('workspaceId', workspaceId)
|
||||
url.searchParams.set('conversationId', conversationId)
|
||||
|
||||
return url.pathname + url.search
|
||||
},
|
||||
method: 'DELETE',
|
||||
headers: () => ({
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response): Promise<MemoryResponse> => {
|
||||
const result = await response.json()
|
||||
const data = result.data || result
|
||||
|
||||
return {
|
||||
success: result.success !== false,
|
||||
output: {
|
||||
message: data.message || 'Memories deleted successfully',
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the memory was deleted successfully' },
|
||||
message: { type: 'string', description: 'Success or error message' },
|
||||
error: { type: 'string', description: 'Error message if operation failed' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
/**
|
||||
* @vitest-environment node
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { memoryGetTool } from '@/tools/memory/get'
|
||||
|
||||
interface MemoryGetParams {
|
||||
_context?: {
|
||||
workspaceId?: string
|
||||
}
|
||||
conversationId?: string
|
||||
id?: string
|
||||
}
|
||||
|
||||
describe('memoryGetTool', () => {
|
||||
const buildUrl = memoryGetTool.request.url as (params: MemoryGetParams) => string
|
||||
const transformResponse = memoryGetTool.transformResponse!
|
||||
|
||||
it('builds an exact memory lookup URL', () => {
|
||||
const url = buildUrl({
|
||||
_context: { workspaceId: 'workspace-1' },
|
||||
conversationId: 'user-123',
|
||||
})
|
||||
|
||||
expect(url).toBe('/api/memory/user-123?workspaceId=workspace-1')
|
||||
expect(url).not.toContain('query=')
|
||||
expect(url).not.toContain('limit=')
|
||||
})
|
||||
|
||||
it('encodes legacy id values in the path', () => {
|
||||
const url = buildUrl({
|
||||
_context: { workspaceId: 'workspace-1' },
|
||||
id: 'team/user 123',
|
||||
})
|
||||
|
||||
expect(url).toBe('/api/memory/team%2Fuser%20123?workspaceId=workspace-1')
|
||||
})
|
||||
|
||||
it('returns empty memories when key is not found (null data)', async () => {
|
||||
const result = await transformResponse(
|
||||
new Response(JSON.stringify({ success: true, data: null }))
|
||||
)
|
||||
|
||||
expect(result).toEqual({
|
||||
success: true,
|
||||
output: {
|
||||
memories: [],
|
||||
message: 'No memories found',
|
||||
},
|
||||
})
|
||||
})
|
||||
|
||||
it('wraps the exact memory response as a single result', async () => {
|
||||
const result = await transformResponse(
|
||||
new Response(
|
||||
JSON.stringify({
|
||||
success: true,
|
||||
data: {
|
||||
conversationId: 'user-123',
|
||||
data: [{ role: 'user', content: 'Remember this' }],
|
||||
},
|
||||
})
|
||||
)
|
||||
)
|
||||
|
||||
expect(result).toEqual({
|
||||
success: true,
|
||||
output: {
|
||||
memories: [
|
||||
{
|
||||
conversationId: 'user-123',
|
||||
data: [{ role: 'user', content: 'Remember this' }],
|
||||
},
|
||||
],
|
||||
message: 'Found 1 memory',
|
||||
},
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,81 @@
|
||||
import type { MemoryResponse } from '@/tools/memory/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const memoryGetTool: ToolConfig<any, MemoryResponse> = {
|
||||
id: 'memory_get',
|
||||
name: 'Get Memory',
|
||||
description: 'Retrieve memory by conversationId. Returns matching memories.',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {
|
||||
conversationId: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'Conversation identifier (e.g., user-123, session-abc). Returns memories for this conversation.',
|
||||
},
|
||||
id: {
|
||||
type: 'string',
|
||||
required: false,
|
||||
visibility: 'user-or-llm',
|
||||
description:
|
||||
'Legacy parameter for conversation identifier. Use conversationId instead. Provided for backwards compatibility.',
|
||||
},
|
||||
},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const workspaceId = params._context?.workspaceId
|
||||
if (!workspaceId) {
|
||||
throw new Error('workspaceId is required in execution context')
|
||||
}
|
||||
|
||||
const conversationId = params.conversationId || params.id
|
||||
if (!conversationId) {
|
||||
throw new Error('conversationId or id is required')
|
||||
}
|
||||
const url = new URL(`/api/memory/${encodeURIComponent(conversationId)}`, 'http://dummy')
|
||||
url.searchParams.set('workspaceId', workspaceId)
|
||||
|
||||
return url.pathname + url.search
|
||||
},
|
||||
method: 'GET',
|
||||
headers: () => ({
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response): Promise<MemoryResponse> => {
|
||||
const result = await response.json()
|
||||
const memory = result.data
|
||||
|
||||
if (!memory) {
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
memories: [],
|
||||
message: 'No memories found',
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
memories: [memory],
|
||||
message: 'Found 1 memory',
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether the memory was retrieved successfully' },
|
||||
memories: {
|
||||
type: 'array',
|
||||
description: 'Array of memory objects with conversationId and data fields',
|
||||
},
|
||||
message: { type: 'string', description: 'Success or error message' },
|
||||
error: { type: 'string', description: 'Error message if operation failed' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
import type { MemoryResponse } from '@/tools/memory/types'
|
||||
import type { ToolConfig } from '@/tools/types'
|
||||
|
||||
export const memoryGetAllTool: ToolConfig<any, MemoryResponse> = {
|
||||
id: 'memory_get_all',
|
||||
name: 'Get All Memories',
|
||||
description: 'Retrieve all memories from the database',
|
||||
version: '1.0.0',
|
||||
|
||||
params: {},
|
||||
|
||||
request: {
|
||||
url: (params) => {
|
||||
const workspaceId = params._context?.workspaceId
|
||||
if (!workspaceId) {
|
||||
throw new Error('workspaceId is required in execution context')
|
||||
}
|
||||
|
||||
return `/api/memory?workspaceId=${encodeURIComponent(workspaceId)}`
|
||||
},
|
||||
method: 'GET',
|
||||
headers: () => ({
|
||||
'Content-Type': 'application/json',
|
||||
}),
|
||||
},
|
||||
|
||||
transformResponse: async (response): Promise<MemoryResponse> => {
|
||||
const result = await response.json()
|
||||
|
||||
const data = result.data || result
|
||||
const memories = data.memories || data || []
|
||||
|
||||
if (!Array.isArray(memories) || memories.length === 0) {
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
memories: [],
|
||||
message: 'No memories found',
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
success: true,
|
||||
output: {
|
||||
memories,
|
||||
message: `Found ${memories.length} memories`,
|
||||
},
|
||||
}
|
||||
},
|
||||
|
||||
outputs: {
|
||||
success: { type: 'boolean', description: 'Whether all memories were retrieved successfully' },
|
||||
memories: {
|
||||
type: 'array',
|
||||
description: 'Array of all memory objects with key, conversationId, and data fields',
|
||||
},
|
||||
message: { type: 'string', description: 'Success or error message' },
|
||||
error: { type: 'string', description: 'Error message if operation failed' },
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
import { memoryAddTool } from '@/tools/memory/add'
|
||||
import { memoryDeleteTool } from '@/tools/memory/delete'
|
||||
import { memoryGetTool } from '@/tools/memory/get'
|
||||
import { memoryGetAllTool } from '@/tools/memory/get_all'
|
||||
|
||||
export { memoryAddTool, memoryGetTool, memoryGetAllTool, memoryDeleteTool }
|
||||
@@ -0,0 +1,30 @@
|
||||
import type { ToolResponse } from '@/tools/types'
|
||||
|
||||
export interface MemoryResponse extends ToolResponse {
|
||||
output: {
|
||||
memories?: any[]
|
||||
message?: string
|
||||
}
|
||||
}
|
||||
|
||||
interface AgentMemoryData {
|
||||
role: 'user' | 'assistant' | 'system'
|
||||
content: string
|
||||
}
|
||||
|
||||
interface MemoryRecord {
|
||||
id: string
|
||||
key: string
|
||||
conversationId: string
|
||||
data: AgentMemoryData[]
|
||||
createdAt: string
|
||||
updatedAt: string
|
||||
workflowId?: string
|
||||
workspaceId?: string
|
||||
}
|
||||
|
||||
interface MemoryError {
|
||||
code: string
|
||||
message: string
|
||||
details?: Record<string, any>
|
||||
}
|
||||
Reference in New Issue
Block a user