@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":"outcome.env.js","sourceRoot":"/","sources":["opportunity/outcome/outcome.env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAKH;;;GAGG;AACH,MAAM,UAAU,oBAAoB;IAClC,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,sBAAsB,EAAE,IAAI,EAAE,CAAC;IACzD,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC;AAC9D,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO,oBAAoB,EAAE,KAAK,KAAK,CAAC;AAC1C,CAAC;AAED;;;;;GAKG;AACH,MAAM,CAAC,MAAM,+BAA+B,GAAG,CAAC,CAAC;AAEjD,gFAAgF;AAChF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAC,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gCAAgC,GAC3C,+BAA+B,GAAG,0BAA0B,CAAC;AAE/D,0EAA0E;AAC1E,MAAM,CAAC,MAAM,sBAAsB,GAAG,EAAE,CAAC;AAEzC,iFAAiF;AACjF,MAAM,CAAC,MAAM,gCAAgC,GAAG,GAAG,CAAC","sourcesContent":["/**\n * Centralized accessors for Lens B outcome-question environment variables\n * (IND-434).\n *\n * OUTCOME_QUESTIONS_MODE off | shadow | on — Lens B \"explicit opportunity\n * outcomes → grounded questions\" pipeline.\n *\n * off (default): no outcome feedback events are\n * captured and no hypothesis mining runs. Zero\n * behavior change.\n * shadow: capture one idempotent append-only\n * feedback event per explicit owner action, mine\n * neutral trade-off hypotheses for the exact\n * recipient + intent + fingerprint, and emit\n * aggregate telemetry only. No question, ranking,\n * intent, premise, memory, newborn-stamp, or push\n * writes.\n * on: reserved for a later phase (IND-438) that\n * turns a grounded hypothesis into a user-facing\n * question. This slice treats \"on\" exactly like\n * \"shadow\" for capture + mining; it never emits\n * questions.\n *\n * All reads go through this module — do not read this variable via\n * `process.env` elsewhere. Values are read on every call (no caching) so tests\n * and long-lived processes observe changes.\n */\n\n/** Lens B outcome-question mode. */\nexport type OutcomeQuestionsMode = \"off\" | \"shadow\" | \"on\";\n\n/**\n * Current OUTCOME_QUESTIONS_MODE (default off). Only the exact trimmed literals\n * \"shadow\" and \"on\" activate; every other value (including unset/empty) is off.\n */\nexport function outcomeQuestionsMode(): OutcomeQuestionsMode {\n const value = process.env.OUTCOME_QUESTIONS_MODE?.trim();\n return value === \"shadow\" || value === \"on\" ? value : \"off\";\n}\n\n/**\n * True when Lens B capture + mining should run at all. Both \"shadow\" and \"on\"\n * activate the shadow pipeline; only the future question-emitting behavior is\n * gated on \"on\" (not part of this slice).\n */\nexport function isOutcomeQuestionsActivated(): boolean {\n return outcomeQuestionsMode() !== \"off\";\n}\n\n/**\n * Independent-support threshold (k). Every compared group (discriminator side)\n * must have at least this many INDEPENDENT (related-opportunity-deduplicated)\n * examples before the hypothesis is eligible. Enforced per side, so no side\n * can be traced back to a small handful of individuals.\n */\nexport const OUTCOME_MIN_INDEPENDENT_SUPPORT = 5;\n\n/** Minimum number of qualified sides (each ≥ k) for a hypothesis to compare. */\nexport const OUTCOME_MIN_COMPARED_SIDES = 2;\n\n/**\n * k-anonymity floor for attempting a mining pass at all: the number of\n * distinct independent examples (after related-opportunity dedup) required\n * before the miner is invoked. Set to k × minimum compared sides so a pass can\n * never produce an eligible hypothesis below the aggregate floor.\n */\nexport const OUTCOME_MIN_INDEPENDENT_EXAMPLES =\n OUTCOME_MIN_INDEPENDENT_SUPPORT * OUTCOME_MIN_COMPARED_SIDES;\n\n/** Max independent examples sent to the miner LLM (most recent first). */\nexport const OUTCOME_MAX_CANDIDATES = 48;\n\n/** Max chars of presentation-safe candidate snapshot stored/sent per example. */\nexport const OUTCOME_MAX_PUBLIC_CONTEXT_CHARS = 400;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.hypotheses.d.ts","sourceRoot":"/","sources":["opportunity/outcome/outcome.hypotheses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAGH,OAAO,KAAK,EAAE,0BAA0B,EAAqB,mBAAmB,EAAsB,MAAM,oBAAoB,CAAC;AAOjI;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,GAAG,mBAAmB,CAsF5F"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.hypotheses.js","sourceRoot":"/","sources":["opportunity/outcome/outcome.hypotheses.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAAE,0BAA0B,EAAE,+BAA+B,EAAE,MAAM,kBAAkB,CAAC;AAG/F,8DAA8D;AAC9D,SAAS,SAAS,CAAC,CAAS;IAC1B,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,CAAC,GAAG,GAAG,CAAC;AACnC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAiC;IACrE,MAAM,UAAU,GAAG,KAAK,CAAC,qBAAqB,IAAI,+BAA+B,CAAC;IAClF,MAAM,QAAQ,GAAG,KAAK,CAAC,gBAAgB,IAAI,0BAA0B,CAAC;IAEtE,+DAA+D;IAC/D,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC;IAErC,MAAM,UAAU,GAAwB,EAAE,CAA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,CAAC","sourcesContent":["/**\n * Lens B outcome join + threshold — pure functions, no LLM, no I/O (IND-434).\n *\n * Given discriminators whose candidate → side assignments were produced BLIND\n * to outcome (the miner never saw which side the user chose), this module joins\n * the explicit owner-outcome labels and produces aggregate-only telemetry:\n *\n * - Independence: capture admits only one unique counterpart per opportunity;\n * the caller then deduplicates by that recipient-scoped counterpart hash.\n * Every retained entry therefore represents one distinct counterpart.\n * - Threshold: a discriminator side is \"qualified\" only when it holds at\n * least `minIndependentSupport` (k) independent examples. A hypothesis is\n * eligible only when at least `minComparedSides` sides qualify.\n * - Small-cell suppression: only qualified sides (≥ k) are ever emitted, so\n * no aggregate row can be traced to a small handful of individuals.\n *\n * The outcome label is joined here and ONLY here — the miner and the side\n * assignments upstream are independent of it, so association can never leak\n * into classification.\n */\n\nimport { OUTCOME_MIN_COMPARED_SIDES, OUTCOME_MIN_INDEPENDENT_SUPPORT } from \"./outcome.env.js\";\nimport type { JoinOutcomeHypothesesInput, OutcomeHypothesis, OutcomeShadowResult, OutcomeSideSupport } from \"./outcome.types.js\";\n\n/** Round a rate to 0.01 for telemetry (never a raw count). */\nfunction roundRate(n: number): number {\n return Math.round(n * 100) / 100;\n}\n\n/**\n * Join outcome labels onto blind side assignments and keep only hypotheses that\n * clear the independent-support threshold on at least `minComparedSides` sides.\n *\n * @returns Aggregate telemetry: eligible hypotheses sorted by (min support desc,\n * label asc) for deterministic ordering, each carrying only qualified sides.\n */\nexport function joinOutcomeHypotheses(input: JoinOutcomeHypothesesInput): OutcomeShadowResult {\n const minSupport = input.minIndependentSupport ?? OUTCOME_MIN_INDEPENDENT_SUPPORT;\n const minSides = input.minComparedSides ?? OUTCOME_MIN_COMPARED_SIDES;\n\n // Distinct independent examples with a joinable outcome label.\n const poolSize = input.examples.size;\n\n const hypotheses: OutcomeHypothesis[] = [];\n\n for (const discriminator of input.discriminators) {\n // Normalize sides by trimming, then reject the ENTIRE discriminator if any\n // side is empty or if labels are not unique after normalization. Silently\n // deduplicating malformed model output would turn an ambiguous comparison\n // into apparently valid evidence.\n const normalizedSides = discriminator.sides.map((side) => side.trim());\n if (normalizedSides.some((side) => side.length === 0)) continue;\n if (new Set(normalizedSides).size !== normalizedSides.length) continue;\n if (normalizedSides.length < minSides) continue;\n const validSides = new Set(normalizedSides);\n\n // First normalize VERIFIED, labelled assignments by candidate id. If the\n // same independent example is assigned to different sides, mark it\n // ambiguous and exclude it from every side; it must never support two cells.\n const sideById = new Map<string, string>();\n const ambiguousIds = new Set<string>();\n for (const assignment of discriminator.assignments) {\n if (assignment.side === null || !assignment.verified) continue;\n const side = assignment.side.trim();\n if (!validSides.has(side) || !input.examples.has(assignment.id)) continue;\n const previous = sideById.get(assignment.id);\n if (previous !== undefined && previous !== side) ambiguousIds.add(assignment.id);\n else if (previous === undefined) sideById.set(assignment.id, side);\n }\n\n // Tally DISTINCT independent example ids per unambiguous side. Repeating\n // the same assignment never increases support.\n const idsBySide = new Map<string, Set<string>>();\n const acceptedIdsBySide = new Map<string, Set<string>>();\n for (const [id, side] of sideById) {\n if (ambiguousIds.has(id)) continue;\n const label = input.examples.get(id);\n if (label === undefined) continue;\n if (!idsBySide.has(side)) idsBySide.set(side, new Set());\n idsBySide.get(side)!.add(id);\n if (label === \"accepted\") {\n if (!acceptedIdsBySide.has(side)) acceptedIdsBySide.set(side, new Set());\n acceptedIdsBySide.get(side)!.add(id);\n }\n }\n\n // Keep only sides that clear the independent-support threshold (>= k\n // genuinely distinct independent examples).\n const qualifiedSides: OutcomeSideSupport[] = [];\n for (const side of normalizedSides) {\n const support = idsBySide.get(side)?.size ?? 0;\n if (support < minSupport) continue; // small-cell: never emitted\n const accepted = acceptedIdsBySide.get(side)?.size ?? 0;\n qualifiedSides.push({\n side,\n independentSupport: support,\n acceptRate: roundRate(accepted / support),\n });\n }\n\n if (qualifiedSides.length < minSides) continue; // not enough to compare\n\n // Deterministic side ordering: support desc, then label asc.\n qualifiedSides.sort(\n (a, b) => b.independentSupport - a.independentSupport || a.side.localeCompare(b.side),\n );\n\n hypotheses.push({\n label: discriminator.label,\n questionSeed: discriminator.questionSeed,\n sides: qualifiedSides,\n evidenceRate: discriminator.evidenceRate,\n minIndependentSupport: Math.min(...qualifiedSides.map((s) => s.independentSupport)),\n });\n }\n\n // Deterministic hypothesis ordering: strongest support first, then label.\n hypotheses.sort(\n (a, b) => b.minIndependentSupport - a.minIndependentSupport || a.label.localeCompare(b.label),\n );\n\n return { poolSize, eligibleCount: hypotheses.length, hypotheses };\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.shadow.d.ts","sourceRoot":"/","sources":["opportunity/outcome/outcome.shadow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAItF,OAAO,KAAK,EAAE,cAAc,EAAgB,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAI5F,oDAAoD;AACpD,MAAM,WAAW,kBAAkB;IACjC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,QAAQ,EAAE,cAAc,EAAE,CAAC;IAC3B,KAAK,EAAE,IAAI,CAAC,sBAAsB,EAAE,MAAM,CAAC,CAAC;IAC5C,kEAAkE;IAClE,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,4CAA4C;IAC5C,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sCAAsC;IACtC,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,0BAA0B,CAAC,QAAQ,EAAE,cAAc,EAAE,GAAG,cAAc,EAAE,CAgBvF;AAED;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAgD9F"}
|
|
@@ -1 +0,0 @@
|
|
|
1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AAE,UAAU,EAAE,EAC5C,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,SAAS,CACpD,CAAC;IACF,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,OAAO,EAAE,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,EAAE,CAAC;IAC5E,CAAC;IAED,6DAA6D;IAC7D,MAAM,QAAQ,GAAG,IAAI,GAAG,CACtB,OAAO,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC,CAAC,KAAK,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,CAC5D,CAAC;IACF,MAAM,MAAM,GAAG,qBAAqB,CAAC;QACnC,cAAc,EAAE,KAAK;QACrB,QAAQ;QACR,qBAAqB,EAAE,UAAU;QACjC,gBAAgB,EAAE,QAAQ;KAC3B,CAAC,CAAC;IAEH,MAAM,CAAC,KAAK,CAAC,sBAAsB,EAAE;QACnC,QAAQ,EAAE,MAAM,CAAC,QAAQ;QACzB,aAAa,EAAE,MAAM,CAAC,aAAa;KACpC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/**\n * Lens B shadow orchestrator (IND-434): deduplicate related opportunities,\n * mine neutral axes over the deduplicated historical pool BLIND to outcome,\n * then join the owner-outcome labels and threshold the result.\n *\n * No persistence, no questions, no UI. The output is consumed only by aggregate\n * telemetry for human review.\n *\n * Pipeline:\n * 1. Dedup related opportunities: collapse examples sharing a dedup key to a\n * single representative (most recent), so a cluster of related opps can\n * neither dominate the miner nor inflate a side's independent support.\n * 2. Cap to the most recent OUTCOME_MAX_CANDIDATES for a bounded LLM pass.\n * 3. Build the miner pool — PoolCandidate carries id + publicContext + score\n * and, critically, NO outcome label. The miner is structurally blind.\n * 4. Mine neutral axes + assign candidates (evidence-verified).\n * 5. Join outcome labels (only now) and apply the k-support threshold.\n */\n\nimport { protocolLogger } from \"../../shared/observability/protocol.logger.js\";\nimport type { PoolDiscriminatorMiner } from \"../discriminator/discriminator.miner.js\";\nimport type { PoolCandidate } from \"../discriminator/discriminator.types.js\";\nimport { OUTCOME_MAX_CANDIDATES, OUTCOME_MIN_COMPARED_SIDES, OUTCOME_MIN_INDEPENDENT_SUPPORT } from \"./outcome.env.js\";\nimport { joinOutcomeHypotheses } from \"./outcome.hypotheses.js\";\nimport type { OutcomeExample, OutcomeLabel, OutcomeShadowResult } from \"./outcome.types.js\";\n\nconst logger = protocolLogger(\"OutcomeQuestionShadow\");\n\n/** Input for one Lens B shadow mining+join pass. */\nexport interface OutcomeShadowInput {\n /**\n * Intent payload (+ summary) text that owns this scope. Used only as miner\n * context; never mixed with outcome labels.\n */\n intentText: string;\n /**\n * Captured owner-outcome examples for exactly one recipient + intent +\n * fingerprint scope. Each carries a presentation-safe snapshot and a dedup\n * key; outcome labels live here but are withheld from the miner.\n */\n examples: OutcomeExample[];\n miner: Pick<PoolDiscriminatorMiner, \"mine\">;\n /** Override the independent-support threshold (defaults to k). */\n minIndependentSupport?: number;\n /** Override the minimum qualified sides. */\n minComparedSides?: number;\n /** Override the LLM candidate cap. */\n maxCandidates?: number;\n signal?: AbortSignal;\n}\n\n/**\n * Collapse related opportunities to independent examples: one representative\n * (most recent by occurredAt) per distinct dedup key. Deterministic — ties on\n * occurredAt fall back to opportunityId ordering.\n */\nexport function deduplicateOutcomeExamples(examples: OutcomeExample[]): OutcomeExample[] {\n const byKey = new Map<string, OutcomeExample>();\n for (const example of examples) {\n const existing = byKey.get(example.dedupKey);\n if (existing === undefined) {\n byKey.set(example.dedupKey, example);\n continue;\n }\n const newer =\n example.occurredAt > existing.occurredAt ||\n (example.occurredAt === existing.occurredAt && example.opportunityId > existing.opportunityId);\n if (newer) byKey.set(example.dedupKey, example);\n }\n return [...byKey.values()].sort(\n (a, b) => b.occurredAt.localeCompare(a.occurredAt) || a.opportunityId.localeCompare(b.opportunityId),\n );\n}\n\n/**\n * Run the Lens B shadow pipeline for one scope.\n *\n * Throws only when *mining* fails (callers are fire-and-forget and must catch).\n * A pool that is empty or below the compare floor after dedup returns an empty\n * result rather than throwing.\n */\nexport async function runOutcomeShadow(input: OutcomeShadowInput): Promise<OutcomeShadowResult> {\n const minSupport = input.minIndependentSupport ?? OUTCOME_MIN_INDEPENDENT_SUPPORT;\n const minSides = input.minComparedSides ?? OUTCOME_MIN_COMPARED_SIDES;\n const maxCandidates = input.maxCandidates ?? OUTCOME_MAX_CANDIDATES;\n\n // 1–2. Dedup related opportunities, then cap to a bounded, recent pool.\n const independent = deduplicateOutcomeExamples(input.examples).slice(0, maxCandidates);\n if (independent.length < minSupport * minSides) {\n return { poolSize: independent.length, eligibleCount: 0, hypotheses: [] };\n }\n\n // 3. Build the miner pool with RUN-LOCAL aliases (c0, c1, …) as candidate ids\n // — raw opportunity ids are never sent to the LLM. The alias→outcome map is\n // kept internally for the join. PoolCandidate deliberately excludes the\n // outcome label, so the miner cannot condition on which side was chosen.\n const aliased = independent.map((example, index) => ({ alias: `c${index}`, example }));\n const candidates: PoolCandidate[] = aliased.map(({ alias, example }) => ({\n id: alias,\n publicContext: example.publicContext,\n score: example.score ?? 1,\n }));\n\n // 4. Blind assignment (assignments come back keyed by the run-local alias).\n const mined = await input.miner.mine(\n { intentText: input.intentText, candidates },\n input.signal ? { signal: input.signal } : undefined,\n );\n if (mined.length === 0) {\n return { poolSize: independent.length, eligibleCount: 0, hypotheses: [] };\n }\n\n // 5. Join outcome labels (only now) by alias, and threshold.\n const examples = new Map<string, OutcomeLabel>(\n aliased.map(({ alias, example }) => [alias, example.label]),\n );\n const result = joinOutcomeHypotheses({\n discriminators: mined,\n examples,\n minIndependentSupport: minSupport,\n minComparedSides: minSides,\n });\n\n logger.debug(\"shadow join complete\", {\n poolSize: result.poolSize,\n eligibleCount: result.eligibleCount,\n });\n\n return result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H,UAAU,EAAE,iBAAiB,EAAE,CAAC;CACjC;AAED,4EAA4E;AAC5E,MAAM,WAAW,0BAA0B;IACzC,8EAA8E;IAC9E,cAAc,EAAE,kBAAkB,EAAE,CAAC;IACrC;;;;OAIG;IACH,QAAQ,EAAE,GAAG,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;IACpC,6DAA6D;IAC7D,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,gEAAgE;IAChE,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"outcome.types.js","sourceRoot":"/","sources":["opportunity/outcome/outcome.types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG","sourcesContent":["/**\n * Lens B outcome-question mining — shared types (IND-434).\n *\n * Lens B learns whether a user's OWN past explicit opportunity decisions\n * (accept / reject) suggest a useful clarification question, WITHOUT treating\n * mutable statuses, counterparty actions, or system transitions as\n * preferences. It is the historical-outcome analogue of the live-pool Lens A\n * discriminator (see ../discriminator/*).\n *\n * The two lenses share the neutral-axis mining machinery (PoolDiscriminatorMiner\n * assigns candidates to axis sides from presentation-safe context only). Lens B\n * adds the crucial privacy/correctness discipline on top:\n *\n * 1. Candidates are assigned to sides BLIND to their outcome label — the\n * classifier never sees which side the user chose (the miner input carries\n * no outcome field at all).\n * 2. Outcome labels are joined only AFTER assignment.\n * 3. Related opportunities are deduplicated (one independent example per\n * distinct counterpart) before support is counted.\n * 4. Every compared group (side) must clear the independent-support\n * threshold k, so aggregate telemetry never exposes a small cell.\n *\n * P7 (shadow) uses these types for aggregate-telemetry output only: no\n * questions, ranking, intent, premise, memory, newborn-stamp, or push writes.\n */\n\nimport type { MinedDiscriminator } from \"../discriminator/discriminator.types.js\";\n\n/**\n * The only two explicit owner actions Lens B treats as preference labels.\n * Non-action, delivery, expiry, timeout, merge, cascade, screening, and every\n * counterparty/agent/system transition are deliberately excluded upstream.\n */\nexport type OutcomeLabel = \"accepted\" | \"rejected\";\n\n/**\n * One captured owner-outcome example, as consumed by the mining orchestrator.\n * Built from an append-only feedback event; carries only presentation-safe\n * text plus join/dedup keys — never raw ids, vectors, or model reasoning.\n */\nexport interface OutcomeExample {\n /**\n * Opportunity id — the join key between blind assignment and outcome label.\n * Never emitted in telemetry.\n */\n opportunityId: string;\n /** Presentation-safe candidate snapshot the miner assigns sides from. */\n publicContext: string;\n /** Explicit owner action. Joined AFTER assignment, never seen by the miner. */\n label: OutcomeLabel;\n /**\n * Related-opportunity dedup key: a stable, non-reversible identifier of the\n * counterpart (or opportunity when no counterpart). Two examples with the\n * same key count as ONE independent example.\n */\n dedupKey: string;\n /** Sort key for recency-based capping/representative selection (ISO-8601). */\n occurredAt: string;\n /** Optional confidence mass for score-weighted assignment; defaults to 1. */\n score?: number;\n}\n\n/** Aggregate support for one discriminator side, after dedup + threshold. */\nexport interface OutcomeSideSupport {\n /** Neutral side label carried verbatim from the miner. */\n side: string;\n /** Distinct independent (deduplicated) examples assigned to this side (≥ k). */\n independentSupport: number;\n /**\n * Independent accepted examples ÷ independentSupport, rounded to 0.01. A\n * rate, never a raw small-cell count.\n */\n acceptRate: number;\n}\n\n/** One eligible neutral hypothesis with aggregate-only stats. */\nexport interface OutcomeHypothesis {\n /** Discriminator label, e.g. \"Hands-on builders vs strategic advisors\". */\n label: string;\n /** A neutral question the intent owner could answer to resolve the axis. */\n questionSeed: string;\n /** Only the qualified sides (each ≥ k independent examples). */\n sides: OutcomeSideSupport[];\n /** Evidence-verification rate carried from the miner (hallucination health). */\n evidenceRate: number;\n /** Minimum independentSupport across the qualified sides (≥ k). */\n minIndependentSupport: number;\n}\n\n/** Result of one shadow mining pass (the aggregate telemetry payload shape). */\nexport interface OutcomeShadowResult {\n /** Distinct independent examples considered after dedup + capping. */\n poolSize: number;\n /** Count of eligible hypotheses (meets k + ≥ minComparedSides qualified). */\n eligibleCount: number;\n /**\n * Eligible hypotheses only, sorted deterministically. Aggregate stats only —\n * no opportunity ids, no candidate text, no small-cell counts.\n */\n hypotheses: OutcomeHypothesis[];\n}\n\n/** Input to the pure outcome-join step (assignment already done, blind). */\nexport interface JoinOutcomeHypothesesInput {\n /** Mined discriminators with verified side assignments (blind to outcome). */\n discriminators: MinedDiscriminator[];\n /**\n * Outcome labels keyed by opportunity id. Each example is already\n * independent (deduplicated by the orchestrator), so one entry = one\n * independent example.\n */\n examples: Map<string, OutcomeLabel>;\n /** Independent-support threshold per side. Defaults to k. */\n minIndependentSupport?: number;\n /** Minimum qualified sides. Defaults to the module constant. */\n minComparedSides?: number;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"premise.analyzer.d.ts","sourceRoot":"/","sources":["premise/premise.analyzer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiExB,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;EAoBlB,CAAC;AAEH,MAAM,MAAM,qBAAqB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAEnE;;GAEG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,KAAK,CAA2C;;IAS3C,MAAM,CACjB,WAAW,EAAE,MAAM,EACnB,cAAc,CAAC,EAAE,MAAM,EACvB,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GACrC,OAAO,CAAC,qBAAqB,CAAC;CAwBlC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"premise.analyzer.js","sourceRoot":"/","sources":["premise/premise.analyzer.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,KAAK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AAK,GAAG,qBAAqB,CAAC,iBAAiB,EAAE,cAAc,EAAE;YACpE,IAAI,EAAE,kBAAkB;SACzB,CAAC,CAAC;IACL,CAAC;IAGY,AAAN,KAAK,CAAC,MAAM,CACjB,WAAmB,EACnB,cAAuB,EACvB,UAAoC,EAAE;QAEtC,SAAS,CAAC,OAAO,CAAC,wBAAwB,EAAE,EAAE,OAAO,EAAE,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC;QAEvF,MAAM,YAAY,GAAG,cAAc;YACjC,CAAC,CAAC,kCAAkC,cAAc,IAAI;YACtD,CAAC,CAAC,EAAE,CAAC;QAEP,MAAM,MAAM,GAAG,GAAG,YAAY;;GAE/B,WAAW;;yDAE2C,CAAC;QAEtD,MAAM,QAAQ,GAAG;YACf,IAAI,aAAa,CAAC,YAAY,CAAC;YAC/B,IAAI,YAAY,CAAC,MAAM,CAAC;SACzB,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,qBAAqB,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;QACjF,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAE5C,SAAS,CAAC,OAAO,CAAC,iBAAiB,EAAE,EAAE,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE,eAAe,EAAE,MAAM,CAAC,eAAe,EAAE,CAAC,CAAC;QACvH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA5Bc;IADZ,KAAK,EAAE;;;;6CA4BP","sourcesContent":["import { HumanMessage, SystemMessage } from \"@langchain/core/messages\";\nimport { z } from \"zod\";\nimport { protocolLogger } from \"../shared/observability/protocol.logger.js\";\nimport { Timed } from \"../shared/observability/performance.js\";\nimport { createStructuredModel } from \"../shared/agent/model.config.js\";\nimport { invokeWithAbortSignal } from \"../shared/agent/model-signal.js\";\n\nconst logger = protocolLogger(\"PremiseAnalyzer\");\nconst invokeLog = protocolLogger(\"PremiseAnalyzer:invoke\");\n\nconst systemPrompt = `\nYou are the Premise Analyzer for the Index Network — an intent-driven discovery protocol.\n\nYour job: classify a self-descriptive premise using adapted Speech Act Theory, then score its felicity conditions.\n\nA premise is a proposition a person asserts about themselves. It is NOT a desire or request (those are intents). Premises are conditions of possibility — facts about who someone is that ground opportunity discovery.\n\nAlways reason before classifying. Output reasoning first.\n\n═══════════════════════════════════════════════════\nSTEP 1 — CLASSIFY THE SPEECH ACT\n═══════════════════════════════════════════════════\n\nDECLARATIVE: The premise constitutes a fact about the speaker's identity, role, or status.\n Examples:\n · \"I am a climate-tech founder\" → DECLARATIVE\n · \"I hold a PhD in computational biology\" → DECLARATIVE\n · \"I am based in Berlin\" → DECLARATIVE\n · \"I am raising Series A\" → DECLARATIVE (constitutes current status)\n\nASSERTIVE: The premise describes a capability, experience, or characteristic.\n Examples:\n · \"I have 10 years of experience in distributed systems\" → ASSERTIVE\n · \"I built a collaboration platform used by 50k users\" → ASSERTIVE\n · \"I speak fluent Mandarin and German\" → ASSERTIVE\n · \"I specialize in zero-knowledge proofs\" → ASSERTIVE\n\n═══════════════════════════════════════════════════\nSTEP 2 — SCORE THE FELICITY CONDITIONS (0–100)\n═══════════════════════════════════════════════════\n\nAUTHORITY (Preparatory Condition)\n Does the speaker plausibly have standing to assert this?\n 100 → Highly specific, verifiable claim (\"I founded X in 2019\")\n 60 → Plausible but unverifiable (\"I have deep expertise in AI\")\n 20 → Implausible or grandiose (\"I am the world's leading expert\")\n\nSINCERITY (Sincerity Condition)\n Does the linguistic form suggest genuine self-description vs. aspiration?\n 100 → Present tense, first person, specific (\"I am a YC-backed founder\")\n 60 → Hedged or aspirational (\"I'm sort of getting into crypto\")\n 20 → Clearly aspirational masquerading as fact (\"I'm basically a VC\")\n\nCLARITY (Essential Condition)\n How specific and matchable is this premise?\n 100 → \"I build distributed database systems in Rust at a Series B startup\"\n 60 → \"I work in tech\" (clear direction, vague spec)\n 20 → \"I do things\" (barely informative)\n\nSEMANTIC ENTROPY → 0.0 to 1.0\n 0.0 = maximally constrained (role + domain + location + stage all specified)\n 1.0 = no constraints at all\n 0.0 example: \"I am a senior ML engineer at Google Brain in Mountain View\"\n 1.0 example: \"I'm a person\"\n`;\n\nconst responseFormat = z.object({\n reasoning: z.string().describe(\n \"Step-by-step analysis: (1) whether this is DECLARATIVE or ASSERTIVE and why, \" +\n \"(2) felicity condition assessment.\"\n ),\n speechActType: z.enum([\"DECLARATIVE\", \"ASSERTIVE\"]).describe(\n \"DECLARATIVE = constitutes identity/role/status; ASSERTIVE = describes capability/experience\"\n ),\n felicityAuthority: z.number().min(0).max(100).describe(\n \"Preparatory: does the speaker plausibly have standing to assert this (0-100)\"\n ),\n felicitySincerity: z.number().min(0).max(100).describe(\n \"Sincerity: genuine self-description vs. aspirational (0-100)\"\n ),\n felicityClarity: z.number().min(0).max(100).describe(\n \"Essential: how specific and matchable is this premise (0-100)\"\n ),\n semanticEntropy: z.number().min(0).max(1).describe(\n \"Constraint density: 0.0 = maximally specific, 1.0 = completely unconstrained\"\n ),\n});\n\nexport type PremiseAnalyzerOutput = z.infer<typeof responseFormat>;\n\n/**\n * Classifies a premise using adapted Speech Act Theory and scores felicity conditions.\n */\nexport class PremiseAnalyzer {\n private model: ReturnType<typeof createStructuredModel>;\n\n constructor() {\n this.model = createStructuredModel(\"premiseAnalyzer\", responseFormat, {\n name: \"premise_analyzer\"\n });\n }\n\n @Timed()\n public async invoke(\n premiseText: string,\n profileContext?: string,\n options: { signal?: AbortSignal } = {},\n ): Promise<PremiseAnalyzerOutput> {\n invokeLog.verbose('Analyzing premise text', { preview: premiseText.substring(0, 50) });\n\n const contextBlock = profileContext\n ? `\\n# Speaker Profile (Context)\\n${profileContext}\\n`\n : \"\";\n\n const prompt = `${contextBlock}\n# Premise to Analyze\n\"${premiseText}\"\n\nClassify this premise and score its felicity conditions.`;\n\n const messages = [\n new SystemMessage(systemPrompt),\n new HumanMessage(prompt),\n ];\n\n const result = await invokeWithAbortSignal(this.model, messages, options.signal);\n const output = responseFormat.parse(result);\n\n invokeLog.verbose('Analysis result', { speechActType: output.speechActType, semanticEntropy: output.semanticEntropy });\n return output;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"premise.decomposer.d.ts","sourceRoot":"/","sources":["premise/premise.decomposer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAmIxB,QAAA,MAAM,iBAAiB;;;;;;;;;;;;EAQrB,CAAC;AAEH,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAalB,CAAC;AAEH,oFAAoF;AACpF,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AACrE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAElE;;;GAGG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,KAAK,CAA2C;;IAS3C,MAAM,CACjB,KAAK,EAAE,MAAM,EACb,gBAAgB,CAAC,EAAE,kBAAkB,EAAE,EACvC,UAAU,CAAC,EAAE,MAAM,EACnB,OAAO,GAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAO,GACrC,OAAO,CAAC,uBAAuB,CAAC;CAyDpC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"premise.decomposer.js","sourceRoot":"/","sources":["premise/premise.decomposer.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MA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AAC,MAAM;YACpC,eAAe,EAAE,MAAM,CAAC,mBAAmB,CAAC,MAAM;YAClD,aAAa,EAAE,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC;SAC1C,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA9Dc;IADZ,KAAK,EAAE;;;;+CA8DP","sourcesContent":["import { HumanMessage, SystemMessage } from \"@langchain/core/messages\";\nimport { z } from \"zod\";\nimport { protocolLogger } from \"../shared/observability/protocol.logger.js\";\nimport { Timed } from \"../shared/observability/performance.js\";\nimport { createStructuredModel } from \"../shared/agent/model.config.js\";\nimport { invokeWithAbortSignal } from \"../shared/agent/model-signal.js\";\n\nconst logger = protocolLogger(\"PremiseDecomposer\");\nconst invokeLog = protocolLogger(\"PremiseDecomposer:invoke\");\n\nconst systemPrompt = `\nYou are the Premise Decomposer for the Index Network — an intent-driven discovery protocol.\n\nYour job: decompose free-text input about a person into individual, atomic premises.\n\nA premise is a single self-descriptive proposition — a fact someone asserts about themselves.\nEach premise should be:\n1. **Atomic** — one fact per premise, not compound statements\n2. **First-person** — phrased as \"I am...\", \"I work at...\", \"I specialize in...\"\n3. **Self-descriptive** — about the person's identity, role, skills, interests, location, or context\n4. **Non-redundant** — do not repeat the same information in multiple premises\n\n═══════════════════════════════════════════════════\nINPUT TYPES\n═══════════════════════════════════════════════════\n\nYou may receive:\n- **Chat messages**: \"I'm a software engineer at Google, based in SF. I'm interested in AI safety.\"\n- **Bio text**: A paragraph describing someone's background\n- **Scraped content**: LinkedIn/GitHub/Twitter data about someone\n- **Mixed input**: Name, location, and free-text combined\n\n═══════════════════════════════════════════════════\nDECOMPOSITION RULES\n═══════════════════════════════════════════════════\n\n1. Extract every distinct factual claim about the person\n2. Convert third-person (\"She works at...\") to first-person (\"I work at...\")\n3. Separate compound statements: \"I know Python and Rust\" → two premises\n4. Capture the FULL breadth of self-description, not just job/title. In particular,\n do not drop:\n - **Skills & expertise** (\"I specialize in distributed systems\", \"I know Rust\")\n - **Interests & focus areas** (\"I am interested in AI safety\", \"I care about climate\")\n - **Background/narrative context** (education, prior roles, domains, affiliations)\n These map to what a profile would store as interests/skills/context — every such\n fact must surface as its own premise so nothing is lost.\n5. Classify each premise:\n - \\`assertive\\` — stable identity facts (role, skills, interests, education, location)\n - \\`contextual\\` — temporal/situational (current projects, events, fundraising status)\n6. For \\`contextual\\` premises, estimate \\`validityDays\\` — how many days the fact is\n likely to remain true from now (e.g. \"speaking next week\" → ~7, \"raising a Series A\"\n → ~120, \"currently building X\" → ~180). Use null for \\`assertive\\` premises, which\n have no natural expiry.\n7. Skip vague or uninformative statements (\"I like stuff\", \"I'm a person\")\n8. Skip desires, requests, or intents (\"I'm looking for...\", \"I want to...\") — those are intents, not premises\n9. If the input contains NO extractable premises (e.g. just \"Yes\" or \"Hello\"), return an empty array\n10. NEVER extract denials or removal instructions as premises. \"I have nothing to do with X\",\n \"I am not a Y\", or \"remove X from my profile\" are retractions, not facts — handle them\n via the retraction rules below and do NOT emit a premise for them.\n\n═════════════════════════════════════════════════\nRETRACTION RULES\n═════════════════════════════════════════════════\n\nWhen the message includes the user's EXISTING PREMISES (listed with ids), you must also\ndetect which of them the input disavows and return their ids in \\`retractedPremiseIds\\`.\n\nA premise must be retracted when the input:\n- Explicitly asks to remove it (\"remove all mentions of X\", \"delete the part about Y\")\n- Denies it (\"I have nothing to do with X\", \"I never worked at Y\", \"that's not true\")\n- States it no longer holds (\"I no longer live in Berlin\", \"I left Google\")\n- Directly contradicts it (\"I'm based in Istanbul\" contradicts \"I am based in Ankara\")\n\nRules:\n- Only return ids that appear in the provided EXISTING PREMISES list — never invent ids.\n- Retract EVERY existing premise that matches the disavowed topic, not just the first one.\n- Do not retract premises the input merely omits — silence is not disavowal.\n- If no existing premises are provided, or nothing is disavowed, return an empty array.\n- Retraction and extraction are independent: an input can retract old premises AND\n contribute new ones in the same pass.\n\n═══════════════════════════════════════════════════\nBIO REVISION RULES\n═══════════════════════════════════════════════════\n\nWhen the message includes the user's CURRENT BIO, check whether the input disavows,\nremoves, or corrects anything that appears in it.\n\n- If it does, return \\`revisedBio\\`: the bio rewritten with those facts removed or\n corrected. Preserve everything the input does not dispute — same tone, similar\n length, no inventions.\n- If the input explicitly rewrites the bio (\"update my bio to X\"), return that\n rewritten bio.\n- NEVER add new facts to the bio — new information becomes premises, not bio edits.\n Purely additive input (\"I also enjoy X\") must return revisedBio: null.\n- If the bio is unaffected, or no CURRENT BIO was provided, return null.\n- Never return a revised bio that still mentions a disavowed fact.\n\n═══════════════════════════════════════════════════\nEXAMPLES\n═══════════════════════════════════════════════════\n\nInput: \"I'm a climate tech founder based in Berlin. I have a PhD in renewable energy systems and I'm currently raising Series A.\"\nOutput:\n 1. \"I am a climate tech founder\" (assertive, validityDays: null)\n 2. \"I am based in Berlin\" (assertive, validityDays: null)\n 3. \"I hold a PhD in renewable energy systems\" (assertive, validityDays: null)\n 4. \"I am currently raising Series A\" (contextual, validityDays: 120)\n\nInput: \"John Doe is a senior ML engineer at Meta in Menlo Park. He has 8 years of experience in NLP and computer vision.\"\nOutput:\n 1. \"I am a senior ML engineer\" (assertive, validityDays: null)\n 2. \"I work at Meta\" (assertive, validityDays: null)\n 3. \"I am based in Menlo Park\" (assertive, validityDays: null)\n 4. \"I have 8 years of experience in NLP\" (assertive, validityDays: null)\n 5. \"I have experience in computer vision\" (assertive, validityDays: null)\n\nInput: \"Yes, create my profile\"\nOutput: [] (empty — no premises)\n\nInput: \"Remove all mentions of the HOPE programming language. I have nothing to do with it. I specialize in compiler design.\"\nExisting premises:\n - id: aaaa-1 · \"I am the creator of the HOPE programming language\"\n - id: aaaa-2 · \"I specialize in compiler design\"\n - id: aaaa-3 · \"I am based in Istanbul\"\nCurrent bio: \"Software engineer in Istanbul. Creator of the HOPE programming language. Specializes in compiler design.\"\nOutput:\n premises: [] (compiler design already exists as aaaa-2 — nothing new to add)\n retractedPremiseIds: [\"aaaa-1\"]\n revisedBio: \"Software engineer in Istanbul. Specializes in compiler design.\"\n`;\n\nconst premiseItemSchema = z.object({\n text: z.string().describe(\"The premise text in first person (e.g. 'I am a software engineer at Google')\"),\n tier: z.enum([\"assertive\", \"contextual\"]).describe(\n \"assertive = stable identity fact; contextual = temporal/situational\"\n ),\n validityDays: z.number().int().positive().nullable().describe(\n \"For contextual premises: estimated days the fact remains true from now (its validity window). null for assertive premises, which do not expire.\"\n ),\n});\n\nconst responseFormat = z.object({\n reasoning: z.string().describe(\n \"Brief analysis of what factual claims can be extracted from the input\"\n ),\n premises: z.array(premiseItemSchema).describe(\n \"Array of extracted premises. Empty if input contains no self-descriptive facts.\"\n ),\n retractedPremiseIds: z.array(z.string()).default([]).describe(\n \"Ids of EXISTING premises (from the provided list) that the input disavows, denies, or asks to remove. Empty when nothing is disavowed or no existing premises were provided.\"\n ),\n revisedBio: z.string().nullable().default(null).describe(\n \"When the input disavows or corrects facts that appear in the provided CURRENT BIO, the bio rewritten without those facts (preserving everything else). null when the bio is unaffected or no bio was provided.\"\n ),\n});\n\n/** An existing ACTIVE premise offered to the decomposer for retraction matching. */\nexport interface ExistingPremiseRef {\n id: string;\n text: string;\n}\n\nexport type PremiseDecomposerOutput = z.infer<typeof responseFormat>;\nexport type DecomposedPremise = z.infer<typeof premiseItemSchema>;\n\n/**\n * Decomposes free-text input (chat messages, bios, scraped content) into\n * individual atomic premises suitable for the premise graph.\n */\nexport class PremiseDecomposer {\n private model: ReturnType<typeof createStructuredModel>;\n\n constructor() {\n this.model = createStructuredModel(\"premiseDecomposer\", responseFormat, {\n name: \"premise_decomposer\",\n });\n }\n\n @Timed()\n public async invoke(\n input: string,\n existingPremises?: ExistingPremiseRef[],\n currentBio?: string,\n options: { signal?: AbortSignal } = {},\n ): Promise<PremiseDecomposerOutput> {\n invokeLog.verbose('Decomposing input', {\n inputChars: input.length,\n existingPremiseCount: existingPremises?.length ?? 0,\n hasBio: Boolean(currentBio),\n });\n\n const existingBlock = existingPremises?.length\n ? `\\n\\nEXISTING PREMISES (retract by id when the input disavows them):\\n${existingPremises\n .map((p) => `- id: ${p.id} · \"${p.text}\"`)\n .join(\"\\n\")}`\n : \"\";\n\n const bioBlock = currentBio?.trim()\n ? `\\n\\nCURRENT BIO (return revisedBio when the input disavows or corrects anything in it):\\n${currentBio.trim()}`\n : \"\";\n\n const prompt = `Decompose the following text into individual premises:\\n\\n${input}${existingBlock}${bioBlock}`;\n\n const messages = [\n new SystemMessage(systemPrompt),\n new HumanMessage(prompt),\n ];\n\n const result = await invokeWithAbortSignal(this.model, messages, options.signal);\n const output = responseFormat.parse(result);\n\n // Guard against hallucinated ids: only keep retractions that reference premises we offered.\n const knownIds = new Set((existingPremises ?? []).map((p) => p.id));\n const droppedIds = output.retractedPremiseIds.filter((id) => !knownIds.has(id));\n if (droppedIds.length > 0) {\n invokeLog.warn('Dropped unknown retraction ids', { count: droppedIds.length, droppedIds });\n }\n output.retractedPremiseIds = output.retractedPremiseIds.filter((id) => knownIds.has(id));\n\n // A revised bio is only meaningful when we offered one to revise. Also\n // normalize structured-output quirks: literal \"null\", empty strings, and\n // no-op rewrites all mean \"bio unaffected\".\n const normalizedBio = output.revisedBio?.trim();\n if (\n !currentBio?.trim() ||\n !normalizedBio ||\n normalizedBio.toLowerCase() === 'null' ||\n normalizedBio === currentBio.trim()\n ) {\n output.revisedBio = null;\n } else {\n output.revisedBio = normalizedBio;\n }\n\n invokeLog.verbose('Extracted premises and retractions', {\n premiseCount: output.premises.length,\n retractionCount: output.retractedPremiseIds.length,\n hasRevisedBio: Boolean(output.revisedBio),\n });\n return output;\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"premise.graph.d.ts","sourceRoot":"/","sources":["premise/premise.graph.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,uBAAuB,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,eAAe,EAA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Content":["import { StateGraph, START, END } from \"@langchain/langgraph\";\n\nimport { PremiseGraphState } from \"./premise.state.js\";\nimport { PremiseAnalyzer } from \"./premise.analyzer.js\";\nimport type { PremiseAnalyzerOutput } from \"./premise.analyzer.js\";\nimport { PremiseIndexer } from \"./premise.indexer.js\";\n\nimport { buildNetworkAssignmentDecision, resolveAssignmentNetworkScope } from \"../shared/assignment/network-assignment.policy.js\";\nimport { getAbortSignalConfig } from \"../shared/agent/model-signal.js\";\nimport { scopeFromNetworkId } from \"../shared/agent/tool.scope.js\";\nimport type { PremiseGraphDatabase, PremiseAnalysis } from \"../shared/interfaces/database.interface.js\";\nimport type { Embedder } from \"../shared/interfaces/embedder.interface.js\";\nimport { protocolLogger } from \"../shared/observability/protocol.logger.js\";\nimport { timed } from \"../shared/observability/performance.js\";\nimport type { DebugMetaAgent } from \"../chat/chat-streaming.types.js\";\n\nconst logger = protocolLogger(\"PremiseGraphFactory\");\nconst queryLog = protocolLogger(\"PremiseGraph:query\");\nconst analyzeLog = protocolLogger(\"PremiseGraph:analyze\");\nconst embedLog = protocolLogger(\"PremiseGraph:embed\");\nconst persistLog = protocolLogger(\"PremiseGraph:persist\");\nconst indexLog = protocolLogger(\"PremiseGraph:index\");\nconst dedupeLog = protocolLogger(\"PremiseGraph:dedupe\");\n\n/**\n * Minimum cosine similarity (0-1) at which a freshly-decomposed premise is treated\n * as a near-duplicate of an existing ACTIVE premise for the same user and skipped\n * on create. Tuned high so genuine paraphrases collapse while distinct facts (e.g.\n * \"I work at Google\" vs \"I worked at Google\") still persist. Override with\n * PREMISE_DEDUP_SIMILARITY.\n */\nconst DEDUP_SIMILARITY_THRESHOLD = (() => {\n const raw = Number(process.env.PREMISE_DEDUP_SIMILARITY);\n return Number.isFinite(raw) && raw > 0 && raw <= 1 ? raw : 0.93;\n})();\n\n/**\n * Derive a premise provenance confidence (0-1) from the analyzer's felicity scores.\n * Averages authority, sincerity, and clarity — the dimensions that speak to how\n * trustworthy the self-assertion is. Falls back to 1.0 when no analysis is present.\n */\nfunction deriveProvenanceConfidence(analysis: PremiseAnalysis | undefined): number {\n if (!analysis) return 1.0;\n const { felicityAuthority, felicitySincerity, felicityClarity } = analysis;\n const mean = (felicityAuthority + felicitySincerity + felicityClarity) / 3;\n if (!Number.isFinite(mean)) return 1.0;\n return Math.min(1, Math.max(0, mean));\n}\n\n/**\n * Graph factory for premise lifecycle: create, update, and query modes.\n */\nexport class PremiseGraphFactory {\n constructor(\n private database: PremiseGraphDatabase,\n private embedder: Embedder,\n private premiseIndexer: PremiseIndexer = new PremiseIndexer(),\n private premiseAnalyzer: { invoke(premiseText: string, profileContext?: string): Promise<PremiseAnalyzerOutput> } = new PremiseAnalyzer(),\n ) {}\n\n /**\n * Compiles and returns the premise lifecycle graph.\n *\n * @returns A compiled LangGraph graph handling create, update, and query modes.\n */\n public createGraph() {\n const analyzer = this.premiseAnalyzer;\n const indexer = this.premiseIndexer;\n\n const queryNode = async (state: typeof PremiseGraphState.State) => {\n return timed(\"PremiseGraph.query\", async () => {\n queryLog.verbose('Fetching premises for user', { userId: state.userId });\n const premises = await this.database.getPremisesForUser(state.userId, 'ACTIVE');\n return {\n readResult: {\n premises,\n count: premises.length,\n },\n };\n });\n };\n\n const analyzeNode = async (state: typeof PremiseGraphState.State) => {\n return timed(\"PremiseGraph.analyze\", async () => {\n if (!state.assertionText) {\n return { error: \"assertionText is required for create/update mode\" };\n }\n\n analyzeLog.verbose('Analyzing assertion text', { preview: state.assertionText.substring(0, 50) });\n\n const start = Date.now();\n const result = await analyzer.invoke(state.assertionText);\n const timing: DebugMetaAgent = {\n name: \"premise-analyzer\",\n durationMs: Date.now() - start,\n };\n\n const analysis: PremiseAnalysis = {\n speechActType: result.speechActType,\n felicityAuthority: result.felicityAuthority,\n felicitySincerity: result.felicitySincerity,\n felicityClarity: result.felicityClarity,\n semanticEntropy: result.semanticEntropy,\n };\n\n return { analysis, agentTimings: [timing] };\n });\n };\n\n const embedNode = async (state: typeof PremiseGraphState.State) => {\n return timed(\"PremiseGraph.embed\", async () => {\n if (state.error) return {};\n\n if (!state.assertionText) {\n return { error: \"assertionText is required for embedding\" };\n }\n\n embedLog.verbose(`Generating embedding for premise`);\n\n // Embedder.generate returns number[] | number[][], cast for single string input\n const embedding = await this.embedder.generate(state.assertionText, undefined, getAbortSignalConfig()) as number[];\n return { embedding };\n });\n };\n\n // ─────────────────────────────────────────────────────────\n // NODE: Dedupe (create mode only)\n // Skips persisting a near-duplicate of an existing ACTIVE premise for the same\n // user. Re-running similar input (e.g. repeated enrichment) therefore does not\n // accumulate near-identical premises. No-op for update mode, when no embedding\n // is available, or when the adapter does not implement findSimilarActivePremise.\n // ─────────────────────────────────────────────────────────\n const dedupeNode = async (state: typeof PremiseGraphState.State) => {\n return timed(\"PremiseGraph.dedupe\", async () => {\n if (state.error) return {};\n if (state.operationMode === 'update') return {};\n if (!state.embedding || state.embedding.length === 0) return {};\n if (typeof this.database.findSimilarActivePremise !== 'function') return {};\n\n const match = await this.database.findSimilarActivePremise({\n userId: state.userId,\n embedding: state.embedding,\n threshold: DEDUP_SIMILARITY_THRESHOLD,\n });\n\n if (match) {\n dedupeLog.verbose('Skipping near-duplicate premise', {\n similarity: Number(match.similarity.toFixed(3)),\n threshold: DEDUP_SIMILARITY_THRESHOLD,\n premiseId: match.premiseId,\n });\n return { duplicateOf: match };\n }\n return {};\n });\n };\n\n const persistNode = async (state: typeof PremiseGraphState.State) => {\n return timed(\"PremiseGraph.persist\", async () => {\n if (state.error) return {};\n\n if (state.operationMode === 'update' && !state.targetPremiseId) {\n return { error: \"targetPremiseId is required for update mode\" };\n }\n\n if (state.operationMode === 'update' && state.targetPremiseId) {\n persistLog.verbose('Updating premise', { premiseId: state.targetPremiseId });\n\n const updated = await this.database.updatePremise(state.targetPremiseId, {\n assertion: {\n text: state.assertionText!,\n tier: state.tier,\n },\n analysis: state.analysis ?? undefined,\n validity: {\n validFrom: state.validFrom,\n validUntil: state.validUntil,\n volatile: state.volatile,\n },\n embedding: state.embedding,\n });\n return { premise: updated };\n }\n\n persistLog.verbose('Creating new premise for user', { userId: state.userId });\n\n // Provenance confidence: prefer an explicit caller-supplied value; otherwise\n // derive it from the analyzer's felicity scores (how authoritative, sincere,\n // and clear the assertion is) rather than a blanket 1.0, so the stored\n // provenance reflects per-premise signal quality.\n const derivedConfidence = deriveProvenanceConfidence(state.analysis);\n const premise = await this.database.createPremise({\n userId: state.userId,\n assertion: {\n text: state.assertionText!,\n tier: state.tier,\n },\n provenance: {\n source: state.provenanceSource ?? 'explicit',\n sourceId: state.provenanceSourceId,\n confidence: state.provenanceConfidence ?? derivedConfidence,\n timestamp: new Date().toISOString(),\n },\n analysis: state.analysis ?? undefined,\n validity: {\n validFrom: state.validFrom,\n validUntil: state.validUntil,\n volatile: state.volatile,\n },\n embedding: state.embedding,\n });\n return { premise };\n });\n };\n\n const indexNode = async (state: typeof PremiseGraphState.State) => {\n return timed(\"PremiseGraph.index\", async () => {\n if (!state.premise) return {};\n\n indexLog.verbose(`Scoring premise against user networks`);\n\n const assignmentMemberships = await this.database.getAssignmentNetworkMembershipsForUser(state.userId);\n const requestScope = state.scopeType && state.scopeId\n ? { scopeType: state.scopeType, scopeId: state.scopeId }\n : scopeFromNetworkId(state.networkScopeId);\n const indexIds = resolveAssignmentNetworkScope({\n memberships: assignmentMemberships,\n ...requestScope,\n });\n const scope = requestScope.scopeType ? \"network\" : \"global\";\n const assignments: Array<{ networkId: string; relevancyScore: number }> = [];\n const agentTimings: DebugMetaAgent[] = [];\n\n for (const networkId of indexIds) {\n try {\n const assignmentContext = await this.database.getNetworkAssignmentContext(networkId, state.userId);\n if (!assignmentContext) continue;\n const indexPrompt = assignmentContext.indexPrompt;\n const memberPrompt = assignmentContext.memberPrompt;\n const hasPrompts = !!indexPrompt?.trim() || !!memberPrompt?.trim();\n let rawScores: { indexScore?: number; memberScore?: number } | undefined;\n let reason: string | undefined;\n\n if (hasPrompts) {\n const start = Date.now();\n const result = await indexer.invoke({\n premiseText: state.assertionText!,\n indexPrompt: indexPrompt ?? \"\",\n memberPrompt: memberPrompt ?? undefined,\n });\n const timing: DebugMetaAgent = {\n name: \"premise-indexer\",\n durationMs: Date.now() - start,\n };\n rawScores = { indexScore: result.indexScore, memberScore: result.memberScore };\n reason = result.reasoning;\n agentTimings.push(timing);\n }\n\n const decision = buildNetworkAssignmentDecision({\n resourceType: \"premise\",\n mode: \"automatic\",\n scope,\n indexPrompt,\n memberPrompt,\n rawScores,\n evaluator: \"premise-indexer\",\n source: \"premise-graph\",\n reason,\n createdAt: new Date().toISOString(),\n });\n\n if (decision.assigned) {\n await this.database.assignPremiseToNetwork(\n state.premise.id,\n networkId,\n decision.finalScore,\n decision.metadata,\n );\n assignments.push({ networkId, relevancyScore: decision.finalScore });\n }\n } catch (err) {\n indexLog.verbose('Failed to score network, skipping', { networkId, error: err });\n }\n }\n\n indexLog.verbose('Assigned to networks', { count: assignments.length });\n\n return { networkAssignments: assignments, agentTimings };\n });\n };\n\n const routeByMode = (state: typeof PremiseGraphState.State) => {\n if (state.error) return \"end\";\n if (state.operationMode === 'query') return \"query\";\n return \"analyze\";\n };\n\n const graph = new StateGraph(PremiseGraphState)\n .addNode(\"query\", queryNode)\n .addNode(\"analyze\", analyzeNode)\n .addNode(\"embed\", embedNode)\n .addNode(\"dedupe\", dedupeNode)\n .addNode(\"persist\", persistNode)\n .addNode(\"index\", indexNode)\n .addConditionalEdges(START, routeByMode, {\n query: \"query\",\n analyze: \"analyze\",\n end: END,\n })\n .addEdge(\"query\", END)\n .addEdge(\"analyze\", \"embed\")\n .addEdge(\"embed\", \"dedupe\")\n // A near-duplicate short-circuits straight to END (no persist, no index).\n .addConditionalEdges(\"dedupe\", (state: typeof PremiseGraphState.State) => (state.duplicateOf ? \"end\" : \"persist\"), {\n persist: \"persist\",\n end: END,\n })\n .addEdge(\"persist\", \"index\")\n .addEdge(\"index\", END);\n\n return graph.compile();\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"premise.indexer.d.ts","sourceRoot":"/","sources":["premise/premise.indexer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAiCxB,QAAA,MAAM,cAAc;;;;;;;;;;;;EAIlB,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAElE;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAA2C;;IAQxD;;;;;OAKG;IAEU,MAAM,CAAC,KAAK,EAAE;QACzB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;QACpB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GAAG,OAAO,CAAC,oBAAoB,CAAC;CAuBlC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"premise.indexer.js","sourceRoot":"/","sources":["premise/premise.indexer.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,MAAM,GAAG,cAAc,CAAC,gBAAgB,CAAC,CAAC;AAChD,MAAM,SAAS,GAAG,cAAc,CAAC,uBAAuB,CAAC,CAAC;AAE1D,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;CAsBpB,CAAC;AAEF,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,UAAU,EAAE,C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,CAAC,CAAC;IACtC,CAAC;CACF;AA5Bc;IADZ,KAAK,EAAE;;;;4CA4BP","sourcesContent":["import { HumanMessage, SystemMessage } from \"@langchain/core/messages\";\nimport { z } from \"zod\";\nimport { protocolLogger } from \"../shared/observability/protocol.logger.js\";\nimport { Timed } from \"../shared/observability/performance.js\";\nimport { createStructuredModel } from \"../shared/agent/model.config.js\";\nimport { invokeWithAbortSignal } from \"../shared/agent/model-signal.js\";\n\nconst logger = protocolLogger(\"PremiseIndexer\");\nconst invokeLog = protocolLogger(\"PremiseIndexer:invoke\");\n\nconst systemPrompt = `\nYou are a Premise Evaluator for a social networking protocol.\n\nTASK:\nDetermine if a User Premise (a self-descriptive proposition about who someone is) is relevant to a specific Index (community).\n\nINPUTS:\n1. Premise: A self-description the user asserts about themselves.\n2. Network Prompt: The purpose/scope of the target community (Index).\n3. Member Prompt: The specific sharing preferences of the user in that community (optional).\n\nSCORING RUBRIC:\n- 0.9-1.0: Highly relevant. The premise directly relates to the community's purpose.\n- 0.7-0.8: Good relevance. The premise is clearly adjacent to the community's focus.\n- 0.5-0.6: Moderate. Borderline relevance.\n- 0.3-0.4: Low relevance. Weak connection.\n- 0.0-0.2: Not relevant. The premise has no connection to this community.\n\nOUTPUT RULES:\n- Provide indexScore based on how well the Premise fits the Network Prompt.\n- Provide memberScore based on how well the Premise fits the Member Prompt (if provided). If Member Prompt is missing/empty, return 0.0.\n- Provide concise reasoning.\n`;\n\nconst responseFormat = z.object({\n indexScore: z.number().min(0).max(1).describe(\"Score for index relevance (0.0-1.0)\"),\n memberScore: z.number().min(0).max(1).describe(\"Score for member preference match (0.0-1.0)\"),\n reasoning: z.string().describe(\"Brief reasoning for the scores\"),\n});\n\nexport type PremiseIndexerOutput = z.infer<typeof responseFormat>;\n\n/**\n * Scores a premise's relevancy to a network based on the index and member prompts.\n */\nexport class PremiseIndexer {\n private model: ReturnType<typeof createStructuredModel>;\n\n constructor() {\n this.model = createStructuredModel(\"premiseIndexer\", responseFormat, {\n name: \"premise_indexer\"\n });\n }\n\n /**\n * Scores the relevancy of a premise to a network index and member preferences.\n *\n * @param input - The premise text, network prompt, member prompt, and optional network context.\n * @returns Structured output with indexScore, memberScore, and reasoning.\n */\n @Timed()\n public async invoke(input: {\n premiseText: string;\n indexPrompt: string;\n memberPrompt?: string;\n networkContext?: string;\n }): Promise<PremiseIndexerOutput> {\n invokeLog.verbose(`Scoring premise against index`);\n\n const prompt = [\n \"# Premise\",\n input.premiseText,\n \"\",\n \"# Network Prompt\",\n input.indexPrompt || \"(No network prompt provided)\",\n \"\",\n \"# Member Prompt\",\n input.memberPrompt || \"(No member prompt provided)\",\n ...(input.networkContext ? [\"\", \"# Network Context\", input.networkContext] : []),\n ].join(\"\\n\");\n\n const messages = [\n new SystemMessage(systemPrompt),\n new HumanMessage(prompt),\n ];\n\n const result = await invokeWithAbortSignal(this.model, messages);\n return responseFormat.parse(result);\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"premise.state.d.ts","sourceRoot":"/","sources":["premise/premise.state.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAqB,aAAa,EAAE,MAAM,4CAA4C,CAAC;AACpH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AACtE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AAEnE,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;IAgD5B,wDAAwD;;IAMxD,6FAA6F;;IAM7F,0FAA0F;;;;;;;mBA6BrD,MAAM;uBAAiB,MAAM;oBAAc,MAAM;;mBAAjD,MAAM;uBAAiB,MAAM;oBAAc,MAAM;;mBAAjD,MAAM;uBAAiB,MAAM;oBAAc,MAAM;;;mBAKpC,MAAM;wBAAkB,MAAM;;mBAA9B,MAAM;wBAAkB,MAAM;;mBAA9B,MAAM;wBAAkB,MAAM;;;;kBAWpE,aAAa,EAAE;eAClB,MAAM;kBACH,MAAM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,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":["import { Annotation } from \"@langchain/langgraph\";\nimport type { PremiseAnalysis, PremiseProvenance, PremiseRecord } from \"../shared/interfaces/database.interface.js\";\nimport type { DebugMetaAgent } from '../chat/chat-streaming.types.js';\nimport type { ToolScopeType } from '../shared/agent/tool.scope.js';\n\nexport const PremiseGraphState = Annotation.Root({\n userId: Annotation<string>,\n\n assertionText: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n tier: Annotation<'assertive' | 'contextual'>({\n reducer: (curr, next) => next ?? curr,\n default: () => 'assertive',\n }),\n\n validFrom: Annotation<string | undefined>({\n reducer: (curr, next) => next,\n default: () => undefined,\n }),\n\n validUntil: Annotation<string | undefined>({\n reducer: (curr, next) => next,\n default: () => undefined,\n }),\n\n volatile: Annotation<boolean>({\n reducer: (curr, next) => next ?? curr,\n default: () => false,\n }),\n\n provenanceSource: Annotation<PremiseProvenance['source'] | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n provenanceSourceId: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n provenanceConfidence: Annotation<number | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n operationMode: Annotation<'create' | 'update' | 'query'>({\n reducer: (curr, next) => next ?? curr,\n default: () => 'create',\n }),\n\n /** Focused request scope type for assignment writes. */\n scopeType: Annotation<ToolScopeType | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n /** Focused request scope id. When scopeType is `network`, this is the focused network id. */\n scopeId: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n /** @deprecated Use scopeType/scopeId. Retained temporarily for older enqueue handlers. */\n networkScopeId: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n targetPremiseId: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n analysis: Annotation<PremiseAnalysis | undefined>({\n reducer: (curr, next) => next,\n default: () => undefined,\n }),\n\n embedding: Annotation<number[] | undefined>({\n reducer: (curr, next) => next,\n default: () => undefined,\n }),\n\n premise: Annotation<PremiseRecord | undefined>({\n reducer: (curr, next) => next,\n default: () => undefined,\n }),\n\n // Set by the dedupe node when a near-duplicate ACTIVE premise already exists for\n // the user (create mode only). When present, persist/index are skipped — the\n // candidate is treated as already represented by `duplicateOf`.\n duplicateOf: Annotation<{ premiseId: string; assertionText: string; similarity: number } | undefined>({\n reducer: (curr, next) => next,\n default: () => undefined,\n }),\n\n networkAssignments: Annotation<Array<{ networkId: string; relevancyScore: number }>>({\n reducer: (curr, next) => next,\n default: () => [],\n }),\n\n error: Annotation<string | undefined>({\n reducer: (curr, next) => next ?? curr,\n default: () => undefined,\n }),\n\n readResult: Annotation<{\n premises: PremiseRecord[];\n count: number;\n message?: string;\n } | undefined>({\n reducer: (curr, next) => next,\n default: () => undefined,\n }),\n\n agentTimings: Annotation<DebugMetaAgent[]>({\n reducer: (acc, val) => [...acc, ...val],\n default: () => [],\n }),\n});\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"premise.tools.d.ts","sourceRoot":"/","sources":["premise/premise.tools.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAY5E,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,SAuRxE"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"premise.tools.js","sourceRoot":"/","sources":["premise/premise.tools.ts"],"names":[],"mappings":"AAAA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CAAC","sourcesContent":["import { z } from \"zod\";\n\nimport type { DefineTool, ToolDeps } from \"../shared/agent/tool.helpers.js\";\nimport { success, error, UUID_REGEX } from \"../shared/agent/tool.helpers.js\";\nimport { protocolLogger } from \"../shared/observability/protocol.logger.js\";\nimport type { PremiseRecord, PremiseValidity } from \"../shared/interfaces/database.interface.js\";\nimport { invokeWithAbortSignal } from \"../shared/agent/model-signal.js\";\n\nconst logger = protocolLogger(\"ChatTools:Premise\");\nconst createPremiseLog = protocolLogger(\"ChatTools:Premise:createPremise\");\nconst readPremisesLog = protocolLogger(\"ChatTools:Premise:readPremises\");\nconst updatePremiseLog = protocolLogger(\"ChatTools:Premise:updatePremise\");\nconst retractPremiseLog = protocolLogger(\"ChatTools:Premise:retractPremise\");\n\nexport function createPremiseTools(defineTool: DefineTool, deps: ToolDeps) {\n const database = deps.database;\n const premiseGraph = deps.graphs.premise;\n\n // ─────────────────────────────────────────────────────────────────────────────\n // PREMISE CRUD\n // ─────────────────────────────────────────────────────────────────────────────\n\n const createPremise = defineTool({\n name: \"create_premise\",\n description:\n \"Creates a premise — a self-descriptive proposition the user asserts about themselves. \" +\n \"Premises are the foundational facts that shape how the system understands who you are \" +\n \"and what contexts you inhabit.\\n\\n\" +\n \"**Tiers:**\\n\" +\n \"- `assertive` (default): stable identity facts (e.g. 'I am a software engineer', 'I live in Berlin'). \" +\n \"Use for things that are durably true and not time-bound.\\n\" +\n \"- `contextual`: temporal or situational facts (e.g. 'I am attending DevCon this week', \" +\n \"'I am fundraising for my Series A right now'). Use when the user shares something time-bound \" +\n \"or context-specific. These default to `volatile: true`.\\n\\n\" +\n \"**When to use:** Call this whenever the user shares a fact about themselves in first person \" +\n \"('I am', 'I work at', 'I just joined', 'I am currently'). Do not infer premises from vague \" +\n \"statements — only create them when the user is clearly asserting something about themselves.\",\n querySchema: z.object({\n text: z.string().trim().min(1).describe(\"The premise text — a self-descriptive proposition in first person, e.g. 'I am a machine learning researcher at MIT'.\"),\n tier: z.enum([\"assertive\", \"contextual\"]).default(\"assertive\").describe(\"Tier of the premise. 'assertive' = stable identity fact. 'contextual' = temporal/situational. Defaults to 'assertive'.\"),\n validFrom: z.string().datetime().optional().describe(\"ISO 8601 date-time string for when this premise becomes valid. Omit for immediate.\"),\n validUntil: z.string().datetime().optional().describe(\"ISO 8601 date-time string for when this premise expires. Recommended for contextual premises with a known end date; omit if open-ended.\"),\n volatile: z.boolean().optional().describe(\"Whether this premise should be automatically retracted when it expires. Defaults to true for contextual tier, false for assertive.\"),\n }),\n handler: async ({ context, query }) => {\n if (!premiseGraph) {\n return error(\"Premise graph not available.\");\n }\n\n const effectiveVolatile = query.volatile ?? (query.tier === \"contextual\" ? true : false);\n const scopeEnvelope = context.scopeType && context.scopeId\n ? { scopeType: context.scopeType, scopeId: context.scopeId }\n : {};\n\n createPremiseLog.verbose('Creating premise for user', { userId: context.userId, preview: query.text.substring(0, 60) });\n\n const result = await invokeWithAbortSignal(premiseGraph, {\n userId: context.userId,\n assertionText: query.text,\n tier: query.tier,\n validFrom: query.validFrom,\n validUntil: query.validUntil,\n volatile: effectiveVolatile,\n operationMode: \"create\",\n ...scopeEnvelope,\n });\n\n if (result.error) {\n return error(result.error);\n }\n\n if (!result.premise) {\n return error(\"Premise creation failed — no premise returned.\");\n }\n\n const premise = result.premise;\n const indexesAssigned = result.networkAssignments?.length ?? 0;\n const analysisSummary = premise.analysis\n ? `speechActType: ${premise.analysis.speechActType}, clarity: ${premise.analysis.felicityClarity?.toFixed(2) ?? \"n/a\"}`\n : \"no analysis\";\n\n const createResult = success({\n id: premise.id,\n assertion: premise.assertion.text,\n tier: premise.assertion.tier,\n analysisSummary,\n indexesAssigned,\n message: `Premise created and assigned to ${indexesAssigned} index${indexesAssigned === 1 ? \"\" : \"es\"}.`,\n });\n return createResult;\n },\n });\n\n const readPremises = defineTool({\n name: \"read_premises\",\n description:\n \"Retrieves premises — the self-descriptive propositions a user has asserted about themselves. \" +\n \"Premises represent stable identity facts (assertive) and temporal context (contextual).\\n\\n\" +\n \"**Usage modes:**\\n\" +\n \"- No parameters: returns the caller's own active premises.\\n\" +\n \"- With `userId`: returns that user's premises (use when reviewing another member's context).\\n\" +\n \"- With `includeRetracted: true`: returns all premises regardless of status (active, retracted, expired) for history review.\\n\\n\" +\n \"**When to use:** Call before creating a premise to check if it already exists. \" +\n \"Call when the user asks what they have shared about themselves, or to review their current context. \" +\n \"Each premise includes: id, text, tier, status, analysis summary, and validity range.\",\n querySchema: z.object({\n userId: z.string().optional().describe(\"User ID to fetch premises for. Omit to fetch the current user's own premises.\"),\n includeRetracted: z.boolean().default(false).describe(\"When true, returns all premises regardless of status (active, retracted, expired). Defaults to false (active only).\"),\n }),\n handler: async ({ context, query }) => {\n const targetUserId = query.userId?.trim() || context.userId;\n\n if (query.userId?.trim() && !UUID_REGEX.test(query.userId.trim())) {\n return error(\"Invalid userId format.\");\n }\n\n readPremisesLog.verbose('Fetching premises for user', { userId: targetUserId });\n\n // Query DB directly (bypassing graph) to support status filtering.\n // The graph's query node hardcodes ACTIVE status, so includeRetracted\n // would be dead code if we routed through it.\n const statusFilter = query.includeRetracted ? undefined : \"ACTIVE\" as const;\n const premises = await database.getPremisesForUser(targetUserId, statusFilter);\n\n const mapped = premises.map((p: PremiseRecord) => ({\n id: p.id,\n text: p.assertion.text,\n tier: p.assertion.tier,\n status: p.status,\n analysisSummary: p.analysis\n ? `speechActType: ${p.analysis.speechActType ?? \"n/a\"}, clarity: ${p.analysis.felicityClarity?.toFixed(2) ?? \"n/a\"}`\n : \"no analysis\",\n validFrom: p.validity.validFrom ?? null,\n validUntil: p.validity.validUntil ?? null,\n volatile: p.validity.volatile ?? false,\n }));\n\n return success({\n premises: mapped,\n count: mapped.length,\n });\n },\n });\n\n const updatePremise = defineTool({\n name: \"update_premise\",\n description:\n \"Modifies an existing premise. Updating the text triggers re-analysis and re-embedding, \" +\n \"which may change how it influences opportunity discovery. \" +\n \"Use when the user corrects or refines something they previously stated about themselves, \" +\n \"or when validity dates need adjustment.\\n\\n\" +\n \"**When to use:** When the user says 'actually, I meant...', 'update my premise about...', \" +\n \"or provides a corrected version of a previously stated fact. \" +\n \"Requires the premise ID — call read_premises first if you don't have it.\",\n querySchema: z.object({\n premiseId: z.string().describe(\"UUID of the premise to update. Get from read_premises.\"),\n text: z.string().trim().min(1).optional().describe(\"New assertion text. Triggers re-analysis and re-embedding when provided.\"),\n validFrom: z.string().datetime().optional().describe(\"New ISO 8601 valid-from date-time.\"),\n validUntil: z.string().datetime().optional().describe(\"New ISO 8601 valid-until date-time.\"),\n volatile: z.boolean().optional().describe(\"Update the volatile flag.\"),\n }),\n handler: async ({ context, query }) => {\n if (!UUID_REGEX.test(query.premiseId)) {\n return error(\"Invalid premiseId format.\");\n }\n\n const existing = await database.getPremise(query.premiseId);\n if (!existing) {\n return error(\"Premise not found.\");\n }\n if (existing.userId !== context.userId) {\n return error(\"You can only update your own premises.\");\n }\n if (existing.status === \"RETRACTED\") {\n return error(\"Cannot update a retracted premise. Retracted premises are immutable.\");\n }\n\n updatePremiseLog.verbose('Updating premise for user', { premiseId: query.premiseId, userId: context.userId });\n\n // When text is unchanged, skip the graph (avoids unnecessary LLM\n // re-analysis and non-deterministic re-embedding). Only route through\n // the graph when the assertion text actually changes.\n if (query.text === undefined) {\n const hasValidityChange =\n query.validFrom !== undefined ||\n query.validUntil !== undefined ||\n query.volatile !== undefined;\n\n if (!hasValidityChange) {\n return error(\"No fields to update. Provide text, validFrom, validUntil, or volatile.\");\n }\n\n const mergedValidity: PremiseValidity = {\n ...existing.validity,\n ...(query.validFrom !== undefined && { validFrom: query.validFrom }),\n ...(query.validUntil !== undefined && { validUntil: query.validUntil }),\n ...(query.volatile !== undefined && { volatile: query.volatile }),\n };\n\n const updated = await database.updatePremise(query.premiseId, { validity: mergedValidity });\n\n const metadataResult = success({\n id: updated.id,\n assertion: updated.assertion.text,\n tier: updated.assertion.tier,\n status: updated.status,\n message: \"Premise updated successfully (metadata only, no re-analysis).\",\n });\n return metadataResult;\n }\n\n // Text change requires the graph for re-analysis and re-embedding\n if (!premiseGraph) {\n return error(\"Premise graph not available.\");\n }\n\n const result = await invokeWithAbortSignal(premiseGraph, {\n userId: context.userId,\n assertionText: query.text,\n tier: existing.assertion.tier,\n validFrom: query.validFrom ?? existing.validity.validFrom ?? undefined,\n validUntil: query.validUntil ?? existing.validity.validUntil ?? undefined,\n volatile: query.volatile ?? existing.validity.volatile,\n operationMode: \"update\",\n targetPremiseId: query.premiseId,\n ...(context.scopeType && context.scopeId ? { scopeType: context.scopeType, scopeId: context.scopeId } : {}),\n });\n\n if (result.error) {\n return error(result.error);\n }\n\n if (!result.premise) {\n return error(\"Premise update failed — no updated premise returned.\");\n }\n\n const updated = result.premise;\n\n const updateResult = success({\n id: updated.id,\n assertion: updated.assertion.text,\n tier: updated.assertion.tier,\n status: updated.status,\n message: \"Premise updated successfully.\",\n });\n return updateResult;\n },\n });\n\n const retractPremise = defineTool({\n name: \"retract_premise\",\n description:\n \"Retracts a premise — a soft delete that preserves the history of what was asserted. \" +\n \"Retracted premises are no longer active but remain in the audit trail. \" +\n \"Use when the user explicitly wants to remove something they previously stated about themselves, \" +\n \"or when a contextual premise is no longer true.\\n\\n\" +\n \"**When to use:** When the user says 'remove my premise about...', 'I no longer...', \" +\n \"or 'that's not true anymore'. Do not retract premises proactively — only on explicit user instruction.\",\n querySchema: z.object({\n premiseId: z.string().describe(\"UUID of the premise to retract. Get from read_premises.\"),\n }),\n handler: async ({ context, query }) => {\n if (!UUID_REGEX.test(query.premiseId)) {\n return error(\"Invalid premiseId format.\");\n }\n\n const existing = await database.getPremise(query.premiseId);\n if (!existing) {\n return error(\"Premise not found.\");\n }\n if (existing.userId !== context.userId) {\n return error(\"You can only retract your own premises.\");\n }\n if (existing.status === \"RETRACTED\") {\n return error(\"Premise is already retracted.\");\n }\n\n retractPremiseLog.verbose('Retracting premise for user', { premiseId: query.premiseId, userId: context.userId });\n\n await database.updatePremise(query.premiseId, {\n status: \"RETRACTED\",\n retractedAt: new Date(),\n });\n\n const retractResult = success({\n id: query.premiseId,\n message: \"Premise retracted successfully.\",\n });\n return retractResult;\n },\n });\n\n return [createPremise, readPremises, updatePremise, retractPremise];\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"questioner.agent.d.ts","sourceRoot":"/","sources":["questioner/questioner.agent.ts"],"names":[],"mappings":"AAWA,OAAO,EAAkD,KAAK,wBAAwB,EAAoD,MAAM,sCAAsC,CAAC;AACvL,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAKxE,OAAO,EAAkC,KAAK,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAO7F,MAAM,WAAW,qBAAqB;IACpC,sCAAsC;IACtC,WAAW,CAAC,EAAE,UAAU,CAAC,OAAO,qBAAqB,CAAC,CAAC,CAAC,CAAC,CAAC;CAC3D;AAED;;;;GAIG;AACH,qBAAa,eAAe;IAC1B,OAAO,CAAC,KAAK,CAA2C;gBAE5C,MAAM,CAAC,EAAE,qBAAqB;IAM1C;;;;;;;;OAQG;IAEG,MAAM,CACV,KAAK,EAAE,eAAe,EACtB,OAAO,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,WAAW,CAAA;KAAE,GACjC,OAAO,CAAC,wBAAwB,GAAG,IAAI,CAAC;CAmD5C"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"questioner.agent.js","sourceRoot":"/","sources":["questioner/questioner.agent.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,EAAE,+BAA+B,EAAkG,MAAM,sCAAsC,CAAC;AACvL,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,C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AAC;AACb,CAAC;AAED,SAAS,qBAAqB,CAAC,CAAuB;IACpD,MAAM,EACJ,QAAQ,EAAE,SAAS,EACnB,sBAAsB,EAAE,uBAAuB,EAC/C,GAAG,WAAW,EACf,GAAG,CAAC,CAAC;IACN,OAAO,WAAW,CAAC;AACrB,CAAC","sourcesContent":["/**\n * QuestionerAgent — stateless, mode-driven agent that generates structured\n * decision questions from arbitrary protocol contexts.\n *\n * Follows the IndexNegotiator pattern: constructor takes optional config,\n * single public `invoke()` method receives the full context per call.\n * The LLM model is bound once at construction; the preset (system prompt +\n * builder) is selected per invocation based on `input.mode`.\n */\nimport { HumanMessage, SystemMessage } from \"@langchain/core/messages\";\n\nimport { QuestionGeneratorResponseSchema, type Question, type QuestionGenerationResult, type QuestionStrategy, type QuestionWithStrategy } from \"../shared/schemas/question.schema.js\";\nimport { createStructuredModel } from \"../shared/agent/model.config.js\";\nimport { invokeWithAbortSignal } from \"../shared/agent/model-signal.js\";\nimport { protocolLogger } from \"../shared/observability/protocol.logger.js\";\nimport { Timed } from \"../shared/observability/performance.js\";\nimport { getPreset } from \"./questioner.presets.js\";\nimport { isValidQuestionerInputContract, type QuestionerInput } from \"./questioner.types.js\";\n\nconst logger = protocolLogger(\"QuestionerAgent\");\n\n/** Maximum same-strategy questions allowed in a single emission. */\nconst MAX_SAME_STRATEGY = 2;\n\nexport interface QuestionerAgentConfig {\n /** Optional model config override. */\n modelConfig?: Parameters<typeof createStructuredModel>[3];\n}\n\n/**\n * Stateless question-generation agent. Accepts a `QuestionerInput` envelope,\n * selects the preset for the given mode, invokes the LLM, and applies\n * guardrails (dedup + strategy diversity).\n */\nexport class QuestionerAgent {\n private model: ReturnType<typeof createStructuredModel>;\n\n constructor(config?: QuestionerAgentConfig) {\n this.model = createStructuredModel(\"questioner\", QuestionGeneratorResponseSchema, {\n name: \"clarifying_questions\",\n }, config?.modelConfig);\n }\n\n /**\n * Generate up to 3 decision questions from the given input.\n *\n * @param input Envelope with mode, userId, source info, and mode-specific context.\n * @param options.signal Optional AbortSignal to cancel the in-flight LLM call.\n * @returns A result with parallel questions[] and strategies[] arrays,\n * or null when generation failed, guardrails dropped all candidates,\n * the LLM threw, or the call was aborted.\n */\n @Timed()\n async invoke(\n input: QuestionerInput,\n options?: { signal?: AbortSignal },\n ): Promise<QuestionGenerationResult | null> {\n if (!isValidQuestionerInputContract(input)) {\n logger.warn('QuestionerAgent rejected invalid mode/purpose/context contract', { mode: input.mode });\n return null;\n }\n const preset = getPreset(input.mode, input.purpose);\n const userMessage = preset.buildPrompt(input.context);\n\n let raw: unknown;\n try {\n raw = await invokeWithAbortSignal(\n this.model,\n [new SystemMessage(preset.systemPrompt), new HumanMessage(userMessage)],\n options?.signal,\n );\n } catch (err) {\n const aborted = options?.signal?.aborted ?? false;\n if (aborted) {\n logger.info(\"QuestionerAgent aborted by signal\", {\n mode: input.mode,\n reason: options?.signal?.reason instanceof Error\n ? options.signal.reason.message\n : String(options?.signal?.reason ?? \"unknown\"),\n });\n } else {\n logger.warn(\"QuestionerAgent LLM call failed\", {\n mode: input.mode,\n error: err instanceof Error ? err.message : String(err),\n });\n }\n return null;\n }\n\n const parsed = QuestionGeneratorResponseSchema.safeParse(raw);\n if (!parsed.success) {\n logger.warn(\"QuestionerAgent parse failed\", {\n mode: input.mode,\n error: parsed.error.message,\n });\n return null;\n }\n\n const filtered = applyGuardrails(parsed.data.questions);\n if (filtered.length === 0) return null;\n\n return {\n questions: filtered.map(stripInternalMetadata),\n strategies: filtered.map((q) => q.strategy),\n underspecificationTypes: filtered.map((q) => q.underspecificationType),\n };\n }\n}\n\n// --- Guardrails (migrated from question.generator.ts) -------------------------\n\nfunction applyGuardrails(questions: QuestionWithStrategy[]): QuestionWithStrategy[] {\n const dedupedByTitle = dedupByTitle(questions);\n return enforceStrategyDiversity(dedupedByTitle);\n}\n\nfunction dedupByTitle(questions: QuestionWithStrategy[]): QuestionWithStrategy[] {\n const seen = new Set<string>();\n const out: QuestionWithStrategy[] = [];\n for (const q of questions) {\n if (seen.has(q.title)) continue;\n seen.add(q.title);\n out.push(q);\n }\n return out;\n}\n\nfunction enforceStrategyDiversity(\n questions: QuestionWithStrategy[],\n): QuestionWithStrategy[] {\n const counts = new Map<QuestionStrategy, number>();\n const out: QuestionWithStrategy[] = [];\n for (const q of questions) {\n const n = counts.get(q.strategy) ?? 0;\n if (n >= MAX_SAME_STRATEGY) continue;\n counts.set(q.strategy, n + 1);\n out.push(q);\n }\n return out;\n}\n\nfunction stripInternalMetadata(q: QuestionWithStrategy): Question {\n const {\n strategy: _strategy,\n underspecificationType: _underspecificationType,\n ...publicShape\n } = q;\n return publicShape;\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"questioner.ask.tool.d.ts","sourceRoot":"/","sources":["questioner/questioner.ask.tool.ts"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAM5E,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AA8BxD,8EAA8E;AAC9E,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,eAAe,GAAG,IAAI,GAAG,IAAI,CAEhF;AAqCD;;;;;;;GAOG;AACH,wBAAgB,0BAA0B,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,kBAsMhF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"questioner.ask.tool.js","sourceRoot":"/","sources":["questioner/questioner.ask.tool.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAG5E,OAAO,E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conversation questions for the chat\n * orchestrator (AskUserQuestion-style human-in-the-loop).\n *\n * Flow (hybrid authoring):\n * 1. The orchestrator states what it needs to learn (`purpose`) plus optional\n * draft questions.\n * 2. The QuestionerAgent (mode `chat`) refines that into polished structured\n * questions, grounded in the recent conversation excerpt and the user's\n * global context.\n * 3. Questions are persisted (`questions` table, mode `chat`,\n * `conversationId = sessionId`) via the injected {@link ChatQuestionsHost}.\n * 4. A `user_question` trace event streams the persisted questions to the\n * frontend, which renders them inline while the turn stays open.\n * 5. The tool blocks on `awaitAnswers` until the user answers/dismisses\n * through the questions REST endpoints, the wait budget elapses, or the\n * run is aborted. Answers come back as the tool result so the model\n * continues the SAME turn.\n *\n * On timeout the questions remain `pending`: they survive reloads via the\n * conversation-linked question fetch, and a later answer re-enters the chat\n * as a new user turn (frontend responsibility).\n *\n * Chat-only: not registered in the MCP tool registry. The handler also fails\n * gracefully when the session/stream context or host bridge is missing.\n */\nimport { z } from \"zod\";\n\nimport type { DefineTool, ToolDeps } from \"../shared/agent/tool.helpers.js\";\nimport { error, success } from \"../shared/agent/tool.helpers.js\";\nimport { requestContext } from \"../shared/observability/request-context.js\";\nimport { protocolLogger } from \"../shared/observability/protocol.logger.js\";\nimport type { PersistableQuestion, PersistedQuestion, ChatQuestionAnswerOutcome } from \"../shared/interfaces/questioner.interface.js\";\nimport type { Question, QuestionGenerationResult, QuestionStrategy, UnderspecificationType } from \"../shared/schemas/question.schema.js\";\nimport { QuestionerAgent } from \"./questioner.agent.js\";\nimport { chatQuestionWaitTimeoutMs } from \"./questioner.env.js\";\nimport type { ChatContext } from \"./questioner.types.js\";\n\nconst logger = protocolLogger(\"AskUserQuestionTool\");\n\n\n/** Heartbeat interval while blocked, so SSE transports do not idle out. */\nconst WAIT_HEARTBEAT_MS = 15_000;\n\n/** Messages included in the conversation excerpt fed to the QuestionerAgent. */\nconst EXCERPT_MESSAGE_COUNT = 10;\n\n/**\n * Fetch window for the excerpt. Host adapters return the FIRST N messages\n * (ascending) when a limit is passed, so we fetch a wide window and keep the\n * tail to get the most recent exchange.\n */\nconst EXCERPT_FETCH_LIMIT = 100;\n\n/** Max characters per message inside the excerpt. */\nconst EXCERPT_MESSAGE_CHARS = 400;\n\n// Lazy singleton — construction binds the LLM once; invocations are stateless.\nlet questionerAgent: QuestionerAgent | null = null;\nfunction getQuestionerAgent(): QuestionerAgent {\n if (!questionerAgent) questionerAgent = new QuestionerAgent();\n return questionerAgent;\n}\n\n/** Test seam: replace or reset the module-level QuestionerAgent singleton. */\nexport function setQuestionerAgentForTesting(agent: QuestionerAgent | null): void {\n questionerAgent = agent;\n}\n\nconst draftQuestionSchema = z.object({\n prompt: z\n .string()\n .min(5)\n .max(400)\n .describe(\"The question to ask, ending in a question mark. Self-contained plain language.\"),\n options: z\n .array(z.string().min(1).max(120))\n .min(2)\n .max(4)\n .optional()\n .describe(\"2-4 mutually distinct answer options. Omit to let the question generator derive them.\"),\n multiSelect: z\n .boolean()\n .optional()\n .describe(\"True when several options can be picked together (priorities, bundles).\"),\n});\n\n/**\n * Build a fallback Question directly from an orchestrator draft when the\n * QuestionerAgent produced nothing. Requires the draft to carry options.\n */\nfunction questionFromDraft(draft: z.infer<typeof draftQuestionSchema>, index: number): Question | null {\n if (!draft.options || draft.options.length < 2) return null;\n return {\n title: `Question ${index + 1}`,\n prompt: draft.prompt.slice(0, 400),\n options: draft.options.slice(0, 4).map((label) => ({\n label: label.slice(0, 120),\n description: label.slice(0, 280),\n })),\n multiSelect: draft.multiSelect ?? false,\n };\n}\n\n/**\n * Creates the chat-only `ask_user_question` tool. Registered by\n * `createChatTools` only when `deps.chatQuestions` is provided — never part\n * of the MCP tool registry (MCP clients have their own elicitation surface).\n *\n * @param defineTool - Tool factory provided by the composition root.\n * @param deps - Shared tool dependencies; requires `chatQuestions`.\n */\nexport function createAskUserQuestionTools(defineTool: DefineTool, deps: ToolDeps) {\n const askUserQuestion = defineTool({\n name: \"ask_user_question\",\n description:\n \"Ask the user 1-3 structured clarifying questions and WAIT for their answer before continuing. \" +\n \"The conversation pauses: the user sees interactive question cards inline and your turn resumes \" +\n \"with their selections as the tool result.\\n\\n\" +\n \"**Use when** a decision materially changes what you do next — before an expensive operation \" +\n \"(discovery, creating an intent from ambiguous input), when facing meaningfully different \" +\n \"directions, or when one concrete missing detail (timing, scope, budget, format) blocks progress.\\n\\n\" +\n \"**Do not use** for facts already visible in the conversation or profile, procedural \" +\n \"confirmations (\\\"Should I proceed?\\\"), or open-ended questions better asked in your response text.\\n\\n\" +\n \"**Input:** `purpose` states what you need to learn and why. Optionally propose `questions` \" +\n \"drafts (prompt + 2-4 options); a question generator refines wording and option quality.\\n\\n\" +\n \"**Returns:** One entry per question with `status` (`answered`/`dismissed`/`timeout`) and the \" +\n \"user's `selectedOptions`/`freeText`. On `timeout` the questions stay visible in the \" +\n \"conversation — acknowledge briefly and end your turn; do NOT repeat the questions in text.\",\n querySchema: z.object({\n purpose: z\n .string()\n .min(10)\n .max(600)\n .describe(\"What you need to learn from the user and why it changes what you do next.\"),\n questions: z\n .array(draftQuestionSchema)\n .min(1)\n .max(3)\n .optional()\n .describe(\"Draft questions to ask. The question generator polishes them before display.\"),\n }),\n handler: async ({ context, query }) => {\n const host = deps.chatQuestions;\n if (!host) {\n return error(\n \"Interactive questions are not available in this environment. Ask the user directly in your response text instead.\",\n );\n }\n if (context.isMcp || !context.sessionId) {\n return error(\n \"Interactive questions require a live chat session. Ask the user directly in your response text instead.\",\n );\n }\n const store = requestContext.getStore();\n const emit = store?.traceEmitter;\n const signal = store?.abortSignal;\n if (!emit) {\n return error(\n \"Interactive questions require a streaming chat turn. Ask the user directly in your response text instead.\",\n );\n }\n\n const sessionId = context.sessionId;\n\n // ── 1. Gather grounding context ────────────────────────────────────\n const [conversationExcerpt, userContext] = await Promise.all([\n loadConversationExcerpt(deps, sessionId),\n deps.getUserContextText?.(context.userId).catch(() => \"\") ?? Promise.resolve(\"\"),\n ]);\n\n // ── 2. Generate polished questions (hybrid: drafts + QuestionerAgent) ──\n const chatContext: ChatContext = {\n purpose: query.purpose,\n ...(query.questions?.length ? { draftQuestions: query.questions } : {}),\n ...(conversationExcerpt ? { conversationExcerpt } : {}),\n ...(userContext ? { userContext } : {}),\n };\n\n let generated: QuestionGenerationResult | null = null;\n try {\n generated = await getQuestionerAgent().invoke(\n {\n mode: \"chat\",\n userId: context.userId,\n sourceType: \"conversation\",\n sourceId: sessionId,\n context: chatContext,\n conversationId: sessionId,\n },\n signal ? { signal } : undefined,\n );\n } catch (err) {\n logger.warn(\"QuestionerAgent invocation failed\", {\n error: err instanceof Error ? err.message : String(err),\n });\n }\n\n let finalQuestions: Question[];\n let strategies: QuestionStrategy[];\n let underspecificationTypes: Array<UnderspecificationType | null>;\n if (generated && generated.questions.length > 0) {\n finalQuestions = generated.questions;\n strategies = generated.strategies;\n underspecificationTypes = generated.underspecificationTypes;\n } else {\n // Fallback: use the orchestrator's own drafts verbatim (options required).\n const fromDrafts = (query.questions ?? [])\n .map((d, i) => questionFromDraft(d, i))\n .filter((q): q is Question => q !== null);\n if (fromDrafts.length === 0) {\n return error(\n \"Could not prepare structured questions. Ask the user directly in your response text instead.\",\n );\n }\n finalQuestions = fromDrafts;\n strategies = fromDrafts.map(() => \"surface_missing_detail\" as const);\n underspecificationTypes = fromDrafts.map(() => null);\n }\n\n if (signal?.aborted) {\n return error(\"The chat turn was cancelled before the questions could be shown.\");\n }\n\n // ── 3. Persist (mode `chat`, linked to this conversation) ──────────\n const timestamp = new Date().toISOString();\n const batch: PersistableQuestion[] = finalQuestions.map((payload, i) => ({\n detection: {\n mode: \"chat\",\n sourceType: \"conversation\",\n sourceId: sessionId,\n timestamp,\n },\n actors: [{ userId: context.userId, role: \"subject\" as const }],\n payload,\n strategy: strategies[i] ?? \"surface_missing_detail\",\n underspecificationType: underspecificationTypes[i] ?? null,\n conversationId: sessionId,\n }));\n\n let persisted: PersistedQuestion[];\n try {\n persisted = await host.persist(batch);\n } catch (err) {\n logger.error(\"Failed to persist chat questions\", {\n error: err instanceof Error ? err.message : String(err),\n });\n return error(\"Could not deliver the questions to the user. Ask directly in your response text instead.\");\n }\n\n // ── 4. Stream the cards to the frontend ────────────────────────────\n emit({\n type: \"user_question\",\n // The event is an opaque action reference. Question text is canonical\n // only after the recipient resolves this ID through the server.\n questions: persisted.map((q) => ({ id: q.id })),\n });\n\n // ── 5. Block until answered / dismissed / timeout / abort ──────────\n const heartbeat = setInterval(() => {\n try {\n emit({ type: \"status\", message: \"Waiting for your answer…\" });\n } catch {\n /* stream may be closing; the wait resolves via timeout/abort */\n }\n }, WAIT_HEARTBEAT_MS);\n\n let outcomes: ChatQuestionAnswerOutcome[];\n try {\n outcomes = await host.awaitAnswers(\n persisted.map((q) => q.id),\n { timeoutMs: chatQuestionWaitTimeoutMs(), ...(signal ? { signal } : {}) },\n );\n } finally {\n clearInterval(heartbeat);\n }\n\n const byId = new Map(persisted.map((q) => [q.id, q]));\n const results = outcomes.map((o) => {\n const q = byId.get(o.questionId);\n return {\n questionId: o.questionId,\n prompt: q?.payload.prompt ?? \"\",\n status: o.status,\n ...(o.answer\n ? {\n selectedOptions: o.answer.selectedOptions,\n ...(o.answer.freeText ? { freeText: o.answer.freeText } : {}),\n }\n : {}),\n };\n });\n\n const answeredCount = results.filter((r) => r.status === \"answered\").length;\n const timedOut = results.some((r) => r.status === \"timeout\");\n\n return success({\n answers: results,\n summary: `${answeredCount} of ${results.length} question(s) answered`,\n ...(timedOut\n ? {\n guidance:\n \"The user has not answered the remaining question(s) yet. They stay visible in the conversation — acknowledge briefly, do NOT repeat the questions in text, and end your turn.\",\n }\n : {}),\n });\n },\n });\n\n return [askUserQuestion] as const;\n}\n\n/**\n * Load a compact excerpt of the most recent conversation messages for the\n * QuestionerAgent's grounding. Best-effort: returns \"\" on any failure or when\n * no chat session reader is available. Note: the in-flight user message is\n * not yet persisted; the orchestrator's `purpose` carries that context.\n */\nasync function loadConversationExcerpt(deps: ToolDeps, sessionId: string): Promise<string> {\n if (!deps.chatSession) return \"\";\n try {\n const messages = await deps.chatSession.getSessionMessages(sessionId, EXCERPT_FETCH_LIMIT);\n if (!messages || messages.length === 0) return \"\";\n return messages\n .slice(-EXCERPT_MESSAGE_COUNT)\n .map((m) => {\n const role = m.role === \"assistant\" ? \"Assistant\" : \"User\";\n const text = (m.content ?? \"\").replace(/\\s+/g, \" \").trim();\n return `${role}: ${text.slice(0, EXCERPT_MESSAGE_CHARS)}`;\n })\n .join(\"\\n\");\n } catch (err) {\n logger.warn(\"Failed to load conversation excerpt\", {\n error: err instanceof Error ? err.message : String(err),\n });\n return \"\";\n }\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"questioner.discovery.prompt.d.ts","sourceRoot":"/","sources":["questioner/questioner.discovery.prompt.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,sBAAsB,EAAmB,MAAM,gDAAgD,CAAC;AAG9G,gEAAgE;AAChE,eAAO,MAAM,uBAAuB,yyLA0CgJ,CAAC;AAErL;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,sBAAsB,GAAG,MAAM,CAmClF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"questioner.discovery.prompt.js","sourceRoot":"/","sources":["questioner/questioner.discovery.prompt.ts"],"names":[],"mappings":"AAeA,gEAAgE;AAChE,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oLA0C6I,CAAC;AAErL;;;GAGG;AACH,MAAM,UAAU,4BAA4B,CAAC,KAA6B;IACxE,MAAM,cAAc,GAAG,KAAK,CAAC,WAAW,EAAE,IAAI,EAAE,IAAI,mBAAmB,CAAC;IACxE,MAAM,sBAAsB,GAAG,6BAA6B,CAAC,KAAK,CAAC,kBAAkB,CAAC,CAAC;IACvF,MAAM,gBAAgB,GAAG,KAAK,CAAC,WAAW;QACxC,CAAC,CAAC,YAAY,CAAC,KAAK,CAAC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AC,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC/B,KAAK,CAAC,IAAI,CAAC,2CAA2C,CAAC,CAAC;QACxD,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,aAAa;YAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC1D,CAAC;IACD,IAAI,CAAC,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,6BAA6B,CAAC,CAAC;QAC1C,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,gBAAgB;YAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,IAAI,CAAC,CAAC,gBAAgB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAClC,KAAK,CAAC,IAAI,CAAC,oCAAoC,CAAC,CAAC;QACjD,KAAK,MAAM,CAAC,IAAI,CAAC,CAAC,gBAAgB;YAAE,KAAK,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC7D,CAAC;IACD,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,mBAAmB,CAAC;AACnE,CAAC","sourcesContent":["/**\n * Discovery-mode prompt for the QuestionerAgent: the system prompt constant\n * and a pure string-building `buildDiscoveryQuestionPrompt` that assembles the\n * user message from a `DiscoveryQuestionInput`.\n *\n * Pure: no I/O, no LLM call. The QuestionerAgent (via the `discovery` preset\n * in `questioner.presets.ts`) orchestrates this module + an LLM client.\n *\n * Relocated from the removed `opportunity/question.prompt.ts` (IND-458); the\n * input types live in `shared/schemas/discovery-question.schema.ts`.\n */\nimport type { ChatContextDigest } from \"../shared/schemas/chat-context.schema.js\";\nimport type { DiscoveryQuestionInput, NegotiationRole } from \"../shared/schemas/discovery-question.schema.js\";\nimport type { DiscoveryNegotiationDigest } from \"../shared/schemas/negotiation-digest.schema.js\";\n\n/** System prompt for the QuestionerAgent's `discovery` mode. */\nexport const DISCOVERY_SYSTEM_PROMPT = `You help write user-facing follow-up questions after Index has reviewed potential connections for a human. Your job: surface the minimum set of structured decision questions the human must answer to make the next discovery turn sharper, or improve their outlook on the intent.\n\nYou may pick from five strategies. Choose contextually; mix when multiple questions genuinely complement.\n- refine_intent: ask the user to sharpen or pivot their original signal.\n- surface_missing_detail: ask for one concrete missing input (stage, location, timing, scope, …).\n- open_adjacent_thread: offer a pivot suggested by recurring connection signals.\n- reflective_summary: mirror what the connection review revealed and ask the user to decide.\n- surface_emergent_knowledge: cite a fact you learned from the connection review and ask the user to decide in light of it.\n\nAsk a question only when ALL of these hold:\n1. Index cannot resolve the decision autonomously from the evidence shown.\n2. The answer would materially change which people surface next.\n3. The same fact is NOT already in chatContext.statedFacts, NOT already asked in chatContext.openQuestions, and NOT already shared in chatContext.surfacedFindings.\n\nStandalone prompt rule. Every generated \\`prompt\\` must be understandable outside the conversation where it was created. Naturally include the original query, discovery pattern, connection pattern, or concrete learned fact in the question text itself. Do not rely on \\`title\\`, UI labels, hidden metadata, or surrounding digest/chat text to explain what the question is about. For example, prefer \"For your AI crypto decentralized deep-tech search, which area is most critical right now?\" over \"Which area is most critical right now?\"\n\nReferential closure. The prompt must resolve entirely on its own, with no dangling references. The reader sees ONLY the question text — never the people you reviewed, the events on their calendar, or this conversation. Do not use demonstratives or definite anaphora that point at things the reader cannot see: \"these builders\", \"those founders\", \"these researchers\", \"these conversations\", \"this lunch\", \"the speaker\". If you reference a person, name them. If you reference a group, restate the concrete shared attribute inside the question itself (\"founders working on decentralized identity\"), never \"these founders\". Never imply a list, set, or prior exchange the reader is not currently looking at.\n- Bad: \"What kind of collaboration are you looking for with these builders?\"\n- Good: \"You're meeting people building agent infrastructure — what kind of collaboration are you looking for?\"\n\nNo process narration. Never describe Index's own activity or internal state. Forbidden: \"the previous negotiation\", \"the negotiation stalled\", \"opportunities found so far\", \"my search\", \"the counterparty\", \"candidates reviewed\", restating why a match did or did not happen, or quoting words a counterparty did or did not use. Ask about the user's goal or intent directly, never about the matching pipeline.\n- Bad: \"All opportunities found so far are related to 'Edge Esmeralda'. Would you like to broaden the search?\"\n- Good: \"Do you want to focus on people at Edge Esmeralda, or also connect beyond it?\"\n\nCardinality. Default one question. Add a second only when a DIFFERENT strategy genuinely complements the first (e.g. one surface_emergent_knowledge + one refine_intent). Add a third only when there are ≥3 substantive people reviewed and three distinct strategies each unblock a real decision. Two questions of the same strategy are acceptable only if their decision domains differ (different titles). Avoid stacking three pulls (info-from-user); balance with pushes (info-to-user via reflective_summary / surface_emergent_knowledge).\n\nOrdering. Questions whose answer unblocks the most connection reviews come first; then highest-impact; then ambiguity-clarifying. Reviews that needed more detail or ran out of time signal under-specification — prioritize.\n\nUser-facing language. Every title, prompt, option label, and option description is shown directly to the user. Never mention raw protocol mechanics or internal labels such as \"agent\", \"patient\", \"peer\", \"suggestedRoles\", \"role distribution\", \"counterparty\", \"negotiation\", \"turn_cap\", \"timeout\", or \"candidate\". Use natural language instead: people, matches, connections, mutual collaboration, someone who can help, or someone seeking help.\n\nOption construction. Each option must represent a meaningfully different outcome. Suffix the safest path with \" (Recommended)\" and list it first. The description states the CONSEQUENCE of choosing the option, not its definition. 2–4 options. Never add an \"Other\" option — clients provide a free-text fallback automatically. For surface_emergent_knowledge questions, anchor the prompt in the concrete cited fact (\"Multiple people flagged that…\") and let the options represent decisions in light of that fact, not different versions of the fact.\n\nTitle rules. ≤12 chars. Noun of the decision domain. Discovery examples: \"Stage\", \"Timing\", \"Role\", \"Location\", \"Stack\", \"Budget\", \"Scope\", \"Format\".\n\nAnti-patterns — never do these.\n- Don't ask procedural confirmations (\"Should I look again?\").\n- Don't ask about hypothetical edge cases that didn't occur.\n- Don't ask about specific person identities; treat the provided person summary as the only allowed reference.\n- Don't repeat anything in chatContext.openQuestions.\n- Don't re-surface anything in chatContext.surfacedFindings.\n- Don't ask for facts in chatContext.statedFacts.\n\nOutput. Return at most 3 entries in the \"questions\" array. Each entry must include a \"strategy\" field (one of the five values). If nothing is worth asking, return \"questions\": [].`;\n\n/**\n * Pure builder: assembles the discovery-mode user message string from a\n * structured input.\n */\nexport function buildDiscoveryQuestionPrompt(input: DiscoveryQuestionInput): string {\n const profileSummary = input.userContext?.trim() || \"(no profile data)\";\n const connectionReviewBlocks = renderConnectionReviewDigests(input.negotiationDigests);\n const chatContextBlock = input.chatContext\n ? renderDigest(input.chatContext)\n : \"(no chat context available)\";\n const engagementPattern = renderEngagementPattern(input.summary.roleDistribution);\n\n return [\n \"## Seeker's query\",\n input.query,\n \"\",\n \"## Seeker profile\",\n profileSummary,\n \"\",\n \"## This discovery turn\",\n `- ${input.summary.totalCandidates} people reviewed`,\n `- ${input.summary.opportunitiesFound} promising connections found`,\n `- ${input.summary.noOpportunityCount} reviews did not find enough fit (${input.summary.timeoutCount} needed more detail or time)`,\n `- Engagement pattern: ${engagementPattern}`,\n \"\",\n \"## Connection review evidence (compact digests)\",\n connectionReviewBlocks,\n \"\",\n \"## What the user has already said in this session\",\n chatContextBlock,\n \"\",\n \"## Now\",\n input.now,\n \"\",\n \"## Your task\",\n \"Identify the minimum set of decision questions the seeker must answer to make\",\n \"the next discovery turn sharper. Apply every rule from your system prompt\",\n \"before outputting. Return an empty `questions` array if nothing is worth asking.\",\n ].join(\"\\n\");\n}\n\n/**\n * Render the negotiation-digest collection into compact one-liners. Each digest\n * is fixed-size (≤ ~400 chars after rendering), so the rendered block scales\n * linearly with candidate count: 10 candidates ≈ 4 KB, well within budget.\n */\nfunction renderConnectionReviewDigests(digests: DiscoveryNegotiationDigest[]): string {\n if (digests.length === 0) return \"(no connection reviews)\";\n return digests\n .map((d) => {\n const relationshipSignal = d.suggestedRoles\n ? [` Relationship signal: ${renderRelationshipSignal(d.suggestedRoles)}`]\n : [];\n return [\n `- Person: ${d.counterpartyHint}`,\n ` Community context: ${d.indexContext}`,\n ` Outcome: ${renderOutcome(d)}`,\n ...relationshipSignal,\n ` Take: ${d.keyTake}`,\n ].join(\"\\n\");\n })\n .join(\"\\n\\n\");\n}\n\nfunction renderEngagementPattern(dist: Partial<Record<NegotiationRole, number>>): string {\n const parts: string[] = [];\n if ((dist.peer ?? 0) > 0) {\n parts.push(`${dist.peer} mutual collaboration${dist.peer === 1 ? \"\" : \"s\"}`);\n }\n if ((dist.agent ?? 0) > 0) {\n parts.push(`${dist.agent} where the user could offer help or expertise`);\n }\n if ((dist.patient ?? 0) > 0) {\n parts.push(`${dist.patient} where the user seemed to be seeking help or expertise`);\n }\n return parts.length > 0 ? parts.join(\", \") : \"(no engagement pattern available)\";\n}\n\nfunction renderOutcome(digest: DiscoveryNegotiationDigest): string {\n const outcome = digest.outcomeRole === \"opportunity\"\n ? \"promising connection\"\n : \"not enough fit\";\n const reason = renderOutcomeReason(digest.outcomeReason);\n return reason ? `${outcome} (${reason})` : outcome;\n}\n\nfunction renderOutcomeReason(reason: DiscoveryNegotiationDigest[\"outcomeReason\"]): string {\n switch (reason) {\n case \"turn_cap\":\n return \"needed more detail\";\n case \"timeout\":\n return \"ran out of time\";\n case \"rejected\":\n return \"not enough mutual interest\";\n case \"stalled\":\n return \"stalled\";\n case \"screened_out\":\n return \"didn't look like a strong enough fit to pursue\";\n case null:\n return \"\";\n }\n}\n\nfunction renderRelationshipSignal(roles: NonNullable<DiscoveryNegotiationDigest[\"suggestedRoles\"]>): string {\n if (roles.ownUser === \"peer\" && roles.otherUser === \"peer\") return \"mutual collaboration\";\n if (roles.ownUser === \"agent\" && roles.otherUser === \"patient\") {\n return \"the user could offer help or expertise\";\n }\n if (roles.ownUser === \"patient\" && roles.otherUser === \"agent\") {\n return \"the user seemed to be seeking help or expertise\";\n }\n if (roles.ownUser === \"agent\") return \"the user could offer help or expertise\";\n if (roles.ownUser === \"patient\") return \"the user seemed to be seeking help or expertise\";\n return \"collaboration fit\";\n}\n\nfunction renderDigest(d: ChatContextDigest): string {\n const lines: string[] = [];\n if (d.statedFacts.length > 0) {\n lines.push(\"Stated facts:\");\n for (const f of d.statedFacts) lines.push(` - ${f}`);\n }\n if (d.openQuestions.length > 0) {\n lines.push(\"Open questions (assistant already asked):\");\n for (const q of d.openQuestions) lines.push(` - ${q}`);\n }\n if (d.rejectionReasons.length > 0) {\n lines.push(\"User pushback / rejections:\");\n for (const r of d.rejectionReasons) lines.push(` - ${r}`);\n }\n if (d.surfacedFindings.length > 0) {\n lines.push(\"Findings already surfaced to user:\");\n for (const f of d.surfacedFindings) lines.push(` - ${f}`);\n }\n return lines.length > 0 ? lines.join(\"\\n\") : \"(digest is empty)\";\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"questioner.env.d.ts","sourceRoot":"/","sources":["questioner/questioner.env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH;;;;;;;GAOG;AACH,eAAO,MAAM,sCAAsC,QAAS,CAAC;AAC7D,eAAO,MAAM,qCAAqC,SAAU,CAAC;AAC7D,eAAO,MAAM,kCAAkC,KAAK,CAAC;AAerD,oEAAoE;AACpE,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C;AAED;;;GAGG;AACH,wBAAgB,2BAA2B,IAAI,OAAO,CAErD;AAED,2FAA2F;AAC3F,wBAAgB,oBAAoB,IAAI,OAAO,CAE9C;AAED,2EAA2E;AAC3E,wBAAgB,wBAAwB,IAAI,MAAM,CAMjD;AAED;;;;GAIG;AACH,wBAAgB,2BAA2B,IAAI,aAAa,GAAG,UAAU,CAIxE;AAED,8DAA8D;AAC9D,wBAAgB,2BAA2B,IAAI,MAAM,CAEpD;AAED,gEAAgE;AAChE,wBAAgB,yBAAyB,IAAI,MAAM,CAElD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"questioner.env.js","sourceRoot":"/","sources":["questioner/questioner.env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;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AC,IAAI,EAAE,CAAC;QAAE,OAAO,kCAAkC,CAAC;IAC3E,MAAM,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;IACxC,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC,CAAC;AAC5C,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,2BAA2B;IACzC,OAAO,OAAO,CAAC,GAAG,CAAC,+BAA+B,EAAE,IAAI,EAAE,KAAK,UAAU;QACvE,CAAC,CAAC,UAAU;QACZ,CAAC,CAAC,aAAa,CAAC;AACpB,CAAC;AAED,8DAA8D;AAC9D,MAAM,UAAU,2BAA2B;IACzC,OAAO,cAAc,CAAC,iCAAiC,EAAE,sCAAsC,CAAC,CAAC;AACnG,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,yBAAyB;IACvC,OAAO,cAAc,CAAC,iCAAiC,EAAE,qCAAqC,CAAC,CAAC;AAClG,CAAC","sourcesContent":["/**\n * Centralized accessors for all question-generation environment variables.\n *\n * Naming scheme (one prefix, hierarchical):\n *\n * QUESTIONER_ENABLED master switch — QuestionerQueue worker +\n * enqueue closures at every composition site.\n * QUESTIONER_UPTAKE_ENABLED per-surface switch — advisory pre-accept uptake\n * interlock. Requires the master switch.\n * QUESTIONER_UPTAKE_AUTHORITY_THRESHOLD\n * authority threshold (0-100, default 70).\n * QUESTIONER_DISCOVERY_ENABLED per-surface switch — decision questions during\n * chat/MCP opportunity discovery. Only effective\n * when the master switch is on (the discovery\n * question step adds inline summarizer latency,\n * so operators can turn it off independently).\n * QUESTIONER_DISCOVERY_INPUT_MODE 'transcripts' | 'insights' generator input.\n * QUESTIONER_DISCOVERY_TIMEOUT_MS per-call deadline for the discovery-questions\n * LLM step (default 12s).\n * QUESTIONER_CHAT_WAIT_TIMEOUT_MS how long the blocking ask_user_question chat\n * tool waits for an inline answer (default 4 min).\n *\n * All reads go through this module — do not read these variables via\n * `process.env` elsewhere. Values are read on every call (no caching) so tests\n * and long-lived processes observe changes.\n */\n\n/**\n * Question-generator budget. Sized against Railway's ~60 s edge timeout:\n * the discovery + evaluation + negotiate phases consume ~50 s on the slow\n * path, leaving ~10 s of headroom for the tail. 12 s is the larger end of\n * \"fits\"; the question step usually completes in 4-8 s, so most legitimate\n * calls finish well inside. Aborted calls return `null` (no questions);\n * the rest of the discovery payload still ships.\n */\nexport const DISCOVERY_QUESTIONS_TIMEOUT_MS_DEFAULT = 12_000;\nexport const CHAT_QUESTION_WAIT_TIMEOUT_MS_DEFAULT = 240_000;\nexport const UPTAKE_AUTHORITY_THRESHOLD_DEFAULT = 70;\n\n/**\n * Parse a positive integer env var, clamped to the safe-integer range so a\n * malformed env value cannot crash `AbortSignal.timeout` (which throws on\n * values outside `[0, MAX_SAFE_INTEGER]`).\n */\nfunction positiveIntEnv(name: string, fallback: number): number {\n const raw = process.env[name];\n if (!raw) return fallback;\n const parsed = Number.parseInt(raw, 10);\n if (!Number.isFinite(parsed) || parsed <= 0 || parsed > Number.MAX_SAFE_INTEGER) return fallback;\n return parsed;\n}\n\n/** Master switch: is any background question generation enabled? */\nexport function isQuestionerEnabled(): boolean {\n return process.env.QUESTIONER_ENABLED === \"true\";\n}\n\n/**\n * Per-surface switch: should chat/MCP opportunity discovery produce decision\n * questions? Hierarchical — always false when the master switch is off.\n */\nexport function isDiscoveryQuestionsEnabled(): boolean {\n return isQuestionerEnabled() && process.env.QUESTIONER_DISCOVERY_ENABLED === \"true\";\n}\n\n/** Advisory uptake interlock. Flag-off by default and subordinate to the master switch. */\nexport function isUptakeGuardEnabled(): boolean {\n return isQuestionerEnabled() && process.env.QUESTIONER_UPTAKE_ENABLED === \"true\";\n}\n\n/** Authority threshold below which hosts may generate uptake questions. */\nexport function uptakeAuthorityThreshold(): number {\n const raw = process.env.QUESTIONER_UPTAKE_AUTHORITY_THRESHOLD;\n if (!raw?.trim()) return UPTAKE_AUTHORITY_THRESHOLD_DEFAULT;\n if (!/^-?\\d+$/.test(raw.trim())) return UPTAKE_AUTHORITY_THRESHOLD_DEFAULT;\n const parsed = Number.parseInt(raw, 10);\n return Math.min(100, Math.max(0, parsed));\n}\n\n/**\n * Input mode for the discovery question generator. Only `transcripts` is\n * implemented; any other value falls back to `transcripts` (startup.env.ts\n * warns on invalid values).\n */\nexport function discoveryQuestionsInputMode(): \"transcripts\" | \"insights\" {\n return process.env.QUESTIONER_DISCOVERY_INPUT_MODE?.trim() === \"insights\"\n ? \"insights\"\n : \"transcripts\";\n}\n\n/** Per-call deadline for the discovery-questions LLM step. */\nexport function discoveryQuestionsTimeoutMs(): number {\n return positiveIntEnv(\"QUESTIONER_DISCOVERY_TIMEOUT_MS\", DISCOVERY_QUESTIONS_TIMEOUT_MS_DEFAULT);\n}\n\n/** Wait budget for the blocking ask_user_question chat tool. */\nexport function chatQuestionWaitTimeoutMs(): number {\n return positiveIntEnv(\"QUESTIONER_CHAT_WAIT_TIMEOUT_MS\", CHAT_QUESTION_WAIT_TIMEOUT_MS_DEFAULT);\n}\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"questioner.presets.d.ts","sourceRoot":"/","sources":["questioner/questioner.presets.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,sCAAsC,CAAC;AAsB1F,MAAM,WAAW,gBAAgB;IAC/B,2CAA2C;IAC3C,YAAY,EAAE,MAAM,CAAC;IACrB,qEAAqE;IACrE,WAAW,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,CAAC;CAC3C;AA2dD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,CAAC,EAAE,eAAe,GAAG,gBAAgB,CAYzF"}
|