@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,184 @@
|
|
|
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";
|
|
13
|
+
import { protocolLogger } from "../support/protocol.logger.js";
|
|
14
|
+
import { Timed } from "../support/performance.js";
|
|
15
|
+
import { createModel } from "./model.config.js";
|
|
16
|
+
const logger = protocolLogger("IntentReconciler");
|
|
17
|
+
/**
|
|
18
|
+
* Config
|
|
19
|
+
*/
|
|
20
|
+
import { config } from "dotenv";
|
|
21
|
+
config({ path: '.env.development', override: true });
|
|
22
|
+
const model = createModel("intentReconciler");
|
|
23
|
+
const CreateActionTypeSchema = z.union([z.literal("create"), z.literal("CREATE")]);
|
|
24
|
+
const UpdateActionTypeSchema = z.union([z.literal("update"), z.literal("UPDATE")]);
|
|
25
|
+
const ExpireActionTypeSchema = z.union([z.literal("expire"), z.literal("EXPIRE")]);
|
|
26
|
+
// ──────────────────────────────────────────────────────────────
|
|
27
|
+
// 1. SYSTEM PROMPT
|
|
28
|
+
// ──────────────────────────────────────────────────────────────
|
|
29
|
+
const systemPrompt = `
|
|
30
|
+
You are an expert Intent Manager. Your goal is to reconcile NEWLY INFERRED intents with the user's ACTIVE intents.
|
|
31
|
+
|
|
32
|
+
You have access to:
|
|
33
|
+
1. Inferred Intents: Goals or Tombstones extracted from recent user activity.
|
|
34
|
+
2. Active Intents: What the user is currently working on.
|
|
35
|
+
|
|
36
|
+
YOUR TASK:
|
|
37
|
+
Compare the Inferred Intents against the Active Intents and decide on the necessary ACTIONS (Create, Update, Expire).
|
|
38
|
+
|
|
39
|
+
MATCHING LOGIC:
|
|
40
|
+
- You must determine if an Inferred Intent refers to the same underlying goal as an Active Intent.
|
|
41
|
+
- You must detect if an Inferred Intent CONTRADICTS an Active Intent (Change of Mind).
|
|
42
|
+
|
|
43
|
+
SEMANTIC GOVERNANCE RULES (Donnellan's Distinction):
|
|
44
|
+
- **REFERENTIAL Intents** (Anchor != NULL): These point to specific entities (e.g., "Google").
|
|
45
|
+
- Matching logic: Match if the Anchor is the SAME.
|
|
46
|
+
- If Anchor is different (e.g. "Join Google" vs "Join Meta"), they are DIFFERENT intents.
|
|
47
|
+
- **ATTRIBUTIVE Intents** (Anchor == NULL): These describe a class of things.
|
|
48
|
+
- Matching logic: Match if the description is semantically similar content.
|
|
49
|
+
- E.g. "Join a startup" and "Work for a small tech company" are the SAME.
|
|
50
|
+
|
|
51
|
+
ACTIONS:
|
|
52
|
+
- CREATE: If an Inferred Goal does NOT match any Active Intent, CREATE it.
|
|
53
|
+
- UPDATE: If an Inferred Goal matches an Active Intent but offers a better/different description, UPDATE it. When the match is an exact duplicate (same goal, no change needed), still output an UPDATE action with that Active Intent's id and the same payload—this allows the caller to link the intent to an index (e.g. add it to a community).
|
|
54
|
+
CRITICAL UPDATE MERGE RULES:
|
|
55
|
+
* When UPDATING an intent, you MUST PRESERVE all existing details from the Active Intent.
|
|
56
|
+
* Only MODIFY or ADD the specific aspects mentioned in the Inferred Intent.
|
|
57
|
+
* NEVER remove existing details unless explicitly contradicted.
|
|
58
|
+
* Examples:
|
|
59
|
+
- Active: "Create a text-based RPG game"
|
|
60
|
+
- Inferred: "Create an RPG game with LLM-enhanced narration"
|
|
61
|
+
- CORRECT UPDATE: "Create a text-based RPG game with LLM-enhanced narration" (preserved "text-based")
|
|
62
|
+
- WRONG UPDATE: "Create an RPG game with LLM-enhanced narration" (lost "text-based")
|
|
63
|
+
* Think of updates as REFINEMENTS or ADDITIONS, not REPLACEMENTS.
|
|
64
|
+
* If the Inferred Intent is a complete restatement, it's fine to use it directly.
|
|
65
|
+
* If the Inferred Intent adds/modifies specific aspects, merge it with existing details.
|
|
66
|
+
- EXPIRE: If an Inferred Tombstone matches an Active Intent (semantically), EXPIRE it.
|
|
67
|
+
- CONFLICT RESOLUTION: If a NEW Goal contradicts an Active Intent, EXPIRE the old and CREATE the new.
|
|
68
|
+
- DEDUPLICATION: Use Donnellan's Distinction above to merge duplicates. For duplicates, output UPDATE (not an empty list) so the intent can be linked to an index.
|
|
69
|
+
|
|
70
|
+
Output a list of specific actions to apply.
|
|
71
|
+
IMPORTANT: The type field MUST be exactly one of: "create", "update", "expire" (lowercase).
|
|
72
|
+
`;
|
|
73
|
+
// ──────────────────────────────────────────────────────────────
|
|
74
|
+
// 2. RESPONSE SCHEMA (Zod)
|
|
75
|
+
// ──────────────────────────────────────────────────────────────
|
|
76
|
+
const CreateIntentActionSchema = z.object({
|
|
77
|
+
type: CreateActionTypeSchema,
|
|
78
|
+
payload: z.string().describe("The new intent description"),
|
|
79
|
+
score: z.number().nullable().describe("The felicity score (0-100)"),
|
|
80
|
+
reasoning: z.string().nullable().describe("Reasoning for the creation (including felicity)"),
|
|
81
|
+
// Semantic Governance Fields
|
|
82
|
+
intentMode: z.enum(['REFERENTIAL', 'ATTRIBUTIVE']).nullable().describe("Donnellan's Distinction"),
|
|
83
|
+
referentialAnchor: z.string().nullable().describe("Entity anchored to"),
|
|
84
|
+
semanticEntropy: z.number().nullable().describe("Constraint Density Score (0-1)"),
|
|
85
|
+
});
|
|
86
|
+
const UpdateIntentActionSchema = z.object({
|
|
87
|
+
type: UpdateActionTypeSchema,
|
|
88
|
+
id: z.string().describe("The ID of the intent to update"),
|
|
89
|
+
payload: z.string().describe("The updated intent description"),
|
|
90
|
+
score: z.number().nullable().describe("The felicity score (0-100)"),
|
|
91
|
+
reasoning: z.string().nullable().describe("Reasoning for the update"),
|
|
92
|
+
intentMode: z.enum(['REFERENTIAL', 'ATTRIBUTIVE']).nullable(),
|
|
93
|
+
});
|
|
94
|
+
const ExpireIntentActionSchema = z.object({
|
|
95
|
+
type: ExpireActionTypeSchema,
|
|
96
|
+
id: z.string().describe("The ID of the intent to expire"),
|
|
97
|
+
reason: z.string().describe("Why it is expired")
|
|
98
|
+
});
|
|
99
|
+
const responseFormat = z.object({
|
|
100
|
+
actions: z.array(z.union([
|
|
101
|
+
CreateIntentActionSchema,
|
|
102
|
+
UpdateIntentActionSchema,
|
|
103
|
+
ExpireIntentActionSchema
|
|
104
|
+
])).describe("List of actions to apply")
|
|
105
|
+
});
|
|
106
|
+
const normalizeActionType = (type) => {
|
|
107
|
+
const normalized = type.toLowerCase();
|
|
108
|
+
if (normalized === "create" || normalized === "update" || normalized === "expire") {
|
|
109
|
+
return normalized;
|
|
110
|
+
}
|
|
111
|
+
logger.warn(`normalizeActionType: unexpected action type "${type}", defaulting to "create"`);
|
|
112
|
+
return "create";
|
|
113
|
+
};
|
|
114
|
+
// ──────────────────────────────────────────────────────────────
|
|
115
|
+
// 4. CLASS DEFINITION
|
|
116
|
+
// ──────────────────────────────────────────────────────────────
|
|
117
|
+
export class IntentReconciler {
|
|
118
|
+
constructor() {
|
|
119
|
+
this.model = model.withStructuredOutput(responseFormat, {
|
|
120
|
+
name: "intent_reconciler"
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Reconciles inferred intents with active intents.
|
|
125
|
+
* @param inferredIntentsFormatted - Formatted string of inferred intents.
|
|
126
|
+
* @param activeIntentsContext - Formatted string of active intents.
|
|
127
|
+
*/
|
|
128
|
+
async invoke(inferredIntentsFormatted, activeIntentsContext) {
|
|
129
|
+
logger.verbose(`[IntentReconciler.invoke] Reconciling intents...`);
|
|
130
|
+
const prompt = `
|
|
131
|
+
# Active Intents
|
|
132
|
+
${activeIntentsContext}
|
|
133
|
+
|
|
134
|
+
# Inferred Intents (Candidates)
|
|
135
|
+
${inferredIntentsFormatted}
|
|
136
|
+
|
|
137
|
+
Based on the Inferred Intents, determine the actions to modify the Active Intents state.
|
|
138
|
+
IMPORTANT:
|
|
139
|
+
- If you CREATE or UPDATE an intent, you MUST popuate the 'score' and 'reasoning' fields.
|
|
140
|
+
- Extract the 'score', 'semanticEntropy', 'referentialAnchor' from the Inferred Intent's data.
|
|
141
|
+
- Include the verification details in the 'reasoning'.
|
|
142
|
+
`;
|
|
143
|
+
const messages = [
|
|
144
|
+
new SystemMessage(systemPrompt),
|
|
145
|
+
new HumanMessage(prompt)
|
|
146
|
+
];
|
|
147
|
+
try {
|
|
148
|
+
const output = await this.model.invoke(messages);
|
|
149
|
+
const normalizedActions = output.actions.map((action) => ({
|
|
150
|
+
...action,
|
|
151
|
+
type: normalizeActionType(action.type),
|
|
152
|
+
}));
|
|
153
|
+
logger.verbose(`[IntentReconciler.invoke] Decision: ${normalizedActions.length} actions.`);
|
|
154
|
+
return { actions: normalizedActions };
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
logger.error("[IntentReconciler] Error during invocation", { error });
|
|
158
|
+
return { actions: [] };
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Factory method to expose the agent as a LangChain tool.
|
|
163
|
+
*/
|
|
164
|
+
static asTool() {
|
|
165
|
+
return tool(async (args) => {
|
|
166
|
+
const agent = new IntentReconciler();
|
|
167
|
+
return await agent.invoke(args.inferredIntents, args.activeIntents);
|
|
168
|
+
}, {
|
|
169
|
+
name: 'intent_reconciler',
|
|
170
|
+
description: 'Reconciles inferred intents with active intents to determine state changes.',
|
|
171
|
+
schema: z.object({
|
|
172
|
+
inferredIntents: z.string().describe('Formatted string of inferred intents'),
|
|
173
|
+
activeIntents: z.string().describe('Formatted string of active intents')
|
|
174
|
+
})
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
__decorate([
|
|
179
|
+
Timed(),
|
|
180
|
+
__metadata("design:type", Function),
|
|
181
|
+
__metadata("design:paramtypes", [String, String]),
|
|
182
|
+
__metadata("design:returntype", Promise)
|
|
183
|
+
], IntentReconciler.prototype, "invoke", null);
|
|
184
|
+
//# sourceMappingURL=intent.reconciler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intent.reconciler.js","sourceRoot":"","sources":["../../src/agents/intent.reconciler.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,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAAC;AAElD;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,MAAM,CAAC,EAAE,IAAI,EAAE,kBAAkB,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AAErD,MAAM,KAAK,GAAG,WAAW,CAAC,kBAAkB,CAAC,C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AAE,CAAC;YACf,MAAM,CAAC,KAAK,CAAC,4CAA4C,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACtE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;QACzB,CAAC;IACH,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,MAAM;QAClB,OAAO,IAAI,CACT,KAAK,EAAE,IAAwD,EAAE,EAAE;YACjE,MAAM,KAAK,GAAG,IAAI,gBAAgB,EAAE,CAAC;YACrC,OAAO,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC;QACtE,CAAC,EACD;YACE,IAAI,EAAE,mBAAmB;YACzB,WAAW,EAAE,6EAA6E;YAC1F,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;gBACf,eAAe,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,sCAAsC,CAAC;gBAC5E,aAAa,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,oCAAoC,CAAC;aACzE,CAAC;SACH,CACF,CAAC;IACJ,CAAC;CACF;AAxDc;IADZ,KAAK,EAAE;;;;8CAoCP"}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
declare const responseFormat: z.ZodObject<{
|
|
3
|
+
reasoning: z.ZodString;
|
|
4
|
+
classification: z.ZodEnum<["COMMISSIVE", "DIRECTIVE", "ASSERTIVE", "EXPRESSIVE", "DECLARATION", "UNKNOWN"]>;
|
|
5
|
+
felicity_scores: z.ZodObject<{
|
|
6
|
+
clarity: z.ZodNumber;
|
|
7
|
+
authority: z.ZodNumber;
|
|
8
|
+
sincerity: z.ZodNumber;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
clarity: number;
|
|
11
|
+
authority: number;
|
|
12
|
+
sincerity: number;
|
|
13
|
+
}, {
|
|
14
|
+
clarity: number;
|
|
15
|
+
authority: number;
|
|
16
|
+
sincerity: number;
|
|
17
|
+
}>;
|
|
18
|
+
semantic_entropy: z.ZodNumber;
|
|
19
|
+
referential_anchor: z.ZodNullable<z.ZodString>;
|
|
20
|
+
flags: z.ZodArray<z.ZodString, "many">;
|
|
21
|
+
}, "strip", z.ZodTypeAny, {
|
|
22
|
+
reasoning: string;
|
|
23
|
+
classification: "COMMISSIVE" | "DIRECTIVE" | "ASSERTIVE" | "EXPRESSIVE" | "DECLARATION" | "UNKNOWN";
|
|
24
|
+
felicity_scores: {
|
|
25
|
+
clarity: number;
|
|
26
|
+
authority: number;
|
|
27
|
+
sincerity: number;
|
|
28
|
+
};
|
|
29
|
+
semantic_entropy: number;
|
|
30
|
+
referential_anchor: string | null;
|
|
31
|
+
flags: string[];
|
|
32
|
+
}, {
|
|
33
|
+
reasoning: string;
|
|
34
|
+
classification: "COMMISSIVE" | "DIRECTIVE" | "ASSERTIVE" | "EXPRESSIVE" | "DECLARATION" | "UNKNOWN";
|
|
35
|
+
felicity_scores: {
|
|
36
|
+
clarity: number;
|
|
37
|
+
authority: number;
|
|
38
|
+
sincerity: number;
|
|
39
|
+
};
|
|
40
|
+
semantic_entropy: number;
|
|
41
|
+
referential_anchor: string | null;
|
|
42
|
+
flags: string[];
|
|
43
|
+
}>;
|
|
44
|
+
export type SemanticVerifierOutput = z.infer<typeof responseFormat>;
|
|
45
|
+
export declare class SemanticVerifier {
|
|
46
|
+
private model;
|
|
47
|
+
constructor();
|
|
48
|
+
/**
|
|
49
|
+
* Verifies the semantic validity of an intent.
|
|
50
|
+
* @param content - The user's raw utterance.
|
|
51
|
+
* @param context - The User Profile as a JSON string.
|
|
52
|
+
*/
|
|
53
|
+
invoke(content: string, context: string): Promise<{
|
|
54
|
+
reasoning: string;
|
|
55
|
+
classification: "COMMISSIVE" | "DIRECTIVE" | "ASSERTIVE" | "EXPRESSIVE" | "DECLARATION" | "UNKNOWN";
|
|
56
|
+
felicity_scores: {
|
|
57
|
+
clarity: number;
|
|
58
|
+
authority: number;
|
|
59
|
+
sincerity: number;
|
|
60
|
+
};
|
|
61
|
+
semantic_entropy: number;
|
|
62
|
+
referential_anchor: string | null;
|
|
63
|
+
flags: string[];
|
|
64
|
+
}>;
|
|
65
|
+
/**
|
|
66
|
+
* Factory method to expose the agent as a LangChain tool.
|
|
67
|
+
*/
|
|
68
|
+
static asTool(): import("@langchain/core/tools").DynamicStructuredTool<z.ZodObject<{
|
|
69
|
+
content: z.ZodString;
|
|
70
|
+
context: z.ZodString;
|
|
71
|
+
}, "strip", z.ZodTypeAny, {
|
|
72
|
+
context: string;
|
|
73
|
+
content: string;
|
|
74
|
+
}, {
|
|
75
|
+
context: string;
|
|
76
|
+
content: string;
|
|
77
|
+
}>, {
|
|
78
|
+
context: string;
|
|
79
|
+
content: string;
|
|
80
|
+
}, {
|
|
81
|
+
context: string;
|
|
82
|
+
content: string;
|
|
83
|
+
}, {
|
|
84
|
+
reasoning: string;
|
|
85
|
+
classification: "COMMISSIVE" | "DIRECTIVE" | "ASSERTIVE" | "EXPRESSIVE" | "DECLARATION" | "UNKNOWN";
|
|
86
|
+
felicity_scores: {
|
|
87
|
+
clarity: number;
|
|
88
|
+
authority: number;
|
|
89
|
+
sincerity: number;
|
|
90
|
+
};
|
|
91
|
+
semantic_entropy: number;
|
|
92
|
+
referential_anchor: string | null;
|
|
93
|
+
flags: string[];
|
|
94
|
+
}, unknown, "semantic_verifier">;
|
|
95
|
+
}
|
|
96
|
+
export {};
|
|
97
|
+
//# sourceMappingURL=intent.verifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intent.verifier.d.ts","sourceRoot":"","sources":["../../src/agents/intent.verifier.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA+IxB,QAAA,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAmClB,CAAC;AAMH,MAAM,MAAM,sBAAsB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAC;AAMpE,qBAAa,gBAAgB;IAC3B,OAAO,CAAC,KAAK,CAAM;;IAQnB;;;;OAIG;IAEU,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;;;;;;;;;;;;IA8BpD;;OAEG;WACW,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgBrB"}
|
|
@@ -0,0 +1,234 @@
|
|
|
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";
|
|
13
|
+
import { protocolLogger } from "../support/protocol.logger.js";
|
|
14
|
+
import { Timed } from "../support/performance.js";
|
|
15
|
+
import { createModel } from "./model.config.js";
|
|
16
|
+
const logger = protocolLogger("SemanticVerifier");
|
|
17
|
+
/**
|
|
18
|
+
* Config
|
|
19
|
+
*/
|
|
20
|
+
import { config } from "dotenv";
|
|
21
|
+
config({ path: '.env.development', override: true });
|
|
22
|
+
const model = createModel("intentVerifier");
|
|
23
|
+
// ──────────────────────────────────────────────────────────────
|
|
24
|
+
// 1. SYSTEM PROMPT
|
|
25
|
+
// ──────────────────────────────────────────────────────────────
|
|
26
|
+
const systemPrompt = `
|
|
27
|
+
You are the Semantic Verification Engine for the Index Network — an intent-driven discovery protocol.
|
|
28
|
+
|
|
29
|
+
Your job: classify a user utterance using Searle's Speech Act Theory, then score its felicity conditions.
|
|
30
|
+
|
|
31
|
+
Always reason before classifying. Output reasoning first.
|
|
32
|
+
|
|
33
|
+
═══════════════════════════════════════════════════
|
|
34
|
+
STEP 1 — CLASSIFY THE ILLOCUTIONARY ACT
|
|
35
|
+
═══════════════════════════════════════════════════
|
|
36
|
+
|
|
37
|
+
Work through this decision tree in order. Stop at the first matching branch.
|
|
38
|
+
|
|
39
|
+
IF the utterance cancels, terminates, or declares a state change (e.g., "I quit", "Project cancelled", "This position is closed"):
|
|
40
|
+
→ DECLARATION
|
|
41
|
+
|
|
42
|
+
ELSE IF the utterance expresses a search, need, or request for another party — even without an explicit verb or first-person subject:
|
|
43
|
+
→ DIRECTIVE
|
|
44
|
+
|
|
45
|
+
DIRECTIVE trigger patterns (any of these → DIRECTIVE):
|
|
46
|
+
· "Looking for [X]" · "Seeking [X]"
|
|
47
|
+
· "In search of [X]" · "Need a [X]"
|
|
48
|
+
· "Want to find [X]" · "Interested in connecting with [X]"
|
|
49
|
+
· "Open to [X]" · "Hiring [X]"
|
|
50
|
+
· "Would love to meet [X]" · "Anyone know [X]"
|
|
51
|
+
|
|
52
|
+
KEY RULE: A verbless gerundive like "Looking for artists for collaboration" IS a DIRECTIVE.
|
|
53
|
+
The missing first-person subject ("I am") is routinely elided in natural intent language.
|
|
54
|
+
The illocutionary force is a search directive aimed at the system, not an assertion about reality.
|
|
55
|
+
|
|
56
|
+
DIRECTIVE positive examples:
|
|
57
|
+
· "Looking for artists for collaboration" → DIRECTIVE (elided subject, search intent)
|
|
58
|
+
· "Seeking a technical co-founder in NYC" → DIRECTIVE
|
|
59
|
+
· "Need a PyTorch expert for a 3-month contract" → DIRECTIVE
|
|
60
|
+
· "Open to angel investment opportunities" → DIRECTIVE
|
|
61
|
+
· "Anyone building in the DeSci space?" → DIRECTIVE
|
|
62
|
+
|
|
63
|
+
DIRECTIVE negative examples (do NOT classify these as DIRECTIVE):
|
|
64
|
+
· "AI is changing the creative industry" → ASSERTIVE (states a belief, no search)
|
|
65
|
+
· "I built a collaboration platform" → ASSERTIVE/COMMISSIVE (past action, no request)
|
|
66
|
+
· "Collaboration is important" → ASSERTIVE (general belief)
|
|
67
|
+
|
|
68
|
+
ELSE IF the utterance commits the speaker to a future action:
|
|
69
|
+
→ COMMISSIVE
|
|
70
|
+
|
|
71
|
+
COMMISSIVE positive examples:
|
|
72
|
+
· "I will deploy the contract by Friday" → COMMISSIVE
|
|
73
|
+
· "I'm going to learn Rust this quarter" → COMMISSIVE
|
|
74
|
+
· "I commit to mentoring two junior devs" → COMMISSIVE
|
|
75
|
+
|
|
76
|
+
COMMISSIVE negative examples (do NOT classify these as COMMISSIVE):
|
|
77
|
+
· "I could probably look into it" → too hedged; score sincerity low instead
|
|
78
|
+
· "We should build something cool" → vague, no personal commitment
|
|
79
|
+
|
|
80
|
+
ELSE IF the utterance states a fact, belief, or opinion with no implied request or commitment:
|
|
81
|
+
→ ASSERTIVE
|
|
82
|
+
|
|
83
|
+
ASSERTIVE positive examples:
|
|
84
|
+
· "Rust is faster than C++" → ASSERTIVE
|
|
85
|
+
· "I have 10 years of experience in ML" → ASSERTIVE (profile statement, not a request)
|
|
86
|
+
· "The crypto market is volatile" → ASSERTIVE
|
|
87
|
+
|
|
88
|
+
ELSE IF the utterance expresses a psychological state or social ritual:
|
|
89
|
+
→ EXPRESSIVE
|
|
90
|
+
|
|
91
|
+
EXPRESSIVE examples: "I'm so excited!", "Hello everyone", "Congrats to the team"
|
|
92
|
+
|
|
93
|
+
If none of the above apply cleanly:
|
|
94
|
+
→ UNKNOWN
|
|
95
|
+
|
|
96
|
+
═══════════════════════════════════════════════════
|
|
97
|
+
STEP 2 — SCORE THE FELICITY CONDITIONS (0–100)
|
|
98
|
+
═══════════════════════════════════════════════════
|
|
99
|
+
|
|
100
|
+
Score AFTER classification. Do not let scores influence the category decision.
|
|
101
|
+
|
|
102
|
+
CLARITY (Essential Condition)
|
|
103
|
+
How unambiguous and actionable is the utterance?
|
|
104
|
+
100 → "Deploy the Solidity contract to Mainnet by March 15"
|
|
105
|
+
60 → "Looking for a developer" (clear direction, vague spec)
|
|
106
|
+
20 → "We should do something cool"
|
|
107
|
+
|
|
108
|
+
AUTHORITY (Preparatory Condition)
|
|
109
|
+
Does the speaker's profile support this act?
|
|
110
|
+
Compare stated skills/role against the action or search domain.
|
|
111
|
+
100 → Profile: Senior ML Engineer | Utterance: "Seeking a research collaborator on transformers"
|
|
112
|
+
20 → Profile: Junior Marketer | Utterance: "I will rewrite the Rust compiler"
|
|
113
|
+
For DIRECTIVEs: authority = plausibility that this person would make this search.
|
|
114
|
+
|
|
115
|
+
SINCERITY (Sincerity Condition)
|
|
116
|
+
Does the linguistic form imply genuine commitment or genuine need?
|
|
117
|
+
For COMMISSIVEs: check modality (will > going to > might > could).
|
|
118
|
+
For DIRECTIVEs: check specificity of the search (specific need > vague wish).
|
|
119
|
+
100 → "I need a Rails contractor starting next week, $150/hr, remote"
|
|
120
|
+
40 → "I could maybe try to find someone"
|
|
121
|
+
|
|
122
|
+
SEMANTIC ENTROPY (Constraint Density) → semantic_entropy field, range 0.0–1.0
|
|
123
|
+
0.0 = maximally constrained (time, location, tech stack, quantifiers all present)
|
|
124
|
+
1.0 = no constraints at all
|
|
125
|
+
0.0 example: "Meet 50 senior React devs in SF by Friday"
|
|
126
|
+
1.0 example: "Network"
|
|
127
|
+
|
|
128
|
+
REFERENTIAL ANCHOR → referential_anchor field
|
|
129
|
+
Does the utterance name a specific unique entity (Donnellan referential use)?
|
|
130
|
+
If YES → output the entity name string.
|
|
131
|
+
If NO (attributive reference to any member of a class) → output null.
|
|
132
|
+
"I want to join Google" → "Google"
|
|
133
|
+
"I want to join a startup" → null
|
|
134
|
+
|
|
135
|
+
═══════════════════════════════════════════════════
|
|
136
|
+
STEP 3 — FLAGS
|
|
137
|
+
═══════════════════════════════════════════════════
|
|
138
|
+
|
|
139
|
+
Add flags when scores fall below threshold:
|
|
140
|
+
authority < 70 → "SKILL_MISMATCH"
|
|
141
|
+
sincerity < 70 → "WEAK_COMMITMENT"
|
|
142
|
+
clarity < 50 → "VAGUE_INTENT"
|
|
143
|
+
classification is ASSERTIVE or EXPRESSIVE → "NOISE"
|
|
144
|
+
`;
|
|
145
|
+
// ──────────────────────────────────────────────────────────────
|
|
146
|
+
// 2. RESPONSE SCHEMA (Zod)
|
|
147
|
+
// ──────────────────────────────────────────────────────────────
|
|
148
|
+
const responseFormat = z.object({
|
|
149
|
+
// reasoning comes first so the model commits to its analysis
|
|
150
|
+
// before the classification token is generated (chain-of-thought anchor)
|
|
151
|
+
reasoning: z.string().describe("Step-by-step analysis: (1) which decision-tree branch fired and why, " +
|
|
152
|
+
"(2) key surface features of the utterance (trigger keywords, elided subject, modality), " +
|
|
153
|
+
"(3) felicity condition assessment."),
|
|
154
|
+
classification: z.enum([
|
|
155
|
+
"COMMISSIVE",
|
|
156
|
+
"DIRECTIVE",
|
|
157
|
+
"ASSERTIVE",
|
|
158
|
+
"EXPRESSIVE",
|
|
159
|
+
"DECLARATION",
|
|
160
|
+
"UNKNOWN"
|
|
161
|
+
]).describe("Searle's Speech Act category — determined by the decision tree in STEP 1"),
|
|
162
|
+
felicity_scores: z.object({
|
|
163
|
+
clarity: z.number().min(0).max(100).describe("Essential Condition: how unambiguous and actionable is the utterance (0–100)"),
|
|
164
|
+
authority: z.number().min(0).max(100).describe("Preparatory Condition: does the speaker's profile support this act (0–100)"),
|
|
165
|
+
sincerity: z.number().min(0).max(100).describe("Sincerity Condition: does the linguistic form imply genuine commitment or need (0–100)"),
|
|
166
|
+
}),
|
|
167
|
+
semantic_entropy: z.number().min(0).max(1).describe("Constraint density: 0.0 = maximally specific (time + location + tech + quantifiers), 1.0 = completely unconstrained"),
|
|
168
|
+
referential_anchor: z.string().nullable().describe("Named specific entity the utterance refers to (Donnellan referential), or null for attributive reference"),
|
|
169
|
+
flags: z.array(z.string()).describe("Semantic violation tags: SKILL_MISMATCH (authority<70), WEAK_COMMITMENT (sincerity<70), VAGUE_INTENT (clarity<50), NOISE (ASSERTIVE or EXPRESSIVE)"),
|
|
170
|
+
});
|
|
171
|
+
// ──────────────────────────────────────────────────────────────
|
|
172
|
+
// 4. CLASS DEFINITION
|
|
173
|
+
// ──────────────────────────────────────────────────────────────
|
|
174
|
+
export class SemanticVerifier {
|
|
175
|
+
constructor() {
|
|
176
|
+
this.model = model.withStructuredOutput(responseFormat, {
|
|
177
|
+
name: "semantic_verifier"
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Verifies the semantic validity of an intent.
|
|
182
|
+
* @param content - The user's raw utterance.
|
|
183
|
+
* @param context - The User Profile as a JSON string.
|
|
184
|
+
*/
|
|
185
|
+
async invoke(content, context) {
|
|
186
|
+
logger.verbose(`[SemanticVerifier.invoke] Verifying: "${content.substring(0, 30)}..."`);
|
|
187
|
+
const prompt = `
|
|
188
|
+
# User Profile (Context)
|
|
189
|
+
${context}
|
|
190
|
+
|
|
191
|
+
# User Utterance (Content)
|
|
192
|
+
"${content}"
|
|
193
|
+
|
|
194
|
+
Verify the Felicity Conditions and Semantic Metrics for this utterance.
|
|
195
|
+
`;
|
|
196
|
+
const messages = [
|
|
197
|
+
new SystemMessage(systemPrompt),
|
|
198
|
+
new HumanMessage(prompt)
|
|
199
|
+
];
|
|
200
|
+
try {
|
|
201
|
+
const result = await this.model.invoke(messages);
|
|
202
|
+
const output = responseFormat.parse(result);
|
|
203
|
+
logger.verbose(`[SemanticVerifier.invoke] Verdict: ${output.classification} Entropy: ${output.semantic_entropy}`);
|
|
204
|
+
return output;
|
|
205
|
+
}
|
|
206
|
+
catch (error) {
|
|
207
|
+
logger.error("[SemanticVerifier] Error during invocation", { error });
|
|
208
|
+
throw error;
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Factory method to expose the agent as a LangChain tool.
|
|
213
|
+
*/
|
|
214
|
+
static asTool() {
|
|
215
|
+
return tool(async (args) => {
|
|
216
|
+
const agent = new SemanticVerifier();
|
|
217
|
+
return await agent.invoke(args.content, args.context);
|
|
218
|
+
}, {
|
|
219
|
+
name: 'semantic_verifier',
|
|
220
|
+
description: 'Verifies the semantic validity and felicity conditions of an intent.',
|
|
221
|
+
schema: z.object({
|
|
222
|
+
content: z.string().describe('The intent content to verify'),
|
|
223
|
+
context: z.string().describe('The user profile context')
|
|
224
|
+
})
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
__decorate([
|
|
229
|
+
Timed(),
|
|
230
|
+
__metadata("design:type", Function),
|
|
231
|
+
__metadata("design:paramtypes", [String, String]),
|
|
232
|
+
__metadata("design:returntype", Promise)
|
|
233
|
+
], SemanticVerifier.prototype, "invoke", null);
|
|
234
|
+
//# sourceMappingURL=intent.verifier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intent.verifier.js","sourceRoot":"","sources":["../../src/agents/intent.verifier.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,KAAK,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,MAAM,GAAG,cAAc,CAAC,kBAAkB,CAAC,CAAC;AAElD;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,MAAM,CAAC,EAAE,IAAI,EAAE,kB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A4C,EAAE,EAAE,KAAK,EAAE,CAAC,CAAC;YACtE,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,MAAM;QAClB,OAAO,IAAI,CACT,KAAK,EAAE,IAA0C,EAAE,EAAE;YACnD,MAAM,KAAK,GAAG,IAAI,gBAAgB,EAAE,CAAC;YACrC,OAAO,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;QACxD,CAAC,EACD;YACE,IAAI,EAAE,mBAAmB;YACzB,WAAW,EAAE,sEAAsE;YACnF,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC;gBACf,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,8BAA8B,CAAC;gBAC5D,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,0BAA0B,CAAC;aACzD,CAAC;SACH,CACF,CAAC;IACJ,CAAC;CACF;AAjDc;IADZ,KAAK,EAAE;;;;8CA6BP"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Invite Generator Agent
|
|
3
|
+
*
|
|
4
|
+
* Generates contextual, editable invite messages for ghost users.
|
|
5
|
+
* Produces warm, concise messages (~3-5 sentences) referencing why two
|
|
6
|
+
* users were matched, with optional referrer mention.
|
|
7
|
+
*/
|
|
8
|
+
import { z } from "zod";
|
|
9
|
+
declare const InviteInputSchema: z.ZodObject<{
|
|
10
|
+
recipientName: z.ZodString;
|
|
11
|
+
senderName: z.ZodString;
|
|
12
|
+
opportunityInterpretation: z.ZodString;
|
|
13
|
+
senderIntents: z.ZodArray<z.ZodString, "many">;
|
|
14
|
+
recipientIntents: z.ZodArray<z.ZodString, "many">;
|
|
15
|
+
referrerName: z.ZodOptional<z.ZodString>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
recipientName: string;
|
|
18
|
+
senderName: string;
|
|
19
|
+
opportunityInterpretation: string;
|
|
20
|
+
senderIntents: string[];
|
|
21
|
+
recipientIntents: string[];
|
|
22
|
+
referrerName?: string | undefined;
|
|
23
|
+
}, {
|
|
24
|
+
recipientName: string;
|
|
25
|
+
senderName: string;
|
|
26
|
+
opportunityInterpretation: string;
|
|
27
|
+
senderIntents: string[];
|
|
28
|
+
recipientIntents: string[];
|
|
29
|
+
referrerName?: string | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
declare const InviteOutputSchema: z.ZodObject<{
|
|
32
|
+
message: z.ZodString;
|
|
33
|
+
}, "strip", z.ZodTypeAny, {
|
|
34
|
+
message: string;
|
|
35
|
+
}, {
|
|
36
|
+
message: string;
|
|
37
|
+
}>;
|
|
38
|
+
export type InviteInput = z.infer<typeof InviteInputSchema>;
|
|
39
|
+
export type InviteOutput = z.infer<typeof InviteOutputSchema>;
|
|
40
|
+
/**
|
|
41
|
+
* Generates a contextual invite message for a ghost user.
|
|
42
|
+
* @param input - Context about sender, recipient, and opportunity
|
|
43
|
+
* @returns Generated invite message text
|
|
44
|
+
*/
|
|
45
|
+
export declare function generateInviteMessage(input: InviteInput): Promise<InviteOutput>;
|
|
46
|
+
export {};
|
|
47
|
+
//# sourceMappingURL=invite.generator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invite.generator.d.ts","sourceRoot":"","sources":["../../src/agents/invite.generator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;EAOrB,CAAC;AAEH,QAAA,MAAM,kBAAkB;;;;;;EAEtB,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAgB9D;;;;GAIG;AACH,wBAAsB,qBAAqB,CAAC,KAAK,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAkBrF"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Invite Generator Agent
|
|
3
|
+
*
|
|
4
|
+
* Generates contextual, editable invite messages for ghost users.
|
|
5
|
+
* Produces warm, concise messages (~3-5 sentences) referencing why two
|
|
6
|
+
* users were matched, with optional referrer mention.
|
|
7
|
+
*/
|
|
8
|
+
import { HumanMessage, SystemMessage } from "@langchain/core/messages";
|
|
9
|
+
import { z } from "zod";
|
|
10
|
+
import { createModel } from "./model.config.js";
|
|
11
|
+
const model = createModel("inviteGenerator");
|
|
12
|
+
const InviteInputSchema = z.object({
|
|
13
|
+
recipientName: z.string(),
|
|
14
|
+
senderName: z.string(),
|
|
15
|
+
opportunityInterpretation: z.string(),
|
|
16
|
+
senderIntents: z.array(z.string()),
|
|
17
|
+
recipientIntents: z.array(z.string()),
|
|
18
|
+
referrerName: z.string().optional(),
|
|
19
|
+
});
|
|
20
|
+
const InviteOutputSchema = z.object({
|
|
21
|
+
message: z.string().describe("The invite message text, ready to edit and send"),
|
|
22
|
+
});
|
|
23
|
+
const SYSTEM_PROMPT = `You generate brief, casual invite messages for a discovery platform called Index.
|
|
24
|
+
|
|
25
|
+
The sender wants to reach out to someone they were matched with. Write a short, human message (2-3 sentences max) that:
|
|
26
|
+
- Sounds like a real person texting, not a LinkedIn outreach or AI email
|
|
27
|
+
- References one concrete, specific detail from the opportunity context — something actual, like a specific project, technology, or goal they share. Not "we have similar interests" or "I noticed we're both in this space" — name the actual thing.
|
|
28
|
+
- If a referrer is provided, casually drops that they were introduced
|
|
29
|
+
- Ends naturally — no formal CTAs, no "Would you be open to..." closings
|
|
30
|
+
|
|
31
|
+
Tone: casual, direct, human. Think how you'd actually message someone you just got introduced to.
|
|
32
|
+
Do NOT use a generic opener like "Hi [Name], I'm [Sender]." Just get to the point.
|
|
33
|
+
Do NOT summarize the person's background. Pick one real, specific overlap from the context and mention it.
|
|
34
|
+
Do NOT include a subject line. This is a chat message.
|
|
35
|
+
Do NOT use placeholder brackets like [Name]. Use the actual names provided.`;
|
|
36
|
+
/**
|
|
37
|
+
* Generates a contextual invite message for a ghost user.
|
|
38
|
+
* @param input - Context about sender, recipient, and opportunity
|
|
39
|
+
* @returns Generated invite message text
|
|
40
|
+
*/
|
|
41
|
+
export async function generateInviteMessage(input) {
|
|
42
|
+
const validated = InviteInputSchema.parse(input);
|
|
43
|
+
const structuredModel = model.withStructuredOutput(InviteOutputSchema);
|
|
44
|
+
const userPrompt = `Generate an invite message with this context:
|
|
45
|
+
- Sender: ${validated.senderName}
|
|
46
|
+
- Recipient: ${validated.recipientName}
|
|
47
|
+
- Why they matched: ${validated.opportunityInterpretation}
|
|
48
|
+
- Sender's interests: ${validated.senderIntents.join(', ') || 'Not specified'}
|
|
49
|
+
- Recipient's interests: ${validated.recipientIntents.join(', ') || 'Not specified'}${validated.referrerName ? `\n- Referred by: ${validated.referrerName}` : ''}`;
|
|
50
|
+
const result = await structuredModel.invoke([
|
|
51
|
+
new SystemMessage(SYSTEM_PROMPT),
|
|
52
|
+
new HumanMessage(userPrompt),
|
|
53
|
+
]);
|
|
54
|
+
return result;
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=invite.generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"invite.generator.js","sourceRoot":"","sources":["../../src/agents/invite.generator.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACvE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAEhD,MAAM,KAAK,GAAG,WAAW,CAAC,iBAAiB,CAAC,CAAC;AAE7C,MAAM,iBAAiB,GAAG,CAA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