@indexnetwork/protocol 6.12.0-rc.403.1 → 6.13.22-rc.405.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +241 -0
- package/IMPLEMENTATION.md +20 -0
- package/STABILITY.md +4 -0
- package/dist/agent/agent.tools.d.ts +11 -3
- package/dist/agent/agent.tools.js +11 -301
- package/dist/capabilities/communities.facade.d.ts +13 -0
- package/dist/capabilities/communities.facade.js +12 -0
- package/dist/capabilities/communities.tools.port.d.ts +5 -0
- package/dist/capabilities/communities.tools.port.js +1 -0
- package/dist/capabilities/contacts.facade.d.ts +9 -0
- package/dist/capabilities/contacts.facade.js +8 -0
- package/dist/capabilities/contacts.tools.port.d.ts +9 -0
- package/dist/capabilities/contacts.tools.port.js +1 -0
- package/dist/capabilities/integrations.facade.d.ts +8 -0
- package/dist/capabilities/integrations.facade.js +7 -0
- package/dist/capabilities/integrations.tools.port.d.ts +9 -0
- package/dist/capabilities/integrations.tools.port.js +1 -0
- package/dist/capabilities/interaction-composition.facade.d.ts +10 -0
- package/dist/capabilities/interaction-composition.facade.js +9 -0
- package/dist/capabilities/negotiation.discovery.facade.d.ts +9 -0
- package/dist/capabilities/negotiation.discovery.facade.js +7 -0
- package/dist/capabilities/negotiation.facade.d.ts +23 -0
- package/dist/capabilities/negotiation.facade.js +17 -0
- package/dist/capabilities/negotiation.memory.facade.d.ts +6 -0
- package/dist/capabilities/negotiation.memory.facade.js +5 -0
- package/dist/capabilities/negotiation.questions.facade.d.ts +6 -0
- package/dist/capabilities/negotiation.questions.facade.js +5 -0
- package/dist/capabilities/negotiation.state.facade.d.ts +5 -0
- package/dist/capabilities/negotiation.state.facade.js +1 -0
- package/dist/capabilities/negotiation.summary.facade.d.ts +5 -0
- package/dist/capabilities/negotiation.summary.facade.js +5 -0
- package/dist/capabilities/negotiation.tools.port.d.ts +5 -0
- package/dist/capabilities/negotiation.tools.port.js +1 -0
- package/dist/capabilities/opportunities.facade.d.ts +50 -0
- package/dist/capabilities/opportunities.facade.js +50 -0
- package/dist/capabilities/opportunities.safety.facade.d.ts +2 -0
- package/dist/capabilities/opportunities.safety.facade.js +2 -0
- package/dist/capabilities/opportunities.tools.port.d.ts +5 -0
- package/dist/capabilities/opportunities.tools.port.js +1 -0
- package/dist/capabilities/participant-agents.debug.facade.d.ts +2 -0
- package/dist/capabilities/participant-agents.debug.facade.js +1 -0
- package/dist/capabilities/participant-agents.facade.d.ts +35 -0
- package/dist/capabilities/participant-agents.facade.js +35 -0
- package/dist/capabilities/participant-agents.tools.facade.d.ts +8 -0
- package/dist/capabilities/participant-agents.tools.facade.js +8 -0
- package/dist/capabilities/participant-agents.tools.port.d.ts +9 -0
- package/dist/capabilities/participant-agents.tools.port.js +1 -0
- package/dist/capabilities/participant-context.facade.d.ts +13 -0
- package/dist/capabilities/participant-context.facade.js +14 -0
- package/dist/capabilities/participant-context.tools.port.d.ts +9 -0
- package/dist/capabilities/participant-context.tools.port.js +1 -0
- package/dist/capabilities/questions.enqueue.facade.d.ts +5 -0
- package/dist/capabilities/questions.enqueue.facade.js +1 -0
- package/dist/capabilities/questions.facade.d.ts +8 -0
- package/dist/capabilities/questions.facade.js +7 -0
- package/dist/capabilities/questions.runtime.facade.d.ts +5 -0
- package/dist/capabilities/questions.runtime.facade.js +5 -0
- package/dist/capabilities/questions.tools.port.d.ts +5 -0
- package/dist/capabilities/questions.tools.port.js +1 -0
- package/dist/capabilities/signals.facade.d.ts +16 -0
- package/dist/capabilities/signals.facade.js +14 -0
- package/dist/capabilities/signals.indexing.facade.d.ts +12 -0
- package/dist/capabilities/signals.indexing.facade.js +11 -0
- package/dist/capabilities/signals.tools.port.d.ts +5 -0
- package/dist/capabilities/signals.tools.port.js +1 -0
- package/dist/chat/chat-streaming.types.d.ts +0 -1
- package/dist/chat/chat-streaming.types.js +1 -2
- package/dist/chat/chat.agent.d.ts +0 -1
- package/dist/chat/chat.agent.js +0 -1
- package/dist/chat/chat.graph.d.ts +0 -1
- package/dist/chat/chat.graph.js +0 -1
- package/dist/chat/chat.interrupt.classifier.d.ts +0 -1
- package/dist/chat/chat.interrupt.classifier.js +0 -1
- package/dist/chat/chat.persona.d.ts +0 -1
- package/dist/chat/chat.persona.js +0 -1
- package/dist/chat/chat.prompt.d.ts +0 -1
- package/dist/chat/chat.prompt.js +0 -1
- package/dist/chat/chat.prompt.modules.d.ts +0 -1
- package/dist/chat/chat.prompt.modules.js +0 -1
- package/dist/chat/chat.question-dedup.d.ts +0 -1
- package/dist/chat/chat.question-dedup.js +0 -1
- package/dist/chat/chat.state.d.ts +0 -1
- package/dist/chat/chat.state.js +0 -1
- package/dist/chat/chat.streamer.d.ts +0 -1
- package/dist/chat/chat.streamer.js +0 -1
- package/dist/chat/chat.suggester.d.ts +0 -1
- package/dist/chat/chat.suggester.js +0 -1
- package/dist/chat/chat.summarizer.d.ts +0 -1
- package/dist/chat/chat.summarizer.js +0 -1
- package/dist/chat/chat.title.generator.d.ts +0 -1
- package/dist/chat/chat.title.generator.js +0 -1
- package/dist/chat/chat.tools.d.ts +0 -1
- package/dist/chat/chat.tools.js +0 -1
- package/dist/chat/chat.utils.d.ts +0 -1
- package/dist/chat/chat.utils.js +0 -1
- package/dist/chat/negotiator.persona.d.ts +0 -1
- package/dist/chat/negotiator.persona.js +0 -1
- package/dist/chat/negotiator.prompt.d.ts +1 -2
- package/dist/chat/negotiator.prompt.js +1 -2
- package/dist/chat/negotiator.tools.d.ts +0 -1
- package/dist/chat/negotiator.tools.js +0 -1
- package/dist/chat/onboarding.persona.d.ts +0 -1
- package/dist/chat/onboarding.persona.js +0 -1
- package/dist/chat/onboarding.prompt.d.ts +0 -1
- package/dist/chat/onboarding.prompt.js +0 -1
- package/dist/chat/reporter.action.contracts.d.ts +36 -0
- package/dist/chat/reporter.action.contracts.js +1 -0
- package/dist/chat/reporter.action.tools.d.ts +2 -37
- package/dist/chat/reporter.action.tools.js +0 -1
- package/dist/chat/reporter.persona.d.ts +0 -1
- package/dist/chat/reporter.persona.js +0 -1
- package/dist/chat/reporter.prompt.d.ts +0 -1
- package/dist/chat/reporter.prompt.js +0 -1
- package/dist/chat/signal.persona.d.ts +0 -1
- package/dist/chat/signal.persona.js +0 -1
- package/dist/chat/signal.prompt.d.ts +0 -1
- package/dist/chat/signal.prompt.js +0 -1
- package/dist/communities/application/index.d.ts +45 -0
- package/dist/communities/application/index.js +50 -0
- package/dist/communities/application/indexer.graph.d.ts +446 -0
- package/dist/communities/application/indexer.graph.js +420 -0
- package/dist/communities/application/indexer.state.d.ts +172 -0
- package/dist/communities/application/indexer.state.js +116 -0
- package/dist/communities/application/membership.graph.d.ts +270 -0
- package/dist/communities/application/membership.graph.js +229 -0
- package/dist/communities/application/network.graph.d.ts +648 -0
- package/dist/communities/application/network.graph.js +303 -0
- package/dist/communities/application/network.recommender.d.ts +44 -0
- package/dist/communities/application/network.recommender.js +113 -0
- package/dist/communities/application/network.tools.d.ts +35 -0
- package/dist/communities/application/network.tools.js +578 -0
- package/dist/communities/domain/index.d.ts +29 -0
- package/dist/communities/domain/index.js +31 -0
- package/dist/communities/domain/membership.state.d.ts +87 -0
- package/dist/communities/domain/membership.state.js +53 -0
- package/dist/communities/domain/network.state.d.ts +192 -0
- package/dist/communities/domain/network.state.js +66 -0
- package/dist/communities/index.d.ts +14 -0
- package/dist/communities/index.js +14 -0
- package/dist/communities/ports/index.d.ts +25 -0
- package/dist/communities/ports/index.js +27 -0
- package/dist/communities/public/index.d.ts +30 -0
- package/dist/communities/public/index.js +33 -0
- package/dist/contact/contact.inviter.d.ts +7 -44
- package/dist/contact/contact.inviter.js +6 -59
- package/dist/contact/contact.tools.d.ts +7 -5
- package/dist/contact/contact.tools.js +7 -177
- package/dist/contacts/application/contact.inviter.d.ts +49 -0
- package/dist/contacts/application/contact.inviter.js +64 -0
- package/dist/contacts/application/contact.tools.d.ts +20 -0
- package/dist/contacts/application/contact.tools.js +191 -0
- package/dist/contacts/application/index.d.ts +22 -0
- package/dist/contacts/application/index.js +21 -0
- package/dist/contacts/domain/contact.types.d.ts +51 -0
- package/dist/contacts/domain/contact.types.js +10 -0
- package/dist/contacts/domain/index.d.ts +18 -0
- package/dist/contacts/domain/index.js +1 -0
- package/dist/contacts/index.d.ts +24 -0
- package/dist/contacts/index.js +24 -0
- package/dist/contacts/ports/contact.repository.port.d.ts +28 -0
- package/dist/contacts/ports/contact.repository.port.js +14 -0
- package/dist/contacts/ports/contact.tools.port.d.ts +26 -0
- package/dist/contacts/ports/contact.tools.port.js +21 -0
- package/dist/contacts/ports/index.d.ts +22 -0
- package/dist/contacts/ports/index.js +21 -0
- package/dist/contacts/public/index.d.ts +36 -0
- package/dist/contacts/public/index.js +33 -0
- package/dist/context/context.generator.d.ts +0 -1
- package/dist/context/context.generator.js +0 -1
- package/dist/enrichment/enrichment.enricher.d.ts +0 -1
- package/dist/enrichment/enrichment.enricher.js +0 -1
- package/dist/enrichment/enrichment.generator.d.ts +0 -1
- package/dist/enrichment/enrichment.generator.js +0 -1
- package/dist/enrichment/enrichment.graph.d.ts +6 -7
- package/dist/enrichment/enrichment.graph.js +0 -1
- package/dist/enrichment/enrichment.state.d.ts +2 -3
- package/dist/enrichment/enrichment.state.js +0 -1
- package/dist/enrichment/enrichment.tools.d.ts +3 -3
- package/dist/enrichment/enrichment.tools.js +0 -1
- package/dist/index.d.ts +106 -91
- package/dist/index.js +79 -71
- package/dist/integration/integration.tools.d.ts +6 -10
- package/dist/integration/integration.tools.js +6 -82
- package/dist/integrations/application/index.d.ts +14 -0
- package/dist/integrations/application/index.js +14 -0
- package/dist/integrations/application/integration.tools.d.ts +27 -0
- package/dist/integrations/application/integration.tools.js +98 -0
- package/dist/integrations/domain/index.d.ts +18 -0
- package/dist/integrations/domain/index.js +1 -0
- package/dist/integrations/domain/integration.types.d.ts +53 -0
- package/dist/integrations/domain/integration.types.js +11 -0
- package/dist/integrations/index.d.ts +27 -0
- package/dist/integrations/index.js +27 -0
- package/dist/integrations/ports/index.d.ts +28 -0
- package/dist/integrations/ports/index.js +26 -0
- package/dist/integrations/ports/integration.adapter.port.d.ts +62 -0
- package/dist/integrations/ports/integration.adapter.port.js +15 -0
- package/dist/integrations/ports/integration.importer.port.d.ts +31 -0
- package/dist/integrations/ports/integration.importer.port.js +15 -0
- package/dist/integrations/ports/integration.tools.port.d.ts +28 -0
- package/dist/integrations/ports/integration.tools.port.js +21 -0
- package/dist/integrations/public/index.d.ts +37 -0
- package/dist/integrations/public/index.js +34 -0
- package/dist/intent/intent.clarifier.d.ts +3 -52
- package/dist/intent/intent.clarifier.js +2 -202
- package/dist/intent/intent.graph.d.ts +3 -551
- package/dist/intent/intent.graph.js +3 -937
- package/dist/intent/intent.indexer.d.ts +2 -83
- package/dist/intent/intent.indexer.js +2 -171
- package/dist/intent/intent.inferrer.d.ts +2 -95
- package/dist/intent/intent.inferrer.js +2 -234
- package/dist/intent/intent.reconciler.d.ts +2 -106
- package/dist/intent/intent.reconciler.js +2 -187
- package/dist/intent/intent.specificity.d.ts +2 -3
- package/dist/intent/intent.specificity.js +2 -3
- package/dist/intent/intent.state.d.ts +8 -229
- package/dist/intent/intent.state.js +8 -189
- package/dist/intent/intent.tools.d.ts +6 -24
- package/dist/intent/intent.tools.js +4 -788
- package/dist/intent/intent.verifier.d.ts +2 -116
- package/dist/intent/intent.verifier.js +2 -263
- package/dist/maintenance/maintenance.graph.d.ts +0 -1
- package/dist/maintenance/maintenance.graph.js +0 -1
- package/dist/maintenance/maintenance.state.d.ts +0 -1
- package/dist/maintenance/maintenance.state.js +0 -1
- package/dist/mcp/elicitation.builder.d.ts +0 -1
- package/dist/mcp/elicitation.builder.js +0 -1
- package/dist/mcp/elicitation.dispatcher.d.ts +0 -1
- package/dist/mcp/elicitation.dispatcher.js +0 -1
- package/dist/mcp/mcp.server.d.ts +0 -1
- package/dist/mcp/mcp.server.js +1 -2
- package/dist/negotiation/application/index.d.ts +48 -0
- package/dist/negotiation/application/index.js +49 -0
- package/dist/negotiation/application/insight.generator.d.ts +31 -0
- package/dist/negotiation/application/insight.generator.js +105 -0
- package/dist/negotiation/application/negotiation.agent.d.ts +110 -0
- package/dist/negotiation/application/negotiation.agent.js +244 -0
- package/dist/negotiation/application/negotiation.detail-reader.d.ts +94 -0
- package/dist/negotiation/application/negotiation.detail-reader.js +91 -0
- package/dist/negotiation/application/negotiation.graph.d.ts +664 -0
- package/dist/negotiation/application/negotiation.graph.js +1393 -0
- package/dist/negotiation/application/negotiation.reflect.d.ts +194 -0
- package/dist/negotiation/application/negotiation.reflect.js +145 -0
- package/dist/negotiation/application/negotiation.screen.d.ts +78 -0
- package/dist/negotiation/application/negotiation.screen.js +108 -0
- package/dist/negotiation/application/negotiation.summarizer.d.ts +25 -0
- package/dist/negotiation/application/negotiation.summarizer.js +101 -0
- package/dist/negotiation/application/negotiation.tools.d.ts +18 -0
- package/dist/negotiation/application/negotiation.tools.js +782 -0
- package/dist/negotiation/domain/index.d.ts +48 -0
- package/dist/negotiation/domain/index.js +50 -0
- package/dist/negotiation/domain/negotiation.consultation-policy.d.ts +39 -0
- package/dist/negotiation/domain/negotiation.consultation-policy.js +68 -0
- package/dist/negotiation/domain/negotiation.deadlock.contracts.d.ts +10 -0
- package/dist/negotiation/domain/negotiation.deadlock.contracts.js +1 -0
- package/dist/negotiation/domain/negotiation.deadlock.d.ts +81 -0
- package/dist/negotiation/domain/negotiation.deadlock.js +103 -0
- package/dist/negotiation/domain/negotiation.intent-snapshot-provenance.d.ts +21 -0
- package/dist/negotiation/domain/negotiation.intent-snapshot-provenance.js +28 -0
- package/dist/negotiation/domain/negotiation.lifecycle-narration.d.ts +18 -0
- package/dist/negotiation/domain/negotiation.lifecycle-narration.js +87 -0
- package/dist/negotiation/domain/negotiation.memory.d.ts +65 -0
- package/dist/negotiation/domain/negotiation.memory.js +83 -0
- package/dist/negotiation/domain/negotiation.protocol.d.ts +536 -0
- package/dist/negotiation/domain/negotiation.protocol.js +202 -0
- package/dist/negotiation/domain/negotiation.question-safety.d.ts +25 -0
- package/dist/negotiation/domain/negotiation.question-safety.js +55 -0
- package/dist/negotiation/domain/negotiation.screen.contracts.d.ts +88 -0
- package/dist/negotiation/domain/negotiation.screen.contracts.js +58 -0
- package/dist/negotiation/domain/negotiation.state.d.ts +497 -0
- package/dist/negotiation/domain/negotiation.state.js +288 -0
- package/dist/negotiation/domain/negotiation.task-lock-policy.d.ts +10 -0
- package/dist/negotiation/domain/negotiation.task-lock-policy.js +22 -0
- package/dist/negotiation/index.d.ts +49 -0
- package/dist/negotiation/index.js +49 -0
- package/dist/negotiation/insight.generator.d.ts +3 -30
- package/dist/negotiation/insight.generator.js +3 -104
- package/dist/negotiation/negotiation.agent.d.ts +3 -109
- package/dist/negotiation/negotiation.agent.js +3 -248
- package/dist/negotiation/negotiation.attribution.d.ts +0 -1
- package/dist/negotiation/negotiation.attribution.js +0 -1
- package/dist/negotiation/negotiation.consultation-policy.d.ts +3 -38
- package/dist/negotiation/negotiation.consultation-policy.js +3 -67
- package/dist/negotiation/negotiation.deadlock.contracts.d.ts +5 -0
- package/dist/negotiation/negotiation.deadlock.contracts.js +5 -0
- package/dist/negotiation/negotiation.deadlock.d.ts +3 -94
- package/dist/negotiation/negotiation.deadlock.js +3 -101
- package/dist/negotiation/negotiation.detail-reader.d.ts +5 -0
- package/dist/negotiation/negotiation.detail-reader.js +5 -0
- package/dist/negotiation/negotiation.graph.d.ts +3 -663
- package/dist/negotiation/negotiation.graph.js +3 -1459
- package/dist/negotiation/negotiation.intent-snapshot-provenance.d.ts +5 -0
- package/dist/negotiation/negotiation.intent-snapshot-provenance.js +5 -0
- package/dist/negotiation/negotiation.lifecycle-narration.d.ts +5 -0
- package/dist/negotiation/negotiation.lifecycle-narration.js +5 -0
- package/dist/negotiation/negotiation.memory.d.ts +5 -56
- package/dist/negotiation/negotiation.memory.js +5 -69
- package/dist/negotiation/negotiation.protocol.d.ts +3 -535
- package/dist/negotiation/negotiation.protocol.js +3 -201
- package/dist/negotiation/negotiation.question-safety.d.ts +3 -24
- package/dist/negotiation/negotiation.question-safety.js +3 -54
- package/dist/negotiation/negotiation.reflect.d.ts +4 -197
- package/dist/negotiation/negotiation.reflect.js +4 -151
- package/dist/negotiation/negotiation.screen.d.ts +6 -159
- package/dist/negotiation/negotiation.screen.js +6 -152
- package/dist/negotiation/negotiation.state.d.ts +3 -495
- package/dist/negotiation/negotiation.state.js +3 -284
- package/dist/negotiation/negotiation.summarizer.d.ts +3 -24
- package/dist/negotiation/negotiation.summarizer.js +3 -100
- package/dist/negotiation/negotiation.task-lock-policy.d.ts +5 -0
- package/dist/negotiation/negotiation.task-lock-policy.js +5 -0
- package/dist/negotiation/negotiation.tools.d.ts +3 -15
- package/dist/negotiation/negotiation.tools.js +3 -946
- package/dist/negotiation/ports/index.d.ts +18 -0
- package/dist/negotiation/ports/index.js +18 -0
- package/dist/negotiation/ports/negotiation.tools.port.d.ts +18 -0
- package/dist/negotiation/ports/negotiation.tools.port.js +1 -0
- package/dist/negotiation/public/index.d.ts +58 -0
- package/dist/negotiation/public/index.js +60 -0
- package/dist/network/indexer/indexer.graph.d.ts +3 -413
- package/dist/network/indexer/indexer.graph.js +3 -375
- package/dist/network/indexer/indexer.state.d.ts +3 -149
- package/dist/network/indexer/indexer.state.js +3 -98
- package/dist/network/membership/membership.graph.d.ts +3 -248
- package/dist/network/membership/membership.graph.js +3 -202
- package/dist/network/membership/membership.state.d.ts +3 -75
- package/dist/network/membership/membership.state.js +3 -41
- package/dist/network/network.graph.d.ts +3 -629
- package/dist/network/network.graph.js +3 -267
- package/dist/network/network.recommender.d.ts +3 -40
- package/dist/network/network.recommender.js +3 -109
- package/dist/network/network.state.d.ts +3 -180
- package/dist/network/network.state.js +3 -54
- package/dist/network/network.tools.d.ts +5 -3
- package/dist/network/network.tools.js +5 -566
- package/dist/opportunity/application/delivery-card.cache.d.ts +25 -0
- package/dist/opportunity/application/delivery-card.cache.js +43 -0
- package/dist/opportunity/application/index.d.ts +63 -0
- package/dist/opportunity/application/index.js +68 -0
- package/dist/opportunity/application/negotiation-context.loader.d.ts +59 -0
- package/dist/opportunity/application/negotiation-context.loader.js +88 -0
- package/dist/opportunity/application/opportunity.card-presentation.d.ts +44 -0
- package/dist/opportunity/application/opportunity.card-presentation.js +104 -0
- package/dist/opportunity/application/opportunity.discover.d.ts +215 -0
- package/dist/opportunity/application/opportunity.discover.js +793 -0
- package/dist/opportunity/application/opportunity.discovery-continuation-finalization.d.ts +34 -0
- package/dist/opportunity/application/opportunity.discovery-continuation-finalization.js +74 -0
- package/dist/opportunity/application/opportunity.discovery-mcp-lifecycle-finalization.d.ts +44 -0
- package/dist/opportunity/application/opportunity.discovery-mcp-lifecycle-finalization.js +92 -0
- package/dist/opportunity/application/opportunity.discovery-negotiation-summary.d.ts +14 -0
- package/dist/opportunity/application/opportunity.discovery-negotiation-summary.js +46 -0
- package/dist/opportunity/application/opportunity.enricher.d.ts +71 -0
- package/dist/opportunity/application/opportunity.enricher.js +280 -0
- package/dist/opportunity/application/opportunity.evaluator.d.ts +275 -0
- package/dist/opportunity/application/opportunity.evaluator.js +459 -0
- package/dist/opportunity/application/opportunity.existing-negotiation.d.ts +77 -0
- package/dist/opportunity/application/opportunity.existing-negotiation.js +109 -0
- package/dist/opportunity/application/opportunity.feed-selection.d.ts +30 -0
- package/dist/opportunity/application/opportunity.feed-selection.js +96 -0
- package/dist/opportunity/application/opportunity.graph.d.ts +1427 -0
- package/dist/opportunity/application/opportunity.graph.js +3693 -0
- package/dist/opportunity/application/opportunity.introducer.d.ts +77 -0
- package/dist/opportunity/application/opportunity.introducer.js +99 -0
- package/dist/opportunity/application/opportunity.lifecycle.d.ts +63 -0
- package/dist/opportunity/application/opportunity.lifecycle.js +181 -0
- package/dist/opportunity/application/opportunity.newborn-stamping.d.ts +41 -0
- package/dist/opportunity/application/opportunity.newborn-stamping.js +81 -0
- package/dist/opportunity/application/opportunity.pending-questions.d.ts +33 -0
- package/dist/opportunity/application/opportunity.pending-questions.js +42 -0
- package/dist/opportunity/application/opportunity.persist.d.ts +58 -0
- package/dist/opportunity/application/opportunity.persist.js +145 -0
- package/dist/opportunity/application/opportunity.persistence-admission.d.ts +39 -0
- package/dist/opportunity/application/opportunity.persistence-admission.js +59 -0
- package/dist/opportunity/application/opportunity.presenter.d.ts +156 -0
- package/dist/opportunity/application/opportunity.presenter.js +736 -0
- package/dist/opportunity/application/opportunity.tools.d.ts +131 -0
- package/dist/opportunity/application/opportunity.tools.js +1834 -0
- package/dist/opportunity/application/opportunity.update-admission.d.ts +24 -0
- package/dist/opportunity/application/opportunity.update-admission.js +38 -0
- package/dist/opportunity/delivery-card.cache.d.ts +5 -26
- package/dist/opportunity/delivery-card.cache.js +5 -44
- package/dist/opportunity/discovery-question.helper.d.ts +3 -17
- package/dist/opportunity/discovery-question.helper.js +3 -14
- package/dist/opportunity/discriminator/discriminator.adjustments.d.ts +0 -1
- package/dist/opportunity/discriminator/discriminator.adjustments.js +0 -1
- package/dist/opportunity/discriminator/discriminator.assigner.d.ts +4 -5
- package/dist/opportunity/discriminator/discriminator.assigner.js +0 -1
- package/dist/opportunity/discriminator/discriminator.env.d.ts +0 -1
- package/dist/opportunity/discriminator/discriminator.env.js +0 -1
- package/dist/opportunity/discriminator/discriminator.miner.d.ts +0 -1
- package/dist/opportunity/discriminator/discriminator.miner.js +0 -1
- package/dist/opportunity/discriminator/discriminator.push.d.ts +0 -1
- package/dist/opportunity/discriminator/discriminator.push.js +0 -1
- package/dist/opportunity/discriminator/discriminator.question.d.ts +0 -1
- package/dist/opportunity/discriminator/discriminator.question.js +0 -1
- package/dist/opportunity/discriminator/discriminator.scorer.d.ts +0 -1
- package/dist/opportunity/discriminator/discriminator.scorer.js +0 -1
- package/dist/opportunity/discriminator/discriminator.shadow.d.ts +0 -1
- package/dist/opportunity/discriminator/discriminator.shadow.js +0 -1
- package/dist/opportunity/discriminator/discriminator.types.d.ts +0 -1
- package/dist/opportunity/discriminator/discriminator.types.js +0 -1
- package/dist/opportunity/domain/discovery-question.helper.d.ts +18 -0
- package/dist/opportunity/domain/discovery-question.helper.js +15 -0
- package/dist/opportunity/domain/index.d.ts +55 -0
- package/dist/opportunity/domain/index.js +52 -0
- package/dist/opportunity/domain/negotiation-summary.builder.d.ts +37 -0
- package/dist/opportunity/domain/negotiation-summary.builder.js +66 -0
- package/dist/opportunity/domain/opportunity.actor.d.ts +15 -0
- package/dist/opportunity/domain/opportunity.actor.js +39 -0
- package/dist/opportunity/domain/opportunity.claim-safety.d.ts +24 -0
- package/dist/opportunity/domain/opportunity.claim-safety.js +88 -0
- package/dist/opportunity/domain/opportunity.discovery-run-coalescing.d.ts +33 -0
- package/dist/opportunity/domain/opportunity.discovery-run-coalescing.js +33 -0
- package/dist/opportunity/domain/opportunity.discovery.contracts.d.ts +45 -0
- package/dist/opportunity/domain/opportunity.discovery.contracts.js +1 -0
- package/dist/opportunity/domain/opportunity.evidence.d.ts +21 -0
- package/dist/opportunity/domain/opportunity.evidence.js +78 -0
- package/dist/opportunity/domain/opportunity.labels.d.ts +8 -0
- package/dist/opportunity/domain/opportunity.labels.js +10 -0
- package/dist/opportunity/domain/opportunity.presentation-cache.d.ts +6 -0
- package/dist/opportunity/domain/opportunity.presentation-cache.js +14 -0
- package/dist/opportunity/domain/opportunity.presentation.d.ts +76 -0
- package/dist/opportunity/domain/opportunity.presentation.js +516 -0
- package/dist/opportunity/domain/opportunity.safe-presentation.d.ts +104 -0
- package/dist/opportunity/domain/opportunity.safe-presentation.js +102 -0
- package/dist/opportunity/domain/opportunity.state.d.ts +519 -0
- package/dist/opportunity/domain/opportunity.state.js +309 -0
- package/dist/opportunity/domain/opportunity.utils.d.ts +217 -0
- package/dist/opportunity/domain/opportunity.utils.js +395 -0
- package/dist/opportunity/feed/feed.categorizer.d.ts +0 -1
- package/dist/opportunity/feed/feed.categorizer.js +0 -1
- package/dist/opportunity/feed/feed.graph.d.ts +1 -2
- package/dist/opportunity/feed/feed.graph.js +0 -1
- package/dist/opportunity/feed/feed.health.d.ts +0 -1
- package/dist/opportunity/feed/feed.health.js +0 -1
- package/dist/opportunity/feed/feed.state.d.ts +1 -2
- package/dist/opportunity/feed/feed.state.js +0 -1
- package/dist/opportunity/index.d.ts +37 -0
- package/dist/opportunity/index.js +37 -0
- package/dist/opportunity/negotiation-context.loader.d.ts +3 -58
- package/dist/opportunity/negotiation-context.loader.js +3 -87
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.env.d.ts +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.env.js +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.extractor.d.ts +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.extractor.js +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.miner.d.ts +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.miner.js +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.shadow.d.ts +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.shadow.js +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.types.d.ts +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.types.js +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.verifier.d.ts +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.verifier.js +0 -1
- package/dist/opportunity/negotiation-summary.builder.d.ts +3 -36
- package/dist/opportunity/negotiation-summary.builder.js +3 -65
- package/dist/opportunity/opportunity.actor.d.ts +3 -14
- package/dist/opportunity/opportunity.actor.js +3 -38
- package/dist/opportunity/opportunity.card-presentation.d.ts +5 -0
- package/dist/opportunity/opportunity.card-presentation.js +5 -0
- package/dist/opportunity/opportunity.claim-safety.d.ts +3 -23
- package/dist/opportunity/opportunity.claim-safety.js +3 -87
- package/dist/opportunity/opportunity.discover.d.ts +3 -218
- package/dist/opportunity/opportunity.discover.js +3 -917
- package/dist/opportunity/opportunity.discovery-continuation-finalization.d.ts +5 -0
- package/dist/opportunity/opportunity.discovery-continuation-finalization.js +5 -0
- package/dist/opportunity/opportunity.discovery-mcp-lifecycle-finalization.d.ts +5 -0
- package/dist/opportunity/opportunity.discovery-mcp-lifecycle-finalization.js +5 -0
- package/dist/opportunity/opportunity.discovery-negotiation-summary.d.ts +5 -0
- package/dist/opportunity/opportunity.discovery-negotiation-summary.js +5 -0
- package/dist/opportunity/opportunity.discovery-run-coalescing.d.ts +5 -0
- package/dist/opportunity/opportunity.discovery-run-coalescing.js +5 -0
- package/dist/opportunity/opportunity.discovery.contracts.d.ts +5 -0
- package/dist/opportunity/opportunity.discovery.contracts.js +5 -0
- package/dist/opportunity/opportunity.enricher.d.ts +3 -70
- package/dist/opportunity/opportunity.enricher.js +3 -279
- package/dist/opportunity/opportunity.evaluator.d.ts +5 -276
- package/dist/opportunity/opportunity.evaluator.js +5 -460
- package/dist/opportunity/opportunity.evidence.d.ts +5 -22
- package/dist/opportunity/opportunity.evidence.js +5 -79
- package/dist/opportunity/opportunity.existing-negotiation.d.ts +5 -0
- package/dist/opportunity/opportunity.existing-negotiation.js +5 -0
- package/dist/opportunity/opportunity.feed-selection.d.ts +5 -0
- package/dist/opportunity/opportunity.feed-selection.js +5 -0
- package/dist/opportunity/opportunity.graph.d.ts +3 -1489
- package/dist/opportunity/opportunity.graph.js +3 -4071
- package/dist/opportunity/opportunity.introducer.d.ts +3 -76
- package/dist/opportunity/opportunity.introducer.js +3 -98
- package/dist/opportunity/opportunity.labels.d.ts +5 -9
- package/dist/opportunity/opportunity.labels.js +5 -11
- package/dist/opportunity/opportunity.lifecycle.d.ts +5 -0
- package/dist/opportunity/opportunity.lifecycle.js +5 -0
- package/dist/opportunity/opportunity.newborn-stamping.d.ts +5 -0
- package/dist/opportunity/opportunity.newborn-stamping.js +5 -0
- package/dist/opportunity/opportunity.pending-questions.d.ts +3 -32
- package/dist/opportunity/opportunity.pending-questions.js +3 -41
- package/dist/opportunity/opportunity.persist.d.ts +3 -57
- package/dist/opportunity/opportunity.persist.js +3 -144
- package/dist/opportunity/opportunity.persistence-admission.d.ts +5 -0
- package/dist/opportunity/opportunity.persistence-admission.js +5 -0
- package/dist/opportunity/opportunity.presentation-cache.d.ts +5 -7
- package/dist/opportunity/opportunity.presentation-cache.js +5 -15
- package/dist/opportunity/opportunity.presentation.d.ts +3 -75
- package/dist/opportunity/opportunity.presentation.js +3 -515
- package/dist/opportunity/opportunity.presenter.d.ts +10 -155
- package/dist/opportunity/opportunity.presenter.js +10 -735
- package/dist/opportunity/opportunity.safe-presentation.d.ts +3 -103
- package/dist/opportunity/opportunity.safe-presentation.js +3 -101
- package/dist/opportunity/opportunity.state.d.ts +3 -518
- package/dist/opportunity/opportunity.state.js +3 -308
- package/dist/opportunity/opportunity.tools.d.ts +3 -157
- package/dist/opportunity/opportunity.tools.js +3 -2238
- package/dist/opportunity/opportunity.update-admission.d.ts +5 -0
- package/dist/opportunity/opportunity.update-admission.js +5 -0
- package/dist/opportunity/opportunity.utils.d.ts +3 -216
- package/dist/opportunity/opportunity.utils.js +3 -394
- package/dist/opportunity/outcome/outcome.env.d.ts +0 -1
- package/dist/opportunity/outcome/outcome.env.js +0 -1
- package/dist/opportunity/outcome/outcome.hypotheses.d.ts +0 -1
- package/dist/opportunity/outcome/outcome.hypotheses.js +0 -1
- package/dist/opportunity/outcome/outcome.shadow.d.ts +0 -1
- package/dist/opportunity/outcome/outcome.shadow.js +0 -1
- package/dist/opportunity/outcome/outcome.types.d.ts +0 -1
- package/dist/opportunity/outcome/outcome.types.js +0 -1
- package/dist/opportunity/ports/index.d.ts +5 -0
- package/dist/opportunity/ports/index.js +1 -0
- package/dist/opportunity/ports/opportunity.tools.port.d.ts +5 -0
- package/dist/opportunity/ports/opportunity.tools.port.js +1 -0
- package/dist/opportunity/public/index.d.ts +58 -0
- package/dist/opportunity/public/index.js +51 -0
- package/dist/participant-agents/application/agent.tools.d.ts +16 -0
- package/dist/participant-agents/application/agent.tools.js +313 -0
- package/dist/participant-agents/application/index.d.ts +21 -0
- package/dist/participant-agents/application/index.js +22 -0
- package/dist/participant-agents/domain/agent.types.d.ts +76 -0
- package/dist/participant-agents/domain/agent.types.js +22 -0
- package/dist/participant-agents/domain/index.d.ts +20 -0
- package/dist/participant-agents/domain/index.js +1 -0
- package/dist/participant-agents/index.d.ts +24 -0
- package/dist/participant-agents/index.js +24 -0
- package/dist/participant-agents/ports/agent.dispatcher.port.d.ts +25 -0
- package/dist/participant-agents/ports/agent.dispatcher.port.js +1 -0
- package/dist/participant-agents/ports/agent.repository.port.d.ts +118 -0
- package/dist/participant-agents/ports/agent.repository.port.js +10 -0
- package/dist/participant-agents/ports/agent.tools.port.d.ts +24 -0
- package/dist/participant-agents/ports/agent.tools.port.js +20 -0
- package/dist/participant-agents/ports/index.d.ts +29 -0
- package/dist/participant-agents/ports/index.js +27 -0
- package/dist/participant-agents/public/index.d.ts +39 -0
- package/dist/participant-agents/public/index.js +36 -0
- package/dist/participant-context/application/index.d.ts +73 -0
- package/dist/participant-context/application/index.js +83 -0
- package/dist/participant-context/domain/index.d.ts +67 -0
- package/dist/participant-context/domain/index.js +68 -0
- package/dist/participant-context/index.d.ts +16 -0
- package/dist/participant-context/index.js +16 -0
- package/dist/participant-context/ports/index.d.ts +37 -0
- package/dist/participant-context/ports/index.js +34 -0
- package/dist/participant-context/public/index.d.ts +48 -0
- package/dist/participant-context/public/index.js +55 -0
- package/dist/platform/index.d.ts +19 -0
- package/dist/platform/index.js +23 -0
- package/dist/premise/premise.analyzer.d.ts +0 -1
- package/dist/premise/premise.analyzer.js +0 -2
- package/dist/premise/premise.decomposer.d.ts +0 -1
- package/dist/premise/premise.decomposer.js +0 -2
- package/dist/premise/premise.graph.d.ts +1 -2
- package/dist/premise/premise.graph.js +0 -2
- package/dist/premise/premise.indexer.d.ts +0 -1
- package/dist/premise/premise.indexer.js +0 -2
- package/dist/premise/premise.state.d.ts +1 -2
- package/dist/premise/premise.state.js +0 -1
- package/dist/premise/premise.tools.d.ts +3 -3
- package/dist/premise/premise.tools.js +0 -2
- package/dist/public/index.d.ts +17 -0
- package/dist/public/index.js +17 -0
- package/dist/questioner/questioner.agent.d.ts +4 -27
- package/dist/questioner/questioner.agent.js +3 -133
- package/dist/questioner/questioner.ask.tool.d.ts +3 -12
- package/dist/questioner/questioner.ask.tool.js +3 -299
- package/dist/questioner/questioner.discovery.prompt.d.ts +3 -7
- package/dist/questioner/questioner.discovery.prompt.js +3 -180
- package/dist/questioner/questioner.env.d.ts +3 -57
- package/dist/questioner/questioner.env.js +3 -93
- package/dist/questioner/questioner.presets.d.ts +4 -19
- package/dist/questioner/questioner.presets.js +3 -465
- package/dist/questioner/questioner.qud.d.ts +3 -6
- package/dist/questioner/questioner.qud.js +3 -10
- package/dist/questioner/questioner.tools.d.ts +3 -15
- package/dist/questioner/questioner.tools.js +3 -186
- package/dist/questioner/questioner.types.d.ts +4 -218
- package/dist/questioner/questioner.types.js +5 -62
- package/dist/questions/application/index.d.ts +39 -0
- package/dist/questions/application/index.js +41 -0
- package/dist/questions/application/question.agent.d.ts +28 -0
- package/dist/questions/application/question.agent.js +139 -0
- package/dist/questions/application/question.ask.tool.d.ts +12 -0
- package/dist/questions/application/question.ask.tool.js +300 -0
- package/dist/questions/application/question.discovery.prompt.d.ts +8 -0
- package/dist/questions/application/question.discovery.prompt.js +181 -0
- package/dist/questions/application/question.env.d.ts +61 -0
- package/dist/questions/application/question.env.js +97 -0
- package/dist/questions/application/question.input.d.ts +237 -0
- package/dist/questions/application/question.input.js +61 -0
- package/dist/questions/application/question.presets.d.ts +24 -0
- package/dist/questions/application/question.presets.js +445 -0
- package/dist/questions/application/question.qud.d.ts +12 -0
- package/dist/questions/application/question.qud.js +16 -0
- package/dist/questions/application/question.tools.d.ts +15 -0
- package/dist/questions/application/question.tools.js +190 -0
- package/dist/questions/domain/index.d.ts +25 -0
- package/dist/questions/domain/index.js +25 -0
- package/dist/questions/domain/question.schema.d.ts +1537 -0
- package/dist/questions/domain/question.schema.js +422 -0
- package/dist/questions/index.d.ts +22 -0
- package/dist/questions/index.js +22 -0
- package/dist/questions/ports/index.d.ts +29 -0
- package/dist/questions/ports/index.js +27 -0
- package/dist/questions/ports/question.generator.port.d.ts +34 -0
- package/dist/questions/ports/question.generator.port.js +1 -0
- package/dist/questions/ports/question.persistence.port.d.ts +87 -0
- package/dist/questions/ports/question.persistence.port.js +1 -0
- package/dist/questions/ports/question.tools.port.d.ts +15 -0
- package/dist/questions/ports/question.tools.port.js +1 -0
- package/dist/questions/public/index.d.ts +47 -0
- package/dist/questions/public/index.js +49 -0
- package/dist/runtime/background/index.d.ts +14 -0
- package/dist/runtime/background/index.js +14 -0
- package/dist/runtime/foreground/composition/tool.factory.d.ts +16 -0
- package/dist/runtime/foreground/composition/tool.factory.js +224 -0
- package/dist/runtime/foreground/composition/tool.registry.d.ts +11 -0
- package/dist/runtime/foreground/composition/tool.registry.js +106 -0
- package/dist/runtime/foreground/index.d.ts +13 -0
- package/dist/runtime/foreground/index.js +13 -0
- package/dist/runtime/foreground/signals/intent.tools.d.ts +13 -0
- package/dist/runtime/foreground/signals/intent.tools.js +13 -0
- package/dist/shared/agent/model-signal.d.ts +0 -1
- package/dist/shared/agent/model-signal.js +0 -1
- package/dist/shared/agent/model.config.d.ts +0 -1
- package/dist/shared/agent/model.config.js +0 -1
- package/dist/shared/agent/tool.factory.d.ts +4 -15
- package/dist/shared/agent/tool.factory.js +4 -226
- package/dist/shared/agent/tool.helpers.d.ts +51 -12
- package/dist/shared/agent/tool.helpers.js +0 -1
- package/dist/shared/agent/tool.registry.d.ts +9 -9
- package/dist/shared/agent/tool.registry.js +9 -104
- package/dist/shared/agent/tool.runtime.d.ts +0 -1
- package/dist/shared/agent/tool.runtime.js +0 -1
- package/dist/shared/agent/tool.scope.d.ts +0 -1
- package/dist/shared/agent/tool.scope.js +0 -1
- package/dist/shared/agent/utility.tools.d.ts +5 -3
- package/dist/shared/agent/utility.tools.js +0 -1
- package/dist/shared/assignment/network-assignment.policy.d.ts +0 -1
- package/dist/shared/assignment/network-assignment.policy.js +0 -1
- package/dist/shared/hyde/hyde.documents.d.ts +0 -1
- package/dist/shared/hyde/hyde.documents.js +0 -1
- package/dist/shared/hyde/hyde.env.d.ts +0 -1
- package/dist/shared/hyde/hyde.env.js +0 -1
- package/dist/shared/hyde/hyde.frame.d.ts +4 -5
- package/dist/shared/hyde/hyde.frame.js +0 -1
- package/dist/shared/hyde/hyde.generator.d.ts +0 -1
- package/dist/shared/hyde/hyde.generator.js +0 -1
- package/dist/shared/hyde/hyde.graph.d.ts +0 -1
- package/dist/shared/hyde/hyde.graph.js +0 -1
- package/dist/shared/hyde/hyde.state.d.ts +0 -1
- package/dist/shared/hyde/hyde.state.js +0 -1
- package/dist/shared/hyde/hyde.strategies.d.ts +0 -1
- package/dist/shared/hyde/hyde.strategies.js +0 -1
- package/dist/shared/hyde/hyde.validator.d.ts +0 -1
- package/dist/shared/hyde/hyde.validator.js +0 -1
- package/dist/shared/hyde/lens.inferrer.d.ts +6 -7
- package/dist/shared/hyde/lens.inferrer.js +0 -1
- package/dist/shared/interfaces/agent-dispatcher.interface.d.ts +4 -1
- package/dist/shared/interfaces/agent-dispatcher.interface.js +4 -1
- package/dist/shared/interfaces/agent.interface.d.ts +13 -173
- package/dist/shared/interfaces/agent.interface.js +12 -12
- package/dist/shared/interfaces/auth.interface.d.ts +0 -1
- package/dist/shared/interfaces/auth.interface.js +0 -1
- package/dist/shared/interfaces/cache.interface.d.ts +0 -1
- package/dist/shared/interfaces/cache.interface.js +0 -1
- package/dist/shared/interfaces/chat-message-writer.interface.d.ts +0 -1
- package/dist/shared/interfaces/chat-message-writer.interface.js +0 -1
- package/dist/shared/interfaces/chat-session.interface.d.ts +0 -1
- package/dist/shared/interfaces/chat-session.interface.js +0 -1
- package/dist/shared/interfaces/chat-summary.interface.d.ts +0 -1
- package/dist/shared/interfaces/chat-summary.interface.js +0 -1
- package/dist/shared/interfaces/connect-link.interface.d.ts +0 -1
- package/dist/shared/interfaces/connect-link.interface.js +0 -1
- package/dist/shared/interfaces/contact.interface.d.ts +7 -55
- package/dist/shared/interfaces/contact.interface.js +7 -1
- package/dist/shared/interfaces/database.interface.d.ts +0 -1
- package/dist/shared/interfaces/database.interface.js +0 -1
- package/dist/shared/interfaces/delivery-ledger.interface.d.ts +0 -1
- package/dist/shared/interfaces/delivery-ledger.interface.js +0 -1
- package/dist/shared/interfaces/discovery-run.interface.d.ts +2 -3
- package/dist/shared/interfaces/discovery-run.interface.js +0 -1
- package/dist/shared/interfaces/embedder.interface.d.ts +0 -1
- package/dist/shared/interfaces/embedder.interface.js +0 -1
- package/dist/shared/interfaces/enrichment-run.interface.d.ts +2 -3
- package/dist/shared/interfaces/enrichment-run.interface.js +0 -1
- package/dist/shared/interfaces/enrichment.interface.d.ts +0 -1
- package/dist/shared/interfaces/enrichment.interface.js +0 -1
- package/dist/shared/interfaces/integration.interface.d.ts +6 -88
- package/dist/shared/interfaces/integration.interface.js +7 -1
- package/dist/shared/interfaces/negotiation-events.interface.d.ts +0 -1
- package/dist/shared/interfaces/negotiation-events.interface.js +0 -1
- package/dist/shared/interfaces/negotiation-summary.interface.d.ts +0 -1
- package/dist/shared/interfaces/negotiation-summary.interface.js +0 -1
- package/dist/shared/interfaces/negotiator-memory.interface.d.ts +0 -1
- package/dist/shared/interfaces/negotiator-memory.interface.js +0 -1
- package/dist/shared/interfaces/question-generator.interface.d.ts +3 -28
- package/dist/shared/interfaces/question-generator.interface.js +0 -1
- package/dist/shared/interfaces/questioner.interface.d.ts +3 -77
- package/dist/shared/interfaces/questioner.interface.js +0 -1
- package/dist/shared/interfaces/queue.interface.d.ts +0 -1
- package/dist/shared/interfaces/queue.interface.js +0 -1
- package/dist/shared/interfaces/scraper.interface.d.ts +0 -1
- package/dist/shared/interfaces/scraper.interface.js +0 -1
- package/dist/shared/interfaces/tool-request-context.interface.d.ts +12 -0
- package/dist/shared/interfaces/tool-request-context.interface.js +1 -0
- package/dist/shared/network/metadata.renderer.d.ts +0 -1
- package/dist/shared/network/metadata.renderer.js +0 -1
- package/dist/shared/observability/debug-meta.sanitizer.d.ts +0 -1
- package/dist/shared/observability/debug-meta.sanitizer.js +0 -1
- package/dist/shared/observability/log.d.ts +0 -1
- package/dist/shared/observability/log.js +0 -1
- package/dist/shared/observability/performance.d.ts +0 -1
- package/dist/shared/observability/performance.js +0 -1
- package/dist/shared/observability/protocol.logger.d.ts +0 -1
- package/dist/shared/observability/protocol.logger.js +0 -1
- package/dist/shared/observability/request-context.d.ts +0 -1
- package/dist/shared/observability/request-context.js +0 -1
- package/dist/shared/observability/trace.d.ts +0 -1
- package/dist/shared/observability/trace.js +0 -1
- package/dist/shared/schemas/chat-context.schema.d.ts +0 -1
- package/dist/shared/schemas/chat-context.schema.js +0 -1
- package/dist/shared/schemas/discovery-question.schema.d.ts +17 -18
- package/dist/shared/schemas/discovery-question.schema.js +0 -1
- package/dist/shared/schemas/identity.schema.d.ts +0 -1
- package/dist/shared/schemas/identity.schema.js +0 -1
- package/dist/shared/schemas/mcp-auth.schema.d.ts +0 -1
- package/dist/shared/schemas/mcp-auth.schema.js +0 -1
- package/dist/shared/schemas/negotiation-digest.schema.d.ts +5 -6
- package/dist/shared/schemas/negotiation-digest.schema.js +0 -1
- package/dist/shared/schemas/negotiation-state.schema.d.ts +4 -5
- package/dist/shared/schemas/negotiation-state.schema.js +0 -1
- package/dist/shared/schemas/network-assignment.schema.d.ts +0 -1
- package/dist/shared/schemas/network-assignment.schema.js +0 -1
- package/dist/shared/schemas/pending-question.schema.d.ts +0 -1
- package/dist/shared/schemas/pending-question.schema.js +0 -1
- package/dist/shared/schemas/question.schema.d.ts +3 -1505
- package/dist/shared/schemas/question.schema.js +3 -410
- package/dist/shared/ui/lucide.icon-catalog.d.ts +0 -1
- package/dist/shared/ui/lucide.icon-catalog.js +0 -1
- package/dist/shared/utils/social-label.d.ts +0 -1
- package/dist/shared/utils/social-label.js +0 -1
- package/dist/shared/utils/telegram-handle.d.ts +0 -1
- package/dist/shared/utils/telegram-handle.js +0 -1
- package/dist/signals/application/index.d.ts +19 -0
- package/dist/signals/application/index.js +22 -0
- package/dist/signals/application/intent.clarifier.d.ts +51 -0
- package/dist/signals/application/intent.clarifier.js +201 -0
- package/dist/signals/application/intent.graph.d.ts +552 -0
- package/dist/signals/application/intent.graph.js +938 -0
- package/dist/signals/application/intent.indexer.d.ts +82 -0
- package/dist/signals/application/intent.indexer.js +170 -0
- package/dist/signals/application/intent.inferrer.d.ts +94 -0
- package/dist/signals/application/intent.inferrer.js +233 -0
- package/dist/signals/application/intent.reconciler.d.ts +105 -0
- package/dist/signals/application/intent.reconciler.js +186 -0
- package/dist/signals/application/intent.tools.d.ts +24 -0
- package/dist/signals/application/intent.tools.js +789 -0
- package/dist/signals/application/intent.verifier.d.ts +115 -0
- package/dist/signals/application/intent.verifier.js +262 -0
- package/dist/signals/domain/index.d.ts +9 -0
- package/dist/signals/domain/index.js +11 -0
- package/dist/signals/domain/intent.state.d.ts +230 -0
- package/dist/signals/domain/intent.state.js +190 -0
- package/dist/signals/domain/signal.specificity.d.ts +2 -0
- package/dist/signals/domain/signal.specificity.js +2 -0
- package/dist/signals/index.d.ts +13 -0
- package/dist/signals/index.js +13 -0
- package/dist/signals/ports/index.d.ts +15 -0
- package/dist/signals/ports/index.js +13 -0
- package/dist/signals/public/index.d.ts +15 -0
- package/dist/signals/public/index.js +16 -0
- package/package.json +14 -3
- package/dist/agent/agent.tools.d.ts.map +0 -1
- package/dist/agent/agent.tools.js.map +0 -1
- package/dist/agent/tests/fakes.d.ts +0 -25
- package/dist/agent/tests/fakes.d.ts.map +0 -1
- package/dist/agent/tests/fakes.js +0 -178
- package/dist/agent/tests/fakes.js.map +0 -1
- package/dist/chat/chat-streaming.types.d.ts.map +0 -1
- package/dist/chat/chat-streaming.types.js.map +0 -1
- package/dist/chat/chat.agent.d.ts.map +0 -1
- package/dist/chat/chat.agent.js.map +0 -1
- package/dist/chat/chat.graph.d.ts.map +0 -1
- package/dist/chat/chat.graph.js.map +0 -1
- package/dist/chat/chat.interrupt.classifier.d.ts.map +0 -1
- package/dist/chat/chat.interrupt.classifier.js.map +0 -1
- package/dist/chat/chat.persona.d.ts.map +0 -1
- package/dist/chat/chat.persona.js.map +0 -1
- package/dist/chat/chat.prompt.d.ts.map +0 -1
- package/dist/chat/chat.prompt.js.map +0 -1
- package/dist/chat/chat.prompt.modules.d.ts.map +0 -1
- package/dist/chat/chat.prompt.modules.js.map +0 -1
- package/dist/chat/chat.question-dedup.d.ts.map +0 -1
- package/dist/chat/chat.question-dedup.js.map +0 -1
- package/dist/chat/chat.state.d.ts.map +0 -1
- package/dist/chat/chat.state.js.map +0 -1
- package/dist/chat/chat.streamer.d.ts.map +0 -1
- package/dist/chat/chat.streamer.js.map +0 -1
- package/dist/chat/chat.suggester.d.ts.map +0 -1
- package/dist/chat/chat.suggester.js.map +0 -1
- package/dist/chat/chat.summarizer.d.ts.map +0 -1
- package/dist/chat/chat.summarizer.js.map +0 -1
- package/dist/chat/chat.title.generator.d.ts.map +0 -1
- package/dist/chat/chat.title.generator.js.map +0 -1
- package/dist/chat/chat.tools.d.ts.map +0 -1
- package/dist/chat/chat.tools.js.map +0 -1
- package/dist/chat/chat.utils.d.ts.map +0 -1
- package/dist/chat/chat.utils.js.map +0 -1
- package/dist/chat/negotiator.persona.d.ts.map +0 -1
- package/dist/chat/negotiator.persona.js.map +0 -1
- package/dist/chat/negotiator.prompt.d.ts.map +0 -1
- package/dist/chat/negotiator.prompt.js.map +0 -1
- package/dist/chat/negotiator.tools.d.ts.map +0 -1
- package/dist/chat/negotiator.tools.js.map +0 -1
- package/dist/chat/onboarding.persona.d.ts.map +0 -1
- package/dist/chat/onboarding.persona.js.map +0 -1
- package/dist/chat/onboarding.prompt.d.ts.map +0 -1
- package/dist/chat/onboarding.prompt.js.map +0 -1
- package/dist/chat/reporter.action.tools.d.ts.map +0 -1
- package/dist/chat/reporter.action.tools.js.map +0 -1
- package/dist/chat/reporter.persona.d.ts.map +0 -1
- package/dist/chat/reporter.persona.js.map +0 -1
- package/dist/chat/reporter.prompt.d.ts.map +0 -1
- package/dist/chat/reporter.prompt.js.map +0 -1
- package/dist/chat/signal.persona.d.ts.map +0 -1
- package/dist/chat/signal.persona.js.map +0 -1
- package/dist/chat/signal.prompt.d.ts.map +0 -1
- package/dist/chat/signal.prompt.js.map +0 -1
- package/dist/chat/tests/chat.graph.mocks.d.ts +0 -98
- package/dist/chat/tests/chat.graph.mocks.d.ts.map +0 -1
- package/dist/chat/tests/chat.graph.mocks.js +0 -225
- package/dist/chat/tests/chat.graph.mocks.js.map +0 -1
- package/dist/contact/contact.inviter.d.ts.map +0 -1
- package/dist/contact/contact.inviter.js.map +0 -1
- package/dist/contact/contact.tools.d.ts.map +0 -1
- package/dist/contact/contact.tools.js.map +0 -1
- package/dist/context/context.generator.d.ts.map +0 -1
- package/dist/context/context.generator.js.map +0 -1
- package/dist/enrichment/enrichment.enricher.d.ts.map +0 -1
- package/dist/enrichment/enrichment.enricher.js.map +0 -1
- package/dist/enrichment/enrichment.generator.d.ts.map +0 -1
- package/dist/enrichment/enrichment.generator.js.map +0 -1
- package/dist/enrichment/enrichment.graph.d.ts.map +0 -1
- package/dist/enrichment/enrichment.graph.js.map +0 -1
- package/dist/enrichment/enrichment.state.d.ts.map +0 -1
- package/dist/enrichment/enrichment.state.js.map +0 -1
- package/dist/enrichment/enrichment.tools.d.ts.map +0 -1
- package/dist/enrichment/enrichment.tools.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/integration/integration.tools.d.ts.map +0 -1
- package/dist/integration/integration.tools.js.map +0 -1
- package/dist/intent/intent.clarifier.d.ts.map +0 -1
- package/dist/intent/intent.clarifier.js.map +0 -1
- package/dist/intent/intent.graph.d.ts.map +0 -1
- package/dist/intent/intent.graph.js.map +0 -1
- package/dist/intent/intent.indexer.d.ts.map +0 -1
- package/dist/intent/intent.indexer.js.map +0 -1
- package/dist/intent/intent.inferrer.d.ts.map +0 -1
- package/dist/intent/intent.inferrer.js.map +0 -1
- package/dist/intent/intent.reconciler.d.ts.map +0 -1
- package/dist/intent/intent.reconciler.js.map +0 -1
- package/dist/intent/intent.specificity.d.ts.map +0 -1
- package/dist/intent/intent.specificity.js.map +0 -1
- package/dist/intent/intent.state.d.ts.map +0 -1
- package/dist/intent/intent.state.js.map +0 -1
- package/dist/intent/intent.tools.d.ts.map +0 -1
- package/dist/intent/intent.tools.js.map +0 -1
- package/dist/intent/intent.verifier.d.ts.map +0 -1
- package/dist/intent/intent.verifier.js.map +0 -1
- package/dist/maintenance/maintenance.graph.d.ts.map +0 -1
- package/dist/maintenance/maintenance.graph.js.map +0 -1
- package/dist/maintenance/maintenance.state.d.ts.map +0 -1
- package/dist/maintenance/maintenance.state.js.map +0 -1
- package/dist/mcp/elicitation.builder.d.ts.map +0 -1
- package/dist/mcp/elicitation.builder.js.map +0 -1
- package/dist/mcp/elicitation.dispatcher.d.ts.map +0 -1
- package/dist/mcp/elicitation.dispatcher.js.map +0 -1
- package/dist/mcp/mcp.server.d.ts.map +0 -1
- package/dist/mcp/mcp.server.js.map +0 -1
- package/dist/negotiation/insight.generator.d.ts.map +0 -1
- package/dist/negotiation/insight.generator.js.map +0 -1
- package/dist/negotiation/negotiation.agent.d.ts.map +0 -1
- package/dist/negotiation/negotiation.agent.js.map +0 -1
- package/dist/negotiation/negotiation.attribution.d.ts.map +0 -1
- package/dist/negotiation/negotiation.attribution.js.map +0 -1
- package/dist/negotiation/negotiation.consultation-policy.d.ts.map +0 -1
- package/dist/negotiation/negotiation.consultation-policy.js.map +0 -1
- package/dist/negotiation/negotiation.deadlock.d.ts.map +0 -1
- package/dist/negotiation/negotiation.deadlock.js.map +0 -1
- package/dist/negotiation/negotiation.graph.d.ts.map +0 -1
- package/dist/negotiation/negotiation.graph.js.map +0 -1
- package/dist/negotiation/negotiation.memory.d.ts.map +0 -1
- package/dist/negotiation/negotiation.memory.js.map +0 -1
- package/dist/negotiation/negotiation.protocol.d.ts.map +0 -1
- package/dist/negotiation/negotiation.protocol.js.map +0 -1
- package/dist/negotiation/negotiation.question-safety.d.ts.map +0 -1
- package/dist/negotiation/negotiation.question-safety.js.map +0 -1
- package/dist/negotiation/negotiation.reflect.d.ts.map +0 -1
- package/dist/negotiation/negotiation.reflect.js.map +0 -1
- package/dist/negotiation/negotiation.screen.d.ts.map +0 -1
- package/dist/negotiation/negotiation.screen.js.map +0 -1
- package/dist/negotiation/negotiation.state.d.ts.map +0 -1
- package/dist/negotiation/negotiation.state.js.map +0 -1
- package/dist/negotiation/negotiation.summarizer.d.ts.map +0 -1
- package/dist/negotiation/negotiation.summarizer.js.map +0 -1
- package/dist/negotiation/negotiation.tools.d.ts.map +0 -1
- package/dist/negotiation/negotiation.tools.js.map +0 -1
- package/dist/network/indexer/indexer.graph.d.ts.map +0 -1
- package/dist/network/indexer/indexer.graph.js.map +0 -1
- package/dist/network/indexer/indexer.state.d.ts.map +0 -1
- package/dist/network/indexer/indexer.state.js.map +0 -1
- package/dist/network/membership/membership.graph.d.ts.map +0 -1
- package/dist/network/membership/membership.graph.js.map +0 -1
- package/dist/network/membership/membership.state.d.ts.map +0 -1
- package/dist/network/membership/membership.state.js.map +0 -1
- package/dist/network/network.graph.d.ts.map +0 -1
- package/dist/network/network.graph.js.map +0 -1
- package/dist/network/network.recommender.d.ts.map +0 -1
- package/dist/network/network.recommender.js.map +0 -1
- package/dist/network/network.state.d.ts.map +0 -1
- package/dist/network/network.state.js.map +0 -1
- package/dist/network/network.tools.d.ts.map +0 -1
- package/dist/network/network.tools.js.map +0 -1
- package/dist/opportunity/delivery-card.cache.d.ts.map +0 -1
- package/dist/opportunity/delivery-card.cache.js.map +0 -1
- package/dist/opportunity/discovery-question.helper.d.ts.map +0 -1
- package/dist/opportunity/discovery-question.helper.js.map +0 -1
- package/dist/opportunity/discriminator/discriminator.adjustments.d.ts.map +0 -1
- package/dist/opportunity/discriminator/discriminator.adjustments.js.map +0 -1
- package/dist/opportunity/discriminator/discriminator.assigner.d.ts.map +0 -1
- package/dist/opportunity/discriminator/discriminator.assigner.js.map +0 -1
- package/dist/opportunity/discriminator/discriminator.env.d.ts.map +0 -1
- package/dist/opportunity/discriminator/discriminator.env.js.map +0 -1
- package/dist/opportunity/discriminator/discriminator.miner.d.ts.map +0 -1
- package/dist/opportunity/discriminator/discriminator.miner.js.map +0 -1
- package/dist/opportunity/discriminator/discriminator.push.d.ts.map +0 -1
- package/dist/opportunity/discriminator/discriminator.push.js.map +0 -1
- package/dist/opportunity/discriminator/discriminator.question.d.ts.map +0 -1
- package/dist/opportunity/discriminator/discriminator.question.js.map +0 -1
- package/dist/opportunity/discriminator/discriminator.scorer.d.ts.map +0 -1
- package/dist/opportunity/discriminator/discriminator.scorer.js.map +0 -1
- package/dist/opportunity/discriminator/discriminator.shadow.d.ts.map +0 -1
- package/dist/opportunity/discriminator/discriminator.shadow.js.map +0 -1
- package/dist/opportunity/discriminator/discriminator.types.d.ts.map +0 -1
- package/dist/opportunity/discriminator/discriminator.types.js.map +0 -1
- package/dist/opportunity/feed/feed.categorizer.d.ts.map +0 -1
- package/dist/opportunity/feed/feed.categorizer.js.map +0 -1
- package/dist/opportunity/feed/feed.graph.d.ts.map +0 -1
- package/dist/opportunity/feed/feed.graph.js.map +0 -1
- package/dist/opportunity/feed/feed.health.d.ts.map +0 -1
- package/dist/opportunity/feed/feed.health.js.map +0 -1
- package/dist/opportunity/feed/feed.state.d.ts.map +0 -1
- package/dist/opportunity/feed/feed.state.js.map +0 -1
- package/dist/opportunity/negotiation-context.loader.d.ts.map +0 -1
- package/dist/opportunity/negotiation-context.loader.js.map +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.env.d.ts.map +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.env.js.map +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.extractor.d.ts.map +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.extractor.js.map +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.miner.d.ts.map +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.miner.js.map +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.shadow.d.ts.map +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.shadow.js.map +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.types.d.ts.map +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.types.js.map +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.verifier.d.ts.map +0 -1
- package/dist/opportunity/negotiation-evidence/negotiation-evidence.verifier.js.map +0 -1
- package/dist/opportunity/negotiation-summary.builder.d.ts.map +0 -1
- package/dist/opportunity/negotiation-summary.builder.js.map +0 -1
- package/dist/opportunity/opportunity.actor.d.ts.map +0 -1
- package/dist/opportunity/opportunity.actor.js.map +0 -1
- package/dist/opportunity/opportunity.claim-safety.d.ts.map +0 -1
- package/dist/opportunity/opportunity.claim-safety.js.map +0 -1
- package/dist/opportunity/opportunity.discover.d.ts.map +0 -1
- package/dist/opportunity/opportunity.discover.js.map +0 -1
- package/dist/opportunity/opportunity.enricher.d.ts.map +0 -1
- package/dist/opportunity/opportunity.enricher.js.map +0 -1
- package/dist/opportunity/opportunity.evaluator.d.ts.map +0 -1
- package/dist/opportunity/opportunity.evaluator.js.map +0 -1
- package/dist/opportunity/opportunity.evidence.d.ts.map +0 -1
- package/dist/opportunity/opportunity.evidence.js.map +0 -1
- package/dist/opportunity/opportunity.graph.d.ts.map +0 -1
- package/dist/opportunity/opportunity.graph.js.map +0 -1
- package/dist/opportunity/opportunity.introducer.d.ts.map +0 -1
- package/dist/opportunity/opportunity.introducer.js.map +0 -1
- package/dist/opportunity/opportunity.labels.d.ts.map +0 -1
- package/dist/opportunity/opportunity.labels.js.map +0 -1
- package/dist/opportunity/opportunity.pending-questions.d.ts.map +0 -1
- package/dist/opportunity/opportunity.pending-questions.js.map +0 -1
- package/dist/opportunity/opportunity.persist.d.ts.map +0 -1
- package/dist/opportunity/opportunity.persist.js.map +0 -1
- package/dist/opportunity/opportunity.presentation-cache.d.ts.map +0 -1
- package/dist/opportunity/opportunity.presentation-cache.js.map +0 -1
- package/dist/opportunity/opportunity.presentation.d.ts.map +0 -1
- package/dist/opportunity/opportunity.presentation.js.map +0 -1
- package/dist/opportunity/opportunity.presenter.d.ts.map +0 -1
- package/dist/opportunity/opportunity.presenter.js.map +0 -1
- package/dist/opportunity/opportunity.safe-presentation.d.ts.map +0 -1
- package/dist/opportunity/opportunity.safe-presentation.js.map +0 -1
- package/dist/opportunity/opportunity.state.d.ts.map +0 -1
- package/dist/opportunity/opportunity.state.js.map +0 -1
- package/dist/opportunity/opportunity.tools.d.ts.map +0 -1
- package/dist/opportunity/opportunity.tools.js.map +0 -1
- package/dist/opportunity/opportunity.utils.d.ts.map +0 -1
- package/dist/opportunity/opportunity.utils.js.map +0 -1
- package/dist/opportunity/outcome/outcome.env.d.ts.map +0 -1
- package/dist/opportunity/outcome/outcome.env.js.map +0 -1
- package/dist/opportunity/outcome/outcome.hypotheses.d.ts.map +0 -1
- package/dist/opportunity/outcome/outcome.hypotheses.js.map +0 -1
- package/dist/opportunity/outcome/outcome.shadow.d.ts.map +0 -1
- package/dist/opportunity/outcome/outcome.shadow.js.map +0 -1
- package/dist/opportunity/outcome/outcome.types.d.ts.map +0 -1
- package/dist/opportunity/outcome/outcome.types.js.map +0 -1
- package/dist/premise/premise.analyzer.d.ts.map +0 -1
- package/dist/premise/premise.analyzer.js.map +0 -1
- package/dist/premise/premise.decomposer.d.ts.map +0 -1
- package/dist/premise/premise.decomposer.js.map +0 -1
- package/dist/premise/premise.graph.d.ts.map +0 -1
- package/dist/premise/premise.graph.js.map +0 -1
- package/dist/premise/premise.indexer.d.ts.map +0 -1
- package/dist/premise/premise.indexer.js.map +0 -1
- package/dist/premise/premise.state.d.ts.map +0 -1
- package/dist/premise/premise.state.js.map +0 -1
- package/dist/premise/premise.tools.d.ts.map +0 -1
- package/dist/premise/premise.tools.js.map +0 -1
- package/dist/questioner/questioner.agent.d.ts.map +0 -1
- package/dist/questioner/questioner.agent.js.map +0 -1
- package/dist/questioner/questioner.ask.tool.d.ts.map +0 -1
- package/dist/questioner/questioner.ask.tool.js.map +0 -1
- package/dist/questioner/questioner.discovery.prompt.d.ts.map +0 -1
- package/dist/questioner/questioner.discovery.prompt.js.map +0 -1
- package/dist/questioner/questioner.env.d.ts.map +0 -1
- package/dist/questioner/questioner.env.js.map +0 -1
- package/dist/questioner/questioner.presets.d.ts.map +0 -1
- package/dist/questioner/questioner.presets.js.map +0 -1
- package/dist/questioner/questioner.qud.d.ts.map +0 -1
- package/dist/questioner/questioner.qud.js.map +0 -1
- package/dist/questioner/questioner.tools.d.ts.map +0 -1
- package/dist/questioner/questioner.tools.js.map +0 -1
- package/dist/questioner/questioner.types.d.ts.map +0 -1
- package/dist/questioner/questioner.types.js.map +0 -1
- package/dist/shared/agent/model-signal.d.ts.map +0 -1
- package/dist/shared/agent/model-signal.js.map +0 -1
- package/dist/shared/agent/model.config.d.ts.map +0 -1
- package/dist/shared/agent/model.config.js.map +0 -1
- package/dist/shared/agent/tests/llm-assert.d.ts +0 -11
- package/dist/shared/agent/tests/llm-assert.d.ts.map +0 -1
- package/dist/shared/agent/tests/llm-assert.js +0 -43
- package/dist/shared/agent/tests/llm-assert.js.map +0 -1
- package/dist/shared/agent/tool.factory.d.ts.map +0 -1
- package/dist/shared/agent/tool.factory.js.map +0 -1
- package/dist/shared/agent/tool.helpers.d.ts.map +0 -1
- package/dist/shared/agent/tool.helpers.js.map +0 -1
- package/dist/shared/agent/tool.registry.d.ts.map +0 -1
- package/dist/shared/agent/tool.registry.js.map +0 -1
- package/dist/shared/agent/tool.runtime.d.ts.map +0 -1
- package/dist/shared/agent/tool.runtime.js.map +0 -1
- package/dist/shared/agent/tool.scope.d.ts.map +0 -1
- package/dist/shared/agent/tool.scope.js.map +0 -1
- package/dist/shared/agent/utility.tools.d.ts.map +0 -1
- package/dist/shared/agent/utility.tools.js.map +0 -1
- package/dist/shared/assignment/network-assignment.policy.d.ts.map +0 -1
- package/dist/shared/assignment/network-assignment.policy.js.map +0 -1
- package/dist/shared/hyde/hyde.documents.d.ts.map +0 -1
- package/dist/shared/hyde/hyde.documents.js.map +0 -1
- package/dist/shared/hyde/hyde.env.d.ts.map +0 -1
- package/dist/shared/hyde/hyde.env.js.map +0 -1
- package/dist/shared/hyde/hyde.frame.d.ts.map +0 -1
- package/dist/shared/hyde/hyde.frame.js.map +0 -1
- package/dist/shared/hyde/hyde.generator.d.ts.map +0 -1
- package/dist/shared/hyde/hyde.generator.js.map +0 -1
- package/dist/shared/hyde/hyde.graph.d.ts.map +0 -1
- package/dist/shared/hyde/hyde.graph.js.map +0 -1
- package/dist/shared/hyde/hyde.state.d.ts.map +0 -1
- package/dist/shared/hyde/hyde.state.js.map +0 -1
- package/dist/shared/hyde/hyde.strategies.d.ts.map +0 -1
- package/dist/shared/hyde/hyde.strategies.js.map +0 -1
- package/dist/shared/hyde/hyde.validator.d.ts.map +0 -1
- package/dist/shared/hyde/hyde.validator.js.map +0 -1
- package/dist/shared/hyde/lens.inferrer.d.ts.map +0 -1
- package/dist/shared/hyde/lens.inferrer.js.map +0 -1
- package/dist/shared/interfaces/agent-dispatcher.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/agent-dispatcher.interface.js.map +0 -1
- package/dist/shared/interfaces/agent.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/agent.interface.js.map +0 -1
- package/dist/shared/interfaces/auth.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/auth.interface.js.map +0 -1
- package/dist/shared/interfaces/cache.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/cache.interface.js.map +0 -1
- package/dist/shared/interfaces/chat-message-writer.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/chat-message-writer.interface.js.map +0 -1
- package/dist/shared/interfaces/chat-session.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/chat-session.interface.js.map +0 -1
- package/dist/shared/interfaces/chat-summary.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/chat-summary.interface.js.map +0 -1
- package/dist/shared/interfaces/connect-link.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/connect-link.interface.js.map +0 -1
- package/dist/shared/interfaces/contact.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/contact.interface.js.map +0 -1
- package/dist/shared/interfaces/database.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/database.interface.js.map +0 -1
- package/dist/shared/interfaces/delivery-ledger.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/delivery-ledger.interface.js.map +0 -1
- package/dist/shared/interfaces/discovery-run.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/discovery-run.interface.js.map +0 -1
- package/dist/shared/interfaces/embedder.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/embedder.interface.js.map +0 -1
- package/dist/shared/interfaces/enrichment-run.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/enrichment-run.interface.js.map +0 -1
- package/dist/shared/interfaces/enrichment.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/enrichment.interface.js.map +0 -1
- package/dist/shared/interfaces/integration.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/integration.interface.js.map +0 -1
- package/dist/shared/interfaces/negotiation-events.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/negotiation-events.interface.js.map +0 -1
- package/dist/shared/interfaces/negotiation-summary.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/negotiation-summary.interface.js.map +0 -1
- package/dist/shared/interfaces/negotiator-memory.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/negotiator-memory.interface.js.map +0 -1
- package/dist/shared/interfaces/question-generator.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/question-generator.interface.js.map +0 -1
- package/dist/shared/interfaces/questioner.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/questioner.interface.js.map +0 -1
- package/dist/shared/interfaces/queue.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/queue.interface.js.map +0 -1
- package/dist/shared/interfaces/scraper.interface.d.ts.map +0 -1
- package/dist/shared/interfaces/scraper.interface.js.map +0 -1
- package/dist/shared/network/metadata.renderer.d.ts.map +0 -1
- package/dist/shared/network/metadata.renderer.js.map +0 -1
- package/dist/shared/observability/debug-meta.sanitizer.d.ts.map +0 -1
- package/dist/shared/observability/debug-meta.sanitizer.js.map +0 -1
- package/dist/shared/observability/log.d.ts.map +0 -1
- package/dist/shared/observability/log.js.map +0 -1
- package/dist/shared/observability/performance.d.ts.map +0 -1
- package/dist/shared/observability/performance.js.map +0 -1
- package/dist/shared/observability/protocol.logger.d.ts.map +0 -1
- package/dist/shared/observability/protocol.logger.js.map +0 -1
- package/dist/shared/observability/request-context.d.ts.map +0 -1
- package/dist/shared/observability/request-context.js.map +0 -1
- package/dist/shared/observability/trace.d.ts.map +0 -1
- package/dist/shared/observability/trace.js.map +0 -1
- package/dist/shared/schemas/chat-context.schema.d.ts.map +0 -1
- package/dist/shared/schemas/chat-context.schema.js.map +0 -1
- package/dist/shared/schemas/discovery-question.schema.d.ts.map +0 -1
- package/dist/shared/schemas/discovery-question.schema.js.map +0 -1
- package/dist/shared/schemas/identity.schema.d.ts.map +0 -1
- package/dist/shared/schemas/identity.schema.js.map +0 -1
- package/dist/shared/schemas/mcp-auth.schema.d.ts.map +0 -1
- package/dist/shared/schemas/mcp-auth.schema.js.map +0 -1
- package/dist/shared/schemas/negotiation-digest.schema.d.ts.map +0 -1
- package/dist/shared/schemas/negotiation-digest.schema.js.map +0 -1
- package/dist/shared/schemas/negotiation-state.schema.d.ts.map +0 -1
- package/dist/shared/schemas/negotiation-state.schema.js.map +0 -1
- package/dist/shared/schemas/network-assignment.schema.d.ts.map +0 -1
- package/dist/shared/schemas/network-assignment.schema.js.map +0 -1
- package/dist/shared/schemas/pending-question.schema.d.ts.map +0 -1
- package/dist/shared/schemas/pending-question.schema.js.map +0 -1
- package/dist/shared/schemas/question.schema.d.ts.map +0 -1
- package/dist/shared/schemas/question.schema.js.map +0 -1
- package/dist/shared/ui/lucide.icon-catalog.d.ts.map +0 -1
- package/dist/shared/ui/lucide.icon-catalog.js.map +0 -1
- package/dist/shared/utils/social-label.d.ts.map +0 -1
- package/dist/shared/utils/social-label.js.map +0 -1
- package/dist/shared/utils/telegram-handle.d.ts.map +0 -1
- package/dist/shared/utils/telegram-handle.js.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool.registry.js","sourceRoot":"/","sources":["shared/agent/tool.registry.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,wCAAwC,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,qBAAqB,EAAE,MAAM,sCAAsC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAErE,MAAM,MAAM,GAAG,cAAc,CAAC,cAAc,CAAC,CAAC;AAE9C;;;;;;;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B,EAAE,qBAAqB,CAAC;QAC9C,CAAC,qBAAqB,EAAE,qBAAqB,CAAC;QAC9C,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;QAChD,CAAC,sBAAsB,EAAE,sBAAsB,CAAC;QAChD,CAAC,iBAAiB,EAAE,oBAAoB,CAAC;QACzC,CAAC,oBAAoB,EAAE,uBAAuB,CAAC;KAChD,CAAC;IACF,KAAK,MAAM,CAAC,OAAO,EAAE,aAAa,CAAC,IAAI,uBAAuB,EAAE,CAAC;QAC/D,MAAM,SAAS,GAAG,QAAQ,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;QAC9C,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,4DAA4D,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC,CAAC;YAC7G,SAAS;QACX,CAAC;QACD,QAAQ,CAAC,GAAG,CAAC,OAAO,EAAE;YACpB,GAAG,SAAS;YACZ,IAAI,EAAE,OAAO;YACb,WAAW,EAAE,uBAAuB,aAAa,uFAAuF,SAAS,CAAC,WAAW,EAAE;SAChK,CAAC,CAAC;IACL,CAAC;IAED,MAAM,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,SAAS,EAAE,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAC;IACtE,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { z } from 'zod';\n\nimport type { DefineTool, ResolvedToolContext, ToolDeps, RawToolDefinition, ToolRegistry } from './tool.helpers.js';\nimport { error, redactSensitiveFields } from './tool.helpers.js';\nimport { createEnrichmentTools } from '../../enrichment/enrichment.tools.js';\nimport { createIntentTools } from '../../intent/intent.tools.js';\nimport { createNetworkTools } from '../../network/network.tools.js';\nimport { createOpportunityTools } from '../../opportunity/opportunity.tools.js';\nimport { createUtilityTools } from './utility.tools.js';\nimport { createIntegrationTools } from '../../integration/integration.tools.js';\nimport { createContactTools } from '../../contact/contact.tools.js';\nimport { createAgentTools } from '../../agent/agent.tools.js';\nimport { createNegotiationTools } from '../../negotiation/negotiation.tools.js';\nimport { createChatTools } from '../../chat/chat.tools.js';\nimport { createPremiseTools } from '../../premise/premise.tools.js';\nimport { createQuestionerTools } from '../../questioner/questioner.tools.js';\nimport { protocolLogger } from '../observability/protocol.logger.js';\nimport { requestContext } from '../observability/request-context.js';\n\nconst logger = protocolLogger('ToolRegistry');\n\n/**\n * Creates a tool registry containing all tool handlers indexed by name.\n * Handlers are raw async functions (not LangChain tool() wrappers) that\n * accept { context, query } and return a JSON string.\n *\n * @param deps - Shared tool dependencies (graphs, database, embedder, etc.)\n * @param context - Resolved user context for this request.\n * @returns Map of tool name to raw tool definition.\n */\nexport function createToolRegistry(deps: ToolDeps): ToolRegistry {\n const registry: ToolRegistry = new Map();\n\n // defineTool that captures raw handlers into the registry\n function defineTool<T extends z.ZodType>(opts: {\n name: string;\n description: string;\n querySchema: T;\n handler: (input: { context: ResolvedToolContext; query: z.infer<T> }) => Promise<string>;\n }) {\n const entry: RawToolDefinition = {\n name: opts.name,\n description: opts.description,\n schema: opts.querySchema,\n handler: async (input: { context: ResolvedToolContext; query: unknown }) => {\n logger.verbose('Tool invoked', {\n toolName: opts.name,\n context: { userId: input.context.userId, scopeType: input.context.scopeType, scopeId: input.context.scopeId },\n query: redactSensitiveFields(input.query),\n });\n try {\n return await opts.handler({ context: input.context, query: input.query as z.infer<T> });\n } catch (err) {\n const abortSignal = requestContext.getStore()?.abortSignal;\n if (abortSignal?.aborted) {\n throw err;\n }\n logger.error('Tool failed', {\n toolName: opts.name,\n error: err instanceof Error ? err.message : String(err),\n });\n return error(`Failed to execute ${opts.name}: ${err instanceof Error ? err.message : String(err)}`);\n }\n },\n };\n\n registry.set(opts.name, entry);\n\n // Return a dummy — create*Tools functions collect return values into arrays,\n // but for the registry path we only need the side-effect on the Map.\n return null as unknown;\n }\n\n // Create all tool domains -- each one calls defineTool() which populates the registry.\n // The local defineTool is compatible with DefineTool (which returns any).\n const dt = defineTool as DefineTool;\n createEnrichmentTools(dt, deps);\n createIntentTools(dt, deps);\n createNetworkTools(dt, deps);\n createOpportunityTools(dt, deps);\n createUtilityTools(dt, deps);\n createIntegrationTools(dt, deps);\n createContactTools(dt, deps);\n createAgentTools(dt, deps);\n createNegotiationTools(dt, deps);\n createPremiseTools(dt, deps);\n createQuestionerTools(dt, deps);\n if (deps.chatSession) {\n createChatTools(dt, deps);\n }\n\n // Deprecated tool-name aliases (IND-371). The canonical implementations are now\n // registered under their *_user_context / *_enrichment_run names; we expose the\n // legacy *_user_profile / *_profile_run names as thin aliases that delegate to the\n // exact same handler + schema, so existing MCP clients keep working while they\n // migrate. The old names are removed in IND-373.\n const DEPRECATED_TOOL_ALIASES: ReadonlyArray<readonly [oldName: string, canonicalName: string]> = [\n [\"read_user_profiles\", \"read_user_contexts\"],\n [\"create_user_profile\", \"create_user_context\"],\n [\"update_user_profile\", \"update_user_context\"],\n [\"confirm_user_profile\", \"confirm_user_context\"],\n [\"preview_user_profile\", \"preview_user_context\"],\n [\"get_profile_run\", \"get_enrichment_run\"],\n [\"cancel_profile_run\", \"cancel_enrichment_run\"],\n ];\n for (const [oldName, canonicalName] of DEPRECATED_TOOL_ALIASES) {\n const canonical = registry.get(canonicalName);\n if (!canonical) {\n logger.warn('Cannot register deprecated alias: canonical tool not found', { alias: oldName, canonicalName });\n continue;\n }\n registry.set(oldName, {\n ...canonical,\n name: oldName,\n description: `[DEPRECATED — use \\`${canonicalName}\\` instead; this alias is retained for backward compatibility and will be removed.] ${canonical.description}`,\n });\n }\n\n logger.verbose('Tool registry created', { toolCount: registry.size });\n return registry;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool.runtime.d.ts","sourceRoot":"/","sources":["shared/agent/tool.runtime.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AAGxE,OAAO,KAAK,EAAE,iBAAiB,EAAE,mBAAmB,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AAQ,CAAC,OAAO,EAAE,CAAC;IACrB,CAAC;AACH,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,GAAY;IACnD,IAAI,CAAC,CAAC,GAAG,YAAY,gBAAgB,CAAC;QAAE,OAAO,IAAI,CAAC;IACpD,OAAO,IAAI,CAAC,SAAS,CAAC;QACpB,OAAO,EAAE,KAAK;QACd,IAAI,EAAE,GAAG,CAAC,IAAI;QACd,KAAK,EAAE,GAAG,CAAC,OAAO;QAClB,IAAI,EAAE;YACJ,IAAI,EAAE,GAAG,CAAC,QAAQ;YAClB,YAAY,EAAE,GAAG,CAAC,MAAM,CAAC,KAAK;YAC9B,SAAS,EAAE,GAAG,CAAC,MAAM,CAAC,SAAS;YAC/B,cAAc,EAAE,GAAG,CAAC,MAAM,CAAC,cAAc;SAC1C;KACF,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { timed } from \"../observability/performance.js\";\nimport type { TraceEmitter } from \"../observability/request-context.js\";\nimport { requestContext } from \"../observability/request-context.js\";\n\nimport type { RawToolDefinition, ResolvedToolContext } from \"./tool.helpers.js\";\n\nexport type ToolTimeoutClass = \"fast\" | \"bounded_slow\" | \"async_candidate\" | \"interactive\";\nexport type ToolRuntimeErrorCode = \"TOOL_TIMEOUT\" | \"TOOL_CANCELLED\" | \"TOOL_OUTPUT_TOO_LARGE\";\n\nexport interface ToolTimeoutPolicy {\n class: ToolTimeoutClass;\n timeoutMs: number;\n maxOutputBytes: number;\n}\n\nexport interface ToolInvocationRuntimeInput {\n toolName: string;\n tool: Pick<RawToolDefinition, \"handler\">;\n context: ResolvedToolContext;\n query: unknown;\n signal?: AbortSignal;\n traceEmitter?: TraceEmitter;\n timeoutMs?: number;\n maxOutputBytes?: number;\n}\n\nconst FAST_TIMEOUT_MS = 10_000;\nconst BOUNDED_SLOW_TIMEOUT_MS = 45_000;\nconst ASYNC_CANDIDATE_TIMEOUT_MS = 50_000;\n// Interactive tools deliberately block on human input (ask_user_question).\n// Must exceed the tool's own internal wait budget (QUESTIONER_CHAT_WAIT_TIMEOUT_MS,\n// default 4 min) so the tool returns a graceful timeout result instead of\n// being killed by the runtime.\nconst INTERACTIVE_TIMEOUT_MS = 300_000;\nconst DEFAULT_MAX_OUTPUT_BYTES = 1_000_000;\n\nconst FAST_TOOLS = new Set([\n \"record_onboarding_privacy_consent\",\n \"create_intent_index\",\n \"delete_intent_index\",\n \"search_intents\",\n \"read_networks\",\n \"update_network\",\n \"create_network\",\n \"delete_network\",\n \"create_network_membership\",\n \"delete_network_membership\",\n \"confirm_opportunity_delivery\",\n \"read_docs\",\n \"get_discovery_run\",\n \"cancel_discovery_run\",\n \"get_profile_run\",\n \"cancel_profile_run\",\n \"remove_contact\",\n \"register_agent\",\n \"list_agents\",\n \"update_agent\",\n \"delete_agent\",\n \"grant_agent_permission\",\n \"revoke_agent_permission\",\n \"retract_premise\",\n]);\n\nconst INTERACTIVE_TOOLS = new Set([\"ask_user_question\"]);\n\nconst ASYNC_CANDIDATE_TOOLS = new Set([\n // Canonical *_user_context names (IND-371)\n \"read_user_contexts\",\n \"preview_user_context\",\n \"create_user_context\",\n \"update_user_context\",\n // Deprecated *_user_profile aliases (kept until IND-373 retires them)\n \"read_user_profiles\",\n \"preview_user_profile\",\n \"create_user_profile\",\n \"update_user_profile\",\n \"create_intent\",\n \"update_intent\",\n \"discover_opportunities\",\n \"scrape_url\",\n \"import_gmail_contacts\",\n \"import_contacts\",\n \"respond_to_negotiation\",\n \"create_premise\",\n \"update_premise\",\n]);\n\nfunction parsePositiveIntEnv(name: string, fallback: number): number {\n const raw = process.env[name];\n if (!raw) return fallback;\n const parsed = Number.parseInt(raw, 10);\n return Number.isFinite(parsed) && parsed > 0 && parsed <= Number.MAX_SAFE_INTEGER\n ? parsed\n : fallback;\n}\n\nfunction toolNameEnv(toolName: string): string {\n return `MCP_TOOL_TIMEOUT_${toolName.toUpperCase().replace(/[^A-Z0-9]+/g, \"_\")}_MS`;\n}\n\nfunction toolNameOutputEnv(toolName: string): string {\n return `MCP_TOOL_MAX_OUTPUT_${toolName.toUpperCase().replace(/[^A-Z0-9]+/g, \"_\")}_BYTES`;\n}\n\nexport function getToolTimeoutPolicy(toolName: string): ToolTimeoutPolicy {\n const classification: ToolTimeoutClass = FAST_TOOLS.has(toolName)\n ? \"fast\"\n : INTERACTIVE_TOOLS.has(toolName)\n ? \"interactive\"\n : ASYNC_CANDIDATE_TOOLS.has(toolName)\n ? \"async_candidate\"\n : \"bounded_slow\";\n\n let classDefault: number;\n switch (classification) {\n case \"fast\":\n classDefault = parsePositiveIntEnv(\"MCP_TOOL_TIMEOUT_FAST_MS\", FAST_TIMEOUT_MS);\n break;\n case \"interactive\":\n classDefault = parsePositiveIntEnv(\"MCP_TOOL_TIMEOUT_INTERACTIVE_MS\", INTERACTIVE_TIMEOUT_MS);\n break;\n case \"async_candidate\":\n classDefault = parsePositiveIntEnv(\"MCP_TOOL_TIMEOUT_ASYNC_CANDIDATE_MS\", ASYNC_CANDIDATE_TIMEOUT_MS);\n break;\n default:\n classDefault = parsePositiveIntEnv(\"MCP_TOOL_TIMEOUT_BOUNDED_SLOW_MS\", BOUNDED_SLOW_TIMEOUT_MS);\n }\n\n const defaultMaxOutputBytes = parsePositiveIntEnv(\"MCP_TOOL_MAX_OUTPUT_BYTES\", DEFAULT_MAX_OUTPUT_BYTES);\n\n return {\n class: classification,\n timeoutMs: parsePositiveIntEnv(toolNameEnv(toolName), classDefault),\n maxOutputBytes: parsePositiveIntEnv(toolNameOutputEnv(toolName), defaultMaxOutputBytes),\n };\n}\n\nexport class ToolRuntimeError extends Error {\n constructor(\n public readonly code: ToolRuntimeErrorCode,\n message: string,\n public readonly toolName: string,\n public readonly policy: ToolTimeoutPolicy,\n ) {\n super(message);\n this.name = \"ToolRuntimeError\";\n }\n}\n\n/** Builds the typed timeout/cancellation error shared by the abort race and catch paths. */\nfunction makeAbortError(timedOut: boolean, toolName: string, policy: ToolTimeoutPolicy): ToolRuntimeError {\n const code: ToolRuntimeErrorCode = timedOut ? \"TOOL_TIMEOUT\" : \"TOOL_CANCELLED\";\n return new ToolRuntimeError(\n code,\n code === \"TOOL_TIMEOUT\"\n ? `Tool ${toolName} timed out after ${policy.timeoutMs}ms.`\n : `Tool ${toolName} was cancelled before it completed.`,\n toolName,\n policy,\n );\n}\n\nfunction combineSignals(signals: Array<AbortSignal | undefined>): {\n signal: AbortSignal;\n abort: (reason?: unknown) => void;\n cleanup: () => void;\n} {\n const controller = new AbortController();\n const listeners: Array<() => void> = [];\n\n for (const source of signals) {\n if (!source) continue;\n if (source.aborted) {\n controller.abort(source.reason);\n break;\n }\n const onAbort = () => {\n if (!controller.signal.aborted) controller.abort(source.reason);\n };\n source.addEventListener(\"abort\", onAbort, { once: true });\n listeners.push(() => source.removeEventListener(\"abort\", onAbort));\n }\n\n return {\n signal: controller.signal,\n abort: (reason?: unknown) => {\n if (!controller.signal.aborted) controller.abort(reason);\n },\n cleanup: () => {\n for (const cleanup of listeners) cleanup();\n },\n };\n}\n\nexport async function invokeToolRuntime(input: ToolInvocationRuntimeInput): Promise<string> {\n return timed(`ToolRuntime.${input.toolName}`, () => invokeToolRuntimeInner(input));\n}\n\nasync function invokeToolRuntimeInner(input: ToolInvocationRuntimeInput): Promise<string> {\n const basePolicy = getToolTimeoutPolicy(input.toolName);\n const policy = {\n ...basePolicy,\n ...(input.timeoutMs !== undefined ? { timeoutMs: input.timeoutMs } : {}),\n ...(input.maxOutputBytes !== undefined ? { maxOutputBytes: input.maxOutputBytes } : {}),\n };\n const inherited = requestContext.getStore();\n const combined = combineSignals([input.signal, inherited?.abortSignal]);\n let timedOut = false;\n const timer = setTimeout(() => {\n timedOut = true;\n combined.abort(new Error(`Tool ${input.toolName} timed out after ${policy.timeoutMs}ms`));\n }, policy.timeoutMs);\n\n let removeAbortListener = () => {};\n const abortPromise = new Promise<never>((_, reject) => {\n const onAbort = () => {\n reject(makeAbortError(timedOut, input.toolName, policy));\n };\n combined.signal.addEventListener(\"abort\", onAbort, { once: true });\n removeAbortListener = () => combined.signal.removeEventListener(\"abort\", onAbort);\n });\n\n try {\n const run = () => input.tool.handler({ context: input.context, query: input.query });\n const toolPromise = requestContext.run(\n {\n ...inherited,\n abortSignal: combined.signal,\n traceEmitter: input.traceEmitter ?? inherited?.traceEmitter,\n },\n run,\n );\n const result = await Promise.race([toolPromise, abortPromise]);\n const outputBytes = new TextEncoder().encode(result).byteLength;\n if (outputBytes > policy.maxOutputBytes) {\n throw new ToolRuntimeError(\n \"TOOL_OUTPUT_TOO_LARGE\",\n `Tool ${input.toolName} returned ${outputBytes} bytes, exceeding the ${policy.maxOutputBytes} byte limit.`,\n input.toolName,\n policy,\n );\n }\n return result;\n } catch (err) {\n if (err instanceof ToolRuntimeError) throw err;\n if (combined.signal.aborted) {\n throw makeAbortError(timedOut, input.toolName, policy);\n }\n throw err;\n } finally {\n clearTimeout(timer);\n removeAbortListener();\n combined.cleanup();\n }\n}\n\nexport function toolRuntimeErrorToResult(err: unknown): string | null {\n if (!(err instanceof ToolRuntimeError)) return null;\n return JSON.stringify({\n success: false,\n code: err.code,\n error: err.message,\n data: {\n tool: err.toolName,\n timeoutClass: err.policy.class,\n timeoutMs: err.policy.timeoutMs,\n maxOutputBytes: err.policy.maxOutputBytes,\n },\n });\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tool.scope.d.ts","sourceRoot":"/","sources":["shared/agent/tool.scope.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,QAAQ,CAAC;AAEjD,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,uBAAwB,SAAQ,iBAAiB;IA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AAC;AAClE,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,mBAAmB,CAAC,KAAiD;IACnF,OAAO,KAAK,CAAC,SAAS,IAAI,gBAAgB,CAAC,KAAK,CAAC,IAAI,cAAc,CAAC;AACtE,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,KAA8B;IACpE,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,gBAAgB,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;IACvF,CAAC;IAED,OAAO,gBAAgB,CACrB,KAAK,CAAC,WAAW;SACd,MAAM,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,KAAK,KAAK,CAAC,OAAO,IAAI,UAAU,CAAC,UAAU,KAAK,IAAI,CAAC;SAChG,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAC7C,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CAAC,KAA8B;IACtE,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;QAC5B,OAAO,gBAAgB,CAAC,KAAK,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC;IACvF,CAAC;IAED,OAAO,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,SAAS,KAAK,KAAK,CAAC,OAAO,CAAC;QACnF,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC;QACjB,CAAC,CAAC,EAAE,CAAC;AACT,CAAC","sourcesContent":["/**\n * Request scope primitives for protocol tools.\n *\n * `scopeType`/`scopeId` describe the user's focused scope, not the full set of\n * networks a caller may read or write. Helper functions derive concrete network\n * id sets from the focused scope plus the caller's memberships.\n */\nexport type ToolScopeType = 'network' | 'intent';\n\nexport interface ToolScopeEnvelope {\n scopeType?: ToolScopeType;\n scopeId?: string;\n}\n\nexport interface ScopeMembership {\n networkId: string;\n isPersonal?: boolean | null;\n}\n\nexport interface DeriveNetworkScopeInput extends ToolScopeEnvelope {\n memberships: ScopeMembership[];\n}\n\nfunction uniqueNetworkIds(ids: string[]): string[] {\n return [...new Set(ids.map((id) => id.trim()).filter(Boolean))];\n}\n\nexport function scopeFromNetworkId(networkId: string | null | undefined): ToolScopeEnvelope {\n const scopeId = networkId?.trim();\n return scopeId ? { scopeType: 'network', scopeId } : {};\n}\n\nexport function scopeFromIntentId(intentId: string | null | undefined): ToolScopeEnvelope {\n const scopeId = intentId?.trim();\n return scopeId ? { scopeType: 'intent', scopeId } : {};\n}\n\nexport function hasNetworkScope(scope: ToolScopeEnvelope): scope is { scopeType: 'network'; scopeId: string } {\n return scope.scopeType === 'network' && typeof scope.scopeId === 'string' && scope.scopeId.trim().length > 0;\n}\n\nexport function hasIntentScope(scope: ToolScopeEnvelope): scope is { scopeType: 'intent'; scopeId: string } {\n return scope.scopeType === 'intent' && typeof scope.scopeId === 'string' && scope.scopeId.trim().length > 0;\n}\n\n/**\n * Returns the focused network id from the canonical scope envelope.\n *\n * This intentionally does not inspect legacy `networkId` fields; callers that\n * still need a transition fallback should pass `scopeFromNetworkId(networkId)`\n * at the boundary so tool logic remains envelope-driven.\n */\nexport function focusedNetworkId(scope: ToolScopeEnvelope): string | undefined {\n return hasNetworkScope(scope) ? scope.scopeId.trim() : undefined;\n}\n\nexport function focusedIntentId(scope: ToolScopeEnvelope): string | undefined {\n return hasIntentScope(scope) ? scope.scopeId.trim() : undefined;\n}\n\n/** Human-readable label for a focused scope, used in scope-restriction notes. */\nexport function focusedNetworkLabel(scope: ToolScopeEnvelope & { indexName?: string }): string {\n return scope.indexName ?? focusedNetworkId(scope) ?? 'this network';\n}\n\nexport function deriveAllowedNetworkIds(input: DeriveNetworkScopeInput): string[] {\n if (!hasNetworkScope(input)) {\n return uniqueNetworkIds(input.memberships.map((membership) => membership.networkId));\n }\n\n return uniqueNetworkIds(\n input.memberships\n .filter((membership) => membership.networkId === input.scopeId || membership.isPersonal === true)\n .map((membership) => membership.networkId),\n );\n}\n\nexport function deriveDiscoveryNetworkIds(input: DeriveNetworkScopeInput): string[] {\n if (!hasNetworkScope(input)) {\n return uniqueNetworkIds(input.memberships.map((membership) => membership.networkId));\n }\n\n return input.memberships.some((membership) => membership.networkId === input.scopeId)\n ? [input.scopeId]\n : [];\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utility.tools.d.ts","sourceRoot":"/","sources":["shared/agent/utility.tools.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAG9D,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,4BAsTxE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utility.tools.js","sourceRoot":"/","sources":["shared/agent/utility.tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,qCAAqC,CAAC;AAGrE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjE,MAAM,UAAU,kBAAkB,CAAC,UAAsB,EAAE,IAAc;IACvE,MAAM,EAAE,OAAO,EAAE,GAAG,IAAI,CAAC;IAEzB,MAAM,SAAS,GAAG,UAAU,CAAC;QAC3B,IAAI,EAAE,YAAY;QAClB,WAAW,EACT,gHAAgH;YAChH,iGAAiG;YACjG,oBAAoB;YACpB,+IAA+I;YAC/I,yHAAyH;YACzH,kDAAkD;YAClD,wHAAwH;YACxH,wFAAwF;YACxF,yFAAyF;QAC3F,WAAW,EAAE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AAC;oBACZ,OAAO,OAAO,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;gBAC7D,CAAC;gBACD,iCAAiC;YACnC,CAAC;YAED,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;YACrD,OAAO,OAAO,CAAC,EAAE,OAAO,EAAE,OAAO,EAAE,CAAC,CAAC;QACvC,CAAC;KACF,CAAC,CAAC;IAEH,MAAM,mBAAmB,GAAG,UAAU,CAAC;QACrC,IAAI,EAAE,uBAAuB;QAC7B,WAAW,EACT,0GAA0G;YAC1G,qHAAqH;YACrH,yGAAyG;QAC3G,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,sEAAsE,CAAC;SACrI,CAAC,CAAC,MAAM,EAAE;QACX,OAAO,EAAE,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE;YAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC;YAChE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,uBAAuB,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC;YAC1E,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;QAC1B,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,SAAS,EAAE,QAAQ,EAAE,mBAAmB,CAAU,CAAC;AAC7D,CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport { requestContext } from \"../observability/request-context.js\";\n\nimport type { DefineTool, ToolDeps } from \"./tool.helpers.js\";\nimport { success, error, normalizeUrl } from \"./tool.helpers.js\";\n\nexport function createUtilityTools(defineTool: DefineTool, deps: ToolDeps) {\n const { scraper } = deps;\n\n const scrapeUrl = defineTool({\n name: \"scrape_url\",\n description:\n \"Extracts text content from a web URL — articles, LinkedIn/GitHub profiles, documentation, project pages, etc. \" +\n \"Returns the page's text content (up to 10,000 characters) for use in subsequent tool calls.\\n\\n\" +\n \"**When to use:**\\n\" +\n \"- Before create_intent: when the user shares a URL and wants to create an intent from it. Scrape first, then synthesize into a description.\\n\" +\n \"- Before create_user_context or update_user_context: when the user shares a profile URL to update their profile from.\\n\" +\n \"- When the user asks about content at a URL.\\n\\n\" +\n \"**URL format:** Bare domains work fine (e.g. 'github.com/user/repo') — protocol (https://) is added automatically.\\n\\n\" +\n \"**Returns:** `{ url, contentLength, content }`. Content is truncated at 10,000 chars. \" +\n \"Returns an error if the URL is unreachable, requires login, or has no extractable text.\",\n querySchema: z.object({\n url: z.string().describe(\"The URL to extract content from. Protocol is optional — 'github.com/user/repo', 'linkedin.com/in/name', and 'https://example.com' all work.\"),\n objective: z.string().optional().describe(\"Why you're scraping — guides content extraction for better results. Examples: 'User wants to create an intent from this project page', 'User wants to update their profile from this LinkedIn page', 'Extract key information about this company'. Omit for generic text extraction.\"),\n }),\n handler: async ({ context: _context, query }) => {\n const normalizedUrl = normalizeUrl(query.url);\n if (!normalizedUrl) {\n return error(\"Invalid URL format. Please provide a valid URL (e.g. 'github.com/user/repo' or 'https://example.com').\");\n }\n\n const content = await scraper.extractUrlContent(normalizedUrl, {\n objective: query.objective?.trim() || undefined,\n signal: requestContext.getStore()?.abortSignal,\n });\n\n if (!content) {\n return error(\"Couldn't extract content from that URL. It may be blocked, require login, or have no extractable text.\");\n }\n\n const truncatedContent = content.length > 10000\n ? content.substring(0, 10000) + \"\\n\\n[Content truncated...]\"\n : content;\n\n return success({\n url: normalizedUrl,\n contentLength: content.length,\n content: truncatedContent,\n });\n },\n });\n\n const readDocs = defineTool({\n name: \"read_docs\",\n description:\n \"Returns comprehensive documentation about the Index Network protocol — entity model, workflows, tool usage guidance, and domain concepts. \" +\n \"This is the primary way for an external agent to bootstrap understanding of the system.\\n\\n\" +\n \"**When to use:** Call this FIRST when starting a new session. MCP agents MUST call read_docs(topic='mcp_agent_guide') at the start of every conversation to learn proper output formatting and workflow rules.\\n\" +\n \"Also call when you need to understand:\\n\" +\n \"- What entities exist and how they relate (intents, indexes, opportunities, profiles, contacts)\\n\" +\n \"- The discovery workflow (how intents become opportunities)\\n\" +\n \"- Which tools to call in what order for common tasks\\n\" +\n \"- Authentication and API patterns\\n\\n\" +\n \"**Returns:** Markdown documentation. Pass `topic` to get a specific section, or omit for the full reference.\\n\\n\" +\n \"**Available topics:** 'entities', 'intents', 'opportunities', 'indexes', 'profiles', 'contacts', 'discovery', 'workflows', 'authentication', 'mcp_agent_guide'\",\n querySchema: z.object({\n topic: z.string().optional().describe(\"Narrow to a specific topic: 'entities', 'intents', 'opportunities', 'indexes', 'profiles', 'contacts', 'discovery', 'workflows', or 'authentication'. Omit to get the full documentation.\"),\n }),\n handler: async ({ context: _context, query }) => {\n const topic = query.topic?.trim().toLowerCase();\n\n const sections: Record<string, string> = {\n entities: `## Entity Model & Relationships\n\n- **Users**: People on the platform. Authenticated via API key (X-API-Key header) for MCP/external agents, or session-based (Better Auth) for the web app.\n- **Profiles**: A user's identity — name, bio, skills, interests, location, social links. Generated from account data or social URLs via enrichment. One profile per user.\n- **Indexes** (also called \"networks\"): Communities or groups where members share intents and discover opportunities. Each has a title, optional prompt (purpose description), join policy (anyone or invite_only), and an owner. The user's **personal network** (isPersonal=true) stores their contacts.\n- **Network Members**: Junction between Users and Indexes. Tracks permissions (owner, member, contact), join date, auto-assign setting, and optional member prompt.\n- **Intents**: Signals of interest/need — what a user is looking for (e.g. \"Looking for a React developer in Berlin\"). Each has a description (payload), summary, confidence score (0-1), inferenceType (explicit/implicit), source tracking, and vector embedding.\n- **IntentNetworks**: Many-to-many junction between Intents and Indexes. An intent can be in multiple indexes. Has a relevancyScore (0-1) indicating how well the intent fits the index's purpose.\n- **Opportunities**: Discovered connections between users based on complementary intents within shared networks. Have actors with roles (introducer, party), status lifecycle, match reasoning, confidence score, and presentation data.\n- **Contacts**: People in a user's personal network, stored as network members with 'contact' permission on the personal network. Can be real users or ghost users (placeholder accounts enriched from public data).\n- **Ghost Users**: Placeholder accounts created for contacts who aren't on the platform yet. Enriched with public profile data (LinkedIn, GitHub) and participate in opportunity matching.\n\n### Key Relationships\n- Users → Profiles (1:1)\n- Users → Indexes (many:many via Network Members)\n- Users → Intents (1:many, user owns intents)\n- Intents → Indexes (many:many via IntentNetworks with relevancyScore)\n- Opportunities → Users (many:many via actors with roles)\n- Opportunities → Indexes (scoped to shared network context)\n- Contacts → Personal Network (stored as members with 'contact' permission)`,\n\n intents: `## Intent Lifecycle\n\nIntents are the core unit of discovery — they represent what users are seeking and drive semantic matching.\n\n1. **Creation** (create_intent): User describes what they're looking for. The system runs inference (extracting structured intents from free text) and verification (checking specificity, speech-act type). Returns a proposal for user approval.\n2. **Confidence & Classification**: Each intent gets a confidence score (0-1), inferenceType (explicit = user stated directly, implicit = system inferred), and speech act classification (commissive, directive, assertive).\n3. **Index Assignment**: After creation, the intent is automatically evaluated against all networks the user belongs to. The index's prompt is used as criteria. Matching indexes get linked via IntentNetworks with a relevancyScore (0-1).\n4. **Discovery Trigger**: Creating an intent triggers background opportunity detection — the system searches for other users in shared networks whose intents complement this one.\n5. **Source Tracking**: Intents track their origin via sourceType (file, integration, link, discovery_form, enrichment) and sourceId.\n6. **Update** (update_intent): Re-processes through inference/verification, recalculates embeddings and index assignments.\n7. **Archive** (delete_intent): Soft-deletes the intent. It stops participating in discovery but is not permanently removed.\n\n### Intent Best Practices\n- Be specific: \"Looking for a senior React developer for a 3-month contract in Berlin\" > \"Need a developer\"\n- One intent per need: don't combine multiple requests into one intent\n- Update rather than delete+create to preserve history`,\n\n opportunities: `## Opportunity Lifecycle\n\nOpportunities represent discovered connections between users — potential matches worth pursuing.\n\n1. **Detection** (discover_opportunities): The opportunity graph finds users whose intents semantically complement each other within shared networks. Uses HyDE embeddings for retrieval and an LLM evaluator for scoring.\n2. **Roles**: Each opportunity assigns roles to actors:\n - **introducer**: The person who triggered the introduction (may be the system or another user)\n - **party**: The people being connected (typically 2)\n3. **Status Flow**: draft → pending → accepted/rejected/expired\n - **draft**: Created but not sent. Only the creator/introducer sees it.\n - **pending**: Sent to the other party. They're notified and can respond.\n - **accepted**: Both parties agreed to connect.\n - **rejected**: One party declined.\n - **expired**: Timed out without response.\n4. **Creation Modes**:\n - **Discovery**: Automatic — system finds matches based on intent overlap (discover_opportunities with searchQuery)\n - **Introduction**: Manual — a user introduces two specific people (discover_opportunities with partyUserIds + entities)\n - **Direct**: One-to-one — connect with a specific person (discover_opportunities with targetUserId)\n5. **Presentation**: Each opportunity includes personalized match reasoning, confidence score, and suggested next action.\n\n### Opportunity Workflow\n1. discover_opportunities(searchQuery=\"AI engineers\") → returns draft opportunity cards\n2. update_opportunity(opportunityId, status=\"pending\") → sends to other party\n3. Other party sees opportunity → calls update_opportunity(status=\"accepted\" or \"rejected\")`,\n\n indexes: `## Index Mechanics\n\nIndexes (also called \"networks\") are communities where members share what they're looking for and the system discovers connections between them.\n\n- **Purpose prompt**: Each index has an optional prompt describing its purpose (e.g. \"AI/ML co-founders in Berlin\"). This prompt is used by the intent indexer to evaluate whether an intent belongs in this community. Networks without prompts accept all intents (relevancyScore defaults to 1.0).\n- **Join policy**: \"anyone\" (open — any user can self-join) or \"invite_only\" (only the owner can add members).\n- **Personal network**: Each user has exactly one personal network (isPersonal=true) created on registration. It stores their contacts. Cannot be deleted, renamed, or listed publicly.\n- **Membership**: Members can see all intents in the index. The **auto-assign** setting on a membership means new intents by that user are automatically evaluated against the index.\n- **Owner permissions**: Network owners can update settings (title, prompt, joinPolicy), add/remove members, and delete the network (if sole member).\n- **Discovery scope**: Opportunities are discovered within index boundaries — the system matches intents of members who share at least one index.\n\n### Index Workflow\n1. create_network(title, prompt) → creates new community, you become owner\n2. create_network_membership(networkId, userId) → invite members\n3. Members create intents → auto-assigned to the index based on prompt\n4. discover_opportunities(networkId) → discover matches within this community`,\n\n profiles: `## Profile System\n\nProfiles are the user's identity on the platform, used for semantic matching in opportunity discovery.\n\n- **Structure**: name, bio, location, skills[], interests[], social links (LinkedIn, GitHub, Twitter, websites)\n- **Generation**: Auto-generated from account data (name, email, social links) via web enrichment. Can also be created from explicit user input (bioOrDescription).\n- **Enrichment**: The system scrapes public profiles (LinkedIn, GitHub, Twitter) to build a rich identity with skills, interests, and narrative context.\n- **Embeddings**: HyDE (Hypothetical Document Embedding) generates synthetic documents for semantic matching:\n - Mirror: self-description of the person\n - Reciprocal: what this person would look for in others\n - Neighborhood: related community context\n- **Onboarding flow**: create_user_context() → preview → create_user_context(confirm=true) → complete_onboarding()\n- **Updates**: Use update_user_context for targeted changes, create_user_context for full regeneration.\n\n### Profile Best Practices\n- Richer profiles produce better opportunity matches\n- Social links enable enrichment — encourage users to add LinkedIn/GitHub\n- Profiles are recalculated when updated, which may surface new matches`,\n\n contacts: `## Contact Management\n\nContacts are people in a user's personal network, stored as members of their personal network with 'contact' permission.\n\n- **Adding contacts**: Via import_contacts (bulk), add_contact (single email), or import_gmail_contacts (Google integration).\n- **Ghost users**: When a contact email doesn't match an existing account, a ghost user is created. Ghost users are enriched with public profile data and participate in opportunity matching — they can be discovered even before joining the platform.\n- **Personal network scope**: Pass the personal network networkId to discover_opportunities to scope discovery to just the user's contacts.\n- **Contact data**: Each contact has userId, name, email, avatar, and isGhost flag.\n\n### Contact Workflow\n1. import_contacts or import_gmail_contacts → bulk add to network\n2. list_contacts → view all contacts with userId\n3. discover_opportunities(networkId=personalIndexId) → find matches among contacts\n4. add_contact(email) → add individual contact\n5. remove_contact(contactUserId) → remove from network`,\n\n discovery: `## Discovery Mechanics\n\nDiscovery is the process of finding meaningful connections between users based on their intents and profiles.\n\n### How Discovery Works\n1. **Trigger**: Runs automatically when an intent is created, or explicitly when discover_opportunities is called.\n2. **Pipeline**: Preparation (gather user context) → Scope (determine which indexes to search) → Candidate retrieval (semantic matching via HyDE embeddings) → Evaluation (LLM scores relevance and complementarity) → Ranking → Persist as opportunities.\n3. **Semantic matching**: Uses HyDE (Hypothetical Document Embeddings) to find candidate intents that complement the source. This goes beyond keyword matching — it understands conceptual relationships.\n4. **Evaluation**: An LLM evaluator agent scores each candidate match on relevance, complementarity, and actionability. Low-scoring matches are filtered out.\n5. **Results**: Persisted as draft opportunities with roles, reasoning, and confidence scores.\n6. **Background processing**: After intent creation, a queue job continues looking for matches asynchronously.\n7. **Pagination**: Large result sets are paginated. Use continueFrom with the discoveryId to evaluate more candidates.\n\n### Discovery Best Practices\n- More specific intents produce more relevant matches\n- Richer profiles improve matching quality\n- Scope to a specific index (networkId) for more targeted results\n- After discovery returns no results, suggest creating an intent to attract future matches`,\n\n workflows: `## Common Tool Workflows\n\n### New User Setup\n1. create_user_context(linkedinUrl/githubUrl) → generate profile from social data\n2. complete_onboarding() → unlock full access\n3. read_networks() → see available communities\n4. create_network_membership(networkId) → join a community\n5. create_intent(description) → post what you're looking for\n6. discover_opportunities(searchQuery) → find matches\n\n### Finding Connections\n1. read_networks() → list user's communities (get networkId)\n2. discover_opportunities(searchQuery, networkId) → discover matches\n3. Review opportunity cards → update_opportunity(opportunityId, status=\"pending\") to send\n\n### Making an Introduction\n1. read_network_memberships(networkId) → find members in shared community\n2. read_user_contexts(userId) → get profiles of both parties\n3. read_intents(networkId, userId) → get intents of both parties\n4. discover_opportunities(partyUserIds=[id1,id2], entities=[...], hint=\"reason\") → create introduction\n\n### Managing Contacts\n1. import_gmail_contacts() or import_contacts([...]) → add contacts\n2. list_contacts() → view network\n3. discover_opportunities(networkId=personalIndexId) → find matches among contacts\n\n### Creating a Community\n1. create_network(title, prompt) → create network\n2. create_network_membership(networkId, userId) → invite members\n3. Members create intents → auto-indexed\n4. discover_opportunities(networkId) → discover connections within community`,\n\n authentication: `## Authentication & API Access\n\n### For External AI Agents (MCP)\n- Authenticate via **X-API-Key** header with a valid API key\n- The API key is tied to a specific user account\n- All operations execute in the context of the authenticated user\n- Base URL: protocol.index.network/mcp\n\n### Key Constraints\n- Users can only read their own intents globally, or intents in indexes they belong to\n- Users can only read profiles of people in shared networks\n- Network-scoped operations are restricted to that index\n- Personal networks cannot be deleted or renamed\n- Only network owners can update settings, add/remove members (for invite_only networks)\n\n### Rate Limits & Best Practices\n- Avoid unnecessary read_intents/read_networks calls — cache results within a conversation\n- Use pagination (limit/page) for large result sets\n- Call read_docs once at the start to understand the domain`,\n\n mcp_agent_guide: `## MCP Agent Integration Guide\n\n**IMPORTANT: Read this section if you are an AI agent accessing Index Network via MCP tools.**\n\n### Output Formatting\n- Tool results often contain structured JSON data (proposals, opportunities, cards). **Do NOT dump raw JSON to the user.** Parse the JSON and present information in natural language with clear formatting.\n- Some tool results contain interactive card markup (code blocks with \\`intent_proposal\\`, \\`opportunity_card\\` language tags). These are designed for the Index Network web UI. **As an MCP agent, ignore card markup.** Instead, extract the meaningful data from the JSON and present it conversationally.\n- When presenting opportunities or intents, use bullet points or short paragraphs — not raw JSON objects.\n\n### Intent Creation Workflow\n- **Always pass \\`autoApprove: true\\` when calling \\`create_intent\\`.** This persists intents directly without returning proposal cards that require manual UI approval.\n- The tool will return a list of created intents with their descriptions and confidence scores. Present these in natural language.\n- Do not tell the user to \"click on cards\" or \"approve above\" — there is no UI. Intents are created immediately with autoApprove.\n- After creating intents, proactively suggest or run discovery to find matches.\n\n### Discovery Workflow\n- After creating intents, proactively suggest running discovery: \\`discover_opportunities(searchQuery=...)\\`\n- Present discovered opportunities in natural language with the counterpart's name, match reasoning, and suggested next steps.\n- Do not reference \"cards\", \"panels\", or any web UI elements.\n\n### General MCP Agent Rules\n- You are operating via API tools, not a web interface. Never reference clicking, scrolling, cards, panels, or any visual UI elements.\n- Be proactive: if a logical next step exists (e.g., running discovery after creating intents), suggest or execute it.\n- Use \\`list_opportunities\\` to check existing matches, \\`list_negotiations\\` for ongoing negotiations.\n- Use \\`read_networks\\` to understand which communities the user belongs to before scoping operations.\n- When errors occur, provide clear technical context rather than vague \"backend issue\" messages.`,\n };\n\n if (topic) {\n const matched = Object.entries(sections).find(([key]) => key.includes(topic) || topic.includes(key));\n if (matched) {\n return success({ topic: matched[0], content: matched[1] });\n }\n // If topic not found, return all\n }\n\n const fullDoc = Object.values(sections).join(\"\\n\\n\");\n return success({ content: fullDoc });\n },\n });\n\n const reportAgentActivity = defineTool({\n name: \"report_agent_activity\",\n description:\n \"Reports grounded, aggregate-only activity for the authenticated user's agent over a recent time window. \" +\n \"It includes live signal count, opportunities surfaced by the user's own signals, pending/answered question counts, \" +\n \"and negotiation totals. It never returns counterpart identities, transcripts, or per-counterparty rows.\",\n querySchema: z.object({\n sinceHours: z.number().int().optional().default(24).describe(\"Look back this many hours; values are clamped to 1-168 (default 24).\"),\n }).strict(),\n handler: async ({ query }) => {\n const sinceHours = Math.max(1, Math.min(168, query.sinceHours));\n const summary = await deps.userDb.getAgentActivitySummary({ sinceHours });\n return success(summary);\n },\n });\n\n return [scrapeUrl, readDocs, reportAgentActivity] as const;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"network-assignment.policy.d.ts","sourceRoot":"/","sources":["shared/assignment/network-assignment.policy.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AACjF,OAAO,KAAK,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,6BAA6B,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAEpO,yEAAyE;AACzE,eAAO,MAAM,oCAAoC,MAAM,CAAC;AAExD,MAAM,WAAW,mBAAmB;IAClC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B;AAED,MAAM,MAAM,yBAAyB,GAAG,eAAe,GAAG,MAAM,CAAC;AAEjE,MAAM,WAAW,iCAAkC,SAAQ,iBAAiB;IAC1E,WAAW,EAAE,yBAAyB,EAAE,CAAC;IACzC,0DAA0D;IAC1D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,kCAAmC,SAAQ,mBAAmB;IAC7E,YAAY,EAAE,6BAA6B,CAAC;IAC5C,IAAI,EAAE,qBAAqB,CAAC;IAC5B,KAAK,EAAE,sBAAsB,CAAC;IAC9B,SAAS,CAAC,EAAE,0BAA0B,GAAG,IAAI,CAAC;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,yBAAyB;IACxC,QAAQ,EAAE,OAAO,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,yBAAyB,CAAC;CACrC;AAED;;;;;GAKG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,mBAAmB,GAAG,+BAA+B,CAOlG;AAED;;;;;;;GAOG;AACH,wBAAgB,6BAA6B,CAAC,IAAI,EAAE,iCAAiC,GAAG,MAAM,EAAE,CAW/F;AAED;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,kCAAkC,GAAG,yBAAyB,CAiBlH;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,SAAS,EAAE,0BAA0B,EACrC,cAAc,EAAE,+BAA+B,GAC9C,MAAM,CAcR"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"network-assignment.policy.js","sourceRoot":"/","sources":["shared/assignment/network-assignment.policy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,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,CAAC;AACzC,CAAC","sourcesContent":["import { deriveAllowedNetworkIds, scopeFromNetworkId } from \"../agent/tool.scope.js\";\nimport type { ScopeMembership, ToolScopeEnvelope } from \"../agent/tool.scope.js\";\nimport type { NetworkAssignmentMetadata, NetworkAssignmentMode, NetworkAssignmentPromptPresence, NetworkAssignmentRawScores, NetworkAssignmentResourceType, NetworkAssignmentScope } from \"../schemas/network-assignment.schema.js\";\n\n/** Centralized default for unified premise/intent network assignment. */\nexport const DEFAULT_NETWORK_ASSIGNMENT_THRESHOLD = 0.7;\n\nexport interface PromptPresenceInput {\n indexPrompt?: string | null;\n memberPrompt?: string | null;\n}\n\nexport type AssignmentScopeMembership = ScopeMembership | string;\n\nexport interface ResolveAssignmentNetworkScopeArgs extends ToolScopeEnvelope {\n memberships: AssignmentScopeMembership[];\n /** @deprecated Use `scopeType: 'network'` + `scopeId`. */\n networkScopeId?: string;\n}\n\nexport interface BuildNetworkAssignmentDecisionArgs extends PromptPresenceInput {\n resourceType: NetworkAssignmentResourceType;\n mode: NetworkAssignmentMode;\n scope: NetworkAssignmentScope;\n rawScores?: NetworkAssignmentRawScores | null;\n threshold?: number;\n evaluator?: string;\n source?: string;\n reason?: string;\n createdAt?: string;\n}\n\nexport interface NetworkAssignmentDecision {\n assigned: boolean;\n finalScore: number;\n metadata: NetworkAssignmentMetadata;\n}\n\n/**\n * Classifies whether a network/member prompt pair can filter a resource.\n *\n * @param input - Network and member prompt values to inspect.\n * @returns Prompt-presence classification for assignment policy decisions.\n */\nexport function classifyPromptPresence(input: PromptPresenceInput): NetworkAssignmentPromptPresence {\n const hasIndex = !!input.indexPrompt?.trim();\n const hasMember = !!input.memberPrompt?.trim();\n if (hasIndex && hasMember) return \"both\";\n if (hasIndex) return \"index\";\n if (hasMember) return \"member\";\n return \"none\";\n}\n\n/**\n * Resolves the networks to evaluate: all memberships in global scope, or the\n * focused network plus personal memberships in network scope. The focused\n * network must also be a membership to avoid broadening scope accidentally.\n *\n * @param args - User memberships plus optional active network scope.\n * @returns Network IDs that assignment should evaluate.\n */\nexport function resolveAssignmentNetworkScope(args: ResolveAssignmentNetworkScopeArgs): string[] {\n const memberships = args.memberships.map((membership) => (\n typeof membership === \"string\"\n ? { networkId: membership, isPersonal: false }\n : membership\n ));\n const scope = args.scopeType && args.scopeId\n ? { scopeType: args.scopeType, scopeId: args.scopeId }\n : scopeFromNetworkId(args.networkScopeId);\n\n return deriveAllowedNetworkIds({ memberships, ...scope });\n}\n\n/**\n * Builds a unified assignment decision and metadata envelope.\n *\n * @param args - Assignment resource, scope, prompt, score, and provenance inputs.\n * @returns Assignment decision and explainability metadata.\n */\nexport function buildNetworkAssignmentDecision(args: BuildNetworkAssignmentDecisionArgs): NetworkAssignmentDecision {\n const threshold = clampScore(args.threshold ?? DEFAULT_NETWORK_ASSIGNMENT_THRESHOLD);\n const promptPresence = classifyPromptPresence(args);\n\n if (args.mode === \"manual_override\") {\n const finalScore = 1.0;\n return buildDecision(args, promptPresence, threshold, finalScore, true, args.reason ?? \"Explicit manual override.\");\n }\n\n if (promptPresence === \"none\") {\n const finalScore = 1.0;\n return buildDecision(args, promptPresence, threshold, finalScore, true, args.reason ?? \"No prompts configured; network has no dynamic filtration.\");\n }\n\n const finalScore = combineAssignmentScores(args.rawScores ?? {}, promptPresence);\n const assigned = finalScore >= threshold;\n return buildDecision(args, promptPresence, threshold, finalScore, assigned, args.reason);\n}\n\n/**\n * Combines index/member scores according to available prompt filtration.\n *\n * @param rawScores - Optional normalized index and member scores.\n * @param promptPresence - Which prompts are present for this assignment decision.\n * @returns Final normalized score in the 0..1 range.\n */\nexport function combineAssignmentScores(\n rawScores: NetworkAssignmentRawScores,\n promptPresence: NetworkAssignmentPromptPresence,\n): number {\n const indexScore = clampScore(rawScores.indexScore ?? 0);\n const memberScore = clampScore(rawScores.memberScore ?? 0);\n\n switch (promptPresence) {\n case \"both\":\n return clampScore(indexScore * 0.6 + memberScore * 0.4);\n case \"index\":\n return indexScore;\n case \"member\":\n return memberScore;\n case \"none\":\n return 1.0;\n }\n}\n\nfunction buildDecision(\n args: BuildNetworkAssignmentDecisionArgs,\n promptPresence: NetworkAssignmentPromptPresence,\n threshold: number,\n finalScore: number,\n assigned: boolean,\n reason?: string,\n): NetworkAssignmentDecision {\n return {\n assigned,\n finalScore,\n metadata: {\n resourceType: args.resourceType,\n mode: args.mode,\n scope: args.scope,\n policy: \"unified-threshold-v1\",\n threshold,\n promptPresence,\n ...(args.rawScores ? { rawScores: args.rawScores } : {}),\n finalScore,\n assigned,\n ...(reason ? { reason } : {}),\n ...(args.evaluator ? { evaluator: args.evaluator } : {}),\n ...(args.source ? { source: args.source } : {}),\n ...(args.createdAt ? { createdAt: args.createdAt } : {}),\n },\n };\n}\n\nfunction clampScore(score: number): number {\n if (!Number.isFinite(score)) return 0;\n return Math.max(0, Math.min(1, score));\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hyde.documents.d.ts","sourceRoot":"/","sources":["shared/hyde/hyde.documents.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qCAAqC,CAAC;AACxE,OAAO,EAAiC,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAEvF,+EAA+E;AAC/E,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,CAEpE;AAoBD;;;GAGG;AACH,wBAAgB,gCAAgC,CAC9C,SAAS,EAAE,YAAY,EAAE,EACzB,IAAI,EAAE,kBAAkB,EACxB,UAAU,EAAE,MAAM,GACjB,YAAY,EAAE,CAyBhB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hyde.documents.js","sourceRoot":"/","sources":["shared/hyde/hyde.documents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAGpC,OAAO,EAAE,6BAA6B,EAA2B,MAAM,eAAe,CAAC;AAEvF,+EAA+E;AAC/E,MAA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D,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,yBAAyB,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC,CAAC;IACrG,IAAI,iBAAqC,CAAC;IAC1C,IAAI,eAAe,GAAG,MAAM,CAAC,iBAAiB,CAAC;IAE/C,KAAK,MAAM,QAAQ,IAAI,QAAQ,EAAE,CAAC;QAChC,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAC;QAClD,IAAI,OAAO,WAAW,KAAK,QAAQ;YAAE,SAAS;QAC9C,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC1C,IAAI,SAAS,GAAG,eAAe,EAAE,CAAC;YAChC,eAAe,GAAG,SAAS,CAAC;YAC5B,iBAAiB,GAAG,WAAW,CAAC;QAClC,CAAC;IACH,CAAC;IAED,OAAO,iBAAiB;QACtB,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,KAAK,iBAAiB,CAAC;QACpF,CAAC,CAAC,EAAE,CAAC;AACT,CAAC","sourcesContent":["import { createHash } from 'crypto';\n\nimport type { HydeDocument } from '../interfaces/database.interface.js';\nimport { HYDE_FRAME_GENERATION_VERSION, type HydeGenerationMode } from './hyde.env.js';\n\n/** Hash source text without persisting the source itself in frame metadata. */\nexport function computeHydeSourceTextHash(sourceText: string): string {\n return createHash('sha256').update(sourceText).digest('hex');\n}\n\nfunction isFrameStrategy(strategy: string): boolean {\n return strategy.startsWith(`${HYDE_FRAME_GENERATION_VERSION}:`);\n}\n\nfunction hasFrameMetadataForSource(document: HydeDocument, sourceTextHash: string): boolean {\n const context = document.context;\n return isFrameStrategy(document.strategy)\n && context?.hydeGenerationVersion === HYDE_FRAME_GENERATION_VERSION\n && context.validationStatus === 'valid'\n && typeof context.lensLabel === 'string'\n && context.lensLabel.length > 0\n && typeof context.frameFingerprint === 'string'\n && context.frameFingerprint.length > 0\n && context.sourceTextHash === sourceTextHash\n && typeof context.generatedAt === 'string'\n && Number.isFinite(Date.parse(context.generatedAt));\n}\n\n/**\n * Select persisted documents that belong to the currently active generation\n * mode and, for frame-v1, the newest generation marker group.\n */\nexport function selectHydeDocumentsForGeneration(\n documents: HydeDocument[],\n mode: HydeGenerationMode,\n sourceText: string,\n): HydeDocument[] {\n if (mode === 'legacy') {\n return documents.filter((document) =>\n !isFrameStrategy(document.strategy)\n && document.context?.hydeGenerationVersion !== HYDE_FRAME_GENERATION_VERSION);\n }\n\n const sourceTextHash = computeHydeSourceTextHash(sourceText);\n const eligible = documents.filter((document) => hasFrameMetadataForSource(document, sourceTextHash));\n let newestGeneratedAt: string | undefined;\n let newestTimestamp = Number.NEGATIVE_INFINITY;\n\n for (const document of eligible) {\n const generatedAt = document.context?.generatedAt;\n if (typeof generatedAt !== 'string') continue;\n const timestamp = Date.parse(generatedAt);\n if (timestamp > newestTimestamp) {\n newestTimestamp = timestamp;\n newestGeneratedAt = generatedAt;\n }\n }\n\n return newestGeneratedAt\n ? eligible.filter((document) => document.context?.generatedAt === newestGeneratedAt)\n : [];\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hyde.env.d.ts","sourceRoot":"/","sources":["shared/hyde/hyde.env.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,eAAO,MAAM,6BAA6B,EAAG,UAAmB,CAAC;AAEjE,MAAM,MAAM,kBAAkB,GAAG,QAAQ,GAAG,OAAO,6BAA6B,CAAC;AAEjF;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,KAAK,GAAE,MAAM,GAAG,SAAsD,GACrE,kBAAkB,CAEpB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hyde.env.js","sourceRoot":"/","sources":["shared/hyde/hyde.env.ts"],"names":[],"mappings":"AAAA,6BAA6B;AAC7B,MAAM,CAAC,MAAM,6BAA6B,GAAG,UAAmB,CAAC;AAIjE;;;GAGG;AACH,MAAM,UAAU,qBAAqB,CACnC,QAA4B,OAAO,CAAC,GAAG,CAAC,8BAA8B;IAEtE,OAAO,KAAK,KAAK,MAAM,CAAC,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,QAAQ,CAAC;AACrE,CAAC","sourcesContent":["/** HyDE generation modes. */\nexport const HYDE_FRAME_GENERATION_VERSION = 'frame-v1' as const;\n\nexport type HydeGenerationMode = 'legacy' | typeof HYDE_FRAME_GENERATION_VERSION;\n\n/**\n * Resolve the HyDE generation mode from the feature flag.\n * Only the exact literal `true` enables frame-constrained generation.\n */\nexport function getHydeGenerationMode(\n value: string | undefined = process.env.HYDE_FRAME_CONSTRAINTS_ENABLED,\n): HydeGenerationMode {\n return value === 'true' ? HYDE_FRAME_GENERATION_VERSION : 'legacy';\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hyde.frame.d.ts","sourceRoot":"/","sources":["shared/hyde/hyde.frame.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,0BAA0B,gGAQ7B,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjF,gFAAgF;AAChF,MAAM,WAAW,uBAAuB;IACtC,IAAI,EAAE,sBAAsB,CAAC;IAC7B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,uBAAuB,8EAO1B,CAAC;AAEX,MAAM,MAAM,mBAAmB,GAAG,CAAC,OAAO,uBAAuB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE3E,oEAA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,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;KACvF,CAAC;AACJ,CAAC","sourcesContent":["import { z } from 'zod';\n\n/** Source-grounded role supported by an exact span from the source text. */\nexport interface HydeFrameRole {\n role: string;\n evidence: string;\n}\n\nexport const HYDE_HARD_CONSTRAINT_TYPES = [\n 'location',\n 'time',\n 'numeric',\n 'credential',\n 'organization',\n 'exclusivity',\n 'other',\n] as const;\n\nexport type HydeHardConstraintType = (typeof HYDE_HARD_CONSTRAINT_TYPES)[number];\n\n/** Explicit hard constraint supported by an exact span from the source text. */\nexport interface HydeFrameHardConstraint {\n type: HydeHardConstraintType;\n value: string;\n evidence: string;\n}\n\nexport const HYDE_NAMED_ENTITY_TYPES = [\n 'person',\n 'organization',\n 'product',\n 'location',\n 'event',\n 'other',\n] as const;\n\nexport type HydeNamedEntityType = (typeof HYDE_NAMED_ENTITY_TYPES)[number];\n\n/** Named entity supported by an exact span from the source text. */\nexport interface HydeFrameNamedEntity {\n type: HydeNamedEntityType;\n name: string;\n evidence: string;\n}\n\n/** Domain term supported by an exact span from the source text. */\nexport interface HydeFrameVocabulary {\n term: string;\n evidence: string;\n}\n\n/**\n * Source-grounded controls for frame-constrained HyDE generation.\n * Counterpart roles may be reciprocal/complementary inferences, but their\n * evidence must still be an exact span from the source text.\n */\nexport interface HydeSourceFrame {\n sourceRoles: HydeFrameRole[];\n counterpartRoles: HydeFrameRole[];\n hardConstraints: HydeFrameHardConstraint[];\n namedEntities: HydeFrameNamedEntity[];\n domainVocabulary: HydeFrameVocabulary[];\n}\n\nconst roleSchema = z.object({\n role: z.string().min(1),\n evidence: z.string().min(1).describe('Exact evidence span copied from sourceText'),\n});\n\nconst hardConstraintSchema = z.object({\n type: z.enum(HYDE_HARD_CONSTRAINT_TYPES),\n value: z.string().min(1),\n evidence: z.string().min(1).describe('Exact evidence span copied from sourceText'),\n});\n\nconst namedEntitySchema = z.object({\n type: z.enum(HYDE_NAMED_ENTITY_TYPES),\n name: z.string().min(1),\n evidence: z.string().min(1).describe('Exact evidence span copied from sourceText'),\n});\n\nconst vocabularySchema = z.object({\n term: z.string().min(1),\n evidence: z.string().min(1).describe('Exact evidence span copied from sourceText'),\n});\n\n/** Structured-output schema for source-grounded frames. */\nexport const HydeSourceFrameSchema = z.object({\n sourceRoles: z.array(roleSchema),\n counterpartRoles: z.array(roleSchema),\n hardConstraints: z.array(hardConstraintSchema),\n namedEntities: z.array(namedEntitySchema),\n domainVocabulary: z.array(vocabularySchema),\n});\n\nfunction escapeRegularExpression(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/** Case-insensitive literal matching bounded by Unicode letters and numbers. */\nfunction containsAlphanumericSpanCaseInsensitive(container: string, value: string): boolean {\n const needle = value.trim();\n if (!needle) return false;\n return new RegExp(\n `(?<![\\\\p{L}\\\\p{M}\\\\p{N}])${escapeRegularExpression(needle)}(?![\\\\p{L}\\\\p{M}\\\\p{N}])`,\n 'iu',\n ).test(container);\n}\n\nfunction hasExactEvidence(sourceText: string, evidence: string): boolean {\n return containsAlphanumericSpanCaseInsensitive(sourceText, evidence);\n}\n\nconst GENERIC_ROLE_TOKENS = new Set([\n 'advisor', 'analyst', 'attendee', 'borrower', 'builder', 'buyer', 'candidate',\n 'capitalist', 'ceo', 'cfo', 'client', 'cmo', 'cofounder', 'collaborator',\n 'consultant', 'coo', 'creator', 'cto', 'customer', 'designer', 'developer',\n 'director', 'employer', 'engineer', 'entrepreneur', 'executive', 'expert',\n 'founder', 'funder', 'hire', 'hiring', 'investor', 'leader', 'lender',\n 'manager', 'mentor', 'operator', 'organizer', 'owner', 'partner', 'practitioner',\n 'professional', 'provider', 'recruiter', 'researcher', 'scientist', 'seller',\n 'speaker', 'specialist', 'sponsor', 'strategist', 'supplier', 'technologist',\n 'vendor', 'vp',\n]);\n\nconst GENERIC_ROLE_MODIFIERS = new Set([\n 'business', 'co', 'commercial', 'community', 'creative', 'early', 'experienced',\n 'growth', 'independent', 'industry', 'junior', 'lead', 'local', 'nonprofit',\n 'operations', 'product', 'professional', 'public', 'senior', 'stage',\n 'startup', 'technical', 'venture',\n]);\n\nfunction roleTokens(role: string): string[] {\n return role.toLowerCase().match(/[\\p{L}\\p{M}\\d]+/gu) ?? [];\n}\n\nfunction hasUnsupportedSourceRoleMaterial(role: string, evidence: string): boolean {\n const substantiveTokens = roleTokens(role).filter((token) => !GENERIC_ROLE_MODIFIERS.has(token));\n return substantiveTokens.length === 0\n || substantiveTokens.some((token) => !containsAlphanumericSpanCaseInsensitive(evidence, token));\n}\n\nfunction hasUnsupportedCounterpartRoleMaterial(role: string, evidence: string): boolean {\n return roleTokens(role).some((token) =>\n !GENERIC_ROLE_TOKENS.has(token)\n && !GENERIC_ROLE_MODIFIERS.has(token)\n && !containsAlphanumericSpanCaseInsensitive(evidence, token));\n}\n\n/**\n * Remove frame elements that cross the source-evidence boundary. Structured\n * payloads must occur inside their evidence span. Source roles require grounded\n * substantive tokens; counterpart roles may add generic inferred role language.\n */\nexport function sanitizeHydeSourceFrame(sourceText: string, frame: HydeSourceFrame): HydeSourceFrame {\n const grounded = <T extends { evidence: string }>(items: T[]): T[] =>\n items.filter((item) => hasExactEvidence(sourceText, item.evidence));\n return {\n sourceRoles: grounded(frame.sourceRoles)\n .filter((item) => !hasUnsupportedSourceRoleMaterial(item.role, item.evidence)),\n counterpartRoles: grounded(frame.counterpartRoles)\n .filter((item) => !hasUnsupportedCounterpartRoleMaterial(item.role, item.evidence)),\n hardConstraints: grounded(frame.hardConstraints)\n .filter((item) => containsAlphanumericSpanCaseInsensitive(item.evidence, item.value)),\n namedEntities: grounded(frame.namedEntities)\n .filter((item) => containsAlphanumericSpanCaseInsensitive(item.evidence, item.name)),\n domainVocabulary: grounded(frame.domainVocabulary)\n .filter((item) => containsAlphanumericSpanCaseInsensitive(item.evidence, item.term)),\n };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hyde.generator.d.ts","sourceRoot":"/","sources":["shared/hyde/hyde.generator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAQnF,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAoB3D,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,iBAAiB;IAChC,qCAAqC;IACrC,UAAU,EAAE,MAAM,CAAC;IACnB,uEAAuE;IACvE,IAAI,EAAE,MAAM,CAAC;IACb,yCAAyC;IACzC,MAAM,EAAE,gBAAgB,CAAC;IACzB,kFAAkF;IAClF,WAAW,CAAC,EAAE,eAAe,CAAC;CAC/B;AAED,mFAAmF;AACnF,MAAM,WAAW,4BAA4B;IAC3C,MAAM,CAAC,KAAK,EAAE,sBAAsB,EAAE,MAAM,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5F;AAMD,2EAA2E;AAC3E,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,iBAAiB,GAAG;IAAE,WAAW,EAAE,eAAe,CAAA;CAAE,GAAG,MAAM,CA0BxG;AAED,qFAAqF;AACrF,qBAAa,aAAa;IACxB,OAAO,CAAC,KAAK,CAAC,CAA+B;gBAEjC,KAAK,CAAC,EAAE,4BAA4B;IAQhD,OAAO,CAAC,QAAQ;IAOhB,2EAA2E;IAErE,QAAQ,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAuBvE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hyde.generator.js","sourceRoot":"/","sources":["shared/hyde/hyde.generator.ts"],"names":[],"mappings":";;;;;;;;;AAKA,OAAO,EAAE,YAAY,EAAE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YAClC,CAAC,CAAC,oBAAoB,CAAC,KAA6D,CAAC;YACrF,CAAC,CAAC,mBAAmB,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC;QAEpE,MAAM,QAAQ,GAAG;YACf,IAAI,aAAa,CAAC,aAAa,CAAC;YAChC,IAAI,YAAY,CAAC,UAAU,CAAC;SAC7B,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,QAAQ,CAAC,CAAC;QACtE,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC5C,MAAM,IAAI,GAAG,MAAM,CAAC,oBAAoB,IAAI,EAAE,CAAC;QAE/C,MAAM,CAAC,OAAO,CAAC,yBAAyB,EAAE;YACxC,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,MAAM,EAAE,KAAK,CAAC,MAAM;YACpB,UAAU,EAAE,IAAI,CAAC,MAAM;YACvB,gBAAgB,EAAE,CAAC,CAAC,KAAK,CAAC,WAAW;SACtC,CAAC,CAAC;QAEH,OAAO,EAAE,IAAI,EAAE,CAAC;IAClB,CAAC;CACF;AAvBO;IADL,KAAK,EAAE;;;;6CAuBP","sourcesContent":["/**\n * HyDE Generator Agent: pure LLM agent for generating hypothetical documents\n * in the target corpus voice. Uses free-text lens labels instead of enum strategies.\n */\nimport type { BaseLanguageModelInput } from '@langchain/core/language_models/base';\nimport { HumanMessage, SystemMessage } from '@langchain/core/messages';\nimport { z } from 'zod';\n\nimport { createStructuredModel } from \"../agent/model.config.js\";\nimport { invokeWithAbortSignal } from \"../agent/model-signal.js\";\nimport { protocolLogger } from '../observability/protocol.logger.js';\nimport { Timed } from \"../observability/performance.js\";\nimport type { HydeSourceFrame } from './hyde.frame.js';\nimport { HYDE_CORPUS_PROMPTS } from './hyde.strategies.js';\nimport type { HydeTargetCorpus } from './lens.inferrer.js';\n\nconst logger = protocolLogger(\"HydeGenerator\");\n\nconst SYSTEM_PROMPT = `You are a Hypothetical Document Generator for semantic search.\n\nYour task: Given a source statement (e.g. an intent or goal), write a short hypothetical document in the voice of the TARGET side—the kind of person or statement that would be an ideal match for that source.\n\nRules:\n- Write in first person as the target.\n- Be concrete and specific so the text is good for vector similarity search.\n- Output only the hypothetical document text, no meta-commentary.\n- Keep length to a few sentences or one short paragraph.`;\n\nconst responseFormat = z.object({\n hypotheticalDocument: z\n .string()\n .describe('The hypothetical document text in the target voice, suitable for embedding and retrieval'),\n});\n\nexport interface HydeGeneratorOutput {\n text: string;\n}\n\nexport interface HydeGenerateInput {\n /** Original intent or query text. */\n sourceText: string;\n /** Free-text lens label from LensInferrer (e.g. \"crypto infra VC\"). */\n lens: string;\n /** Which corpus voice to generate in. */\n corpus: HydeTargetCorpus;\n /** Sanitized source-grounded frame. Absence preserves the exact legacy prompt. */\n sourceFrame?: HydeSourceFrame;\n}\n\n/** Minimal structured model contract used for deterministic injection in tests. */\nexport interface HydeGeneratorStructuredModel {\n invoke(input: BaseLanguageModelInput, config?: { signal?: AbortSignal }): Promise<unknown>;\n}\n\nfunction renderList(items: string[]): string {\n return items.length > 0 ? items.join('; ') : '(none)';\n}\n\n/** Build the frame-v1 generation prompt from sanitized source evidence. */\nexport function buildFrameHydePrompt(input: HydeGenerateInput & { sourceFrame: HydeSourceFrame }): string {\n const { sourceText, corpus, sourceFrame } = input;\n const corpusInstruction = {\n profiles: 'Write a first-person professional biography in the target profile voice.',\n intents: 'Write a first-person goal or aspiration in the target intent voice.',\n premises: 'Write a first-person stable identity, values, or worldview statement in the target premise voice.',\n }[corpus];\n\n return `${corpusInstruction}\n\nSource text: \"${sourceText}\"\n\nSanitized source frame:\n- Source roles: ${renderList(sourceFrame.sourceRoles.map((item) => `${item.role} [evidence: \"${item.evidence}\"]`))}\n- Counterpart/complementary roles: ${renderList(sourceFrame.counterpartRoles.map((item) => `${item.role} [evidence: \"${item.evidence}\"]`))}\n- Explicit hard constraints: ${renderList(sourceFrame.hardConstraints.map((item) => `${item.type}: ${item.value} [evidence: \"${item.evidence}\"]`))}\n- Named entities: ${renderList(sourceFrame.namedEntities.map((item) => `${item.type}: ${item.name} [evidence: \"${item.evidence}\"]`))}\n- Domain vocabulary: ${renderList(sourceFrame.domainVocabulary.map((item) => `${item.term} [evidence: \"${item.evidence}\"]`))}\n\nGeneration constraints:\n- You MAY elaborate generic roles and generic domain language.\n- You MAY use reciprocal/complementary inversion and write in the target voice.\n- You MUST NOT introduce any new proper noun or named entity.\n- You MUST NOT introduce any new hard location, time, numeric, credential, organization, or exclusivity constraint.\n- Preserve explicit source-frame constraints when they apply to the reciprocal target.\n- Output only a few sentences or one short paragraph.`;\n}\n\n/** Generates hypothetical documents in a target corpus voice for semantic search. */\nexport class HydeGenerator {\n private model?: HydeGeneratorStructuredModel;\n\n constructor(model?: HydeGeneratorStructuredModel) {\n // Preserve the legacy production model construction path; injected models\n // keep prompt tests provider-free.\n this.model = model ?? createStructuredModel(\"hydeGenerator\", responseFormat, {\n name: \"hyde_generator\",\n });\n }\n\n private getModel(): HydeGeneratorStructuredModel {\n this.model ??= createStructuredModel(\"hydeGenerator\", responseFormat, {\n name: \"hyde_generator\",\n });\n return this.model;\n }\n\n /** Generate a hypothetical document for the given source text and lens. */\n @Timed()\n async generate(input: HydeGenerateInput): Promise<HydeGeneratorOutput> {\n const promptText = input.sourceFrame\n ? buildFrameHydePrompt(input as HydeGenerateInput & { sourceFrame: HydeSourceFrame })\n : HYDE_CORPUS_PROMPTS[input.corpus](input.sourceText, input.lens);\n\n const messages = [\n new SystemMessage(SYSTEM_PROMPT),\n new HumanMessage(promptText),\n ];\n\n const result = await invokeWithAbortSignal(this.getModel(), messages);\n const parsed = responseFormat.parse(result);\n const text = parsed.hypotheticalDocument ?? '';\n\n logger.verbose('Generated HyDE document', {\n lens: input.lens,\n corpus: input.corpus,\n textLength: text.length,\n frameConstrained: !!input.sourceFrame,\n });\n\n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AAG,CAAC,cAAc;oCAClC,WAAW,EAAE,GAAG,CAAC,WAAW;iCAC7B;6BACF,CAAC,CAAC,CAAC,EAAE,CAAC;yBACR,CAAC,CAAC;oBACL,CAAC;gBACH,CAAC;gBACD,OAAO,EAAE,CAAC;YACZ,CAAC,CAAC,CAAC;QACL,CAAC,CAAC;QAEF,MAAM,QAAQ,GAAG,IAAI,UAAU,CAAC,cAAc,CAAC;aAC5C,OAAO,CAAC,cAAc,EAAE,eAAe,CAAC;aACxC,OAAO,CAAC,aAAa,EAAE,cAAc,CAAC;aACtC,OAAO,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;aAChD,OAAO,CAAC,OAAO,EAAE,SAAS,CAAC;aAC3B,OAAO,CAAC,eAAe,EAAE,gBAAgB,CAAC;aAC1C,OAAO,CAAC,KAAK,EAAE,cAAc,CAAC;aAC9B,OAAO,CAAC,cAAc,EAAE,aAAa,CAAC;aACtC,mBAAmB,CAAC,aAAa,EAAE,cAAc,EAAE;YAClD,QAAQ,EAAE,kBAAkB;YAC5B,IAAI,EAAE,OAAO;SACd,CAAC,CAAC;QAEL,IAAI,IAAI,KAAK,6BAA6B,EAAE,CAAC;YAC3C,QAAQ;iBACL,OAAO,CAAC,oBAAoB,EAAE,qBAAqB,CAAC;iBACpD,OAAO,CAAC,kBAAkB,EAAE,oBAAoB,CAAC;iBACjD,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC,CAAC;QAC5C,CAAC;aAAM,CAAC;YACN,QAAQ,CAAC,OAAO,CAAC,kBAAkB,EAAE,OAAO,CAAC,CAAC;QAChD,CAAC;QAED,QAAQ;aACL,OAAO,CAAC,OAAO,EAAE,eAAe,CAAC;aACjC,OAAO,CAAC,eAAe,EAAE,GAAG,CAAC,CAAC;QAEjC,OAAO,QAAQ,CAAC,OAAO,EAAE,CAAC;IAC5B,CAAC;CACF","sourcesContent":["/**\n * HyDE Graph: cache-aware hypothetical document generation with lens inference.\n *\n * Legacy flow: infer_lenses → check_cache → generate_missing? → embed → cache_results.\n * Frame-v1 flow adds one batch validate_generated node before embed.\n */\nimport { createHash } from 'crypto';\nimport { END, START, StateGraph } from '@langchain/langgraph';\n\nimport type { DebugMetaAgent } from '../../chat/chat-streaming.types.js';\nimport { getAbortSignalConfig } from '../agent/model-signal.js';\nimport type { HydeCache } from '../interfaces/cache.interface.js';\nimport type { HydeGraphDatabase } from '../interfaces/database.interface.js';\nimport type { EmbeddingGenerator } from '../interfaces/embedder.interface.js';\nimport { protocolLogger } from '../observability/protocol.logger.js';\nimport { timed } from '../observability/performance.js';\nimport { requestContext } from \"../observability/request-context.js\";\nimport { computeHydeSourceTextHash } from './hyde.documents.js';\nimport { getHydeGenerationMode, HYDE_FRAME_GENERATION_VERSION, type HydeGenerationMode } from './hyde.env.js';\nimport { sanitizeHydeSourceFrame, type HydeSourceFrame } from './hyde.frame.js';\nimport type { HydeGenerateInput, HydeGeneratorOutput } from './hyde.generator.js';\nimport { HydeGraphState, type HydeDocumentState } from './hyde.state.js';\nimport type { LensInferenceInput, LensInferenceOutput } from './lens.inferrer.js';\nimport { HYDE_DEFAULT_CACHE_TTL } from './hyde.strategies.js';\nimport { HydeValidator, type HydeValidationInput, type HydeValidationOutput, type HydeValidationVerdict } from './hyde.validator.js';\n\nconst logger = protocolLogger(\"HyDEGraphFactory\");\nlet lastGenerationTimestamp = 0;\n\nfunction nextGenerationMarker(): string {\n lastGenerationTimestamp = Math.max(Date.now(), lastGenerationTimestamp + 1);\n return new Date(lastGenerationTimestamp).toISOString();\n}\n\n/** Narrow lens inferrer contract accepted by the graph. */\nexport interface HydeLensInferrerLike {\n infer(input: LensInferenceInput): Promise<LensInferenceOutput>;\n}\n\n/** Narrow document generator contract accepted by the graph. */\nexport interface HydeGeneratorLike {\n generate(input: HydeGenerateInput): Promise<HydeGeneratorOutput>;\n}\n\n/** Narrow batch validator contract accepted by the graph. */\nexport interface HydeValidatorLike {\n validate(input: HydeValidationInput): Promise<HydeValidationOutput>;\n}\n\nexport interface HydeGraphOptions {\n /** Test override. Production derives the mode from HYDE_FRAME_CONSTRAINTS_ENABLED. */\n mode?: HydeGenerationMode;\n validator?: HydeValidatorLike;\n}\n\n/** Hash a lens label (+ optional corpus) to a short key for cache/DB indexing. */\nfunction lensHash(label: string, corpus?: string): string {\n const input = corpus\n ? `${label.toLowerCase().trim()}:${corpus}`\n : label.toLowerCase().trim();\n return createHash('sha256').update(input).digest('hex').slice(0, 16);\n}\n\nfunction entityCacheKey(sourceId: string | undefined, sourceText: string): string {\n return sourceId ?? `q:${createHash('sha256').update(sourceText).digest('hex').slice(0, 16)}`;\n}\n\nfunction sortedFrame(frame: HydeSourceFrame): HydeSourceFrame {\n const sort = <T>(items: T[]): T[] => [...items].sort((left, right) => {\n const leftJson = JSON.stringify(left);\n const rightJson = JSON.stringify(right);\n return leftJson < rightJson ? -1 : leftJson > rightJson ? 1 : 0;\n });\n return {\n sourceRoles: sort(frame.sourceRoles),\n counterpartRoles: sort(frame.counterpartRoles),\n hardConstraints: sort(frame.hardConstraints),\n namedEntities: sort(frame.namedEntities),\n domainVocabulary: sort(frame.domainVocabulary),\n };\n}\n\n/** Deterministic identity for the source content and sanitized frame. */\nfunction computeHydeFrameFingerprint(sourceText: string, sourceFrame: HydeSourceFrame): string {\n return createHash('sha256')\n .update(sourceText)\n .update('\\0')\n .update(JSON.stringify(sortedFrame(sourceFrame)))\n .digest('hex');\n}\n\nfunction requireFrameFingerprint(frameFingerprint: string | undefined): string {\n if (!frameFingerprint) throw new Error('frame-v1 HyDE requires a frame fingerprint');\n return frameFingerprint;\n}\n\n/** Preserve the exact legacy Redis key and isolate frame-v1 data by namespace. */\nfunction cacheKey(\n mode: HydeGenerationMode,\n sourceType: string,\n sourceId: string | undefined,\n sourceText: string,\n lens: string,\n corpus?: string,\n frameFingerprint?: string,\n): string {\n const entityKey = entityCacheKey(sourceId, sourceText);\n if (mode === 'legacy') return `hyde:${sourceType}:${entityKey}:${lensHash(lens, corpus)}`;\n return `hyde:${HYDE_FRAME_GENERATION_VERSION}:${sourceType}:${entityKey}:${requireFrameFingerprint(frameFingerprint)}:${lensHash(lens, corpus)}`;\n}\n\n/** Preserve legacy identity and use a stable frame-v1 identity per lens/corpus. */\nfunction dbStrategy(mode: HydeGenerationMode, label: string, corpus?: string): string {\n const hash = lensHash(label, corpus);\n return mode === 'legacy' ? hash : `${HYDE_FRAME_GENERATION_VERSION}:${hash}`;\n}\n\nfunction isValidGenerationMarker(value: unknown): value is string {\n return typeof value === 'string' && Number.isFinite(Date.parse(value));\n}\n\nfunction isFrameCacheDocument(\n doc: HydeDocumentState,\n lensLabel: string,\n frameFingerprint: string,\n sourceTextHash: string,\n): boolean {\n return doc.hydeGenerationVersion === HYDE_FRAME_GENERATION_VERSION\n && doc.validationStatus === 'valid'\n && doc.lens === lensLabel\n && doc.frameFingerprint === frameFingerprint\n && doc.sourceTextHash === sourceTextHash\n && isValidGenerationMarker(doc.generatedAt);\n}\n\ninterface FrameDbContext extends Record<string, unknown> {\n hydeGenerationVersion: typeof HYDE_FRAME_GENERATION_VERSION;\n lensLabel: string;\n validationStatus: 'valid';\n frameFingerprint: string;\n sourceTextHash: string;\n generatedAt: string;\n}\n\nfunction isFrameDbContext(\n context: Record<string, unknown> | null,\n lensLabel: string,\n frameFingerprint: string,\n sourceTextHash: string,\n): context is FrameDbContext {\n return context?.hydeGenerationVersion === HYDE_FRAME_GENERATION_VERSION\n && context.lensLabel === lensLabel\n && context.validationStatus === 'valid'\n && context.frameFingerprint === frameFingerprint\n && context.sourceTextHash === sourceTextHash\n && isValidGenerationMarker(context.generatedAt);\n}\n\nfunction emptyFrame(): HydeSourceFrame {\n return {\n sourceRoles: [],\n counterpartRoles: [],\n hardConstraints: [],\n namedEntities: [],\n domainVocabulary: [],\n };\n}\n\nfunction opaqueDocumentKey(doc: HydeDocumentState): string {\n return `d-${createHash('sha256')\n .update(`${doc.lens}\\0${doc.targetCorpus}\\0${doc.hydeText}`)\n .digest('hex')\n .slice(0, 16)}`;\n}\n\nfunction isRuntimeVerdict(value: unknown): value is HydeValidationVerdict {\n if (!value || typeof value !== 'object') return false;\n const verdict = value as Partial<HydeValidationVerdict>;\n return typeof verdict.key === 'string'\n && typeof verdict.valid === 'boolean'\n && Array.isArray(verdict.unsupportedNamedEntities)\n && verdict.unsupportedNamedEntities.every((item) => typeof item === 'string')\n && Array.isArray(verdict.unsupportedHardConstraints)\n && verdict.unsupportedHardConstraints.every((item) => typeof item === 'string')\n && typeof verdict.reasoning === 'string';\n}\n\n/** Factory for the HyDE generation graph. Existing five-argument calls remain valid. */\nexport class HydeGraphFactory {\n constructor(\n private database: HydeGraphDatabase,\n private embedder: EmbeddingGenerator,\n private cache: HydeCache,\n private inferrer: HydeLensInferrerLike,\n private generator: HydeGeneratorLike,\n private options: HydeGraphOptions = {},\n ) {}\n\n createGraph() {\n const self = this;\n const mode = this.options.mode ?? getHydeGenerationMode();\n const validator = mode === HYDE_FRAME_GENERATION_VERSION\n ? (this.options.validator ?? new HydeValidator())\n : undefined;\n\n /** Node 1: Infer lenses from source text + optional profile context. */\n const inferLensesNode = async (state: typeof HydeGraphState.State) => {\n return timed(\"HydeGraph.inferLenses\", async () => {\n const { sourceText, profileContext, maxLenses } = state;\n const agentTimingsAccum: DebugMetaAgent[] = [];\n\n try {\n const traceEmitter = requestContext.getStore()?.traceEmitter;\n const inferrerStart = Date.now();\n traceEmitter?.({ type: \"agent_start\", name: \"lens-inferrer\" });\n const result = await self.inferrer.infer({\n sourceText,\n profileContext,\n maxLenses,\n ...(mode === HYDE_FRAME_GENERATION_VERSION ? { frameConstrained: true } : {}),\n });\n const durationMs = Date.now() - inferrerStart;\n agentTimingsAccum.push({ name: 'lens.inferrer', durationMs });\n traceEmitter?.({ type: \"agent_end\", name: \"lens-inferrer\", durationMs, summary: result.lenses.length > 0 ? `Inferred ${result.lenses.length} lens(es)` : \"lens-inferrer completed\" });\n\n if (mode === HYDE_FRAME_GENERATION_VERSION) {\n const sourceFrame = sanitizeHydeSourceFrame(sourceText, result.sourceFrame ?? emptyFrame());\n return {\n lenses: result.lenses,\n sourceFrame,\n frameFingerprint: computeHydeFrameFingerprint(sourceText, sourceFrame),\n sourceTextHash: computeHydeSourceTextHash(sourceText),\n generatedAt: nextGenerationMarker(),\n agentTimings: agentTimingsAccum,\n };\n }\n\n return { lenses: result.lenses, agentTimings: agentTimingsAccum };\n } catch (error) {\n logger.error('Lens inference failed in graph node', { error });\n if (mode === HYDE_FRAME_GENERATION_VERSION) {\n const sourceFrame = emptyFrame();\n return {\n lenses: [],\n sourceFrame,\n frameFingerprint: computeHydeFrameFingerprint(sourceText, sourceFrame),\n sourceTextHash: computeHydeSourceTextHash(sourceText),\n generatedAt: nextGenerationMarker(),\n agentTimings: agentTimingsAccum,\n };\n }\n return { lenses: [], agentTimings: agentTimingsAccum };\n }\n });\n };\n\n /** Node 2: Check the mode-isolated cache/DB for matching documents. */\n const checkCacheNode = async (state: typeof HydeGraphState.State) => {\n return timed(\"HydeGraph.checkCache\", async () => {\n const { sourceType, sourceId, sourceText, lenses, forceRegenerate } = state;\n\n if (forceRegenerate) return { hydeDocuments: {} };\n\n const frameFingerprint = mode === HYDE_FRAME_GENERATION_VERSION\n ? requireFrameFingerprint(state.frameFingerprint)\n : undefined;\n const sourceTextHash = mode === HYDE_FRAME_GENERATION_VERSION\n ? state.sourceTextHash ?? computeHydeSourceTextHash(sourceText)\n : undefined;\n const cached: Record<string, HydeDocumentState> = {};\n for (const lens of lenses) {\n const key = cacheKey(\n mode,\n sourceType,\n sourceId ?? undefined,\n sourceText,\n lens.label,\n lens.corpus,\n frameFingerprint,\n );\n const fromCache = await self.cache.get<HydeDocumentState>(key);\n const cacheAccepted = fromCache?.hydeText\n && fromCache.hydeEmbedding?.length\n && (mode === 'legacy' || isFrameCacheDocument(fromCache, lens.label, frameFingerprint!, sourceTextHash!));\n if (cacheAccepted && fromCache) {\n cached[lens.label] = {\n ...fromCache,\n ...(mode === HYDE_FRAME_GENERATION_VERSION ? { origin: 'cache' as const } : {}),\n };\n continue;\n }\n\n if (sourceId) {\n const fromDb = await self.database.getHydeDocument(\n sourceType,\n sourceId,\n dbStrategy(mode, lens.label, lens.corpus),\n );\n const frameDbContext = mode === HYDE_FRAME_GENERATION_VERSION && fromDb\n ? fromDb.context\n : null;\n if (fromDb && (mode === 'legacy' || isFrameDbContext(frameDbContext, lens.label, frameFingerprint!, sourceTextHash!))) {\n cached[lens.label] = {\n lens: lens.label,\n targetCorpus: fromDb.targetCorpus as HydeDocumentState['targetCorpus'],\n hydeText: fromDb.hydeText,\n hydeEmbedding: fromDb.hydeEmbedding,\n ...(mode === HYDE_FRAME_GENERATION_VERSION\n ? {\n origin: 'db' as const,\n validationStatus: 'valid' as const,\n hydeGenerationVersion: HYDE_FRAME_GENERATION_VERSION,\n frameFingerprint,\n sourceTextHash,\n generatedAt: (frameDbContext as FrameDbContext).generatedAt,\n }\n : {}),\n };\n }\n }\n }\n\n if (mode === HYDE_FRAME_GENERATION_VERSION) {\n const newestTimestamp = Math.max(\n ...Object.values(cached).map((doc) => Date.parse(doc.generatedAt ?? '')),\n );\n if (Number.isFinite(newestTimestamp)) {\n return {\n hydeDocuments: Object.fromEntries(Object.entries(cached).filter(([, doc]) =>\n Date.parse(doc.generatedAt ?? '') === newestTimestamp)),\n };\n }\n }\n\n return { hydeDocuments: cached };\n });\n };\n\n const shouldGenerate = (state: typeof HydeGraphState.State): string =>\n state.lenses.some((lens) => !state.hydeDocuments[lens.label]) ? 'generate' : 'skip';\n\n /** Node 3: Generate all missing documents and return a complete snapshot. */\n const generateMissingNode = async (state: typeof HydeGraphState.State) => {\n return timed(\"HydeGraph.generateMissing\", async () => {\n const { sourceText, sourceFrame, lenses, hydeDocuments } = state;\n const missing = lenses.filter((lens) => !hydeDocuments[lens.label]);\n const agentTimingsAccum: DebugMetaAgent[] = [];\n const generated: Record<string, HydeDocumentState> = {};\n const sourceTextHash = mode === HYDE_FRAME_GENERATION_VERSION\n ? state.sourceTextHash ?? computeHydeSourceTextHash(sourceText)\n : undefined;\n const generatedAt = mode === HYDE_FRAME_GENERATION_VERSION\n ? state.generatedAt ?? nextGenerationMarker()\n : undefined;\n\n await Promise.all(missing.map(async (lens) => {\n const traceEmitter = requestContext.getStore()?.traceEmitter;\n const generatorStart = Date.now();\n traceEmitter?.({ type: \"agent_start\", name: \"hyde-generator\" });\n const out = await self.generator.generate({\n sourceText,\n lens: lens.label,\n corpus: lens.corpus,\n ...(mode === HYDE_FRAME_GENERATION_VERSION && sourceFrame ? { sourceFrame } : {}),\n });\n const durationMs = Date.now() - generatorStart;\n agentTimingsAccum.push({ name: 'hyde.generator', durationMs });\n traceEmitter?.({ type: \"agent_end\", name: \"hyde-generator\", durationMs, summary: `Generated: ${lens.label}` });\n generated[lens.label] = {\n lens: lens.label,\n targetCorpus: lens.corpus,\n hydeText: out.text,\n hydeEmbedding: [],\n ...(mode === HYDE_FRAME_GENERATION_VERSION\n ? {\n origin: 'generated' as const,\n frameFingerprint: requireFrameFingerprint(state.frameFingerprint),\n sourceTextHash,\n generatedAt,\n }\n : {}),\n };\n }));\n\n const retained = mode === HYDE_FRAME_GENERATION_VERSION\n ? Object.fromEntries(Object.entries(hydeDocuments).map(([label, doc]) => [\n label,\n {\n ...doc,\n frameFingerprint: requireFrameFingerprint(state.frameFingerprint),\n sourceTextHash,\n generatedAt,\n },\n ]))\n : hydeDocuments;\n\n return { hydeDocuments: { ...retained, ...generated }, agentTimings: agentTimingsAccum };\n });\n };\n\n /** Frame-v1 only: validate newly generated docs in one batch. */\n const validateGeneratedNode = async (state: typeof HydeGraphState.State) => {\n return timed(\"HydeGraph.validateGenerated\", async () => {\n const generated = Object.values(state.hydeDocuments).filter((doc) => doc.origin === 'generated');\n if (generated.length === 0 || !validator) return { hydeDocuments: state.hydeDocuments };\n\n const frame = sanitizeHydeSourceFrame(state.sourceText, state.sourceFrame ?? emptyFrame());\n const documents: HydeValidationInput['documents'] = {};\n const lensByDocumentKey = new Map<string, string>();\n for (const doc of generated) {\n const key = opaqueDocumentKey(doc);\n documents[key] = { corpus: doc.targetCorpus, text: doc.hydeText };\n lensByDocumentKey.set(key, doc.lens);\n }\n\n const updated = { ...state.hydeDocuments };\n const agentTimingsAccum: DebugMetaAgent[] = [];\n const traceEmitter = requestContext.getStore()?.traceEmitter;\n const validatorStart = Date.now();\n let validCount = 0;\n let rejectedCount = 0;\n let failedOpenCount = 0;\n traceEmitter?.({ type: 'agent_start', name: 'hyde-validator' });\n\n try {\n const output = await validator.validate({\n sourceText: state.sourceText,\n sourceFrame: frame,\n documents,\n });\n const rawVerdicts: unknown[] = Array.isArray((output as { verdicts?: unknown }).verdicts)\n ? (output as { verdicts: unknown[] }).verdicts\n : [];\n\n for (const key of Object.keys(documents)) {\n const lensLabel = lensByDocumentKey.get(key);\n if (!lensLabel) continue;\n const matching = rawVerdicts.filter((value) =>\n !!value && typeof value === 'object' && (value as { key?: unknown }).key === key);\n const doc = updated[lensLabel];\n if (!doc) continue;\n\n if (matching.length !== 1 || !isRuntimeVerdict(matching[0])) {\n failedOpenCount += 1;\n updated[lensLabel] = { ...doc, validationStatus: 'failed_open', hydeGenerationVersion: HYDE_FRAME_GENERATION_VERSION };\n continue;\n }\n\n const verdict = matching[0];\n const hasUnsupportedGrounding = verdict.unsupportedNamedEntities.length > 0\n || verdict.unsupportedHardConstraints.length > 0;\n const contradictory = verdict.valid === hasUnsupportedGrounding;\n if (contradictory) {\n failedOpenCount += 1;\n updated[lensLabel] = { ...doc, validationStatus: 'failed_open', hydeGenerationVersion: HYDE_FRAME_GENERATION_VERSION };\n } else if (!verdict.valid) {\n rejectedCount += 1;\n delete updated[lensLabel];\n } else {\n validCount += 1;\n updated[lensLabel] = { ...doc, validationStatus: 'valid', hydeGenerationVersion: HYDE_FRAME_GENERATION_VERSION };\n }\n }\n } catch (error) {\n logger.error('HyDE validation failed open', { error });\n validCount = 0;\n rejectedCount = 0;\n failedOpenCount = generated.length;\n for (const doc of generated) {\n updated[doc.lens] = { ...doc, validationStatus: 'failed_open', hydeGenerationVersion: HYDE_FRAME_GENERATION_VERSION };\n }\n } finally {\n const durationMs = Date.now() - validatorStart;\n agentTimingsAccum.push({ name: 'hyde.validator', durationMs });\n traceEmitter?.({\n type: 'agent_end',\n name: 'hyde-validator',\n durationMs,\n summary: `${validCount} valid, ${rejectedCount} rejected, ${failedOpenCount} failed open`,\n });\n }\n\n return { hydeDocuments: updated, agentTimings: agentTimingsAccum };\n });\n };\n\n /** Embed all accepted/cached documents that do not have embeddings. */\n const embedNode = async (state: typeof HydeGraphState.State) => {\n return timed(\"HydeGraph.embed\", async () => {\n const toEmbed: { label: string; doc: HydeDocumentState }[] = [];\n const updated: Record<string, HydeDocumentState> = {};\n const hydeEmbeddings: Record<string, number[]> = {};\n\n for (const [label, doc] of Object.entries(state.hydeDocuments)) {\n if (doc.hydeEmbedding?.length) {\n updated[label] = doc;\n hydeEmbeddings[label] = doc.hydeEmbedding;\n } else {\n toEmbed.push({ label, doc });\n }\n }\n\n if (toEmbed.length > 0) {\n const embeddings = await self.embedder.generate(\n toEmbed.map((item) => item.doc.hydeText),\n undefined,\n getAbortSignalConfig(),\n );\n const embeddingArray = Array.isArray(embeddings[0]) ? embeddings as number[][] : [embeddings as number[]];\n for (let i = 0; i < toEmbed.length; i++) {\n const { label, doc } = toEmbed[i];\n const embedding = embeddingArray[i] ?? [];\n updated[label] = { ...doc, hydeEmbedding: embedding };\n hydeEmbeddings[label] = embedding;\n }\n }\n\n return { hydeDocuments: updated, hydeEmbeddings };\n });\n };\n\n /** Cache/persist only legacy docs or successfully validated frame-v1 docs. */\n const cacheResultsNode = async (state: typeof HydeGraphState.State) => {\n return timed(\"HydeGraph.cacheResults\", async () => {\n const { sourceType, sourceId, sourceText, hydeDocuments } = state;\n const frameFingerprint = mode === HYDE_FRAME_GENERATION_VERSION\n ? requireFrameFingerprint(state.frameFingerprint)\n : undefined;\n const sourceTextHash = mode === HYDE_FRAME_GENERATION_VERSION\n ? state.sourceTextHash ?? computeHydeSourceTextHash(sourceText)\n : undefined;\n for (const [label, doc] of Object.entries(hydeDocuments)) {\n if (mode === HYDE_FRAME_GENERATION_VERSION\n && !isFrameCacheDocument(doc, label, frameFingerprint!, sourceTextHash!)) continue;\n\n const key = cacheKey(\n mode,\n sourceType,\n sourceId ?? undefined,\n sourceText,\n label,\n doc.targetCorpus,\n frameFingerprint,\n );\n await self.cache.set(key, doc, { ttl: HYDE_DEFAULT_CACHE_TTL });\n\n if (sourceId) {\n await self.database.saveHydeDocument({\n sourceType,\n sourceId,\n strategy: dbStrategy(mode, label, doc.targetCorpus),\n targetCorpus: doc.targetCorpus,\n hydeText: doc.hydeText,\n hydeEmbedding: doc.hydeEmbedding,\n ...(mode === HYDE_FRAME_GENERATION_VERSION ? {\n context: {\n hydeGenerationVersion: HYDE_FRAME_GENERATION_VERSION,\n lensLabel: label,\n validationStatus: 'valid',\n frameFingerprint: doc.frameFingerprint,\n sourceTextHash: doc.sourceTextHash,\n generatedAt: doc.generatedAt,\n },\n } : {}),\n });\n }\n }\n return {};\n });\n };\n\n const workflow = new StateGraph(HydeGraphState)\n .addNode('infer_lenses', inferLensesNode)\n .addNode('check_cache', checkCacheNode)\n .addNode('generate_missing', generateMissingNode)\n .addNode('embed', embedNode)\n .addNode('cache_results', cacheResultsNode)\n .addEdge(START, 'infer_lenses')\n .addEdge('infer_lenses', 'check_cache')\n .addConditionalEdges('check_cache', shouldGenerate, {\n generate: 'generate_missing',\n skip: 'embed',\n });\n\n if (mode === HYDE_FRAME_GENERATION_VERSION) {\n workflow\n .addNode('validate_generated', validateGeneratedNode)\n .addEdge('generate_missing', 'validate_generated')\n .addEdge('validate_generated', 'embed');\n } else {\n workflow.addEdge('generate_missing', 'embed');\n }\n\n workflow\n .addEdge('embed', 'cache_results')\n .addEdge('cache_results', END);\n\n return workflow.compile();\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hyde.state.d.ts","sourceRoot":"/","sources":["shared/hyde/h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E,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,IAAI;QACrC,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS;KACzB,CAAC;IAEF,sEAAsE;IACtE,YAAY,EAAE,UAAU,CAAmB;QACzC,OAAO,EAAE,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC,GAAG,GAAG,EAAE,GAAG,GAAG,CAAC;QACvC,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE;KAClB,CAAC;CACH,CAAC,CAAC","sourcesContent":["/**\n * HyDE Graph state: cache-aware hypothetical document generation.\n * Used by the HyDE graph for infer_lenses → check_cache → generate_missing → embed → cache_results.\n */\n\nimport { Annotation } from '@langchain/langgraph';\nimport type { Id } from '../interfaces/database.interface.js';\nimport type { Lens, HydeTargetCorpus } from './lens.inferrer.js';\nimport type { HydeSourceFrame } from './hyde.frame.js';\nimport type { DebugMetaAgent } from '../../chat/chat-streaming.types.js';\n\nexport type HydeDocumentOrigin = 'cache' | 'db' | 'generated';\nexport type HydeValidationStatus = 'valid' | 'invalid' | 'failed_open';\n\n/** Single HyDE document (text + embedding) for one lens. */\nexport interface HydeDocumentState {\n lens: string;\n targetCorpus: HydeTargetCorpus;\n hydeText: string;\n hydeEmbedding: number[];\n origin?: HydeDocumentOrigin;\n validationStatus?: HydeValidationStatus;\n hydeGenerationVersion?: 'frame-v1';\n frameFingerprint?: string;\n sourceTextHash?: string;\n generatedAt?: string;\n}\n\n/** State for the HyDE generation graph. */\nexport const HydeGraphState = Annotation.Root({\n // ─── Inputs ─────────────────────────────────────────────────────────────\n\n /** Source type: intent, profile, user context, or ad-hoc query. */\n sourceType: Annotation<'intent' | 'query' | 'context'>,\n\n /** Source entity ID (e.g. intent ID, user ID). Omitted for ad-hoc query. */\n sourceId: Annotation<Id<'intents'> | Id<'users'> | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n /** Source text to generate HyDE from (intent payload, profile summary, or query). */\n sourceText: Annotation<string>,\n\n /** Optional profile context for lens inference (user's profile summary). */\n profileContext: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n /** Maximum number of lenses to infer (default 3). */\n maxLenses: Annotation<number>({\n reducer: (curr, next) => next ?? curr,\n default: () => 3,\n }),\n\n /** When true, skip cache/DB and regenerate all lenses. */\n forceRegenerate: Annotation<boolean>({\n reducer: (curr, next) => next ?? curr,\n default: () => false,\n }),\n\n // ─── Intermediate / output ─────────────────────────────────────────────\n\n /** Inferred lenses from the LensInferrer agent. */\n lenses: Annotation<Lens[]>({\n reducer: (curr, next) => next ?? curr,\n default: () => [],\n }),\n\n /** Sanitized source-grounded frame produced by frame-v1 inference. */\n sourceFrame: Annotation<HydeSourceFrame | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n /** Exact sourceText + sanitized sourceFrame identity for frame-v1 reuse. */\n frameFingerprint: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n /** Hash of the exact source text for persisted frame-v1 freshness checks. */\n sourceTextHash: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n /** Shared cohort marker assigned when this run generates any missing document. */\n generatedAt: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n /**\n * Complete HyDE document snapshot keyed by lens label. Writers replace the\n * snapshot so rejected documents can be removed before embedding.\n */\n hydeDocuments: Annotation<Record<string, HydeDocumentState>>({\n reducer: (curr, next) => next ?? curr,\n default: () => ({}),\n }),\n\n /**\n * Final embeddings per lens (convenience output for search).\n * Populated by embed node; used by opportunity graph.\n */\n hydeEmbeddings: Annotation<Record<string, number[]>>({\n reducer: (curr, next) => (next ? { ...curr, ...next } : curr),\n default: () => ({}),\n }),\n\n /** Non-fatal error message. */\n error: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n /** Timing records for each agent invocation within this graph run. */\n agentTimings: Annotation<DebugMetaAgent[]>({\n reducer: (acc, val) => [...acc, ...val],\n default: () => [],\n }),\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hyde.strategies.d.ts","sourceRoot":"/","sources":["shared/hyde/hyde.strategies.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,YAAY,EAAE,IAAI,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAE1G,+DAA+D;AAC/D,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAE3C;;;GAGG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,gBAAgB,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,MAAM,CAmBtG,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hyde.strategies.js","sourceRoot":"/","sources":["shared/hyde/hyde.strategies.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAMH,+DAA+D;AAC/D,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAE3C;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAA2E;IACzG,QAAQ,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC;+EAC6C,UAAU;0EACf,IAAI;;;GAG3E;IACD,OAAO,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC;+DAC8B,IAAI;6CACtB,UAAU;;;GAGpD;IACD,QAAQ,EAAE,CAAC,UAAU,EAAE,IAAI,EAAE,EAAE,CAAC;oGACkE,UAAU;0CACpE,IAAI;;;GAG3C;CACF,CAAC","sourcesContent":["/**\n * HyDE (Hypothetical Document Embeddings) type definitions.\n *\n * The system is now role-agnostic: instead of hardcoded strategy names\n * (mirror, reciprocal, mentor, investor, collaborator, hiree), an LLM\n * infers free-text \"lenses\" dynamically. This file re-exports the lens\n * types and provides constants for the HyDE pipeline.\n */\n\nimport type { HydeTargetCorpus } from './lens.inferrer.js';\n\nexport type { Lens, HydeTargetCorpus, LensInferenceInput, LensInferenceOutput } from './lens.inferrer.js';\n\n/** Default cache TTL for ephemeral HyDE documents (1 hour). */\nexport const HYDE_DEFAULT_CACHE_TTL = 3600;\n\n/**\n * Prompt templates for HyDE document generation.\n * Keyed by target corpus — the lens label provides the semantic specificity.\n */\nexport const HYDE_CORPUS_PROMPTS: Record<HydeTargetCorpus, (sourceText: string, lens: string) => string> = {\n profiles: (sourceText, lens) => `\n Write a professional biography for someone who could fulfill this need: \"${sourceText}\".\n Focus on the specific expertise, background, and role described by: ${lens}.\n\n Write in first person. Include concrete skills, domain experience, and current professional focus that would make them a strong match.\n `,\n intents: (sourceText, lens) => `\n Write a goal or aspiration statement for someone who is: ${lens}.\n This person's needs would complement: \"${sourceText}\".\n\n Write in first person as if stating their own goal.\n `,\n premises: (sourceText, lens) => `\n Write a short self-description for someone whose identity, values, or worldview aligns with: \"${sourceText}\".\n Reflect the character described by: ${lens}.\n\n Write in first person as a stable statement of who this person is, not what they want.\n `,\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hyde.validator.d.ts","sourceRoot":"/","sources":["shared/hyde/hyde.validator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAEnF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAE3D,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,gBAAgB,CAAC;IACzB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,mBAAmB;I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KAAK,CAAC;IACpB,CAAC;IAED,qEAAqE;IACrE,KAAK,CAAC,QAAQ,CAAC,KAA0B;QACvC,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE;YAC1D,IAAI,aAAa,CAAC,uBAAuB,CAAC;YAC1C,IAAI,YAAY,CAAC,yBAAyB,CAAC,KAAK,CAAC,CAAC;SACnD,CAAC,CAAC;QACH,OAAO,4BAA4B,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IACpD,CAAC;CACF","sourcesContent":["import type { BaseLanguageModelInput } from '@langchain/core/language_models/base';\nimport { HumanMessage, SystemMessage } from '@langchain/core/messages';\nimport { z } from 'zod';\n\nimport { createStructuredModel } from '../agent/model.config.js';\nimport { invokeWithAbortSignal } from '../agent/model-signal.js';\nimport type { HydeSourceFrame } from './hyde.frame.js';\nimport type { HydeTargetCorpus } from './lens.inferrer.js';\n\nexport interface HydeValidationDocument {\n corpus: HydeTargetCorpus;\n text: string;\n}\n\nexport interface HydeValidationInput {\n sourceText: string;\n sourceFrame: HydeSourceFrame;\n /** Generated documents keyed by opaque caller-supplied identifiers. */\n documents: Record<string, HydeValidationDocument>;\n}\n\nexport interface HydeValidationVerdict {\n key: string;\n valid: boolean;\n unsupportedNamedEntities: string[];\n unsupportedHardConstraints: string[];\n reasoning: string;\n}\n\nexport interface HydeValidationOutput {\n verdicts: HydeValidationVerdict[];\n}\n\n/** Structured-output schema for a single batch validation response. */\nexport const HydeValidationResponseSchema = z.object({\n verdicts: z.array(z.object({\n key: z.string().min(1),\n valid: z.boolean(),\n unsupportedNamedEntities: z.array(z.string()),\n unsupportedHardConstraints: z.array(z.string()),\n reasoning: z.string().min(1).describe('Concise explanation of the verdict'),\n })),\n});\n\nconst VALIDATOR_SYSTEM_PROMPT = `You validate hypothetical retrieval documents against a sanitized source-grounded frame.\n\nA document is invalid only when it invents unsupported proper nouns/named entities or unsupported HARD constraints (location, time, numeric, credential, organization, or exclusivity constraints).\n\nExplicitly allowed and not grounds for rejection:\n- first-person target voice;\n- generic role or domain elaboration;\n- reciprocal or complementary inversion of source and target roles.\n\nReturn exactly one verdict for each opaque key. Copy each key exactly. Mark valid=false when either unsupported list is non-empty. Keep reasoning concise.`;\n\n/** Build a profile-free batch validation prompt. */\nexport function buildHydeValidationPrompt(input: HydeValidationInput): string {\n return `Source text:\\n${input.sourceText}\\n\\nSanitized source frame:\\n${JSON.stringify(input.sourceFrame)}\\n\\nGenerated documents:\\n${JSON.stringify(input.documents)}`;\n}\n\n/** Minimal structured model contract used for deterministic injection in tests. */\nexport interface HydeValidatorStructuredModel {\n invoke(input: BaseLanguageModelInput, config?: { signal?: AbortSignal }): Promise<unknown>;\n}\n\n/** Production structured-model batch validator for frame-v1 HyDE documents. */\nexport class HydeValidator {\n private model?: HydeValidatorStructuredModel;\n\n constructor(model?: HydeValidatorStructuredModel) {\n this.model = model;\n }\n\n private getModel(): HydeValidatorStructuredModel {\n this.model ??= createStructuredModel('hydeValidator', HydeValidationResponseSchema, {\n name: 'hyde_validator',\n });\n return this.model;\n }\n\n /** Validate all generated documents in one structured-model call. */\n async validate(input: HydeValidationInput): Promise<HydeValidationOutput> {\n const result = await invokeWithAbortSignal(this.getModel(), [\n new SystemMessage(VALIDATOR_SYSTEM_PROMPT),\n new HumanMessage(buildHydeValidationPrompt(input)),\n ]);\n return HydeValidationResponseSchema.parse(result);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"lens.inferrer.d.ts","sourceRoot":"/","sources":["shared/hyde/lens.inferrer.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,sCAAsC,CAAC;AAEnF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,OAAO,EAAkD,KAAK,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEvG,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,SAA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C,EAAE,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;QAE9E,IAAI,WAAW,CAAC,MAAM,KAAK,UAAU,EAAE,CAAC;YACtC,MAAM,CAAC,KAAK,CAAC,gCAAgC,EAAE,EAAE,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC,CAAC;YAC9E,OAAO;gBACL,MAAM;gBACN,WAAW,EAAE;oBACX,WAAW,EAAE,EAAE;oBACf,gBAAgB,EAAE,EAAE;oBACpB,eAAe,EAAE,EAAE;oBACnB,aAAa,EAAE,EAAE;oBACjB,gBAAgB,EAAE,EAAE;iBACrB;aACF,CAAC;QACJ,CAAC;QAED,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,WAAW,CAAC,KAAK,EAAE,CAAC;IACpD,CAAC;CACF;AA9EO;IADL,KAAK,EAAE;;;;yCA8EP","sourcesContent":["/**\n * Lens Inferrer Agent: analyzes source text (intent or query) with optional\n * profile context and infers 1-N search lenses, each tagged with a target corpus.\n * Replaces the hardcoded HydeStrategy enum and regex-based selectStrategiesFromQuery.\n */\nimport type { BaseLanguageModelInput } from '@langchain/core/language_models/base';\nimport { HumanMessage, SystemMessage } from '@langchain/core/messages';\nimport { z } from 'zod';\n\nimport { createStructuredModel } from \"../agent/model.config.js\";\nimport { invokeWithAbortSignal } from \"../agent/model-signal.js\";\nimport { protocolLogger } from '../observability/protocol.logger.js';\nimport { Timed } from \"../observability/performance.js\";\nimport { HydeSourceFrameSchema, sanitizeHydeSourceFrame, type HydeSourceFrame } from './hyde.frame.js';\n\nexport type HydeTargetCorpus = 'profiles' | 'intents' | 'premises';\n\n/** A single inferred lens — a search perspective the LLM decided is relevant. */\nexport interface Lens {\n /** Free-text description (e.g. \"crypto infrastructure VC\"). */\n label: string;\n /** Which vector index to search: user profiles or user intents. */\n corpus: HydeTargetCorpus;\n /** Why this perspective is relevant (for logging/trace). */\n reasoning: string;\n}\n\nexport interface LensInferenceInput {\n /** Intent payload or search query. */\n sourceText: string;\n /** User's profile summary for domain context (optional). */\n profileContext?: string;\n /** Maximum number of lenses to infer (default 3). */\n maxLenses?: number;\n /** Use the source-grounded frame-v1 inference path. */\n frameConstrained?: boolean;\n}\n\nexport interface LensInferenceOutput {\n lenses: Lens[];\n /** Sanitized source frame, present only for frame-constrained inference. */\n sourceFrame?: HydeSourceFrame;\n}\n\nconst SYSTEM_PROMPT = `You analyze goals and search queries to identify the most relevant perspectives for finding matching people in a professional network.\n\nFor each perspective you identify, specify:\n1. A clear, specific description of who or what to search for\n2. Whether to search \"profiles\" (user bios, expertise, backgrounds), \"intents\" (stated goals, needs, aspirations), or \"premises\" (identity assertions, values, worldview)\n3. A brief reason why this perspective is relevant\n\nGuidelines:\n- Be specific and domain-aware. \"early-stage crypto infrastructure investor\" is better than \"investor\".\n- Consider both sides: who can help the person AND whose goals complement theirs.\n- When user context is provided, tailor perspectives to their domain (e.g. a DePIN founder searching for \"investors\" needs crypto-native infra investors specifically).\n- Generate only perspectives that add distinct search value — don't repeat similar angles.\n- Use \"profiles\" when looking for a type of person (expert, advisor, leader). Use \"intents\" when looking for a complementary goal or need (someone raising, someone hiring, someone seeking collaboration). Use \"premises\" when looking for someone whose identity, values, or worldview aligns — stable traits rather than transient goals.\n- Always include at least one \"profiles\" perspective when the source describes a need that a specific type of professional could fulfill. Most intents benefit from profile-based discovery.\n- LOCATION AWARENESS: When the source text or user context mentions a specific location (city, region, country), incorporate it into lens descriptions. For example, \"investors in San Francisco\" should produce a lens like \"SF-based early-stage investor\" rather than just \"early-stage investor\". This helps the hypothetical document generator produce location-specific search documents, improving retrieval quality.`;\n\n/** Source-grounded system prompt used only by frame extraction. */\nexport const FRAME_SYSTEM_PROMPT = `You extract a source-grounded frame for semantic retrieval from sourceText alone.\n\nSource-frame rules:\n- Extract evidence ONLY from sourceText.\n- Every frame element must include an evidence field copied as an exact substring of sourceText.\n- sourceRoles describe roles held or offered by the source side.\n- sourceRoles and counterpartRoles MUST use generic lower-case role labels only (for example, \"founder\", \"investor\", or \"technical advisor\"). Never put a person, organization, product, location, time, number, credential, or exclusivity detail in a role label.\n- counterpartRoles describe reciprocal or complementary target roles. A generic role may be inferred, but its evidence must be an exact sourceText span that supports the inference.\n- hardConstraints contain only explicit constraints and classify each as location, time, numeric, credential, organization, exclusivity, or other.\n- namedEntities contain only proper names explicitly present in sourceText and classify each as person, organization, product, location, event, or other.\n- domainVocabulary contains source domain terms worth preserving.`;\n\nconst lensSchema = z.object({\n label: z.string().describe('Specific description of the search perspective'),\n corpus: z.enum(['profiles', 'intents', 'premises']).describe('Search user profiles, user intents, or user premises (identity/values)'),\n reasoning: z.string().describe('Why this perspective is relevant'),\n});\n\nconst responseFormat = z.object({\n lenses: z.array(lensSchema).min(1).max(5).describe('Inferred search lenses'),\n});\n\n/** Structured-output schema used only by source-frame extraction. */\nexport const FrameResponseSchema = z.object({\n sourceFrame: HydeSourceFrameSchema,\n});\n\ntype ModelInput = BaseLanguageModelInput;\n\n/** Minimal structured model contract used for deterministic injection in tests. */\nexport interface LensStructuredModel {\n invoke(input: ModelInput, config?: { signal?: AbortSignal }): Promise<unknown>;\n}\n\nexport interface LensInferrerOptions {\n legacyModel?: LensStructuredModel;\n frameModel?: LensStructuredModel;\n}\n\nconst logger = protocolLogger(\"LensInferrer\");\n\n/** Infers search lenses from source text and optional profile context. */\nexport class LensInferrer {\n private legacyModel?: LensStructuredModel;\n private frameModel?: LensStructuredModel;\n\n constructor(options: LensInferrerOptions = {}) {\n // Preserve legacy construction behavior in production. Frame-only model\n // injection deliberately avoids constructing a provider-backed legacy model.\n this.legacyModel = options.legacyModel\n ?? (options.frameModel ? undefined : createStructuredModel(\"lensInferrer\", responseFormat, { name: \"lens_inferrer\" }));\n this.frameModel = options.frameModel;\n }\n\n private getLegacyModel(): LensStructuredModel {\n this.legacyModel ??= createStructuredModel(\"lensInferrer\", responseFormat, {\n name: \"lens_inferrer\",\n });\n return this.legacyModel;\n }\n\n private getFrameModel(): LensStructuredModel {\n this.frameModel ??= createStructuredModel(\"lensInferrer\", FrameResponseSchema, {\n name: \"lens_inferrer_frame_v1\",\n });\n return this.frameModel;\n }\n\n /** Infer search lenses while preserving the legacy path unless explicitly enabled. */\n @Timed()\n async infer(input: LensInferenceInput): Promise<LensInferenceOutput> {\n const { sourceText, profileContext, maxLenses = 3, frameConstrained = false } = input;\n\n logger.verbose('Inferring lenses', {\n sourceTextLength: sourceText.length,\n hasProfileContext: !!profileContext,\n maxLenses,\n frameConstrained,\n });\n\n let humanPrompt = `Identify up to ${maxLenses} search perspectives for finding relevant matches.\\n\\nSource: \"${sourceText}\"`;\n\n if (profileContext) {\n humanPrompt += `\\n\\nUser context: ${profileContext}`;\n }\n\n const messages = [\n new SystemMessage(SYSTEM_PROMPT),\n new HumanMessage(humanPrompt),\n ];\n\n if (!frameConstrained) {\n try {\n const result = await invokeWithAbortSignal(this.getLegacyModel(), messages);\n const parsed = responseFormat.parse(result);\n const lenses = parsed.lenses.slice(0, maxLenses);\n\n logger.verbose('Lenses inferred', {\n count: lenses.length,\n lenses: lenses.map(l => ({ label: l.label, corpus: l.corpus })),\n });\n\n return { lenses };\n } catch (error: unknown) {\n logger.error('Lens inference failed', { error });\n return { lenses: [] };\n }\n }\n\n const frameMessages = [\n new SystemMessage(FRAME_SYSTEM_PROMPT),\n new HumanMessage(`Extract the source frame.\\n\\nSource: \"${sourceText}\"`),\n ];\n const lensPromise = (async () => {\n const result = await invokeWithAbortSignal(this.getLegacyModel(), messages);\n return responseFormat.parse(result).lenses.slice(0, maxLenses);\n })();\n const framePromise = (async () => {\n const result = await invokeWithAbortSignal(this.getFrameModel(), frameMessages);\n const parsed = FrameResponseSchema.parse(result);\n return sanitizeHydeSourceFrame(sourceText, parsed.sourceFrame);\n })();\n const [lensResult, frameResult] = await Promise.allSettled([lensPromise, framePromise]);\n\n if (lensResult.status === 'rejected') {\n logger.error('Lens inference failed', { error: lensResult.reason });\n return { lenses: [] };\n }\n\n const lenses = lensResult.value;\n logger.verbose('Frame-constrained lenses inferred', { count: lenses.length });\n\n if (frameResult.status === 'rejected') {\n logger.error('Source frame extraction failed', { error: frameResult.reason });\n return {\n lenses,\n sourceFrame: {\n sourceRoles: [],\n counterpartRoles: [],\n hardConstraints: [],\n namedEntities: [],\n domainVocabulary: [],\n },\n };\n }\n\n return { lenses, sourceFrame: frameResult.value };\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-dispatcher.interface.d.ts","sourceRoot":"/","sources":["shared/interfaces/agent-dispatcher.interface.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACtH,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,8CAA8C,CAAC;AAC5F,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,yBAAyB,CAAC;AAE9E,gEAAgE;AAChE,MAAM,WAAW,sBAAsB;IACrC,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,sBAAsB,CAAC;IAChC,SAAS,EAAE,sBAAsB,CAAC;IAClC,YAAY,EAAE;QAAE,SAAS,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IACrD,cAAc,EAAE,cAAc,CAAC;IAC/B,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,WAAW,EAAE,OAAO,CAAC;IACrB,iEAAiE;IACjE,YAAY,EAAE,OAAO,CAAC;IACtB,gHAAgH;IAChH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,mGAAmG;IACnG,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gEAAgE;IAChE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,4FAA4F;IAC5F,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,qBAAqB,EAAE,CAAC;IAC3C,uFAAuF;IACvF,mBAAmB,CAAC,EAAE,8BAA8B,CAAC;IACrD;;;;;OAKG;IACH,aAAa,CAAC,EAAE,uBAAuB,CAAC;CACzC;AAED,oCAAoC;AACpC,MAAM,MAAM,mBAAmB,GAC3B;IAAE,OAAO,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,eAAe,CAAA;CAAE,GACxC;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,UAAU,GAAG,SAAS,CAAA;CAAE,GAClD;IAAE,OAAO,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,SAAS,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC;AAE/D;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;OAOG;IACH,QAAQ,CACN,MAAM,EAAE,MAAM,EACd,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,EAC9D,OAAO,EAAE,sBAAsB,EAC/B,OAAO,EAAE;QAAE,SAAS,EAAE,MAAM,CAAA;KAAE,GAC7B,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAEhC;;;;OAIG;IACH,gBAAgB,CACd,MAAM,EAAE,MAAM,EACd,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAC7D,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent-dispatcher.interface.js","sourceRoot":"/","sources":["shared/interfaces/agent-dispatcher.interface.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * AgentDispatcher interface for the negotiation graph.\n *\n * The graph calls dispatch() per turn and receives a result.\n * It never knows about webhooks, MCP, transports, or agent resolution.\n * The concrete implementation lives in the host application.\n */\n\nimport type { NegotiationTurn, UserNegotiationContext, SeedAssessment } from '../schemas/negotiation-state.schema.js';\nimport type { NegotiatorMemoryEntry } from '../../negotiation/negotiation.memory.js';\nimport type { AttributedPriorDialogue } from '../../negotiation/negotiation.attribution.js';\nimport type { NegotiationPrivateConsultation } from './database.interface.js';\n\n/** Payload sent to the dispatcher for each negotiation turn. */\nexport interface NegotiationTurnPayload {\n negotiationId: string;\n ownUser: UserNegotiationContext;\n otherUser: UserNegotiationContext;\n indexContext: { networkId: string; prompt?: string };\n seedAssessment: SeedAssessment;\n history: NegotiationTurn[];\n isFinalTurn: boolean;\n /** Whether ownUser is the party that initiated the discovery. */\n isDiscoverer: boolean;\n /** The explicit search query that triggered this discovery (if any). Takes priority over background intents. */\n discoveryQuery?: string;\n /** The acting user's seat under the v2 client-advocate protocol (`initiator` | `counterparty`). */\n seat?: string;\n /** Negotiation protocol version for this task (`v1` | `v2`). */\n protocolVersion?: string;\n /** Actions the acting seat may submit on this turn (seat + version + final-turn scoped). */\n allowedActions?: string[];\n /**\n * The acting user's OWN negotiator memories (P5.3 read path) — private\n * context for the dispatched agent. Never contains the counterparty's\n * memory; absent when `NEGOTIATOR_MEMORY_INJECT` is off or nothing was\n * retrieved.\n */\n negotiatorMemory?: NegotiatorMemoryEntry[];\n /** Recipient-private ask-user consultation, present only for that recipient's turn. */\n privateConsultation?: NegotiationPrivateConsultation;\n /**\n * Prior dialogue with this counterparty, grouped and labeled per opportunity\n * (IND-569). Present only on continuations; lets an external agent see which\n * prior turns belonged to already-concluded OTHER opportunities versus the\n * one under negotiation now. Absent → no attributed prior dialogue available.\n */\n priorDialogue?: AttributedPriorDialogue;\n}\n\n/** Result of a dispatch attempt. */\nexport type AgentDispatchResult =\n | { handled: true; turn: NegotiationTurn }\n | { handled: false; reason: 'no_agent' | 'timeout' }\n | { handled: false; reason: 'waiting'; resumeToken: string };\n\n/**\n * Dispatches a negotiation turn to the appropriate agent.\n * Tries external (poller) agents first, falls back to system agent.\n */\nexport interface AgentDispatcher {\n /**\n * Attempt to dispatch a negotiation turn to an external (poller) agent.\n * @param userId - The user whose agent should handle this turn\n * @param scope - Permission scope for agent resolution\n * @param payload - Turn context (users, history, seed assessment)\n * @param options - Timeout configuration\n * @returns Handled result with turn, or unhandled result with reason\n */\n dispatch(\n userId: string,\n scope: { action: string; scopeType: string; scopeId?: string },\n payload: NegotiationTurnPayload,\n options: { timeoutMs: number },\n ): Promise<AgentDispatchResult>;\n\n /**\n * Check whether a user has an authorized external (poller) agent for the given\n * scope. Used at init to determine scenario-based turn caps. Type-only by design\n * (no heartbeat freshness) — see IND-410.\n */\n hasExternalAgent(\n userId: string,\n scope: { action: string; scopeType: string; scopeId?: string },\n ): Promise<boolean>;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent.interface.d.ts","sourceRoot":"/","sources":["shared/interfaces/agent.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,IAAI,EAAE,UAAU,GAAG,UAAU,GAAG,QAAQ,CAAC;IACzC,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,SAAS,EAAE,IAAI,CAAC;IAChB,SAAS,EAAE,IAAI,CAAC;CACjB;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,KAAK,CAAC;IACf,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,QAAQ,EAA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Aa,CACX,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GAC3D,OAAO,CAAC,OAAO,CAAC,CAAC;IAEpB;;;;;;OAMG;IACH,oBAAoB,CAClB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,KAAK,CAAC,EAAE;QAAE,IAAI,EAAE,QAAQ,GAAG,MAAM,GAAG,SAAS,CAAC;QAAC,EAAE,CAAC,EAAE,MAAM,CAAA;KAAE,GAC3D,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAAC;IAEjC;;;OAGG;IACH,iBAAiB,IAAI;QAAE,gBAAgB,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAA;KAAE,CAAC;CACvE;AAED;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB;;;CAGnB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"agent.interface.js","sourceRoot":"/","sources":["shared/interfaces/agent.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA6LH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG;IAC9B,gBAAgB,EAAE,sCAAsC;IACxD,UAAU,EAAE,sCAAsC;CAC1C,CAAC","sourcesContent":["/**\n * Database adapter interface for agent registry operations.\n * Implemented by the host application and injected via ProtocolDeps.\n */\n\nexport interface AgentRecord {\n id: string;\n ownerId: string;\n name: string;\n description: string | null;\n type: 'personal' | 'external' | 'system';\n status: 'active' | 'inactive';\n metadata: Record<string, unknown>;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface AgentTransportRecord {\n id: string;\n agentId: string;\n channel: 'mcp';\n config: Record<string, unknown>;\n priority: number;\n active: boolean;\n failureCount: number;\n}\n\nexport interface AgentPermissionRecord {\n id: string;\n agentId: string;\n userId: string;\n scope: 'global' | 'node' | 'network';\n scopeId: string | null;\n actions: string[];\n createdAt: Date;\n}\n\nexport interface AgentWithRelations extends AgentRecord {\n transports: AgentTransportRecord[];\n permissions: AgentPermissionRecord[];\n}\n\nexport interface CreateAgentInput {\n ownerId: string;\n name: string;\n description?: string;\n /** Required: personal rows are auto-provisioned negotiators; tool/registration paths create 'external'. */\n type: 'personal' | 'external' | 'system';\n metadata?: Record<string, unknown>;\n}\n\nexport interface CreateTransportInput {\n agentId: string;\n channel: 'mcp';\n config?: Record<string, unknown>;\n priority?: number;\n}\n\nexport interface GrantPermissionInput {\n agentId: string;\n userId: string;\n scope?: 'global' | 'node' | 'network';\n scopeId?: string;\n actions: string[];\n}\n\n/**\n * Database adapter interface for agent registry operations.\n *\n * Handles CRUD for agents, their transports, and permission grants.\n * Implemented by the host application (backend) and injected into the\n * protocol layer via constructor injection at the composition root.\n */\nexport interface AgentDatabase {\n /**\n * Creates a new agent record.\n * @param input - Agent creation parameters.\n * @returns The persisted agent record.\n */\n createAgent(input: CreateAgentInput): Promise<AgentRecord>;\n\n /**\n * Retrieves an agent by its ID.\n * @param agentId - The agent UUID.\n * @returns The agent record, or null if not found.\n */\n getAgent(agentId: string): Promise<AgentRecord | null>;\n\n /**\n * Retrieves an agent along with its transports and permissions.\n * @param agentId - The agent UUID.\n * @returns The agent with relations, or null if not found.\n */\n getAgentWithRelations(agentId: string): Promise<AgentWithRelations | null>;\n\n /**\n * Updates mutable fields on an agent.\n * @param agentId - The agent UUID.\n * @param updates - Partial set of fields to update.\n * @returns The updated agent record, or null if not found.\n */\n updateAgent(\n agentId: string,\n updates: Partial<Pick<AgentRecord, 'name' | 'description' | 'status' | 'metadata'>>,\n ): Promise<AgentRecord | null>;\n\n /**\n * Deletes an agent and its associated transports and permissions.\n * @param agentId - The agent UUID.\n */\n deleteAgent(agentId: string): Promise<void>;\n\n /**\n * Lists all agents owned by a user, including their relations.\n * @param userId - The owner's user ID.\n * @returns Array of agents with transports and permissions.\n */\n listAgentsForUser(userId: string): Promise<AgentWithRelations[]>;\n\n /**\n * Creates a transport channel for an agent.\n * @param input - Transport creation parameters.\n * @returns The persisted transport record.\n */\n createTransport(input: CreateTransportInput): Promise<AgentTransportRecord>;\n\n /**\n * Deletes a transport channel.\n * @param transportId - The transport UUID.\n */\n deleteTransport(transportId: string): Promise<void>;\n\n /**\n * Increments the failure counter for a transport channel.\n * @param transportId - The transport UUID.\n */\n recordTransportFailure(transportId: string): Promise<void>;\n\n /**\n * Resets the failure counter for a transport channel after a successful delivery.\n * @param transportId - The transport UUID.\n */\n recordTransportSuccess(transportId: string): Promise<void>;\n\n /**\n * Grants a permission to an agent for a given user and scope.\n * @param input - Permission grant parameters.\n * @returns The persisted permission record.\n */\n grantPermission(input: GrantPermissionInput): Promise<AgentPermissionRecord>;\n\n /**\n * Revokes a permission by its ID.\n * @param permissionId - The permission UUID.\n */\n revokePermission(permissionId: string): Promise<void>;\n\n /**\n * Checks whether an agent holds a specific permission for a user.\n * @param agentId - The agent UUID.\n * @param userId - The user whose permission is being checked.\n * @param action - The action string to verify (e.g. `\"read\"`, `\"write\"`).\n * @param scope - Optional scope restriction; defaults to global if omitted.\n * @returns True if the permission exists, false otherwise.\n */\n hasPermission(\n agentId: string,\n userId: string,\n action: string,\n scope?: { type: 'global' | 'node' | 'network'; id?: string },\n ): Promise<boolean>;\n\n /**\n * Returns all agents authorized for a user and action, optionally within a scope.\n * @param userId - The user to check authorization for.\n * @param action - The action string (e.g. `\"read\"`, `\"write\"`).\n * @param scope - Optional scope restriction.\n * @returns Array of authorized agents with their relations.\n */\n findAuthorizedAgents(\n userId: string,\n action: string,\n scope?: { type: 'global' | 'node' | 'network'; id?: string },\n ): Promise<AgentWithRelations[]>;\n\n /**\n * Returns the well-known IDs for built-in system agents.\n * @returns Object mapping system agent roles to their fixed UUIDs.\n */\n getSystemAgentIds(): { chatOrchestrator: string; negotiator: string };\n}\n\n/**\n * Fixed UUIDs for built-in system agents.\n *\n * These are seeded into the database on first run and must never change,\n * as they are referenced by foreign keys and hard-coded in protocol logic.\n */\nexport const SYSTEM_AGENT_IDS = {\n chatOrchestrator: '00000000-0000-0000-0000-000000000001',\n negotiator: '00000000-0000-0000-0000-000000000002',\n} as const;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.interface.d.ts","sourceRoot":"/","sources":["shared/interfaces/auth.interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAElE;;;;;;GAMG;AACH,MAAM,WAAW,eAAe;IAC9B;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,eAAe,CAAC,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC;QAC5C,MAAM,EAAE,MAAM,CAAC;QACf,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,aAAa,CAAC,EAAE,OAAO,CAAC;QACxB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;QAC/B,aAAa,CAAC,EAAE,UAAU,GAAG,KAAK,CAAC;KACpC,CAAC,CAAC;IAEH;;;;;;OAMG;IACH,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAClD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"auth.interface.js","sourceRoot":"/","sources":["shared/interfaces/auth.interface.ts"],"names":[],"mappings":"","sourcesContent":["import type { McpAuthInput } from '../schemas/mcp-auth.schema.js';\n\n/**\n * Resolves the authenticated MCP identity from an auth input DTO.\n * The DTO is extracted from the transport at the edge (e.g. from HTTP Request\n * headers) before the protocol layer is called. New auth paths stay free of\n * platform-specific `Request` coupling; `resolveUserId` remains only as a\n * deprecated compatibility bridge while callers migrate to `resolveIdentity`.\n */\nexport interface McpAuthResolver {\n /**\n * Extracts and validates the authenticated identity from the auth input.\n *\n * @param input - Transport-neutral auth input DTO with credential fields\n * extracted at the MCP transport edge.\n * @returns The authenticated user's UUID, optional agent UUID, auth method,\n * `networkScopeId` if the caller's API key is bound to a network-scoped\n * agent, and `clientSurface` declaring which kind of UI is rendering the\n * MCP response (drives connect-link redirect choice at click time).\n *\n * When `networkScopeId` is set, the MCP server promotes it into the\n * canonical `{ scopeType: 'network', scopeId }` envelope. Downstream tools\n * derive concrete allowed network IDs from that envelope plus memberships.\n *\n * `isSessionAuth` is true for OAuth/JWT bearer sessions — the agent-\n * registration gate in the MCP server is skipped for these callers.\n *\n * `clientSurface` is passed through from the DTO. Only `'telegram'`\n * activates the t.me redirect path on `/c/{code}` clicks.\n *\n * @throws Error if authentication fails (no token, invalid token, etc.)\n */\n resolveIdentity(input: McpAuthInput): Promise<{\n userId: string;\n agentId?: string;\n isSessionAuth?: boolean;\n networkScopeId?: string | null;\n clientSurface?: 'telegram' | 'web';\n }>;\n\n /**\n * Deprecated HTTP Request bridge retained for compatibility with older\n * callers. New transport code must extract `McpAuthInput` at the edge and\n * call `resolveIdentity` instead.\n *\n * @deprecated Use resolveIdentity instead.\n */\n resolveUserId(request: Request): Promise<string>;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cache.interface.d.ts","sourceRoot":"/","sources":["shared/interfaces/cache.interface.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,YAAY;IAC3B,qBAAqB;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,KAAK;IACpB;;;OAGG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;IAEvC;;OAEG;IACH,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,OAAO,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAErE;;;OAGG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtC;;OAEG;IACH,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAEtC;;;OAGG;IACH,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,CAAC;IAE/C;;;OAGG;IACH,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CACnD;AAMD,iDAAiD;AACjD,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,GAAG,QAAQ,GAAG,QAAQ,CAAC,CAAC;AAEzE,wDAAwD;AACxD,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,KAAK,EAAE,KAAK,GAAG,KAAK,GAAG,MAAM,CAAC,CAAC"}
|