@indexnetwork/protocol 3.13.0-rc.288.1 → 4.1.1-rc.290.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/dist/chat/chat.prompt.js +25 -25
- package/dist/chat/chat.prompt.js.map +1 -1
- package/dist/chat/chat.prompt.modules.js +8 -8
- package/dist/chat/chat.prompt.modules.js.map +1 -1
- package/dist/chat/tests/chat.graph.mocks.d.ts +1 -7
- package/dist/chat/tests/chat.graph.mocks.d.ts.map +1 -1
- package/dist/chat/tests/chat.graph.mocks.js +1 -2
- package/dist/chat/tests/chat.graph.mocks.js.map +1 -1
- package/dist/contact/contact.tools.js +3 -3
- package/dist/contact/contact.tools.js.map +1 -1
- package/dist/{profile/profile.enricher.d.ts → enrichment/enrichment.enricher.d.ts} +1 -1
- package/dist/enrichment/enrichment.enricher.d.ts.map +1 -0
- package/dist/{profile/profile.enricher.js → enrichment/enrichment.enricher.js} +1 -1
- package/dist/enrichment/enrichment.enricher.js.map +1 -0
- package/dist/{profile/profile.generator.d.ts → enrichment/enrichment.generator.d.ts} +3 -3
- package/dist/enrichment/enrichment.generator.d.ts.map +1 -0
- package/dist/{profile/profile.generator.js → enrichment/enrichment.generator.js} +6 -6
- package/dist/enrichment/enrichment.generator.js.map +1 -0
- package/dist/{profile/profile.graph.d.ts → enrichment/enrichment.graph.d.ts} +61 -201
- package/dist/enrichment/enrichment.graph.d.ts.map +1 -0
- package/dist/{profile/profile.graph.js → enrichment/enrichment.graph.js} +7 -7
- package/dist/enrichment/enrichment.graph.js.map +1 -0
- package/dist/{profile/profile.state.d.ts → enrichment/enrichment.state.d.ts} +8 -32
- package/dist/enrichment/enrichment.state.d.ts.map +1 -0
- package/dist/{profile/profile.state.js → enrichment/enrichment.state.js} +2 -2
- package/dist/enrichment/enrichment.state.js.map +1 -0
- package/dist/enrichment/enrichment.tools.d.ts +3 -0
- package/dist/enrichment/enrichment.tools.d.ts.map +1 -0
- package/dist/{profile/profile.tools.js → enrichment/enrichment.tools.js} +119 -132
- package/dist/enrichment/enrichment.tools.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/intent/intent.graph.d.ts.map +1 -1
- package/dist/intent/intent.graph.js +7 -6
- package/dist/intent/intent.graph.js.map +1 -1
- package/dist/intent/intent.tools.js +5 -5
- package/dist/intent/intent.tools.js.map +1 -1
- package/dist/mcp/mcp.server.d.ts +1 -1
- package/dist/mcp/mcp.server.d.ts.map +1 -1
- package/dist/mcp/mcp.server.js +12 -4
- package/dist/mcp/mcp.server.js.map +1 -1
- package/dist/negotiation/negotiation.tools.js +1 -1
- package/dist/negotiation/negotiation.tools.js.map +1 -1
- package/dist/network/network.tools.js +2 -2
- package/dist/network/network.tools.js.map +1 -1
- package/dist/opportunity/opportunity.graph.d.ts +9 -15
- package/dist/opportunity/opportunity.graph.d.ts.map +1 -1
- package/dist/opportunity/opportunity.graph.js +12 -29
- package/dist/opportunity/opportunity.graph.js.map +1 -1
- package/dist/opportunity/opportunity.presenter.d.ts.map +1 -1
- package/dist/opportunity/opportunity.presenter.js +3 -11
- package/dist/opportunity/opportunity.presenter.js.map +1 -1
- package/dist/opportunity/opportunity.state.d.ts +4 -10
- package/dist/opportunity/opportunity.state.d.ts.map +1 -1
- package/dist/opportunity/opportunity.state.js +1 -1
- package/dist/opportunity/opportunity.state.js.map +1 -1
- package/dist/opportunity/opportunity.tools.js +8 -8
- package/dist/opportunity/opportunity.tools.js.map +1 -1
- package/dist/questioner/questioner.presets.js +1 -1
- package/dist/questioner/questioner.presets.js.map +1 -1
- package/dist/questioner/questioner.tools.d.ts +1 -1
- package/dist/questioner/questioner.tools.js +2 -2
- package/dist/questioner/questioner.tools.js.map +1 -1
- package/dist/shared/agent/tool.factory.js +6 -6
- package/dist/shared/agent/tool.factory.js.map +1 -1
- package/dist/shared/agent/tool.helpers.d.ts +8 -8
- package/dist/shared/agent/tool.helpers.d.ts.map +1 -1
- package/dist/shared/agent/tool.helpers.js.map +1 -1
- package/dist/shared/agent/tool.registry.d.ts.map +1 -1
- package/dist/shared/agent/tool.registry.js +28 -2
- package/dist/shared/agent/tool.registry.js.map +1 -1
- package/dist/shared/agent/tool.runtime.d.ts.map +1 -1
- package/dist/shared/agent/tool.runtime.js +6 -0
- package/dist/shared/agent/tool.runtime.js.map +1 -1
- package/dist/shared/agent/utility.tools.js +5 -5
- package/dist/shared/agent/utility.tools.js.map +1 -1
- package/dist/shared/hyde/hyde.graph.d.ts +6 -6
- package/dist/shared/hyde/hyde.state.d.ts +2 -2
- package/dist/shared/hyde/hyde.state.js.map +1 -1
- package/dist/shared/interfaces/database.interface.d.ts +16 -16
- package/dist/shared/interfaces/database.interface.d.ts.map +1 -1
- package/dist/shared/interfaces/database.interface.js.map +1 -1
- package/dist/shared/interfaces/{profile-run.interface.d.ts → enrichment-run.interface.d.ts} +21 -21
- package/dist/shared/interfaces/enrichment-run.interface.d.ts.map +1 -0
- package/dist/shared/interfaces/enrichment-run.interface.js +2 -0
- package/dist/shared/interfaces/enrichment-run.interface.js.map +1 -0
- package/dist/shared/schemas/discovery-question.schema.d.ts +2 -2
- package/dist/shared/schemas/identity.schema.d.ts +45 -0
- package/dist/shared/schemas/identity.schema.d.ts.map +1 -0
- package/dist/shared/schemas/identity.schema.js +20 -0
- package/dist/shared/schemas/identity.schema.js.map +1 -0
- package/dist/shared/schemas/question.schema.d.ts +4 -4
- package/dist/shared/schemas/question.schema.d.ts.map +1 -1
- package/dist/shared/schemas/question.schema.js +1 -1
- package/dist/shared/schemas/question.schema.js.map +1 -1
- package/package.json +1 -1
- package/dist/profile/profile.enricher.d.ts.map +0 -1
- package/dist/profile/profile.enricher.js.map +0 -1
- package/dist/profile/profile.generator.d.ts.map +0 -1
- package/dist/profile/profile.generator.js.map +0 -1
- package/dist/profile/profile.graph.d.ts.map +0 -1
- package/dist/profile/profile.graph.js.map +0 -1
- package/dist/profile/profile.state.d.ts.map +0 -1
- package/dist/profile/profile.state.js.map +0 -1
- package/dist/profile/profile.tools.d.ts +0 -3
- package/dist/profile/profile.tools.d.ts.map +0 -1
- package/dist/profile/profile.tools.js.map +0 -1
- package/dist/shared/interfaces/profile-run.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/profile-run.interface.js +0 -2
- package/dist/shared/interfaces/profile-run.interface.js.map +0 -1
- package/dist/shared/schemas/profile.schema.d.ts +0 -100
- package/dist/shared/schemas/profile.schema.d.ts.map +0 -1
- package/dist/shared/schemas/profile.schema.js +0 -26
- package/dist/shared/schemas/profile.schema.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chat.graph.mocks.js","sourceRoot":"/","sources":["chat/tests/chat.graph.mocks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA+CH,MAAM,IAAI,GAAG,KAAK,IAAwB,EAAE,CAAC,SAAS,CAAC;AACvD,MAAM,SAAS,GAAG,KAAK,IAAqB,EAAE,CAAC,EAAE,CAAC;AAClD,MAAM,QAAQ,GAAG,KAAK,IAAmB,EAAE,CAAC,IAAI,CAAC;AACjD,MAAM,QAAQ,GAAG,KAAK,IAAsB,EAAE,CAAC,KAAK,CAAC;AAErD,MAAM,iBAAiB,GAAG,GAAe,EAAE,CAAC,CAAC;IAC3C,EAAE,EAAE,EAAE;IACN,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE;QACX,UAAU,EAAE,QAAQ;QACpB,mBAAmB,EAAE,KAAK;QAC1B,cAAc,EAAE,IAAI;KACrB;IACD,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,IAAI,IAAI,EAAE;IACrB,SAAS,EAAE,IAAI,IAAI,EAAE;IACrB,WAAW,EAAE,CAAC;IACd,WAAW,EAAE,CAAC;IACd,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,M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I,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC;gBACxD,8DAA8D;aAC7D,CAAQ,CAAC;QACZ,CAAC;QACD,8DAA8D;QAC9D,oBAAoB,EAAE,CAAC,EAAO,EAAE,OAAe,EAAE,MAAgB,EAAE,EAAE;YACnE,OAAO,IAAI,KAAK,CAAC,EAAE,EAAE;gBACnB,GAAG,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC;gBACxD,8DAA8D;aAC7D,CAAQ,CAAC;QACZ,CAAC;QACD,GAAG,SAAS;KACG,CAAC;AACpB,CAAC","sourcesContent":["/**\n * Configurable mock database and fixture data for chat graph workflow tests.\n * Use createChatGraphMockDb(config) to get a full ChatGraphCompositeDatabase\n * with controllable profile, intents, index membership, and opportunities.\n */\n\nimport type { ChatGraphCompositeDatabase, CreateIntentData, ActiveIntent, IndexedIntentDetails, NetworkMembership, OwnedIndex, UserRecord, Opportunity, OpportunityStatus } from \"../../shared/interfaces/database.interface.js\";\nimport type { ChatSessionReader } from \"../../shared/interfaces/chat-session.interface.js\";\nimport type { ProtocolDeps } from \"../../shared/agent/tool.helpers.js\";\n\n// Minimal profile shape for getProfileByUserId (avoids importing ProfileDocument)\nexport interface MockProfileFixture {\n id: string;\n userId: string;\n identity: { name: string; bio: string; location: string };\n narrative: { context: string };\n attributes: { skills: string[]; interests: string[] };\n embedding: number[] | null;\n}\n\nexport interface ChatGraphMockConfig {\n /** Profile for the session user (null = no profile). */\n profile?: MockProfileFixture | null;\n /** Active intents per userId (global scope). */\n activeIntents?: (userId: string) => ActiveIntent[] | Promise<ActiveIntent[]>;\n /** Intents in index for a member (userId, networkId) -> member's intents in that index. */\n intentsInIndexForMember?: (\n userId: string,\n networkId: string\n ) => ActiveIntent[] | Promise<ActiveIntent[]>;\n /** All intents in index (owner view). (networkId, requestingUserId) -> details. */\n indexIntentsForOwner?: (\n networkId: string,\n requestingUserId: string\n ) => IndexedIntentDetails[] | Promise<IndexedIntentDetails[]>;\n /** Opportunities for user. */\n opportunitiesForUser?: (userId: string) => Opportunity[] | Promise<Opportunity[]>;\n /** Network memberships for user. */\n networkMemberships?: (userId: string) => NetworkMembership[] | Promise<NetworkMembership[]>;\n /** Index by id (for scope validation). */\n getNetwork?: (networkId: string) => { id: string; title: string } | null | Promise<{ id: string; title: string } | null>;\n /** (networkId, userId) -> is member. */\n isNetworkMember?: (networkId: string, userId: string) => boolean | Promise<boolean>;\n /** (networkId, userId) -> is owner. */\n isIndexOwner?: (networkId: string, userId: string) => boolean | Promise<boolean>;\n /** User record by id. */\n getUser?: (userId: string) => UserRecord | null | Promise<UserRecord | null>;\n /** Owned indexes for user. */\n ownedIndexes?: (userId: string) => OwnedIndex[] | Promise<OwnedIndex[]>;\n}\n\nconst noop = async (): Promise<undefined> => undefined;\nconst noopArray = async <T>(): Promise<T[]> => [];\nconst noopNull = async (): Promise<null> => null;\nconst noopBool = async (): Promise<boolean> => false;\n\nconst defaultOwnedIndex = (): OwnedIndex => ({\n id: \"\",\n title: \"\",\n prompt: null,\n imageUrl: null,\n permissions: {\n joinPolicy: \"anyone\",\n allowGuestVibeCheck: false,\n invitationLink: null,\n },\n isPersonal: false,\n createdAt: new Date(),\n updatedAt: new Date(),\n memberCount: 0,\n intentCount: 0,\n user: { id: \"\", name: \"\", avatar: null },\n _count: { members: 0 },\n});\n\n/** Actor shape for opportunity mocks (role determines visibility). */\nexport type MockOpportunityActor = { networkId: string; userId: string; role: \"introducer\" | \"patient\" | \"agent\" | \"peer\" | \"party\"; intent?: string };\n\n/** Build a minimal Opportunity for list_opportunities / discover_opportunities tests. */\nexport function mockOpportunity(overrides: {\n id?: string;\n status?: OpportunityStatus;\n networkId?: string;\n /** Current user (must be one of the actors so they \"have\" this opportunity). */\n currentUserId?: string;\n /** Other party user ids (role \"party\"); tool resolves names via getUser. Ignored if actors is provided. */\n otherPartyUserIds?: string[];\n /** Override actors with specific roles for role-based visibility tests. */\n actors?: MockOpportunityActor[];\n}): Opportunity {\n const id = overrides.id ?? `opp-${Date.now()}`;\n const networkId = overrides.networkId ?? \"idx-1\";\n const otherIds = overrides.otherPartyUserIds ?? [\"user-alice\"];\n const currentUserId = overrides.currentUserId ?? \"current-user\";\n const actors = overrides.actors ?? [\n { networkId, userId: currentUserId, role: \"party\" as const },\n ...otherIds.map((userId) => ({ networkId, userId, role: \"party\" as const })),\n ];\n return {\n id,\n detection: {\n source: \"opportunity_graph\" as const,\n timestamp: new Date().toISOString(),\n },\n actors,\n interpretation: { category: \"connection\", reasoning: \"Match\", confidence: 0.8 },\n context: { networkId },\n confidence: \"0.8\",\n status: overrides.status ?? \"latent\",\n createdAt: new Date(),\n updatedAt: new Date(),\n expiresAt: null,\n } as Opportunity;\n}\n\n/** Build a minimal IndexedIntentDetails for owner view. */\nexport function mockIndexedIntent(overrides: {\n id?: string;\n payload?: string;\n userId?: string;\n userName?: string;\n}): IndexedIntentDetails {\n return {\n id: overrides.id ?? `intent-${Date.now()}`,\n payload: overrides.payload ?? \"Looking for a co-founder\",\n summary: null,\n userId: overrides.userId ?? \"user-1\",\n userName: overrides.userName ?? \"Alice\",\n createdAt: new Date(),\n };\n}\n\n/** Build a minimal ActiveIntent. */\nexport function mockActiveIntent(overrides: { id?: string; payload?: string }): ActiveIntent {\n return {\n id: overrides.id ?? `intent-${Date.now()}`,\n payload: overrides.payload ?? \"Looking for a technical co-founder\",\n summary: null,\n createdAt: new Date(),\n };\n}\n\n/** Build a minimal profile fixture. */\nexport function mockProfile(overrides: { userId?: string; name?: string }): MockProfileFixture {\n const userId = overrides.userId ?? \"user-1\";\n return {\n id: `profile-${userId}`,\n userId,\n identity: {\n name: overrides.name ?? \"Test User\",\n bio: \"Test bio\",\n location: \"NYC\",\n },\n narrative: { context: \"Test context\" },\n attributes: { skills: [\"TypeScript\"], interests: [\"AI\"] },\n embedding: null,\n };\n}\n\n/**\n * Create a ChatGraphCompositeDatabase mock from config.\n * Any method not overridden by config uses a safe noop/default.\n */\nexport function createChatGraphMockDb(\n config: ChatGraphMockConfig = {}\n): ChatGraphCompositeDatabase {\n const profile = config.profile ?? null;\n const activeIntents = config.activeIntents ?? (() => []);\n const intentsInIndexForMember = config.intentsInIndexForMember ?? (() => []);\n const indexIntentsForOwner = config.indexIntentsForOwner ?? (() => []);\n const opportunitiesForUser = config.opportunitiesForUser ?? (() => []);\n const networkMemberships = config.networkMemberships ?? (() => []);\n const getNetwork = config.getNetwork ?? (() => null);\n const isNetworkMember = config.isNetworkMember ?? (() => false);\n const isIndexOwner = config.isIndexOwner ?? (() => false);\n const getUser =\n config.getUser ??\n ((userId: string): UserRecord => ({ id: userId, name: \"Test User\", email: \"test@example.com\", socials: [] }));\n const ownedIndexes = config.ownedIndexes ?? (() => []);\n\n return {\n getProfile: async () => (profile ? { ...profile } : null),\n getProfileByUserId: async () => (profile ? { ...profile } : null),\n getActiveIntents: async (userId: string) =>\n Promise.resolve(activeIntents(userId)).then((f) => (Array.isArray(f) ? f : [])),\n getIntentsInIndexForMember: async (userId: string, networkId: string) =>\n Promise.resolve(intentsInIndexForMember(userId, networkId)).then((f) =>\n Array.isArray(f) ? f : []\n ),\n getUser: async (userId: string) => Promise.resolve(getUser(userId)),\n updateUser: async (userId: string, data: any) => ({\n id: userId,\n name: data?.name ?? 'Test User',\n email: 'test@example.com',\n socials: data?.socials ?? null,\n location: data?.location ?? null,\n }),\n saveProfile: noop,\n createIntent: async (data: CreateIntentData) => ({\n id: `intent-${Date.now()}`,\n payload: data.payload,\n summary: null,\n isIncognito: false,\n createdAt: new Date(),\n updatedAt: new Date(),\n userId: data.userId,\n }),\n updateIntent: noopNull,\n archiveIntent: async () => ({ success: true }),\n getUserIndexIds: async (userId: string) => {\n const memberships = await Promise.resolve(networkMemberships(userId));\n return Array.isArray(memberships) ? memberships.map((m) => m.networkId) : [];\n },\n getNetworkMemberships: async (userId: string) =>\n Promise.resolve(networkMemberships(userId)).then((f) => (Array.isArray(f) ? f : [])),\n getNetwork: async (networkId: string) => Promise.resolve(getNetwork(networkId)),\n getNetworkMembership: async (networkId: string, userId: string) => {\n const index = await Promise.resolve(getNetwork(networkId));\n if (!index) return null;\n const member = await Promise.resolve(isNetworkMember(networkId, userId));\n return member ? { networkId, networkTitle: index.title, indexPrompt: null, permissions: [] } : null;\n },\n getNetworkWithPermissions: async () => null,\n getIntentForIndexing: noopNull,\n getNetworkMemberContext: noopNull,\n getNegotiationTaskForOpportunity: noopNull,\n getOpportunitiesForUser: async (userId: string) =>\n Promise.resolve(opportunitiesForUser(userId)).then((f) => (Array.isArray(f) ? f : [])),\n createOpportunity: async () => mockOpportunity({ currentUserId: \"system\" }) as Opportunity,\n getOpportunity: noopNull,\n opportunityExistsBetweenActors: async () => false,\n findOpportunitiesByActors: async () => [],\n updateOpportunityStatus: noopNull,\n getHydeDocument: noopNull,\n getHydeDocumentsForSource: noopArray,\n saveHydeDocument: noop,\n getIntent: noopNull,\n isIntentAssignedToIndex: noopBool,\n assignIntentToNetwork: noop,\n unassignIntentFromIndex: noop,\n getNetworkIdsForIntent: noopArray,\n getOwnedIndexes: async (userId: string) =>\n Promise.resolve(ownedIndexes(userId)).then((f) => (Array.isArray(f) ? f : [])),\n isIndexOwner: async (networkId: string, userId: string) =>\n Promise.resolve(isIndexOwner(networkId, userId)),\n isNetworkMember: async (networkId: string, userId: string) =>\n Promise.resolve(isNetworkMember(networkId, userId)),\n getNetworkMembersForOwner: noopArray,\n getNetworkMembersForMember: noopArray,\n getMembersFromUserIndexes: async () => [],\n removeMemberFromIndex: async () => ({ success: true }),\n getNetworkIntentsForOwner: async (networkId: string, requestingUserId: string, opts?: { limit?: number; offset?: number }) =>\n Promise.resolve(indexIntentsForOwner(networkId, requestingUserId)).then((f) =>\n Array.isArray(f) ? f : []\n ),\n getNetworkIntentsForMember: async () => [],\n updateIndexSettings: async () => defaultOwnedIndex(),\n softDeleteNetwork: noop,\n deleteProfile: noop,\n createNetwork: async () => defaultOwnedIndex(),\n getNetworkMemberCount: async () => 0,\n addMemberToNetwork: noop,\n } as unknown as ChatGraphCompositeDatabase;\n}\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// MOCK CHAT SESSION READER & PROTOCOL DEPS\n// ═══════════════════════════════════════════════════════════════════════════════\n\n/** Mock ChatSessionReader with stub implementations for graph tests. */\nexport const mockChatSessionReader: ChatSessionReader = {\n getSessionMessages: async () => [],\n listSessions: async () => [],\n getSession: async () => null,\n};\n\n/**\n * Create a mock ProtocolDeps with stub implementations for all fields.\n * Pass overrides to customise individual deps for specific tests.\n */\nexport function createMockProtocolDeps(overrides?: Partial<ProtocolDeps>): ProtocolDeps {\n // NOTE: database, embedder, scraper are intentionally omitted.\n // ChatGraphFactory spreads protocolDeps over {database, embedder, scraper, ...},\n // so including stubs here would overwrite the real mocks passed to the constructor.\n return {\n cache: { get: async () => null, set: async () => {}, delete: async () => false, exists: async () => false, mget: async () => [], deleteByPattern: async () => 0 },\n hydeCache: { get: async () => null, set: async () => {}, delete: async () => false, exists: async () => false },\n \n integration: { createSession: async () => ({ toolkits: async () => ({ items: [] }), authorize: async () => ({ redirectUrl: \"\" }) }), executeToolAction: async () => ({ successful: true }), listConnections: async () => [], getAuthUrl: async () => ({ redirectUrl: \"\" }), disconnect: async () => ({ success: true }) } as unknown as ProtocolDeps[\"integration\"],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n intentQueue: { addGenerateHydeJob: async () => ({}), addDeleteHydeJob: async () => ({}) } as any,\n contactService: { importContacts: async () => ({ imported: 0, skipped: 0, newContacts: 0, existingContacts: 0, details: [] }), listContacts: async () => [], addContact: async () => ({ userId: \"\", isNew: false, isGhost: false }), removeContact: async () => {} } as unknown as ProtocolDeps[\"contactService\"],\n chatSession: mockChatSessionReader,\n enricher: { enrichUserProfile: async () => null } as unknown as ProtocolDeps[\"enricher\"],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n negotiationDatabase: {} as any,\n integrationImporter: { importContacts: async () => ({ imported: 0, skipped: 0, newContacts: 0, existingContacts: 0 }) },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n createUserDatabase: (db: any, _userId: string) => {\n return new Proxy({}, {\n get: (_target, prop) => db[prop] ?? (async () => null),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n }) as any;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n createSystemDatabase: (db: any, _userId: string, _scope: string[]) => {\n return new Proxy({}, {\n get: (_target, prop) => db[prop] ?? (async () => null),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n }) as any;\n },\n ...overrides,\n } as ProtocolDeps;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chat.graph.mocks.js","sourceRoot":"/","sources":["chat/tests/chat.graph.mocks.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AA8CH,MAAM,IAAI,GAAG,KAAK,IAAwB,EAAE,CAAC,SAAS,CAAC;AACvD,MAAM,SAAS,GAAG,KAAK,IAAqB,EAAE,CAAC,EAAE,CAAC;AAClD,MAAM,QAAQ,GAAG,KAAK,IAAmB,EAAE,CAAC,IAAI,CAAC;AACjD,MAAM,QAAQ,GAAG,KAAK,IAAsB,EAAE,CAAC,KAAK,CAAC;AAErD,MAAM,iBAAiB,GAAG,GAAe,EAAE,CAAC,CAAC;IAC3C,EAAE,EAAE,EAAE;IACN,KAAK,EAAE,EAAE;IACT,MAAM,EAAE,IAAI;IACZ,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE;QACX,UAAU,EAAE,QAAQ;QACpB,mBAAmB,EAAE,KAAK;QAC1B,cAAc,EAAE,IAAI;KACrB;IACD,UAAU,EAAE,KAAK;IACjB,SAAS,EAAE,IAAI,IAAI,EAAE;IACrB,SAAS,EAAE,IAAI,IAAI,EAAE;IACrB,WAAW,EAAE,CAAC;IACd,WAAW,EAAE,CAAC;IACd,IAAI,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,E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,8DAA8D;QAC9D,oBAAoB,EAAE,CAAC,EAAO,EAAE,OAAe,EAAE,MAAgB,EAAE,EAAE;YACnE,OAAO,IAAI,KAAK,CAAC,EAAE,EAAE;gBACnB,GAAG,EAAE,CAAC,OAAO,EAAE,IAAI,EAAE,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE,CAAC,IAAI,CAAC;gBACxD,8DAA8D;aAC7D,CAAQ,CAAC;QACZ,CAAC;QACD,GAAG,SAAS;KACG,CAAC;AACpB,CAAC","sourcesContent":["/**\n * Configurable mock database and fixture data for chat graph workflow tests.\n * Use createChatGraphMockDb(config) to get a full ChatGraphCompositeDatabase\n * with controllable profile, intents, index membership, and opportunities.\n */\n\nimport type { ChatGraphCompositeDatabase, CreateIntentData, ActiveIntent, IndexedIntentDetails, NetworkMembership, OwnedIndex, UserRecord, Opportunity, OpportunityStatus } from \"../../shared/interfaces/database.interface.js\";\nimport type { ChatSessionReader } from \"../../shared/interfaces/chat-session.interface.js\";\nimport type { ProtocolDeps } from \"../../shared/agent/tool.helpers.js\";\n\n// Minimal profile shape for getProfileByUserId (UserIdentity-shaped: identity + context)\nexport interface MockProfileFixture {\n id: string;\n userId: string;\n identity: { name: string; bio: string; location: string };\n context: string;\n embedding: number[] | null;\n}\n\nexport interface ChatGraphMockConfig {\n /** Profile for the session user (null = no profile). */\n profile?: MockProfileFixture | null;\n /** Active intents per userId (global scope). */\n activeIntents?: (userId: string) => ActiveIntent[] | Promise<ActiveIntent[]>;\n /** Intents in index for a member (userId, networkId) -> member's intents in that index. */\n intentsInIndexForMember?: (\n userId: string,\n networkId: string\n ) => ActiveIntent[] | Promise<ActiveIntent[]>;\n /** All intents in index (owner view). (networkId, requestingUserId) -> details. */\n indexIntentsForOwner?: (\n networkId: string,\n requestingUserId: string\n ) => IndexedIntentDetails[] | Promise<IndexedIntentDetails[]>;\n /** Opportunities for user. */\n opportunitiesForUser?: (userId: string) => Opportunity[] | Promise<Opportunity[]>;\n /** Network memberships for user. */\n networkMemberships?: (userId: string) => NetworkMembership[] | Promise<NetworkMembership[]>;\n /** Index by id (for scope validation). */\n getNetwork?: (networkId: string) => { id: string; title: string } | null | Promise<{ id: string; title: string } | null>;\n /** (networkId, userId) -> is member. */\n isNetworkMember?: (networkId: string, userId: string) => boolean | Promise<boolean>;\n /** (networkId, userId) -> is owner. */\n isIndexOwner?: (networkId: string, userId: string) => boolean | Promise<boolean>;\n /** User record by id. */\n getUser?: (userId: string) => UserRecord | null | Promise<UserRecord | null>;\n /** Owned indexes for user. */\n ownedIndexes?: (userId: string) => OwnedIndex[] | Promise<OwnedIndex[]>;\n}\n\nconst noop = async (): Promise<undefined> => undefined;\nconst noopArray = async <T>(): Promise<T[]> => [];\nconst noopNull = async (): Promise<null> => null;\nconst noopBool = async (): Promise<boolean> => false;\n\nconst defaultOwnedIndex = (): OwnedIndex => ({\n id: \"\",\n title: \"\",\n prompt: null,\n imageUrl: null,\n permissions: {\n joinPolicy: \"anyone\",\n allowGuestVibeCheck: false,\n invitationLink: null,\n },\n isPersonal: false,\n createdAt: new Date(),\n updatedAt: new Date(),\n memberCount: 0,\n intentCount: 0,\n user: { id: \"\", name: \"\", avatar: null },\n _count: { members: 0 },\n});\n\n/** Actor shape for opportunity mocks (role determines visibility). */\nexport type MockOpportunityActor = { networkId: string; userId: string; role: \"introducer\" | \"patient\" | \"agent\" | \"peer\" | \"party\"; intent?: string };\n\n/** Build a minimal Opportunity for list_opportunities / discover_opportunities tests. */\nexport function mockOpportunity(overrides: {\n id?: string;\n status?: OpportunityStatus;\n networkId?: string;\n /** Current user (must be one of the actors so they \"have\" this opportunity). */\n currentUserId?: string;\n /** Other party user ids (role \"party\"); tool resolves names via getUser. Ignored if actors is provided. */\n otherPartyUserIds?: string[];\n /** Override actors with specific roles for role-based visibility tests. */\n actors?: MockOpportunityActor[];\n}): Opportunity {\n const id = overrides.id ?? `opp-${Date.now()}`;\n const networkId = overrides.networkId ?? \"idx-1\";\n const otherIds = overrides.otherPartyUserIds ?? [\"user-alice\"];\n const currentUserId = overrides.currentUserId ?? \"current-user\";\n const actors = overrides.actors ?? [\n { networkId, userId: currentUserId, role: \"party\" as const },\n ...otherIds.map((userId) => ({ networkId, userId, role: \"party\" as const })),\n ];\n return {\n id,\n detection: {\n source: \"opportunity_graph\" as const,\n timestamp: new Date().toISOString(),\n },\n actors,\n interpretation: { category: \"connection\", reasoning: \"Match\", confidence: 0.8 },\n context: { networkId },\n confidence: \"0.8\",\n status: overrides.status ?? \"latent\",\n createdAt: new Date(),\n updatedAt: new Date(),\n expiresAt: null,\n } as Opportunity;\n}\n\n/** Build a minimal IndexedIntentDetails for owner view. */\nexport function mockIndexedIntent(overrides: {\n id?: string;\n payload?: string;\n userId?: string;\n userName?: string;\n}): IndexedIntentDetails {\n return {\n id: overrides.id ?? `intent-${Date.now()}`,\n payload: overrides.payload ?? \"Looking for a co-founder\",\n summary: null,\n userId: overrides.userId ?? \"user-1\",\n userName: overrides.userName ?? \"Alice\",\n createdAt: new Date(),\n };\n}\n\n/** Build a minimal ActiveIntent. */\nexport function mockActiveIntent(overrides: { id?: string; payload?: string }): ActiveIntent {\n return {\n id: overrides.id ?? `intent-${Date.now()}`,\n payload: overrides.payload ?? \"Looking for a technical co-founder\",\n summary: null,\n createdAt: new Date(),\n };\n}\n\n/** Build a minimal profile fixture. */\nexport function mockProfile(overrides: { userId?: string; name?: string }): MockProfileFixture {\n const userId = overrides.userId ?? \"user-1\";\n return {\n id: `profile-${userId}`,\n userId,\n identity: {\n name: overrides.name ?? \"Test User\",\n bio: \"Test bio\",\n location: \"NYC\",\n },\n context: \"Test context\",\n embedding: null,\n };\n}\n\n/**\n * Create a ChatGraphCompositeDatabase mock from config.\n * Any method not overridden by config uses a safe noop/default.\n */\nexport function createChatGraphMockDb(\n config: ChatGraphMockConfig = {}\n): ChatGraphCompositeDatabase {\n const profile = config.profile ?? null;\n const activeIntents = config.activeIntents ?? (() => []);\n const intentsInIndexForMember = config.intentsInIndexForMember ?? (() => []);\n const indexIntentsForOwner = config.indexIntentsForOwner ?? (() => []);\n const opportunitiesForUser = config.opportunitiesForUser ?? (() => []);\n const networkMemberships = config.networkMemberships ?? (() => []);\n const getNetwork = config.getNetwork ?? (() => null);\n const isNetworkMember = config.isNetworkMember ?? (() => false);\n const isIndexOwner = config.isIndexOwner ?? (() => false);\n const getUser =\n config.getUser ??\n ((userId: string): UserRecord => ({ id: userId, name: \"Test User\", email: \"test@example.com\", socials: [] }));\n const ownedIndexes = config.ownedIndexes ?? (() => []);\n\n return {\n getProfile: async () => (profile ? { ...profile } : null),\n getProfileByUserId: async () => (profile ? { ...profile } : null),\n getActiveIntents: async (userId: string) =>\n Promise.resolve(activeIntents(userId)).then((f) => (Array.isArray(f) ? f : [])),\n getIntentsInIndexForMember: async (userId: string, networkId: string) =>\n Promise.resolve(intentsInIndexForMember(userId, networkId)).then((f) =>\n Array.isArray(f) ? f : []\n ),\n getUser: async (userId: string) => Promise.resolve(getUser(userId)),\n updateUser: async (userId: string, data: any) => ({\n id: userId,\n name: data?.name ?? 'Test User',\n email: 'test@example.com',\n socials: data?.socials ?? null,\n location: data?.location ?? null,\n }),\n saveProfile: noop,\n createIntent: async (data: CreateIntentData) => ({\n id: `intent-${Date.now()}`,\n payload: data.payload,\n summary: null,\n isIncognito: false,\n createdAt: new Date(),\n updatedAt: new Date(),\n userId: data.userId,\n }),\n updateIntent: noopNull,\n archiveIntent: async () => ({ success: true }),\n getUserIndexIds: async (userId: string) => {\n const memberships = await Promise.resolve(networkMemberships(userId));\n return Array.isArray(memberships) ? memberships.map((m) => m.networkId) : [];\n },\n getNetworkMemberships: async (userId: string) =>\n Promise.resolve(networkMemberships(userId)).then((f) => (Array.isArray(f) ? f : [])),\n getNetwork: async (networkId: string) => Promise.resolve(getNetwork(networkId)),\n getNetworkMembership: async (networkId: string, userId: string) => {\n const index = await Promise.resolve(getNetwork(networkId));\n if (!index) return null;\n const member = await Promise.resolve(isNetworkMember(networkId, userId));\n return member ? { networkId, networkTitle: index.title, indexPrompt: null, permissions: [] } : null;\n },\n getNetworkWithPermissions: async () => null,\n getIntentForIndexing: noopNull,\n getNetworkMemberContext: noopNull,\n getNegotiationTaskForOpportunity: noopNull,\n getOpportunitiesForUser: async (userId: string) =>\n Promise.resolve(opportunitiesForUser(userId)).then((f) => (Array.isArray(f) ? f : [])),\n createOpportunity: async () => mockOpportunity({ currentUserId: \"system\" }) as Opportunity,\n getOpportunity: noopNull,\n opportunityExistsBetweenActors: async () => false,\n findOpportunitiesByActors: async () => [],\n updateOpportunityStatus: noopNull,\n getHydeDocument: noopNull,\n getHydeDocumentsForSource: noopArray,\n saveHydeDocument: noop,\n getIntent: noopNull,\n isIntentAssignedToIndex: noopBool,\n assignIntentToNetwork: noop,\n unassignIntentFromIndex: noop,\n getNetworkIdsForIntent: noopArray,\n getOwnedIndexes: async (userId: string) =>\n Promise.resolve(ownedIndexes(userId)).then((f) => (Array.isArray(f) ? f : [])),\n isIndexOwner: async (networkId: string, userId: string) =>\n Promise.resolve(isIndexOwner(networkId, userId)),\n isNetworkMember: async (networkId: string, userId: string) =>\n Promise.resolve(isNetworkMember(networkId, userId)),\n getNetworkMembersForOwner: noopArray,\n getNetworkMembersForMember: noopArray,\n getMembersFromUserIndexes: async () => [],\n removeMemberFromIndex: async () => ({ success: true }),\n getNetworkIntentsForOwner: async (networkId: string, requestingUserId: string, opts?: { limit?: number; offset?: number }) =>\n Promise.resolve(indexIntentsForOwner(networkId, requestingUserId)).then((f) =>\n Array.isArray(f) ? f : []\n ),\n getNetworkIntentsForMember: async () => [],\n updateIndexSettings: async () => defaultOwnedIndex(),\n softDeleteNetwork: noop,\n deleteProfile: noop,\n createNetwork: async () => defaultOwnedIndex(),\n getNetworkMemberCount: async () => 0,\n addMemberToNetwork: noop,\n } as unknown as ChatGraphCompositeDatabase;\n}\n\n// ═══════════════════════════════════════════════════════════════════════════════\n// MOCK CHAT SESSION READER & PROTOCOL DEPS\n// ═══════════════════════════════════════════════════════════════════════════════\n\n/** Mock ChatSessionReader with stub implementations for graph tests. */\nexport const mockChatSessionReader: ChatSessionReader = {\n getSessionMessages: async () => [],\n listSessions: async () => [],\n getSession: async () => null,\n};\n\n/**\n * Create a mock ProtocolDeps with stub implementations for all fields.\n * Pass overrides to customise individual deps for specific tests.\n */\nexport function createMockProtocolDeps(overrides?: Partial<ProtocolDeps>): ProtocolDeps {\n // NOTE: database, embedder, scraper are intentionally omitted.\n // ChatGraphFactory spreads protocolDeps over {database, embedder, scraper, ...},\n // so including stubs here would overwrite the real mocks passed to the constructor.\n return {\n cache: { get: async () => null, set: async () => {}, delete: async () => false, exists: async () => false, mget: async () => [], deleteByPattern: async () => 0 },\n hydeCache: { get: async () => null, set: async () => {}, delete: async () => false, exists: async () => false },\n \n integration: { createSession: async () => ({ toolkits: async () => ({ items: [] }), authorize: async () => ({ redirectUrl: \"\" }) }), executeToolAction: async () => ({ successful: true }), listConnections: async () => [], getAuthUrl: async () => ({ redirectUrl: \"\" }), disconnect: async () => ({ success: true }) } as unknown as ProtocolDeps[\"integration\"],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n intentQueue: { addGenerateHydeJob: async () => ({}), addDeleteHydeJob: async () => ({}) } as any,\n contactService: { importContacts: async () => ({ imported: 0, skipped: 0, newContacts: 0, existingContacts: 0, details: [] }), listContacts: async () => [], addContact: async () => ({ userId: \"\", isNew: false, isGhost: false }), removeContact: async () => {} } as unknown as ProtocolDeps[\"contactService\"],\n chatSession: mockChatSessionReader,\n enricher: { enrichUserProfile: async () => null } as unknown as ProtocolDeps[\"enricher\"],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n negotiationDatabase: {} as any,\n integrationImporter: { importContacts: async () => ({ imported: 0, skipped: 0, newContacts: 0, existingContacts: 0 }) },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n createUserDatabase: (db: any, _userId: string) => {\n return new Proxy({}, {\n get: (_target, prop) => db[prop] ?? (async () => null),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n }) as any;\n },\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n createSystemDatabase: (db: any, _userId: string, _scope: string[]) => {\n return new Proxy({}, {\n get: (_target, prop) => db[prop] ?? (async () => null),\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n }) as any;\n },\n ...overrides,\n } as ProtocolDeps;\n}\n"]}
|
|
@@ -54,9 +54,9 @@ export function createContactTools(defineTool, deps) {
|
|
|
54
54
|
"(via import_contacts, add_contact, or import_gmail_contacts) stored as members of their personal index.\n\n" +
|
|
55
55
|
"**When to use:** To see who's in the user's network, find a contact's userId for other operations, " +
|
|
56
56
|
"or check if a specific person is already a contact.\n\n" +
|
|
57
|
-
"**Returns:** Array of contacts, each with: userId (use with
|
|
57
|
+
"**Returns:** Array of contacts, each with: userId (use with read_user_contexts or discover_opportunities), " +
|
|
58
58
|
"name, email, avatar URL, and isGhost (true = no account yet, profile enriched from public data). " +
|
|
59
|
-
"Use the userId with
|
|
59
|
+
"Use the userId with read_user_contexts(userId) to get the full profile, or with discover_opportunities(targetUserId) to connect.",
|
|
60
60
|
querySchema: z.object({
|
|
61
61
|
limit: z.number().optional().describe('Maximum number of contacts to return. Omit to return all contacts. Use for large networks to paginate results.'),
|
|
62
62
|
}),
|
|
@@ -141,7 +141,7 @@ export function createContactTools(defineTool, deps) {
|
|
|
141
141
|
name: 'search_contacts',
|
|
142
142
|
description: "Searches the authenticated user's personal network by name or email (case-insensitive substring). " +
|
|
143
143
|
"Use when the user refers to a contact by partial name or email and you need their userId for another tool " +
|
|
144
|
-
"(e.g.
|
|
144
|
+
"(e.g. read_user_contexts, discover_opportunities).\n\n" +
|
|
145
145
|
"**When to use:** Before list_contacts when the network is large — returns only matching contacts, bounded by limit.\n\n" +
|
|
146
146
|
"**Returns:** Array of matching contacts: userId, name, email, avatar, isGhost.",
|
|
147
147
|
querySchema: z.object({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contact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C;iBACJ,CAAC,CAAC;YACL,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;gBACnD,OAAO,KAAK,CAAC,8CAA8C,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC;KACF,CAAC,CAAC;IAEH,OAAO;QACL,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACrC,aAAa;QACb,cAAc;QACd,eAAe;KAChB,CAAC;AACJ,CAAC","sourcesContent":["import { z } from 'zod';\nimport type { DefineTool, ToolDeps } from '../shared/agent/tool.helpers.js';\nimport { success, error } from '../shared/agent/tool.helpers.js';\nimport { protocolLogger } from '../shared/observability/protocol.logger.js';\n\nconst logger = protocolLogger('ContactTools');\n\n/**\n * Creates contact management tools for the chat agent.\n * Enables importing, listing, and managing the user's network.\n */\nexport function createContactTools(defineTool: DefineTool, deps: ToolDeps) {\n const { contactService } = deps;\n // Contact import / manual-add create ghost users. These are gated behind the\n // CONTACTS_ENABLED flag (injected as deps.contactsEnabled). Read/remove/search\n // tools below are always available so existing contacts stay manageable.\n const contactsEnabled = deps.contactsEnabled === true;\n\n // Only register when enabled: in the registry path defineTool registers as a\n // side effect, so the call itself must be gated, not just the returned array.\n const import_contacts = contactsEnabled ? defineTool({\n name: 'import_contacts',\n description:\n \"Bulk-imports contacts into the authenticated user's personal network (personal index). Contacts become members of the user's \" +\n \"personal index with 'contact' permission, making them available for opportunity discovery.\\n\\n\" +\n \"**What happens:** Each contact is matched by email. If the email belongs to an existing user, they're linked directly. \" +\n \"If not, a 'ghost user' is created — a placeholder account enriched with public profile data (from LinkedIn, GitHub, etc.) \" +\n \"that participates in opportunity matching even before the person joins the platform.\\n\\n\" +\n \"**When to use:** When the user provides a list of contacts to add (from CSV, manual input, or any source other than Gmail). \" +\n \"For Gmail specifically, use import_gmail_contacts instead.\\n\\n\" +\n \"**Returns:** Import statistics: imported (total processed), skipped (invalid), newContacts (ghost users created), \" +\n \"existingContacts (already in network). Use list_contacts to see all contacts after import.\",\n querySchema: z.object({\n contacts: z.array(z.object({\n name: z.string().describe('Full name of the contact (e.g. \"Jane Smith\")'),\n email: z.string().describe('Email address — used as the unique identifier for matching existing users'),\n })).describe('Array of contact objects to import. Each must have name and email. Duplicates (by email) are skipped.'),\n }),\n handler: async ({ context, query }) => {\n try {\n const result = await contactService.importContacts(\n context.userId,\n query.contacts\n );\n return success({\n message: `Imported ${result.imported} contacts to your network.`,\n imported: result.imported,\n skipped: result.skipped,\n newContacts: result.newContacts,\n existingContacts: result.existingContacts,\n });\n } catch (err) {\n logger.error('Failed to import contacts', { err });\n return error('Failed to import contacts. Please try again.');\n }\n },\n }) : null;\n\n const list_contacts = defineTool({\n name: 'list_contacts',\n description:\n \"Lists all contacts in the authenticated user's personal network. Contacts are people the user has added \" +\n \"(via import_contacts, add_contact, or import_gmail_contacts) stored as members of their personal index.\\n\\n\" +\n \"**When to use:** To see who's in the user's network, find a contact's userId for other operations, \" +\n \"or check if a specific person is already a contact.\\n\\n\" +\n \"**Returns:** Array of contacts, each with: userId (use with read_user_profiles or discover_opportunities), \" +\n \"name, email, avatar URL, and isGhost (true = no account yet, profile enriched from public data). \" +\n \"Use the userId with read_user_profiles(userId) to get the full profile, or with discover_opportunities(targetUserId) to connect.\",\n querySchema: z.object({\n limit: z.number().optional().describe('Maximum number of contacts to return. Omit to return all contacts. Use for large networks to paginate results.'),\n }),\n handler: async ({ context, query }) => {\n try {\n let contacts = await contactService.listContacts(context.userId);\n\n if (query.limit && query.limit > 0) {\n contacts = contacts.slice(0, query.limit);\n }\n\n return success({\n count: contacts.length,\n contacts: contacts.map(c => ({\n userId: c.userId,\n name: c.user.name,\n email: c.user.email,\n avatar: c.user.avatar,\n isGhost: c.user.isGhost,\n })),\n });\n } catch (err) {\n logger.error('Failed to list contacts', { err });\n return error('Failed to list contacts. Please try again.');\n }\n },\n });\n\n const add_contact = contactsEnabled ? defineTool({\n name: 'add_contact',\n description:\n \"Adds a single contact to the authenticated user's personal network by email address. \" +\n \"For bulk imports, use import_contacts instead.\\n\\n\" +\n \"**What happens:** Looks up the email. If an account exists, links that user as a contact. \" +\n \"If not, creates a ghost user (placeholder enriched with public profile data) and adds them. \" +\n \"The contact can then appear in opportunity discovery within the user's personal index.\\n\\n\" +\n \"**When to use:** When the user wants to add a specific person (e.g. 'add john@example.com to my network').\\n\\n\" +\n \"**Returns:** Confirmation with the contact's userId and whether a new ghost user was created (isNewGhost). \" +\n \"Use the userId with discover_opportunities(targetUserId) to find connection opportunities.\",\n querySchema: z.object({\n email: z.string().describe('Email address of the person to add. Used as unique identifier — if already a contact, the operation is idempotent.'),\n name: z.string().optional().describe('Full name of the contact. Optional — if omitted, the email prefix is used as name. Provide when known for better profile enrichment.'),\n }),\n handler: async ({ context, query }) => {\n try {\n const result = await contactService.addContact(context.userId, query.email, { name: query.name, restore: true });\n\n return success({\n added: true,\n message: result.isNew\n ? `Added ${query.name || query.email} to your network. Their profile is being enriched.`\n : `Added ${query.name || query.email} to your network.`,\n userId: result.userId,\n isNewGhost: result.isNew,\n });\n } catch (err) {\n logger.error('Failed to add contact', { err });\n return error('Failed to add contact. Please try again.');\n }\n },\n }) : null;\n\n const remove_contact = defineTool({\n name: 'remove_contact',\n description:\n \"Removes a contact from the authenticated user's personal network. The contact relationship is deleted — \" +\n \"the person is no longer a member of the user's personal index and won't appear in personal-index-scoped discovery.\\n\\n\" +\n \"**When to use:** When the user wants to remove someone from their network (e.g. 'remove John from my contacts').\\n\\n\" +\n \"**Note:** This only removes the contact relationship. If the contact is a real user (not a ghost), \" +\n \"they still exist on the platform and may appear in shared index discovery.\\n\\n\" +\n \"**Returns:** Confirmation that the contact was removed.\",\n querySchema: z.object({\n contactUserId: z.string().describe('The userId of the contact to remove. Get this from list_contacts results.'),\n }),\n handler: async ({ context, query }) => {\n try {\n await contactService.removeContact(context.userId, query.contactUserId);\n return success({ removed: true, message: 'Contact removed from your network.' });\n } catch (err) {\n logger.error('Failed to remove contact', { err });\n return error('Failed to remove contact. Please try again.');\n }\n },\n });\n\n const search_contacts = defineTool({\n name: 'search_contacts',\n description:\n \"Searches the authenticated user's personal network by name or email (case-insensitive substring). \" +\n \"Use when the user refers to a contact by partial name or email and you need their userId for another tool \" +\n \"(e.g. read_user_profiles, discover_opportunities).\\n\\n\" +\n \"**When to use:** Before list_contacts when the network is large — returns only matching contacts, bounded by limit.\\n\\n\" +\n \"**Returns:** Array of matching contacts: userId, name, email, avatar, isGhost.\",\n querySchema: z.object({\n query: z.string().trim().min(1).describe('Free-text query matched against contact name and email (case-insensitive, substring).'),\n limit: z.number().int().positive().max(100).optional().describe('Maximum rows to return. Defaults to 25.'),\n }),\n handler: async ({ context, query }) => {\n try {\n const rows = await contactService.searchContacts(context.userId, query.query, query.limit ?? 25);\n return success({\n count: rows.length,\n contacts: rows.map(r => ({\n userId: r.contactId,\n name: r.name,\n email: r.email,\n avatar: r.avatar,\n isGhost: r.isGhost,\n })),\n });\n } catch (err) {\n logger.error('Failed to search contacts', { err });\n return error('Failed to search contacts. Please try again.');\n }\n },\n });\n\n return [\n ...(import_contacts ? [import_contacts] : []),\n ...(add_contact ? [add_contact] : []),\n list_contacts,\n remove_contact,\n search_contacts,\n ];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"contact.tools.js","sourceRoot":"/","sources":["contact/contact.tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAE5E,MAAM,MAAM,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;AAE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AC,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QACrC,aAAa;QACb,cAAc;QACd,eAAe;KAChB,CAAC;AACJ,CAAC","sourcesContent":["import { z } from 'zod';\nimport type { DefineTool, ToolDeps } from '../shared/agent/tool.helpers.js';\nimport { success, error } from '../shared/agent/tool.helpers.js';\nimport { protocolLogger } from '../shared/observability/protocol.logger.js';\n\nconst logger = protocolLogger('ContactTools');\n\n/**\n * Creates contact management tools for the chat agent.\n * Enables importing, listing, and managing the user's network.\n */\nexport function createContactTools(defineTool: DefineTool, deps: ToolDeps) {\n const { contactService } = deps;\n // Contact import / manual-add create ghost users. These are gated behind the\n // CONTACTS_ENABLED flag (injected as deps.contactsEnabled). Read/remove/search\n // tools below are always available so existing contacts stay manageable.\n const contactsEnabled = deps.contactsEnabled === true;\n\n // Only register when enabled: in the registry path defineTool registers as a\n // side effect, so the call itself must be gated, not just the returned array.\n const import_contacts = contactsEnabled ? defineTool({\n name: 'import_contacts',\n description:\n \"Bulk-imports contacts into the authenticated user's personal network (personal index). Contacts become members of the user's \" +\n \"personal index with 'contact' permission, making them available for opportunity discovery.\\n\\n\" +\n \"**What happens:** Each contact is matched by email. If the email belongs to an existing user, they're linked directly. \" +\n \"If not, a 'ghost user' is created — a placeholder account enriched with public profile data (from LinkedIn, GitHub, etc.) \" +\n \"that participates in opportunity matching even before the person joins the platform.\\n\\n\" +\n \"**When to use:** When the user provides a list of contacts to add (from CSV, manual input, or any source other than Gmail). \" +\n \"For Gmail specifically, use import_gmail_contacts instead.\\n\\n\" +\n \"**Returns:** Import statistics: imported (total processed), skipped (invalid), newContacts (ghost users created), \" +\n \"existingContacts (already in network). Use list_contacts to see all contacts after import.\",\n querySchema: z.object({\n contacts: z.array(z.object({\n name: z.string().describe('Full name of the contact (e.g. \"Jane Smith\")'),\n email: z.string().describe('Email address — used as the unique identifier for matching existing users'),\n })).describe('Array of contact objects to import. Each must have name and email. Duplicates (by email) are skipped.'),\n }),\n handler: async ({ context, query }) => {\n try {\n const result = await contactService.importContacts(\n context.userId,\n query.contacts\n );\n return success({\n message: `Imported ${result.imported} contacts to your network.`,\n imported: result.imported,\n skipped: result.skipped,\n newContacts: result.newContacts,\n existingContacts: result.existingContacts,\n });\n } catch (err) {\n logger.error('Failed to import contacts', { err });\n return error('Failed to import contacts. Please try again.');\n }\n },\n }) : null;\n\n const list_contacts = defineTool({\n name: 'list_contacts',\n description:\n \"Lists all contacts in the authenticated user's personal network. Contacts are people the user has added \" +\n \"(via import_contacts, add_contact, or import_gmail_contacts) stored as members of their personal index.\\n\\n\" +\n \"**When to use:** To see who's in the user's network, find a contact's userId for other operations, \" +\n \"or check if a specific person is already a contact.\\n\\n\" +\n \"**Returns:** Array of contacts, each with: userId (use with read_user_contexts or discover_opportunities), \" +\n \"name, email, avatar URL, and isGhost (true = no account yet, profile enriched from public data). \" +\n \"Use the userId with read_user_contexts(userId) to get the full profile, or with discover_opportunities(targetUserId) to connect.\",\n querySchema: z.object({\n limit: z.number().optional().describe('Maximum number of contacts to return. Omit to return all contacts. Use for large networks to paginate results.'),\n }),\n handler: async ({ context, query }) => {\n try {\n let contacts = await contactService.listContacts(context.userId);\n\n if (query.limit && query.limit > 0) {\n contacts = contacts.slice(0, query.limit);\n }\n\n return success({\n count: contacts.length,\n contacts: contacts.map(c => ({\n userId: c.userId,\n name: c.user.name,\n email: c.user.email,\n avatar: c.user.avatar,\n isGhost: c.user.isGhost,\n })),\n });\n } catch (err) {\n logger.error('Failed to list contacts', { err });\n return error('Failed to list contacts. Please try again.');\n }\n },\n });\n\n const add_contact = contactsEnabled ? defineTool({\n name: 'add_contact',\n description:\n \"Adds a single contact to the authenticated user's personal network by email address. \" +\n \"For bulk imports, use import_contacts instead.\\n\\n\" +\n \"**What happens:** Looks up the email. If an account exists, links that user as a contact. \" +\n \"If not, creates a ghost user (placeholder enriched with public profile data) and adds them. \" +\n \"The contact can then appear in opportunity discovery within the user's personal index.\\n\\n\" +\n \"**When to use:** When the user wants to add a specific person (e.g. 'add john@example.com to my network').\\n\\n\" +\n \"**Returns:** Confirmation with the contact's userId and whether a new ghost user was created (isNewGhost). \" +\n \"Use the userId with discover_opportunities(targetUserId) to find connection opportunities.\",\n querySchema: z.object({\n email: z.string().describe('Email address of the person to add. Used as unique identifier — if already a contact, the operation is idempotent.'),\n name: z.string().optional().describe('Full name of the contact. Optional — if omitted, the email prefix is used as name. Provide when known for better profile enrichment.'),\n }),\n handler: async ({ context, query }) => {\n try {\n const result = await contactService.addContact(context.userId, query.email, { name: query.name, restore: true });\n\n return success({\n added: true,\n message: result.isNew\n ? `Added ${query.name || query.email} to your network. Their profile is being enriched.`\n : `Added ${query.name || query.email} to your network.`,\n userId: result.userId,\n isNewGhost: result.isNew,\n });\n } catch (err) {\n logger.error('Failed to add contact', { err });\n return error('Failed to add contact. Please try again.');\n }\n },\n }) : null;\n\n const remove_contact = defineTool({\n name: 'remove_contact',\n description:\n \"Removes a contact from the authenticated user's personal network. The contact relationship is deleted — \" +\n \"the person is no longer a member of the user's personal index and won't appear in personal-index-scoped discovery.\\n\\n\" +\n \"**When to use:** When the user wants to remove someone from their network (e.g. 'remove John from my contacts').\\n\\n\" +\n \"**Note:** This only removes the contact relationship. If the contact is a real user (not a ghost), \" +\n \"they still exist on the platform and may appear in shared index discovery.\\n\\n\" +\n \"**Returns:** Confirmation that the contact was removed.\",\n querySchema: z.object({\n contactUserId: z.string().describe('The userId of the contact to remove. Get this from list_contacts results.'),\n }),\n handler: async ({ context, query }) => {\n try {\n await contactService.removeContact(context.userId, query.contactUserId);\n return success({ removed: true, message: 'Contact removed from your network.' });\n } catch (err) {\n logger.error('Failed to remove contact', { err });\n return error('Failed to remove contact. Please try again.');\n }\n },\n });\n\n const search_contacts = defineTool({\n name: 'search_contacts',\n description:\n \"Searches the authenticated user's personal network by name or email (case-insensitive substring). \" +\n \"Use when the user refers to a contact by partial name or email and you need their userId for another tool \" +\n \"(e.g. read_user_contexts, discover_opportunities).\\n\\n\" +\n \"**When to use:** Before list_contacts when the network is large — returns only matching contacts, bounded by limit.\\n\\n\" +\n \"**Returns:** Array of matching contacts: userId, name, email, avatar, isGhost.\",\n querySchema: z.object({\n query: z.string().trim().min(1).describe('Free-text query matched against contact name and email (case-insensitive, substring).'),\n limit: z.number().int().positive().max(100).optional().describe('Maximum rows to return. Defaults to 25.'),\n }),\n handler: async ({ context, query }) => {\n try {\n const rows = await contactService.searchContacts(context.userId, query.query, query.limit ?? 25);\n return success({\n count: rows.length,\n contacts: rows.map(r => ({\n userId: r.contactId,\n name: r.name,\n email: r.email,\n avatar: r.avatar,\n isGhost: r.isGhost,\n })),\n });\n } catch (err) {\n logger.error('Failed to search contacts', { err });\n return error('Failed to search contacts. Please try again.');\n }\n },\n });\n\n return [\n ...(import_contacts ? [import_contacts] : []),\n ...(add_contact ? [add_contact] : []),\n list_contacts,\n remove_contact,\n search_contacts,\n ];\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichment.enricher.d.ts","sourceRoot":"/","sources":["enrichment/enrichment.enricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAKrF;AAED;;;;;;;GAOG;AACH,wBAAgB,wCAAwC,CACtD,IAAI,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,GAAG,IAAI,CAAA;CAAE,EAC/D,YAAY,EAAE,MAAM,GACnB,OAAO,CAST"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichment.enricher.js","sourceRoot":"/","sources":["enrichment/enrichment.enricher.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,wBAAwB,CAAC,KAAa,EAAE,YAAoB;IAC1E,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC;IACpC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACpD,MAAM,SAAS,GAAG,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;IACpD,OAAO,OAAO,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC;AAC7C,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,wCAAwC,CACtD,IAA+D,EAC/D,YAAoB;IAEpB,IAAI,CAAC,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAChC,MAAM,OAAO,GAAG,YAAY,CAAC,IAAI,EAAE,CAAC;IACpC,IAAI,CAAC,OAAO,IAAI,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IAEpD,iDAAiD;IACjD,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,OAAO;QAAE,OAAO,KAAK,CAAC;IAE/C,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/**\n * Returns true when the enriched name is meaningfully better than the email local-part.\n * A name that is empty, contains '@', or case-insensitively matches the prefix is NOT meaningful.\n */\nexport function isEnrichedNameMeaningful(email: string, enrichedName: string): boolean {\n const trimmed = enrichedName.trim();\n if (!trimmed || trimmed.includes('@')) return false;\n const localPart = email.split('@')[0].toLowerCase();\n return trimmed.toLowerCase() !== localPart;\n}\n\n/**\n * Decides whether to set {@link users.name} from Parallel `enrichment.identity.name` for ghost users.\n * @remarks Real users (Google login, etc.) are never touched. Ghost users always get\n * their name enriched when Parallel returns a non-empty name that isn't an email.\n * @param user - Current user row (must include `email`, `name`, `isGhost`)\n * @param enrichedName - `enrichment.identity.name` from Parallel (may be untrimmed)\n * @returns True if `users.name` should be updated to the enriched full name\n */\nexport function shouldEnrichGhostDisplayNameFromParallel(\n user: { name: string; email: string; isGhost?: boolean | null },\n enrichedName: string,\n): boolean {\n if (!user.isGhost) return false;\n const trimmed = enrichedName.trim();\n if (!trimmed || trimmed.includes(\"@\")) return false;\n\n // Skip only if exactly the same (case-sensitive)\n if (user.name.trim() === trimmed) return false;\n\n return true;\n}\n"]}
|
|
@@ -14,10 +14,10 @@ declare const responseFormat: z.ZodObject<{
|
|
|
14
14
|
}, z.core.$strip>;
|
|
15
15
|
}, z.core.$strip>;
|
|
16
16
|
type Profile = z.infer<typeof responseFormat>;
|
|
17
|
-
export type
|
|
17
|
+
export type GeneratedProfile = Profile & {
|
|
18
18
|
userId: string;
|
|
19
19
|
};
|
|
20
|
-
export declare class
|
|
20
|
+
export declare class EnrichmentGenerator {
|
|
21
21
|
private static baseModel;
|
|
22
22
|
private model;
|
|
23
23
|
constructor();
|
|
@@ -64,4 +64,4 @@ export declare class ProfileGenerator {
|
|
|
64
64
|
}, unknown, "profileGenerator">;
|
|
65
65
|
}
|
|
66
66
|
export {};
|
|
67
|
-
//# sourceMappingURL=
|
|
67
|
+
//# sourceMappingURL=enrichment.generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichment.generator.d.ts","sourceRoot":"/","sources":["enrichment/enrichment.generator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAkB3B,QAAA,MAAM,cAAc;;;;;;;;;;;;;iBAalB,CAAC;AAEH,KAAK,OAAO,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9C,MAAM,MAAM,gBAAgB,GAAG,OAAO,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAE5D,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAC,SAAS,CAA6C;IACrE,OAAO,CAAC,KAAK,CAAkF;;IAS/F,OAAO,CAAC,QAAQ;IAeH,MAAM,CAAC,KAAK,EAAE,MAAM;;;;;;;;;;;;;;;;;WAgBnB,MAAM;;;;;;;;;;;;;;;;;;;;;;;CAerB"}
|
|
@@ -14,7 +14,7 @@ import { protocolLogger } from "../shared/observability/protocol.logger.js";
|
|
|
14
14
|
import { Timed } from "../shared/observability/performance.js";
|
|
15
15
|
import { createModel } from "../shared/agent/model.config.js";
|
|
16
16
|
import { invokeWithAbortSignal } from "../shared/agent/model-signal.js";
|
|
17
|
-
const logger = protocolLogger("
|
|
17
|
+
const logger = protocolLogger("EnrichmentGenerator");
|
|
18
18
|
const systemPrompt = `
|
|
19
19
|
You are an expert profiler. Your task is to synthesize a structured User Profile from raw data or user requests.
|
|
20
20
|
|
|
@@ -38,9 +38,9 @@ const responseFormat = z.object({
|
|
|
38
38
|
skills: z.array(z.string()).describe("Professional skills"),
|
|
39
39
|
}),
|
|
40
40
|
});
|
|
41
|
-
export class
|
|
41
|
+
export class EnrichmentGenerator {
|
|
42
42
|
constructor() {
|
|
43
|
-
const baseModel =
|
|
43
|
+
const baseModel = EnrichmentGenerator.baseModel ?? (EnrichmentGenerator.baseModel = createModel("profileGenerator"));
|
|
44
44
|
this.model = baseModel.withStructuredOutput(responseFormat, {
|
|
45
45
|
name: "profile_generator"
|
|
46
46
|
});
|
|
@@ -75,7 +75,7 @@ export class ProfileGenerator {
|
|
|
75
75
|
}
|
|
76
76
|
static asTool() {
|
|
77
77
|
return tool(async (args) => {
|
|
78
|
-
const profileGenerator = new
|
|
78
|
+
const profileGenerator = new EnrichmentGenerator();
|
|
79
79
|
return await profileGenerator.invoke(args.input);
|
|
80
80
|
}, {
|
|
81
81
|
name: 'profileGenerator',
|
|
@@ -91,5 +91,5 @@ __decorate([
|
|
|
91
91
|
__metadata("design:type", Function),
|
|
92
92
|
__metadata("design:paramtypes", [String]),
|
|
93
93
|
__metadata("design:returntype", Promise)
|
|
94
|
-
],
|
|
95
|
-
//# sourceMappingURL=
|
|
94
|
+
], EnrichmentGenerator.prototype, "invoke", null);
|
|
95
|
+
//# sourceMappingURL=enrichment.generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"enrichment.generator.js","sourceRoot":"/","sources":["enrichment/enrichment.generator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,MAAM,GAAG,cAAc,CAAC,qBAAqB,CAAC,CAAC;AAErD,MAAM,YAAY,GAAG;;;;;;;;CAQpB,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,QAAQ,EAAE,CAAC,CAAC,MAAM,CAAC;QACjB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sBAAsB,CAAC;QACjD,GAAG,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,2HAA2H,CAAC;QACrJ,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,+CAA+C,CAAC;KAC/E,CAAC;IACF,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC;QAClB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oGAAoG,CAAC;KACnI,CAAC;IACF,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC;QACnB,SAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM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M,qBAAqB,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACjE,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5C,MAAM,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QAC1C,MAAM,CAAC,OAAO,CAAC,mBAAmB,EAAE;YAClC,WAAW,EAAE,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,MAAM;YAC5C,cAAc,EAAE,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,MAAM;SACnD,CAAC,CAAC;QACH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IACjC,CAAC;IAEM,MAAM,CAAC,MAAM;QAClB,OAAO,IAAI,CACT,KAAK,EAAE,IAAuB,EAAE,EAAE;YAChC,MAAM,gBAAgB,GAAG,IAAI,mBAAmB,EAAE,CAAC;YACnD,OAAO,MAAM,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnD,CAAC,EACD;YACE,IAAI,EAAE,kBAAkB;YACxB,WAAW,EAAE,mBAAmB;YAChC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;gBACf,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;aAC9E,CAAC;SACH,CACF,CAAC;IACJ,CAAC;CACF;AA/Bc;IADZ,KAAK,EAAE;;;;iDAeP","sourcesContent":["import { HumanMessage, SystemMessage } from \"@langchain/core/messages\";\nimport { tool } from \"@langchain/core/tools\";\nimport { z } from \"zod/v4\";\nimport { protocolLogger } from \"../shared/observability/protocol.logger.js\";\nimport { Timed } from \"../shared/observability/performance.js\";\nimport { createModel } from \"../shared/agent/model.config.js\";\nimport { invokeWithAbortSignal } from \"../shared/agent/model-signal.js\";\n\nconst logger = protocolLogger(\"EnrichmentGenerator\");\n\nconst systemPrompt = `\n You are an expert profiler. Your task is to synthesize a structured User Profile from raw data or user requests.\n\n When given EXISTING PROFILE + USER REQUEST: Apply the request to the existing profile. Add, update, or remove skills and interests as the user asks. Preserve everything else. Output the full updated profile.\n\n When given raw data only: Infer name, bio, location, narrative.context, and extract skills and interests.\n\n PRIVACY: identity.bio and narrative.context are public-facing. Never include email addresses, phone numbers, physical addresses, government IDs, or other contact identifiers — even if they appear in the raw data. Describe the person professionally; do not embed ways to contact them.\n`;\n\nconst responseFormat = z.object({\n identity: z.object({\n name: z.string().describe(\"The user's full name\"),\n bio: z.string().describe(\"Professional summary (2-3 sentences) only; no email, phone, physical address, government ID, or other contact identifiers\"),\n location: z.string().describe(\"Inferred location (City, Country) or 'Remote'\"),\n }),\n narrative: z.object({\n context: z.string().describe(\"Rich narrative without email, phone, physical address, government ID, or other contact identifiers\"),\n }),\n attributes: z.object({\n interests: z.array(z.string()).describe(\"Inferred or explicit interests\"),\n skills: z.array(z.string()).describe(\"Professional skills\"),\n }),\n});\n\ntype Profile = z.infer<typeof responseFormat>;\nexport type GeneratedProfile = Profile & { userId: string };\n\nexport class EnrichmentGenerator {\n private static baseModel: ReturnType<typeof createModel> | undefined;\n private model: { invoke(input: unknown, config?: { signal?: AbortSignal }): Promise<unknown> };\n\n constructor() {\n const baseModel = EnrichmentGenerator.baseModel ??= createModel(\"profileGenerator\");\n this.model = baseModel.withStructuredOutput(responseFormat, {\n name: \"profile_generator\"\n });\n }\n\n private toString(profile: Profile): string {\n return [\n '# Identity',\n '## Name', profile.identity.name,\n '## Bio', profile.identity.bio,\n '## Location', profile.identity.location,\n '# Narrative',\n '## Context', profile.narrative.context,\n '# Attributes',\n '## Interests', profile.attributes.interests.join(', '),\n '## Skills', profile.attributes.skills.join(', ')\n ].join('\\n');\n }\n\n @Timed()\n public async invoke(input: string) {\n logger.verbose(\"Received input\", { inputLength: input?.length });\n const messages = [\n new SystemMessage(systemPrompt),\n new HumanMessage(`Here is the raw data:\\n${input}`)\n ];\n const result = await invokeWithAbortSignal(this.model, messages);\n const output = responseFormat.parse(result);\n const textToEmbed = this.toString(output);\n logger.verbose(\"Generated profile\", {\n skillsCount: output.attributes.skills.length,\n interestsCount: output.attributes.interests.length\n });\n return { output, textToEmbed };\n }\n\n public static asTool() {\n return tool(\n async (args: { input: string }) => {\n const profileGenerator = new EnrichmentGenerator();\n return await profileGenerator.invoke(args.input);\n },\n {\n name: 'profileGenerator',\n description: 'Profile Generator',\n schema: z.object({\n input: z.string().describe('Raw data scraped from the web (via Parallel.ai)'),\n })\n }\n );\n }\n}"]}
|