@prmichaelsen/remember-mcp 3.15.7 → 3.16.2

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 (49) hide show
  1. package/.github/workflows/publish.yml +55 -0
  2. package/CHANGELOG.md +20 -0
  3. package/agent/design/local.unified-internal-memory-tools.md +325 -0
  4. package/agent/milestones/milestone-20-unified-internal-memory-tools.md +58 -0
  5. package/agent/progress.yaml +115 -1
  6. package/agent/tasks/milestone-20-unified-internal-memory-tools/task-212-add-internal-context-type.md +54 -0
  7. package/agent/tasks/milestone-20-unified-internal-memory-tools/task-213-update-server-factory-internal-context.md +117 -0
  8. package/agent/tasks/milestone-20-unified-internal-memory-tools/task-214-create-tag-builder-utility.md +50 -0
  9. package/agent/tasks/milestone-20-unified-internal-memory-tools/task-215-create-unified-internal-memory-tools.md +65 -0
  10. package/agent/tasks/milestone-20-unified-internal-memory-tools/task-216-update-default-search-filters.md +46 -0
  11. package/agent/tasks/milestone-20-unified-internal-memory-tools/task-217-delete-standalone-ghost-tools.md +46 -0
  12. package/agent/tasks/milestone-20-unified-internal-memory-tools/task-218-add-tests-unified-internal-tools.md +66 -0
  13. package/dist/e2e-helpers.d.ts +1 -1
  14. package/dist/server-factory.d.ts +17 -41
  15. package/dist/server-factory.js +420 -149
  16. package/dist/server.js +202 -20
  17. package/dist/tools/{create-ghost-memory.d.ts → create-internal-memory.d.ts} +7 -9
  18. package/dist/tools/internal-tools.spec.d.ts +2 -0
  19. package/dist/tools/{query-ghost-memory.d.ts → query-internal-memory.d.ts} +6 -6
  20. package/dist/tools/{search-ghost-memory-by.d.ts → search-internal-memory-by.d.ts} +6 -6
  21. package/dist/tools/{search-ghost-memory.d.ts → search-internal-memory.d.ts} +6 -6
  22. package/dist/tools/{update-ghost-memory.d.ts → update-internal-memory.d.ts} +6 -6
  23. package/dist/types/auth.d.ts +22 -8
  24. package/dist/utils/internal-tags.d.ts +14 -0
  25. package/dist/utils/internal-tags.spec.d.ts +2 -0
  26. package/package.json +2 -3
  27. package/src/e2e-helpers.ts +4 -2
  28. package/src/ghost-persona.e2e.ts +18 -17
  29. package/src/server-factory.ts +117 -55
  30. package/src/tools/create-internal-memory.ts +105 -0
  31. package/src/tools/find-similar.ts +2 -2
  32. package/src/tools/internal-tools.spec.ts +312 -0
  33. package/src/tools/query-internal-memory.ts +73 -0
  34. package/src/tools/query-memory.ts +15 -12
  35. package/src/tools/search-by.spec.ts +6 -2
  36. package/src/tools/search-by.ts +6 -6
  37. package/src/tools/{search-ghost-memory-by.ts → search-internal-memory-by.ts} +34 -27
  38. package/src/tools/search-internal-memory.ts +87 -0
  39. package/src/tools/search-memory.ts +15 -12
  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.ts +0 -73
