@bubblelab/bubble-core 0.1.163 → 0.1.166

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,104 @@
1
+ import { z } from 'zod';
2
+ export type AgentMemoryMap = Record<string, string>;
3
+ export type AgentMemoryUpdateCallback = (filePath: string, content: string) => Promise<void>;
4
+ /**
5
+ * A function that calls an LLM and returns the response text.
6
+ * Provided by the caller (AIAgentBubble) so all LLM calls go through the same infrastructure.
7
+ */
8
+ export type LLMCallFn = (prompt: string) => Promise<string>;
9
+ /**
10
+ * Format the core memory files + indexes for injection into the system prompt.
11
+ * This is always injected — it's the agent's identity and awareness of what it knows.
12
+ */
13
+ export declare function formatCoreMemoryForPrompt(memory: AgentMemoryMap): string;
14
+ /**
15
+ * Self-improvement prompt appended to the system prompt.
16
+ */
17
+ export declare const MEMORY_SELF_IMPROVEMENT_PROMPT = "You have persistent memory across conversations. Your known topics, recent events, and core identity are above.\n\n## Before You Respond\n\n**Always recall first.** Before responding to the user or delegating to a capability, use recall_memory to retrieve full details about any people or topics mentioned in the conversation. The indexes above are summaries \u2014 the full context is in the topic files. Don't respond with partial knowledge when you could look it up.\n\n## Remembering\n\nYou have two memory tools:\n\n**create_memory** \u2014 Create a new memory file for someone or something you haven't seen before:\n- People & topics: file=\"topics/{slug}.md\", content=\"...\", topicName=\"Sarah Chen\", topicAliases=[\"Sarah\"]\n- Events: file=\"events/2025-02-15.md\", content=\"...\", eventSummary=\"Met Sarah, discussed Redis caching\"\n\n**update_memory** \u2014 Add new information to an existing memory file:\n- file=\"topics/sarah-chen.md\", content=\"Prefers bullet points over paragraphs\"\n\nWhen you meet someone new who isn't in your Known Topics, create a topic for them immediately with the specific date (e.g., \"Met on 2025-02-15, PST timezone\"). Always use the actual date, never say \"today\".\n\nYour personality (soul.md) and identity (identity.md) evolve automatically after each conversation \u2014 you don't need to update those yourself.\n\n## Delegating\n\nWhen delegating to a capability, include relevant context from memory (timezone, preferences, prior decisions) in your task description. The capability agent doesn't have access to your memory.";
18
+ /**
19
+ * Extracts person names from conversation history and returns matching topic content.
20
+ * Conversation history messages have the format: "[Name (timezone)]: message" or "[Name]: message"
21
+ */
22
+ export declare function autoRecallPersonTopics(memory: AgentMemoryMap, conversationHistory: Array<{
23
+ role: string;
24
+ content: string;
25
+ }>): string;
26
+ /**
27
+ * Build the recall_memory custom tool.
28
+ * Uses simple keyword/alias matching to find relevant files,
29
+ * then returns their combined content.
30
+ */
31
+ export declare function buildMemoryRecallTool(memory: AgentMemoryMap): {
32
+ name: string;
33
+ description: string;
34
+ schema: z.ZodObject<{
35
+ query: z.ZodString;
36
+ }, "strip", z.ZodTypeAny, {
37
+ query: string;
38
+ }, {
39
+ query: string;
40
+ }>;
41
+ func: (input: Record<string, unknown>) => Promise<string>;
42
+ };
43
+ /**
44
+ * Build the create_memory custom tool.
45
+ * Creates new topic/event files and updates indexes.
46
+ * Zero LLM calls — direct file write + index update.
47
+ */
48
+ export declare function buildMemoryCreateTool(memory: AgentMemoryMap, updateCallback: AgentMemoryUpdateCallback): {
49
+ name: string;
50
+ description: string;
51
+ schema: z.ZodObject<{
52
+ file: z.ZodString;
53
+ content: z.ZodString;
54
+ topicName: z.ZodOptional<z.ZodString>;
55
+ topicAliases: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
56
+ eventSummary: z.ZodOptional<z.ZodString>;
57
+ }, "strip", z.ZodTypeAny, {
58
+ file: string;
59
+ content: string;
60
+ topicName?: string | undefined;
61
+ topicAliases?: string[] | undefined;
62
+ eventSummary?: string | undefined;
63
+ }, {
64
+ file: string;
65
+ content: string;
66
+ topicName?: string | undefined;
67
+ topicAliases?: string[] | undefined;
68
+ eventSummary?: string | undefined;
69
+ }>;
70
+ func: (input: Record<string, unknown>) => Promise<string>;
71
+ };
72
+ /**
73
+ * Build the update_memory custom tool.
74
+ * Updates existing topic/event files. Uses callLLM only for merging topic content.
75
+ * No routing LLM — the master agent decides which file to target.
76
+ */
77
+ export declare function buildMemoryUpdateTool(memory: AgentMemoryMap, updateCallback: AgentMemoryUpdateCallback, callLLM: LLMCallFn): {
78
+ name: string;
79
+ description: string;
80
+ schema: z.ZodObject<{
81
+ file: z.ZodString;
82
+ content: z.ZodString;
83
+ }, "strip", z.ZodTypeAny, {
84
+ file: string;
85
+ content: string;
86
+ }, {
87
+ file: string;
88
+ content: string;
89
+ }>;
90
+ func: (input: Record<string, unknown>) => Promise<string>;
91
+ };
92
+ interface ConversationMessage {
93
+ role: string;
94
+ content: string;
95
+ }
96
+ /**
97
+ * Run a post-execution reflection over the conversation.
98
+ * Only updates soul.md and identity.md — implicit personality shaping.
99
+ * Topics and events are left for the agent to update explicitly via update_memory.
100
+ * Called after the agent finishes responding.
101
+ */
102
+ export declare function runMemoryReflection(conversationMessages: ConversationMessage[], memory: AgentMemoryMap, updateCallback: AgentMemoryUpdateCallback, callLLM: LLMCallFn): Promise<void>;
103
+ export {};
104
+ //# sourceMappingURL=agent-memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-memory.d.ts","sourceRoot":"","sources":["../../../src/bubbles/service-bubble/agent-memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEpD,MAAM,MAAM,yBAAyB,GAAG,CACtC,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,KACZ,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;AA4B5D;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,cAAc,GAAG,MAAM,CA8CxE;AAED;;GAEG;AACH,eAAO,MAAM,8BAA8B,qjDAuBuJ,CAAC;AAMnM;;;GAGG;AACH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