@indexnetwork/protocol 17.0.1-rc.480.1 → 18.0.0-rc.481.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/IMPLEMENTATION.md +46 -3
- package/STABILITY.md +5 -1
- package/dist/index.d.ts +2 -9
- package/dist/index.js +4 -6
- package/dist/intents/{application → graph}/intent.graph.d.ts +26 -26
- package/dist/intents/{application → graph}/intent.graph.execute.d.ts +1 -1
- package/dist/intents/{application → graph}/intent.graph.execute.js +1 -1
- package/dist/intents/{application → graph}/intent.graph.js +4 -4
- package/dist/intents/{application → graph}/intent.graph.reconcile.d.ts +2 -2
- package/dist/intents/{application → graph}/intent.graph.shared.d.ts +5 -5
- package/dist/intents/{application → graph}/intent.graph.shared.js +1 -1
- package/dist/intents/{domain/intent.state.d.ts → graph/intent.graph.state.d.ts} +3 -3
- package/dist/intents/{application/intent.clarifier.js → intent.clarifier.js} +5 -5
- package/dist/intents/{application/intent.indexer.js → intent.indexer.js} +4 -4
- package/dist/intents/{application/intent.inferrer.js → intent.inferrer.js} +4 -4
- package/dist/intents/intent.module.d.ts +633 -0
- package/dist/intents/intent.module.js +103 -0
- package/dist/intents/{domain/intent.proposal.d.ts → intent.proposal.d.ts} +2 -0
- package/dist/intents/{domain/intent.proposal.js → intent.proposal.js} +2 -0
- package/dist/intents/{application/intent.reconciler.js → intent.reconciler.js} +4 -4
- package/dist/intents/{application/intent.tools.d.ts → intent.tools.d.ts} +6 -3
- package/dist/intents/{application/intent.tools.js → intent.tools.js} +6 -7
- package/dist/intents/{application/intent.verifier.js → intent.verifier.js} +4 -4
- package/dist/networks/application/indexer.graph.d.ts +7 -7
- package/dist/networks/application/indexer.graph.js +2 -2
- package/dist/networks/ports/index.d.ts +4 -2
- package/dist/networks/ports/index.js +1 -5
- package/dist/opportunities/application/opportunity.graph.prep.js +3 -3
- package/dist/shared/agent/tool.factory.js +10 -6
- package/dist/shared/agent/tool.helpers.d.ts +2 -2
- package/dist/shared/agent/tool.registry.js +2 -2
- package/package.json +1 -1
- package/dist/intents/application/index.d.ts +0 -21
- package/dist/intents/application/index.js +0 -26
- package/dist/intents/domain/index.d.ts +0 -9
- package/dist/intents/domain/index.js +0 -11
- package/dist/intents/domain/signal.specificity.d.ts +0 -2
- package/dist/intents/domain/signal.specificity.js +0 -2
- package/dist/intents/index.d.ts +0 -18
- package/dist/intents/index.js +0 -14
- package/dist/intents/ports/index.d.ts +0 -15
- package/dist/intents/ports/index.js +0 -13
- package/dist/intents/ports/signals.tools.port.d.ts +0 -5
- package/dist/intents/ports/signals.tools.port.js +0 -1
- /package/dist/intents/{application → graph}/intent.graph.infer.d.ts +0 -0
- /package/dist/intents/{application → graph}/intent.graph.infer.js +0 -0
- /package/dist/intents/{application → graph}/intent.graph.reconcile.js +0 -0
- /package/dist/intents/{domain/intent.state.js → graph/intent.graph.state.js} +0 -0
- /package/dist/intents/{application → intake}/intake.orchestrator.d.ts +0 -0
- /package/dist/intents/{application → intake}/intake.orchestrator.js +0 -0
- /package/dist/intents/{application → intake}/intake.pack.generator.d.ts +0 -0
- /package/dist/intents/{application → intake}/intake.pack.generator.js +0 -0
- /package/dist/intents/{application/intent.clarifier.d.ts → intent.clarifier.d.ts} +0 -0
- /package/dist/intents/{application/intent.indexer.d.ts → intent.indexer.d.ts} +0 -0
- /package/dist/intents/{application/intent.inferrer.d.ts → intent.inferrer.d.ts} +0 -0
- /package/dist/intents/{application/intent.reconciler.d.ts → intent.reconciler.d.ts} +0 -0
- /package/dist/intents/{application/intent.verifier.d.ts → intent.verifier.d.ts} +0 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* intents — the capability's single public surface.
|
|
3
|
+
*
|
|
4
|
+
* Everything the rest of the package (and every host) may reach lives on the
|
|
5
|
+
* {@link Intents} class. The directories beside this file are private
|
|
6
|
+
* implementation, grouped by what they do rather than by layer:
|
|
7
|
+
*
|
|
8
|
+
* graph/ the lifecycle graph — prep, infer, verify, reconcile, execute
|
|
9
|
+
* intake/ the guided first-signal interview
|
|
10
|
+
* intent.inferrer an utterance into candidate signals
|
|
11
|
+
* intent.reconciler candidate signals into create/update/expire actions
|
|
12
|
+
* intent.verifier felicity and entropy verdicts
|
|
13
|
+
* intent.clarifier the clarification path when a signal is underspecified
|
|
14
|
+
* intent.indexer scoring one signal against one network
|
|
15
|
+
* intent.proposal the persisted proposal record and description normalization
|
|
16
|
+
* intent.tools the agent-facing tool definitions
|
|
17
|
+
*
|
|
18
|
+
* Only the two multi-file stages keep a directory. Nothing outside `intents/`
|
|
19
|
+
* imports any of it; the layout may change freely as long as this class keeps
|
|
20
|
+
* its shape.
|
|
21
|
+
*/
|
|
22
|
+
import { IntentGraphFactory } from "./graph/intent.graph.js";
|
|
23
|
+
import { IntentIndexer } from "./intent.indexer.js";
|
|
24
|
+
import { FALLBACK_WHO_QUESTION, SignalIntakeOrchestrator } from "./intake/intake.orchestrator.js";
|
|
25
|
+
import { SignalIntakePackGenerator } from "./intake/intake.pack.generator.js";
|
|
26
|
+
import { normalizeIntentDescription } from "./intent.proposal.js";
|
|
27
|
+
import { createIntentTools } from "./intent.tools.js";
|
|
28
|
+
import { SemanticVerifier } from "./intent.verifier.js";
|
|
29
|
+
/**
|
|
30
|
+
* The intents capability.
|
|
31
|
+
*
|
|
32
|
+
* One instance is cheap: the model-backed collaborators behind each method are
|
|
33
|
+
* constructed on first use and then reused, so a host can hold a single
|
|
34
|
+
* `Intents` and call only the parts it needs without paying for the rest.
|
|
35
|
+
*/
|
|
36
|
+
export class Intents {
|
|
37
|
+
constructor(deps = {}) {
|
|
38
|
+
this.deps = deps;
|
|
39
|
+
}
|
|
40
|
+
// ── Lifecycle graph ─────────────────────────────────────────────────────────
|
|
41
|
+
/**
|
|
42
|
+
* Build the intent lifecycle graph — load, infer, verify, reconcile, execute.
|
|
43
|
+
*
|
|
44
|
+
* @throws If the instance was constructed without a `database`.
|
|
45
|
+
*/
|
|
46
|
+
createGraph() {
|
|
47
|
+
const { database, embedder, queue, questionerEnqueue, agents } = this.deps;
|
|
48
|
+
if (!database) {
|
|
49
|
+
throw new Error("Intents.createGraph() requires a `database` dependency.");
|
|
50
|
+
}
|
|
51
|
+
return new IntentGraphFactory(database, embedder, queue, questionerEnqueue, agents).createGraph();
|
|
52
|
+
}
|
|
53
|
+
// ── Verification ────────────────────────────────────────────────────────────
|
|
54
|
+
/**
|
|
55
|
+
* Verify one utterance against the speaker's profile — felicity conditions,
|
|
56
|
+
* speech-act classification, semantic entropy, and specificity.
|
|
57
|
+
*
|
|
58
|
+
* @param content - The raw utterance.
|
|
59
|
+
* @param profileContext - The speaker's profile, serialized as JSON.
|
|
60
|
+
*/
|
|
61
|
+
async verifyIntent(content, profileContext) {
|
|
62
|
+
this.verifier ?? (this.verifier = new SemanticVerifier());
|
|
63
|
+
return this.verifier.invoke(content, profileContext);
|
|
64
|
+
}
|
|
65
|
+
// ── Indexing ────────────────────────────────────────────────────────────────
|
|
66
|
+
/**
|
|
67
|
+
* Score how well one signal fits one network, from the network's purpose and
|
|
68
|
+
* the member's sharing preferences.
|
|
69
|
+
*
|
|
70
|
+
* @returns Scores and reasoning, or `null` when the model call fails.
|
|
71
|
+
*/
|
|
72
|
+
async indexIntent(intent, indexPrompt, memberPrompt, sourceName, networkContext) {
|
|
73
|
+
this.indexer ?? (this.indexer = new IntentIndexer());
|
|
74
|
+
return this.indexer.invoke(intent, indexPrompt, memberPrompt, sourceName, networkContext);
|
|
75
|
+
}
|
|
76
|
+
// ── Guided intake ───────────────────────────────────────────────────────────
|
|
77
|
+
/** Generate a participant's intake brief and round-1 question. */
|
|
78
|
+
async generateIntakePack(input) {
|
|
79
|
+
this.packGenerator ?? (this.packGenerator = new SignalIntakePackGenerator());
|
|
80
|
+
return this.packGenerator.generate(input);
|
|
81
|
+
}
|
|
82
|
+
/** Plan and write the next intake follow-up questions. */
|
|
83
|
+
async generateIntakeFollowUps(input) {
|
|
84
|
+
this.orchestrator ?? (this.orchestrator = new SignalIntakeOrchestrator());
|
|
85
|
+
return this.orchestrator.generateFollowUps(input);
|
|
86
|
+
}
|
|
87
|
+
/** Turn answered intake rounds into a signal description and card summary. */
|
|
88
|
+
async synthesizeIntake(input) {
|
|
89
|
+
this.orchestrator ?? (this.orchestrator = new SignalIntakeOrchestrator());
|
|
90
|
+
return this.orchestrator.synthesize(input);
|
|
91
|
+
}
|
|
92
|
+
/** Normalize a signal description to its persisted form. */
|
|
93
|
+
static normalizeDescription(description) {
|
|
94
|
+
return normalizeIntentDescription(description);
|
|
95
|
+
}
|
|
96
|
+
/** Register the agent-facing intent tools against a tool definer. */
|
|
97
|
+
static createTools(defineTool, deps) {
|
|
98
|
+
return createIntentTools(defineTool, deps);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
// ── Stateless surface ───────────────────────────────────────────────────────
|
|
102
|
+
/** The static round-1 question used when pack generation is unavailable. */
|
|
103
|
+
Intents.FALLBACK_INTAKE_QUESTION = FALLBACK_WHO_QUESTION;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** Default user-facing warning for broad attributive intent proposals. */
|
|
2
|
+
export declare const DEFAULT_SPECIFICITY_WARNING = "This signal is broad and may produce many weak matches. Add a more concrete role, outcome, location, timeframe, domain, or specific need to get better recommendations.";
|
|
1
3
|
/** Verifier output retained verbatim across the host persistence boundary. */
|
|
2
4
|
export interface IntentProposalVerifierOutput {
|
|
3
5
|
reasoning: string;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** Default user-facing warning for broad attributive intent proposals. */
|
|
2
|
+
export const DEFAULT_SPECIFICITY_WARNING = "This signal is broad and may produce many weak matches. Add a more concrete role, outcome, location, timeframe, domain, or specific need to get better recommendations.";
|
|
1
3
|
/** Normalize intent text exactly as the direct graph write path does. */
|
|
2
4
|
export function normalizeIntentDescription(description) {
|
|
3
5
|
if (!description || typeof description !== "string")
|
|
@@ -10,10 +10,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
import { HumanMessage, SystemMessage } from "@langchain/core/messages";
|
|
11
11
|
import { tool } from "@langchain/core/tools";
|
|
12
12
|
import { z } from "zod";
|
|
13
|
-
import { protocolLogger } from "
|
|
14
|
-
import { Timed } from "
|
|
15
|
-
import { createStructuredModel } from "
|
|
16
|
-
import { invokeWithAbortSignal } from "
|
|
13
|
+
import { protocolLogger } from "../shared/observability/protocol.logger.js";
|
|
14
|
+
import { Timed } from "../shared/observability/performance.js";
|
|
15
|
+
import { createStructuredModel } from "../shared/agent/model.config.js";
|
|
16
|
+
import { invokeWithAbortSignal } from "../shared/agent/model-signal.js";
|
|
17
17
|
const logger = protocolLogger("IntentReconciler");
|
|
18
18
|
const invokeLog = protocolLogger("IntentReconciler:invoke");
|
|
19
19
|
const CreateActionTypeSchema = z.union([z.literal("create"), z.literal("CREATE")]);
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import { IntentClarifier } from "./intent.clarifier.js";
|
|
2
|
-
import type { ExecutionResult, IntentValidationFailure } from "
|
|
3
|
-
import type { DefineTool } from "
|
|
4
|
-
|
|
2
|
+
import type { ExecutionResult, IntentValidationFailure } from "./graph/intent.graph.state.js";
|
|
3
|
+
import type { DefineTool, ToolRegistryCompositionDeps } from "../shared/agent/tool.helpers.js";
|
|
4
|
+
/** Host capabilities consumed by signal and intent tools. */
|
|
5
|
+
export type IntentToolDeps = Pick<ToolRegistryCompositionDeps, "userDb" | "systemDb"> & Pick<ToolRegistryCompositionDeps, "intentProposalStore"> & {
|
|
6
|
+
graphs: Pick<ToolRegistryCompositionDeps["graphs"], "intent" | "intentIndex" | "profile">;
|
|
7
|
+
};
|
|
5
8
|
type IntentClarifierLike = Pick<IntentClarifier, "invoke">;
|
|
6
9
|
/** Replace the lazy clarifier in deterministic tool tests. */
|
|
7
10
|
export declare function setIntentClarifierForTesting(clarifier: IntentClarifierLike | null): void;
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { IntentClarifier } from "./intent.clarifier.js";
|
|
3
|
-
import { DEFAULT_SPECIFICITY_WARNING } from "
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { deriveAllowedNetworkIds, focusedIntentId, focusedNetworkId, focusedNetworkLabel } from "../../shared/agent/tool.scope.js";
|
|
3
|
+
import { DEFAULT_SPECIFICITY_WARNING, normalizeIntentDescription } from "./intent.proposal.js";
|
|
4
|
+
import { protocolLogger } from "../shared/observability/protocol.logger.js";
|
|
5
|
+
import { traceGraph } from "../shared/observability/trace.js";
|
|
6
|
+
import { success, error, UUID_REGEX } from "../shared/agent/tool.helpers.js";
|
|
7
|
+
import { invokeWithAbortSignal } from "../shared/agent/model-signal.js";
|
|
8
|
+
import { deriveAllowedNetworkIds, focusedIntentId, focusedNetworkId, focusedNetworkLabel } from "../shared/agent/tool.scope.js";
|
|
10
9
|
const logger = protocolLogger("ChatTools:Intent");
|
|
11
10
|
let intentClarifier;
|
|
12
11
|
function getIntentClarifier() {
|
|
@@ -10,10 +10,10 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
import { HumanMessage, SystemMessage } from "@langchain/core/messages";
|
|
11
11
|
import { tool } from "@langchain/core/tools";
|
|
12
12
|
import { z } from "zod";
|
|
13
|
-
import { protocolLogger } from "
|
|
14
|
-
import { Timed } from "
|
|
15
|
-
import { createStructuredModel } from "
|
|
16
|
-
import { invokeWithAbortSignal } from "
|
|
13
|
+
import { protocolLogger } from "../shared/observability/protocol.logger.js";
|
|
14
|
+
import { Timed } from "../shared/observability/performance.js";
|
|
15
|
+
import { createStructuredModel } from "../shared/agent/model.config.js";
|
|
16
|
+
import { invokeWithAbortSignal } from "../shared/agent/model-signal.js";
|
|
17
17
|
const logger = protocolLogger("SemanticVerifier");
|
|
18
18
|
const invokeLog = protocolLogger("SemanticVerifier:invoke");
|
|
19
19
|
const referentialBreadthSchema = z.enum(["narrow", "moderate", "broad"]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IntentNetworkGraphDatabase } from "../ports/index.js";
|
|
2
2
|
import type { DebugMetaAgent } from "../../agents/index.js";
|
|
3
|
-
import type {
|
|
3
|
+
import type { IntentNetworkIndexer } from "../ports/index.js";
|
|
4
4
|
import { IntentNetworkGraphState, type AssignmentResult } from "./indexer.state.js";
|
|
5
5
|
/**
|
|
6
6
|
* Factory class to build and compile the Intent–Network (indexer) Graph.
|
|
@@ -12,9 +12,9 @@ import { IntentNetworkGraphState, type AssignmentResult } from "./indexer.state.
|
|
|
12
12
|
*
|
|
13
13
|
* ## Signal assignment policy
|
|
14
14
|
*
|
|
15
|
-
* The
|
|
16
|
-
*
|
|
17
|
-
*
|
|
15
|
+
* The indexer is injected at construction time via the communities ports layer,
|
|
16
|
+
* which narrows the intents module to the one method used here — this factory
|
|
17
|
+
* never reaches intents internals directly.
|
|
18
18
|
*
|
|
19
19
|
* Two assignment paths:
|
|
20
20
|
* 1. Direct (`skipEvaluation: true`):
|
|
@@ -23,7 +23,7 @@ import { IntentNetworkGraphState, type AssignmentResult } from "./indexer.state.
|
|
|
23
23
|
* - Loads intent + network context (indexPrompt, memberPrompt).
|
|
24
24
|
* - No-prompt fast path: if both prompts are absent, assigns with
|
|
25
25
|
* `mode: automatic, promptPresence: 'none'` without calling the LLM.
|
|
26
|
-
* - Otherwise invokes
|
|
26
|
+
* - Otherwise invokes the intents indexer to get indexScore + memberScore + reasoning.
|
|
27
27
|
* - Applies `buildNetworkAssignmentDecision` to produce the threshold/metadata.
|
|
28
28
|
* - Only writes the link when the decision's `assigned` flag is true.
|
|
29
29
|
*
|
|
@@ -49,12 +49,12 @@ export type IntentNetworkState = typeof IntentNetworkGraphState.State;
|
|
|
49
49
|
/** Everything the intent-network nodes reach for. */
|
|
50
50
|
export interface IntentNetworkGraphDeps {
|
|
51
51
|
database: IntentNetworkGraphDatabase;
|
|
52
|
-
intentNetworker:
|
|
52
|
+
intentNetworker: IntentNetworkIndexer;
|
|
53
53
|
}
|
|
54
54
|
export declare class IntentNetworkGraphFactory {
|
|
55
55
|
/** Resolved dependency bag shared by every node. */
|
|
56
56
|
readonly deps: IntentNetworkGraphDeps;
|
|
57
|
-
constructor(database: IntentNetworkGraphDatabase, intentNetworker:
|
|
57
|
+
constructor(database: IntentNetworkGraphDatabase, intentNetworker: IntentNetworkIndexer);
|
|
58
58
|
createGraph(): import("@langchain/langgraph").CompiledStateGraph<{
|
|
59
59
|
userId: string;
|
|
60
60
|
networkId: string | undefined;
|
|
@@ -141,13 +141,13 @@ export async function assignNode(state, deps) {
|
|
|
141
141
|
const sourceName = intentForIndexing.sourceType
|
|
142
142
|
? `${intentForIndexing.sourceType}:${intentForIndexing.sourceId ?? ""}`
|
|
143
143
|
: undefined;
|
|
144
|
-
//
|
|
144
|
+
// Score the signal against the network (intents module, injected via ports)
|
|
145
145
|
const _traceEmitter = requestContext.getStore()?.traceEmitter;
|
|
146
146
|
const _indexerStart = Date.now();
|
|
147
147
|
_traceEmitter?.({ type: "agent_start", name: "intent-networker" });
|
|
148
148
|
let result = null;
|
|
149
149
|
try {
|
|
150
|
-
result = await deps.intentNetworker.
|
|
150
|
+
result = await deps.intentNetworker.indexIntent(intentForIndexing.payload, indexPrompt, memberPrompt, sourceName, renderedContext);
|
|
151
151
|
}
|
|
152
152
|
finally {
|
|
153
153
|
const _indexerMs = Date.now() - _indexerStart;
|
|
@@ -21,5 +21,7 @@
|
|
|
21
21
|
* IND-546: explicit port layer for communities; signals consumed via capabilities/signals.facade.ts.
|
|
22
22
|
*/
|
|
23
23
|
export type { NetworkGraphDatabase, NetworkMembershipGraphDatabase, IntentNetworkGraphDatabase, } from "../../shared/interfaces/database.interface.js";
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
import type { Intents } from "../../intents/intent.module.js";
|
|
25
|
+
/** The one intents method communities calls: score a signal against a network. */
|
|
26
|
+
export type IntentNetworkIndexer = Pick<Intents, "indexIntent">;
|
|
27
|
+
export type { IntentIndexerOutput } from "../../intents/intent.module.js";
|
|
@@ -20,8 +20,4 @@
|
|
|
20
20
|
*
|
|
21
21
|
* IND-546: explicit port layer for communities; signals consumed via capabilities/signals.facade.ts.
|
|
22
22
|
*/
|
|
23
|
-
|
|
24
|
-
// Re-exported from the signals capability facade so that application-layer code
|
|
25
|
-
// (indexer.graph.ts, indexer.state.ts) imports from the communities port, not
|
|
26
|
-
// directly from the signals facade or its implementation.
|
|
27
|
-
export { IntentIndexer } from "../../intents/index.js";
|
|
23
|
+
export {};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Each stage is a top-level function taking the graph state and an explicit
|
|
5
5
|
* dependency bag. `opportunity.graph.ts` wires them into the StateGraph.
|
|
6
6
|
*/
|
|
7
|
-
import {
|
|
7
|
+
import { Intents } from '../../intents/intent.module.js';
|
|
8
8
|
import { withCallLogging } from '../../shared/observability/protocol.logger.js';
|
|
9
9
|
import { timed } from '../../shared/observability/performance.js';
|
|
10
10
|
import { requestContext } from '../../shared/observability/request-context.js';
|
|
@@ -200,7 +200,7 @@ export async function scopeNode(state, deps) {
|
|
|
200
200
|
else if (state.searchQuery?.trim()) {
|
|
201
201
|
// Chat path: score query against target indexes in parallel
|
|
202
202
|
try {
|
|
203
|
-
const indexer = new
|
|
203
|
+
const indexer = new Intents();
|
|
204
204
|
const scopeAgentTimings = [];
|
|
205
205
|
const scorableIndexes = targetNetworks.filter(ti => ti.title !== 'Unknown');
|
|
206
206
|
const scoringPromises = scorableIndexes.map(async (ti) => {
|
|
@@ -213,7 +213,7 @@ export async function scopeNode(state, deps) {
|
|
|
213
213
|
traceEmitter?.({ type: "agent_start", name: "intent-networker" });
|
|
214
214
|
let result = null;
|
|
215
215
|
try {
|
|
216
|
-
result = await indexer.
|
|
216
|
+
result = await indexer.indexIntent(state.searchQuery, ctx?.indexPrompt ?? null, ctx?.memberPrompt ?? null);
|
|
217
217
|
}
|
|
218
218
|
catch {
|
|
219
219
|
return { networkId: ti.networkId, score: 1.0 };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { tool } from "@langchain/core/tools";
|
|
2
|
-
import {
|
|
2
|
+
import { Intents } from "../../intents/intent.module.js";
|
|
3
3
|
import { EnrichmentGraphFactory } from "../../enrichment/enrichment.graph.js";
|
|
4
4
|
import { OpportunityGraphFactory } from "../../opportunities/index.js";
|
|
5
5
|
import { HydeGraphFactory } from "../../discovery/hyde.graph.js";
|
|
6
6
|
import { HydeGenerator } from "../../discovery/hyde.generator.js";
|
|
7
7
|
import { LensInferrer } from "../../discovery/lens.inferrer.js";
|
|
8
8
|
import { NetworkGraphFactory, NetworkMembershipGraphFactory, IntentNetworkGraphFactory } from "../../networks/index.js";
|
|
9
|
-
import { IntentIndexer } from "../../intents/application/intent.indexer.js";
|
|
10
9
|
import { NegotiationGraphFactory } from "../../negotiations/index.js";
|
|
11
10
|
import { PremiseGraphFactory } from "../../premises/premise.graph.js";
|
|
12
11
|
import { protocolLogger } from "../observability/protocol.logger.js";
|
|
@@ -14,7 +13,6 @@ import { resolveChatContext, error, redactSensitiveFields } from "./tool.helpers
|
|
|
14
13
|
import { deriveAllowedNetworkIds, focusedIntentId, scopeFromNetworkId } from "./tool.scope.js";
|
|
15
14
|
import { invokeToolRuntime, toolRuntimeErrorToResult } from "./tool.runtime.js";
|
|
16
15
|
import { createEnrichmentTools } from "../../enrichment/enrichment.tools.js";
|
|
17
|
-
import { createIntentTools } from "../../intents/application/intent.tools.js";
|
|
18
16
|
import { createNetworkTools } from "../../networks/index.js";
|
|
19
17
|
import { createOpportunityTools } from "../../opportunities/index.js";
|
|
20
18
|
import { createUtilityTools } from "./utility.tools.js";
|
|
@@ -116,7 +114,13 @@ export async function createChatTools(deps, preResolvedContext) {
|
|
|
116
114
|
...(resolvedContext.sessionId && !input.conversationId ? { conversationId: resolvedContext.sessionId } : {}),
|
|
117
115
|
})
|
|
118
116
|
: undefined;
|
|
119
|
-
const
|
|
117
|
+
const intents = new Intents({
|
|
118
|
+
database,
|
|
119
|
+
embedder,
|
|
120
|
+
queue: deps.intentQueue,
|
|
121
|
+
questionerEnqueue: sessionAwareEnqueue,
|
|
122
|
+
});
|
|
123
|
+
const intentGraph = intents.createGraph();
|
|
120
124
|
const premiseGraph = new PremiseGraphFactory(database, embedder).createGraph();
|
|
121
125
|
const profileGraph = new EnrichmentGraphFactory(database, scraper, deps.enricher, premiseGraph).createGraph();
|
|
122
126
|
const hydeCache = deps.hydeCache;
|
|
@@ -131,7 +135,7 @@ export async function createChatTools(deps, preResolvedContext) {
|
|
|
131
135
|
negotiationGraph, deps.agentDispatcher, deps.queueNegotiateExisting, deps.stampNewbornOpportunities).createGraph();
|
|
132
136
|
const networkGraph = new NetworkGraphFactory(database).createGraph();
|
|
133
137
|
const networkMembershipGraph = new NetworkMembershipGraphFactory(database).createGraph();
|
|
134
|
-
const intentNetworkGraph = new IntentNetworkGraphFactory(database,
|
|
138
|
+
const intentNetworkGraph = new IntentNetworkGraphFactory(database, intents).createGraph();
|
|
135
139
|
// ─── Create context-bound databases ────────────────────────────────────────
|
|
136
140
|
// Use injected instances when provided (e.g. tests). Otherwise create from the same
|
|
137
141
|
// database used for graphs so that scope checks (e.g. ensureScopedMembership, opportunity
|
|
@@ -186,7 +190,7 @@ export async function createChatTools(deps, preResolvedContext) {
|
|
|
186
190
|
};
|
|
187
191
|
// ─── Create domain tools ──────────────────────────────────────────────────
|
|
188
192
|
const profileTools = createEnrichmentTools(defineTool, toolDeps);
|
|
189
|
-
const intentTools =
|
|
193
|
+
const intentTools = Intents.createTools(defineTool, toolDeps);
|
|
190
194
|
// An intent-scoped conversation exists to refine its selected signal. Keep
|
|
191
195
|
// creation out of the model-visible registry; the update handler separately
|
|
192
196
|
// clamps writes to the exact scoped intent as a runtime backstop.
|
|
@@ -187,7 +187,7 @@ interface ToolContextBindings {
|
|
|
187
187
|
/** Optional durable persistence for reporter cleanup-action proposals. */
|
|
188
188
|
actionProposalStore?: import('../../chat/reporter.action.contracts.js').AgentActionProposalStore;
|
|
189
189
|
/** Durable host persistence for verified intent proposals shown in chat. */
|
|
190
|
-
intentProposalStore?: import('../../intents/
|
|
190
|
+
intentProposalStore?: import('../../intents/intent.proposal.js').IntentProposalStore;
|
|
191
191
|
/**
|
|
192
192
|
* Host bridge for the negotiator persona's `remember`/`forget` memory
|
|
193
193
|
* tools (P5.4). Injected by the composition root only when negotiator
|
|
@@ -344,7 +344,7 @@ interface ToolDepsBindings {
|
|
|
344
344
|
/** Context-bound database for LLM/system operations on cross-user resources within shared networks. */
|
|
345
345
|
systemDb: SystemDatabase;
|
|
346
346
|
/** Durable host persistence for verified intent proposals shown in chat. */
|
|
347
|
-
intentProposalStore?: import('../../intents/
|
|
347
|
+
intentProposalStore?: import('../../intents/intent.proposal.js').IntentProposalStore;
|
|
348
348
|
scraper: Scraper;
|
|
349
349
|
embedder: import('../interfaces/embedder.interface.js').Embedder;
|
|
350
350
|
cache: Cache;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { error, redactSensitiveFields } from './tool.helpers.js';
|
|
2
2
|
import { createEnrichmentTools } from '../../enrichment/enrichment.tools.js';
|
|
3
|
-
import {
|
|
3
|
+
import { Intents } from '../../intents/intent.module.js';
|
|
4
4
|
import { createNetworkTools } from '../../networks/index.js';
|
|
5
5
|
import { createOpportunityTools } from '../../opportunities/index.js';
|
|
6
6
|
import { createUtilityTools } from './utility.tools.js';
|
|
@@ -53,7 +53,7 @@ export function createToolRegistry(deps, options = {}) {
|
|
|
53
53
|
// The local defineTool is compatible with DefineTool (which returns any).
|
|
54
54
|
const dt = defineTool;
|
|
55
55
|
createEnrichmentTools(dt, deps, { surface: isMcpSurface ? 'mcp' : 'rest' });
|
|
56
|
-
|
|
56
|
+
Intents.createTools(dt, deps);
|
|
57
57
|
createNetworkTools(dt, deps);
|
|
58
58
|
createOpportunityTools(dt, deps);
|
|
59
59
|
// Utility tools always register read_docs + read_activity_summary; on the
|
package/package.json
CHANGED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* intents/application — signal lifecycle and graph orchestration seams.
|
|
3
|
-
*
|
|
4
|
-
* Houses the LangGraph factory, model-binding adapters (inferrer, clarifier,
|
|
5
|
-
* verifier, reconciler, indexer), and the tool-definition factory.
|
|
6
|
-
* Participant-facing runtime tool registration lives in the foreground shell
|
|
7
|
-
* (shared/agent/tool.factory).
|
|
8
|
-
*
|
|
9
|
-
* Boundary: may import from intents/domain and intents/ports, plus
|
|
10
|
-
* only-when-needed LangGraph / model-binding seams inside this directory.
|
|
11
|
-
* Must not import host implementations.
|
|
12
|
-
*/
|
|
13
|
-
export { IntentGraphFactory, enforceIntentActionBoundary, buildExplicitUpdateActions } from "./intent.graph.js";
|
|
14
|
-
export { ExplicitIntentInferrer, type InferredIntent, type InferrerOptions } from "./intent.inferrer.js";
|
|
15
|
-
export { IntentClarifier } from "./intent.clarifier.js";
|
|
16
|
-
export { SemanticVerifier, type SemanticVerifierOutput } from "./intent.verifier.js";
|
|
17
|
-
export { IntentReconciler, type IntentReconcilerOutput, type NormalizedIntentAction } from "./intent.reconciler.js";
|
|
18
|
-
export { IntentIndexer, IntentIndexerOutputSchema, type IntentIndexerOutput } from "./intent.indexer.js";
|
|
19
|
-
export { createIntentTools, describeIntentUpdateFailure } from "./intent.tools.js";
|
|
20
|
-
export { SignalIntakePackGenerator, normalizeIntakePack, type IntakePack, type IntakePackInput, type IntakePackQuestion, type IntakePackQuestionOption, } from "./intake.pack.generator.js";
|
|
21
|
-
export { SignalIntakeOrchestrator, answerLabel, FALLBACK_WHO_QUESTION, FALLBACK_BRING_QUESTION, type IntakeAnswer, type IntakeRound, type FollowUpPlan, type FollowUpPlanInput, type SynthesisInput, type SynthesisResult, } from "./intake.orchestrator.js";
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* intents/application — signal lifecycle and graph orchestration seams.
|
|
3
|
-
*
|
|
4
|
-
* Houses the LangGraph factory, model-binding adapters (inferrer, clarifier,
|
|
5
|
-
* verifier, reconciler, indexer), and the tool-definition factory.
|
|
6
|
-
* Participant-facing runtime tool registration lives in the foreground shell
|
|
7
|
-
* (shared/agent/tool.factory).
|
|
8
|
-
*
|
|
9
|
-
* Boundary: may import from intents/domain and intents/ports, plus
|
|
10
|
-
* only-when-needed LangGraph / model-binding seams inside this directory.
|
|
11
|
-
* Must not import host implementations.
|
|
12
|
-
*/
|
|
13
|
-
// ── Graph orchestration ───────────────────────────────────────────────────────
|
|
14
|
-
export { IntentGraphFactory, enforceIntentActionBoundary, buildExplicitUpdateActions } from "./intent.graph.js";
|
|
15
|
-
// ── Model-binding adapters ────────────────────────────────────────────────────
|
|
16
|
-
export { ExplicitIntentInferrer } from "./intent.inferrer.js";
|
|
17
|
-
export { IntentClarifier } from "./intent.clarifier.js";
|
|
18
|
-
export { SemanticVerifier } from "./intent.verifier.js";
|
|
19
|
-
export { IntentReconciler } from "./intent.reconciler.js";
|
|
20
|
-
export { IntentIndexer, IntentIndexerOutputSchema } from "./intent.indexer.js";
|
|
21
|
-
// ── Tool factory (signals layer) ──────────────────────────────────────────────
|
|
22
|
-
export { createIntentTools, describeIntentUpdateFailure } from "./intent.tools.js";
|
|
23
|
-
// ── Fast-intake pack ──────────────────────────────────────────────────────────
|
|
24
|
-
export { SignalIntakePackGenerator, normalizeIntakePack, } from "./intake.pack.generator.js";
|
|
25
|
-
// ── Fast-intake orchestrator ──────────────────────────────────────────────────
|
|
26
|
-
export { SignalIntakeOrchestrator, answerLabel, FALLBACK_WHO_QUESTION, FALLBACK_BRING_QUESTION, } from "./intake.orchestrator.js";
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* intents/domain — pure signal contracts.
|
|
3
|
-
*
|
|
4
|
-
* Value types, graph-state shapes, validation-failure enumerations, and
|
|
5
|
-
* domain constants that define the signals capability's domain language.
|
|
6
|
-
* No LLM calls, no LangGraph edges, no host-adapter imports.
|
|
7
|
-
*/
|
|
8
|
-
export { type VerifiedIntent, type IntentValidationFailureCategory, type IntentValidationFailure, type ExecutionResult, IntentGraphState, } from "./intent.state.js";
|
|
9
|
-
export { DEFAULT_SPECIFICITY_WARNING } from "./signal.specificity.js";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* intents/domain — pure signal contracts.
|
|
3
|
-
*
|
|
4
|
-
* Value types, graph-state shapes, validation-failure enumerations, and
|
|
5
|
-
* domain constants that define the signals capability's domain language.
|
|
6
|
-
* No LLM calls, no LangGraph edges, no host-adapter imports.
|
|
7
|
-
*/
|
|
8
|
-
// ── State and value types ─────────────────────────────────────────────────────
|
|
9
|
-
export { IntentGraphState, } from "./intent.state.js";
|
|
10
|
-
// ── Domain constants ──────────────────────────────────────────────────────────
|
|
11
|
-
export { DEFAULT_SPECIFICITY_WARNING } from "./signal.specificity.js";
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/** Default user-facing warning for broad attributive intent proposals. */
|
|
2
|
-
export declare const DEFAULT_SPECIFICITY_WARNING = "This signal is broad and may produce many weak matches. Add a more concrete role, outcome, location, timeframe, domain, or specific need to get better recommendations.";
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
/** Default user-facing warning for broad attributive intent proposals. */
|
|
2
|
-
export const DEFAULT_SPECIFICITY_WARNING = "This signal is broad and may produce many weak matches. Add a more concrete role, outcome, location, timeframe, domain, or specific need to get better recommendations.";
|
package/dist/intents/index.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* signals — the capability's sole cross-capability surface.
|
|
3
|
-
*
|
|
4
|
-
* Anything outside this capability imports from here and nowhere else.
|
|
5
|
-
* Supersedes the capabilities/*.facade.ts + intents/public/ pair; the export
|
|
6
|
-
* list is the union of the facades it replaces, so the contract is unchanged.
|
|
7
|
-
*/
|
|
8
|
-
export { answerLabel, FALLBACK_BRING_QUESTION, FALLBACK_WHO_QUESTION, SignalIntakeOrchestrator, } from "./application/intake.orchestrator.js";
|
|
9
|
-
export type { FollowUpPlan, FollowUpPlanInput, IntakeAnswer, IntakeRound, SynthesisInput, SynthesisResult, } from "./application/intake.orchestrator.js";
|
|
10
|
-
export { normalizeIntakePack, SignalIntakePackGenerator, } from "./application/intake.pack.generator.js";
|
|
11
|
-
export type { IntakePack, IntakePackInput, IntakePackQuestion, IntakePackQuestionOption, } from "./application/intake.pack.generator.js";
|
|
12
|
-
export { IntentGraphFactory, } from "./application/intent.graph.js";
|
|
13
|
-
export { IntentIndexer, } from "./application/intent.indexer.js";
|
|
14
|
-
export type { IntentIndexerOutput, } from "./application/intent.indexer.js";
|
|
15
|
-
export { createIntentTools, } from "./application/intent.tools.js";
|
|
16
|
-
export { SemanticVerifier, } from "./application/intent.verifier.js";
|
|
17
|
-
export { normalizeIntentDescription, } from "./domain/intent.proposal.js";
|
|
18
|
-
export type { IntentToolDeps, } from "./ports/signals.tools.port.js";
|
package/dist/intents/index.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* signals — the capability's sole cross-capability surface.
|
|
3
|
-
*
|
|
4
|
-
* Anything outside this capability imports from here and nowhere else.
|
|
5
|
-
* Supersedes the capabilities/*.facade.ts + intents/public/ pair; the export
|
|
6
|
-
* list is the union of the facades it replaces, so the contract is unchanged.
|
|
7
|
-
*/
|
|
8
|
-
export { answerLabel, FALLBACK_BRING_QUESTION, FALLBACK_WHO_QUESTION, SignalIntakeOrchestrator, } from "./application/intake.orchestrator.js";
|
|
9
|
-
export { normalizeIntakePack, SignalIntakePackGenerator, } from "./application/intake.pack.generator.js";
|
|
10
|
-
export { IntentGraphFactory, } from "./application/intent.graph.js";
|
|
11
|
-
export { IntentIndexer, } from "./application/intent.indexer.js";
|
|
12
|
-
export { createIntentTools, } from "./application/intent.tools.js";
|
|
13
|
-
export { SemanticVerifier, } from "./application/intent.verifier.js";
|
|
14
|
-
export { normalizeIntentDescription, } from "./domain/intent.proposal.js";
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* intents/ports — narrow injected dependency contracts.
|
|
3
|
-
*
|
|
4
|
-
* Re-exports the subset of shared/interfaces types that the signals
|
|
5
|
-
* capability declares as explicit injected ports. Consumers of the
|
|
6
|
-
* signals module should import these port types here rather than from
|
|
7
|
-
* the broader shared/interfaces barrel to keep the dependency surface
|
|
8
|
-
* narrow and auditable.
|
|
9
|
-
*
|
|
10
|
-
* Ports are migrated here incrementally; placeholders name the intended
|
|
11
|
-
* contracts before they are physically relocated.
|
|
12
|
-
*/
|
|
13
|
-
export type { IntentGraphDatabase } from "../../shared/interfaces/database.interface.js";
|
|
14
|
-
export type { EmbeddingGenerator } from "../../shared/interfaces/embedder.interface.js";
|
|
15
|
-
export type { IntentGraphQueue } from "../../shared/interfaces/queue.interface.js";
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* intents/ports — narrow injected dependency contracts.
|
|
3
|
-
*
|
|
4
|
-
* Re-exports the subset of shared/interfaces types that the signals
|
|
5
|
-
* capability declares as explicit injected ports. Consumers of the
|
|
6
|
-
* signals module should import these port types here rather than from
|
|
7
|
-
* the broader shared/interfaces barrel to keep the dependency surface
|
|
8
|
-
* narrow and auditable.
|
|
9
|
-
*
|
|
10
|
-
* Ports are migrated here incrementally; placeholders name the intended
|
|
11
|
-
* contracts before they are physically relocated.
|
|
12
|
-
*/
|
|
13
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import type { ToolRegistryCompositionDeps } from "../../shared/agent/tool.helpers.js";
|
|
2
|
-
/** Host capabilities consumed by signal and intent tools. */
|
|
3
|
-
export type IntentToolDeps = Pick<ToolRegistryCompositionDeps, "userDb" | "systemDb"> & Pick<ToolRegistryCompositionDeps, "intentProposalStore"> & {
|
|
4
|
-
graphs: Pick<ToolRegistryCompositionDeps["graphs"], "intent" | "intentIndex" | "profile">;
|
|
5
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|