@indexnetwork/protocol 4.3.7-rc.317.1 → 4.4.1-rc.319.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chat/chat-streaming.types.d.ts +29 -2
- package/dist/chat/chat-streaming.types.d.ts.map +1 -1
- package/dist/chat/chat-streaming.types.js +3 -0
- package/dist/chat/chat-streaming.types.js.map +1 -1
- package/dist/chat/chat.agent.d.ts +15 -0
- package/dist/chat/chat.agent.d.ts.map +1 -1
- package/dist/chat/chat.agent.js.map +1 -1
- package/dist/chat/chat.prompt.d.ts.map +1 -1
- package/dist/chat/chat.prompt.js +3 -0
- package/dist/chat/chat.prompt.js.map +1 -1
- package/dist/chat/chat.streamer.d.ts.map +1 -1
- package/dist/chat/chat.streamer.js +9 -1
- package/dist/chat/chat.streamer.js.map +1 -1
- package/dist/enrichment/enrichment.graph.d.ts +3 -11
- package/dist/enrichment/enrichment.graph.d.ts.map +1 -1
- package/dist/enrichment/enrichment.graph.js +72 -2
- package/dist/enrichment/enrichment.graph.js.map +1 -1
- package/dist/enrichment/enrichment.tools.d.ts.map +1 -1
- package/dist/enrichment/enrichment.tools.js +1 -0
- package/dist/enrichment/enrichment.tools.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/premise/premise.decomposer.d.ts +12 -1
- package/dist/premise/premise.decomposer.d.ts.map +1 -1
- package/dist/premise/premise.decomposer.js +87 -5
- package/dist/premise/premise.decomposer.js.map +1 -1
- package/dist/premise/premise.tools.d.ts.map +1 -1
- package/dist/premise/premise.tools.js +0 -24
- package/dist/premise/premise.tools.js.map +1 -1
- package/dist/questioner/questioner.ask.tool.d.ts +14 -0
- package/dist/questioner/questioner.ask.tool.d.ts.map +1 -0
- package/dist/questioner/questioner.ask.tool.js +309 -0
- package/dist/questioner/questioner.ask.tool.js.map +1 -0
- package/dist/questioner/questioner.presets.d.ts.map +1 -1
- package/dist/questioner/questioner.presets.js +73 -0
- package/dist/questioner/questioner.presets.js.map +1 -1
- package/dist/questioner/questioner.types.d.ts +21 -1
- package/dist/questioner/questioner.types.d.ts.map +1 -1
- package/dist/questioner/questioner.types.js.map +1 -1
- package/dist/shared/agent/tool.factory.d.ts.map +1 -1
- package/dist/shared/agent/tool.factory.js +10 -1
- package/dist/shared/agent/tool.factory.js.map +1 -1
- package/dist/shared/agent/tool.helpers.d.ts +20 -14
- package/dist/shared/agent/tool.helpers.d.ts.map +1 -1
- package/dist/shared/agent/tool.helpers.js +12 -1
- package/dist/shared/agent/tool.helpers.js.map +1 -1
- package/dist/shared/agent/tool.runtime.d.ts +1 -1
- package/dist/shared/agent/tool.runtime.d.ts.map +1 -1
- package/dist/shared/agent/tool.runtime.js +14 -3
- package/dist/shared/agent/tool.runtime.js.map +1 -1
- package/dist/shared/interfaces/database.interface.d.ts +9 -1
- package/dist/shared/interfaces/database.interface.d.ts.map +1 -1
- package/dist/shared/interfaces/database.interface.js.map +1 -1
- package/dist/shared/interfaces/questioner.interface.d.ts +26 -0
- package/dist/shared/interfaces/questioner.interface.d.ts.map +1 -1
- package/dist/shared/interfaces/questioner.interface.js.map +1 -1
- package/dist/shared/observability/request-context.d.ts +15 -0
- package/dist/shared/observability/request-context.d.ts.map +1 -1
- package/dist/shared/observability/request-context.js.map +1 -1
- package/dist/shared/schemas/question.schema.d.ts +4 -4
- package/dist/shared/schemas/question.schema.d.ts.map +1 -1
- package/dist/shared/schemas/question.schema.js +2 -0
- package/dist/shared/schemas/question.schema.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,YAAY,EAAE,SAAS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E,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAE5E,iFAAiF;AAEjF,OAAO,EAAE,eAAe,EAAE,6BAA6B,EAAE,yBAAyB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEpI,OAAO,EAAE,sBAAsB,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AASvE,iFAAiF;AAEjF,OAAO,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC","sourcesContent":["// =============================================================================\n// @indexnetwork/protocol — public API barrel\n//\n// This file is the ONLY supported entry point. Deep imports\n// (\"@indexnetwork/protocol/src/...\") are not part of the contract and may break\n// in any release. Every symbol is re-exported explicitly (no wildcards) so the\n// surface is reviewable and changes are intentional.\n//\n// Stability tiers are defined in STABILITY.md. In short:\n// • Stable — Interfaces, Graph factories, Agents, createChatTools,\n// the tool/runtime helpers, and shared schemas.\n// • Experimental — Sections marked @experimental below (advanced graph state\n// types and internal helpers); may change in a minor release.\n// =============================================================================\n\n// ─── Public API (recommended for external consumers) ──────────────────────────\n\nexport { createChatTools } from \"./shared/agent/tool.factory.js\";\nexport { getModelName } from \"./shared/agent/model.config.js\";\nexport type { ChatTools } from \"./shared/agent/tool.factory.js\";\nexport type { ModelConfig, ModelSettings } from \"./shared/agent/model.config.js\";\nexport type { ToolContext, ResolvedToolContext, ToolDeps, ProtocolDeps, RawToolDefinition, CompiledGraph } from \"./shared/agent/tool.helpers.js\";\nexport { ChatContextAccessError, resolveChatContext } from \"./shared/agent/tool.helpers.js\";\nexport {\n deriveAllowedNetworkIds,\n deriveDiscoveryNetworkIds,\n focusedNetworkId,\n focusedNetworkLabel,\n hasNetworkScope,\n scopeFromNetworkId,\n} from \"./shared/agent/tool.scope.js\";\nexport type { ToolScopeEnvelope, ToolScopeType, ScopeMembership, DeriveNetworkScopeInput } from \"./shared/agent/tool.scope.js\";\nexport { requestContext } from \"./shared/observability/request-context.js\";\nexport { setTimingWrapper } from \"./shared/observability/performance.js\";\nexport { ToolRuntimeError, getToolTimeoutPolicy, invokeToolRuntime, toolRuntimeErrorToResult } from \"./shared/agent/tool.runtime.js\";\nexport type { ToolRuntimeErrorCode, ToolTimeoutClass, ToolTimeoutPolicy } from \"./shared/agent/tool.runtime.js\";\n\n// ─── Interfaces (implement these to wire up your infrastructure) ───────────────\n\nexport type { McpAuthResolver } from \"./shared/interfaces/auth.interface.js\";\nexport type { Cache, CacheOptions, HydeCache, OpportunityCache } from \"./shared/interfaces/cache.interface.js\";\nexport type { ChatSessionReader, ChatSessionDetail, ChatSessionSummary } from \"./shared/interfaces/chat-session.interface.js\";\nexport type { ChatSummaryReader } from \"./shared/interfaces/chat-summary.interface.js\";\nexport type { ChatMessageWriter } from \"./shared/interfaces/chat-message-writer.interface.js\";\nexport type { QuestionGeneratorReader } from \"./shared/interfaces/question-generator.interface.js\";\nexport type { QuestionerDatabase, PersistableQuestion, PersistedQuestion, QuestionFilters } from \"./shared/interfaces/questioner.interface.js\";\nexport type { NegotiationSummaryReader } from \"./shared/interfaces/negotiation-summary.interface.js\";\nexport type { DiscoveryNegotiationDigest } from \"./shared/schemas/negotiation-digest.schema.js\";\nexport { NegotiationSummarizer, buildFallbackDigest } from \"./negotiation/negotiation.summarizer.js\";\nexport type { ContactServiceAdapter, ContactEntry, ContactImportResult, ContactInput, ContactResult, ContactSearchResult } from \"./shared/interfaces/contact.interface.js\";\nexport type {\n ChatGraphCompositeDatabase, UserDatabase, SystemDatabase, Database,\n OpportunityGraphDatabase, OpportunityControllerDatabase, HomeGraphDatabase,\n IntentGraphDatabase, IntentNetworkGraphDatabase, NetworkGraphDatabase, NetworkMembershipGraphDatabase,\n HydeGraphDatabase, EnrichmentGraphDatabase, PremiseGraphDatabase, NegotiationGraphDatabase,\n NegotiationQueries, NegotiationUserAnswer,\n Opportunity, OpportunityActor, OpportunityContext, OpportunityDetection, OpportunityInterpretation,\n OpportunityQueryOptions, OpportunitySignal, OpportunityStatus,\n ActiveIntent, CreatedIntent, CreateIntentData, UpdateIntentData, IntentRecord, SimilarIntent, SimilarIntentSearchOptions,\n IndexedIntentDetails, IndexMemberDetails, AssignmentNetworkMembership, NetworkAssignmentContext, NetworkMembership, OwnedIndex,\n CreateHydeDocumentData, HydeDocument, HydeSourceType, CreateOpportunityData,\n PremiseAnalysis, PremiseAssertion, PremiseProvenance, PremiseRecord, PremiseValidity,\n OnboardingPrivacyState, OnboardingProfileSeed, OnboardingState, PrivacyConsentDecision, PrivacyConsentSource,\n UpdateIndexSettingsData, UserRecord, UserSocial, ArchiveResult, Id,\n} from \"./shared/interfaces/database.interface.js\";\nexport type {\n Embedder, EmbeddingGenerator, EmbeddingGenerateOptions,\n VectorStore, VectorStoreOption, VectorSearchResult,\n HydeCandidate, HydeSearchOptions, LensEmbedding,\n} from \"./shared/interfaces/embedder.interface.js\";\nexport type { ProfileEnricher, EnrichmentRequest, EnrichmentResult } from \"./shared/interfaces/enrichment.interface.js\";\nexport type { IntegrationAdapter, IntegrationConnection, IntegrationSession, IntegrationSessionOptions, ToolActionResponse } from \"./shared/interfaces/integration.interface.js\";\nexport type { IntentGraphQueue } from \"./shared/interfaces/queue.interface.js\";\nexport type { Scraper, ExtractUrlContentOptions } from \"./shared/interfaces/scraper.interface.js\";\nexport type { Storage } from \"./shared/interfaces/storage.interface.js\";\nexport type { DeliveryLedger, DeliveredOpportunityRow } from \"./shared/interfaces/delivery-ledger.interface.js\";\nexport type { MintConnectLink, ConnectLinkKind } from \"./shared/interfaces/connect-link.interface.js\";\nexport type {\n DiscoveryRunStore, DiscoveryRunQueue, DiscoveryRunInput, CreateDiscoveryRunInput,\n DiscoveryRunRecord, DiscoveryRunStatus,\n} from \"./shared/interfaces/discovery-run.interface.js\";\nexport type {\n EnrichmentRunStore, EnrichmentRunQueue, EnrichmentRunInput, CreateEnrichmentRunInput,\n UpdateUserEnrichmentRunInput, PreviewUserEnrichmentRunInput,\n EnrichmentRunRecord, EnrichmentRunStatus, EnrichmentRunOperation,\n} from \"./shared/interfaces/enrichment-run.interface.js\";\nexport type { NegotiationTimeoutQueue } from \"./shared/interfaces/negotiation-events.interface.js\";\nexport type { AgentDispatcher, AgentDispatchResult, NegotiationTurnPayload } from \"./shared/interfaces/agent-dispatcher.interface.js\";\nexport type { AgentRecord, AgentTransportRecord, AgentPermissionRecord, AgentWithRelations, CreateAgentInput, CreateTransportInput, GrantPermissionInput, AgentDatabase } from './shared/interfaces/agent.interface.js';\nexport { SYSTEM_AGENT_IDS } from './shared/interfaces/agent.interface.js';\n\n// ─── Shared schemas ───────────────────────────────────────────────────────────\n\nexport { ChatContextDigestSchema, type ChatContextDigest } from \"./shared/schemas/chat-context.schema.js\";\nexport { QuestionOptionSchema, QuestionSchema, QuestionStrategySchema, QuestionWithStrategySchema, QuestionGeneratorResponseSchema, QuestionModeSchema, QuestionDetectionSchema, QuestionActorSchema, QuestionAnswerSchema, type Question, type QuestionOption, type QuestionStrategy, type QuestionWithStrategy, type QuestionGeneratorResponse, type QuestionGenerationResult, type QuestionMode, type QuestionDetection, type QuestionActor, type QuestionAnswer } from \"./shared/schemas/question.schema.js\";\nexport type { PendingQuestionSummary } from \"./shared/schemas/pending-question.schema.js\";\nexport type { McpAuthInput } from \"./shared/schemas/mcp-auth.schema.js\";\nexport { UserIdentitySchema, type UserIdentity } from \"./shared/schemas/identity.schema.js\";\nexport type { DiscoverySourceProfile, DiscoverySummary, DiscoveryNegotiation, DiscoveryTurn, DiscoveryOutcome, DiscoveryQuestionInput, NegotiationRole } from \"./shared/schemas/discovery-question.schema.js\";\nexport { NetworkAssignmentResourceTypeSchema, NetworkAssignmentModeSchema, NetworkAssignmentScopeSchema, NetworkAssignmentPromptPresenceSchema, NetworkAssignmentPolicySchema, NetworkAssignmentRawScoresSchema, NetworkAssignmentMetadataSchema, OpportunityEvidenceKindSchema, OpportunityEvidenceSchema } from \"./shared/schemas/network-assignment.schema.js\";\nexport type { NetworkAssignmentResourceType, NetworkAssignmentMode, NetworkAssignmentScope, NetworkAssignmentPromptPresence, NetworkAssignmentPolicy, NetworkAssignmentRawScores, NetworkAssignmentMetadata, OpportunityEvidenceKind, OpportunityEvidence } from \"./shared/schemas/network-assignment.schema.js\";\nexport { DEFAULT_NETWORK_ASSIGNMENT_THRESHOLD, classifyPromptPresence, resolveAssignmentNetworkScope, buildNetworkAssignmentDecision, combineAssignmentScores } from \"./shared/assignment/network-assignment.policy.js\";\nexport type { PromptPresenceInput, ResolveAssignmentNetworkScopeArgs, AssignmentScopeMembership, BuildNetworkAssignmentDecisionArgs, NetworkAssignmentDecision } from \"./shared/assignment/network-assignment.policy.js\";\nexport { buildCandidateEvidence, withCandidateEvidence, mergeOpportunityEvidence, withMatchedStrategies, renderOpportunityEvidenceForPrompt } from \"./opportunity/opportunity.evidence.js\";\nexport type { EvidenceCandidateInput } from \"./opportunity/opportunity.evidence.js\";\n\n// ─── Graph factories ──────────────────────────────────────────────────────────\n\nexport { ChatGraphFactory } from \"./chat/chat.graph.js\";\nexport { HomeGraphFactory } from \"./opportunity/feed/feed.graph.js\";\nexport { HydeGraphFactory } from \"./shared/hyde/hyde.graph.js\";\nexport { NetworkGraphFactory } from \"./network/network.graph.js\";\nexport { NetworkMembershipGraphFactory } from \"./network/membership/membership.graph.js\";\nexport { IntentGraphFactory } from \"./intent/intent.graph.js\";\nexport { IntentNetworkGraphFactory } from \"./network/indexer/indexer.graph.js\";\nexport { MaintenanceGraphFactory } from \"./maintenance/maintenance.graph.js\";\nexport type { MaintenanceGraphDatabase, MaintenanceGraphCache, MaintenanceGraphQueue } from \"./maintenance/maintenance.graph.js\";\nexport { NegotiationGraphFactory, createDefaultNegotiationGraph, negotiateCandidates } from \"./negotiation/negotiation.graph.js\";\nexport { OpportunityGraphFactory } from \"./opportunity/opportunity.graph.js\";\nexport { EnrichmentGraphFactory } from \"./enrichment/enrichment.graph.js\";\nexport { PremiseGraphFactory } from \"./premise/premise.graph.js\";\n\n// ─── Agents ───────────────────────────────────────────────────────────────────\n\nexport { UserContextGenerator } from \"./context/context.generator.js\";\nexport type { UserContextInput, IncrementalContextInput, UserContextResult, GlobalContextInput, GlobalIncrementalContextInput } from \"./context/context.generator.js\";\nexport { ChatTitleGenerator } from \"./chat/chat.title.generator.js\";\nexport { ChatInterruptClassifier } from \"./chat/chat.interrupt.classifier.js\";\nexport type { ClassifyInterruptInput } from \"./chat/chat.interrupt.classifier.js\";\nexport { ChatSummarizer } from \"./chat/chat.summarizer.js\";\nexport type { ChatSummarizerInput, ChatSummarizerMessage } from \"./chat/chat.summarizer.js\";\nexport { HydeGenerator } from \"./shared/hyde/hyde.generator.js\";\nexport { SuggestionGenerator } from \"./chat/chat.suggester.js\";\nexport type { SuggestionGeneratorInput } from \"./chat/chat.suggester.js\";\nexport { generateInviteMessage } from \"./contact/contact.inviter.js\";\nexport type { InviteInput, InviteOutput } from \"./contact/contact.inviter.js\";\nexport { IntentIndexer } from \"./intent/intent.indexer.js\";\nexport type { IntentIndexerOutput } from \"./intent/intent.indexer.js\";\nexport { PremiseAnalyzer } from \"./premise/premise.analyzer.js\";\nexport type { PremiseAnalyzerOutput } from \"./premise/premise.analyzer.js\";\nexport { PremiseDecomposer } from \"./premise/premise.decomposer.js\";\nexport type { PremiseDecomposerOutput, DecomposedPremise } from \"./premise/premise.decomposer.js\";\nexport { PremiseIndexer } from \"./premise/premise.indexer.js\";\nexport type { PremiseIndexerOutput } from \"./premise/premise.indexer.js\";\nexport { LensInferrer } from \"./shared/hyde/lens.inferrer.js\";\nexport { NegotiationInsightsGenerator } from \"./negotiation/insight.generator.js\";\nexport type { NegotiationDigest } from \"./negotiation/insight.generator.js\";\nexport { IndexNegotiator } from \"./negotiation/negotiation.agent.js\";\nexport type { NegotiationAgentInput } from \"./negotiation/negotiation.agent.js\";\nexport { QuestionerAgent } from \"./questioner/questioner.agent.js\";\nexport type { QuestionerAgentConfig } from \"./questioner/questioner.agent.js\";\nexport type { QuestionerInput, QuestionerContext, QuestionerEnqueuePayload, QuestionerEnqueueFn, DiscoveryContext, IntentContext, ProfileContext, NegotiationContext } from \"./questioner/questioner.types.js\";\nexport { getPreset } from \"./questioner/questioner.presets.js\";\nexport type { QuestionerPreset } from \"./questioner/questioner.presets.js\";\nexport { OpportunityEvaluator } from \"./opportunity/opportunity.evaluator.js\";\nexport type { EvaluatorInput, OpportunityEvaluatorOptionsConstructor } from \"./opportunity/opportunity.evaluator.js\";\nexport { OpportunityPresenter, gatherPresenterContext } from \"./opportunity/opportunity.presenter.js\";\nexport { createOpportunityTools } from \"./opportunity/opportunity.tools.js\";\nexport { createEnrichmentTools } from \"./enrichment/enrichment.tools.js\";\nexport type { PresenterDatabase } from \"./opportunity/opportunity.presenter.js\";\nexport { QuestionGenerator } from \"./opportunity/question.generator.js\";\n\n// ─── Support utilities ────────────────────────────────────────────────────────\n\nexport { renderNetworkContext } from './shared/network/metadata.renderer.js';\nexport { canUserSeeOpportunity, isActionableForViewer, validateOpportunityActors, classifyOpportunity, selectByComposition, selectDigestCandidates, DIGEST_REDELIVERY_COOLDOWN_DAYS, FEED_SOFT_TARGETS } from \"./opportunity/opportunity.utils.js\";\nexport type { DigestDeliveredRow } from \"./opportunity/opportunity.utils.js\";\nexport { getPrimaryActionLabel } from \"./opportunity/opportunity.labels.js\";\nexport { computeFeedHealth } from \"./opportunity/feed/feed.health.js\";\nexport type { FeedHealthInput, FeedHealthResult } from \"./opportunity/feed/feed.health.js\";\nexport { selectContactsForDiscovery, shouldRunIntroducerDiscovery, runIntroducerDiscovery, MAX_CONTACTS_PER_CYCLE, MAX_CANDIDATES_PER_CONTACT, INTRODUCER_DISCOVERY_SOURCE } from \"./opportunity/opportunity.introducer.js\";\nexport type { IntroducerDiscoveryDatabase, IntroducerDiscoveryQueue, ContactWithIntents } from \"./opportunity/opportunity.introducer.js\";\nexport { persistOpportunities } from \"./opportunity/opportunity.persist.js\";\nexport { presentOpportunity } from \"./opportunity/opportunity.presentation.js\";\nexport type { UserInfo } from \"./opportunity/opportunity.presentation.js\";\nexport { stripUuids, stripIntroducerMentions, truncateAtBoundary } from \"./opportunity/opportunity.presentation.js\";\nexport { safeFallbackSummary, getSafePresentationOrSkip, SAFE_FALLBACK_MAX_CHARS, DEFAULT_FALLBACK_HEADLINE, DEFAULT_FALLBACK_ACTION, DEFAULT_EMPTY_FALLBACK_TEXT } from \"./opportunity/opportunity.safe-presentation.js\";\nexport type { SafeFallbackOptions, SafePresentation, SafePresentationOptions, SafePresentationSource } from \"./opportunity/opportunity.safe-presentation.js\";\nexport { getOrCreateDeliveryCardBatch, DELIVERY_CARD_CACHE_TTL, type CachedDeliveryCard, type OpportunityWithContext } from \"./opportunity/delivery-card.cache.js\";\n\n// ─── Tools ────────────────────────────────────────────────────────────────────\n\nexport { createToolRegistry } from \"./shared/agent/tool.registry.js\";\nexport { createAgentTools } from './agent/agent.tools.js';\nexport { AMBIENT_PARK_WINDOW_MS } from './negotiation/negotiation.tools.js';\nexport { normalizeTelegramHandle } from './shared/utils/telegram-handle.js';\n\n// ─── MCP ──────────────────────────────────────────────────────────────────────\n\nexport { createMcpServer, computeAgentAllowedNetworkIds, buildMcpOnboardingMessage, ONBOARDING_ALLOWED } from \"./mcp/mcp.server.js\";\nexport type { ScopedDepsFactory } from \"./mcp/mcp.server.js\";\nexport { buildElicitationCreate, flattenChoice } from \"./mcp/elicitation.builder.js\";\nexport { dispatchElicitations } from \"./mcp/elicitation.dispatcher.js\";\nexport type { ElicitResultLike, ElicitInputFn, DispatchElicitationsParams } from \"./mcp/elicitation.dispatcher.js\";\n\n// ─── States (for advanced graph consumers) ────────────────────────────────────\n// @experimental — internal graph-state shapes; may change in a minor release.\n\nexport type { UserNegotiationContext, NegotiationTurn, NegotiationOutcome, SeedAssessment } from \"./shared/schemas/negotiation-state.schema.js\";\nexport type { NegotiationGraphLike } from \"./negotiation/negotiation.state.js\";\n\n// ─── Streamers ────────────────────────────────────────────────────────────────\n\nexport { ChatStreamer } from \"./chat/chat.streamer.js\";\nexport { ResponseStreamer } from \"./shared/agent/response.streamer.js\";\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,6CAA6C;AAC7C,EAAE;AACF,4DAA4D;AAC5D,gFAAgF;AAChF,+EAA+E;AAC/E,qDAAqD;AACrD,EAAE;AACF,yDAAyD;AACzD,2EAA2E;AAC3E,mEAAmE;AACnE,+EAA+E;AAC/E,iFAAiF;AACjF,gFAAgF;AAEhF,iFAAiF;AAEjF,OAAO,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAI9D,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AAC5F,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,gBAAgB,EAChB,mBAAmB,EACnB,eAAe,EACf,kBAAkB,GACnB,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,uCAAuC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,wBAAwB,EAAE,MAAM,gCAAgC,CAAC;AAcrI,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,yCAAyC,CAAC;AAyCrG,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAE1E,iFAAiF;AAEjF,OAAO,EAAE,uBAAuB,EAA0B,MAAM,yCAAyC,CAAC;AAC1G,OAAO,EAAE,oBAAoB,EAAE,cAAc,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,+BAA+B,EAAE,kBAAkB,EAAE,uBAAuB,EAAE,mBAAmB,EA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AE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC","sourcesContent":["// =============================================================================\n// @indexnetwork/protocol — public API barrel\n//\n// This file is the ONLY supported entry point. Deep imports\n// (\"@indexnetwork/protocol/src/...\") are not part of the contract and may break\n// in any release. Every symbol is re-exported explicitly (no wildcards) so the\n// surface is reviewable and changes are intentional.\n//\n// Stability tiers are defined in STABILITY.md. In short:\n// • Stable — Interfaces, Graph factories, Agents, createChatTools,\n// the tool/runtime helpers, and shared schemas.\n// • Experimental — Sections marked @experimental below (advanced graph state\n// types and internal helpers); may change in a minor release.\n// =============================================================================\n\n// ─── Public API (recommended for external consumers) ──────────────────────────\n\nexport { createChatTools } from \"./shared/agent/tool.factory.js\";\nexport { getModelName } from \"./shared/agent/model.config.js\";\nexport type { ChatTools } from \"./shared/agent/tool.factory.js\";\nexport type { ModelConfig, ModelSettings } from \"./shared/agent/model.config.js\";\nexport type { ToolContext, ResolvedToolContext, ToolDeps, ProtocolDeps, RawToolDefinition, CompiledGraph } from \"./shared/agent/tool.helpers.js\";\nexport { ChatContextAccessError, resolveChatContext } from \"./shared/agent/tool.helpers.js\";\nexport {\n deriveAllowedNetworkIds,\n deriveDiscoveryNetworkIds,\n focusedNetworkId,\n focusedNetworkLabel,\n hasNetworkScope,\n scopeFromNetworkId,\n} from \"./shared/agent/tool.scope.js\";\nexport type { ToolScopeEnvelope, ToolScopeType, ScopeMembership, DeriveNetworkScopeInput } from \"./shared/agent/tool.scope.js\";\nexport { requestContext } from \"./shared/observability/request-context.js\";\nexport { setTimingWrapper } from \"./shared/observability/performance.js\";\nexport { ToolRuntimeError, getToolTimeoutPolicy, invokeToolRuntime, toolRuntimeErrorToResult } from \"./shared/agent/tool.runtime.js\";\nexport type { ToolRuntimeErrorCode, ToolTimeoutClass, ToolTimeoutPolicy } from \"./shared/agent/tool.runtime.js\";\n\n// ─── Interfaces (implement these to wire up your infrastructure) ───────────────\n\nexport type { McpAuthResolver } from \"./shared/interfaces/auth.interface.js\";\nexport type { Cache, CacheOptions, HydeCache, OpportunityCache } from \"./shared/interfaces/cache.interface.js\";\nexport type { ChatSessionReader, ChatSessionDetail, ChatSessionSummary } from \"./shared/interfaces/chat-session.interface.js\";\nexport type { ChatSummaryReader } from \"./shared/interfaces/chat-summary.interface.js\";\nexport type { ChatMessageWriter } from \"./shared/interfaces/chat-message-writer.interface.js\";\nexport type { QuestionGeneratorReader } from \"./shared/interfaces/question-generator.interface.js\";\nexport type { QuestionerDatabase, PersistableQuestion, PersistedQuestion, QuestionFilters, ChatQuestionsHost, ChatQuestionAnswerOutcome } from \"./shared/interfaces/questioner.interface.js\";\nexport type { NegotiationSummaryReader } from \"./shared/interfaces/negotiation-summary.interface.js\";\nexport type { DiscoveryNegotiationDigest } from \"./shared/schemas/negotiation-digest.schema.js\";\nexport { NegotiationSummarizer, buildFallbackDigest } from \"./negotiation/negotiation.summarizer.js\";\nexport type { ContactServiceAdapter, ContactEntry, ContactImportResult, ContactInput, ContactResult, ContactSearchResult } from \"./shared/interfaces/contact.interface.js\";\nexport type {\n ChatGraphCompositeDatabase, UserDatabase, SystemDatabase, Database,\n OpportunityGraphDatabase, OpportunityControllerDatabase, HomeGraphDatabase,\n IntentGraphDatabase, IntentNetworkGraphDatabase, NetworkGraphDatabase, NetworkMembershipGraphDatabase,\n HydeGraphDatabase, EnrichmentGraphDatabase, PremiseGraphDatabase, NegotiationGraphDatabase,\n NegotiationQueries, NegotiationUserAnswer,\n Opportunity, OpportunityActor, OpportunityContext, OpportunityDetection, OpportunityInterpretation,\n OpportunityQueryOptions, OpportunitySignal, OpportunityStatus,\n ActiveIntent, CreatedIntent, CreateIntentData, UpdateIntentData, IntentRecord, SimilarIntent, SimilarIntentSearchOptions,\n IndexedIntentDetails, IndexMemberDetails, AssignmentNetworkMembership, NetworkAssignmentContext, NetworkMembership, OwnedIndex,\n CreateHydeDocumentData, HydeDocument, HydeSourceType, CreateOpportunityData,\n PremiseAnalysis, PremiseAssertion, PremiseProvenance, PremiseRecord, PremiseValidity,\n OnboardingPrivacyState, OnboardingProfileSeed, OnboardingState, PrivacyConsentDecision, PrivacyConsentSource,\n UpdateIndexSettingsData, UserRecord, UserSocial, ArchiveResult, Id,\n} from \"./shared/interfaces/database.interface.js\";\nexport type {\n Embedder, EmbeddingGenerator, EmbeddingGenerateOptions,\n VectorStore, VectorStoreOption, VectorSearchResult,\n HydeCandidate, HydeSearchOptions, LensEmbedding,\n} from \"./shared/interfaces/embedder.interface.js\";\nexport type { ProfileEnricher, EnrichmentRequest, EnrichmentResult } from \"./shared/interfaces/enrichment.interface.js\";\nexport type { IntegrationAdapter, IntegrationConnection, IntegrationSession, IntegrationSessionOptions, ToolActionResponse } from \"./shared/interfaces/integration.interface.js\";\nexport type { IntentGraphQueue } from \"./shared/interfaces/queue.interface.js\";\nexport type { Scraper, ExtractUrlContentOptions } from \"./shared/interfaces/scraper.interface.js\";\nexport type { Storage } from \"./shared/interfaces/storage.interface.js\";\nexport type { DeliveryLedger, DeliveredOpportunityRow } from \"./shared/interfaces/delivery-ledger.interface.js\";\nexport type { MintConnectLink, ConnectLinkKind } from \"./shared/interfaces/connect-link.interface.js\";\nexport type {\n DiscoveryRunStore, DiscoveryRunQueue, DiscoveryRunInput, CreateDiscoveryRunInput,\n DiscoveryRunRecord, DiscoveryRunStatus,\n} from \"./shared/interfaces/discovery-run.interface.js\";\nexport type {\n EnrichmentRunStore, EnrichmentRunQueue, EnrichmentRunInput, CreateEnrichmentRunInput,\n UpdateUserEnrichmentRunInput, PreviewUserEnrichmentRunInput,\n EnrichmentRunRecord, EnrichmentRunStatus, EnrichmentRunOperation,\n} from \"./shared/interfaces/enrichment-run.interface.js\";\nexport type { NegotiationTimeoutQueue } from \"./shared/interfaces/negotiation-events.interface.js\";\nexport type { AgentDispatcher, AgentDispatchResult, NegotiationTurnPayload } from \"./shared/interfaces/agent-dispatcher.interface.js\";\nexport type { AgentRecord, AgentTransportRecord, AgentPermissionRecord, AgentWithRelations, CreateAgentInput, CreateTransportInput, GrantPermissionInput, AgentDatabase } from './shared/interfaces/agent.interface.js';\nexport { SYSTEM_AGENT_IDS } from './shared/interfaces/agent.interface.js';\n\n// ─── Shared schemas ───────────────────────────────────────────────────────────\n\nexport { ChatContextDigestSchema, type ChatContextDigest } from \"./shared/schemas/chat-context.schema.js\";\nexport { QuestionOptionSchema, QuestionSchema, QuestionStrategySchema, QuestionWithStrategySchema, QuestionGeneratorResponseSchema, QuestionModeSchema, QuestionDetectionSchema, QuestionActorSchema, QuestionAnswerSchema, type Question, type QuestionOption, type QuestionStrategy, type QuestionWithStrategy, type QuestionGeneratorResponse, type QuestionGenerationResult, type QuestionMode, type QuestionDetection, type QuestionActor, type QuestionAnswer } from \"./shared/schemas/question.schema.js\";\nexport type { PendingQuestionSummary } from \"./shared/schemas/pending-question.schema.js\";\nexport type { McpAuthInput } from \"./shared/schemas/mcp-auth.schema.js\";\nexport { UserIdentitySchema, type UserIdentity } from \"./shared/schemas/identity.schema.js\";\nexport type { DiscoverySourceProfile, DiscoverySummary, DiscoveryNegotiation, DiscoveryTurn, DiscoveryOutcome, DiscoveryQuestionInput, NegotiationRole } from \"./shared/schemas/discovery-question.schema.js\";\nexport { NetworkAssignmentResourceTypeSchema, NetworkAssignmentModeSchema, NetworkAssignmentScopeSchema, NetworkAssignmentPromptPresenceSchema, NetworkAssignmentPolicySchema, NetworkAssignmentRawScoresSchema, NetworkAssignmentMetadataSchema, OpportunityEvidenceKindSchema, OpportunityEvidenceSchema } from \"./shared/schemas/network-assignment.schema.js\";\nexport type { NetworkAssignmentResourceType, NetworkAssignmentMode, NetworkAssignmentScope, NetworkAssignmentPromptPresence, NetworkAssignmentPolicy, NetworkAssignmentRawScores, NetworkAssignmentMetadata, OpportunityEvidenceKind, OpportunityEvidence } from \"./shared/schemas/network-assignment.schema.js\";\nexport { DEFAULT_NETWORK_ASSIGNMENT_THRESHOLD, classifyPromptPresence, resolveAssignmentNetworkScope, buildNetworkAssignmentDecision, combineAssignmentScores } from \"./shared/assignment/network-assignment.policy.js\";\nexport type { PromptPresenceInput, ResolveAssignmentNetworkScopeArgs, AssignmentScopeMembership, BuildNetworkAssignmentDecisionArgs, NetworkAssignmentDecision } from \"./shared/assignment/network-assignment.policy.js\";\nexport { buildCandidateEvidence, withCandidateEvidence, mergeOpportunityEvidence, withMatchedStrategies, renderOpportunityEvidenceForPrompt } from \"./opportunity/opportunity.evidence.js\";\nexport type { EvidenceCandidateInput } from \"./opportunity/opportunity.evidence.js\";\n\n// ─── Graph factories ──────────────────────────────────────────────────────────\n\nexport { ChatGraphFactory } from \"./chat/chat.graph.js\";\nexport { HomeGraphFactory } from \"./opportunity/feed/feed.graph.js\";\nexport { HydeGraphFactory } from \"./shared/hyde/hyde.graph.js\";\nexport { NetworkGraphFactory } from \"./network/network.graph.js\";\nexport { NetworkMembershipGraphFactory } from \"./network/membership/membership.graph.js\";\nexport { IntentGraphFactory } from \"./intent/intent.graph.js\";\nexport { IntentNetworkGraphFactory } from \"./network/indexer/indexer.graph.js\";\nexport { MaintenanceGraphFactory } from \"./maintenance/maintenance.graph.js\";\nexport type { MaintenanceGraphDatabase, MaintenanceGraphCache, MaintenanceGraphQueue } from \"./maintenance/maintenance.graph.js\";\nexport { NegotiationGraphFactory, createDefaultNegotiationGraph, negotiateCandidates } from \"./negotiation/negotiation.graph.js\";\nexport { OpportunityGraphFactory } from \"./opportunity/opportunity.graph.js\";\nexport { EnrichmentGraphFactory } from \"./enrichment/enrichment.graph.js\";\nexport { PremiseGraphFactory } from \"./premise/premise.graph.js\";\n\n// ─── Agents ───────────────────────────────────────────────────────────────────\n\nexport { UserContextGenerator } from \"./context/context.generator.js\";\nexport type { UserContextInput, IncrementalContextInput, UserContextResult, GlobalContextInput, GlobalIncrementalContextInput } from \"./context/context.generator.js\";\nexport { ChatTitleGenerator } from \"./chat/chat.title.generator.js\";\nexport { ChatInterruptClassifier } from \"./chat/chat.interrupt.classifier.js\";\nexport type { ClassifyInterruptInput } from \"./chat/chat.interrupt.classifier.js\";\nexport { ChatSummarizer } from \"./chat/chat.summarizer.js\";\nexport type { ChatSummarizerInput, ChatSummarizerMessage } from \"./chat/chat.summarizer.js\";\nexport { HydeGenerator } from \"./shared/hyde/hyde.generator.js\";\nexport { SuggestionGenerator } from \"./chat/chat.suggester.js\";\nexport type { SuggestionGeneratorInput } from \"./chat/chat.suggester.js\";\nexport { generateInviteMessage } from \"./contact/contact.inviter.js\";\nexport type { InviteInput, InviteOutput } from \"./contact/contact.inviter.js\";\nexport { IntentIndexer } from \"./intent/intent.indexer.js\";\nexport type { IntentIndexerOutput } from \"./intent/intent.indexer.js\";\nexport { PremiseAnalyzer } from \"./premise/premise.analyzer.js\";\nexport type { PremiseAnalyzerOutput } from \"./premise/premise.analyzer.js\";\nexport { PremiseDecomposer } from \"./premise/premise.decomposer.js\";\nexport type { PremiseDecomposerOutput, DecomposedPremise } from \"./premise/premise.decomposer.js\";\nexport { PremiseIndexer } from \"./premise/premise.indexer.js\";\nexport type { PremiseIndexerOutput } from \"./premise/premise.indexer.js\";\nexport { LensInferrer } from \"./shared/hyde/lens.inferrer.js\";\nexport { NegotiationInsightsGenerator } from \"./negotiation/insight.generator.js\";\nexport type { NegotiationDigest } from \"./negotiation/insight.generator.js\";\nexport { IndexNegotiator } from \"./negotiation/negotiation.agent.js\";\nexport type { NegotiationAgentInput } from \"./negotiation/negotiation.agent.js\";\nexport { QuestionerAgent } from \"./questioner/questioner.agent.js\";\nexport type { QuestionerAgentConfig } from \"./questioner/questioner.agent.js\";\nexport type { QuestionerInput, QuestionerContext, QuestionerEnqueuePayload, QuestionerEnqueueFn, DiscoveryContext, IntentContext, ProfileContext, NegotiationContext, ChatContext } from \"./questioner/questioner.types.js\";\nexport { getPreset } from \"./questioner/questioner.presets.js\";\nexport type { QuestionerPreset } from \"./questioner/questioner.presets.js\";\nexport { OpportunityEvaluator } from \"./opportunity/opportunity.evaluator.js\";\nexport type { EvaluatorInput, OpportunityEvaluatorOptionsConstructor } from \"./opportunity/opportunity.evaluator.js\";\nexport { OpportunityPresenter, gatherPresenterContext } from \"./opportunity/opportunity.presenter.js\";\nexport { createOpportunityTools } from \"./opportunity/opportunity.tools.js\";\nexport { createEnrichmentTools } from \"./enrichment/enrichment.tools.js\";\nexport type { PresenterDatabase } from \"./opportunity/opportunity.presenter.js\";\nexport { QuestionGenerator } from \"./opportunity/question.generator.js\";\n\n// ─── Support utilities ────────────────────────────────────────────────────────\n\nexport { renderNetworkContext } from './shared/network/metadata.renderer.js';\nexport { canUserSeeOpportunity, isActionableForViewer, validateOpportunityActors, classifyOpportunity, selectByComposition, selectDigestCandidates, DIGEST_REDELIVERY_COOLDOWN_DAYS, FEED_SOFT_TARGETS } from \"./opportunity/opportunity.utils.js\";\nexport type { DigestDeliveredRow } from \"./opportunity/opportunity.utils.js\";\nexport { getPrimaryActionLabel } from \"./opportunity/opportunity.labels.js\";\nexport { computeFeedHealth } from \"./opportunity/feed/feed.health.js\";\nexport type { FeedHealthInput, FeedHealthResult } from \"./opportunity/feed/feed.health.js\";\nexport { selectContactsForDiscovery, shouldRunIntroducerDiscovery, runIntroducerDiscovery, MAX_CONTACTS_PER_CYCLE, MAX_CANDIDATES_PER_CONTACT, INTRODUCER_DISCOVERY_SOURCE } from \"./opportunity/opportunity.introducer.js\";\nexport type { IntroducerDiscoveryDatabase, IntroducerDiscoveryQueue, ContactWithIntents } from \"./opportunity/opportunity.introducer.js\";\nexport { persistOpportunities } from \"./opportunity/opportunity.persist.js\";\nexport { presentOpportunity } from \"./opportunity/opportunity.presentation.js\";\nexport type { UserInfo } from \"./opportunity/opportunity.presentation.js\";\nexport { stripUuids, stripIntroducerMentions, truncateAtBoundary } from \"./opportunity/opportunity.presentation.js\";\nexport { safeFallbackSummary, getSafePresentationOrSkip, SAFE_FALLBACK_MAX_CHARS, DEFAULT_FALLBACK_HEADLINE, DEFAULT_FALLBACK_ACTION, DEFAULT_EMPTY_FALLBACK_TEXT } from \"./opportunity/opportunity.safe-presentation.js\";\nexport type { SafeFallbackOptions, SafePresentation, SafePresentationOptions, SafePresentationSource } from \"./opportunity/opportunity.safe-presentation.js\";\nexport { getOrCreateDeliveryCardBatch, DELIVERY_CARD_CACHE_TTL, type CachedDeliveryCard, type OpportunityWithContext } from \"./opportunity/delivery-card.cache.js\";\n\n// ─── Tools ────────────────────────────────────────────────────────────────────\n\nexport { createToolRegistry } from \"./shared/agent/tool.registry.js\";\nexport { createAgentTools } from './agent/agent.tools.js';\nexport { AMBIENT_PARK_WINDOW_MS } from './negotiation/negotiation.tools.js';\nexport { normalizeTelegramHandle } from './shared/utils/telegram-handle.js';\n\n// ─── MCP ──────────────────────────────────────────────────────────────────────\n\nexport { createMcpServer, computeAgentAllowedNetworkIds, buildMcpOnboardingMessage, ONBOARDING_ALLOWED } from \"./mcp/mcp.server.js\";\nexport type { ScopedDepsFactory } from \"./mcp/mcp.server.js\";\nexport { buildElicitationCreate, flattenChoice } from \"./mcp/elicitation.builder.js\";\nexport { dispatchElicitations } from \"./mcp/elicitation.dispatcher.js\";\nexport type { ElicitResultLike, ElicitInputFn, DispatchElicitationsParams } from \"./mcp/elicitation.dispatcher.js\";\n\n// ─── States (for advanced graph consumers) ────────────────────────────────────\n// @experimental — internal graph-state shapes; may change in a minor release.\n\nexport type { UserNegotiationContext, NegotiationTurn, NegotiationOutcome, SeedAssessment } from \"./shared/schemas/negotiation-state.schema.js\";\nexport type { NegotiationGraphLike } from \"./negotiation/negotiation.state.js\";\n\n// ─── Streamers ────────────────────────────────────────────────────────────────\n\nexport { ChatStreamer } from \"./chat/chat.streamer.js\";\nexport { ResponseStreamer } from \"./shared/agent/response.streamer.js\";\n"]}
|
|
@@ -27,6 +27,8 @@ declare const responseFormat: z.ZodObject<{
|
|
|
27
27
|
tier: "assertive" | "contextual";
|
|
28
28
|
validityDays: number | null;
|
|
29
29
|
}>, "many">;
|
|
30
|
+
retractedPremiseIds: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
31
|
+
revisedBio: z.ZodDefault<z.ZodNullable<z.ZodString>>;
|
|
30
32
|
}, "strip", z.ZodTypeAny, {
|
|
31
33
|
premises: {
|
|
32
34
|
text: string;
|
|
@@ -34,6 +36,8 @@ declare const responseFormat: z.ZodObject<{
|
|
|
34
36
|
validityDays: number | null;
|
|
35
37
|
}[];
|
|
36
38
|
reasoning: string;
|
|
39
|
+
retractedPremiseIds: string[];
|
|
40
|
+
revisedBio: string | null;
|
|
37
41
|
}, {
|
|
38
42
|
premises: {
|
|
39
43
|
text: string;
|
|
@@ -41,7 +45,14 @@ declare const responseFormat: z.ZodObject<{
|
|
|
41
45
|
validityDays: number | null;
|
|
42
46
|
}[];
|
|
43
47
|
reasoning: string;
|
|
48
|
+
retractedPremiseIds?: string[] | undefined;
|
|
49
|
+
revisedBio?: string | null | undefined;
|
|
44
50
|
}>;
|
|
51
|
+
/** An existing ACTIVE premise offered to the decomposer for retraction matching. */
|
|
52
|
+
export interface ExistingPremiseRef {
|
|
53
|
+
id: string;
|
|
54
|
+
text: string;
|
|
55
|
+
}
|
|
45
56
|
export type PremiseDecomposerOutput = z.infer<typeof responseFormat>;
|
|
46
57
|
export type DecomposedPremise = z.infer<typeof premiseItemSchema>;
|
|
47
58
|
/**
|
|
@@ -51,7 +62,7 @@ export type DecomposedPremise = z.infer<typeof premiseItemSchema>;
|
|
|
51
62
|
export declare class PremiseDecomposer {
|
|
52
63
|
private model;
|
|
53
64
|
constructor();
|
|
54
|
-
invoke(input: string): Promise<PremiseDecomposerOutput>;
|
|
65
|
+
invoke(input: string, existingPremises?: ExistingPremiseRef[], currentBio?: string): Promise<PremiseDecomposerOutput>;
|
|
55
66
|
}
|
|
56
67
|
export {};
|
|
57
68
|
//# sourceMappingURL=premise.decomposer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"premise.decomposer.d.ts","sourceRoot":"/","sources":["premise/premise.decomposer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;
|
|
1
|
+
{"version":3,"file":"premise.decomposer.d.ts","sourceRoot":"/","sources":["premise/premise.decomposer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAkIxB,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,CAAqE;;IAUrE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,gBAAgB,CAAC,EAAE,kBAAkB,EAAE,EAAE,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAiDnI"}
|
|
@@ -60,6 +60,47 @@ DECOMPOSITION RULES
|
|
|
60
60
|
7. Skip vague or uninformative statements ("I like stuff", "I'm a person")
|
|
61
61
|
8. Skip desires, requests, or intents ("I'm looking for...", "I want to...") — those are intents, not premises
|
|
62
62
|
9. If the input contains NO extractable premises (e.g. just "Yes" or "Hello"), return an empty array
|
|
63
|
+
10. NEVER extract denials or removal instructions as premises. "I have nothing to do with X",
|
|
64
|
+
"I am not a Y", or "remove X from my profile" are retractions, not facts — handle them
|
|
65
|
+
via the retraction rules below and do NOT emit a premise for them.
|
|
66
|
+
|
|
67
|
+
═════════════════════════════════════════════════
|
|
68
|
+
RETRACTION RULES
|
|
69
|
+
═════════════════════════════════════════════════
|
|
70
|
+
|
|
71
|
+
When the message includes the user's EXISTING PREMISES (listed with ids), you must also
|
|
72
|
+
detect which of them the input disavows and return their ids in \`retractedPremiseIds\`.
|
|
73
|
+
|
|
74
|
+
A premise must be retracted when the input:
|
|
75
|
+
- Explicitly asks to remove it ("remove all mentions of X", "delete the part about Y")
|
|
76
|
+
- Denies it ("I have nothing to do with X", "I never worked at Y", "that's not true")
|
|
77
|
+
- States it no longer holds ("I no longer live in Berlin", "I left Google")
|
|
78
|
+
- Directly contradicts it ("I'm based in Istanbul" contradicts "I am based in Ankara")
|
|
79
|
+
|
|
80
|
+
Rules:
|
|
81
|
+
- Only return ids that appear in the provided EXISTING PREMISES list — never invent ids.
|
|
82
|
+
- Retract EVERY existing premise that matches the disavowed topic, not just the first one.
|
|
83
|
+
- Do not retract premises the input merely omits — silence is not disavowal.
|
|
84
|
+
- If no existing premises are provided, or nothing is disavowed, return an empty array.
|
|
85
|
+
- Retraction and extraction are independent: an input can retract old premises AND
|
|
86
|
+
contribute new ones in the same pass.
|
|
87
|
+
|
|
88
|
+
═══════════════════════════════════════════════════
|
|
89
|
+
BIO REVISION RULES
|
|
90
|
+
═══════════════════════════════════════════════════
|
|
91
|
+
|
|
92
|
+
When the message includes the user's CURRENT BIO, check whether the input disavows,
|
|
93
|
+
removes, or corrects anything that appears in it.
|
|
94
|
+
|
|
95
|
+
- If it does, return \`revisedBio\`: the bio rewritten with those facts removed or
|
|
96
|
+
corrected. Preserve everything the input does not dispute — same tone, similar
|
|
97
|
+
length, no inventions.
|
|
98
|
+
- If the input explicitly rewrites the bio ("update my bio to X"), return that
|
|
99
|
+
rewritten bio.
|
|
100
|
+
- NEVER add new facts to the bio — new information becomes premises, not bio edits.
|
|
101
|
+
Purely additive input ("I also enjoy X") must return revisedBio: null.
|
|
102
|
+
- If the bio is unaffected, or no CURRENT BIO was provided, return null.
|
|
103
|
+
- Never return a revised bio that still mentions a disavowed fact.
|
|
63
104
|
|
|
64
105
|
═══════════════════════════════════════════════════
|
|
65
106
|
EXAMPLES
|
|
@@ -82,6 +123,17 @@ Output:
|
|
|
82
123
|
|
|
83
124
|
Input: "Yes, create my profile"
|
|
84
125
|
Output: [] (empty — no premises)
|
|
126
|
+
|
|
127
|
+
Input: "Remove all mentions of the HOPE programming language. I have nothing to do with it. I specialize in compiler design."
|
|
128
|
+
Existing premises:
|
|
129
|
+
- id: aaaa-1 · "I am the creator of the HOPE programming language"
|
|
130
|
+
- id: aaaa-2 · "I specialize in compiler design"
|
|
131
|
+
- id: aaaa-3 · "I am based in Istanbul"
|
|
132
|
+
Current bio: "Software engineer in Istanbul. Creator of the HOPE programming language. Specializes in compiler design."
|
|
133
|
+
Output:
|
|
134
|
+
premises: [] (compiler design already exists as aaaa-2 — nothing new to add)
|
|
135
|
+
retractedPremiseIds: ["aaaa-1"]
|
|
136
|
+
revisedBio: "Software engineer in Istanbul. Specializes in compiler design."
|
|
85
137
|
`;
|
|
86
138
|
const premiseItemSchema = z.object({
|
|
87
139
|
text: z.string().describe("The premise text in first person (e.g. 'I am a software engineer at Google')"),
|
|
@@ -91,6 +143,8 @@ const premiseItemSchema = z.object({
|
|
|
91
143
|
const responseFormat = z.object({
|
|
92
144
|
reasoning: z.string().describe("Brief analysis of what factual claims can be extracted from the input"),
|
|
93
145
|
premises: z.array(premiseItemSchema).describe("Array of extracted premises. Empty if input contains no self-descriptive facts."),
|
|
146
|
+
retractedPremiseIds: z.array(z.string()).default([]).describe("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."),
|
|
147
|
+
revisedBio: z.string().nullable().default(null).describe("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."),
|
|
94
148
|
});
|
|
95
149
|
/**
|
|
96
150
|
* Decomposes free-text input (chat messages, bios, scraped content) into
|
|
@@ -103,23 +157,51 @@ export class PremiseDecomposer {
|
|
|
103
157
|
name: "premise_decomposer",
|
|
104
158
|
});
|
|
105
159
|
}
|
|
106
|
-
async invoke(input) {
|
|
107
|
-
logger.verbose(`[PremiseDecomposer.invoke] Decomposing input (${input.length} chars)`);
|
|
108
|
-
const
|
|
160
|
+
async invoke(input, existingPremises, currentBio) {
|
|
161
|
+
logger.verbose(`[PremiseDecomposer.invoke] Decomposing input (${input.length} chars, ${existingPremises?.length ?? 0} existing premise(s), bio: ${currentBio ? 'yes' : 'no'})`);
|
|
162
|
+
const existingBlock = existingPremises?.length
|
|
163
|
+
? `\n\nEXISTING PREMISES (retract by id when the input disavows them):\n${existingPremises
|
|
164
|
+
.map((p) => `- id: ${p.id} · "${p.text}"`)
|
|
165
|
+
.join("\n")}`
|
|
166
|
+
: "";
|
|
167
|
+
const bioBlock = currentBio?.trim()
|
|
168
|
+
? `\n\nCURRENT BIO (return revisedBio when the input disavows or corrects anything in it):\n${currentBio.trim()}`
|
|
169
|
+
: "";
|
|
170
|
+
const prompt = `Decompose the following text into individual premises:\n\n${input}${existingBlock}${bioBlock}`;
|
|
109
171
|
const messages = [
|
|
110
172
|
new SystemMessage(systemPrompt),
|
|
111
173
|
new HumanMessage(prompt),
|
|
112
174
|
];
|
|
113
175
|
const result = await invokeWithAbortSignal(this.model, messages);
|
|
114
176
|
const output = responseFormat.parse(result);
|
|
115
|
-
|
|
177
|
+
// Guard against hallucinated ids: only keep retractions that reference premises we offered.
|
|
178
|
+
const knownIds = new Set((existingPremises ?? []).map((p) => p.id));
|
|
179
|
+
const droppedIds = output.retractedPremiseIds.filter((id) => !knownIds.has(id));
|
|
180
|
+
if (droppedIds.length > 0) {
|
|
181
|
+
logger.warn(`[PremiseDecomposer.invoke] Dropped ${droppedIds.length} unknown retraction id(s)`, { droppedIds });
|
|
182
|
+
}
|
|
183
|
+
output.retractedPremiseIds = output.retractedPremiseIds.filter((id) => knownIds.has(id));
|
|
184
|
+
// A revised bio is only meaningful when we offered one to revise. Also
|
|
185
|
+
// normalize structured-output quirks: literal "null", empty strings, and
|
|
186
|
+
// no-op rewrites all mean "bio unaffected".
|
|
187
|
+
const normalizedBio = output.revisedBio?.trim();
|
|
188
|
+
if (!currentBio?.trim() ||
|
|
189
|
+
!normalizedBio ||
|
|
190
|
+
normalizedBio.toLowerCase() === 'null' ||
|
|
191
|
+
normalizedBio === currentBio.trim()) {
|
|
192
|
+
output.revisedBio = null;
|
|
193
|
+
}
|
|
194
|
+
else {
|
|
195
|
+
output.revisedBio = normalizedBio;
|
|
196
|
+
}
|
|
197
|
+
logger.verbose(`[PremiseDecomposer.invoke] Extracted ${output.premises.length} premise(s), ${output.retractedPremiseIds.length} retraction(s), revisedBio: ${output.revisedBio ? 'yes' : 'no'}`);
|
|
116
198
|
return output;
|
|
117
199
|
}
|
|
118
200
|
}
|
|
119
201
|
__decorate([
|
|
120
202
|
Timed(),
|
|
121
203
|
__metadata("design:type", Function),
|
|
122
|
-
__metadata("design:paramtypes", [String]),
|
|
204
|
+
__metadata("design:paramtypes", [String, Array, String]),
|
|
123
205
|
__metadata("design:returntype", Promise)
|
|
124
206
|
], PremiseDecomposer.prototype, "invoke", null);
|
|
125
207
|
//# sourceMappingURL=premise.decomposer.js.map
|
|
@@ -1 +1 @@
|
|
|
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,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,MAAM,GAAG,cAAc,CAAC,mBAAmB,CAAC,CAAC;AAEnD,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;QACjE,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAE5C,MAAM,CAAC,OAAO,CAAC,wCAAwC,MAAM,CAAC,QAAQ,CAAC,MAAM,aAAa,CAAC,CAAC;QAC5F,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAhBc;IADZ,KAAK,EAAE;;;;+CAgBP","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 { createModel } from \"../shared/agent/model.config.js\";\nimport { invokeWithAbortSignal } from \"../shared/agent/model-signal.js\";\n\nconst logger = protocolLogger(\"PremiseDecomposer\");\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\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`;\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});\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<ReturnType<typeof createModel>[\"withStructuredOutput\"]>;\n\n constructor() {\n const model = createModel(\"premiseDecomposer\");\n this.model = model.withStructuredOutput(responseFormat, {\n name: \"premise_decomposer\",\n });\n }\n\n @Timed()\n public async invoke(input: string): Promise<PremiseDecomposerOutput> {\n logger.verbose(`[PremiseDecomposer.invoke] Decomposing input (${input.length} chars)`);\n\n const prompt = `Decompose the following text into individual premises:\\n\\n${input}`;\n\n const messages = [\n new SystemMessage(systemPrompt),\n new HumanMessage(prompt),\n ];\n\n const result = await invokeWithAbortSignal(this.model, messages);\n const output = responseFormat.parse(result);\n\n logger.verbose(`[PremiseDecomposer.invoke] Extracted ${output.premises.length} premise(s)`);\n return output;\n }\n}\n"]}
|
|
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,MAAM,4CAA4C,CAAC;AAC5E,OAAO,EAAE,KAAK,EAAE,MAAM,wCAAwC,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MA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AK,EAAE;;;;+CAiDP","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 { createModel } from \"../shared/agent/model.config.js\";\nimport { invokeWithAbortSignal } from \"../shared/agent/model-signal.js\";\n\nconst logger = protocolLogger(\"PremiseDecomposer\");\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<ReturnType<typeof createModel>[\"withStructuredOutput\"]>;\n\n constructor() {\n const model = createModel(\"premiseDecomposer\");\n this.model = model.withStructuredOutput(responseFormat, {\n name: \"premise_decomposer\",\n });\n }\n\n @Timed()\n public async invoke(input: string, existingPremises?: ExistingPremiseRef[], currentBio?: string): Promise<PremiseDecomposerOutput> {\n logger.verbose(`[PremiseDecomposer.invoke] Decomposing input (${input.length} chars, ${existingPremises?.length ?? 0} existing premise(s), bio: ${currentBio ? 'yes' : 'no'})`);\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);\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 logger.warn(`[PremiseDecomposer.invoke] Dropped ${droppedIds.length} unknown retraction id(s)`, { 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 logger.verbose(`[PremiseDecomposer.invoke] Extracted ${output.premises.length} premise(s), ${output.retractedPremiseIds.length} retraction(s), revisedBio: ${output.revisedBio ? 'yes' : 'no'}`);\n return output;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
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;AAQ5E,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,
|
|
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;AAQ5E,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,SAuRxE"}
|
|
@@ -68,12 +68,6 @@ export function createPremiseTools(defineTool, deps) {
|
|
|
68
68
|
indexesAssigned,
|
|
69
69
|
message: `Premise created and assigned to ${indexesAssigned} index${indexesAssigned === 1 ? "" : "es"}.`,
|
|
70
70
|
});
|
|
71
|
-
try {
|
|
72
|
-
deps.premiseEvents?.onCreated?.(premise.id, context.userId);
|
|
73
|
-
}
|
|
74
|
-
catch (e) {
|
|
75
|
-
logger.error('[createPremise] premiseEvents.onCreated failed', { error: e });
|
|
76
|
-
}
|
|
77
71
|
return createResult;
|
|
78
72
|
},
|
|
79
73
|
});
|
|
@@ -176,12 +170,6 @@ export function createPremiseTools(defineTool, deps) {
|
|
|
176
170
|
status: updated.status,
|
|
177
171
|
message: "Premise updated successfully (metadata only, no re-analysis).",
|
|
178
172
|
});
|
|
179
|
-
try {
|
|
180
|
-
deps.premiseEvents?.onUpdated?.(query.premiseId, context.userId);
|
|
181
|
-
}
|
|
182
|
-
catch (e) {
|
|
183
|
-
logger.error('[updatePremise] premiseEvents.onUpdated failed', { error: e });
|
|
184
|
-
}
|
|
185
173
|
return metadataResult;
|
|
186
174
|
}
|
|
187
175
|
// Text change requires the graph for re-analysis and re-embedding
|
|
@@ -213,12 +201,6 @@ export function createPremiseTools(defineTool, deps) {
|
|
|
213
201
|
status: updated.status,
|
|
214
202
|
message: "Premise updated successfully.",
|
|
215
203
|
});
|
|
216
|
-
try {
|
|
217
|
-
deps.premiseEvents?.onUpdated?.(query.premiseId, context.userId);
|
|
218
|
-
}
|
|
219
|
-
catch (e) {
|
|
220
|
-
logger.error('[updatePremise] premiseEvents.onUpdated failed', { error: e });
|
|
221
|
-
}
|
|
222
204
|
return updateResult;
|
|
223
205
|
},
|
|
224
206
|
});
|
|
@@ -256,12 +238,6 @@ export function createPremiseTools(defineTool, deps) {
|
|
|
256
238
|
id: query.premiseId,
|
|
257
239
|
message: "Premise retracted successfully.",
|
|
258
240
|
});
|
|
259
|
-
try {
|
|
260
|
-
deps.premiseEvents?.onRetracted?.(query.premiseId, context.userId);
|
|
261
|
-
}
|
|
262
|
-
catch (e) {
|
|
263
|
-
logger.error('[retractPremise] premiseEvents.onRetracted failed', { error: e });
|
|
264
|
-
}
|
|
265
241
|
return retractResult;
|
|
266
242
|
},
|
|
267
243
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"premise.tools.js","sourceRoot":"/","sources":["premise/premise.tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAE5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,MAAM,GAAG,cAAc,CAAC,mBAAmB,CAAC,CAAC;AAEnD,MAAM,UAAU,kBAAkB,CAAC,UAAsB,EAAE,IAAc;IACvE,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC/B,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;IAEzC,gFAAgF;IAChF,eAAe;IACf,gFAAgF;IAEhF,MAAM,aAAa,GAAG,UAAU,CAAC;QAC/B,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,wFAAwF;YACxF,wFAAwF;YACxF,oCAAoC;YACpC,cAAc;YACd,wGAAwG;YACxG,4DAA4D;YAC5D,yFAAyF;YACzF,+FAA+F;YAC/F,6DAA6D;YAC7D,8FAA8F;YAC9F,6FAA6F;YAC7F,8FAA8F;QAChG,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,sHAAsH,CAAC;YAC/J,IAAI,EAAE,CAAC,C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IAAI,QAAQ,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;gBACvC,OAAO,KAAK,CAAC,yCAAyC,CAAC,CAAC;YAC1D,CAAC;YACD,IAAI,QAAQ,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;gBACpC,OAAO,KAAK,CAAC,+BAA+B,CAAC,CAAC;YAChD,CAAC;YAED,MAAM,CAAC,OAAO,CAAC,uCAAuC,KAAK,CAAC,SAAS,aAAa,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YAEpG,MAAM,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,EAAE;gBAC5C,MAAM,EAAE,WAAW;gBACnB,WAAW,EAAE,IAAI,IAAI,EAAE;aACxB,CAAC,CAAC;YAEH,MAAM,aAAa,GAAG,OAAO,CAAC;gBAC5B,EAAE,EAAE,KAAK,CAAC,SAAS;gBACnB,OAAO,EAAE,iCAAiC;aAC3C,CAAC,CAAC;YACH,IAAI,CAAC;gBAAC,IAAI,CAAC,aAAa,EAAE,WAAW,EAAE,CAAC,KAAK,CAAC,SAAS,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;YAAC,CAAC;YAC3E,OAAO,CAAC,EAAE,CAAC;gBAAC,MAAM,CAAC,KAAK,CAAC,mDAAmD,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;YAAC,CAAC;YAC9F,OAAO,aAAa,CAAC;QACvB,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;AACtE,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\");\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 logger.verbose(`[createPremise] Creating premise for user ${context.userId}: \"${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 try { deps.premiseEvents?.onCreated?.(premise.id, context.userId); }\n catch (e) { logger.error('[createPremise] premiseEvents.onCreated failed', { error: e }); }\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 logger.verbose(`[readPremises] Fetching premises for user ${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 logger.verbose(`[updatePremise] Updating premise ${query.premiseId} for user ${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 try { deps.premiseEvents?.onUpdated?.(query.premiseId, context.userId); }\n catch (e) { logger.error('[updatePremise] premiseEvents.onUpdated failed', { error: e }); }\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 try { deps.premiseEvents?.onUpdated?.(query.premiseId, context.userId); }\n catch (e) { logger.error('[updatePremise] premiseEvents.onUpdated failed', { error: e }); }\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 logger.verbose(`[retractPremise] Retracting premise ${query.premiseId} for user ${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 try { deps.premiseEvents?.onRetracted?.(query.premiseId, context.userId); }\n catch (e) { logger.error('[retractPremise] premiseEvents.onRetracted failed', { error: e }); }\n return retractResult;\n },\n });\n\n return [createPremise, readPremises, updatePremise, retractPremise];\n}\n"]}
|
|
1
|
+
{"version":3,"file":"premise.tools.js","sourceRoot":"/","sources":["premise/premise.tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,4CAA4C,CAAC;AAE5E,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,MAAM,GAAG,cAAc,CAAC,mBAAmB,CAAC,CAAC;AAEnD,MAAM,UAAU,kBAAkB,CAAC,UAAsB,EAAE,IAAc;IACvE,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC;IAC/B,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;IAEzC,gFAAgF;IAChF,eAAe;IACf,gFAAgF;IAEhF,MAAM,aAAa,GAAG,UAAU,CAAC;QAC/B,IAAI,EAAE,gBAAgB;QACtB,WAAW,EACT,wFAAwF;YACxF,wFAAwF;YACxF,oCAAoC;YACpC,cAAc;YACd,wGAAwG;YACxG,4DAA4D;YAC5D,yFAAyF;YACzF,+FAA+F;YAC/F,6DAA6D;YAC7D,8FAA8F;YAC9F,6FAA6F;YAC7F,8FAA8F;QAChG,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC;YACpB,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,sHAAsH,CAAC;YAC/J,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,WAAW,EAAE,YAAY,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,wHAAwH,CAAC;YACjM,SAAS,EAAE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,CAAC,IAAI,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;gBACtC,OAAO,KAAK,CAAC,2BAA2B,CAAC,CAAC;YAC5C,CAAC;YAED,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,UAAU,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;YAC5D,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,OAAO,KAAK,CAAC,oBAAoB,CAAC,CAAC;YACrC,CAAC;YACD,IAAI,QAAQ,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;gBACvC,OAAO,KAAK,CAAC,yCAAyC,CAAC,CAAC;YAC1D,CAAC;YACD,IAAI,QAAQ,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;gBACpC,OAAO,KAAK,CAAC,+BAA+B,CAAC,CAAC;YAChD,CAAC;YAED,MAAM,CAAC,OAAO,CAAC,uCAAuC,KAAK,CAAC,SAAS,aAAa,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;YAEpG,MAAM,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,SAAS,EAAE;gBAC5C,MAAM,EAAE,WAAW;gBACnB,WAAW,EAAE,IAAI,IAAI,EAAE;aACxB,CAAC,CAAC;YAEH,MAAM,aAAa,GAAG,OAAO,CAAC;gBAC5B,EAAE,EAAE,KAAK,CAAC,SAAS;gBACnB,OAAO,EAAE,iCAAiC;aAC3C,CAAC,CAAC;YACH,OAAO,aAAa,CAAC;QACvB,CAAC;KACF,CAAC,CAAC;IAEH,OAAO,CAAC,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC;AACtE,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\");\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 logger.verbose(`[createPremise] Creating premise for user ${context.userId}: \"${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 logger.verbose(`[readPremises] Fetching premises for user ${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 logger.verbose(`[updatePremise] Updating premise ${query.premiseId} for user ${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 logger.verbose(`[retractPremise] Retracting premise ${query.premiseId} for user ${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"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { DefineTool, ToolDeps } from "../shared/agent/tool.helpers.js";
|
|
2
|
+
import { QuestionerAgent } from "./questioner.agent.js";
|
|
3
|
+
/** Test seam: replace or reset the module-level QuestionerAgent singleton. */
|
|
4
|
+
export declare function setQuestionerAgentForTesting(agent: QuestionerAgent | null): void;
|
|
5
|
+
/**
|
|
6
|
+
* Creates the chat-only `ask_user_question` tool. Registered by
|
|
7
|
+
* `createChatTools` only when `deps.chatQuestions` is provided — never part
|
|
8
|
+
* of the MCP tool registry (MCP clients have their own elicitation surface).
|
|
9
|
+
*
|
|
10
|
+
* @param defineTool - Tool factory provided by the composition root.
|
|
11
|
+
* @param deps - Shared tool dependencies; requires `chatQuestions`.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createAskUserQuestionTools(defineTool: DefineTool, deps: ToolDeps): readonly [any];
|
|
14
|
+
//# sourceMappingURL=questioner.ask.tool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
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;AAsCxD,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"}
|