@@ -0,0 +1,117 @@
1
+ # Task 213: Update Server Factory — Replace ghostMode with InternalContext
2
+
3
+ **Milestone**: M20 — Unified Internal Memory Tools
4
+ **Status**: Not Started
5
+ **Estimated Hours**: 3-5
6
+ **Dependencies**: task-212
7
+
8
+ ---
9
+
10
+ ## Objective
11
+
12
+ Rewire the server factory and auth context to replace the ad-hoc `ghostMode` pattern with the more stable and extensible `InternalContext` pattern. Ghost identity, type, and source information move into `InternalContext`. Trust and cross-user access context are folded into `InternalContext` as well, eliminating the separate `ghostMode` field.
13
+
14
+ ## Context
15
+
16
+ Currently `ghostMode` on `AuthContext` bundles ghost identity (`owner_user_id`, `accessor_user_id`) with resolved trust context (`accessor_trust_level`). This was fine for user-only ghosts, but doesn't extend to space/group ghosts and creates a parallel path alongside the new `InternalContext`. Rather than maintaining both, we should absorb `ghostMode` into `InternalContext` and drop the old field.
17
+
18
+ ### Current ghostMode usage (7 files):
19
+
20
+ | File | Usage |
21
+ |------|-------|
22
+ | `server-factory.ts` | Creates `ghostMode` from `extras.ghost_owner`, resolves trust level |
23
+ | `types/auth.ts` | Defines `GhostModeContext` and `AuthContext.ghostMode` |
24
+ | `search-memory.ts` | `ghostMode.owner_user_id` for cross-user search, `ghostMode.accessor_trust_level` for trust filter |
25
+ | `query-memory.ts` | Same as search-memory |
26
+ | `search-by.ts` | Same pattern, passes ghost context to core services |
27
+ | `create-ghost-memory.ts` | `ghostMode.accessor_user_id` for tagging (will be deleted in task-217) |
28
+ | Tests | Mock ghostMode in test fixtures |
29
+
30
+ ## Design Reference
31
+
32
+ - [Unified Internal Memory Tools — Section 2: Server Context](../../design/local.unified-internal-memory-tools.md)
33
+
34
+ ## Steps
35
+
36
+ 1. **Expand `InternalContext`** in `src/types/auth.ts` to absorb ghostMode fields:
37
+ ```typescript
38
+ export interface InternalContext {
39
+ type: 'ghost' | 'agent';
40
+ ghost_type?: 'user' | 'space' | 'group';
41
+ ghost_space?: string;
42
+ ghost_group?: string;
43
+ // Absorbed from GhostModeContext:
44
+ owner_user_id?: string; // ghost owner (user ghosts)
45
+ accessor_user_id: string; // who is conversing
46
+ accessor_trust_level?: number; // resolved trust (ghost only)
47
+ }
48
+ ```
49
+
50
+ 2. **Remove `ghostMode`** from `AuthContext`:
51
+ ```typescript
52
+ export interface AuthContext {
53
+ accessToken: string | null;
54
+ credentials: UserCredentials | null;
55
+ internalContext?: InternalContext;
56
+ // ghostMode is gone
57
+ }
58
+ ```
59
+
60
+ 3. **Remove `GhostModeContext`** interface (or deprecate if referenced externally)
61
+
62
+ 4. **Update `server-factory.ts`**:
63
+ - Replace `ghostMode` construction with `internalContext` construction
64
+ - Move trust resolution into `internalContext` building:
65
+ ```typescript
66
+ const internalType = extras?.internal_type as string | undefined;
67
+ let internalContext: InternalContext | undefined;
68
+
69
+ if (internalType) {
70
+ const ghostOwner = extras?.ghost_owner as string | undefined;
71
+ let accessorTrustLevel: number | undefined;
72
+
73
+ if (internalType === 'ghost' && ghostOwner) {
74
+ const ghostConfig = await getGhostConfig(ghostOwner);
75
+ accessorTrustLevel = await resolveAccessorTrustLevel(ghostConfig, ghostOwner, userId);
76
+ }
77
+
78
+ internalContext = {
79
+ type: internalType as 'ghost' | 'agent',
80
+ ghost_type: extras?.ghost_type as 'user' | 'space' | 'group' | undefined,
81
+ ghost_space: extras?.ghost_space as string | undefined,
82
+ ghost_group: extras?.ghost_group as string | undefined,
83
+ owner_user_id: ghostOwner,
84
+ accessor_user_id: userId,
85
+ accessor_trust_level: accessorTrustLevel,
86
+ };
87
+ }
88
+
89
+ const authContext: AuthContext = { accessToken, credentials, internalContext };
90
+ ```
91
+
92
+ 5. **Update `search-memory.ts`** — replace `ghostMode` references:
93
+ - `ghostMode?.owner_user_id` → `internalContext?.owner_user_id`
94
+ - `ghostMode?.accessor_trust_level` → `internalContext?.accessor_trust_level`
95
+ - Cross-user search: `searchUserId = internalContext?.owner_user_id ?? userId`
96
+ - Trust filter: `buildTrustFilter(collection, internalContext.accessor_trust_level)`
97
+
98
+ 6. **Update `query-memory.ts`** — same pattern as search-memory
99
+
100
+ 7. **Update `search-by.ts`** — same pattern, update ghost context passed to core services
101
+
102
+ 8. **Update `e2e-helpers.ts`** — replace `ghostMode` test fixture with `internalContext`
103
+
104
+ 9. **Update test files** — `search-by.spec.ts`, `ghost-tools.spec.ts` mock structures
105
+
106
+ ## Verification
107
+
108
+ - [ ] `GhostModeContext` removed (or deprecated)
109
+ - [ ] `AuthContext.ghostMode` removed
110
+ - [ ] `AuthContext.internalContext` contains all former ghostMode fields
111
+ - [ ] `server-factory.ts` builds `internalContext` from headers, resolves trust level
112
+ - [ ] `search-memory.ts` uses `internalContext` for cross-user search and trust filtering
113
+ - [ ] `query-memory.ts` uses `internalContext` for cross-user search and trust filtering
114
+ - [ ] `search-by.ts` uses `internalContext` for ghost context
115
+ - [ ] No remaining references to `ghostMode` in src/ (except ghost tools being deleted in task-217)
116
+ - [ ] TypeScript compiles without errors
117
+ - [ ] All existing tests updated and passing
@@ -0,0 +1,50 @@
1
+ # Task 214: Create Tag Builder Utility
2
+
3
+ **Milestone**: M20 — Unified Internal Memory Tools
4
+ **Status**: Not Started
5
+ **Estimated Hours**: 2-3
6
+ **Dependencies**: task-212
7
+
8
+ ---
9
+
10
+ ## Objective
11
+
12
+ Create a `buildInternalTags` utility that produces the correct tags for ghost/agent memories based on `AuthContext`, implementing the ghost source isolation tag scheme.
13
+
14
+ ## Context
15
+
16
+ Ghost source isolation requires different tag sets for different ghost types:
17
+ - User ghost (alice): `['ghost', 'ghost_type:user', 'ghost_owner:user:alice']`
18
+ - Space ghost (music-lovers): `['ghost', 'ghost_type:space', 'ghost_owner:space:music-lovers']`
19
+ - Group ghost (band-mates): `['ghost', 'ghost_type:group', 'ghost_owner:group:band-mates']`
20
+ - Agent: `['agent']`
21
+
22
+ ## Design Reference
23
+
24
+ - [Unified Internal Memory Tools — Section 3: Tag Builder](../design/local.unified-internal-memory-tools.md)
25
+
26
+ ## Steps
27
+
28
+ 1. Create `src/utils/internal-tags.ts` with `buildInternalTags(authContext: AuthContext): string[]`
29
+
30
+ 2. Implement the tag builder per the design spec:
31
+ - If `internalContext.type === 'agent'`, return `['agent']`
32
+ - If `internalContext.type === 'ghost'`, return `['ghost']` + type-specific tags
33
+ - If no `internalContext`, return `[]`
34
+
35
+ 3. For ghost type tags (all fields now on `internalContext`):
36
+ - `'user'` → `ghost_type:user` + `ghost_owner:user:{internalContext.owner_user_id}`
37
+ - `'space'` → `ghost_type:space` + `ghost_owner:space:{internalContext.ghost_space}`
38
+ - `'group'` → `ghost_type:group` + `ghost_owner:group:{internalContext.ghost_group}`
39
+
40
+ 4. Export from utils module
41
+
42
+ ## Verification
43
+
44
+ - [ ] `buildInternalTags` returns correct tags for each ghost type
45
+ - [ ] `buildInternalTags` returns `['agent']` for agent context
46
+ - [ ] `buildInternalTags` returns `[]` for no internal context
47
+ - [ ] User ghost uses `internalContext.owner_user_id` for owner tag
48
+ - [ ] Space ghost uses `internalContext.ghost_space` for owner tag
49
+ - [ ] Group ghost uses `internalContext.ghost_group` for owner tag
50
+ - [ ] Unit tests cover all tag permutations
@@ -0,0 +1,65 @@
1
+ # Task 215: Create Unified Internal Memory Tools
2
+
3
+ **Milestone**: M20 — Unified Internal Memory Tools
4
+ **Status**: Not Started
5
+ **Estimated Hours**: 6-8
6
+ **Dependencies**: task-212, task-213, task-214
7
+
8
+ ---
9
+
10
+ ## Objective
11
+
12
+ Create 5 unified `remember_*_internal_memory` tools that replace the 5 standalone ghost tools. Behavior is driven by `AuthContext.internalContext` (populated from HTTP headers).
13
+
14
+ ## Context
15
+
16
+ The existing ghost tools (`create-ghost-memory.ts`, `update-ghost-memory.ts`, `search-ghost-memory.ts`, `query-ghost-memory.ts`, `search-ghost-memory-by.ts`) hardcode ghost-specific behavior. The unified tools generalize this pattern so both ghost and agent memories use the same tool implementations, with behavior determined by the `InternalContext`.
17
+
18
+ ## Design Reference
19
+
20
+ - [Unified Internal Memory Tools — Full Implementation section](../design/local.unified-internal-memory-tools.md)
21
+ - Existing ghost tools in `src/tools/` for reference patterns
22
+
23
+ ## Steps
24
+
25
+ 1. Create `src/tools/create-internal-memory.ts`:
26
+ - Accept same params as `create-ghost-memory` but without ghost-specific hardcoding
27
+ - Read `internalContext` from `authContext` to determine `content_type` (`'ghost'` or `'agent'`)
28
+ - Use `buildInternalTags(authContext)` for auto-tags
29
+ - Error if no `internalContext` present: "Internal context required. X-Internal-Type header must be set."
30
+ - Write to accessor's collection (same as current ghost behavior)
31
+
32
+ 2. Create `src/tools/update-internal-memory.ts`:
33
+ - Same pattern: derive content_type and tags from `internalContext`
34
+ - Error without internal context
35
+
36
+ 3. Create `src/tools/search-internal-memory.ts`:
37
+ - Auto-scope search to current ghost source via `buildInternalTags` scope tags
38
+ - Filter by `content_type` matching `internalContext.type`
39
+ - No override allowed for scope tags
40
+
41
+ 4. Create `src/tools/query-internal-memory.ts`:
42
+ - Same auto-scoping as search
43
+ - RAG query within scoped ghost/agent memories
44
+
45
+ 5. Create `src/tools/search-internal-memory-by.ts`:
46
+ - Same auto-scoping
47
+ - Support all modes: byTime, byRating, byProperty, byBroad, byRandom, byDensity, byMood, bySignificance
48
+ - Copy mode definitions from existing `search-ghost-memory-by.ts`
49
+
50
+ 6. Register all 5 tools in `src/server-factory.ts` tool registration
51
+
52
+ 7. Use descriptive tool descriptions that explain the unified behavior:
53
+ - "Creates an internal memory (ghost observation or agent note) based on the current session context."
54
+ - Make clear these tools are for platform-internal use only
55
+
56
+ ## Verification
57
+
58
+ - [ ] All 5 tools created and registered
59
+ - [ ] Tools error when `internalContext` is missing
60
+ - [ ] Ghost mode: creates memories with `content_type: 'ghost'` and source-specific tags
61
+ - [ ] Agent mode: creates memories with `content_type: 'agent'` and `agent` tag
62
+ - [ ] Search tools auto-scope to current ghost source
63
+ - [ ] Search tools filter by correct content_type
64
+ - [ ] All search modes (byTime, byRating, etc.) work for internal memories
65
+ - [ ] TypeScript compiles without errors
@@ -0,0 +1,46 @@
1
+ # Task 216: Update Default Search Filters for Agent Exclusion
2
+
3
+ **Milestone**: M20 — Unified Internal Memory Tools
4
+ **Status**: Not Started
5
+ **Estimated Hours**: 2-3
6
+ **Dependencies**: task-212
7
+
8
+ ---
9
+
10
+ ## Objective
11
+
12
+ Update default search/query tools (`remember_search_memory`, `remember_query_memory`, `remember_search_by`) to exclude `agent` content type from results, matching the existing `ghost` exclusion pattern.
13
+
14
+ ## Context
15
+
16
+ Default user searches already exclude `content_type: 'ghost'` so ghost memories don't appear in normal memory browsing. The same pattern must be applied to `content_type: 'agent'` so agent observations don't pollute user search results.
17
+
18
+ ## Design Reference
19
+
20
+ - [Unified Internal Memory Tools — Section 5: Content Type](../design/local.unified-internal-memory-tools.md)
21
+
22
+ ## Steps
23
+
24
+ 1. Locate the existing ghost content_type exclusion filter in search tools (likely in `src/tools/search-memory.ts`, `query-memory.ts`, `search-by.ts`)
25
+
26
+ 2. Add `'agent'` to the exclusion list alongside `'ghost'`:
27
+ ```typescript
28
+ // Before: filter out ghost
29
+ types: excludeTypes(['ghost', 'comment', ...])
30
+ // After: filter out ghost AND agent
31
+ types: excludeTypes(['ghost', 'agent', 'comment', ...])
32
+ ```
33
+
34
+ 3. Also check `remember_search_space` and `remember_query_space` — agent memories should not appear in space searches either
35
+
36
+ 4. Verify that the internal memory tools (task-215) do NOT apply this exclusion (they explicitly filter FOR their content type)
37
+
38
+ ## Verification
39
+
40
+ - [ ] `remember_search_memory` excludes `agent` content type
41
+ - [ ] `remember_query_memory` excludes `agent` content type
42
+ - [ ] `remember_search_by` excludes `agent` content type
43
+ - [ ] Space search tools exclude `agent` content type
44
+ - [ ] Internal memory tools still return `agent`/`ghost` results correctly
45
+ - [ ] Existing ghost exclusion unchanged
46
+ - [ ] Existing tests updated/pass
@@ -0,0 +1,46 @@
1
+ # Task 217: Delete Standalone Ghost Tools
2
+
3
+ **Milestone**: M20 — Unified Internal Memory Tools
4
+ **Status**: Not Started
5
+ **Estimated Hours**: 1-2
6
+ **Dependencies**: task-215
7
+
8
+ ---
9
+
10
+ ## Objective
11
+
12
+ Delete the 5 standalone ghost memory tools, their test files, and all references in the server registration. Clean break — no aliases or backwards compatibility shims.
13
+
14
+ ## Context
15
+
16
+ The unified internal memory tools (task-215) replace these entirely. Per design decision, existing ghost memories are acceptable to lose (no backfill). The ghost-config tool is NOT deleted — it's a separate concern.
17
+
18
+ ## Steps
19
+
20
+ 1. Delete tool files:
21
+ - `src/tools/create-ghost-memory.ts`
22
+ - `src/tools/update-ghost-memory.ts`
23
+ - `src/tools/search-ghost-memory.ts`
24
+ - `src/tools/query-ghost-memory.ts`
25
+ - `src/tools/search-ghost-memory-by.ts`
26
+
27
+ 2. Delete test files:
28
+ - `src/tools/ghost-tools.spec.ts`
29
+
30
+ 3. Remove ghost tool registrations from `src/server-factory.ts`:
31
+ - Remove imports
32
+ - Remove tool handler registrations
33
+
34
+ 4. Keep `src/tools/ghost-config.ts` and `src/tools/ghost-config.spec.ts` (separate concern)
35
+
36
+ 5. Update `agent/design/complete-tool-set.md` to remove ghost tools and add unified internal tools
37
+
38
+ ## Verification
39
+
40
+ - [ ] 5 ghost tool files deleted
41
+ - [ ] Ghost tool test file deleted
42
+ - [ ] Ghost tool registrations removed from server-factory
43
+ - [ ] `ghost-config.ts` preserved
44
+ - [ ] No remaining imports of deleted ghost tool files
45
+ - [ ] TypeScript compiles without errors
46
+ - [ ] No dead code referencing deleted tools
@@ -0,0 +1,66 @@
1
+ # Task 218: Add Unit and Integration Tests
2
+
3
+ **Milestone**: M20 — Unified Internal Memory Tools
4
+ **Status**: Not Started
5
+ **Estimated Hours**: 4-6
6
+ **Dependencies**: task-214, task-215, task-216, task-217
7
+
8
+ ---
9
+
10
+ ## Objective
11
+
12
+ Add comprehensive unit and integration tests for the unified internal memory tool suite, covering tag building, search auto-scoping, context validation, and ghost source isolation.
13
+
14
+ ## Context
15
+
16
+ Tests must verify the core guarantees of the unified tool architecture: correct tagging per ghost/agent type, auto-scoping that prevents cross-ghost leakage, error behavior without internal context, and agent exclusion from default searches.
17
+
18
+ ## Design Reference
19
+
20
+ - [Unified Internal Memory Tools — Testing Strategy](../design/local.unified-internal-memory-tools.md)
21
+
22
+ ## Steps
23
+
24
+ ### Unit Tests
25
+
26
+ 1. `src/utils/internal-tags.spec.ts` — Tag builder:
27
+ - Returns `['agent']` for agent context
28
+ - Returns correct tags for user ghost (ghost, ghost_type:user, ghost_owner:user:{id})
29
+ - Returns correct tags for space ghost (ghost, ghost_type:space, ghost_owner:space:{id})
30
+ - Returns correct tags for group ghost (ghost, ghost_type:group, ghost_owner:group:{id})
31
+ - Returns `[]` for no internal context
32
+
33
+ 2. `src/tools/internal-tools.spec.ts` — Unified tools:
34
+ - Create tool errors without internalContext
35
+ - Create tool sets content_type from internalContext.type
36
+ - Create tool applies buildInternalTags for auto-tags
37
+ - Search tool auto-scopes to current ghost source tags
38
+ - Search tool filters by correct content_type
39
+ - Update tool only updates matching content_type memories
40
+ - Query tool auto-scopes like search
41
+
42
+ 3. `src/tools/search-by.spec.ts` — Updated default filter tests:
43
+ - Verify `agent` content type excluded from default searches
44
+ - Verify existing `ghost` exclusion unchanged
45
+
46
+ ### Integration Tests (e2e)
47
+
48
+ 4. Ghost source isolation test:
49
+ - Create memory as alice's ghost → verify ghost_owner:user:alice tag
50
+ - Create memory as carol's ghost → verify ghost_owner:user:carol tag
51
+ - Search as alice's ghost → only sees alice's ghost memories
52
+ - Search as carol's ghost → only sees carol's ghost memories
53
+
54
+ 5. Agent isolation test:
55
+ - Create agent memory → verify content_type: 'agent' and agent tag
56
+ - Default search → does not return agent memories
57
+ - Internal search with agent context → returns agent memories
58
+
59
+ ## Verification
60
+
61
+ - [ ] Tag builder unit tests pass for all permutations
62
+ - [ ] Tool error behavior tested (no context → error)
63
+ - [ ] Ghost source isolation verified (no cross-ghost leakage)
64
+ - [ ] Agent exclusion from default search verified
65
+ - [ ] All existing tests still pass
66
+ - [ ] Test coverage adequate for new code
@@ -9,7 +9,7 @@ import type { AuthContext } from './types/auth.js';
9
9
  export declare function e2eUserId(prefix?: string): string;
