
Security News
Deno 2.6 + Socket: Supply Chain Defense In Your CLI
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.
@aigne/afs-user-profile-memory
Advanced tools
@aigne/afs-user-profile-memory is an AFS module that automatically extracts and maintains structured user profile information from conversations. It enables AI agents to build and maintain long-term memory about users across sessions.
UserProfileMemory listens to conversation history and intelligently extracts user information such as name, location, interests, family members, and projects. It stores this information in a structured JSON format and makes it available to agents through the AFS interface.
npm install @aigne/afs-user-profile-memory @aigne/afs @aigne/core
# or
yarn add @aigne/afs-user-profile-memory @aigne/afs @aigne/core
# or
pnpm add @aigne/afs-user-profile-memory @aigne/afs @aigne/core
import { AIGNE, AIAgent } from "@aigne/core";
import { AFS } from "@aigne/afs";
import { AFSHistory } from "@aigne/afs-history";
import { UserProfileMemory } from "@aigne/afs-user-profile-memory";
import { OpenAIChatModel } from "@aigne/openai";
// Setup AIGNE
const aigne = new AIGNE({
model: new OpenAIChatModel({ apiKey: process.env.OPENAI_API_KEY })
});
// Create AFS
const afs = new AFS();
// Mount history module (required for UserProfileMemory)
afs.mount(new AFSHistory({
storage: { url: "file:./memory.sqlite3" }
}));
// Mount UserProfileMemory
afs.mount(new UserProfileMemory({
context: aigne.newContext()
}));
// Accessible at /modules/user-profile-memory
// Create agent
const agent = AIAgent.from({
name: "assistant",
instructions: "You are a helpful assistant that remembers user information",
afs
});
// Have a conversation - profile is automatically built
const context = aigne.newContext();
await context.invoke(agent, {
message: "Hi! I'm John, I live in San Francisco and I love hiking."
});
// The profile is automatically extracted and stored at /modules/user-profile-memory
const { result } = await afs.read('/modules/user-profile-memory');
console.log(result.content);
// {
// name: [{ name: "John" }],
// location: [{ city: "San Francisco" }],
// interests: [{ content: "hiking" }]
// }
agentSucceed events from AFS/modules/user-profile-memoryThe user profile follows this structure:
interface UserProfile {
name?: Array<{
name: string;
remark?: string;
}>;
gender?: string;
birthday?: string;
languages?: Array<{
language: string;
remark?: string;
}>;
location?: Array<{
country?: string;
city?: string;
address?: string;
remark?: string;
}>;
interests?: Array<{
content: string;
remark?: string;
}>;
family?: Array<{
member: string;
relation?: string;
remark?: string;
}>;
projects?: Array<{
name: string;
remark?: string;
}>;
}
{
"name": [
{ "name": "John Smith", "remark": "Prefers to be called John" }
],
"gender": "male",
"birthday": "1990-05-15",
"languages": [
{ "language": "English", "remark": "Native" },
{ "language": "Spanish", "remark": "Intermediate" }
],
"location": [
{
"country": "USA",
"city": "San Francisco",
"remark": "Moved here in 2020"
}
],
"interests": [
{ "content": "hiking", "remark": "Goes every weekend" },
{ "content": "photography" },
{ "content": "cooking" }
],
"family": [
{ "member": "Sarah", "relation": "wife" },
{ "member": "Emma", "relation": "daughter", "remark": "5 years old" }
],
"projects": [
{ "name": "Personal blog", "remark": "Tech and photography" },
{ "name": "Open source contributions" }
]
}
new UserProfileMemory(options: { context: Context })
Options:
context: An AIGNE context for making AI callsManually trigger profile update from a conversation entry:
await userProfileMemory.updateProfile(conversationEntry);
Search returns the current profile:
const { list } = await afs.search('/modules/user-profile-memory', 'any query');
// Returns array with current profile entry
UserProfileMemory uses JSON Patch (RFC 6902) for efficient incremental updates:
// Example patch operations generated by the AI:
[
{
op: "add",
path: "/interests/0",
value: { content: "hiking" }
},
{
op: "replace",
path: "/location/0/city",
value: "San Francisco"
},
{
op: "remove",
path: "/projects/2"
}
]
This approach:
UserProfileMemory automatically integrates with AIGNE agents:
const agent = AIAgent.from({
name: "personal-assistant",
instructions: `You are a personal assistant that remembers user preferences.
Use the user profile information to personalize your responses.`,
afs: afs
});
// The agent can access the profile using afs_read tool
const result = await context.invoke(agent, {
message: "What do you know about me?"
});
Agents automatically have access to these tools:
UserProfileMemory hooks into the AFS event system:
// UserProfileMemory listens to this event internally
afs.on('agentSucceed', async ({ input, output }) => {
// Automatically updates profile from new conversation
});
// You can also listen to profile updates if needed
// (requires custom implementation)
try {
const { result } = await afs.read('/modules/user-profile-memory');
if (!result) {
console.log('No profile found yet');
}
} catch (error) {
console.error('Failed to read profile:', error);
}
This package includes full TypeScript type definitions:
import type { UserProfileMemory } from "@aigne/afs-user-profile-memory";
import type { userProfileSchema } from "@aigne/afs-user-profile-memory/schema";
import type { z } from "zod";
type UserProfile = z.infer<typeof userProfileSchema>;
@aigne/afs - AFS core functionality@aigne/core - AIGNE frameworkfast-json-patch - JSON Patch operationszod - Schema validationzod-to-json-schema - Convert Zod schemas to JSON SchemaFAQs
AIGNE AFS module for user profile memory
We found that @aigne/afs-user-profile-memory demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Deno 2.6 introduces deno audit with a new --socket flag that plugs directly into Socket to bring supply chain security checks into the Deno CLI.

Security News
New DoS and source code exposure bugs in React Server Components and Next.js: what’s affected and how to update safely.

Security News
Socket CEO Feross Aboukhadijeh joins Software Engineering Daily to discuss modern software supply chain attacks and rising AI-driven security risks.