@prmichaelsen/remember-mcp 3.15.6 → 3.16.0

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/agent/design/local.unified-internal-memory-tools.md +325 -0
  3. package/agent/milestones/milestone-20-unified-internal-memory-tools.md +58 -0
  4. package/agent/progress.yaml +115 -1
  5. package/agent/tasks/milestone-20-unified-internal-memory-tools/task-212-add-internal-context-type.md +54 -0
  6. package/agent/tasks/milestone-20-unified-internal-memory-tools/task-213-update-server-factory-internal-context.md +117 -0
  7. package/agent/tasks/milestone-20-unified-internal-memory-tools/task-214-create-tag-builder-utility.md +50 -0
  8. package/agent/tasks/milestone-20-unified-internal-memory-tools/task-215-create-unified-internal-memory-tools.md +65 -0
  9. package/agent/tasks/milestone-20-unified-internal-memory-tools/task-216-update-default-search-filters.md +46 -0
  10. package/agent/tasks/milestone-20-unified-internal-memory-tools/task-217-delete-standalone-ghost-tools.md +46 -0
  11. package/agent/tasks/milestone-20-unified-internal-memory-tools/task-218-add-tests-unified-internal-tools.md +66 -0
  12. package/dist/e2e-helpers.d.ts +1 -1
  13. package/dist/server-factory.d.ts +17 -41
  14. package/dist/server-factory.js +286 -149
  15. package/dist/server.js +23 -17
  16. package/dist/tools/{create-ghost-memory.d.ts → create-internal-memory.d.ts} +7 -9
  17. package/dist/tools/internal-tools.spec.d.ts +2 -0
  18. package/dist/tools/{query-ghost-memory.d.ts → query-internal-memory.d.ts} +6 -6
  19. package/dist/tools/{search-ghost-memory-by.d.ts → search-internal-memory-by.d.ts} +6 -6
  20. package/dist/tools/{search-ghost-memory.d.ts → search-internal-memory.d.ts} +6 -6
  21. package/dist/tools/{update-ghost-memory.d.ts → update-internal-memory.d.ts} +6 -6
  22. package/dist/types/auth.d.ts +22 -8
  23. package/dist/utils/internal-tags.d.ts +14 -0
  24. package/dist/utils/internal-tags.spec.d.ts +2 -0
  25. package/package.json +1 -2
  26. package/src/e2e-helpers.ts +4 -2
  27. package/src/ghost-persona.e2e.ts +18 -17
  28. package/src/server-factory.ts +117 -55
  29. package/src/tools/create-internal-memory.ts +105 -0
  30. package/src/tools/find-similar.ts +2 -2
  31. package/src/tools/internal-tools.spec.ts +312 -0
  32. package/src/tools/query-internal-memory.ts +73 -0
  33. package/src/tools/query-memory.ts +15 -12
  34. package/src/tools/search-by.spec.ts +6 -2
  35. package/src/tools/search-by.ts +21 -10
  36. package/src/tools/search-internal-memory-by.ts +107 -0
  37. package/src/tools/search-internal-memory.ts +87 -0
  38. package/src/tools/search-memory.ts +15 -12
  39. package/src/tools/search-space-by.ts +22 -11
  40. package/src/tools/search-space.ts +1 -0
  41. package/src/tools/{update-ghost-memory.ts → update-internal-memory.ts} +23 -17
  42. package/src/types/auth.ts +22 -8
  43. package/src/utils/internal-tags.spec.ts +104 -0
  44. package/src/utils/internal-tags.ts +46 -0
  45. package/dist/tools/ghost-tools.spec.d.ts +0 -2
  46. package/src/tools/create-ghost-memory.ts +0 -103
  47. package/src/tools/ghost-tools.spec.ts +0 -361
  48. package/src/tools/query-ghost-memory.ts +0 -63
  49. package/src/tools/search-ghost-memory-by.ts +0 -80
  50. package/src/tools/search-ghost-memory.ts +0 -73
package/dist/server.js CHANGED
@@ -5789,12 +5789,12 @@ var searchMemoryTool = {
5789
5789
  }
5790
5790
  };
