@elizaos/plugin-rolodex 2.0.0-alpha.3
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/dist/__tests__/test-utils.d.ts +5 -0
- package/dist/actions/addContact.d.ts +2 -0
- package/dist/actions/index.d.ts +7 -0
- package/dist/actions/removeContact.d.ts +2 -0
- package/dist/actions/scheduleFollowUp.d.ts +2 -0
- package/dist/actions/searchContacts.d.ts +2 -0
- package/dist/actions/sendMessage.d.ts +14 -0
- package/dist/actions/updateContact.d.ts +2 -0
- package/dist/actions/updateEntity.d.ts +42 -0
- package/dist/evaluators/index.d.ts +3 -0
- package/dist/evaluators/reflection.d.ts +2 -0
- package/dist/evaluators/relationshipExtraction.d.ts +16 -0
- package/dist/frontend/utils.d.ts +2 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +9759 -0
- package/dist/index.js.map +49 -0
- package/dist/providers/contacts.d.ts +2 -0
- package/dist/providers/facts.d.ts +10 -0
- package/dist/providers/followUps.d.ts +2 -0
- package/dist/providers/index.d.ts +4 -0
- package/dist/providers/relationships.d.ts +11 -0
- package/dist/services/EntityResolutionService.d.ts +76 -0
- package/dist/services/FollowUpService.d.ts +37 -0
- package/dist/services/RolodexService.d.ts +73 -0
- package/dist/services/index.d.ts +3 -0
- package/dist/tests/ConversationSimulator.d.ts +71 -0
- package/dist/tests/ScenarioVerifier.d.ts +59 -0
- package/dist/tests/e2e.test.d.ts +2 -0
- package/dist/tests/entity-graph.test.d.ts +2 -0
- package/dist/tests/index.d.ts +6 -0
- package/dist/tests/scenarios.test.d.ts +9 -0
- package/dist/types/index.d.ts +281 -0
- package/dist/utils/graphTraversal.d.ts +86 -0
- package/dist/utils/relationshipStrength.d.ts +16 -0
- package/dist/utils/similarity.d.ts +58 -0
- package/dist/utils/timeWeighting.d.ts +64 -0
- package/package.json +49 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type Provider } from "@elizaos/core";
|
|
2
|
+
/**
|
|
3
|
+
* Function to get key facts that the agent knows.
|
|
4
|
+
* @param {IAgentRuntime} runtime - The runtime environment for the agent.
|
|
5
|
+
* @param {Memory} message - The message object containing relevant information.
|
|
6
|
+
* @param {State} [_state] - Optional state information.
|
|
7
|
+
* @returns {Object} An object containing values, data, and text related to the key facts.
|
|
8
|
+
*/
|
|
9
|
+
declare const factsProvider: Provider;
|
|
10
|
+
export { factsProvider };
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Relationships Provider — enriched with entity links and decay.
|
|
3
|
+
*
|
|
4
|
+
* Injects relationship context into the agent's state, including:
|
|
5
|
+
* - Relationships sorted by decayed strength
|
|
6
|
+
* - Cross-platform identity links
|
|
7
|
+
* - Relationship evolution history
|
|
8
|
+
*/
|
|
9
|
+
import type { Provider } from "@elizaos/core";
|
|
10
|
+
declare const relationshipsProvider: Provider;
|
|
11
|
+
export { relationshipsProvider };
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EntityResolutionService — cross-platform identity resolution.
|
|
3
|
+
*
|
|
4
|
+
* The "ultimate goal" of the rolodex: figuring out that Dave on Discord
|
|
5
|
+
* is the same person as @dave_codes on Twitter.
|
|
6
|
+
*
|
|
7
|
+
* Architecture follows a small-world graph approach:
|
|
8
|
+
* 1. Trigger-based, not scan-based — we resolve when new evidence arrives
|
|
9
|
+
* 2. Local neighborhood first — only compare against entities within
|
|
10
|
+
* 2 hops in the social graph (small-world networks cover the
|
|
11
|
+
* relevant cluster in 2-3 hops)
|
|
12
|
+
* 3. Multi-signal scoring — name similarity, handle correlation,
|
|
13
|
+
* shared connections, project affinity, self-identification
|
|
14
|
+
* 4. Merge tasks — when confidence is above threshold, create a task
|
|
15
|
+
* for verification rather than auto-merging
|
|
16
|
+
*
|
|
17
|
+
* This service is intentionally conservative. It's better to miss a
|
|
18
|
+
* connection than to incorrectly merge two different people.
|
|
19
|
+
*/
|
|
20
|
+
import { type Entity, type IAgentRuntime, Service, type UUID } from "@elizaos/core";
|
|
21
|
+
import type { EntityLink } from "../types/index";
|
|
22
|
+
export declare class EntityResolutionService extends Service {
|
|
23
|
+
static serviceType: "entity_resolution";
|
|
24
|
+
capabilityDescription: string;
|
|
25
|
+
/** In-memory index: normalized name/handle -> entity IDs */
|
|
26
|
+
private nameIndex;
|
|
27
|
+
initialize(runtime: IAgentRuntime): Promise<void>;
|
|
28
|
+
stop(): Promise<void>;
|
|
29
|
+
static start(runtime: IAgentRuntime): Promise<Service>;
|
|
30
|
+
/**
|
|
31
|
+
* Trigger resolution for an entity. Called when:
|
|
32
|
+
* - A new platform identity is added
|
|
33
|
+
* - A new entity is created
|
|
34
|
+
* - Someone mentions a name that matches existing entities
|
|
35
|
+
*
|
|
36
|
+
* Uses small-world graph traversal to limit the search space.
|
|
37
|
+
*/
|
|
38
|
+
resolveEntity(entityId: UUID): Promise<EntityLink[]>;
|
|
39
|
+
/**
|
|
40
|
+
* Look up an entity by name or handle, using the in-memory index
|
|
41
|
+
* for O(1) lookup instead of scanning all entities.
|
|
42
|
+
*/
|
|
43
|
+
findByNameOrHandle(entity: Entity): Set<UUID>;
|
|
44
|
+
/**
|
|
45
|
+
* Register a new entity or new names/handles in the index.
|
|
46
|
+
* Called when entities are created or updated.
|
|
47
|
+
*/
|
|
48
|
+
indexEntity(entity: Entity): void;
|
|
49
|
+
/**
|
|
50
|
+
* Get all existing entity links for an entity.
|
|
51
|
+
*/
|
|
52
|
+
getLinks(entityId: UUID): Promise<EntityLink[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Confirm a proposed link (admin or agent verification).
|
|
55
|
+
*/
|
|
56
|
+
confirmLink(linkId: UUID, confirmedBy: UUID): Promise<boolean>;
|
|
57
|
+
rejectLink(linkId: UUID, rejectedBy: UUID): Promise<boolean>;
|
|
58
|
+
private computeSignals;
|
|
59
|
+
/**
|
|
60
|
+
* Score a set of signals into a single confidence value.
|
|
61
|
+
*
|
|
62
|
+
* Uses weighted combination with diminishing returns for multiple
|
|
63
|
+
* signals of the same type.
|
|
64
|
+
*/
|
|
65
|
+
private scoreCandidate;
|
|
66
|
+
private getExistingLink;
|
|
67
|
+
private createLink;
|
|
68
|
+
private updateLink;
|
|
69
|
+
/**
|
|
70
|
+
* Create a merge task that stays open until verified.
|
|
71
|
+
*/
|
|
72
|
+
private createMergeTask;
|
|
73
|
+
private findLinkComponent;
|
|
74
|
+
private getPlatformIdentities;
|
|
75
|
+
private rebuildNameIndex;
|
|
76
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type IAgentRuntime, Service, type Task, type UUID } from "@elizaos/core";
|
|
2
|
+
import type { ContactInfo, FollowUpSuggestion } from "../types/index";
|
|
3
|
+
export interface FollowUpTask {
|
|
4
|
+
entityId: UUID;
|
|
5
|
+
reason: string;
|
|
6
|
+
message?: string;
|
|
7
|
+
priority: "high" | "medium" | "low";
|
|
8
|
+
metadata?: Record<string, any>;
|
|
9
|
+
}
|
|
10
|
+
export declare class FollowUpService extends Service {
|
|
11
|
+
static serviceType: "follow_up";
|
|
12
|
+
capabilityDescription: string;
|
|
13
|
+
private rolodexService;
|
|
14
|
+
constructor(runtime?: IAgentRuntime);
|
|
15
|
+
initialize(runtime: IAgentRuntime): Promise<void>;
|
|
16
|
+
stop(): Promise<void>;
|
|
17
|
+
static start(runtime: IAgentRuntime): Promise<Service>;
|
|
18
|
+
scheduleFollowUp(entityId: UUID, scheduledAt: Date, reason: string, priority?: "high" | "medium" | "low", message?: string): Promise<Task>;
|
|
19
|
+
getUpcomingFollowUps(days?: number, includeOverdue?: boolean): Promise<Array<{
|
|
20
|
+
task: Task;
|
|
21
|
+
contact: ContactInfo;
|
|
22
|
+
}>>;
|
|
23
|
+
completeFollowUp(taskId: UUID, notes?: string): Promise<void>;
|
|
24
|
+
snoozeFollowUp(taskId: UUID, newDate: Date): Promise<void>;
|
|
25
|
+
getFollowUpSuggestions(): Promise<FollowUpSuggestion[]>;
|
|
26
|
+
private registerFollowUpWorker;
|
|
27
|
+
private registerRecurringCheckInWorker;
|
|
28
|
+
private generateFollowUpReason;
|
|
29
|
+
private generateFollowUpMessage;
|
|
30
|
+
scheduleMultipleFollowUps(followUps: Array<{
|
|
31
|
+
entityId: UUID;
|
|
32
|
+
scheduledAt: Date;
|
|
33
|
+
reason: string;
|
|
34
|
+
priority?: "high" | "medium" | "low";
|
|
35
|
+
message?: string;
|
|
36
|
+
}>): Promise<Task[]>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RolodexService — the core CRM service for the agent.
|
|
3
|
+
*
|
|
4
|
+
* Manages contacts, information claims (with provenance), relationship
|
|
5
|
+
* analytics, and categories. This is the single source of truth for
|
|
6
|
+
* "what do I know about this person?"
|
|
7
|
+
*/
|
|
8
|
+
import { type Entity, type IAgentRuntime, type Metadata, Service, type UUID } from "@elizaos/core";
|
|
9
|
+
import type { ClaimScope, ClaimSourceContext, ContactCategory, ContactInfo, ContactPreferences, Corroboration, InformationTier, RelationshipAnalytics } from "../types/index";
|
|
10
|
+
export declare class RolodexService extends Service {
|
|
11
|
+
static serviceType: "rolodex";
|
|
12
|
+
capabilityDescription: string;
|
|
13
|
+
private contactInfoCache;
|
|
14
|
+
private analyticsCache;
|
|
15
|
+
private categoriesCache;
|
|
16
|
+
initialize(runtime: IAgentRuntime): Promise<void>;
|
|
17
|
+
stop(): Promise<void>;
|
|
18
|
+
static start(runtime: IAgentRuntime): Promise<Service>;
|
|
19
|
+
addContact(entityId: UUID, categories?: string[], preferences?: ContactPreferences, customFields?: Record<string, string>): Promise<ContactInfo>;
|
|
20
|
+
updateContact(entityId: UUID, updates: Partial<ContactInfo>): Promise<ContactInfo | null>;
|
|
21
|
+
getContact(entityId: UUID): Promise<ContactInfo | null>;
|
|
22
|
+
removeContact(entityId: UUID): Promise<boolean>;
|
|
23
|
+
searchContacts(criteria: {
|
|
24
|
+
categories?: string[];
|
|
25
|
+
tags?: string[];
|
|
26
|
+
searchTerm?: string;
|
|
27
|
+
privacyLevel?: string;
|
|
28
|
+
}): Promise<ContactInfo[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Store a new information claim about an entity.
|
|
31
|
+
*/
|
|
32
|
+
addClaim(params: {
|
|
33
|
+
entityId: UUID;
|
|
34
|
+
field: string;
|
|
35
|
+
value: string;
|
|
36
|
+
tier: InformationTier;
|
|
37
|
+
confidence: number;
|
|
38
|
+
sourceEntityId: UUID;
|
|
39
|
+
sourceContext: ClaimSourceContext;
|
|
40
|
+
scope?: ClaimScope;
|
|
41
|
+
}): Promise<void>;
|
|
42
|
+
/**
|
|
43
|
+
* Get all claims about an entity, with time-decayed confidence.
|
|
44
|
+
*/
|
|
45
|
+
getClaims(entityId: UUID, field?: string): Promise<Array<{
|
|
46
|
+
claim: Metadata;
|
|
47
|
+
decayedConfidence: number;
|
|
48
|
+
}>>;
|
|
49
|
+
/**
|
|
50
|
+
* Add a corroboration to an existing claim.
|
|
51
|
+
*/
|
|
52
|
+
corroborateClaim(entityId: UUID, componentId: UUID, corroboration: Corroboration): Promise<void>;
|
|
53
|
+
analyzeRelationship(sourceEntityId: UUID, targetEntityId: UUID): Promise<RelationshipAnalytics | null>;
|
|
54
|
+
getRelationshipInsights(entityId: UUID): Promise<{
|
|
55
|
+
strongestRelationships: Array<{
|
|
56
|
+
entity: Entity;
|
|
57
|
+
analytics: RelationshipAnalytics;
|
|
58
|
+
}>;
|
|
59
|
+
needsAttention: Array<{
|
|
60
|
+
entity: Entity;
|
|
61
|
+
daysSinceContact: number;
|
|
62
|
+
}>;
|
|
63
|
+
recentInteractions: Array<{
|
|
64
|
+
entity: Entity;
|
|
65
|
+
lastInteraction: string;
|
|
66
|
+
}>;
|
|
67
|
+
}>;
|
|
68
|
+
getCategories(): Promise<ContactCategory[]>;
|
|
69
|
+
addCategory(category: ContactCategory): Promise<void>;
|
|
70
|
+
setContactPrivacy(entityId: UUID, privacyLevel: "public" | "private" | "restricted"): Promise<boolean>;
|
|
71
|
+
canAccessContact(requestingEntityId: UUID, targetEntityId: UUID): Promise<boolean>;
|
|
72
|
+
private loadContactInfoFromComponents;
|
|
73
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { type ChannelType, type Entity, type IAgentRuntime, type Memory, type Room } from "@elizaos/core";
|
|
2
|
+
export interface UserProfile {
|
|
3
|
+
name: string;
|
|
4
|
+
roles?: string[];
|
|
5
|
+
metadata?: Record<string, any>;
|
|
6
|
+
}
|
|
7
|
+
export interface ConversationStep {
|
|
8
|
+
from: string;
|
|
9
|
+
content: string;
|
|
10
|
+
delay?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface ConversationScript {
|
|
13
|
+
name: string;
|
|
14
|
+
description: string;
|
|
15
|
+
room: {
|
|
16
|
+
name: string;
|
|
17
|
+
type: ChannelType;
|
|
18
|
+
};
|
|
19
|
+
participants: UserProfile[];
|
|
20
|
+
steps: ConversationStep[];
|
|
21
|
+
}
|
|
22
|
+
export interface SimulatedUser {
|
|
23
|
+
entity: Entity;
|
|
24
|
+
profile: UserProfile;
|
|
25
|
+
}
|
|
26
|
+
export declare class ConversationSimulator {
|
|
27
|
+
private runtime;
|
|
28
|
+
private users;
|
|
29
|
+
private rooms;
|
|
30
|
+
private world;
|
|
31
|
+
constructor(runtime: IAgentRuntime);
|
|
32
|
+
/**
|
|
33
|
+
* Creates a test user entity
|
|
34
|
+
*/
|
|
35
|
+
createUser(profile: UserProfile): Promise<Entity>;
|
|
36
|
+
/**
|
|
37
|
+
* Creates or gets a test room
|
|
38
|
+
*/
|
|
39
|
+
getOrCreateRoom(roomConfig: {
|
|
40
|
+
name: string;
|
|
41
|
+
type: ChannelType;
|
|
42
|
+
}): Promise<Room>;
|
|
43
|
+
/**
|
|
44
|
+
* Simulates sending a message from a user
|
|
45
|
+
*/
|
|
46
|
+
sendMessage(from: Entity, content: string, room: Room): Promise<Memory>;
|
|
47
|
+
/**
|
|
48
|
+
* Executes a multi-turn conversation script
|
|
49
|
+
*/
|
|
50
|
+
runConversation(script: ConversationScript): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Processes a message through the runtime's evaluation pipeline
|
|
53
|
+
*/
|
|
54
|
+
private processMessage;
|
|
55
|
+
/**
|
|
56
|
+
* Waits for all evaluators to complete processing
|
|
57
|
+
*/
|
|
58
|
+
waitForEvaluators(timeout?: number): Promise<void>;
|
|
59
|
+
/**
|
|
60
|
+
* Gets a user by name
|
|
61
|
+
*/
|
|
62
|
+
getUser(name: string): SimulatedUser | undefined;
|
|
63
|
+
/**
|
|
64
|
+
* Gets all created users
|
|
65
|
+
*/
|
|
66
|
+
getAllUsers(): SimulatedUser[];
|
|
67
|
+
/**
|
|
68
|
+
* Cleans up test data
|
|
69
|
+
*/
|
|
70
|
+
cleanup(): Promise<void>;
|
|
71
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type IAgentRuntime, type UUID } from "@elizaos/core";
|
|
2
|
+
export interface EntityExpectations {
|
|
3
|
+
names?: string[];
|
|
4
|
+
hasMetadata?: string[];
|
|
5
|
+
platformIdentities?: Array<{
|
|
6
|
+
platform: string;
|
|
7
|
+
handle: string;
|
|
8
|
+
verified?: boolean;
|
|
9
|
+
}>;
|
|
10
|
+
trustMetrics?: {
|
|
11
|
+
minHelpfulness?: number;
|
|
12
|
+
maxSuspicionLevel?: number;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export interface RelationshipExpectations {
|
|
16
|
+
exists: boolean;
|
|
17
|
+
type?: string;
|
|
18
|
+
sentiment?: "positive" | "negative" | "neutral";
|
|
19
|
+
minStrength?: number;
|
|
20
|
+
hasIndicators?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface DisputeExpectations {
|
|
23
|
+
exists: boolean;
|
|
24
|
+
disputedField?: string;
|
|
25
|
+
disputer?: string;
|
|
26
|
+
count?: number;
|
|
27
|
+
}
|
|
28
|
+
export interface PrivacyExpectations {
|
|
29
|
+
hasPrivateData: boolean;
|
|
30
|
+
sharingRestrictions?: string[];
|
|
31
|
+
}
|
|
32
|
+
export declare class ScenarioVerifier {
|
|
33
|
+
private runtime;
|
|
34
|
+
constructor(runtime: IAgentRuntime);
|
|
35
|
+
/**
|
|
36
|
+
* Verifies entity creation and metadata
|
|
37
|
+
*/
|
|
38
|
+
verifyEntity(entityId: UUID, expected: EntityExpectations): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Verifies relationship creation and properties
|
|
41
|
+
*/
|
|
42
|
+
verifyRelationship(entityA: UUID, entityB: UUID, expected: RelationshipExpectations): Promise<void>;
|
|
43
|
+
/**
|
|
44
|
+
* Verifies dispute logging
|
|
45
|
+
*/
|
|
46
|
+
verifyDispute(entityId: UUID, expected: DisputeExpectations): Promise<void>;
|
|
47
|
+
/**
|
|
48
|
+
* Verifies privacy boundaries
|
|
49
|
+
*/
|
|
50
|
+
verifyPrivacy(entityId: UUID, expected: PrivacyExpectations): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Helper method to verify component existence
|
|
53
|
+
*/
|
|
54
|
+
verifyComponent(entityId: UUID, componentType: string, shouldExist: boolean): Promise<void>;
|
|
55
|
+
/**
|
|
56
|
+
* Verifies that a mentioned person was created as an entity
|
|
57
|
+
*/
|
|
58
|
+
verifyMentionedPerson(personName: string, mentionedBy: UUID): Promise<void>;
|
|
59
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { TestSuite } from "@elizaos/core";
|
|
2
|
+
import { entityGraphTestSuite } from "./entity-graph.test";
|
|
3
|
+
import { rolodexScenarioTests } from "./scenarios.test";
|
|
4
|
+
export declare const rolodexTests: TestSuite;
|
|
5
|
+
export declare const e2eTestSuite: TestSuite;
|
|
6
|
+
export { rolodexScenarioTests, entityGraphTestSuite };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Realistic Benchmark Scenarios for the Rolodex Plugin
|
|
3
|
+
*
|
|
4
|
+
* Each scenario simulates a real-world situation the agent needs to handle.
|
|
5
|
+
* These are designed to test the full pipeline: extraction -> storage ->
|
|
6
|
+
* resolution -> querying.
|
|
7
|
+
*/
|
|
8
|
+
import { type TestSuite } from "@elizaos/core";
|
|
9
|
+
export declare const rolodexScenarioTests: TestSuite;
|
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* plugin-rolodex shared types
|
|
3
|
+
*
|
|
4
|
+
* All types used across the rolodex plugin are defined here so that
|
|
5
|
+
* services, evaluators, providers, actions, and tests share a single
|
|
6
|
+
* source of truth.
|
|
7
|
+
*/
|
|
8
|
+
import type { UUID } from "@elizaos/core";
|
|
9
|
+
/**
|
|
10
|
+
* The four tiers of information confidence.
|
|
11
|
+
*
|
|
12
|
+
* ground_truth – came from a platform API or verified source
|
|
13
|
+
* self_reported – the person said it about themselves, in a specific context
|
|
14
|
+
* hearsay – someone else said it about them
|
|
15
|
+
* inferred – the agent figured it out from evidence
|
|
16
|
+
*/
|
|
17
|
+
export type InformationTier = "ground_truth" | "self_reported" | "hearsay" | "inferred";
|
|
18
|
+
/**
|
|
19
|
+
* Where a claim is considered valid.
|
|
20
|
+
*
|
|
21
|
+
* global – universally true (e.g. a verified wallet address)
|
|
22
|
+
* platform – true on the platform where it was stated
|
|
23
|
+
* room – true only in the room it was mentioned
|
|
24
|
+
*/
|
|
25
|
+
export type ClaimScope = "global" | "platform" | "room";
|
|
26
|
+
/**
|
|
27
|
+
* The context in which a claim was made.
|
|
28
|
+
*/
|
|
29
|
+
export interface ClaimSourceContext {
|
|
30
|
+
platform: string;
|
|
31
|
+
roomId: UUID;
|
|
32
|
+
messageId?: UUID;
|
|
33
|
+
timestamp: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A corroboration is someone else confirming the same claim.
|
|
37
|
+
*/
|
|
38
|
+
export interface Corroboration {
|
|
39
|
+
entityId: UUID;
|
|
40
|
+
timestamp: number;
|
|
41
|
+
context: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A dispute is someone contradicting a claim.
|
|
45
|
+
*/
|
|
46
|
+
export interface ClaimDispute {
|
|
47
|
+
entityId: UUID;
|
|
48
|
+
alternativeValue: string;
|
|
49
|
+
timestamp: number;
|
|
50
|
+
context: string;
|
|
51
|
+
resolved: boolean;
|
|
52
|
+
resolution?: "accepted" | "rejected";
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* An InformationClaim is the atomic unit of knowledge the agent stores
|
|
56
|
+
* about entities. Every piece of information has provenance, confidence,
|
|
57
|
+
* scope, and a decay half-life.
|
|
58
|
+
*/
|
|
59
|
+
export interface InformationClaim {
|
|
60
|
+
id: UUID;
|
|
61
|
+
/** The entity this claim is *about* */
|
|
62
|
+
entityId: UUID;
|
|
63
|
+
/** What kind of information (e.g. 'twitter_handle', 'birthday', 'role') */
|
|
64
|
+
field: string;
|
|
65
|
+
/** The actual value */
|
|
66
|
+
value: string;
|
|
67
|
+
/** Knowledge tier */
|
|
68
|
+
tier: InformationTier;
|
|
69
|
+
/** Current confidence 0-1, decays over time */
|
|
70
|
+
confidence: number;
|
|
71
|
+
/** Base confidence before decay (set when created/corroborated) */
|
|
72
|
+
baseConfidence: number;
|
|
73
|
+
/** Who provided this information */
|
|
74
|
+
sourceEntityId: UUID;
|
|
75
|
+
/** Where/when it was provided */
|
|
76
|
+
sourceContext: ClaimSourceContext;
|
|
77
|
+
/** Others who confirmed it – each corroboration doubles the half-life */
|
|
78
|
+
corroborations: Corroboration[];
|
|
79
|
+
/** Others who disputed it */
|
|
80
|
+
disputes: ClaimDispute[];
|
|
81
|
+
/** Where this claim is considered valid */
|
|
82
|
+
scope: ClaimScope;
|
|
83
|
+
/** Half-life in milliseconds – confidence halves after this duration */
|
|
84
|
+
halfLifeMs: number;
|
|
85
|
+
createdAt: number;
|
|
86
|
+
updatedAt: number;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* A signal that contributes to the confidence that two entities are the
|
|
90
|
+
* same person.
|
|
91
|
+
*/
|
|
92
|
+
export interface ResolutionSignal {
|
|
93
|
+
type: ResolutionSignalType;
|
|
94
|
+
weight: number;
|
|
95
|
+
evidence: string;
|
|
96
|
+
timestamp: number;
|
|
97
|
+
}
|
|
98
|
+
export type ResolutionSignalType = "name_match" | "handle_correlation" | "project_affinity" | "shared_connections" | "temporal_proximity" | "self_identification" | "admin_confirmation" | "llm_inference";
|
|
99
|
+
/**
|
|
100
|
+
* A link between two entities that the agent believes (with some
|
|
101
|
+
* confidence) are the same person.
|
|
102
|
+
*/
|
|
103
|
+
export interface EntityLink {
|
|
104
|
+
id: UUID;
|
|
105
|
+
entityA: UUID;
|
|
106
|
+
entityB: UUID;
|
|
107
|
+
confidence: number;
|
|
108
|
+
status: EntityLinkStatus;
|
|
109
|
+
signals: ResolutionSignal[];
|
|
110
|
+
/** Who or what created this link */
|
|
111
|
+
proposedBy: "system" | UUID;
|
|
112
|
+
confirmedBy?: UUID;
|
|
113
|
+
rejectedBy?: UUID;
|
|
114
|
+
/** The merge task ID if one was created */
|
|
115
|
+
mergeTaskId?: UUID;
|
|
116
|
+
createdAt: number;
|
|
117
|
+
updatedAt: number;
|
|
118
|
+
}
|
|
119
|
+
export type EntityLinkStatus = "proposed" | "confirmed" | "rejected" | "merged";
|
|
120
|
+
/**
|
|
121
|
+
* A candidate pair returned by the candidate generator.
|
|
122
|
+
*/
|
|
123
|
+
export interface ResolutionCandidate {
|
|
124
|
+
entityA: UUID;
|
|
125
|
+
entityB: UUID;
|
|
126
|
+
/** Raw signals before scoring */
|
|
127
|
+
signals: ResolutionSignal[];
|
|
128
|
+
/** Combined score 0-1 */
|
|
129
|
+
score: number;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Relationship types the agent can detect.
|
|
133
|
+
*/
|
|
134
|
+
export type RelationshipType = "friend" | "colleague" | "family" | "community" | "acquaintance" | "mentor" | "adversarial";
|
|
135
|
+
/**
|
|
136
|
+
* A snapshot of a relationship at a point in time, used to track
|
|
137
|
+
* evolution.
|
|
138
|
+
*/
|
|
139
|
+
export interface RelationshipSnapshot {
|
|
140
|
+
type: RelationshipType;
|
|
141
|
+
strength: number;
|
|
142
|
+
sentiment: "positive" | "negative" | "neutral";
|
|
143
|
+
timestamp: number;
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Extended relationship metadata tracked by the rolodex.
|
|
147
|
+
*/
|
|
148
|
+
export interface RolodexRelationshipMetadata {
|
|
149
|
+
relationshipType: RelationshipType;
|
|
150
|
+
sentiment: "positive" | "negative" | "neutral";
|
|
151
|
+
strength: number;
|
|
152
|
+
interactionCount: number;
|
|
153
|
+
lastInteractionAt: string;
|
|
154
|
+
/** Snapshots for evolution tracking */
|
|
155
|
+
history: RelationshipSnapshot[];
|
|
156
|
+
/** Half-life for decay in ms (default 30 days) */
|
|
157
|
+
decayHalfLifeMs: number;
|
|
158
|
+
/** Base strength before decay */
|
|
159
|
+
baseStrength: number;
|
|
160
|
+
/** When strength was last recalculated */
|
|
161
|
+
lastDecayAt: number;
|
|
162
|
+
autoDetected: boolean;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* What the LLM returns when analyzing a conversation for relationships.
|
|
166
|
+
*/
|
|
167
|
+
export interface ExtractionResult {
|
|
168
|
+
platformIdentities: ExtractedIdentity[];
|
|
169
|
+
relationships: ExtractedRelationship[];
|
|
170
|
+
mentionedPeople: ExtractedMention[];
|
|
171
|
+
disputes: ExtractedDispute[];
|
|
172
|
+
privacyBoundaries: ExtractedPrivacy[];
|
|
173
|
+
trustSignals: ExtractedTrustSignal[];
|
|
174
|
+
}
|
|
175
|
+
export interface ExtractedIdentity {
|
|
176
|
+
platform: string;
|
|
177
|
+
handle: string;
|
|
178
|
+
/** Who this identity belongs to (name or reference to speaker) */
|
|
179
|
+
belongsTo: string;
|
|
180
|
+
/** How confident the LLM is */
|
|
181
|
+
confidence: number;
|
|
182
|
+
/** 'self' if the person said it about themselves, 'other' if someone else */
|
|
183
|
+
reportedBy: "self" | "other";
|
|
184
|
+
}
|
|
185
|
+
export interface ExtractedRelationship {
|
|
186
|
+
personA: string;
|
|
187
|
+
personB: string;
|
|
188
|
+
type: RelationshipType;
|
|
189
|
+
sentiment: "positive" | "negative" | "neutral";
|
|
190
|
+
confidence: number;
|
|
191
|
+
evidence: string;
|
|
192
|
+
}
|
|
193
|
+
export interface ExtractedMention {
|
|
194
|
+
name: string;
|
|
195
|
+
context: string;
|
|
196
|
+
attributes: Record<string, string>;
|
|
197
|
+
/** Whether this person is a participant or a third party */
|
|
198
|
+
isParticipant: boolean;
|
|
199
|
+
}
|
|
200
|
+
export interface ExtractedDispute {
|
|
201
|
+
/** Who is disputing */
|
|
202
|
+
disputer: string;
|
|
203
|
+
/** Whose information is being disputed */
|
|
204
|
+
about: string;
|
|
205
|
+
/** What field is being disputed */
|
|
206
|
+
field: string;
|
|
207
|
+
/** The existing value being challenged */
|
|
208
|
+
existingValue: string;
|
|
209
|
+
/** The proposed replacement */
|
|
210
|
+
proposedValue: string;
|
|
211
|
+
confidence: number;
|
|
212
|
+
}
|
|
213
|
+
export interface ExtractedPrivacy {
|
|
214
|
+
/** Who requested privacy */
|
|
215
|
+
requestedBy: string;
|
|
216
|
+
/** What should be kept private */
|
|
217
|
+
content: string;
|
|
218
|
+
/** Who it should be hidden from ('everyone', a specific name, etc.) */
|
|
219
|
+
hiddenFrom: string;
|
|
220
|
+
confidence: number;
|
|
221
|
+
}
|
|
222
|
+
export interface ExtractedTrustSignal {
|
|
223
|
+
entityName: string;
|
|
224
|
+
signal: "helpful" | "suspicious" | "authoritative" | "deceptive" | "neutral";
|
|
225
|
+
evidence: string;
|
|
226
|
+
severity: number;
|
|
227
|
+
}
|
|
228
|
+
export interface ContactCategory {
|
|
229
|
+
id: string;
|
|
230
|
+
name: string;
|
|
231
|
+
description?: string;
|
|
232
|
+
color?: string;
|
|
233
|
+
}
|
|
234
|
+
export interface ContactPreferences {
|
|
235
|
+
preferredCommunicationChannel?: string;
|
|
236
|
+
timezone?: string;
|
|
237
|
+
language?: string;
|
|
238
|
+
contactFrequency?: "daily" | "weekly" | "monthly" | "quarterly";
|
|
239
|
+
doNotDisturb?: boolean;
|
|
240
|
+
notes?: string;
|
|
241
|
+
}
|
|
242
|
+
export interface ContactInfo {
|
|
243
|
+
entityId: UUID;
|
|
244
|
+
categories: string[];
|
|
245
|
+
tags: string[];
|
|
246
|
+
preferences: ContactPreferences;
|
|
247
|
+
customFields: Record<string, string>;
|
|
248
|
+
privacyLevel: "public" | "private" | "restricted";
|
|
249
|
+
lastModified: string;
|
|
250
|
+
}
|
|
251
|
+
export interface RelationshipAnalytics {
|
|
252
|
+
strength: number;
|
|
253
|
+
interactionCount: number;
|
|
254
|
+
lastInteractionAt?: string;
|
|
255
|
+
averageResponseTime?: number;
|
|
256
|
+
sentimentScore?: number;
|
|
257
|
+
topicsDiscussed: string[];
|
|
258
|
+
}
|
|
259
|
+
export interface FollowUpSuggestion {
|
|
260
|
+
entityId: UUID;
|
|
261
|
+
entityName: string;
|
|
262
|
+
reason: string;
|
|
263
|
+
daysSinceLastContact: number;
|
|
264
|
+
relationshipStrength: number;
|
|
265
|
+
suggestedMessage?: string;
|
|
266
|
+
}
|
|
267
|
+
/** Default half-lives per information tier (in milliseconds) */
|
|
268
|
+
export declare const DEFAULT_HALF_LIVES: Record<InformationTier, number>;
|
|
269
|
+
/** Default half-life for relationship decay (30 days) */
|
|
270
|
+
export declare const DEFAULT_RELATIONSHIP_DECAY_MS: number;
|
|
271
|
+
/** Confidence thresholds for entity resolution */
|
|
272
|
+
export declare const RESOLUTION_THRESHOLDS: {
|
|
273
|
+
/** Below this, discard the candidate */
|
|
274
|
+
readonly DISCARD: 0.15;
|
|
275
|
+
/** Above this, create a merge task for review */
|
|
276
|
+
readonly PROPOSE: 0.25;
|
|
277
|
+
/** Above this, auto-confirm the link (still creates a task for record) */
|
|
278
|
+
readonly AUTO_CONFIRM: 0.85;
|
|
279
|
+
};
|
|
280
|
+
/** Weights for each resolution signal type */
|
|
281
|
+
export declare const SIGNAL_WEIGHTS: Record<ResolutionSignalType, number>;
|