10
10
  /** Simple AuthContext with no ghost mode */
11
11
  export declare function e2eAuthContext(): AuthContext;
12
- /** AuthContext with ghost mode for cross-user tests */
12
+ /** AuthContext with ghost internal context for cross-user tests */
13
13
  export declare function e2eGhostAuthContext(ownerUserId: string, accessorUserId: string, trustLevel?: number): AuthContext;
14
14
  /** Initialize databases (idempotent — safe to call many times) */
15
15
  export declare function e2eInit(): Promise<void>;
@@ -7,51 +7,27 @@ export interface ServerOptions {
7
7
  name?: string;
8
8
  version?: string;
9
9
  /**
10
- * Ghost mode configuration. When set, the server operates in ghost mode:
11
- * - Search/query tools search the ghost owner's collection
12
- * - Trust filtering is applied based on the accessor's trust level
13
- * - Trust level is resolved server-side from GhostConfig (Firestore)
10
+ * Internal context for ghost/agent sessions. When set, the server provides
11
+ * unified internal memory tools with behavior driven by the context type.
14
12
  *
15
- * agentbase.me sets this when creating a ghost conversation server.
13
+ * Populated from platform HTTP headers via mcp-auth extras:
14
+ * X-Internal-Type → type ('ghost' | 'agent')
15
+ * X-Ghost-Owner → owner_user_id
16
+ * X-Ghost-Type → ghost_type ('user' | 'space' | 'group')
17
+ * X-Ghost-Space → ghost_space
18
+ * X-Ghost-Group → ghost_group
19
+ *
20
+ * Trust level is resolved server-side from GhostConfig (Firestore).
16
21
  * The LLM never has access to set or override these values.
17
22
  */
18
- ghostMode?: {
19
- /** Ghost owner's user ID (whose memories to search) */
20
- owner_user_id: string;
21
- /** Accessor's user ID (who is chatting with the ghost) */
23
+ internalContext?: {
24
+ type: 'ghost' | 'agent';
25
+ ghost_type?: 'user' | 'space' | 'group';
26
+ ghost_space?: string;
27
+ ghost_group?: string;
28
+ owner_user_id?: string;
22
29
  accessor_user_id: string;
23
30
  };
24
31
  }
25
- /**
26
- * Create a server instance for a specific user/tenant
27
- *
28
- * This factory function is compatible with mcp-auth wrapping pattern.
29
- * It creates isolated server instances with no shared state.
30
- *
31
- * Note: Databases (Weaviate + Firestore) are initialized once globally on first call.
32
- *
33
- * @param accessToken - User's access token (reserved for future external APIs)
34
- * @param userId - User identifier for scoping operations
35
- * @param options - Optional server configuration
36
- * @returns Configured MCP Server instance (not connected to transport)
37
- *
38
- * @example
39
- * ```typescript
40
- * // Direct usage
41
- * const server = createServer('token', 'user123');
42
- * const transport = new StdioServerTransport();
43
- * await server.connect(transport);
44
- *
45
- * // With mcp-auth
46
- * import { wrapServer } from '@prmichaelsen/mcp-auth';
47
- * const wrapped = wrapServer({
48
- * serverFactory: createServer,
49
- * authProvider: new JWTAuthProvider({ ... }),
50
- * tokenResolver: new APITokenResolver({ ... }),
51
- * resourceType: 'remember',
52
- * transport: { type: 'sse', port: 3000 }
53
- * });
54
- * ```
55
- */
56
- export declare function createServer(accessToken: string, userId: string, options?: ServerOptions): Promise<Server>;
32
+ export declare function createServer(accessToken: string, userId: string, options?: ServerOptions | Record<string, string | string[] | undefined>): Promise<Server>;
57
33
  //# sourceMappingURL=server-factory.d.ts.map