@indexnetwork/protocol 14.3.2-rc.477.1 → 17.0.0-rc.479.1
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.
- package/CHANGELOG.md +141 -0
- package/IMPLEMENTATION.md +50 -52
- package/STABILITY.md +3 -3
- package/dist/chat/chat.agent.js +2 -3
- package/dist/chat/chat.graph.d.ts +41 -1
- package/dist/chat/chat.graph.js +108 -127
- package/dist/chat/negotiator.persona.d.ts +1 -1
- package/dist/chat/negotiator.persona.js +1 -4
- package/dist/chat/negotiator.prompt.js +1 -2
- package/dist/chat/onboarding.persona.js +0 -1
- package/dist/chat/reporter.persona.js +0 -1
- package/dist/chat/signal.persona.js +0 -1
- package/dist/contacts/application/contact.tools.d.ts +6 -9
- package/dist/contacts/application/contact.tools.js +11 -92
- package/dist/contacts/application/index.d.ts +2 -14
- package/dist/contacts/application/index.js +2 -13
- package/dist/contacts/domain/contact.types.d.ts +0 -23
- package/dist/contacts/domain/index.d.ts +2 -6
- package/dist/contacts/index.d.ts +1 -1
- package/dist/contacts/index.js +1 -1
- package/dist/contacts/ports/contact.repository.port.d.ts +5 -12
- package/dist/contacts/ports/contact.repository.port.js +4 -6
- package/dist/contacts/ports/contact.tools.port.d.ts +1 -3
- package/dist/contacts/ports/contact.tools.port.js +1 -2
- package/dist/contacts/ports/index.d.ts +1 -1
- package/dist/contacts/ports/index.js +1 -1
- package/dist/discovery/hyde.frame.d.ts +4 -4
- package/dist/discovery/hyde.graph.d.ts +71 -12
- package/dist/discovery/hyde.graph.js +337 -335
- package/dist/discovery/lens.inferrer.d.ts +6 -6
- package/dist/enrichment/enrichment.graph.d.ts +127 -9
- package/dist/enrichment/enrichment.graph.js +633 -655
- package/dist/enrichment/enrichment.state.d.ts +1 -1
- package/dist/enrichment/enrichment.tools.context-read.d.ts +10 -0
- package/dist/enrichment/enrichment.tools.context-read.js +353 -0
- package/dist/enrichment/enrichment.tools.context-write.d.ts +9 -0
- package/dist/enrichment/enrichment.tools.context-write.js +417 -0
- package/dist/enrichment/enrichment.tools.d.ts +11 -1
- package/dist/enrichment/enrichment.tools.helpers.d.ts +139 -0
- package/dist/enrichment/enrichment.tools.helpers.js +234 -0
- package/dist/enrichment/enrichment.tools.js +16 -975
- package/dist/index.d.ts +27 -50
- package/dist/index.js +17 -28
- package/dist/intents/application/intent.graph.d.ts +71 -67
- package/dist/intents/application/intent.graph.execute.d.ts +59 -0
- package/dist/intents/application/intent.graph.execute.js +301 -0
- package/dist/intents/application/intent.graph.infer.d.ts +44 -0
- package/dist/intents/application/intent.graph.infer.js +97 -0
- package/dist/intents/application/intent.graph.js +96 -888
- package/dist/intents/application/intent.graph.reconcile.d.ts +71 -0
- package/dist/intents/application/intent.graph.reconcile.js +274 -0
- package/dist/intents/application/intent.graph.shared.d.ts +70 -0
- package/dist/intents/application/intent.graph.shared.js +153 -0
- package/dist/intents/domain/intent.state.d.ts +1 -1
- package/dist/maintenance/maintenance.graph.d.ts +66 -3
- package/dist/maintenance/maintenance.graph.js +155 -156
- package/dist/mcp/mcp.authorization-policy.d.ts +24 -28
- package/dist/mcp/mcp.authorization-policy.js +14 -34
- package/dist/mcp/mcp.server.d.ts +3 -3
- package/dist/mcp/mcp.server.js +14 -20
- package/dist/negotiations/application/negotiation.candidates.d.ts +83 -0
- package/dist/negotiations/application/negotiation.candidates.js +162 -0
- package/dist/negotiations/application/negotiation.graph.d.ts +91 -157
- package/dist/negotiations/application/negotiation.graph.finalize.d.ts +5 -0
- package/dist/negotiations/application/negotiation.graph.finalize.js +280 -0
- package/dist/negotiations/application/negotiation.graph.init.d.ts +54 -0
- package/dist/negotiations/application/negotiation.graph.init.js +227 -0
- package/dist/negotiations/application/negotiation.graph.js +69 -1388
- package/dist/negotiations/application/negotiation.graph.screen.d.ts +23 -0
- package/dist/negotiations/application/negotiation.graph.screen.js +108 -0
- package/dist/negotiations/application/negotiation.graph.shared.d.ts +75 -0
- package/dist/negotiations/application/negotiation.graph.shared.js +125 -0
- package/dist/negotiations/application/negotiation.graph.turn.d.ts +105 -0
- package/dist/negotiations/application/negotiation.graph.turn.js +484 -0
- package/dist/negotiations/domain/negotiation.state.d.ts +1 -1
- package/dist/negotiations/domain/negotiation.state.js +0 -1
- package/dist/networks/application/indexer.graph.d.ts +165 -7
- package/dist/networks/application/indexer.graph.js +339 -388
- package/dist/networks/application/indexer.state.d.ts +1 -1
- package/dist/networks/application/membership.graph.d.ts +83 -5
- package/dist/networks/application/membership.graph.js +177 -207
- package/dist/networks/application/network.graph.d.ts +148 -5
- package/dist/networks/application/network.graph.js +249 -278
- package/dist/networks/domain/membership.state.d.ts +1 -1
- package/dist/networks/domain/network.state.d.ts +1 -1
- package/dist/opportunities/application/delivery-card.cache.d.ts +1 -1
- package/dist/opportunities/application/delivery-card.cache.js +2 -2
- package/dist/opportunities/application/index.d.ts +2 -2
- package/dist/opportunities/application/index.js +2 -2
- package/dist/opportunities/application/opportunity.evaluator.js +1 -1
- package/dist/opportunities/application/opportunity.graph.d.ts +686 -473
- package/dist/opportunities/application/opportunity.graph.discovery-strategies.d.ts +109 -0
- package/dist/opportunities/application/opportunity.graph.discovery-strategies.js +451 -0
- package/dist/opportunities/application/opportunity.graph.discovery.d.ts +69 -0
- package/dist/opportunities/application/opportunity.graph.discovery.js +397 -0
- package/dist/opportunities/application/opportunity.graph.evaluation.d.ts +82 -0
- package/dist/opportunities/application/opportunity.graph.evaluation.js +608 -0
- package/dist/opportunities/application/opportunity.graph.js +120 -3690
- package/dist/opportunities/application/opportunity.graph.modes.d.ts +538 -0
- package/dist/opportunities/application/opportunity.graph.modes.js +538 -0
- package/dist/opportunities/application/opportunity.graph.negotiate.d.ts +109 -0
- package/dist/opportunities/application/opportunity.graph.negotiate.js +392 -0
- package/dist/opportunities/application/opportunity.graph.persist-node.d.ts +93 -0
- package/dist/opportunities/application/opportunity.graph.persist-node.js +765 -0
- package/dist/opportunities/application/opportunity.graph.prep.d.ts +150 -0
- package/dist/opportunities/application/opportunity.graph.prep.js +381 -0
- package/dist/opportunities/application/opportunity.graph.shared.d.ts +173 -0
- package/dist/opportunities/application/opportunity.graph.shared.js +199 -0
- package/dist/opportunities/application/opportunity.presentation.d.ts +399 -0
- package/dist/opportunities/application/{opportunity.presenter.js → opportunity.presentation.js} +735 -9
- package/dist/opportunities/application/opportunity.tools.cards.d.ts +152 -0
- package/dist/opportunities/application/opportunity.tools.cards.js +235 -0
- package/dist/opportunities/application/opportunity.tools.d.ts +8 -114
- package/dist/opportunities/application/opportunity.tools.js +28 -711
- package/dist/opportunities/application/opportunity.tools.list.d.ts +10 -0
- package/dist/opportunities/application/opportunity.tools.list.js +493 -0
- package/dist/opportunities/domain/index.d.ts +3 -3
- package/dist/opportunities/domain/index.js +3 -3
- package/dist/opportunities/domain/opportunity.state.d.ts +19 -19
- package/dist/opportunities/index.d.ts +6 -6
- package/dist/opportunities/index.js +4 -4
- package/dist/opportunities/ports/opportunity.tools.port.d.ts +1 -1
- package/dist/opportunities/radar/radar.graph.d.ts +57 -13
- package/dist/opportunities/radar/radar.graph.js +470 -471
- package/dist/premises/premise.graph.d.ts +88 -20
- package/dist/premises/premise.graph.js +207 -218
- package/dist/questions/domain/question.schema.d.ts +40 -40
- package/dist/shared/agent/tool.factory.js +0 -8
- package/dist/shared/agent/tool.helpers.d.ts +21 -45
- package/dist/shared/agent/tool.helpers.js +1 -2
- package/dist/shared/agent/tool.registry.d.ts +4 -3
- package/dist/shared/agent/tool.registry.js +2 -4
- package/dist/shared/agent/tool.runtime.js +0 -2
- package/dist/shared/agent/utility.tools.js +9 -13
- package/dist/shared/interfaces/database.capabilities.d.ts +100 -0
- package/dist/shared/interfaces/database.capabilities.js +7 -0
- package/dist/shared/interfaces/database.entities.d.ts +533 -0
- package/dist/shared/interfaces/database.entities.js +10 -0
- package/dist/shared/interfaces/database.identity-queries.d.ts +294 -0
- package/dist/shared/interfaces/database.identity-queries.js +4 -0
- package/dist/shared/interfaces/database.interface.d.ts +15 -2277
- package/dist/shared/interfaces/database.interface.js +8 -0
- package/dist/shared/interfaces/database.member-queries.d.ts +221 -0
- package/dist/shared/interfaces/database.member-queries.js +4 -0
- package/dist/shared/interfaces/database.negotiation.d.ts +305 -0
- package/dist/shared/interfaces/database.negotiation.js +26 -0
- package/dist/shared/interfaces/database.network-queries.d.ts +277 -0
- package/dist/shared/interfaces/database.network-queries.js +4 -0
- package/dist/shared/interfaces/database.opportunity-queries.d.ts +285 -0
- package/dist/shared/interfaces/database.opportunity-queries.js +4 -0
- package/dist/shared/interfaces/database.port.d.ts +322 -0
- package/dist/shared/interfaces/database.port.js +29 -0
- package/dist/shared/schemas/discovery-question.schema.d.ts +14 -14
- package/dist/shared/schemas/negotiation-digest.schema.d.ts +2 -2
- package/package.json +2 -15
- package/dist/contacts/application/contact.inviter.d.ts +0 -49
- package/dist/contacts/application/contact.inviter.js +0 -64
- package/dist/integrations/application/index.d.ts +0 -14
- package/dist/integrations/application/index.js +0 -14
- package/dist/integrations/application/integration.tools.d.ts +0 -27
- package/dist/integrations/application/integration.tools.js +0 -98
- package/dist/integrations/domain/index.d.ts +0 -16
- package/dist/integrations/domain/index.js +0 -1
- package/dist/integrations/domain/integration.types.d.ts +0 -51
- package/dist/integrations/domain/integration.types.js +0 -9
- package/dist/integrations/index.d.ts +0 -10
- package/dist/integrations/index.js +0 -8
- package/dist/integrations/ports/index.d.ts +0 -25
- package/dist/integrations/ports/index.js +0 -23
- package/dist/integrations/ports/integration.adapter.port.d.ts +0 -62
- package/dist/integrations/ports/integration.adapter.port.js +0 -15
- package/dist/integrations/ports/integration.importer.port.d.ts +0 -31
- package/dist/integrations/ports/integration.importer.port.js +0 -15
- package/dist/integrations/ports/integration.tools.port.d.ts +0 -25
- package/dist/integrations/ports/integration.tools.port.js +0 -18
- package/dist/opportunities/application/opportunity.card-presentation.d.ts +0 -44
- package/dist/opportunities/application/opportunity.card-presentation.js +0 -93
- package/dist/opportunities/application/opportunity.presenter.d.ts +0 -156
- package/dist/opportunities/domain/opportunity.presentation-cache.d.ts +0 -5
- package/dist/opportunities/domain/opportunity.presentation-cache.js +0 -11
- package/dist/opportunities/domain/opportunity.presentation.d.ts +0 -76
- package/dist/opportunities/domain/opportunity.presentation.js +0 -516
- package/dist/opportunities/domain/opportunity.safe-presentation.d.ts +0 -104
- package/dist/opportunities/domain/opportunity.safe-presentation.js +0 -102
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Database operations for profiles, intents, and their vector search.
|
|
3
|
+
*/
|
|
4
|
+
import type { UserIdentity } from '../schemas/identity.schema.js';
|
|
5
|
+
import type { ActiveIntent, ActiveNetworkMembershipPair, ArchiveResult, CreateIntentData, CreatedIntent, IntentRecord, NetworkMembership, OnboardingState, SimilarIntent, SimilarIntentSearchOptions, UpdateIntentData, UserRecord, UserSocial } from './database.entities.js';
|
|
6
|
+
/** Profile, intent-lifecycle and retrieval operations. */
|
|
7
|
+
export interface DatabaseIdentityQueries {
|
|
8
|
+
/**
|
|
9
|
+
* Retrieves a user profile by userId.
|
|
10
|
+
* @param userId - The unique identifier of the user
|
|
11
|
+
* @returns The user's profile or null if not found
|
|
12
|
+
*/
|
|
13
|
+
getProfile(userId: string): Promise<UserIdentity | null>;
|
|
14
|
+
/**
|
|
15
|
+
* Creates or updates a user profile.
|
|
16
|
+
* @param userId - The unique identifier of the user
|
|
17
|
+
* @param profile - The profile data to save
|
|
18
|
+
*/
|
|
19
|
+
saveProfile(userId: string, profile: UserIdentity): Promise<void>;
|
|
20
|
+
/**
|
|
21
|
+
* Retrieves basic user information (name, email, socials) by userId.
|
|
22
|
+
* @param userId - The unique identifier of the user
|
|
23
|
+
* @returns The user record or null if not found
|
|
24
|
+
*/
|
|
25
|
+
getUser(userId: string): Promise<UserRecord | null>;
|
|
26
|
+
/**
|
|
27
|
+
* Updates user account fields (name, location, socials).
|
|
28
|
+
* Merges socials with existing values (does not overwrite the whole object).
|
|
29
|
+
* Used by create_user_context tool to persist user-provided info before
|
|
30
|
+
* invoking the Profile Graph in generate mode.
|
|
31
|
+
*
|
|
32
|
+
* @param userId - The unique identifier of the user
|
|
33
|
+
* @param data - Partial user fields to update
|
|
34
|
+
* @returns The updated user record or null if not found
|
|
35
|
+
*/
|
|
36
|
+
updateUser(userId: string, data: {
|
|
37
|
+
name?: string;
|
|
38
|
+
intro?: string;
|
|
39
|
+
location?: string;
|
|
40
|
+
onboarding?: OnboardingState;
|
|
41
|
+
}): Promise<UserRecord | null>;
|
|
42
|
+
getUserSocials(userId: string): Promise<UserSocial[]>;
|
|
43
|
+
setUserSocials(userId: string, socials: {
|
|
44
|
+
label: string;
|
|
45
|
+
value: string;
|
|
46
|
+
}[]): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Soft-delete a ghost user and all their contact memberships.
|
|
49
|
+
* Used when enrichment determines the entity is not a real person.
|
|
50
|
+
* @param userId - The ghost user to soft-delete
|
|
51
|
+
* @returns true if the user was soft-deleted
|
|
52
|
+
*/
|
|
53
|
+
softDeleteGhost(userId: string): Promise<boolean>;
|
|
54
|
+
/**
|
|
55
|
+
* Find an existing user that matches the given social handles.
|
|
56
|
+
* Checks LinkedIn, GitHub, and Twitter/X handles (case-insensitive, exact match).
|
|
57
|
+
* Excludes the given userId and soft-deleted users.
|
|
58
|
+
* Prefers real users over ghosts; among ghosts, returns the oldest.
|
|
59
|
+
* @param userId - The ghost user being enriched (excluded from results)
|
|
60
|
+
* @param socials - Enriched social handles to match against
|
|
61
|
+
* @returns The matching user's id, or null if no match
|
|
62
|
+
*/
|
|
63
|
+
findDuplicateUser(userId: string, socials: UserSocial[]): Promise<{
|
|
64
|
+
id: string;
|
|
65
|
+
} | null>;
|
|
66
|
+
/**
|
|
67
|
+
* Merge a ghost user (source) into a target user.
|
|
68
|
+
* Re-points all data (intents, opportunities, memberships, etc.) from source to target,
|
|
69
|
+
* deletes ghost-only records (profile, sessions, etc.), and soft-deletes the source user.
|
|
70
|
+
* Runs in a single transaction.
|
|
71
|
+
* @param sourceId - The ghost user to merge away
|
|
72
|
+
* @param targetId - The user to merge into
|
|
73
|
+
*/
|
|
74
|
+
mergeGhostUser(sourceId: string, targetId: string): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Retrieves all active (non-archived) intents for a user.
|
|
77
|
+
* Used to populate the `activeIntents` field in the Intent Graph state
|
|
78
|
+
* before graph execution.
|
|
79
|
+
*
|
|
80
|
+
* @param userId - The unique identifier of the user
|
|
81
|
+
* @returns Array of active intents with minimal fields needed for reconciliation
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```typescript
|
|
85
|
+
* const activeIntents = await db.getActiveIntents(userId);
|
|
86
|
+
* const formattedIntents = activeIntents
|
|
87
|
+
* .map(i => `ID: ${i.id}, Description: ${i.payload}, Summary: ${i.summary || 'N/A'}`)
|
|
88
|
+
* .join('\n');
|
|
89
|
+
* ```
|
|
90
|
+
*/
|
|
91
|
+
getActiveIntents(userId: string): Promise<ActiveIntent[]>;
|
|
92
|
+
/**
|
|
93
|
+
* Get active intents that belong to the user and are assigned to a specific index.
|
|
94
|
+
* Caller must be a member of that index; only the user's own intents are returned.
|
|
95
|
+
*
|
|
96
|
+
* @param userId - The user requesting (must be a member of the index)
|
|
97
|
+
* @param indexNameOrId - Network UUID or display name (e.g. "Commons")
|
|
98
|
+
* @returns Array of active intents in that index for the user, or empty if not a member / no match
|
|
99
|
+
*/
|
|
100
|
+
getIntentsInIndexForMember(userId: string, indexNameOrId: string): Promise<ActiveIntent[]>;
|
|
101
|
+
/**
|
|
102
|
+
* Creates a new intent with full processing pipeline.
|
|
103
|
+
* Handles summarization, embedding generation, and index association.
|
|
104
|
+
*
|
|
105
|
+
* Called when the reconciler outputs a "create" action.
|
|
106
|
+
*
|
|
107
|
+
* @param data - The intent creation data
|
|
108
|
+
* @returns The created intent with generated fields
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* // After graph outputs CREATE action
|
|
113
|
+
* const newIntent = await db.createIntent({
|
|
114
|
+
* userId,
|
|
115
|
+
* payload: action.payload,
|
|
116
|
+
* confidence: action.score / 100,
|
|
117
|
+
* inferenceType: 'explicit',
|
|
118
|
+
* sourceType: 'discovery_form'
|
|
119
|
+
* });
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
createIntent(data: CreateIntentData): Promise<CreatedIntent>;
|
|
123
|
+
/**
|
|
124
|
+
* Updates an existing intent.
|
|
125
|
+
* Re-generates summary and embedding if payload changes.
|
|
126
|
+
*
|
|
127
|
+
* Called when the reconciler outputs an "update" action.
|
|
128
|
+
*
|
|
129
|
+
* @param intentId - The unique identifier of the intent to update
|
|
130
|
+
* @param data - The fields to update
|
|
131
|
+
* @returns The updated intent or null if not found
|
|
132
|
+
* @throws Error if the intent exists but user doesn't have access
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* ```typescript
|
|
136
|
+
* // After graph outputs UPDATE action
|
|
137
|
+
* const updated = await db.updateIntent(action.id, {
|
|
138
|
+
* payload: action.payload
|
|
139
|
+
* });
|
|
140
|
+
* ```
|
|
141
|
+
*/
|
|
142
|
+
updateIntent(intentId: string, data: UpdateIntentData): Promise<CreatedIntent | null>;
|
|
143
|
+
/**
|
|
144
|
+
* Archives (soft-deletes) an intent.
|
|
145
|
+
* Sets the archivedAt timestamp rather than hard deleting.
|
|
146
|
+
*
|
|
147
|
+
* Called when the reconciler outputs an "expire" action.
|
|
148
|
+
*
|
|
149
|
+
* @param intentId - The unique identifier of the intent to archive
|
|
150
|
+
* @returns Result object indicating success or failure with error message
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* ```typescript
|
|
154
|
+
* // After graph outputs EXPIRE action
|
|
155
|
+
* const result = await db.archiveIntent(action.id);
|
|
156
|
+
* if (!result.success) {
|
|
157
|
+
* console.error('Failed to archive intent', { error: result.error });
|
|
158
|
+
* }
|
|
159
|
+
* ```
|
|
160
|
+
*/
|
|
161
|
+
archiveIntent(intentId: string): Promise<ArchiveResult>;
|
|
162
|
+
/**
|
|
163
|
+
* Retrieves a single intent by ID.
|
|
164
|
+
*
|
|
165
|
+
* @param intentId - The unique identifier of the intent
|
|
166
|
+
* @returns The full intent record or null if not found
|
|
167
|
+
*/
|
|
168
|
+
getIntent(intentId: string): Promise<IntentRecord | null>;
|
|
169
|
+
/**
|
|
170
|
+
* Retrieves an intent with ownership verification.
|
|
171
|
+
* Ensures the requesting user owns the intent before returning.
|
|
172
|
+
*
|
|
173
|
+
* Used for processing operations (refine, suggestions) that require ownership.
|
|
174
|
+
*
|
|
175
|
+
* @param intentId - The unique identifier of the intent
|
|
176
|
+
* @param userId - The user requesting access
|
|
177
|
+
* @returns The intent if found and owned by user, null if not found
|
|
178
|
+
* @throws Error with message 'Access denied' if intent exists but is not owned by user
|
|
179
|
+
*
|
|
180
|
+
* @example
|
|
181
|
+
* ```typescript
|
|
182
|
+
* try {
|
|
183
|
+
* const intent = await db.getIntentWithOwnership(intentId, userId);
|
|
184
|
+
* if (!intent) return res.status(404).json({ error: 'Not found' });
|
|
185
|
+
* // Process intent...
|
|
186
|
+
* } catch (e) {
|
|
187
|
+
* if (e.message === 'Access denied') {
|
|
188
|
+
* return res.status(403).json({ error: 'Forbidden' });
|
|
189
|
+
* }
|
|
190
|
+
* throw e;
|
|
191
|
+
* }
|
|
192
|
+
* ```
|
|
193
|
+
*/
|
|
194
|
+
getIntentWithOwnership(intentId: string, userId: string): Promise<IntentRecord | null>;
|
|
195
|
+
/**
|
|
196
|
+
* Gets Network IDs where the user has auto-assign membership enabled.
|
|
197
|
+
* Used for determining which indexes to associate new intents with.
|
|
198
|
+
*
|
|
199
|
+
* @param userId - The unique identifier of the user
|
|
200
|
+
* @returns Array of network IDs
|
|
201
|
+
*
|
|
202
|
+
* @example
|
|
203
|
+
* ```typescript
|
|
204
|
+
* const networkIds = await db.getUserIndexIds(userId);
|
|
205
|
+
* if (networkIds.length > 0) {
|
|
206
|
+
* await db.associateIntentWithNetworks(intentId, networkIds);
|
|
207
|
+
* }
|
|
208
|
+
* ```
|
|
209
|
+
*/
|
|
210
|
+
getUserIndexIds(userId: string): Promise<string[]>;
|
|
211
|
+
/**
|
|
212
|
+
* Retrieves all networks the user is a member of with full details.
|
|
213
|
+
* Used for displaying network memberships in chat (index_query).
|
|
214
|
+
*
|
|
215
|
+
* @param userId - The unique identifier of the user
|
|
216
|
+
* @returns Array of network memberships with details
|
|
217
|
+
*/
|
|
218
|
+
getNetworkMemberships(userId: string): Promise<NetworkMembership[]>;
|
|
219
|
+
/**
|
|
220
|
+
* Get a single network membership by index and user.
|
|
221
|
+
* Used when the preloaded memberships list may not contain this network (e.g. after isNetworkMember check).
|
|
222
|
+
*
|
|
223
|
+
* @param networkId - The network ID
|
|
224
|
+
* @param userId - The user ID
|
|
225
|
+
* @returns The membership or null if not found
|
|
226
|
+
*/
|
|
227
|
+
getNetworkMembership(networkId: string, userId: string): Promise<NetworkMembership | null>;
|
|
228
|
+
/**
|
|
229
|
+
* Return only requested user/network pairs backed by a live membership row
|
|
230
|
+
* and a non-deleted network. Permissions are intentionally not filtered:
|
|
231
|
+
* personal-network contacts are valid discovery participants.
|
|
232
|
+
*/
|
|
233
|
+
getActiveNetworkMembershipPairs(pairs: ActiveNetworkMembershipPair[]): Promise<ActiveNetworkMembershipPair[]>;
|
|
234
|
+
/**
|
|
235
|
+
* Get index by ID with core fields. Used for opportunity presentation and context rendering.
|
|
236
|
+
*/
|
|
237
|
+
getNetwork(networkId: string): Promise<{
|
|
238
|
+
id: string;
|
|
239
|
+
title: string;
|
|
240
|
+
prompt?: string | null;
|
|
241
|
+
type?: string;
|
|
242
|
+
metadata?: Record<string, unknown> | null;
|
|
243
|
+
permissions?: Record<string, unknown> | null;
|
|
244
|
+
} | null>;
|
|
245
|
+
/**
|
|
246
|
+
* Get index by ID with permissions (e.g. joinPolicy). Used by chat tools for create_index_membership.
|
|
247
|
+
*/
|
|
248
|
+
getNetworkWithPermissions(networkId: string): Promise<{
|
|
249
|
+
id: string;
|
|
250
|
+
title: string;
|
|
251
|
+
permissions: {
|
|
252
|
+
joinPolicy: 'anyone' | 'invite_only';
|
|
253
|
+
};
|
|
254
|
+
} | null>;
|
|
255
|
+
/**
|
|
256
|
+
* Associates an intent with one or more networks.
|
|
257
|
+
* Creates entries in the intentNetworks join table.
|
|
258
|
+
*
|
|
259
|
+
* @param intentId - The intent to associate
|
|
260
|
+
* @param networkIds - Array of network IDs to associate with
|
|
261
|
+
*
|
|
262
|
+
* @example
|
|
263
|
+
* ```typescript
|
|
264
|
+
* await db.associateIntentWithNetworks(intentId, ['idx_1', 'idx_2']);
|
|
265
|
+
* ```
|
|
266
|
+
*/
|
|
267
|
+
associateIntentWithNetworks(intentId: string, networkIds: string[]): Promise<void>;
|
|
268
|
+
/**
|
|
269
|
+
* Finds semantically similar intents using vector search.
|
|
270
|
+
* Used for deduplication during intent creation and discovery.
|
|
271
|
+
*
|
|
272
|
+
* Privacy scoping: Results are always filtered by userId to ensure
|
|
273
|
+
* users only see their own intents.
|
|
274
|
+
*
|
|
275
|
+
* @param embedding - The query embedding vector
|
|
276
|
+
* @param userId - The user ID for privacy scoping (required)
|
|
277
|
+
* @param options - Search options (limit, threshold)
|
|
278
|
+
* @returns Array of intents with similarity scores, sorted by similarity
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* // Check for duplicates before creating
|
|
283
|
+
* const embedding = await embedder.generate(payload);
|
|
284
|
+
* const similar = await db.findSimilarIntents(embedding, userId, {
|
|
285
|
+
* limit: 5,
|
|
286
|
+
* threshold: 0.85
|
|
287
|
+
* });
|
|
288
|
+
* if (similar.length > 0 && similar[0].similarity > 0.95) {
|
|
289
|
+
* // Likely duplicate - consider updating instead
|
|
290
|
+
* }
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
293
|
+
findSimilarIntents(embedding: number[], userId: string, options?: SimilarIntentSearchOptions): Promise<SimilarIntent[]>;
|
|
294
|
+
}
|