@indexnetwork/protocol 14.3.2-rc.477.1 → 16.1.1-rc.478.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 +107 -0
- package/IMPLEMENTATION.md +50 -52
- package/STABILITY.md +3 -3
- package/dist/chat/chat.agent.js +2 -2
- package/dist/chat/chat.graph.d.ts +41 -1
- package/dist/chat/chat.graph.js +108 -127
- 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 -48
- package/dist/index.js +17 -27
- 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 +12 -16
- 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.helpers.d.ts +21 -0
- package/dist/shared/agent/tool.registry.d.ts +4 -3
- package/dist/shared/agent/tool.registry.js +1 -1
- 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 +228 -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/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,533 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entity records and value types the database port speaks in.
|
|
3
|
+
*
|
|
4
|
+
* Split out of `database.interface.ts`, which had grown to hold the entities,
|
|
5
|
+
* the port, the two access-scoped views, and every capability-narrowed alias in
|
|
6
|
+
* one file. Import from `database.interface.js` — it re-exports all of them.
|
|
7
|
+
*/
|
|
8
|
+
import type { ScopeMembership } from '../agent/tool.scope.js';
|
|
9
|
+
/** Branded string ID for type-safe entity references (keyed by Drizzle table name). */
|
|
10
|
+
export type Id<T extends string = string> = string & {
|
|
11
|
+
readonly __table?: T;
|
|
12
|
+
};
|
|
13
|
+
export interface OnboardingProfileSeed {
|
|
14
|
+
source: 'experiment_signup' | 'experiment_csv_import';
|
|
15
|
+
networkId: string;
|
|
16
|
+
capturedAt: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
bio?: string;
|
|
19
|
+
location?: string;
|
|
20
|
+
socials?: {
|
|
21
|
+
label: string;
|
|
22
|
+
value: string;
|
|
23
|
+
}[];
|
|
24
|
+
}
|
|
25
|
+
export interface NetworkAssignmentContext {
|
|
26
|
+
networkId: string;
|
|
27
|
+
indexPrompt: string | null;
|
|
28
|
+
memberPrompt: string | null;
|
|
29
|
+
}
|
|
30
|
+
export interface AssignmentNetworkMembership extends ScopeMembership {
|
|
31
|
+
networkId: string;
|
|
32
|
+
isPersonal: boolean;
|
|
33
|
+
}
|
|
34
|
+
/** Final-authority result for an existing intent-to-network assignment. */
|
|
35
|
+
export type IntentNetworkFinalAssignmentResult = {
|
|
36
|
+
kind: 'assigned';
|
|
37
|
+
} | {
|
|
38
|
+
kind: 'already_assigned';
|
|
39
|
+
} | {
|
|
40
|
+
kind: 'membership_required';
|
|
41
|
+
} | {
|
|
42
|
+
kind: 'intent_not_owned_or_not_found';
|
|
43
|
+
};
|
|
44
|
+
/** Onboarding flow state stored as JSON on the user record. */
|
|
45
|
+
export interface OnboardingState {
|
|
46
|
+
completedAt?: string;
|
|
47
|
+
profileConfirmedAt?: string;
|
|
48
|
+
firstSignalIntentId?: string;
|
|
49
|
+
flow?: 1 | 2 | 3;
|
|
50
|
+
currentStep?: 'profile' | 'summary' | 'connections' | 'create_network' | 'invite_members' | 'join_networks' | 'first_signal' | 'complete';
|
|
51
|
+
networkId?: string;
|
|
52
|
+
invitationCode?: string;
|
|
53
|
+
profileSeeds?: OnboardingProfileSeed[];
|
|
54
|
+
}
|
|
55
|
+
/** Single social-link row from the user_socials table. */
|
|
56
|
+
export interface UserSocial {
|
|
57
|
+
id: string;
|
|
58
|
+
userId: string;
|
|
59
|
+
label: string;
|
|
60
|
+
value: string;
|
|
61
|
+
}
|
|
62
|
+
/** Detection metadata recorded when an opportunity is created. */
|
|
63
|
+
export interface OpportunityDetection {
|
|
64
|
+
source: 'opportunity_graph' | 'chat' | 'manual' | 'cron' | 'member_added' | 'enrichment' | 'introducer_discovery';
|
|
65
|
+
createdBy?: Id<'users'> | string;
|
|
66
|
+
createdByName?: string;
|
|
67
|
+
triggeredBy?: Id<'intents'>;
|
|
68
|
+
timestamp: string;
|
|
69
|
+
enrichedFrom?: string[];
|
|
70
|
+
}
|
|
71
|
+
/** A participant (user + network) involved in an opportunity. */
|
|
72
|
+
export interface OpportunityActor {
|
|
73
|
+
networkId: Id<'networks'>;
|
|
74
|
+
userId: Id<'users'>;
|
|
75
|
+
intent?: Id<'intents'>;
|
|
76
|
+
/** Which premise grounded this match (set when discoverySource is 'premise-similarity'). */
|
|
77
|
+
premise?: Id<'premises'>;
|
|
78
|
+
role: string;
|
|
79
|
+
/** Only set on role === 'introducer'. false until the introducer explicitly approves; true after approval. */
|
|
80
|
+
approved?: boolean;
|
|
81
|
+
/**
|
|
82
|
+
* ISO-8601 timestamp set the first time this actor advanced the opportunity's
|
|
83
|
+
* state (patient sending, agent accepting, peer "accepting" on draft = sending
|
|
84
|
+
* under the hood, peer accepting on pending, introducer sending). Once set,
|
|
85
|
+
* this actor has committed and cannot be the one to subsequently `accept` the
|
|
86
|
+
* same opportunity — enforced by the self-accept guard in `updateNode`.
|
|
87
|
+
*/
|
|
88
|
+
actedAt?: string;
|
|
89
|
+
}
|
|
90
|
+
/** Individual signal contributing to an opportunity score. */
|
|
91
|
+
export interface OpportunitySignal {
|
|
92
|
+
type: string;
|
|
93
|
+
weight: number;
|
|
94
|
+
detail?: string;
|
|
95
|
+
/** Optional source question for reversible pool-preference provenance. */
|
|
96
|
+
questionId?: string;
|
|
97
|
+
/** Recipient provenance for pool-discriminator signals. */
|
|
98
|
+
recipientUserId?: string;
|
|
99
|
+
/** Intent-pool provenance for pool-discriminator signals. */
|
|
100
|
+
intentId?: string;
|
|
101
|
+
}
|
|
102
|
+
/** LLM-generated interpretation of an opportunity's category and confidence. */
|
|
103
|
+
export interface OpportunityInterpretation {
|
|
104
|
+
category: string;
|
|
105
|
+
reasoning: string;
|
|
106
|
+
confidence: number;
|
|
107
|
+
signals?: OpportunitySignal[];
|
|
108
|
+
}
|
|
109
|
+
/** Optional scoping context (network / conversation) for an opportunity. */
|
|
110
|
+
export interface OpportunityContext {
|
|
111
|
+
networkId?: Id<'networks'>;
|
|
112
|
+
conversationId?: Id<'conversations'>;
|
|
113
|
+
}
|
|
114
|
+
/** User record returned by getUser (minimal fields plus optional profile fields). */
|
|
115
|
+
export interface UserRecord {
|
|
116
|
+
id: string;
|
|
117
|
+
name: string;
|
|
118
|
+
email: string;
|
|
119
|
+
intro?: string | null;
|
|
120
|
+
avatar?: string | null;
|
|
121
|
+
location?: string | null;
|
|
122
|
+
socials: UserSocial[];
|
|
123
|
+
onboarding?: OnboardingState | null;
|
|
124
|
+
isGhost?: boolean;
|
|
125
|
+
deletedAt?: Date | null;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Minimal intent representation used for graph state population.
|
|
129
|
+
* Contains only the fields needed for reconciliation logic.
|
|
130
|
+
*/
|
|
131
|
+
export interface ActiveIntent {
|
|
132
|
+
/** Unique identifier of the intent */
|
|
133
|
+
id: string;
|
|
134
|
+
/** Full intent description/payload */
|
|
135
|
+
payload: string;
|
|
136
|
+
/** Short summary of the intent (may be null if not generated) */
|
|
137
|
+
summary: string | null;
|
|
138
|
+
/** When the intent was created */
|
|
139
|
+
createdAt: Date;
|
|
140
|
+
/** Relevancy score for this intent in its index context (0.0–1.0, null if not scored) */
|
|
141
|
+
relevancyScore?: number | null;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Input data for creating a new intent.
|
|
145
|
+
* Supports the full intent pipeline including embedding and index association.
|
|
146
|
+
*/
|
|
147
|
+
export interface CreateIntentData {
|
|
148
|
+
/** The user who owns this intent */
|
|
149
|
+
userId: string;
|
|
150
|
+
/** Full intent description/payload */
|
|
151
|
+
payload: string;
|
|
152
|
+
/** Pre-computed summary (optional, will be generated if not provided) */
|
|
153
|
+
summary?: string | null;
|
|
154
|
+
/** Pre-computed embedding vector (optional, will be generated if not provided) */
|
|
155
|
+
embedding?: number[];
|
|
156
|
+
/** Whether the intent should be hidden from public views */
|
|
157
|
+
isIncognito?: boolean;
|
|
158
|
+
/** Network IDs to associate with (optional, uses dynamic scoping if empty) */
|
|
159
|
+
networkIds?: string[];
|
|
160
|
+
/** Source type for provenance tracking */
|
|
161
|
+
sourceType?: 'file' | 'integration' | 'link' | 'discovery_form' | 'enrichment';
|
|
162
|
+
/** Source ID for provenance tracking */
|
|
163
|
+
sourceId?: string;
|
|
164
|
+
/** Confidence score from inference (0-1, required) */
|
|
165
|
+
confidence: number;
|
|
166
|
+
/** How the intent was inferred */
|
|
167
|
+
inferenceType: 'explicit' | 'implicit';
|
|
168
|
+
/** Semantic entropy from verifier (0 specific -> 1 vague) */
|
|
169
|
+
semanticEntropy?: number | null;
|
|
170
|
+
/** Referential anchor extracted by verifier (if any) */
|
|
171
|
+
referentialAnchor?: string | null;
|
|
172
|
+
/** Felicity authority score from verifier (0-100) */
|
|
173
|
+
felicityAuthority?: number | null;
|
|
174
|
+
/** Felicity sincerity score from verifier (0-100) */
|
|
175
|
+
felicitySincerity?: number | null;
|
|
176
|
+
/** Felicity clarity score from verifier (0-100) */
|
|
177
|
+
felicityClarity?: number | null;
|
|
178
|
+
/** Donnellan intent mode */
|
|
179
|
+
intentMode?: 'REFERENTIAL' | 'ATTRIBUTIVE' | null;
|
|
180
|
+
/** Speech act category used by protocol enum */
|
|
181
|
+
speechActType?: 'COMMISSIVE' | 'DIRECTIVE' | null;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Input data for updating an existing intent.
|
|
185
|
+
* All fields are optional - only provided fields will be updated.
|
|
186
|
+
*/
|
|
187
|
+
export interface UpdateIntentData {
|
|
188
|
+
/** Updated intent description/payload */
|
|
189
|
+
payload?: string;
|
|
190
|
+
/** Updated summary */
|
|
191
|
+
summary?: string | null;
|
|
192
|
+
/** Updated embedding vector */
|
|
193
|
+
embedding?: number[];
|
|
194
|
+
/** Updated incognito status */
|
|
195
|
+
isIncognito?: boolean;
|
|
196
|
+
/** Updated index associations (replaces existing) */
|
|
197
|
+
networkIds?: string[];
|
|
198
|
+
/** Semantic entropy from verifier (0 specific -> 1 vague) */
|
|
199
|
+
semanticEntropy?: number | null;
|
|
200
|
+
/** Referential anchor extracted by verifier (if any) */
|
|
201
|
+
referentialAnchor?: string | null;
|
|
202
|
+
/** Felicity authority score from verifier (0-100) */
|
|
203
|
+
felicityAuthority?: number | null;
|
|
204
|
+
/** Felicity sincerity score from verifier (0-100) */
|
|
205
|
+
felicitySincerity?: number | null;
|
|
206
|
+
/** Felicity clarity score from verifier (0-100) */
|
|
207
|
+
felicityClarity?: number | null;
|
|
208
|
+
/** Donnellan intent mode */
|
|
209
|
+
intentMode?: 'REFERENTIAL' | 'ATTRIBUTIVE' | null;
|
|
210
|
+
/** Speech act category used by protocol enum */
|
|
211
|
+
speechActType?: 'COMMISSIVE' | 'DIRECTIVE' | null;
|
|
212
|
+
/**
|
|
213
|
+
* Optional compare-and-set guard for recovery-answer writes. Implementations
|
|
214
|
+
* must compare this value with the material payload+summary fingerprint while
|
|
215
|
+
* holding the final intent row lock. Omitted for ordinary intent updates.
|
|
216
|
+
*/
|
|
217
|
+
expectedIntentFingerprint?: string;
|
|
218
|
+
/** Expected owner paired with the recovery-answer fingerprint guard. */
|
|
219
|
+
expectedIntentUserId?: string;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* The result of a successful intent creation.
|
|
223
|
+
* Contains the core fields needed for immediate use.
|
|
224
|
+
*/
|
|
225
|
+
export interface CreatedIntent {
|
|
226
|
+
/** Unique identifier of the created intent */
|
|
227
|
+
id: string;
|
|
228
|
+
/** Full intent description/payload */
|
|
229
|
+
payload: string;
|
|
230
|
+
/** Generated or provided summary */
|
|
231
|
+
summary: string | null;
|
|
232
|
+
/** Incognito status */
|
|
233
|
+
isIncognito: boolean;
|
|
234
|
+
/** Creation timestamp */
|
|
235
|
+
createdAt: Date;
|
|
236
|
+
/** Last update timestamp */
|
|
237
|
+
updatedAt: Date;
|
|
238
|
+
/** Owner user ID */
|
|
239
|
+
userId: string;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Full intent record with all fields (for detailed queries).
|
|
243
|
+
*/
|
|
244
|
+
export interface IntentRecord extends CreatedIntent {
|
|
245
|
+
/** Archival timestamp (null if active) */
|
|
246
|
+
archivedAt: Date | null;
|
|
247
|
+
/** Embedding vector (may be null) */
|
|
248
|
+
embedding?: number[] | null;
|
|
249
|
+
/** Source type for provenance */
|
|
250
|
+
sourceType?: string | null;
|
|
251
|
+
/** Source ID for provenance */
|
|
252
|
+
sourceId?: string | null;
|
|
253
|
+
/** Lifecycle admission state; null is a legacy ACTIVE row. */
|
|
254
|
+
status?: 'ACTIVE' | 'PAUSED' | 'FULFILLED' | 'EXPIRED' | null;
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Intent with similarity score from vector search.
|
|
258
|
+
*/
|
|
259
|
+
export interface SimilarIntent extends IntentRecord {
|
|
260
|
+
/** Cosine similarity score (0-1) */
|
|
261
|
+
similarity: number;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Result of an archive operation.
|
|
265
|
+
*/
|
|
266
|
+
export interface ArchiveResult {
|
|
267
|
+
/** Whether the operation succeeded */
|
|
268
|
+
success: boolean;
|
|
269
|
+
/** Error message if failed */
|
|
270
|
+
error?: string;
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Options for vector similarity search.
|
|
274
|
+
*/
|
|
275
|
+
export interface SimilarIntentSearchOptions {
|
|
276
|
+
/** Maximum number of results to return (default: 10) */
|
|
277
|
+
limit?: number;
|
|
278
|
+
/** Minimum similarity threshold (default: 0.7) */
|
|
279
|
+
threshold?: number;
|
|
280
|
+
}
|
|
281
|
+
/**
|
|
282
|
+
* Represents a user's membership in an index with full details.
|
|
283
|
+
* Used for displaying network memberships in chat (index_query).
|
|
284
|
+
*/
|
|
285
|
+
export interface ActiveNetworkMembershipPair {
|
|
286
|
+
userId: string;
|
|
287
|
+
networkId: string;
|
|
288
|
+
}
|
|
289
|
+
export interface NetworkMembership {
|
|
290
|
+
/** Unique identifier of the index */
|
|
291
|
+
networkId: string;
|
|
292
|
+
/** Display title of the index */
|
|
293
|
+
networkTitle: string;
|
|
294
|
+
/** Index description/prompt (what the community is about) */
|
|
295
|
+
indexPrompt: string | null;
|
|
296
|
+
/** Member's permissions in this network */
|
|
297
|
+
permissions: string[];
|
|
298
|
+
/** Member's custom prompt (overrides network prompt for their intents) */
|
|
299
|
+
memberPrompt: string | null;
|
|
300
|
+
/** Whether new intents are auto-assigned to this network */
|
|
301
|
+
autoAssign: boolean;
|
|
302
|
+
/** Whether this is the user's personal network ("My Network") */
|
|
303
|
+
isPersonal: boolean;
|
|
304
|
+
/** When the user joined the network */
|
|
305
|
+
joinedAt: Date;
|
|
306
|
+
}
|
|
307
|
+
export interface PremiseAssertion {
|
|
308
|
+
text: string;
|
|
309
|
+
tier: 'assertive' | 'contextual';
|
|
310
|
+
summary?: string;
|
|
311
|
+
}
|
|
312
|
+
export interface PremiseProvenance {
|
|
313
|
+
source: 'explicit' | 'enrichment' | 'integration' | 'onboarding';
|
|
314
|
+
sourceId?: string;
|
|
315
|
+
confidence: number;
|
|
316
|
+
timestamp: string;
|
|
317
|
+
}
|
|
318
|
+
export interface PremiseAnalysis {
|
|
319
|
+
speechActType: 'DECLARATIVE' | 'ASSERTIVE';
|
|
320
|
+
felicityAuthority: number;
|
|
321
|
+
felicitySincerity: number;
|
|
322
|
+
felicityClarity: number;
|
|
323
|
+
semanticEntropy: number;
|
|
324
|
+
}
|
|
325
|
+
export interface PremiseValidity {
|
|
326
|
+
validFrom?: string;
|
|
327
|
+
validUntil?: string;
|
|
328
|
+
volatile: boolean;
|
|
329
|
+
}
|
|
330
|
+
export interface PremiseRecord {
|
|
331
|
+
id: string;
|
|
332
|
+
userId: string;
|
|
333
|
+
assertion: PremiseAssertion;
|
|
334
|
+
provenance: PremiseProvenance;
|
|
335
|
+
analysis: PremiseAnalysis | null;
|
|
336
|
+
validity: PremiseValidity;
|
|
337
|
+
embedding: number[] | null;
|
|
338
|
+
status: 'ACTIVE' | 'RETRACTED' | 'EXPIRED';
|
|
339
|
+
createdAt: Date;
|
|
340
|
+
updatedAt: Date;
|
|
341
|
+
retractedAt: Date | null;
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Represents an index owned by the user with full details.
|
|
345
|
+
*/
|
|
346
|
+
export interface OwnedIndex {
|
|
347
|
+
/** Network ID */
|
|
348
|
+
id: string;
|
|
349
|
+
/** Display title */
|
|
350
|
+
title: string;
|
|
351
|
+
/** Index purpose/scope prompt */
|
|
352
|
+
prompt: string | null;
|
|
353
|
+
/** Cover image URL */
|
|
354
|
+
imageUrl: string | null;
|
|
355
|
+
/** Permission settings */
|
|
356
|
+
permissions: {
|
|
357
|
+
joinPolicy: 'anyone' | 'invite_only';
|
|
358
|
+
invitationLink: {
|
|
359
|
+
code: string;
|
|
360
|
+
} | null;
|
|
361
|
+
};
|
|
362
|
+
/** Whether this is a personal network */
|
|
363
|
+
isPersonal: boolean;
|
|
364
|
+
/** When the index was created */
|
|
365
|
+
createdAt: Date;
|
|
366
|
+
/** When the index was last updated */
|
|
367
|
+
updatedAt: Date;
|
|
368
|
+
/** Member count */
|
|
369
|
+
memberCount: number;
|
|
370
|
+
/** Total intents indexed */
|
|
371
|
+
intentCount: number;
|
|
372
|
+
/** Owner summary */
|
|
373
|
+
user: {
|
|
374
|
+
id: string;
|
|
375
|
+
name: string;
|
|
376
|
+
avatar: string | null;
|
|
377
|
+
};
|
|
378
|
+
/** Aggregate counts for frontend compatibility */
|
|
379
|
+
_count: {
|
|
380
|
+
members: number;
|
|
381
|
+
};
|
|
382
|
+
}
|
|
383
|
+
/**
|
|
384
|
+
* Member details visible to network owners (and optionally to members with privacy rules).
|
|
385
|
+
*/
|
|
386
|
+
export interface IndexMemberDetails {
|
|
387
|
+
/** User ID */
|
|
388
|
+
userId: string;
|
|
389
|
+
/** User's display name */
|
|
390
|
+
name: string;
|
|
391
|
+
/** User's avatar URL */
|
|
392
|
+
avatar: string | null;
|
|
393
|
+
/** User's email; only present when viewer is owner/admin or the member themselves (privacy-safe) */
|
|
394
|
+
email?: string | null;
|
|
395
|
+
/** Member's permissions in this network */
|
|
396
|
+
permissions: string[];
|
|
397
|
+
/** Member's custom prompt */
|
|
398
|
+
memberPrompt: string | null;
|
|
399
|
+
/** Whether auto-assign is enabled */
|
|
400
|
+
autoAssign: boolean;
|
|
401
|
+
/** When they joined */
|
|
402
|
+
joinedAt: Date;
|
|
403
|
+
/** Count of their intents in this network */
|
|
404
|
+
intentCount: number;
|
|
405
|
+
/** Whether this user is a ghost (not yet onboarded) */
|
|
406
|
+
isGhost?: boolean;
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Intent details visible to network owners.
|
|
410
|
+
*/
|
|
411
|
+
export interface IndexedIntentDetails {
|
|
412
|
+
/** Intent ID */
|
|
413
|
+
id: string;
|
|
414
|
+
/** Intent payload/description */
|
|
415
|
+
payload: string;
|
|
416
|
+
/** Intent summary */
|
|
417
|
+
summary: string | null;
|
|
418
|
+
/** Owner's user ID */
|
|
419
|
+
userId: string;
|
|
420
|
+
/** Owner's name */
|
|
421
|
+
userName: string;
|
|
422
|
+
/** When the intent was created */
|
|
423
|
+
createdAt: Date;
|
|
424
|
+
/** Relevancy score for this intent in its index context (0.0–1.0, null if not scored) */
|
|
425
|
+
relevancyScore?: number | null;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Options for updating index settings.
|
|
429
|
+
*/
|
|
430
|
+
export interface UpdateIndexSettingsData {
|
|
431
|
+
/** New title (optional) */
|
|
432
|
+
title?: string;
|
|
433
|
+
/** New prompt (optional) */
|
|
434
|
+
prompt?: string | null;
|
|
435
|
+
/** New image URL (optional) */
|
|
436
|
+
imageUrl?: string | null;
|
|
437
|
+
/** New join policy (optional) */
|
|
438
|
+
joinPolicy?: 'anyone' | 'invite_only';
|
|
439
|
+
}
|
|
440
|
+
export type HydeSourceType = 'intent' | 'query' | 'context';
|
|
441
|
+
export interface HydeDocument {
|
|
442
|
+
id: string;
|
|
443
|
+
sourceType: HydeSourceType;
|
|
444
|
+
sourceId: string | null;
|
|
445
|
+
sourceText: string | null;
|
|
446
|
+
strategy: string;
|
|
447
|
+
targetCorpus: string;
|
|
448
|
+
hydeText: string;
|
|
449
|
+
hydeEmbedding: number[];
|
|
450
|
+
context: Record<string, unknown> | null;
|
|
451
|
+
createdAt: Date;
|
|
452
|
+
expiresAt: Date | null;
|
|
453
|
+
}
|
|
454
|
+
export interface CreateHydeDocumentData {
|
|
455
|
+
sourceType: HydeSourceType;
|
|
456
|
+
sourceId?: string;
|
|
457
|
+
sourceText?: string;
|
|
458
|
+
strategy: string;
|
|
459
|
+
targetCorpus: string;
|
|
460
|
+
hydeText: string;
|
|
461
|
+
hydeEmbedding: number[];
|
|
462
|
+
context?: Record<string, unknown>;
|
|
463
|
+
expiresAt?: Date;
|
|
464
|
+
}
|
|
465
|
+
export type OpportunityStatus = 'latent' | 'draft' | 'negotiating' | 'pending' | 'stalled' | 'accepted' | 'rejected' | 'expired';
|
|
466
|
+
/**
|
|
467
|
+
* Minimal opportunity lifecycle evidence used to narrate an agent negotiation.
|
|
468
|
+
* `acceptedByOwner` is true only when the authenticated owner is the persisted
|
|
469
|
+
* human acceptor; other terminal states do not imply an owner action.
|
|
470
|
+
*/
|
|
471
|
+
export interface NegotiationOpportunityLifecycle {
|
|
472
|
+
status: OpportunityStatus;
|
|
473
|
+
acceptedByOwner: boolean;
|
|
474
|
+
}
|
|
475
|
+
export interface Opportunity {
|
|
476
|
+
id: string;
|
|
477
|
+
detection: OpportunityDetection;
|
|
478
|
+
actors: OpportunityActor[];
|
|
479
|
+
interpretation: OpportunityInterpretation;
|
|
480
|
+
context: OpportunityContext;
|
|
481
|
+
confidence: string;
|
|
482
|
+
status: OpportunityStatus;
|
|
483
|
+
createdAt: Date;
|
|
484
|
+
updatedAt: Date;
|
|
485
|
+
expiresAt: Date | null;
|
|
486
|
+
metadata?: Record<string, unknown> | null;
|
|
487
|
+
}
|
|
488
|
+
export interface OpportunityNetworkEligibility {
|
|
489
|
+
/** User whose active memberships define the discovery boundary. */
|
|
490
|
+
ownerUserId: string;
|
|
491
|
+
/** Request/intent-authorized networks after the latest graph-side recomputation. */
|
|
492
|
+
allowedNetworkIds: string[];
|
|
493
|
+
/** When present, each actor network must remain assigned to this intent through commit. */
|
|
494
|
+
triggerIntentId?: string;
|
|
495
|
+
}
|
|
496
|
+
export type OpportunityDedupConflictReason = 'same_trigger_recent_duplicate' | 'pair_active_negotiation';
|
|
497
|
+
export interface OpportunityDedupConflict {
|
|
498
|
+
reason: OpportunityDedupConflictReason;
|
|
499
|
+
existingOpportunityId: string;
|
|
500
|
+
existingTriggerIntentId?: string;
|
|
501
|
+
existingStatus: OpportunityStatus;
|
|
502
|
+
existingCreatedAt: Date;
|
|
503
|
+
}
|
|
504
|
+
export type IntentScopedOpportunityPersistenceResult = {
|
|
505
|
+
created: Opportunity;
|
|
506
|
+
expired: Opportunity[];
|
|
507
|
+
} | {
|
|
508
|
+
conflict: OpportunityDedupConflict;
|
|
509
|
+
};
|
|
510
|
+
export interface CreateOpportunityData {
|
|
511
|
+
detection: OpportunityDetection;
|
|
512
|
+
actors: OpportunityActor[];
|
|
513
|
+
interpretation: OpportunityInterpretation;
|
|
514
|
+
context: OpportunityContext;
|
|
515
|
+
confidence: string;
|
|
516
|
+
status?: OpportunityStatus;
|
|
517
|
+
expiresAt?: Date;
|
|
518
|
+
metadata?: Record<string, unknown> | null;
|
|
519
|
+
}
|
|
520
|
+
export interface OpportunityQueryOptions {
|
|
521
|
+
status?: OpportunityStatus;
|
|
522
|
+
/** When set, filter to opportunities whose status is in this list. Orthogonal to `status` (single) — callers pick one. */
|
|
523
|
+
statuses?: OpportunityStatus[];
|
|
524
|
+
networkId?: string;
|
|
525
|
+
/** Optional selected-intent scope. When `scopeType === 'intent'`, `scopeId` is the selected intent id. */
|
|
526
|
+
scopeType?: 'intent';
|
|
527
|
+
scopeId?: string;
|
|
528
|
+
role?: string;
|
|
529
|
+
limit?: number;
|
|
530
|
+
offset?: number;
|
|
531
|
+
/** When set, include draft opportunities for this chat session. When unset, exclude all draft opportunities (e.g. radar view, API). */
|
|
532
|
+
conversationId?: string;
|
|
533
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entity records and value types the database port speaks in.
|
|
3
|
+
*
|
|
4
|
+
* Split out of `database.interface.ts`, which had grown to hold the entities,
|
|
5
|
+
* the port, the two access-scoped views, and every capability-narrowed alias in
|
|
6
|
+
* one file. Import from `database.interface.js` — it re-exports all of them.
|
|
7
|
+
*/
|
|
8
|
+
export {};
|
|
9
|
+
// ═══════════════════════════════════════════════════════════════════════════════
|
|
10
|
+
// DATABASE INTERFACE
|