@indexnetwork/protocol 4.3.3-rc.308.1 → 4.3.4-rc.310.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/IMPLEMENTATION.md +2 -2
- package/dist/chat/chat.agent.d.ts +1 -1
- package/dist/chat/chat.agent.d.ts.map +1 -1
- package/dist/chat/chat.agent.js +12 -2
- package/dist/chat/chat.agent.js.map +1 -1
- package/dist/chat/chat.graph.d.ts +16 -0
- package/dist/chat/chat.graph.d.ts.map +1 -1
- package/dist/chat/chat.graph.js +5 -2
- package/dist/chat/chat.graph.js.map +1 -1
- package/dist/chat/chat.prompt.d.ts.map +1 -1
- package/dist/chat/chat.prompt.js +44 -37
- 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/chat.state.d.ts +7 -4
- package/dist/chat/chat.state.d.ts.map +1 -1
- package/dist/chat/chat.state.js +12 -3
- package/dist/chat/chat.state.js.map +1 -1
- package/dist/chat/chat.streamer.d.ts +5 -0
- package/dist/chat/chat.streamer.d.ts.map +1 -1
- package/dist/chat/chat.streamer.js +13 -4
- package/dist/chat/chat.streamer.js.map +1 -1
- package/dist/chat/tests/chat.graph.mocks.d.ts +1 -1
- package/dist/chat/tests/chat.graph.mocks.js +1 -1
- package/dist/chat/tests/chat.graph.mocks.js.map +1 -1
- package/dist/contact/contact.tools.js +6 -6
- package/dist/contact/contact.tools.js.map +1 -1
- package/dist/enrichment/enrichment.tools.d.ts.map +1 -1
- package/dist/enrichment/enrichment.tools.js +23 -26
- package/dist/enrichment/enrichment.tools.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/integration/integration.tools.js +1 -1
- package/dist/integration/integration.tools.js.map +1 -1
- package/dist/intent/intent.graph.d.ts.map +1 -1
- package/dist/intent/intent.graph.js +9 -9
- package/dist/intent/intent.graph.js.map +1 -1
- package/dist/intent/intent.indexer.d.ts +1 -1
- package/dist/intent/intent.indexer.js +4 -4
- package/dist/intent/intent.indexer.js.map +1 -1
- package/dist/intent/intent.state.d.ts +8 -8
- package/dist/intent/intent.state.js +8 -8
- package/dist/intent/intent.state.js.map +1 -1
- package/dist/intent/intent.tools.d.ts.map +1 -1
- package/dist/intent/intent.tools.js +87 -70
- package/dist/intent/intent.tools.js.map +1 -1
- package/dist/maintenance/maintenance.graph.d.ts +2 -2
- package/dist/maintenance/maintenance.graph.d.ts.map +1 -1
- package/dist/maintenance/maintenance.graph.js.map +1 -1
- package/dist/mcp/mcp.server.d.ts +5 -7
- package/dist/mcp/mcp.server.d.ts.map +1 -1
- package/dist/mcp/mcp.server.js +11 -20
- package/dist/mcp/mcp.server.js.map +1 -1
- package/dist/negotiation/negotiation.tools.d.ts.map +1 -1
- package/dist/negotiation/negotiation.tools.js +11 -7
- package/dist/negotiation/negotiation.tools.js.map +1 -1
- package/dist/network/indexer/indexer.graph.d.ts +2 -2
- package/dist/network/indexer/indexer.graph.d.ts.map +1 -1
- package/dist/network/indexer/indexer.graph.js +13 -13
- package/dist/network/indexer/indexer.graph.js.map +1 -1
- package/dist/network/indexer/indexer.state.d.ts +3 -3
- package/dist/network/indexer/indexer.state.d.ts.map +1 -1
- package/dist/network/indexer/indexer.state.js +4 -4
- package/dist/network/indexer/indexer.state.js.map +1 -1
- package/dist/network/membership/membership.graph.d.ts +1 -1
- package/dist/network/membership/membership.graph.js +21 -21
- package/dist/network/membership/membership.graph.js.map +1 -1
- package/dist/network/membership/membership.state.d.ts +2 -2
- package/dist/network/membership/membership.state.js +2 -2
- package/dist/network/membership/membership.state.js.map +1 -1
- package/dist/network/network.graph.d.ts +1 -1
- package/dist/network/network.graph.d.ts.map +1 -1
- package/dist/network/network.graph.js +13 -13
- package/dist/network/network.graph.js.map +1 -1
- package/dist/network/network.state.d.ts +3 -3
- package/dist/network/network.state.d.ts.map +1 -1
- package/dist/network/network.state.js +3 -3
- package/dist/network/network.state.js.map +1 -1
- package/dist/network/network.tools.js +68 -68
- package/dist/network/network.tools.js.map +1 -1
- package/dist/opportunity/opportunity.discover.d.ts +1 -1
- package/dist/opportunity/opportunity.discover.d.ts.map +1 -1
- package/dist/opportunity/opportunity.discover.js +1 -1
- package/dist/opportunity/opportunity.discover.js.map +1 -1
- package/dist/opportunity/opportunity.graph.js +11 -11
- package/dist/opportunity/opportunity.graph.js.map +1 -1
- package/dist/opportunity/opportunity.introducer.d.ts +3 -3
- package/dist/opportunity/opportunity.introducer.d.ts.map +1 -1
- package/dist/opportunity/opportunity.introducer.js +2 -2
- package/dist/opportunity/opportunity.introducer.js.map +1 -1
- package/dist/opportunity/opportunity.state.d.ts +1 -1
- package/dist/opportunity/opportunity.state.js +1 -1
- package/dist/opportunity/opportunity.state.js.map +1 -1
- package/dist/opportunity/opportunity.tools.d.ts.map +1 -1
- package/dist/opportunity/opportunity.tools.js +43 -47
- package/dist/opportunity/opportunity.tools.js.map +1 -1
- package/dist/premise/premise.indexer.d.ts +1 -1
- package/dist/premise/premise.indexer.js +5 -5
- package/dist/premise/premise.indexer.js.map +1 -1
- package/dist/questioner/questioner.tools.d.ts +1 -1
- package/dist/questioner/questioner.tools.d.ts.map +1 -1
- package/dist/questioner/questioner.tools.js +5 -6
- package/dist/questioner/questioner.tools.js.map +1 -1
- package/dist/shared/agent/tool.factory.d.ts +1 -1
- package/dist/shared/agent/tool.factory.d.ts.map +1 -1
- package/dist/shared/agent/tool.factory.js +10 -11
- package/dist/shared/agent/tool.factory.js.map +1 -1
- package/dist/shared/agent/tool.helpers.d.ts +6 -6
- package/dist/shared/agent/tool.helpers.d.ts.map +1 -1
- package/dist/shared/agent/tool.helpers.js +2 -2
- package/dist/shared/agent/tool.helpers.js.map +1 -1
- package/dist/shared/agent/tool.registry.js +1 -1
- package/dist/shared/agent/tool.registry.js.map +1 -1
- package/dist/shared/agent/tool.scope.d.ts +12 -0
- package/dist/shared/agent/tool.scope.d.ts.map +1 -1
- package/dist/shared/agent/tool.scope.js +14 -0
- package/dist/shared/agent/tool.scope.js.map +1 -1
- package/dist/shared/agent/utility.tools.js +20 -20
- package/dist/shared/agent/utility.tools.js.map +1 -1
- package/dist/shared/interfaces/auth.interface.d.ts +3 -3
- package/dist/shared/interfaces/auth.interface.js.map +1 -1
- package/dist/shared/interfaces/database.interface.d.ts +59 -59
- 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/discovery-run.interface.d.ts +1 -1
- package/dist/shared/interfaces/discovery-run.interface.d.ts.map +1 -1
- package/dist/shared/interfaces/discovery-run.interface.js.map +1 -1
- package/dist/shared/interfaces/embedder.interface.d.ts +2 -2
- package/dist/shared/interfaces/embedder.interface.d.ts.map +1 -1
- package/dist/shared/interfaces/embedder.interface.js.map +1 -1
- package/dist/shared/interfaces/enrichment-run.interface.d.ts +1 -1
- package/dist/shared/interfaces/enrichment-run.interface.d.ts.map +1 -1
- package/dist/shared/interfaces/enrichment-run.interface.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
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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,CAAC,EAAE;QACvH,8DAA8D;QAC9D,kBAAkB,EAAE,CAAC,EAAO,EAAE,OAAe,EAAE,EAAE;YAC/C,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,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"]}
|
|
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,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,CAAC,EAAE,CAAC,IAAI,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, network 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"]}
|
|
@@ -16,8 +16,8 @@ export function createContactTools(defineTool, deps) {
|
|
|
16
16
|
// side effect, so the call itself must be gated, not just the returned array.
|
|
17
17
|
const import_contacts = contactsEnabled ? defineTool({
|
|
18
18
|
name: 'import_contacts',
|
|
19
|
-
description: "Bulk-imports contacts into the authenticated user's personal network (personal
|
|
20
|
-
"personal
|
|
19
|
+
description: "Bulk-imports contacts into the authenticated user's personal network (personal network). Contacts become members of the user's " +
|
|
20
|
+
"personal network with 'contact' permission, making them available for opportunity discovery.\n\n" +
|
|
21
21
|
"**What happens:** Each contact is matched by email. If the email belongs to an existing user, they're linked directly. " +
|
|
22
22
|
"If not, a 'ghost user' is created — a placeholder account enriched with public profile data (from LinkedIn, GitHub, etc.) " +
|
|
23
23
|
"that participates in opportunity matching even before the person joins the platform.\n\n" +
|
|
@@ -51,7 +51,7 @@ export function createContactTools(defineTool, deps) {
|
|
|
51
51
|
const list_contacts = defineTool({
|
|
52
52
|
name: 'list_contacts',
|
|
53
53
|
description: "Lists all contacts in the authenticated user's personal network. Contacts are people the user has added " +
|
|
54
|
-
"(via import_contacts, add_contact, or import_gmail_contacts) stored as members of their personal
|
|
54
|
+
"(via import_contacts, add_contact, or import_gmail_contacts) stored as members of their personal network.\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
57
|
"**Returns:** Array of contacts, each with: userId (use with read_user_contexts or discover_opportunities), " +
|
|
@@ -89,7 +89,7 @@ export function createContactTools(defineTool, deps) {
|
|
|
89
89
|
"For bulk imports, use import_contacts instead.\n\n" +
|
|
90
90
|
"**What happens:** Looks up the email. If an account exists, links that user as a contact. " +
|
|
91
91
|
"If not, creates a ghost user (placeholder enriched with public profile data) and adds them. " +
|
|
92
|
-
"The contact can then appear in opportunity discovery within the user's personal
|
|
92
|
+
"The contact can then appear in opportunity discovery within the user's personal network.\n\n" +
|
|
93
93
|
"**When to use:** When the user wants to add a specific person (e.g. 'add john@example.com to my network').\n\n" +
|
|
94
94
|
"**Returns:** Confirmation with the contact's userId and whether a new ghost user was created (isNewGhost). " +
|
|
95
95
|
"Use the userId with discover_opportunities(targetUserId) to find connection opportunities.",
|
|
@@ -118,10 +118,10 @@ export function createContactTools(defineTool, deps) {
|
|
|
118
118
|
const remove_contact = defineTool({
|
|
119
119
|
name: 'remove_contact',
|
|
120
120
|
description: "Removes a contact from the authenticated user's personal network. The contact relationship is deleted — " +
|
|
121
|
-
"the person is no longer a member of the user's personal
|
|
121
|
+
"the person is no longer a member of the user's personal network and won't appear in personal-network-scoped discovery.\n\n" +
|
|
122
122
|
"**When to use:** When the user wants to remove someone from their network (e.g. 'remove John from my contacts').\n\n" +
|
|
123
123
|
"**Note:** This only removes the contact relationship. If the contact is a real user (not a ghost), " +
|
|
124
|
-
"they still exist on the platform and may appear in shared
|
|
124
|
+
"they still exist on the platform and may appear in shared network discovery.\n\n" +
|
|
125
125
|
"**Returns:** Confirmation that the contact was removed.",
|
|
126
126
|
querySchema: z.object({
|
|
127
127
|
contactUserId: z.string().describe('The userId of the contact to remove. Get this from list_contacts results.'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contact.tools.js","sourceRoot":"/","sources":["contact/contact.tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAA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B,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_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"]}
|
|
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;AAE9C;;;GAGG;AACH,MAAM,UAAU,kBAAkB,CAAC,UAAsB,EAAE,IAAc;IACvE,MAAM,EAAE,cAAc,EAAE,GAAG,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C,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 network). Contacts become members of the user's \" +\n \"personal network 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 network.\\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 network.\\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 network and won't appear in personal-network-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 network 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"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"enrichment.tools.d.ts","sourceRoot":"/","sources":["enrichment/enrichment.tools.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAuB,QAAQ,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"enrichment.tools.d.ts","sourceRoot":"/","sources":["enrichment/enrichment.tools.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAuB,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAiCjG,wBAAgB,qBAAqB,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,0DAqtC3E"}
|
|
@@ -6,6 +6,7 @@ import { socialsToEnrichmentRequest, detectSocialLabel } from "../shared/utils/s
|
|
|
6
6
|
import { normalizeTelegramHandle } from "../shared/utils/telegram-handle.js";
|
|
7
7
|
import { EnrichmentGenerator } from "./enrichment.generator.js";
|
|
8
8
|
import { invokeWithAbortSignal } from "../shared/agent/model-signal.js";
|
|
9
|
+
import { focusedNetworkId, focusedNetworkLabel } from "../shared/agent/tool.scope.js";
|
|
9
10
|
const logger = protocolLogger("ChatTools:Enrichment");
|
|
10
11
|
function isMeaningfulEnrichment(enrichment) {
|
|
11
12
|
return !!enrichment &&
|
|
@@ -116,9 +117,8 @@ export function createEnrichmentTools(defineTool, deps) {
|
|
|
116
117
|
userId: context.userId,
|
|
117
118
|
userName: context.userName,
|
|
118
119
|
userEmail: context.userEmail,
|
|
119
|
-
...(context
|
|
120
|
+
...(focusedNetworkId(context) ? { scopeType: 'network', scopeId: focusedNetworkId(context) } : {}),
|
|
120
121
|
...(context.indexName ? { indexName: context.indexName } : {}),
|
|
121
|
-
indexScope: context.indexScope,
|
|
122
122
|
...(context.sessionId ? { sessionId: context.sessionId } : {}),
|
|
123
123
|
...(context.agentId ? { agentId: context.agentId } : {}),
|
|
124
124
|
...(context.clientSurface ? { clientSurface: context.clientSurface } : {}),
|
|
@@ -272,10 +272,12 @@ export function createEnrichmentTools(defineTool, deps) {
|
|
|
272
272
|
"use these as the source of truth for whether the user still needs onboarding (do not rely on local file state).",
|
|
273
273
|
querySchema: z.object({
|
|
274
274
|
userId: z.string().optional().describe("Fetch a specific user's profile by their user ID. Get user IDs from read_network_memberships or list_contacts."),
|
|
275
|
-
networkId: z.string().optional().describe("
|
|
275
|
+
networkId: z.string().optional().describe("Network UUID — fetch profiles of all members in this network, or narrow a name search to this network. Get from read_networks."),
|
|
276
276
|
query: z.string().optional().describe("Name to search for (case-insensitive substring match). Searches across all the user's indexes unless networkId is also provided. Use this when the user asks to 'find' or 'look up' someone."),
|
|
277
277
|
}),
|
|
278
278
|
handler: async ({ context, query }) => {
|
|
279
|
+
const scopedNetworkId = focusedNetworkId(context);
|
|
280
|
+
const scopedIndexLabel = focusedNetworkLabel(context);
|
|
279
281
|
const effectiveIndexId = query.networkId?.trim() || undefined;
|
|
280
282
|
const targetUserId = query.userId?.trim() || undefined;
|
|
281
283
|
const nameQuery = query.query?.trim() || undefined;
|
|
@@ -286,15 +288,13 @@ export function createEnrichmentTools(defineTool, deps) {
|
|
|
286
288
|
if (nameQuery) {
|
|
287
289
|
const pattern = nameQuery.toLowerCase();
|
|
288
290
|
const MAX_RESULTS = 20;
|
|
289
|
-
// When chat is
|
|
290
|
-
const searchIndexId = effectiveIndexId ||
|
|
291
|
+
// When chat is network-scoped, restrict name search to that index
|
|
292
|
+
const searchIndexId = effectiveIndexId || scopedNetworkId || undefined;
|
|
291
293
|
let candidates;
|
|
292
294
|
if (searchIndexId) {
|
|
293
295
|
// Scoped to a specific index
|
|
294
|
-
if (
|
|
295
|
-
return error(
|
|
296
|
-
? `This chat is scoped to ${context.indexName}. You can only look up people in this community.`
|
|
297
|
-
: `This chat is scoped to this index. You can only look up people in this community.`);
|
|
296
|
+
if (scopedNetworkId && searchIndexId !== scopedNetworkId) {
|
|
297
|
+
return error(`This chat is scoped to ${scopedIndexLabel}. You can only look up people in this community.`);
|
|
298
298
|
}
|
|
299
299
|
const callerIsMember = await systemDb.isNetworkMember(searchIndexId, context.userId);
|
|
300
300
|
if (!callerIsMember) {
|
|
@@ -348,18 +348,16 @@ export function createEnrichmentTools(defineTool, deps) {
|
|
|
348
348
|
// When no userId / networkId / query is provided, fall through to Mode 1 (self lookup).
|
|
349
349
|
// --- Mode 3: networkId provided → fetch all member profiles ---
|
|
350
350
|
if (effectiveIndexId) {
|
|
351
|
-
// Strict scope enforcement: when chat is
|
|
352
|
-
if (
|
|
353
|
-
return error(
|
|
354
|
-
? `This chat is scoped to ${context.indexName}. You can only read profiles from this community.`
|
|
355
|
-
: `This chat is scoped to this index. You can only read profiles from this community.`);
|
|
351
|
+
// Strict scope enforcement: when chat is network-scoped, only allow querying that index
|
|
352
|
+
if (scopedNetworkId && effectiveIndexId !== scopedNetworkId) {
|
|
353
|
+
return error(`This chat is scoped to ${scopedIndexLabel}. You can only read profiles from this community.`);
|
|
356
354
|
}
|
|
357
|
-
// Verify the caller is a member of the
|
|
355
|
+
// Verify the caller is a member of the network they're querying
|
|
358
356
|
const callerIsMember = await systemDb.isNetworkMember(effectiveIndexId, context.userId);
|
|
359
357
|
if (!callerIsMember) {
|
|
360
358
|
return error("You can only read profiles from indexes you are a member of.");
|
|
361
359
|
}
|
|
362
|
-
// Use systemDb for cross-user access within shared
|
|
360
|
+
// Use systemDb for cross-user access within shared networkes
|
|
363
361
|
const members = await systemDb.getNetworkMembers(effectiveIndexId);
|
|
364
362
|
const profiles = await Promise.all(members.map(async (member) => {
|
|
365
363
|
const profile = await systemDb.getProfile(member.userId);
|
|
@@ -378,16 +376,14 @@ export function createEnrichmentTools(defineTool, deps) {
|
|
|
378
376
|
}
|
|
379
377
|
// --- Mode 2: userId provided (different user) → fetch single profile directly ---
|
|
380
378
|
if (targetUserId && targetUserId !== context.userId) {
|
|
381
|
-
// Strict scope enforcement: when chat is
|
|
382
|
-
if (
|
|
383
|
-
const isInScopedIndex = await systemDb.isNetworkMember(
|
|
379
|
+
// Strict scope enforcement: when chat is network-scoped, verify user is in that index
|
|
380
|
+
if (scopedNetworkId) {
|
|
381
|
+
const isInScopedIndex = await systemDb.isNetworkMember(scopedNetworkId, targetUserId);
|
|
384
382
|
if (!isInScopedIndex) {
|
|
385
|
-
return error(
|
|
386
|
-
? `This chat is scoped to ${context.indexName}. You can only read profiles of members in this community.`
|
|
387
|
-
: `This chat is scoped to this index. You can only read profiles of members in this community.`);
|
|
383
|
+
return error(`This chat is scoped to ${scopedIndexLabel}. You can only read profiles of members in this community.`);
|
|
388
384
|
}
|
|
389
385
|
}
|
|
390
|
-
// Use systemDb for cross-user profile access (requires shared
|
|
386
|
+
// Use systemDb for cross-user profile access (requires shared network)
|
|
391
387
|
const profile = await systemDb.getProfile(targetUserId);
|
|
392
388
|
if (profile) {
|
|
393
389
|
// Thin identity + the user's global user_context text (profile-replacing
|
|
@@ -522,9 +518,10 @@ export function createEnrichmentTools(defineTool, deps) {
|
|
|
522
518
|
message: `Profile preview started. Call get_enrichment_run with profileRunId="${profileRunId}" until it succeeds, fails, or is cancelled.`,
|
|
523
519
|
});
|
|
524
520
|
}
|
|
521
|
+
const scopedNetworkId = focusedNetworkId(context);
|
|
525
522
|
const onboarding = user.onboarding ?? context.user.onboarding;
|
|
526
523
|
const hasEdgeosConsent = hasEdgeosImportConsent(onboarding);
|
|
527
|
-
const seed = hasEdgeosConsent ? selectProfileSeed(onboarding,
|
|
524
|
+
const seed = hasEdgeosConsent ? selectProfileSeed(onboarding, scopedNetworkId) : undefined;
|
|
528
525
|
const authenticatedIdentity = resolveAuthenticatedLookupIdentity(user, context);
|
|
529
526
|
const name = seed?.name || authenticatedIdentity.name || query.name?.trim() || undefined;
|
|
530
527
|
const location = query.location?.trim() || seed?.location || user.location || undefined;
|
|
@@ -602,7 +599,7 @@ export function createEnrichmentTools(defineTool, deps) {
|
|
|
602
599
|
if (query.draft) {
|
|
603
600
|
const profile = { ...query.draft, userId: context.userId };
|
|
604
601
|
await userDb.saveProfile({ userId: context.userId, identity: profile.identity, context: profile.narrative?.context ?? '' });
|
|
605
|
-
await persistApprovedProfileContext(profile, user, context
|
|
602
|
+
await persistApprovedProfileContext(profile, user, focusedNetworkId(context));
|
|
606
603
|
const decomposeLogLabel = context.isMcp
|
|
607
604
|
? 'Approved draft premise decomposition failed'
|
|
608
605
|
: 'Approved draft premise decomposition failed (web)';
|
|
@@ -638,7 +635,7 @@ export function createEnrichmentTools(defineTool, deps) {
|
|
|
638
635
|
location: approvedLocation && approvedLocation.length > 0 ? approvedLocation : user?.location ?? '',
|
|
639
636
|
},
|
|
640
637
|
};
|
|
641
|
-
await persistApprovedProfileContext(rawProfile, user, context
|
|
638
|
+
await persistApprovedProfileContext(rawProfile, user, focusedNetworkId(context));
|
|
642
639
|
const _confirmTraceEmitter = requestContext.getStore()?.traceEmitter;
|
|
643
640
|
const _confirmGraphStart = Date.now();
|
|
644
641
|
_confirmTraceEmitter?.({ type: "graph_start", name: "enrichment" });
|