@indexnetwork/protocol 0.1.0
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/agents/chat.agent.d.ts +218 -0
- package/dist/agents/chat.agent.d.ts.map +1 -0
- package/dist/agents/chat.agent.js +884 -0
- package/dist/agents/chat.agent.js.map +1 -0
- package/dist/agents/chat.prompt.d.ts +18 -0
- package/dist/agents/chat.prompt.d.ts.map +1 -0
- package/dist/agents/chat.prompt.js +372 -0
- package/dist/agents/chat.prompt.js.map +1 -0
- package/dist/agents/chat.prompt.modules.d.ts +61 -0
- package/dist/agents/chat.prompt.modules.d.ts.map +1 -0
- package/dist/agents/chat.prompt.modules.js +366 -0
- package/dist/agents/chat.prompt.modules.js.map +1 -0
- package/dist/agents/chat.title.generator.d.ts +20 -0
- package/dist/agents/chat.title.generator.d.ts.map +1 -0
- package/dist/agents/chat.title.generator.js +66 -0
- package/dist/agents/chat.title.generator.js.map +1 -0
- package/dist/agents/home.categorizer.d.ts +28 -0
- package/dist/agents/home.categorizer.d.ts.map +1 -0
- package/dist/agents/home.categorizer.js +170 -0
- package/dist/agents/home.categorizer.js.map +1 -0
- package/dist/agents/hyde.generator.d.ts +27 -0
- package/dist/agents/hyde.generator.d.ts.map +1 -0
- package/dist/agents/hyde.generator.js +75 -0
- package/dist/agents/hyde.generator.js.map +1 -0
- package/dist/agents/hyde.strategies.d.ts +17 -0
- package/dist/agents/hyde.strategies.d.ts.map +1 -0
- package/dist/agents/hyde.strategies.js +29 -0
- package/dist/agents/hyde.strategies.js.map +1 -0
- package/dist/agents/intent.clarifier.d.ts +29 -0
- package/dist/agents/intent.clarifier.d.ts.map +1 -0
- package/dist/agents/intent.clarifier.js +186 -0
- package/dist/agents/intent.clarifier.js.map +1 -0
- package/dist/agents/intent.indexer.d.ts +77 -0
- package/dist/agents/intent.indexer.d.ts.map +1 -0
- package/dist/agents/intent.indexer.js +164 -0
- package/dist/agents/intent.indexer.js.map +1 -0
- package/dist/agents/intent.inferrer.d.ts +95 -0
- package/dist/agents/intent.inferrer.d.ts.map +1 -0
- package/dist/agents/intent.inferrer.js +238 -0
- package/dist/agents/intent.inferrer.js.map +1 -0
- package/dist/agents/intent.reconciler.d.ts +106 -0
- package/dist/agents/intent.reconciler.d.ts.map +1 -0
- package/dist/agents/intent.reconciler.js +184 -0
- package/dist/agents/intent.reconciler.js.map +1 -0
- package/dist/agents/intent.verifier.d.ts +97 -0
- package/dist/agents/intent.verifier.d.ts.map +1 -0
- package/dist/agents/intent.verifier.js +234 -0
- package/dist/agents/intent.verifier.js.map +1 -0
- package/dist/agents/invite.generator.d.ts +47 -0
- package/dist/agents/invite.generator.d.ts.map +1 -0
- package/dist/agents/invite.generator.js +56 -0
- package/dist/agents/invite.generator.js.map +1 -0
- package/dist/agents/lens.inferrer.d.ts +37 -0
- package/dist/agents/lens.inferrer.d.ts.map +1 -0
- package/dist/agents/lens.inferrer.js +98 -0
- package/dist/agents/lens.inferrer.js.map +1 -0
- package/dist/agents/model.config.d.ts +120 -0
- package/dist/agents/model.config.d.ts.map +1 -0
- package/dist/agents/model.config.js +76 -0
- package/dist/agents/model.config.js.map +1 -0
- package/dist/agents/negotiation.insights.generator.d.ts +32 -0
- package/dist/agents/negotiation.insights.generator.d.ts.map +1 -0
- package/dist/agents/negotiation.insights.generator.js +105 -0
- package/dist/agents/negotiation.insights.generator.js.map +1 -0
- package/dist/agents/negotiation.proposer.d.ts +26 -0
- package/dist/agents/negotiation.proposer.d.ts.map +1 -0
- package/dist/agents/negotiation.proposer.js +67 -0
- package/dist/agents/negotiation.proposer.js.map +1 -0
- package/dist/agents/negotiation.responder.d.ts +26 -0
- package/dist/agents/negotiation.responder.d.ts.map +1 -0
- package/dist/agents/negotiation.responder.js +71 -0
- package/dist/agents/negotiation.responder.js.map +1 -0
- package/dist/agents/opportunity.evaluator.d.ts +253 -0
- package/dist/agents/opportunity.evaluator.d.ts.map +1 -0
- package/dist/agents/opportunity.evaluator.js +413 -0
- package/dist/agents/opportunity.evaluator.js.map +1 -0
- package/dist/agents/opportunity.presenter.d.ts +115 -0
- package/dist/agents/opportunity.presenter.d.ts.map +1 -0
- package/dist/agents/opportunity.presenter.js +524 -0
- package/dist/agents/opportunity.presenter.js.map +1 -0
- package/dist/agents/profile.generator.d.ts +67 -0
- package/dist/agents/profile.generator.d.ts.map +1 -0
- package/dist/agents/profile.generator.js +97 -0
- package/dist/agents/profile.generator.js.map +1 -0
- package/dist/agents/profile.hyde.generator.d.ts +43 -0
- package/dist/agents/profile.hyde.generator.d.ts.map +1 -0
- package/dist/agents/profile.hyde.generator.js +113 -0
- package/dist/agents/profile.hyde.generator.js.map +1 -0
- package/dist/agents/suggestion.generator.d.ts +24 -0
- package/dist/agents/suggestion.generator.d.ts.map +1 -0
- package/dist/agents/suggestion.generator.js +96 -0
- package/dist/agents/suggestion.generator.js.map +1 -0
- package/dist/graphs/chat.graph.d.ts +312 -0
- package/dist/graphs/chat.graph.d.ts.map +1 -0
- package/dist/graphs/chat.graph.js +267 -0
- package/dist/graphs/chat.graph.js.map +1 -0
- package/dist/graphs/home.graph.d.ts +180 -0
- package/dist/graphs/home.graph.d.ts.map +1 -0
- package/dist/graphs/home.graph.js +598 -0
- package/dist/graphs/home.graph.js.map +1 -0
- package/dist/graphs/hyde.graph.d.ts +110 -0
- package/dist/graphs/hyde.graph.d.ts.map +1 -0
- package/dist/graphs/hyde.graph.js +235 -0
- package/dist/graphs/hyde.graph.js.map +1 -0
- package/dist/graphs/index.graph.d.ts +620 -0
- package/dist/graphs/index.graph.d.ts.map +1 -0
- package/dist/graphs/index.graph.js +226 -0
- package/dist/graphs/index.graph.js.map +1 -0
- package/dist/graphs/index_membership.graph.d.ts +250 -0
- package/dist/graphs/index_membership.graph.d.ts.map +1 -0
- package/dist/graphs/index_membership.graph.js +204 -0
- package/dist/graphs/index_membership.graph.js.map +1 -0
- package/dist/graphs/intent.graph.d.ts +490 -0
- package/dist/graphs/intent.graph.d.ts.map +1 -0
- package/dist/graphs/intent.graph.js +787 -0
- package/dist/graphs/intent.graph.js.map +1 -0
- package/dist/graphs/intent_index.graph.d.ts +396 -0
- package/dist/graphs/intent_index.graph.d.ts.map +1 -0
- package/dist/graphs/intent_index.graph.js +331 -0
- package/dist/graphs/intent_index.graph.js.map +1 -0
- package/dist/graphs/maintenance.graph.d.ts +177 -0
- package/dist/graphs/maintenance.graph.d.ts.map +1 -0
- package/dist/graphs/maintenance.graph.js +173 -0
- package/dist/graphs/maintenance.graph.js.map +1 -0
- package/dist/graphs/negotiation.graph.d.ts +819 -0
- package/dist/graphs/negotiation.graph.d.ts.map +1 -0
- package/dist/graphs/negotiation.graph.js +255 -0
- package/dist/graphs/negotiation.graph.js.map +1 -0
- package/dist/graphs/opportunity.graph.d.ts +1082 -0
- package/dist/graphs/opportunity.graph.d.ts.map +1 -0
- package/dist/graphs/opportunity.graph.js +2534 -0
- package/dist/graphs/opportunity.graph.js.map +1 -0
- package/dist/graphs/profile.graph.d.ts +617 -0
- package/dist/graphs/profile.graph.d.ts.map +1 -0
- package/dist/graphs/profile.graph.js +839 -0
- package/dist/graphs/profile.graph.js.map +1 -0
- package/dist/graphs/tests/chat.graph.mocks.d.ts +104 -0
- package/dist/graphs/tests/chat.graph.mocks.d.ts.map +1 -0
- package/dist/graphs/tests/chat.graph.mocks.js +225 -0
- package/dist/graphs/tests/chat.graph.mocks.js.map +1 -0
- package/dist/index.d.ts +62 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +44 -0
- package/dist/index.js.map +1 -0
- package/dist/interfaces/auth.interface.d.ts +15 -0
- package/dist/interfaces/auth.interface.d.ts.map +1 -0
- package/dist/interfaces/auth.interface.js +2 -0
- package/dist/interfaces/auth.interface.js.map +1 -0
- package/dist/interfaces/cache.interface.d.ts +43 -0
- package/dist/interfaces/cache.interface.d.ts.map +1 -0
- package/dist/interfaces/cache.interface.js +6 -0
- package/dist/interfaces/cache.interface.js.map +1 -0
- package/dist/interfaces/chat-session.interface.d.ts +11 -0
- package/dist/interfaces/chat-session.interface.d.ts.map +1 -0
- package/dist/interfaces/chat-session.interface.js +2 -0
- package/dist/interfaces/chat-session.interface.js.map +1 -0
- package/dist/interfaces/contact.interface.d.ts +48 -0
- package/dist/interfaces/contact.interface.d.ts.map +1 -0
- package/dist/interfaces/contact.interface.js +2 -0
- package/dist/interfaces/contact.interface.js.map +1 -0
- package/dist/interfaces/database.interface.d.ts +1495 -0
- package/dist/interfaces/database.interface.d.ts.map +1 -0
- package/dist/interfaces/database.interface.js +2 -0
- package/dist/interfaces/database.interface.js.map +1 -0
- package/dist/interfaces/embedder.interface.d.ts +85 -0
- package/dist/interfaces/embedder.interface.d.ts.map +1 -0
- package/dist/interfaces/embedder.interface.js +5 -0
- package/dist/interfaces/embedder.interface.js.map +1 -0
- package/dist/interfaces/enrichment.interface.d.ts +40 -0
- package/dist/interfaces/enrichment.interface.d.ts.map +1 -0
- package/dist/interfaces/enrichment.interface.js +2 -0
- package/dist/interfaces/enrichment.interface.js.map +1 -0
- package/dist/interfaces/integration.interface.d.ts +91 -0
- package/dist/interfaces/integration.interface.d.ts.map +1 -0
- package/dist/interfaces/integration.interface.js +2 -0
- package/dist/interfaces/integration.interface.js.map +1 -0
- package/dist/interfaces/queue.interface.d.ts +17 -0
- package/dist/interfaces/queue.interface.d.ts.map +1 -0
- package/dist/interfaces/queue.interface.js +5 -0
- package/dist/interfaces/queue.interface.js.map +1 -0
- package/dist/interfaces/scraper.interface.d.ts +31 -0
- package/dist/interfaces/scraper.interface.d.ts.map +1 -0
- package/dist/interfaces/scraper.interface.js +2 -0
- package/dist/interfaces/scraper.interface.js.map +1 -0
- package/dist/interfaces/storage.interface.d.ts +46 -0
- package/dist/interfaces/storage.interface.d.ts.map +1 -0
- package/dist/interfaces/storage.interface.js +6 -0
- package/dist/interfaces/storage.interface.js.map +1 -0
- package/dist/mcp/mcp.server.d.ts +29 -0
- package/dist/mcp/mcp.server.d.ts.map +1 -0
- package/dist/mcp/mcp.server.js +171 -0
- package/dist/mcp/mcp.server.js.map +1 -0
- package/dist/states/chat.state.d.ts +126 -0
- package/dist/states/chat.state.d.ts.map +1 -0
- package/dist/states/chat.state.js +112 -0
- package/dist/states/chat.state.js.map +1 -0
- package/dist/states/home.state.d.ts +100 -0
- package/dist/states/home.state.d.ts.map +1 -0
- package/dist/states/home.state.js +74 -0
- package/dist/states/home.state.js.map +1 -0
- package/dist/states/hyde.state.d.ts +54 -0
- package/dist/states/hyde.state.d.ts.map +1 -0
- package/dist/states/hyde.state.js +66 -0
- package/dist/states/hyde.state.js.map +1 -0
- package/dist/states/index.state.d.ts +179 -0
- package/dist/states/index.state.d.ts.map +1 -0
- package/dist/states/index.state.js +56 -0
- package/dist/states/index.state.js.map +1 -0
- package/dist/states/index_membership.state.d.ts +77 -0
- package/dist/states/index_membership.state.d.ts.map +1 -0
- package/dist/states/index_membership.state.js +43 -0
- package/dist/states/index_membership.state.js.map +1 -0
- package/dist/states/intent.state.d.ts +203 -0
- package/dist/states/intent.state.d.ts.map +1 -0
- package/dist/states/intent.state.js +153 -0
- package/dist/states/intent.state.js.map +1 -0
- package/dist/states/intent_index.state.d.ts +148 -0
- package/dist/states/intent_index.state.d.ts.map +1 -0
- package/dist/states/intent_index.state.js +100 -0
- package/dist/states/intent_index.state.js.map +1 -0
- package/dist/states/maintenance.state.d.ts +36 -0
- package/dist/states/maintenance.state.d.ts.map +1 -0
- package/dist/states/maintenance.state.js +56 -0
- package/dist/states/maintenance.state.js.map +1 -0
- package/dist/states/negotiation.state.d.ts +230 -0
- package/dist/states/negotiation.state.d.ts.map +1 -0
- package/dist/states/negotiation.state.js +82 -0
- package/dist/states/negotiation.state.js.map +1 -0
- package/dist/states/opportunity.state.d.ts +300 -0
- package/dist/states/opportunity.state.d.ts.map +1 -0
- package/dist/states/opportunity.state.js +207 -0
- package/dist/states/opportunity.state.js.map +1 -0
- package/dist/states/profile.state.d.ts +172 -0
- package/dist/states/profile.state.d.ts.map +1 -0
- package/dist/states/profile.state.js +133 -0
- package/dist/states/profile.state.js.map +1 -0
- package/dist/streamers/chat.streamer.d.ts +55 -0
- package/dist/streamers/chat.streamer.d.ts.map +1 -0
- package/dist/streamers/chat.streamer.js +186 -0
- package/dist/streamers/chat.streamer.js.map +1 -0
- package/dist/streamers/index.d.ts +3 -0
- package/dist/streamers/index.d.ts.map +1 -0
- package/dist/streamers/index.js +3 -0
- package/dist/streamers/index.js.map +1 -0
- package/dist/streamers/response.streamer.d.ts +36 -0
- package/dist/streamers/response.streamer.d.ts.map +1 -0
- package/dist/streamers/response.streamer.js +46 -0
- package/dist/streamers/response.streamer.js.map +1 -0
- package/dist/support/chat.utils.d.ts +42 -0
- package/dist/support/chat.utils.d.ts.map +1 -0
- package/dist/support/chat.utils.js +89 -0
- package/dist/support/chat.utils.js.map +1 -0
- package/dist/support/debug-meta.sanitizer.d.ts +18 -0
- package/dist/support/debug-meta.sanitizer.d.ts.map +1 -0
- package/dist/support/debug-meta.sanitizer.js +82 -0
- package/dist/support/debug-meta.sanitizer.js.map +1 -0
- package/dist/support/feed.health.d.ts +32 -0
- package/dist/support/feed.health.d.ts.map +1 -0
- package/dist/support/feed.health.js +76 -0
- package/dist/support/feed.health.js.map +1 -0
- package/dist/support/introducer.discovery.d.ts +78 -0
- package/dist/support/introducer.discovery.d.ts.map +1 -0
- package/dist/support/introducer.discovery.js +101 -0
- package/dist/support/introducer.discovery.js.map +1 -0
- package/dist/support/log.d.ts +65 -0
- package/dist/support/log.d.ts.map +1 -0
- package/dist/support/log.js +76 -0
- package/dist/support/log.js.map +1 -0
- package/dist/support/lucide.icon-catalog.d.ts +22 -0
- package/dist/support/lucide.icon-catalog.d.ts.map +1 -0
- package/dist/support/lucide.icon-catalog.js +101 -0
- package/dist/support/lucide.icon-catalog.js.map +1 -0
- package/dist/support/opportunity.card-text.d.ts +39 -0
- package/dist/support/opportunity.card-text.d.ts.map +1 -0
- package/dist/support/opportunity.card-text.js +333 -0
- package/dist/support/opportunity.card-text.js.map +1 -0
- package/dist/support/opportunity.constants.d.ts +9 -0
- package/dist/support/opportunity.constants.d.ts.map +1 -0
- package/dist/support/opportunity.constants.js +11 -0
- package/dist/support/opportunity.constants.js.map +1 -0
- package/dist/support/opportunity.discover.d.ts +144 -0
- package/dist/support/opportunity.discover.d.ts.map +1 -0
- package/dist/support/opportunity.discover.js +610 -0
- package/dist/support/opportunity.discover.js.map +1 -0
- package/dist/support/opportunity.enricher.d.ts +44 -0
- package/dist/support/opportunity.enricher.d.ts.map +1 -0
- package/dist/support/opportunity.enricher.js +245 -0
- package/dist/support/opportunity.enricher.js.map +1 -0
- package/dist/support/opportunity.persist.d.ts +39 -0
- package/dist/support/opportunity.persist.d.ts.map +1 -0
- package/dist/support/opportunity.persist.js +63 -0
- package/dist/support/opportunity.persist.js.map +1 -0
- package/dist/support/opportunity.presentation.d.ts +21 -0
- package/dist/support/opportunity.presentation.d.ts.map +1 -0
- package/dist/support/opportunity.presentation.js +75 -0
- package/dist/support/opportunity.presentation.js.map +1 -0
- package/dist/support/opportunity.sanitize.d.ts +18 -0
- package/dist/support/opportunity.sanitize.d.ts.map +1 -0
- package/dist/support/opportunity.sanitize.js +89 -0
- package/dist/support/opportunity.sanitize.js.map +1 -0
- package/dist/support/opportunity.utils.d.ts +99 -0
- package/dist/support/opportunity.utils.d.ts.map +1 -0
- package/dist/support/opportunity.utils.js +184 -0
- package/dist/support/opportunity.utils.js.map +1 -0
- package/dist/support/performance.d.ts +19 -0
- package/dist/support/performance.d.ts.map +1 -0
- package/dist/support/performance.js +43 -0
- package/dist/support/performance.js.map +1 -0
- package/dist/support/profile.enrichment-display-name.d.ts +16 -0
- package/dist/support/profile.enrichment-display-name.d.ts.map +1 -0
- package/dist/support/profile.enrichment-display-name.js +22 -0
- package/dist/support/profile.enrichment-display-name.js.map +1 -0
- package/dist/support/protocol.logger.d.ts +22 -0
- package/dist/support/protocol.logger.d.ts.map +1 -0
- package/dist/support/protocol.logger.js +44 -0
- package/dist/support/protocol.logger.js.map +1 -0
- package/dist/support/request-context.d.ts +19 -0
- package/dist/support/request-context.d.ts.map +1 -0
- package/dist/support/request-context.js +7 -0
- package/dist/support/request-context.js.map +1 -0
- package/dist/tools/contact.tools.d.ts +7 -0
- package/dist/tools/contact.tools.d.ts.map +1 -0
- package/dist/tools/contact.tools.js +115 -0
- package/dist/tools/contact.tools.js.map +1 -0
- package/dist/tools/index.d.ts +17 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +140 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/index.tools.d.ts +3 -0
- package/dist/tools/index.tools.d.ts.map +1 -0
- package/dist/tools/index.tools.js +423 -0
- package/dist/tools/index.tools.js.map +1 -0
- package/dist/tools/integration.tools.d.ts +13 -0
- package/dist/tools/integration.tools.d.ts.map +1 -0
- package/dist/tools/integration.tools.js +77 -0
- package/dist/tools/integration.tools.js.map +1 -0
- package/dist/tools/intent.tools.d.ts +3 -0
- package/dist/tools/intent.tools.d.ts.map +1 -0
- package/dist/tools/intent.tools.js +458 -0
- package/dist/tools/intent.tools.js.map +1 -0
- package/dist/tools/opportunity.tools.d.ts +44 -0
- package/dist/tools/opportunity.tools.d.ts.map +1 -0
- package/dist/tools/opportunity.tools.js +814 -0
- package/dist/tools/opportunity.tools.js.map +1 -0
- package/dist/tools/profile.tools.d.ts +3 -0
- package/dist/tools/profile.tools.d.ts.map +1 -0
- package/dist/tools/profile.tools.js +513 -0
- package/dist/tools/profile.tools.js.map +1 -0
- package/dist/tools/tool.helpers.d.ts +225 -0
- package/dist/tools/tool.helpers.d.ts.map +1 -0
- package/dist/tools/tool.helpers.js +172 -0
- package/dist/tools/tool.helpers.js.map +1 -0
- package/dist/tools/tool.registry.d.ts +12 -0
- package/dist/tools/tool.registry.d.ts.map +1 -0
- package/dist/tools/tool.registry.js +62 -0
- package/dist/tools/tool.registry.js.map +1 -0
- package/dist/tools/utility.tools.d.ts +3 -0
- package/dist/tools/utility.tools.d.ts.map +1 -0
- package/dist/tools/utility.tools.js +107 -0
- package/dist/tools/utility.tools.js.map +1 -0
- package/dist/types/chat-streaming.types.d.ts +472 -0
- package/dist/types/chat-streaming.types.d.ts.map +1 -0
- package/dist/types/chat-streaming.types.js +260 -0
- package/dist/types/chat-streaming.types.js.map +1 -0
- package/package.json +32 -0
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export type HydeTargetCorpus = 'profiles' | 'intents';
|
|
2
|
+
/** A single inferred lens — a search perspective the LLM decided is relevant. */
|
|
3
|
+
export interface Lens {
|
|
4
|
+
/** Free-text description (e.g. "crypto infrastructure VC"). */
|
|
5
|
+
label: string;
|
|
6
|
+
/** Which vector index to search: user profiles or user intents. */
|
|
7
|
+
corpus: HydeTargetCorpus;
|
|
8
|
+
/** Why this perspective is relevant (for logging/trace). */
|
|
9
|
+
reasoning: string;
|
|
10
|
+
}
|
|
11
|
+
export interface LensInferenceInput {
|
|
12
|
+
/** Intent payload or search query. */
|
|
13
|
+
sourceText: string;
|
|
14
|
+
/** User's profile summary for domain context (optional). */
|
|
15
|
+
profileContext?: string;
|
|
16
|
+
/** Maximum number of lenses to infer (default 3). */
|
|
17
|
+
maxLenses?: number;
|
|
18
|
+
}
|
|
19
|
+
export interface LensInferenceOutput {
|
|
20
|
+
lenses: Lens[];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Infers search lenses from source text and optional profile context.
|
|
24
|
+
* Each lens represents a search perspective tagged with a target corpus
|
|
25
|
+
* (profiles or intents) for downstream HyDE document generation.
|
|
26
|
+
*/
|
|
27
|
+
export declare class LensInferrer {
|
|
28
|
+
private model;
|
|
29
|
+
/**
|
|
30
|
+
* Infer search lenses from source text and optional profile context.
|
|
31
|
+
*
|
|
32
|
+
* @param input - Source text, optional profile context, optional max lenses
|
|
33
|
+
* @returns Array of inferred lenses with corpus tags; empty array on failure
|
|
34
|
+
*/
|
|
35
|
+
infer(input: LensInferenceInput): Promise<LensInferenceOutput>;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=lens.inferrer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lens.inferrer.d.ts","sourceRoot":"","sources":["../../src/agents/lens.inferrer.ts"],"names":[],"mappings":"AAWA,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,SAAS,CAAC;AAEtD,iFAAiF;AACjF,MAAM,WAAW,IAAI;IACnB,+DAA+D;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,mEAAmE;IACnE,MAAM,EAAE,gBAAgB,CAAC;IACzB,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,kBAAkB;IACjC,sCAAsC;IACtC,UAAU,EAAE,MAAM,CAAC;IACnB,4DAA4D;IAC5D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,qDAAqD;IACrD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,IAAI,EAAE,CAAC;CAChB;AA8BD;;;;GAIG;AACH,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAEV;IAEH;;;;;OAKG;IAEG,KAAK,CAAC,KAAK,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAoCrE"}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Lens Inferrer Agent: analyzes source text (intent or query) with optional
|
|
12
|
+
* profile context and infers 1-N search lenses, each tagged with a target corpus.
|
|
13
|
+
* Replaces the hardcoded HydeStrategy enum and regex-based selectStrategiesFromQuery.
|
|
14
|
+
*/
|
|
15
|
+
import { HumanMessage, SystemMessage } from '@langchain/core/messages';
|
|
16
|
+
import { z } from 'zod';
|
|
17
|
+
import { Timed } from "../support/performance.js";
|
|
18
|
+
import { protocolLogger } from '../support/protocol.logger.js';
|
|
19
|
+
import { createModel } from "./model.config.js";
|
|
20
|
+
const SYSTEM_PROMPT = `You analyze goals and search queries to identify the most relevant perspectives for finding matching people in a professional network.
|
|
21
|
+
|
|
22
|
+
For each perspective you identify, specify:
|
|
23
|
+
1. A clear, specific description of who or what to search for
|
|
24
|
+
2. Whether to search "profiles" (user bios, expertise, backgrounds) or "intents" (stated goals, needs, aspirations)
|
|
25
|
+
3. A brief reason why this perspective is relevant
|
|
26
|
+
|
|
27
|
+
Guidelines:
|
|
28
|
+
- Be specific and domain-aware. "early-stage crypto infrastructure investor" is better than "investor".
|
|
29
|
+
- Consider both sides: who can help the person AND whose goals complement theirs.
|
|
30
|
+
- When user context is provided, tailor perspectives to their domain (e.g. a DePIN founder searching for "investors" needs crypto-native infra investors specifically).
|
|
31
|
+
- Generate only perspectives that add distinct search value — don't repeat similar angles.
|
|
32
|
+
- Use "profiles" when looking for a type of person (expert, advisor, leader). Use "intents" when looking for a complementary goal or need (someone raising, someone hiring, someone seeking collaboration).
|
|
33
|
+
- Always include at least one "profiles" perspective when the source describes a need that a specific type of professional could fulfill. Most intents benefit from profile-based discovery.
|
|
34
|
+
- LOCATION AWARENESS: When the source text or user context mentions a specific location (city, region, country), incorporate it into lens descriptions. For example, "investors in San Francisco" should produce a lens like "SF-based early-stage investor" rather than just "early-stage investor". This helps the hypothetical document generator produce location-specific search documents, improving retrieval quality.`;
|
|
35
|
+
const responseFormat = z.object({
|
|
36
|
+
lenses: z.array(z.object({
|
|
37
|
+
label: z.string().describe('Specific description of the search perspective'),
|
|
38
|
+
corpus: z.enum(['profiles', 'intents']).describe('Search user profiles or user intents'),
|
|
39
|
+
reasoning: z.string().describe('Why this perspective is relevant'),
|
|
40
|
+
})).min(1).max(5).describe('Inferred search lenses'),
|
|
41
|
+
});
|
|
42
|
+
const model = createModel("lensInferrer");
|
|
43
|
+
const logger = protocolLogger("LensInferrer");
|
|
44
|
+
/**
|
|
45
|
+
* Infers search lenses from source text and optional profile context.
|
|
46
|
+
* Each lens represents a search perspective tagged with a target corpus
|
|
47
|
+
* (profiles or intents) for downstream HyDE document generation.
|
|
48
|
+
*/
|
|
49
|
+
export class LensInferrer {
|
|
50
|
+
constructor() {
|
|
51
|
+
this.model = model.withStructuredOutput(responseFormat, {
|
|
52
|
+
name: "lens_inferrer",
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Infer search lenses from source text and optional profile context.
|
|
57
|
+
*
|
|
58
|
+
* @param input - Source text, optional profile context, optional max lenses
|
|
59
|
+
* @returns Array of inferred lenses with corpus tags; empty array on failure
|
|
60
|
+
*/
|
|
61
|
+
async infer(input) {
|
|
62
|
+
const { sourceText, profileContext, maxLenses = 3 } = input;
|
|
63
|
+
logger.verbose('Inferring lenses', {
|
|
64
|
+
sourceTextLength: sourceText.length,
|
|
65
|
+
hasProfileContext: !!profileContext,
|
|
66
|
+
maxLenses,
|
|
67
|
+
});
|
|
68
|
+
let humanPrompt = `Identify up to ${maxLenses} search perspectives for finding relevant matches.\n\nSource: "${sourceText}"`;
|
|
69
|
+
if (profileContext) {
|
|
70
|
+
humanPrompt += `\n\nUser context: ${profileContext}`;
|
|
71
|
+
}
|
|
72
|
+
const messages = [
|
|
73
|
+
new SystemMessage(SYSTEM_PROMPT),
|
|
74
|
+
new HumanMessage(humanPrompt),
|
|
75
|
+
];
|
|
76
|
+
try {
|
|
77
|
+
const result = await this.model.invoke(messages);
|
|
78
|
+
const parsed = responseFormat.parse(result);
|
|
79
|
+
const lenses = parsed.lenses.slice(0, maxLenses);
|
|
80
|
+
logger.verbose('Lenses inferred', {
|
|
81
|
+
count: lenses.length,
|
|
82
|
+
lenses: lenses.map(l => ({ label: l.label, corpus: l.corpus })),
|
|
83
|
+
});
|
|
84
|
+
return { lenses };
|
|
85
|
+
}
|
|
86
|
+
catch (error) {
|
|
87
|
+
logger.error('Lens inference failed', { error });
|
|
88
|
+
return { lenses: [] };
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
__decorate([
|
|
93
|
+
Timed(),
|
|
94
|
+
__metadata("design:type", Function),
|
|
95
|
+
__metadata("design:paramtypes", [Object]),
|
|
96
|
+
__metadata("design:returntype", Promise)
|
|
97
|
+
], LensInferrer.prototype, "infer", null);
|
|
98
|
+
//# sourceMappingURL=lens.inferrer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lens.inferrer.js","sourceRoot":"","sources":["../../src/agents/lens.inferrer.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;GAIG;AACH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AA2BhD,MAAM,aAAa,GAAG;;;;;;;;;;;;;;8ZAcwY,CAAC;AAE/Z,MAAM,cAAc,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9B,MAAM,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC;QACvB,KAAK,EAAE,CA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M,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;YACjD,MAAM,MAAM,GAAG,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;YAC5C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC;YAEjD,MAAM,CAAC,OAAO,CAAC,iBAAiB,EAAE;gBAChC,KAAK,EAAE,MAAM,CAAC,MAAM;gBACpB,MAAM,EAAE,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,KAAK,EAAE,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;aAChE,CAAC,CAAC;YAEH,OAAO,EAAE,MAAM,EAAE,CAAC;QACpB,CAAC;QAAC,OAAO,KAAc,EAAE,CAAC;YACxB,MAAM,CAAC,KAAK,CAAC,uBAAuB,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACjD,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;QACxB,CAAC;IACH,CAAC;CACF;AApCO;IADL,KAAK,EAAE;;;;yCAoCP"}
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
2
|
+
/** Settings that can be configured per agent. */
|
|
3
|
+
export interface ModelSettings {
|
|
4
|
+
model: string;
|
|
5
|
+
temperature?: number;
|
|
6
|
+
maxTokens?: number;
|
|
7
|
+
reasoning?: {
|
|
8
|
+
effort?: 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
9
|
+
exclude?: boolean;
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Runtime configuration for the protocol package.
|
|
14
|
+
* Set once via configureProtocol() at application startup.
|
|
15
|
+
* All fields fall back to environment variables if not provided.
|
|
16
|
+
*/
|
|
17
|
+
export interface ModelConfig {
|
|
18
|
+
/** OpenRouter API key. Falls back to OPENROUTER_API_KEY env var. */
|
|
19
|
+
apiKey?: string;
|
|
20
|
+
/** OpenRouter base URL. Falls back to OPENROUTER_BASE_URL env var. */
|
|
21
|
+
baseURL?: string;
|
|
22
|
+
/** Override the chat agent model. Falls back to CHAT_MODEL env var. */
|
|
23
|
+
chatModel?: string;
|
|
24
|
+
/** Override the chat reasoning effort. Falls back to CHAT_REASONING_EFFORT env var. */
|
|
25
|
+
chatReasoningEffort?: 'minimal' | 'low' | 'medium' | 'high' | 'xhigh';
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Configure the protocol package with runtime credentials and settings.
|
|
29
|
+
* Call once at application startup before any agents are used.
|
|
30
|
+
* Falls back to environment variables for any field not provided.
|
|
31
|
+
*
|
|
32
|
+
* @param config - Runtime configuration overrides
|
|
33
|
+
*/
|
|
34
|
+
export declare function configureProtocol(config: ModelConfig): void;
|
|
35
|
+
declare function getModelConfig(config?: ModelConfig): {
|
|
36
|
+
readonly intentInferrer: {
|
|
37
|
+
readonly model: "google/gemini-2.5-flash";
|
|
38
|
+
};
|
|
39
|
+
readonly intentIndexer: {
|
|
40
|
+
readonly model: "google/gemini-2.5-flash";
|
|
41
|
+
};
|
|
42
|
+
readonly intentVerifier: {
|
|
43
|
+
readonly model: "google/gemini-2.5-flash";
|
|
44
|
+
};
|
|
45
|
+
readonly intentReconciler: {
|
|
46
|
+
readonly model: "google/gemini-2.5-flash";
|
|
47
|
+
};
|
|
48
|
+
readonly intentClarifier: {
|
|
49
|
+
readonly model: "google/gemini-2.5-flash";
|
|
50
|
+
};
|
|
51
|
+
readonly profileGenerator: {
|
|
52
|
+
readonly model: "google/gemini-2.5-flash";
|
|
53
|
+
};
|
|
54
|
+
readonly profileHydeGenerator: {
|
|
55
|
+
readonly model: "google/gemini-2.5-flash";
|
|
56
|
+
};
|
|
57
|
+
readonly hydeGenerator: {
|
|
58
|
+
readonly model: "google/gemini-2.5-flash";
|
|
59
|
+
};
|
|
60
|
+
readonly lensInferrer: {
|
|
61
|
+
readonly model: "google/gemini-2.5-flash";
|
|
62
|
+
};
|
|
63
|
+
readonly opportunityEvaluator: {
|
|
64
|
+
readonly model: "google/gemini-2.5-flash";
|
|
65
|
+
};
|
|
66
|
+
readonly opportunityPresenter: {
|
|
67
|
+
readonly model: "google/gemini-2.5-flash";
|
|
68
|
+
};
|
|
69
|
+
readonly negotiationProposer: {
|
|
70
|
+
readonly model: "google/gemini-2.5-flash";
|
|
71
|
+
};
|
|
72
|
+
readonly negotiationResponder: {
|
|
73
|
+
readonly model: "google/gemini-2.5-flash";
|
|
74
|
+
};
|
|
75
|
+
readonly homeCategorizer: {
|
|
76
|
+
readonly model: "google/gemini-2.5-flash";
|
|
77
|
+
};
|
|
78
|
+
readonly suggestionGenerator: {
|
|
79
|
+
readonly model: "google/gemini-2.5-flash";
|
|
80
|
+
readonly temperature: 0.4;
|
|
81
|
+
readonly maxTokens: 512;
|
|
82
|
+
};
|
|
83
|
+
readonly chatTitleGenerator: {
|
|
84
|
+
readonly model: "google/gemini-2.5-flash";
|
|
85
|
+
readonly temperature: 0.3;
|
|
86
|
+
readonly maxTokens: 32;
|
|
87
|
+
};
|
|
88
|
+
readonly negotiationInsights: {
|
|
89
|
+
readonly model: "google/gemini-2.5-flash";
|
|
90
|
+
readonly temperature: 0.4;
|
|
91
|
+
readonly maxTokens: 512;
|
|
92
|
+
};
|
|
93
|
+
readonly inviteGenerator: {
|
|
94
|
+
readonly model: "google/gemini-2.5-flash";
|
|
95
|
+
readonly temperature: 0.3;
|
|
96
|
+
readonly maxTokens: 512;
|
|
97
|
+
};
|
|
98
|
+
readonly chat: {
|
|
99
|
+
readonly model: string;
|
|
100
|
+
readonly maxTokens: 8192;
|
|
101
|
+
readonly reasoning: {
|
|
102
|
+
readonly effort: NonNullable<ModelSettings["reasoning"]>["effort"];
|
|
103
|
+
readonly exclude: true;
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Returns the model name string for the given agent key.
|
|
109
|
+
* @param agent - Key from MODEL_CONFIG identifying which agent's settings to use.
|
|
110
|
+
* @param config - Optional runtime config overrides (merged with module-level config).
|
|
111
|
+
*/
|
|
112
|
+
export declare function getModelName(agent: keyof ReturnType<typeof getModelConfig>, config?: ModelConfig): string;
|
|
113
|
+
/**
|
|
114
|
+
* Creates a ChatOpenAI instance configured for OpenRouter.
|
|
115
|
+
* @param agent - Key identifying which agent's model settings to use.
|
|
116
|
+
* @param config - Optional runtime config overrides (merged with module-level config).
|
|
117
|
+
*/
|
|
118
|
+
export declare function createModel(agent: keyof ReturnType<typeof getModelConfig>, config?: ModelConfig): ChatOpenAI;
|
|
119
|
+
export {};
|
|
120
|
+
//# sourceMappingURL=model.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.config.d.ts","sourceRoot":"","sources":["../../src/agents/model.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,iDAAiD;AACjD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE;QAAE,MAAM,CAAC,EAAE,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;QAAC,OAAO,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;CAC7F;AAED;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,sEAAsE;IACtE,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,uEAAuE;IACvE,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uFAAuF;IACvF,mBAAmB,CAAC,EAAE,SAAS,GAAG,KAAK,GAAG,QAAQ,GAAG,MAAM,GAAG,OAAO,CAAC;CACvE;AAKD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,WAAW,GAAG,IAAI,CAE3D;AAED,iBAAS,cAAc,CAAC,MAAM,CAAC,EAAE,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;6BAyBkD,WAAW,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC;;;;EAK9I;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,UAAU,CAAC,OAAO,cAAc,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,CAEzG;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,UAAU,CAAC,OAAO,cAAc,CAAC,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,UAAU,CAiB5G"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { ChatOpenAI } from "@langchain/openai";
|
|
2
|
+
/** Module-level config set by configureProtocol(). Merged with per-call overrides. */
|
|
3
|
+
let _activeConfig = {};
|
|
4
|
+
/**
|
|
5
|
+
* Configure the protocol package with runtime credentials and settings.
|
|
6
|
+
* Call once at application startup before any agents are used.
|
|
7
|
+
* Falls back to environment variables for any field not provided.
|
|
8
|
+
*
|
|
9
|
+
* @param config - Runtime configuration overrides
|
|
10
|
+
*/
|
|
11
|
+
export function configureProtocol(config) {
|
|
12
|
+
_activeConfig = config;
|
|
13
|
+
}
|
|
14
|
+
function getModelConfig(config) {
|
|
15
|
+
const merged = { ..._activeConfig, ...config };
|
|
16
|
+
return {
|
|
17
|
+
intentInferrer: { model: "google/gemini-2.5-flash" },
|
|
18
|
+
intentIndexer: { model: "google/gemini-2.5-flash" },
|
|
19
|
+
intentVerifier: { model: "google/gemini-2.5-flash" },
|
|
20
|
+
intentReconciler: { model: "google/gemini-2.5-flash" },
|
|
21
|
+
intentClarifier: { model: "google/gemini-2.5-flash" },
|
|
22
|
+
profileGenerator: { model: "google/gemini-2.5-flash" },
|
|
23
|
+
profileHydeGenerator: { model: "google/gemini-2.5-flash" },
|
|
24
|
+
hydeGenerator: { model: "google/gemini-2.5-flash" },
|
|
25
|
+
lensInferrer: { model: "google/gemini-2.5-flash" },
|
|
26
|
+
opportunityEvaluator: { model: "google/gemini-2.5-flash" },
|
|
27
|
+
opportunityPresenter: { model: "google/gemini-2.5-flash" },
|
|
28
|
+
negotiationProposer: { model: "google/gemini-2.5-flash" },
|
|
29
|
+
negotiationResponder: { model: "google/gemini-2.5-flash" },
|
|
30
|
+
homeCategorizer: { model: "google/gemini-2.5-flash" },
|
|
31
|
+
suggestionGenerator: { model: "google/gemini-2.5-flash", temperature: 0.4, maxTokens: 512 },
|
|
32
|
+
chatTitleGenerator: { model: "google/gemini-2.5-flash", temperature: 0.3, maxTokens: 32 },
|
|
33
|
+
negotiationInsights: { model: "google/gemini-2.5-flash", temperature: 0.4, maxTokens: 512 },
|
|
34
|
+
inviteGenerator: { model: "google/gemini-2.5-flash", temperature: 0.3, maxTokens: 512 },
|
|
35
|
+
chat: {
|
|
36
|
+
model: merged.chatModel ?? process.env.CHAT_MODEL ?? "google/gemini-3-pro-preview",
|
|
37
|
+
maxTokens: 8192,
|
|
38
|
+
reasoning: {
|
|
39
|
+
effort: (merged.chatReasoningEffort ?? process.env.CHAT_REASONING_EFFORT ?? "low"),
|
|
40
|
+
exclude: true,
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Returns the model name string for the given agent key.
|
|
47
|
+
* @param agent - Key from MODEL_CONFIG identifying which agent's settings to use.
|
|
48
|
+
* @param config - Optional runtime config overrides (merged with module-level config).
|
|
49
|
+
*/
|
|
50
|
+
export function getModelName(agent, config) {
|
|
51
|
+
return getModelConfig(config)[agent].model;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Creates a ChatOpenAI instance configured for OpenRouter.
|
|
55
|
+
* @param agent - Key identifying which agent's model settings to use.
|
|
56
|
+
* @param config - Optional runtime config overrides (merged with module-level config).
|
|
57
|
+
*/
|
|
58
|
+
export function createModel(agent, config) {
|
|
59
|
+
const merged = { ..._activeConfig, ...config };
|
|
60
|
+
const apiKey = merged.apiKey ?? process.env.OPENROUTER_API_KEY;
|
|
61
|
+
if (!apiKey?.trim()) {
|
|
62
|
+
throw new Error(`createModel(${agent}): OPENROUTER_API_KEY is required. Pass via configureProtocol({ apiKey }) or set the OPENROUTER_API_KEY environment variable.`);
|
|
63
|
+
}
|
|
64
|
+
const cfg = getModelConfig(merged)[agent];
|
|
65
|
+
return new ChatOpenAI({
|
|
66
|
+
model: cfg.model,
|
|
67
|
+
configuration: {
|
|
68
|
+
baseURL: merged.baseURL ?? process.env.OPENROUTER_BASE_URL ?? "https://openrouter.ai/api/v1",
|
|
69
|
+
apiKey,
|
|
70
|
+
},
|
|
71
|
+
temperature: cfg.temperature,
|
|
72
|
+
maxTokens: cfg.maxTokens,
|
|
73
|
+
...(cfg.reasoning && { modelKwargs: { reasoning: cfg.reasoning } }),
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=model.config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model.config.js","sourceRoot":"","sources":["../../src/agents/model.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AA0B/C,sFAAsF;AACtF,IAAI,aAAa,GAAgB,EAAE,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,MAAmB;IACnD,aAAa,GAAG,MAAM,CAAC;AACzB,CAAC;AAED,SAAS,cAAc,CAAC,MAAoB;IAC1C,MAAM,MAAM,GAAgB,EAAE,GAAG,aAAa,EAAE,GAAG,MAAM,EAAE,CAAC;IAC5D,OAAO;QACL,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
|
1
|
+
/**
|
|
2
|
+
* Negotiation Insights Generator
|
|
3
|
+
*
|
|
4
|
+
* Produces an aggregated, second-person narrative summarizing a user's
|
|
5
|
+
* negotiation history — topics they're sought for, role patterns,
|
|
6
|
+
* opportunity trends, and interesting signals from recent activity.
|
|
7
|
+
*/
|
|
8
|
+
/** Compressed digest of a user's negotiation history for the LLM. */
|
|
9
|
+
export interface NegotiationDigest {
|
|
10
|
+
totalCount: number;
|
|
11
|
+
opportunityCount: number;
|
|
12
|
+
noOpportunityCount: number;
|
|
13
|
+
inProgressCount: number;
|
|
14
|
+
roleDistribution: Record<string, number>;
|
|
15
|
+
counterparties: string[];
|
|
16
|
+
reasoningExcerpts: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Generates an aggregated insight summary from a user's negotiation history.
|
|
20
|
+
* @remarks Lightweight single-call agent; no DB access, no side effects.
|
|
21
|
+
*/
|
|
22
|
+
export declare class NegotiationInsightsGenerator {
|
|
23
|
+
private model;
|
|
24
|
+
constructor();
|
|
25
|
+
/**
|
|
26
|
+
* Produces a narrative summary from a negotiation digest.
|
|
27
|
+
* @param digest - Pre-computed statistics and excerpts from the user's negotiations
|
|
28
|
+
* @returns A 2-4 sentence insight paragraph, or null on failure
|
|
29
|
+
*/
|
|
30
|
+
invoke(digest: NegotiationDigest): Promise<string | null>;
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=negotiation.insights.generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"negotiation.insights.generator.d.ts","sourceRoot":"","sources":["../../src/agents/negotiation.insights.generator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA2BH,qEAAqE;AACrE,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACzC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,iBAAiB,EAAE,MAAM,EAAE,CAAC;CAC7B;AAED;;;GAGG;AACH,qBAAa,4BAA4B;IACvC,OAAO,CAAC,KAAK,CAAa;;IAM1B;;;;OAIG;IAEG,MAAM,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;CAqDhE"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Negotiation Insights Generator
|
|
3
|
+
*
|
|
4
|
+
* Produces an aggregated, second-person narrative summarizing a user's
|
|
5
|
+
* negotiation history — topics they're sought for, role patterns,
|
|
6
|
+
* opportunity trends, and interesting signals from recent activity.
|
|
7
|
+
*/
|
|
8
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
9
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
10
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
11
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
12
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
13
|
+
};
|
|
14
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
15
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
16
|
+
};
|
|
17
|
+
import { HumanMessage, SystemMessage } from "@langchain/core/messages";
|
|
18
|
+
import { log } from "../support/log.js";
|
|
19
|
+
import { Timed } from "../support/performance.js";
|
|
20
|
+
import { createModel } from "./model.config.js";
|
|
21
|
+
const logger = log.lib.from("NegotiationInsightsGenerator");
|
|
22
|
+
const SYSTEM_PROMPT = `You are an analyst summarizing a user's negotiation history on a discovery network.
|
|
23
|
+
Agents negotiate on behalf of users to find collaboration opportunities.
|
|
24
|
+
|
|
25
|
+
Given a digest of past negotiations, write a concise insight paragraph (2-4 sentences) addressed to the user in second person ("you").
|
|
26
|
+
|
|
27
|
+
Guidelines:
|
|
28
|
+
- Be conversational and insightful, not just statistical.
|
|
29
|
+
- Highlight what others seek the user for, and what the user tends to seek.
|
|
30
|
+
- Mention role patterns: Helper (they assist others), Seeker (they need something), Peer (mutual collaboration).
|
|
31
|
+
- Note opportunity rate trends or interesting shifts if apparent.
|
|
32
|
+
- Reference specific topics or counterparty names when they form patterns.
|
|
33
|
+
- If there are very few negotiations (1-2), keep it brief and forward-looking.
|
|
34
|
+
- Do NOT use bullet points or lists. Write flowing prose.
|
|
35
|
+
- Do NOT start with "You have" or "Your negotiations". Be more creative.`;
|
|
36
|
+
/**
|
|
37
|
+
* Generates an aggregated insight summary from a user's negotiation history.
|
|
38
|
+
* @remarks Lightweight single-call agent; no DB access, no side effects.
|
|
39
|
+
*/
|
|
40
|
+
export class NegotiationInsightsGenerator {
|
|
41
|
+
constructor() {
|
|
42
|
+
this.model = createModel("negotiationInsights");
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Produces a narrative summary from a negotiation digest.
|
|
46
|
+
* @param digest - Pre-computed statistics and excerpts from the user's negotiations
|
|
47
|
+
* @returns A 2-4 sentence insight paragraph, or null on failure
|
|
48
|
+
*/
|
|
49
|
+
async invoke(digest) {
|
|
50
|
+
if (digest.totalCount === 0)
|
|
51
|
+
return null;
|
|
52
|
+
const lines = [
|
|
53
|
+
`Total negotiations: ${digest.totalCount}`,
|
|
54
|
+
`Opportunities: ${digest.opportunityCount}, No opportunity: ${digest.noOpportunityCount}, In progress: ${digest.inProgressCount}`,
|
|
55
|
+
];
|
|
56
|
+
const roles = Object.entries(digest.roleDistribution);
|
|
57
|
+
if (roles.length > 0) {
|
|
58
|
+
lines.push(`Role distribution: ${roles.map(([r, n]) => `${r}: ${n}`).join(", ")}`);
|
|
59
|
+
}
|
|
60
|
+
if (digest.counterparties.length > 0) {
|
|
61
|
+
lines.push(`Counterparties: ${digest.counterparties.join(", ")}`);
|
|
62
|
+
}
|
|
63
|
+
if (digest.reasoningExcerpts.length > 0) {
|
|
64
|
+
lines.push(`Sample reasoning excerpts:\n${digest.reasoningExcerpts.map((r) => `- ${r}`).join("\n")}`);
|
|
65
|
+
}
|
|
66
|
+
const userMessage = `Negotiation digest:\n${lines.join("\n")}\n\nWrite the insight summary:`;
|
|
67
|
+
try {
|
|
68
|
+
const response = await this.model.invoke([
|
|
69
|
+
new SystemMessage(SYSTEM_PROMPT),
|
|
70
|
+
new HumanMessage(userMessage),
|
|
71
|
+
]);
|
|
72
|
+
let text;
|
|
73
|
+
if (typeof response.content === "string") {
|
|
74
|
+
text = response.content.trim();
|
|
75
|
+
}
|
|
76
|
+
else if (Array.isArray(response.content)) {
|
|
77
|
+
text = response.content
|
|
78
|
+
.filter((b) => b.type === "text")
|
|
79
|
+
.map((b) => b.text ?? "")
|
|
80
|
+
.join("")
|
|
81
|
+
.trim();
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
text = "";
|
|
85
|
+
}
|
|
86
|
+
if (!text)
|
|
87
|
+
return null;
|
|
88
|
+
logger.verbose("[NegotiationInsightsGenerator.invoke] Insights generated", { length: text.length });
|
|
89
|
+
return text;
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
logger.warn("[NegotiationInsightsGenerator.invoke] Failed to generate insights", {
|
|
93
|
+
error: error instanceof Error ? error.message : String(error),
|
|
94
|
+
});
|
|
95
|
+
return null;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
__decorate([
|
|
100
|
+
Timed(),
|
|
101
|
+
__metadata("design:type", Function),
|
|
102
|
+
__metadata("design:paramtypes", [Object]),
|
|
103
|
+
__metadata("design:returntype", Promise)
|
|
104
|
+
], NegotiationInsightsGenerator.prototype, "invoke", null);
|
|
105
|
+
//# sourceMappingURL=negotiation.insights.generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"negotiation.insights.generator.js","sourceRoot":"","sources":["../../src/agents/negotiation.insights.generator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;;;;;;;;;;AAGH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAElD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC;AAE5D,MAAM,aAAa,GAAG;;;;;;;;;;;;;yEAamD,CAAC;AAa1E;;;GAGG;AACH,MAAM,OAAO,4BAA4B;IAGvC;QACE,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,qBAAqB,CAAC,CAAC;IAClD,CAAC;IAED;;;;OAIG;IAEG,AAAN,KAAK,CAAC,MAAM,CAAC,MAAyB;QACpC,IAAI,MAAM,CAAC,UAAU,KAAK,CAAC;YAAE,OAAO,IAAI,CAAC;QAEzC,MAAM,KAAK,GAAa;YACtB,uBAAuB,MAAM,CAAC,UAAU,EAAE;YAC1C,kBAAkB,MAAM,CAAC,gBAAgB,qBAAqB,MAAM,CAAC,kBAAkB,kBAAkB,MAAM,CAAC,eAAe,EAAE;SAClI,CAAC;QAEF,MAAM,KAAK,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC;QACtD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACrB,KAAK,CAAC,IAAI,CAAC,sBAAsB,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,CAAC,KAAK,CAA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B,IAAI,CAAC,EAAE,CAAC;qBACR,IAAI,EAAE,CAAC;YACZ,CAAC;iBAAM,CAAC;gBACN,IAAI,GAAG,EAAE,CAAC;YACZ,CAAC;YAED,IAAI,CAAC,IAAI;gBAAE,OAAO,IAAI,CAAC;YAEvB,MAAM,CAAC,OAAO,CAAC,0DAA0D,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YACpG,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,CAAC,IAAI,CAAC,mEAAmE,EAAE;gBAC/E,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC;aAC9D,CAAC,CAAC;YACH,OAAO,IAAI,CAAC;QACd,CAAC;IACH,CAAC;CACF;AArDO;IADL,KAAK,EAAE;;;;0DAqDP"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type NegotiationTurn, type UserNegotiationContext, type SeedAssessment } from "../states/negotiation.state.js";
|
|
2
|
+
export interface NegotiationProposerInput {
|
|
3
|
+
ownUser: UserNegotiationContext;
|
|
4
|
+
otherUser: UserNegotiationContext;
|
|
5
|
+
indexContext: {
|
|
6
|
+
indexId: string;
|
|
7
|
+
prompt: string;
|
|
8
|
+
};
|
|
9
|
+
seedAssessment: SeedAssessment;
|
|
10
|
+
history: NegotiationTurn[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Negotiation agent that argues for the match.
|
|
14
|
+
* @remarks Uses structured output to produce a NegotiationTurn.
|
|
15
|
+
*/
|
|
16
|
+
export declare class NegotiationProposer {
|
|
17
|
+
private model;
|
|
18
|
+
constructor();
|
|
19
|
+
/**
|
|
20
|
+
* Generate a proposal or counter-proposal turn.
|
|
21
|
+
* @param input - User contexts, seed assessment, and negotiation history
|
|
22
|
+
* @returns A structured NegotiationTurn
|
|
23
|
+
*/
|
|
24
|
+
invoke(input: NegotiationProposerInput): Promise<NegotiationTurn>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=negotiation.proposer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"negotiation.proposer.d.ts","sourceRoot":"","sources":["../../src/agents/negotiation.proposer.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,eAAe,EAAE,KAAK,sBAAsB,EAAE,KAAK,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAyB/I,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,sBAAsB,CAAC;IAChC,SAAS,EAAE,sBAAsB,CAAC;IAClC,YAAY,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,cAAc,EAAE,cAAc,CAAC;IAC/B,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B;AAED;;;GAGG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,KAAK,CAAC;;IASd;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,eAAe,CAAC;CA+BxE"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { createModel } from "./model.config.js";
|
|
2
|
+
import { NegotiationTurnSchema } from "../states/negotiation.state.js";
|
|
3
|
+
const SYSTEM_PROMPT = `You are a negotiation agent representing your user in an opportunity matching system.
|
|
4
|
+
Your role is to PROPOSE and ARGUE FOR a potential match between your user and another user.
|
|
5
|
+
|
|
6
|
+
You will receive:
|
|
7
|
+
- Your user's profile, intents, and context
|
|
8
|
+
- The other user's profile, intents, and context
|
|
9
|
+
- An initial assessment from a pre-screening evaluator
|
|
10
|
+
- Any prior negotiation history
|
|
11
|
+
|
|
12
|
+
Your job:
|
|
13
|
+
1. On the FIRST turn: Propose the match. Explain why this connection would benefit both parties. Set action to "propose".
|
|
14
|
+
2. On SUBSEQUENT turns (after a counter from the other agent): Address their objections. Either:
|
|
15
|
+
- "counter" with updated reasoning if you still believe in the match
|
|
16
|
+
- "accept" if the other agent's counter is reasonable and you agree
|
|
17
|
+
- "reject" if their objections reveal this is genuinely not a good match
|
|
18
|
+
|
|
19
|
+
Rules:
|
|
20
|
+
- Be honest. Do not hallucinate fit where there is none.
|
|
21
|
+
- Focus on concrete intent alignment, not vague similarities.
|
|
22
|
+
- If the evaluator pre-screen score was low, acknowledge weaknesses.
|
|
23
|
+
- Your fitScore should reflect YOUR honest assessment, not just echo the seed score.
|
|
24
|
+
- suggestedRoles: "agent" = can help, "patient" = seeks help, "peer" = mutual benefit.`;
|
|
25
|
+
/**
|
|
26
|
+
* Negotiation agent that argues for the match.
|
|
27
|
+
* @remarks Uses structured output to produce a NegotiationTurn.
|
|
28
|
+
*/
|
|
29
|
+
export class NegotiationProposer {
|
|
30
|
+
constructor() {
|
|
31
|
+
this.model = createModel("negotiationProposer").withStructuredOutput(NegotiationTurnSchema, { name: "negotiation_proposer" });
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Generate a proposal or counter-proposal turn.
|
|
35
|
+
* @param input - User contexts, seed assessment, and negotiation history
|
|
36
|
+
* @returns A structured NegotiationTurn
|
|
37
|
+
*/
|
|
38
|
+
async invoke(input) {
|
|
39
|
+
const historyText = input.history.length > 0
|
|
40
|
+
? `\n\nNegotiation history:\n${input.history.map((t, i) => `Turn ${i + 1}: ${t.action} — fitScore: ${t.assessment.fitScore}, reasoning: ${t.assessment.reasoning}`).join("\n")}`
|
|
41
|
+
: "";
|
|
42
|
+
const userMessage = `YOUR USER:
|
|
43
|
+
Name: ${input.ownUser.profile.name ?? "Unknown"}
|
|
44
|
+
Bio: ${input.ownUser.profile.bio ?? "N/A"}
|
|
45
|
+
Skills: ${input.ownUser.profile.skills?.join(", ") ?? "N/A"}
|
|
46
|
+
Intents: ${input.ownUser.intents.map((i) => `- ${i.title}: ${i.description} (confidence: ${i.confidence})`).join("\n")}
|
|
47
|
+
|
|
48
|
+
OTHER USER:
|
|
49
|
+
Name: ${input.otherUser.profile.name ?? "Unknown"}
|
|
50
|
+
Bio: ${input.otherUser.profile.bio ?? "N/A"}
|
|
51
|
+
Skills: ${input.otherUser.profile.skills?.join(", ") ?? "N/A"}
|
|
52
|
+
Intents: ${input.otherUser.intents.map((i) => `- ${i.title}: ${i.description} (confidence: ${i.confidence})`).join("\n")}
|
|
53
|
+
|
|
54
|
+
INDEX CONTEXT: ${input.indexContext.prompt || "General discovery"}
|
|
55
|
+
|
|
56
|
+
EVALUATOR PRE-SCREEN: Score ${input.seedAssessment.score}/100 — ${input.seedAssessment.reasoning}
|
|
57
|
+
Suggested role: ${input.seedAssessment.valencyRole}${historyText}
|
|
58
|
+
|
|
59
|
+
${input.history.length === 0 ? "This is the opening turn. Propose the match." : "The other agent countered. Respond to their objections."}`;
|
|
60
|
+
const result = await this.model.invoke([
|
|
61
|
+
{ role: "system", content: SYSTEM_PROMPT },
|
|
62
|
+
{ role: "user", content: userMessage },
|
|
63
|
+
]);
|
|
64
|
+
return result;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=negotiation.proposer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"negotiation.proposer.js","sourceRoot":"","sources":["../../src/agents/negotiation.proposer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAA0E,MAAM,gCAAgC,CAAC;AAE/I,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;;;;;;uFAqBiE,CAAC;AAUxF;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IAG9B;QACE,IAAI,CAAC,KAAK,GAAG,WAAW,CAAC,qBAAqB,CAAC,CAAC,oBAAoB,CAClE,qBAAqB,EACrB,EAAE,IAAI,EAAE,sBAAsB,EAAE,CACjC,CAAC;IACJ,CAAC;IAED;;;;OAIG;I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AAC,CAAC,IAAI,CAAC,IAAI,CAAC;;iBAEvG,KAAK,CAAC,YAAY,CAAC,MAAM,IAAI,mBAAmB;;8BAEnC,KAAK,CAAC,cAAc,CAAC,KAAK,UAAU,KAAK,CAAC,cAAc,CAAC,SAAS;kBAC9E,KAAK,CAAC,cAAc,CAAC,WAAW,GAAG,WAAW;;EAE9D,KAAK,CAAC,OAAO,CAAC,MAAM,KAAK,CAAC,CAAC,CAAC,CAAC,8CAA8C,CAAC,CAAC,CAAC,yDAAyD,EAAE,CAAC;QAExI,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;YACrC,EAAE,IAAI,EAAE,QAAQ,EAAE,OAAO,EAAE,aAAa,EAAE;YAC1C,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE;SACvC,CAAC,CAAC;QAEH,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type NegotiationTurn, type UserNegotiationContext, type SeedAssessment } from "../states/negotiation.state.js";
|
|
2
|
+
export interface NegotiationResponderInput {
|
|
3
|
+
ownUser: UserNegotiationContext;
|
|
4
|
+
otherUser: UserNegotiationContext;
|
|
5
|
+
indexContext: {
|
|
6
|
+
indexId: string;
|
|
7
|
+
prompt: string;
|
|
8
|
+
};
|
|
9
|
+
seedAssessment: SeedAssessment;
|
|
10
|
+
history: NegotiationTurn[];
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Negotiation agent that evaluates proposals against its user's interests.
|
|
14
|
+
* @remarks Uses structured output to produce a NegotiationTurn.
|
|
15
|
+
*/
|
|
16
|
+
export declare class NegotiationResponder {
|
|
17
|
+
private model;
|
|
18
|
+
constructor();
|
|
19
|
+
/**
|
|
20
|
+
* Evaluate a proposal/counter and respond.
|
|
21
|
+
* @param input - User contexts, seed assessment, and negotiation history
|
|
22
|
+
* @returns A structured NegotiationTurn (accept/reject/counter)
|
|
23
|
+
*/
|
|
24
|
+
invoke(input: NegotiationResponderInput): Promise<NegotiationTurn>;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=negotiation.responder.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"negotiation.responder.d.ts","sourceRoot":"","sources":["../../src/agents/negotiation.responder.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,eAAe,EAAE,KAAK,sBAAsB,EAAE,KAAK,cAAc,EAAE,MAAM,gCAAgC,CAAC;AA2B/I,MAAM,WAAW,yBAAyB;IACxC,OAAO,EAAE,sBAAsB,CAAC;IAChC,SAAS,EAAE,sBAAsB,CAAC;IAClC,YAAY,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IAClD,cAAc,EAAE,cAAc,CAAC;IAC/B,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B;AAED;;;GAGG;AACH,qBAAa,oBAAoB;IAC/B,OAAO,CAAC,KAAK,CAAC;;IASd;;;;OAIG;IACG,MAAM,CAAC,KAAK,EAAE,yBAAyB,GAAG,OAAO,CAAC,eAAe,CAAC;CAiCzE"}
|