5791
5791
  async function handleSearchMemory(args, userId, authContext) {
5792
- const ghostMode = authContext?.ghostMode;
5793
- const searchUserId = ghostMode?.owner_user_id ?? userId;
5794
- const debug = createDebugLogger({ tool: "remember_search_memory", userId: searchUserId, operation: ghostMode ? "ghost search" : "search memory" });
5792
+ const internalContext = authContext?.internalContext;
5793
+ const searchUserId = internalContext?.owner_user_id ?? userId;
5794
+ const debug = createDebugLogger({ tool: "remember_search_memory", userId: searchUserId, operation: internalContext ? "internal search" : "search memory" });
5795
5795
  try {
5796
5796
  debug.info("Tool invoked");
5797
- debug.trace("Arguments", { args, ghostMode: !!ghostMode });
5797
+ debug.trace("Arguments", { args, internalContext: !!internalContext });
5798
5798
  if (!args.query || args.query.trim() === "") {
5799
5799
  throw new Error("Query cannot be empty");
5800
5800
  }
@@ -5803,18 +5803,21 @@ async function handleSearchMemory(args, userId, authContext) {
5803
5803
  userId: searchUserId,
5804
5804
  query: args.query,
5805
5805
  includeRelationships,
5806
- ghostMode: !!ghostMode
5806
+ internalContext: !!internalContext
5807
5807
  });
5808
5808
  const collection = getMemoryCollection2(searchUserId);
5809
5809
  const alpha = args.alpha ?? 0.7;
5810
5810
  const limit = args.limit ?? 10;
5811
5811
  const offset = args.offset ?? 0;
5812
5812
  const deletedFilter = buildDeletedFilter(collection, args.deleted_filter || "exclude");
5813
- const trustFilter = ghostMode ? buildTrustFilter(collection, ghostMode.accessor_trust_level) : null;
5813
+ const trustFilter = internalContext?.accessor_trust_level != null ? buildTrustFilter(collection, internalContext.accessor_trust_level) : null;
5814
5814
  const searchFilters = includeRelationships ? buildCombinedSearchFilters(collection, args.filters) : buildMemoryOnlyFilters(collection, args.filters);
5815
5815
  const hasExplicitTypeFilter = args.filters?.types && args.filters.types.length > 0;
5816
- const ghostExclusionFilter = !hasExplicitTypeFilter ? collection.filter.byProperty("content_type").notEqual("ghost") : null;
5817
- const combinedFilters = combineFiltersWithAnd([deletedFilter, trustFilter, ghostExclusionFilter, searchFilters].filter((f) => f !== null));
5816
+ const internalExclusionFilter = !hasExplicitTypeFilter ? combineFiltersWithAnd([
5817
+ collection.filter.byProperty("content_type").notEqual("ghost"),
5818
+ collection.filter.byProperty("content_type").notEqual("agent")
5819
+ ]) : null;
5820
+ const combinedFilters = combineFiltersWithAnd([deletedFilter, trustFilter, internalExclusionFilter, searchFilters].filter((f) => f !== null));
5818
5821
  const searchOptions = {
5819
5822
  alpha,
5820
5823
  limit,
@@ -6160,7 +6163,7 @@ async function handleFindSimilar(args, userId, authContext) {
6160
6163
  deleted_filter: args.deleted_filter
6161
6164
  });
6162
6165
  const filteredMemories = coreResult.similar_memories.filter(
6163
- (m) => m.content_type !== "ghost"
6166
+ (m) => m.content_type !== "ghost" && m.content_type !== "agent"
6164
6167
  );
6165
6168
  const result = {
6166
6169
  query: {
@@ -6303,27 +6306,30 @@ var queryMemoryTool = {
6303
6306
  }
6304
6307
  };
6305
6308
  async function handleQueryMemory(args, userId, authContext) {
6306
- const ghostMode = authContext?.ghostMode;
6307
- const searchUserId = ghostMode?.owner_user_id ?? userId;
6308
- const debug = createDebugLogger({ tool: "remember_query_memory", userId: searchUserId, operation: ghostMode ? "ghost query" : "query memory" });
6309
+ const internalContext = authContext?.internalContext;
6310
+ const searchUserId = internalContext?.owner_user_id ?? userId;
6311
+ const debug = createDebugLogger({ tool: "remember_query_memory", userId: searchUserId, operation: internalContext ? "internal query" : "query memory" });
6309
6312
  try {
6310
6313
  debug.info("Tool invoked");
6311
- debug.trace("Arguments", { args, ghostMode: !!ghostMode });
6314
+ debug.trace("Arguments", { args, internalContext: !!internalContext });
6312
6315
  if (!args.query || args.query.trim() === "") {
6313
6316
  throw new Error("Query cannot be empty");
6314
6317
  }
6315
- logger.info("Querying memories", { userId: searchUserId, query: args.query, ghostMode: !!ghostMode });
6318
+ logger.info("Querying memories", { userId: searchUserId, query: args.query, internalContext: !!internalContext });
6316
6319
  const collection = getMemoryCollection2(searchUserId);
6317
6320
  const limit = args.limit ?? 5;
6318
6321
  const minRelevance = args.min_relevance ?? 0.6;
6319
6322
  const includeContext = args.include_context ?? true;
6320
6323
  const format = args.format ?? "detailed";
6321
6324
  const deletedFilter = buildDeletedFilter(collection, args.deleted_filter || "exclude");
6322
- const trustFilter = ghostMode ? buildTrustFilter(collection, ghostMode.accessor_trust_level) : null;
6325
+ const trustFilter = internalContext?.accessor_trust_level != null ? buildTrustFilter(collection, internalContext.accessor_trust_level) : null;
6323
6326
  const searchFilters = buildCombinedSearchFilters(collection, args.filters);
6324
6327
  const hasExplicitTypeFilter = args.filters?.types && args.filters.types.length > 0;
6325
- const ghostExclusionFilter = !hasExplicitTypeFilter ? collection.filter.byProperty("content_type").notEqual("ghost") : null;
6326
- const combinedFilters = combineFiltersWithAnd([deletedFilter, trustFilter, ghostExclusionFilter, searchFilters].filter((f) => f !== null));
6328
+ const internalExclusionFilter = !hasExplicitTypeFilter ? combineFiltersWithAnd([
6329
+ collection.filter.byProperty("content_type").notEqual("ghost"),
6330
+ collection.filter.byProperty("content_type").notEqual("agent")
6331
+ ]) : null;
6332
+ const combinedFilters = combineFiltersWithAnd([deletedFilter, trustFilter, internalExclusionFilter, searchFilters].filter((f) => f !== null));
6327
6333
  const searchOptions = {
6328
6334
  limit,
6329
6335
  distance: 1 - minRelevance,
@@ -1,9 +1,10 @@
1
1
  /**
2
- * remember_create_ghost_memory tool
3
- * Creates a ghost memory with hardcoded content_type and ghost-specific tags
2
+ * remember_create_internal_memory tool
3
+ * Creates a ghost or agent memory based on the current session's InternalContext.
4
+ * Content type and tags are derived from platform HTTP headers, not tool args.
4
5
  */
5
6
  import type { AuthContext } from '../types/auth.js';
6
- export declare const createGhostMemoryTool: {
7
+ export declare const createInternalMemoryTool: {
7
8
  name: string;
8
9
  description: string;
9
10
  inputSchema: {
@@ -40,25 +41,22 @@ export declare const createGhostMemoryTool: {
40
41
  type: string;
41
42
  minimum: number;
42
43
  maximum: number;
43
- description: string;
44
44
  };
45
45
  feel_social_weight: {
46
46
  type: string;
47
47
  minimum: number;
48
48
  maximum: number;
49
- description: string;
50
49
  };
51
50
  feel_narrative_importance: {
52
51
  type: string;
53
52
  minimum: number;
54
53
  maximum: number;
55
- description: string;
56
54
  };
57
55
  };
58
56
  required: string[];
59
57
  };
60
58
  };
61
- export interface CreateGhostMemoryArgs {
59
+ export interface CreateInternalMemoryArgs {
62
60
  content: string;
63
61
  title?: string;
64
62
  tags?: string[];
@@ -66,5 +64,5 @@ export interface CreateGhostMemoryArgs {
66
64
  trust?: number;
67
65
  [key: string]: any;
68
66
  }
69
- export declare function handleCreateGhostMemory(args: CreateGhostMemoryArgs, userId: string, authContext?: AuthContext): Promise<string>;
70
- //# sourceMappingURL=create-ghost-memory.d.ts.map
67
+ export declare function handleCreateInternalMemory(args: CreateInternalMemoryArgs, userId: string, authContext?: AuthContext): Promise<string>;
68
+ //# sourceMappingURL=create-internal-memory.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=internal-tools.spec.d.ts.map
@@ -1,9 +1,9 @@
1
1
  /**
2
- * remember_query_ghost_memory tool
3
- * Wraps query_memory with hardcoded ghost type filter
2
+ * remember_query_internal_memory tool
3
+ * Wraps query_memory with auto-scoped content type and ghost source filters.
4
4
  */
5
5
  import type { AuthContext } from '../types/auth.js';
6
- export declare const queryGhostMemoryTool: {
6
+ export declare const queryInternalMemoryTool: {
7
7
  name: string;
8
8
  description: string;
9
9
  inputSchema: {
@@ -25,10 +25,10 @@ export declare const queryGhostMemoryTool: {
25
25
  required: string[];
26
26
  };
27
27
  };
28
- export interface QueryGhostMemoryArgs {
28
+ export interface QueryInternalMemoryArgs {
29
29
  query: string;
30
30
  limit?: number;
31
31
  min_relevance?: number;
32
32
  }
33
- export declare function handleQueryGhostMemory(args: QueryGhostMemoryArgs, userId: string, authContext?: AuthContext): Promise<string>;
34
- //# sourceMappingURL=query-ghost-memory.d.ts.map
33
+ export declare function handleQueryInternalMemory(args: QueryInternalMemoryArgs, userId: string, authContext?: AuthContext): Promise<string>;
34
+ //# sourceMappingURL=query-internal-memory.d.ts.map
@@ -1,10 +1,10 @@
1
1
  /**
2
- * remember_search_ghost_memory_by tool
3
- * Wraps search_by with hardcoded ghost type filter
2
+ * remember_search_internal_memory_by tool
3
+ * Wraps search_by with auto-scoped content type and ghost source filters.
4
4
  */
5
5
  import type { AuthContext } from '../types/auth.js';
6
6
  import type { SearchByMode } from './search-by.js';
7
- export declare const searchGhostMemoryByTool: {
7
+ export declare const searchInternalMemoryByTool: {
8
8
  name: string;
9
9
  description: string;
10
10
  inputSchema: {
@@ -41,7 +41,7 @@ export declare const searchGhostMemoryByTool: {
41
41
  required: string[];
42
42
  };
43
43
  };
44
- export interface SearchGhostMemoryByArgs {
44
+ export interface SearchInternalMemoryByArgs {
45
45
  mode: SearchByMode;
46
46
  query?: string;
47
47
  sort_order?: 'asc' | 'desc';
@@ -50,5 +50,5 @@ export interface SearchGhostMemoryByArgs {
50
50
  offset?: number;
51
51
  deleted_filter?: 'exclude' | 'include' | 'only';
52
52
  }
53
- export declare function handleSearchGhostMemoryBy(args: SearchGhostMemoryByArgs, userId: string, authContext?: AuthContext): Promise<string>;
54
- //# sourceMappingURL=search-ghost-memory-by.d.ts.map
53
+ export declare function handleSearchInternalMemoryBy(args: SearchInternalMemoryByArgs, userId: string, authContext?: AuthContext): Promise<string>;
54
+ //# sourceMappingURL=search-internal-memory-by.d.ts.map
@@ -1,9 +1,9 @@
1
1
  /**
2
- * remember_search_ghost_memory tool
3
- * Wraps search_memory with hardcoded ghost type filter
2
+ * remember_search_internal_memory tool
3
+ * Wraps search_memory with auto-scoped content type and ghost source filters.
4
4
  */
5
5
  import type { AuthContext } from '../types/auth.js';
6
- export declare const searchGhostMemoryTool: {
6
+ export declare const searchInternalMemoryTool: {
7
7
  name: string;
8
8
  description: string;
9
9
  inputSchema: {
@@ -41,7 +41,7 @@ export declare const searchGhostMemoryTool: {
41
41
  required: string[];
42
42
  };
43
43
  };
44
- export interface SearchGhostMemoryArgs {
44
+ export interface SearchInternalMemoryArgs {
45
45
  query: string;
46
46
  alpha?: number;
47
47
  tags?: string[];
@@ -49,5 +49,5 @@ export interface SearchGhostMemoryArgs {
49
49
  offset?: number;
50
50
  deleted_filter?: 'exclude' | 'include' | 'only';
51
51
  }
52
- export declare function handleSearchGhostMemory(args: SearchGhostMemoryArgs, userId: string, authContext?: AuthContext): Promise<string>;
53
- //# sourceMappingURL=search-ghost-memory.d.ts.map
52
+ export declare function handleSearchInternalMemory(args: SearchInternalMemoryArgs, userId: string, authContext?: AuthContext): Promise<string>;
53
+ //# sourceMappingURL=search-internal-memory.d.ts.map
@@ -1,9 +1,9 @@
1
1
  /**
2
- * remember_update_ghost_memory tool
3
- * Updates a ghost memory after validating content_type
2
+ * remember_update_internal_memory tool
3
+ * Updates a ghost or agent memory after validating content_type matches session context.
4
4
  */
5
5
  import type { AuthContext } from '../types/auth.js';
6
- export declare const updateGhostMemoryTool: {
6
+ export declare const updateInternalMemoryTool: {
7
7
  name: string;
8
8
  description: string;
9
9
  inputSchema: {
@@ -39,7 +39,7 @@ export declare const updateGhostMemoryTool: {
39
39
  required: string[];
40
40
  };
41
41
  };
42
- export interface UpdateGhostMemoryArgs {
42
+ export interface UpdateInternalMemoryArgs {
43
43
  memory_id: string;
44
44
  content?: string;
45
45
  title?: string;
@@ -47,5 +47,5 @@ export interface UpdateGhostMemoryArgs {
47
47
  weight?: number;
48
48
  trust?: number;
49
49
  }
50
- export declare function handleUpdateGhostMemory(args: UpdateGhostMemoryArgs, userId: string, authContext?: AuthContext): Promise<string>;
51
- //# sourceMappingURL=update-ghost-memory.d.ts.map
50
+ export declare function handleUpdateInternalMemory(args: UpdateInternalMemoryArgs, userId: string, authContext?: AuthContext): Promise<string>;
51
+ //# sourceMappingURL=update-internal-memory.d.ts.map
@@ -24,20 +24,34 @@ export interface UserCredentials {
24
24
  user_id: string;
25
25
  group_memberships: GroupMembership[];
26
26
  }
27
- /** Ghost conversation context — resolved server-side, never from tool args */
28
- export interface GhostModeContext {
29
- /** The ghost owner's user ID (whose memories are being searched) */
30
- owner_user_id: string;
31
- /** The accessor's user ID (who is chatting with the ghost) */
27
+ /**
28
+ * Internal context for ghost/agent sessions — resolved server-side from
29
+ * platform HTTP headers, never from tool args.
30
+ *
31
+ * Replaces the former GhostModeContext. All ghost identity, trust, and
32
+ * agent context is unified here.
33
+ */
34
+ export interface InternalContext {
35
+ /** Whether this is a ghost or agent session */
36
+ type: 'ghost' | 'agent';
37
+ /** Ghost sub-type (required when type is 'ghost') */
38
+ ghost_type?: 'user' | 'space' | 'group';
39
+ /** Space ID (space ghosts only) */
40
+ ghost_space?: string;
41
+ /** Group ID (group ghosts only) */
42
+ ghost_group?: string;
43
+ /** The ghost owner's user ID (user ghosts — whose memories are searched) */
44
+ owner_user_id?: string;
45
+ /** The accessor's user ID (who is conversing) */
32
46
  accessor_user_id: string;
33
47
  /** Resolved trust level (looked up from GhostConfig, not user-supplied) */
34
- accessor_trust_level: number;
48
+ accessor_trust_level?: number;
35
49
  }
36
50
  export interface AuthContext {
37
51
  accessToken: string | null;
38
52
  credentials: UserCredentials | null;
39
- /** Present when the server is running in ghost conversation mode */
40
- ghostMode?: GhostModeContext;
53
+ /** Present when the server is running in ghost or agent mode */
54
+ internalContext?: InternalContext;
41
55
  }
42
56
  export type WriteMode = 'owner_only' | 'group_editors' | 'anyone';
43
57
  export interface CredentialsProvider {
@@ -0,0 +1,14 @@
1
+ import type { AuthContext } from '../types/auth.js';
2
+ /**
3
+ * Build tags for internal (ghost/agent) memories based on the current
4
+ * session's InternalContext. These tags implement ghost source isolation
5
+ * so memories from different ghost conversations are distinguishable.
6
+ *
7
+ * Tag scheme:
8
+ * User ghost (alice): ['ghost', 'ghost_type:user', 'ghost_owner:user:alice']
9
+ * Space ghost (music-lovers): ['ghost', 'ghost_type:space', 'ghost_owner:space:music-lovers']
10
+ * Group ghost (band-mates): ['ghost', 'ghost_type:group', 'ghost_owner:group:band-mates']
11
+ * Agent: ['agent']
12
+ */
13
+ export declare function buildInternalTags(authContext: AuthContext): string[];
14
+ //# sourceMappingURL=internal-tags.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=internal-tags.spec.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prmichaelsen/remember-mcp",
3
- "version": "3.15.6",
3
+ "version": "3.16.0",
4
4
  "description": "Multi-tenant memory system MCP server with vector search and relationships",
5
5
  "main": "dist/server.js",
6
6
  "type": "module",
@@ -51,7 +51,6 @@
51
51
  "@google-cloud/vision": "^5.3.4",
52
52
  "@modelcontextprotocol/sdk": "^1.0.4",
53
53
  "@prmichaelsen/firebase-admin-sdk-v8": "^2.2.0",
54
- "@prmichaelsen/mcp-auth": "^7.0.4",
55
54
  "@prmichaelsen/remember-core": "^0.45.0",
56
55
  "dotenv": "^16.4.5",
57
56
  "uuid": "^13.0.0",
@@ -24,12 +24,14 @@ export function e2eAuthContext(): AuthContext {
24
24
  return { accessToken: null, credentials: null };
25
25
  }
26
26
 
27
- /** AuthContext with ghost mode for cross-user tests */
27
+ /** AuthContext with ghost internal context for cross-user tests */
28
28
  export function e2eGhostAuthContext(ownerUserId: string, accessorUserId: string, trustLevel = 0.5): AuthContext {
29
29
  return {
30
30
  accessToken: null,
31
31
  credentials: null,
32
- ghostMode: {
32
+ internalContext: {
33
+ type: 'ghost',
34
+ ghost_type: 'user',
33
35
  owner_user_id: ownerUserId,
34
36
  accessor_user_id: accessorUserId,
35
37
  accessor_trust_level: trustLevel,
@@ -10,11 +10,11 @@ import {
10
10
  e2eEnsureCollection, e2eCleanup, parseResult, waitForIndex,
11
11
  } from './e2e-helpers.js';
12
12
  import { handleGhostConfig } from './tools/ghost-config.js';
13
- import { handleCreateGhostMemory } from './tools/create-ghost-memory.js';
14
- import { handleSearchGhostMemory } from './tools/search-ghost-memory.js';
15
- import { handleUpdateGhostMemory } from './tools/update-ghost-memory.js';
16
- import { handleQueryGhostMemory } from './tools/query-ghost-memory.js';
17
- import { handleSearchGhostMemoryBy } from './tools/search-ghost-memory-by.js';
13
+ import { handleCreateInternalMemory } from './tools/create-internal-memory.js';
14
+ import { handleSearchInternalMemory } from './tools/search-internal-memory.js';
15
+ import { handleUpdateInternalMemory } from './tools/update-internal-memory.js';
16
+ import { handleQueryInternalMemory } from './tools/query-internal-memory.js';
17
+ import { handleSearchInternalMemoryBy } from './tools/search-internal-memory-by.js';
18
18
  import { handleGetCore } from './tools/get-core.js';
19
19
 
20
20
  const ownerId = e2eUserId('ghost_owner');
@@ -79,7 +79,7 @@ describe('E2E: Ghost/Persona', () => {
79
79
  // -------------------------------------------------------------------------
80
80
 
81
81
  it('creates a ghost memory', async () => {
82
- const res = parseResult(await handleCreateGhostMemory(
82
+ const res = parseResult(await handleCreateInternalMemory(
83
83
  {
84
84
  content: `${accessorId} asked about my favorite hiking trails. They seem genuinely interested in outdoor activities.`,
85
85
  weight: 0.6,
@@ -94,7 +94,8 @@ describe('E2E: Ghost/Persona', () => {
94
94
  expect(res.memory_id).toBeTruthy();
95
95
  expect(res.content_type).toBe('ghost');
96
96
  expect(res.tags).toContain('ghost');
97
- expect(res.tags).toContain(`ghost:${accessorId}`);
97
+ expect(res.tags).toContain('ghost_type:user');
98
+ expect(res.tags).toContain(`ghost_owner:user:${ownerId}`);
98
99
  ghostMemoryId = res.memory_id;
99
100
  console.log(` created ghost memory ${ghostMemoryId}`);
100
101
  });
@@ -106,10 +107,10 @@ describe('E2E: Ghost/Persona', () => {
106
107
  it('searches ghost memories', async () => {
107
108
  await waitForIndex(5000);
108
109
 
109
- // Search ghost memories specifically
110
- const res = parseResult(await handleSearchGhostMemory(
110
+ // Search ghost memories via unified internal tool
111
+ const res = parseResult(await handleSearchInternalMemory(
111
112
  { query: 'hiking trails outdoor activities', limit: 5 },
112
- ownerId, ownerAuth,
113
+ ownerId, ghostAuth,
113
114
  ));
114
115
 
115
116
  expect(res.memories).toBeDefined();
@@ -123,7 +124,7 @@ describe('E2E: Ghost/Persona', () => {
123
124
  // -------------------------------------------------------------------------
124
125
 
125
126
  it('updates the ghost memory', async () => {
126
- const res = parseResult(await handleUpdateGhostMemory(
127
+ const res = parseResult(await handleUpdateInternalMemory(
127
128
  {
128
129
  memory_id: ghostMemoryId,
129
130
  content: `${accessorId} asked about my favorite hiking trails. They seem genuinely interested in outdoor activities. Follow-up: they mentioned they go rock climbing too.`,
@@ -141,10 +142,10 @@ describe('E2E: Ghost/Persona', () => {
141
142
  it('queries ghost memories with natural language', async () => {
142
143
  await waitForIndex();
143
144
 
144
- // Use ownerAuth to avoid trust filter — query is already filtered to ghost content_type
145
- const res = parseResult(await handleQueryGhostMemory(
145
+ // Use ghostAuth — query is auto-scoped to ghost content_type via internal context
146
+ const res = parseResult(await handleQueryInternalMemory(
146
147
  { query: 'What are the accessor\'s outdoor interests?', limit: 5, min_relevance: 0.3 },
147
- ownerId, ownerAuth,
148
+ ownerId, ghostAuth,
148
149
  ));
149
150
 
150
151
  expect(res.memories).toBeDefined();
@@ -160,10 +161,10 @@ describe('E2E: Ghost/Persona', () => {
160
161
  // This creates an impossible filter: content_type='ghost' AND content_type!='ghost'.
161
162
  // Fix: core should skip ghost exclusion when types filter explicitly includes 'ghost'.
162
163
  // This test WILL FAIL until the core bug is fixed.
163
- it('search_ghost_memory_by byTime returns ghost results', async () => {
164
- const res = parseResult(await handleSearchGhostMemoryBy(
164
+ it('search_internal_memory_by byTime returns ghost results', async () => {
165
+ const res = parseResult(await handleSearchInternalMemoryBy(
165
166
  { mode: 'byTime', limit: 5 },
166
- ownerId, ownerAuth,
167
+ ownerId, ghostAuth,
167
168
  ));
168
169
 
169
170
  expect(res.memories).toBeDefined();