@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,97 @@
|
|
|
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
|
+
import { HumanMessage, SystemMessage } from "@langchain/core/messages";
|
|
11
|
+
import { tool } from "@langchain/core/tools";
|
|
12
|
+
import { z } from "zod/v4";
|
|
13
|
+
import { protocolLogger } from "../support/protocol.logger.js";
|
|
14
|
+
import { config } from "dotenv";
|
|
15
|
+
import { Timed } from "../support/performance.js";
|
|
16
|
+
import { createModel } from "./model.config.js";
|
|
17
|
+
config({ path: '.env.development', override: true });
|
|
18
|
+
const logger = protocolLogger("ProfileGenerator");
|
|
19
|
+
const model = createModel("profileGenerator");
|
|
20
|
+
const systemPrompt = `
|
|
21
|
+
You are an expert profiler. Your task is to synthesize a structured User Profile from raw data or user requests.
|
|
22
|
+
|
|
23
|
+
When given EXISTING PROFILE + USER REQUEST: Apply the request to the existing profile. Add, update, or remove skills and interests as the user asks. Preserve everything else. Output the full updated profile.
|
|
24
|
+
|
|
25
|
+
When given raw data only: Infer name, bio, location, narrative.context, and extract skills and interests.
|
|
26
|
+
|
|
27
|
+
PRIVACY: identity.bio and narrative.context are public-facing. Never include email addresses, phone numbers, physical addresses, government IDs, or other contact identifiers — even if they appear in the raw data. Describe the person professionally; do not embed ways to contact them.
|
|
28
|
+
`;
|
|
29
|
+
const responseFormat = z.object({
|
|
30
|
+
identity: z.object({
|
|
31
|
+
name: z.string().describe("The user's full name"),
|
|
32
|
+
bio: z.string().describe("Professional summary (2-3 sentences) only; no email, phone, physical address, government ID, or other contact identifiers"),
|
|
33
|
+
location: z.string().describe("Inferred location (City, Country) or 'Remote'"),
|
|
34
|
+
}),
|
|
35
|
+
narrative: z.object({
|
|
36
|
+
context: z.string().describe("Rich narrative without email, phone, physical address, government ID, or other contact identifiers"),
|
|
37
|
+
}),
|
|
38
|
+
attributes: z.object({
|
|
39
|
+
interests: z.array(z.string()).describe("Inferred or explicit interests"),
|
|
40
|
+
skills: z.array(z.string()).describe("Professional skills"),
|
|
41
|
+
}),
|
|
42
|
+
});
|
|
43
|
+
export class ProfileGenerator {
|
|
44
|
+
constructor() {
|
|
45
|
+
this.model = model.withStructuredOutput(responseFormat, {
|
|
46
|
+
name: "profile_generator"
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
toString(profile) {
|
|
50
|
+
const textToEmbed = [
|
|
51
|
+
'# Identity',
|
|
52
|
+
'## Name', profile.identity.name,
|
|
53
|
+
'## Bio', profile.identity.bio,
|
|
54
|
+
'## Location', profile.identity.location,
|
|
55
|
+
'# Narrative',
|
|
56
|
+
'## Context', profile.narrative.context,
|
|
57
|
+
'# Attributes',
|
|
58
|
+
'## Interests', profile.attributes.interests.join(', '),
|
|
59
|
+
'## Skills', profile.attributes.skills.join(', ')
|
|
60
|
+
].join('\n');
|
|
61
|
+
return textToEmbed;
|
|
62
|
+
}
|
|
63
|
+
async invoke(input) {
|
|
64
|
+
logger.verbose("Received input", { inputLength: input?.length });
|
|
65
|
+
const messages = [
|
|
66
|
+
new SystemMessage(systemPrompt),
|
|
67
|
+
new HumanMessage(`Here is the raw data:\n${input}`)
|
|
68
|
+
];
|
|
69
|
+
const result = await this.model.invoke(messages);
|
|
70
|
+
const output = responseFormat.parse(result);
|
|
71
|
+
const textToEmbed = this.toString(output);
|
|
72
|
+
logger.verbose("Generated profile", {
|
|
73
|
+
skillsCount: output.attributes.skills.length,
|
|
74
|
+
interestsCount: output.attributes.interests.length
|
|
75
|
+
});
|
|
76
|
+
return { output, textToEmbed };
|
|
77
|
+
}
|
|
78
|
+
static asTool() {
|
|
79
|
+
return tool(async (args) => {
|
|
80
|
+
const profileGenerator = new ProfileGenerator();
|
|
81
|
+
return await profileGenerator.invoke(args.input);
|
|
82
|
+
}, {
|
|
83
|
+
name: 'profileGenerator',
|
|
84
|
+
description: 'Profile Generator',
|
|
85
|
+
schema: z.object({
|
|
86
|
+
input: z.string().describe('Raw data scraped from the web (via Parallel.ai)'),
|
|
87
|
+
})
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
__decorate([
|
|
92
|
+
Timed(),
|
|
93
|
+
__metadata("design:type", Function),
|
|
94
|
+
__metadata("design:paramtypes", [String]),
|
|
95
|
+
__metadata("design:returntype", Promise)
|
|
96
|
+
], ProfileGenerator.prototype, "invoke", null);
|
|
97
|
+
//# sourceMappingURL=profile.generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.generator.js","sourceRoot":"","sources":["../../src/agents/profile.generator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,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CAAC,CAAC;QACH,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;IACjC,CAAC;IAEM,MAAM,CAAC,MAAM;QAClB,OAAO,IAAI,CACT,KAAK,EAAE,IAAuB,EAAE,EAAE;YAChC,MAAM,gBAAgB,GAAG,IAAI,gBAAgB,EAAE,CAAC;YAChD,OAAO,MAAM,gBAAgB,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACnD,CAAC,EACD;YACE,IAAI,EAAE,kBAAkB;YACxB,WAAW,EAAE,mBAAmB;YAChC,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;gBACf,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,iDAAiD,CAAC;aAC9E,CAAC;SACH,CACF,CAAC;IACJ,CAAC;CACF;AA/Bc;IADZ,KAAK,EAAE;;;;8CAeP"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { z } from "zod/v4";
|
|
2
|
+
export declare class HydeGenerator {
|
|
3
|
+
private model;
|
|
4
|
+
constructor();
|
|
5
|
+
private toString;
|
|
6
|
+
invoke(input: string): Promise<{
|
|
7
|
+
output: {
|
|
8
|
+
identity: {
|
|
9
|
+
bio: string;
|
|
10
|
+
};
|
|
11
|
+
narrative: {
|
|
12
|
+
context: string;
|
|
13
|
+
};
|
|
14
|
+
attributes: {
|
|
15
|
+
interests: string[];
|
|
16
|
+
skills: string[];
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
textToEmbed: string;
|
|
20
|
+
}>;
|
|
21
|
+
static asTool(): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
22
|
+
input: z.ZodString;
|
|
23
|
+
}, z.core.$strip>, {
|
|
24
|
+
input: string;
|
|
25
|
+
}, {
|
|
26
|
+
input: string;
|
|
27
|
+
}, {
|
|
28
|
+
output: {
|
|
29
|
+
identity: {
|
|
30
|
+
bio: string;
|
|
31
|
+
};
|
|
32
|
+
narrative: {
|
|
33
|
+
context: string;
|
|
34
|
+
};
|
|
35
|
+
attributes: {
|
|
36
|
+
interests: string[];
|
|
37
|
+
skills: string[];
|
|
38
|
+
};
|
|
39
|
+
};
|
|
40
|
+
textToEmbed: string;
|
|
41
|
+
}, unknown, "hydeGenerator">;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=profile.hyde.generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.hyde.generator.d.ts","sourceRoot":"","sources":["../../src/agents/profile.hyde.generator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AA0D3B,qBAAa,aAAa;IACxB,OAAO,CAAC,KAAK,CAAM;;IAOnB,OAAO,CAAC,QAAQ;IAeH,MAAM,CAAC,KAAK,EAAE,MAAM;;;;;;;;;;;;;;;WAgBnB,MAAM;;;;;;;;;;;;;;;;;;;;;CAerB"}
|
|
@@ -0,0 +1,113 @@
|
|
|
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
|
+
import { HumanMessage, SystemMessage } from "@langchain/core/messages";
|
|
11
|
+
import { tool } from "@langchain/core/tools";
|
|
12
|
+
import { z } from "zod/v4";
|
|
13
|
+
import { protocolLogger } from "../support/protocol.logger.js";
|
|
14
|
+
/**
|
|
15
|
+
* Config
|
|
16
|
+
*/
|
|
17
|
+
import { config } from "dotenv";
|
|
18
|
+
config({ path: '.env.development', override: true });
|
|
19
|
+
import { Timed } from "../support/performance.js";
|
|
20
|
+
import { createModel } from "./model.config.js";
|
|
21
|
+
const logger = protocolLogger("HyDEGenerator");
|
|
22
|
+
const model = createModel("profileHydeGenerator");
|
|
23
|
+
const systemPrompt = `
|
|
24
|
+
You are a Profile Profiler.
|
|
25
|
+
Given a user's profile, imagine a **Hypothetical User Profile** person that would be the best match for the user to accomplish their goals.
|
|
26
|
+
|
|
27
|
+
Imagine this ideal candidate actually exists. Write a profile for THEM.
|
|
28
|
+
Your output will be used to vector-search a database of real user profiles.
|
|
29
|
+
|
|
30
|
+
Structure your response as a natural language Bio/Narrative written in the **Third Person**.
|
|
31
|
+
|
|
32
|
+
The description should include:
|
|
33
|
+
1. **Context**: Who they are (role, background).
|
|
34
|
+
2. **Skills/lnterests**: What they are good at that complements the user.
|
|
35
|
+
3. **Goals**: What they are trying to achieve that aligns with the user.
|
|
36
|
+
|
|
37
|
+
**CRITICAL INSTRUCTION - COMPLEMENTARY MATCHING:**
|
|
38
|
+
- Do NOT just look for "similar" people. Look for people who provide what the user NEEDS (Supply/Demand).
|
|
39
|
+
- If the user is a **Founder**, describe an **Investor** or **VC**.
|
|
40
|
+
- If the user is a **Learner**, describe a **Mentor** or **Expert**.
|
|
41
|
+
- If the user is a **Builder**, describe a **Collaborator** or **Co-founder**.
|
|
42
|
+
|
|
43
|
+
Do NOT describe the Source User. Describe the TARGET Match.
|
|
44
|
+
Do NOT invent a name for the candidate. Refer to them as "The candidate", "They", or "This individual".
|
|
45
|
+
Do NOT include locations.
|
|
46
|
+
|
|
47
|
+
PRIVACY: Never include email addresses, phone numbers, physical addresses, government IDs, or other contact identifiers in bio or narrative — even if they appear in the source profile.
|
|
48
|
+
`;
|
|
49
|
+
const responseFormat = z.object({
|
|
50
|
+
identity: z.object({
|
|
51
|
+
bio: z.string().describe("Professional summary only; no email, phone, physical address, government ID, or other contact identifiers"),
|
|
52
|
+
}),
|
|
53
|
+
narrative: z.object({
|
|
54
|
+
context: z.string().describe("Rich narrative without email, phone, physical address, government ID, or other contact identifiers"),
|
|
55
|
+
}),
|
|
56
|
+
attributes: z.object({
|
|
57
|
+
interests: z.array(z.string()).describe("Inferred or explicit interests"),
|
|
58
|
+
skills: z.array(z.string()).describe("Professional skills"),
|
|
59
|
+
}),
|
|
60
|
+
});
|
|
61
|
+
export class HydeGenerator {
|
|
62
|
+
constructor() {
|
|
63
|
+
this.model = model.withStructuredOutput(responseFormat, {
|
|
64
|
+
name: "hyde_generator"
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
toString(description) {
|
|
68
|
+
const textToEmbed = [
|
|
69
|
+
'# Identity',
|
|
70
|
+
'## Bio', description.identity.bio,
|
|
71
|
+
'# Narrative',
|
|
72
|
+
'## Context', description.narrative.context,
|
|
73
|
+
'# Attributes',
|
|
74
|
+
'## Interests', description.attributes.interests.join(', '),
|
|
75
|
+
'## Skills', description.attributes.skills.join(', ')
|
|
76
|
+
].join('\n');
|
|
77
|
+
return textToEmbed;
|
|
78
|
+
}
|
|
79
|
+
async invoke(input) {
|
|
80
|
+
logger.verbose("Received input", { inputLength: input?.length });
|
|
81
|
+
const messages = [
|
|
82
|
+
new SystemMessage(systemPrompt),
|
|
83
|
+
new HumanMessage(`Here is the profile for the HyDE Generation:\n${input}`)
|
|
84
|
+
];
|
|
85
|
+
const result = await this.model.invoke(messages);
|
|
86
|
+
const output = responseFormat.parse(result);
|
|
87
|
+
const textToEmbed = this.toString(output);
|
|
88
|
+
logger.verbose("Generated HyDE profile", {
|
|
89
|
+
skillsCount: output.attributes.skills.length,
|
|
90
|
+
interestsCount: output.attributes.interests.length
|
|
91
|
+
});
|
|
92
|
+
return { output, textToEmbed };
|
|
93
|
+
}
|
|
94
|
+
static asTool() {
|
|
95
|
+
return tool(async (args) => {
|
|
96
|
+
const hydeGenerator = new HydeGenerator();
|
|
97
|
+
return await hydeGenerator.invoke(args.input);
|
|
98
|
+
}, {
|
|
99
|
+
name: 'hydeGenerator',
|
|
100
|
+
description: 'HyDE Generator',
|
|
101
|
+
schema: z.object({
|
|
102
|
+
input: z.string().describe('The profile to generate a HyDE for'),
|
|
103
|
+
})
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
__decorate([
|
|
108
|
+
Timed(),
|
|
109
|
+
__metadata("design:type", Function),
|
|
110
|
+
__metadata("design:paramtypes", [String]),
|
|
111
|
+
__metadata("design:returntype", Promise)
|
|
112
|
+
], HydeGenerator.prototype, "invoke", null);
|
|
113
|
+
//# sourceMappingURL=profile.hyde.generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.hyde.generator.js","sourceRoot":"","sources":["../../src/agents/profile.hyde.generator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAC7C,OAAO,EAAE,CAAC,EAAE,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAE/D;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,MAAM,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AACrD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,GAAG,cAAc,CAAC,eAAe,CAAC,CAAC;AAE/C,MAAM,KAAK,GAAG,WAAW,CAAC,sBAAsB,CAAC,CAAC;AAElD,MAAM,YAAY,GAAG;;;;;;;;;;;;;;;;;;;;;;;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
+
export interface SuggestionGeneratorInput {
|
|
3
|
+
/** Last few messages (user and assistant) to derive context */
|
|
4
|
+
messages: Array<{
|
|
5
|
+
role: "user" | "assistant";
|
|
6
|
+
content: string;
|
|
7
|
+
}>;
|
|
8
|
+
/** Optional index/community context to tailor suggestions */
|
|
9
|
+
indexContext?: string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Lightweight generator for context-aware chat follow-up suggestions.
|
|
13
|
+
* Uses a fast model and structured output to return 3-5 suggestions per call.
|
|
14
|
+
*/
|
|
15
|
+
export declare class SuggestionGenerator {
|
|
16
|
+
private model;
|
|
17
|
+
constructor();
|
|
18
|
+
/**
|
|
19
|
+
* Generate follow-up suggestions from the last exchange.
|
|
20
|
+
* Returns empty array on failure (graceful degradation).
|
|
21
|
+
*/
|
|
22
|
+
generate(input: SuggestionGeneratorInput): Promise<ChatSuggestion[]>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=suggestion.generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggestion.generator.d.ts","sourceRoot":"","sources":["../../src/agents/suggestion.generator.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,kCAAkC,CAAC;AAiCvE,MAAM,WAAW,wBAAwB;IACvC,+DAA+D;IAC/D,QAAQ,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,GAAG,WAAW,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjE,6DAA6D;IAC7D,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;;GAGG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,KAAK,CAAiD;;IAO9D;;;OAGG;IAEG,QAAQ,CAAC,KAAK,EAAE,wBAAwB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;CAsC3E"}
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
+
import { HumanMessage, SystemMessage } from "@langchain/core/messages";
|
|
11
|
+
import { z } from "zod";
|
|
12
|
+
import { protocolLogger } from "../support/protocol.logger.js";
|
|
13
|
+
import { Timed } from "../support/performance.js";
|
|
14
|
+
import { createModel } from "./model.config.js";
|
|
15
|
+
const logger = protocolLogger("SuggestionGenerator");
|
|
16
|
+
const suggestionItemSchema = z.object({
|
|
17
|
+
label: z.string().describe("Short label for the chip (2-5 words)"),
|
|
18
|
+
type: z.enum(["direct", "prompt"]).describe("direct = auto-submit message; prompt = prefill input"),
|
|
19
|
+
followupText: z.string().nullable().describe("For type=direct: full message to send when clicked; null for prompt type"),
|
|
20
|
+
prefill: z.string().nullable().describe("For type=prompt: text to prefill the input; null for direct type"),
|
|
21
|
+
});
|
|
22
|
+
const suggestionsSchema = z.object({
|
|
23
|
+
suggestions: z
|
|
24
|
+
.array(suggestionItemSchema)
|
|
25
|
+
.min(1)
|
|
26
|
+
.max(6)
|
|
27
|
+
.describe("3-5 follow-up suggestions based on the conversation"),
|
|
28
|
+
});
|
|
29
|
+
const SYSTEM_PROMPT = `You generate follow-up suggestions for a chat user based on their conversation.
|
|
30
|
+
|
|
31
|
+
Rules:
|
|
32
|
+
- Return 3-5 suggestions. Mix of "direct" (one-click send) and "prompt" (prefill for user to edit).
|
|
33
|
+
- Labels must be short: 2-5 words (e.g. "Find collaborators", "Add more details").
|
|
34
|
+
- For type=direct: provide followupText as the exact message to send (complete sentence).
|
|
35
|
+
- For type=prompt: provide prefill as the start of a sentence the user can complete (e.g. "I need help with ").
|
|
36
|
+
- Suggestions must be relevant to the last exchange and natural next steps.
|
|
37
|
+
- Do not repeat what the user or assistant just said; suggest logical follow-ups.
|
|
38
|
+
- Voice: Calm, direct; no hype or networking clichés. Prefer words like opportunity, overlap, signal, pattern, relevant. Avoid: search, leverage, networking, match, optimize, scale.`;
|
|
39
|
+
/**
|
|
40
|
+
* Lightweight generator for context-aware chat follow-up suggestions.
|
|
41
|
+
* Uses a fast model and structured output to return 3-5 suggestions per call.
|
|
42
|
+
*/
|
|
43
|
+
export class SuggestionGenerator {
|
|
44
|
+
constructor() {
|
|
45
|
+
const llm = createModel("suggestionGenerator");
|
|
46
|
+
this.model = llm.withStructuredOutput(suggestionsSchema, { name: "chat_suggestions" });
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Generate follow-up suggestions from the last exchange.
|
|
50
|
+
* Returns empty array on failure (graceful degradation).
|
|
51
|
+
*/
|
|
52
|
+
async generate(input) {
|
|
53
|
+
const { messages, indexContext } = input;
|
|
54
|
+
if (messages.length === 0)
|
|
55
|
+
return [];
|
|
56
|
+
const excerpt = messages
|
|
57
|
+
.slice(-6)
|
|
58
|
+
.map((m) => `${m.role === "user" ? "User" : "Assistant"}: ${m.content.slice(0, 300)}`)
|
|
59
|
+
.join("\n\n");
|
|
60
|
+
const userContent = indexContext
|
|
61
|
+
? `Conversation (community context: ${indexContext}):\n\n${excerpt}\n\nGenerate 3-5 follow-up suggestions.`
|
|
62
|
+
: `Conversation:\n\n${excerpt}\n\nGenerate 3-5 follow-up suggestions.`;
|
|
63
|
+
try {
|
|
64
|
+
const result = await this.model.invoke([
|
|
65
|
+
new SystemMessage(SYSTEM_PROMPT),
|
|
66
|
+
new HumanMessage(userContent),
|
|
67
|
+
]);
|
|
68
|
+
const parsed = suggestionsSchema.safeParse(result);
|
|
69
|
+
if (!parsed.success) {
|
|
70
|
+
logger.warn("[SuggestionGenerator] Parse failed", { error: parsed.error.message });
|
|
71
|
+
return [];
|
|
72
|
+
}
|
|
73
|
+
const out = parsed.data.suggestions.map((s) => ({
|
|
74
|
+
label: s.label,
|
|
75
|
+
type: s.type,
|
|
76
|
+
...(s.type === "direct" && s.followupText != null && { followupText: s.followupText }),
|
|
77
|
+
...(s.type === "prompt" && s.prefill != null && { prefill: s.prefill }),
|
|
78
|
+
}));
|
|
79
|
+
logger.verbose("[SuggestionGenerator] Generated", { count: out.length });
|
|
80
|
+
return out;
|
|
81
|
+
}
|
|
82
|
+
catch (error) {
|
|
83
|
+
logger.warn("[SuggestionGenerator] Failed", {
|
|
84
|
+
error: error instanceof Error ? error.message : String(error),
|
|
85
|
+
});
|
|
86
|
+
return [];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
__decorate([
|
|
91
|
+
Timed(),
|
|
92
|
+
__metadata("design:type", Function),
|
|
93
|
+
__metadata("design:paramtypes", [Object]),
|
|
94
|
+
__metadata("design:returntype", Promise)
|
|
95
|
+
], SuggestionGenerator.prototype, "generate", null);
|
|
96
|
+
//# sourceMappingURL=suggestion.generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"suggestion.generator.js","sourceRoot":"","sources":["../../src/agents/suggestion.generator.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,C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