@indexnetwork/protocol 13.2.0-rc.466.1 → 14.0.0-rc.468.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.
Files changed (76) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/dist/capabilities/participant-agents.facade.d.ts +1 -2
  3. package/dist/capabilities/participant-agents.facade.js +1 -2
  4. package/dist/chat/chat-streaming.types.d.ts +16 -40
  5. package/dist/chat/chat-streaming.types.js +1 -8
  6. package/dist/chat/chat.agent.d.ts +5 -25
  7. package/dist/chat/chat.agent.js +12 -46
  8. package/dist/chat/chat.graph.d.ts +4 -6
  9. package/dist/chat/chat.graph.js +2 -3
  10. package/dist/chat/chat.persona.d.ts +7 -21
  11. package/dist/chat/chat.persona.js +1 -24
  12. package/dist/chat/chat.prompt.d.ts +0 -13
  13. package/dist/chat/chat.prompt.js +6 -428
  14. package/dist/chat/chat.prompt.modules.d.ts +2 -32
  15. package/dist/chat/chat.prompt.modules.js +1 -235
  16. package/dist/chat/chat.streamer.js +2 -8
  17. package/dist/communities/public/index.d.ts +2 -2
  18. package/dist/communities/public/index.js +2 -2
  19. package/dist/contacts/public/index.d.ts +1 -1
  20. package/dist/contacts/public/index.js +1 -1
  21. package/dist/index.d.ts +1 -1
  22. package/dist/index.js +0 -1
  23. package/dist/integrations/public/index.d.ts +1 -1
  24. package/dist/integrations/public/index.js +1 -1
  25. package/dist/mcp/mcp.server.d.ts +1 -1
  26. package/dist/mcp/mcp.server.js +1 -1
  27. package/dist/negotiation/public/index.d.ts +1 -1
  28. package/dist/negotiation/public/index.js +1 -1
  29. package/dist/participant-agents/public/index.d.ts +2 -2
  30. package/dist/participant-agents/public/index.js +2 -2
  31. package/dist/participant-context/application/index.js +1 -1
  32. package/dist/participant-context/domain/index.d.ts +1 -1
  33. package/dist/participant-context/domain/index.js +1 -1
  34. package/dist/participant-context/public/index.d.ts +2 -2
  35. package/dist/participant-context/public/index.js +2 -2
  36. package/dist/questions/public/index.d.ts +1 -1
  37. package/dist/questions/public/index.js +1 -1
  38. package/dist/shared/agent/tool.factory.d.ts +15 -4
  39. package/dist/shared/agent/tool.factory.js +233 -4
  40. package/dist/shared/agent/tool.registry.d.ts +21 -9
  41. package/dist/shared/agent/tool.registry.js +80 -12
  42. package/dist/signals/application/index.d.ts +1 -1
  43. package/dist/signals/application/index.js +1 -1
  44. package/dist/signals/public/index.d.ts +2 -2
  45. package/dist/signals/public/index.js +2 -2
  46. package/package.json +1 -1
  47. package/dist/communities/index.d.ts +0 -14
  48. package/dist/communities/index.js +0 -14
  49. package/dist/contacts/index.d.ts +0 -18
  50. package/dist/contacts/index.js +0 -18
  51. package/dist/integrations/index.d.ts +0 -22
  52. package/dist/integrations/index.js +0 -22
  53. package/dist/negotiation/index.d.ts +0 -25
  54. package/dist/negotiation/index.js +0 -25
  55. package/dist/opportunity/index.d.ts +0 -29
  56. package/dist/opportunity/index.js +0 -29
  57. package/dist/participant-agents/index.d.ts +0 -17
  58. package/dist/participant-agents/index.js +0 -17
  59. package/dist/platform/index.d.ts +0 -19
  60. package/dist/platform/index.js +0 -23
  61. package/dist/public/index.d.ts +0 -17
  62. package/dist/public/index.js +0 -17
  63. package/dist/questions/index.d.ts +0 -15
  64. package/dist/questions/index.js +0 -15
  65. package/dist/runtime/background/index.d.ts +0 -14
  66. package/dist/runtime/background/index.js +0 -14
  67. package/dist/runtime/foreground/composition/tool.factory.d.ts +0 -17
  68. package/dist/runtime/foreground/composition/tool.factory.js +0 -235
  69. package/dist/runtime/foreground/composition/tool.registry.d.ts +0 -24
  70. package/dist/runtime/foreground/composition/tool.registry.js +0 -80
  71. package/dist/runtime/foreground/index.d.ts +0 -13
  72. package/dist/runtime/foreground/index.js +0 -13
  73. package/dist/runtime/foreground/signals/intent.tools.d.ts +0 -13
  74. package/dist/runtime/foreground/signals/intent.tools.js +0 -13
  75. package/dist/signals/index.d.ts +0 -13
  76. package/dist/signals/index.js +0 -13
@@ -1,6 +1,235 @@
1
+ import { tool } from "@langchain/core/tools";
2
+ import { IntentGraphFactory } from "../../signals/application/intent.graph.js";
3
+ import { EnrichmentGraphFactory } from "../../enrichment/enrichment.graph.js";
4
+ import { OpportunityGraphFactory } from "../../capabilities/opportunities.facade.js";
5
+ import { HydeGraphFactory } from "../hyde/hyde.graph.js";
6
+ import { HydeGenerator } from "../hyde/hyde.generator.js";
7
+ import { LensInferrer } from "../hyde/lens.inferrer.js";
8
+ import { NetworkGraphFactory, NetworkMembershipGraphFactory, IntentNetworkGraphFactory } from "../../capabilities/communities.facade.js";
9
+ import { IntentIndexer } from "../../signals/application/intent.indexer.js";
10
+ import { NegotiationGraphFactory } from "../../capabilities/negotiation.facade.js";
11
+ import { PremiseGraphFactory } from "../../premise/premise.graph.js";
12
+ import { protocolLogger } from "../observability/protocol.logger.js";
13
+ import { resolveChatContext, error, redactSensitiveFields } from "./tool.helpers.js";
14
+ import { deriveAllowedNetworkIds, focusedIntentId, scopeFromNetworkId } from "./tool.scope.js";
15
+ import { invokeToolRuntime, toolRuntimeErrorToResult } from "./tool.runtime.js";
16
+ import { createEnrichmentTools } from "../../enrichment/enrichment.tools.js";
17
+ import { createIntentTools } from "../../signals/application/intent.tools.js";
18
+ import { createNetworkTools } from "../../capabilities/communities.facade.js";
19
+ import { createOpportunityTools } from "../../capabilities/opportunities.facade.js";
20
+ import { createUtilityTools } from "./utility.tools.js";
21
+ import { createIntegrationTools } from "../../capabilities/integrations.facade.js";
22
+ import { createContactTools } from "../../capabilities/contacts.facade.js";
23
+ import { createAgentTools } from "../../capabilities/participant-agents.tools.facade.js";
24
+ import { createNegotiationTools } from "../../capabilities/negotiation.facade.js";
25
+ import { createPremiseTools } from "../../premise/premise.tools.js";
26
+ import { createQuestionerTools, createAskUserQuestionTools } from "../../capabilities/questions.facade.js";
27
+ import { bindOwnerApprovalProvenance } from "../../opportunity/application/opportunity.owner-provenance.js";
28
+ const logger = protocolLogger("ChatTools");
29
+ // ═══════════════════════════════════════════════════════════════════════════════
30
+ // TOOL FACTORY
31
+ // ═══════════════════════════════════════════════════════════════════════════════
1
32
  /**
2
- * @deprecated Canonical location: runtime/foreground/composition/tool.factory
3
- * Retained for backward compatibility during IND-544 migration.
4
- * Import createChatTools from @indexnetwork/protocol instead.
33
+ * Creates all chat tools bound to a specific user context.
34
+ * Resolves user/network identity from DB at init time.
35
+ * Tools are created fresh for each user session to ensure proper isolation.
36
+ *
37
+ * All external dependencies (cache, integration, queue, etc.) are provided
38
+ * via the `deps` parameter — the protocol lib never imports concrete adapters.
5
39
  */
6
- export { createChatTools, } from "../../runtime/foreground/composition/tool.factory.js";
40
+ export async function createChatTools(deps, preResolvedContext) {
41
+ const { database, embedder, scraper } = deps;
42
+ const explicitScope = deps.scopeType && deps.scopeId
43
+ ? { scopeType: deps.scopeType, scopeId: deps.scopeId }
44
+ : scopeFromNetworkId(deps.networkId);
45
+ // ─── Resolve context from DB ───────────────────────────────────────────────
46
+ // resolveChatContext still accepts a networkId because it loads scoped index
47
+ // presentation metadata; the canonical request scope is explicitScope.
48
+ const resolvedContext = preResolvedContext ??
49
+ (await resolveChatContext({
50
+ database,
51
+ userId: deps.userId,
52
+ networkId: explicitScope.scopeType === 'network' ? explicitScope.scopeId : deps.networkId,
53
+ sessionId: deps.sessionId,
54
+ contactsEnabled: deps.contactsEnabled,
55
+ actionToolsEnabled: deps.actionToolsEnabled,
56
+ }));
57
+ if (!preResolvedContext && explicitScope.scopeType && explicitScope.scopeId) {
58
+ resolvedContext.scopeType = explicitScope.scopeType;
59
+ resolvedContext.scopeId = explicitScope.scopeId;
60
+ }
61
+ // This factory is an orchestrated chat surface, never a direct owner request.
62
+ // Bind that fact at composition time rather than inferring it from a session
63
+ // id or a caller-controlled tool argument inside the opportunity handler.
64
+ bindOwnerApprovalProvenance(resolvedContext, {
65
+ surface: 'chat',
66
+ sessionAuthenticated: false,
67
+ });
68
+ const allowedNetworkIds = deriveAllowedNetworkIds({
69
+ memberships: resolvedContext.userNetworks,
70
+ ...(resolvedContext.scopeType && resolvedContext.scopeId
71
+ ? { scopeType: resolvedContext.scopeType, scopeId: resolvedContext.scopeId }
72
+ : {}),
73
+ });
74
+ // ─── Tool wrapper ──────────────────────────────────────────────────────────
75
+ /**
76
+ * Standardized tool factory. Auto-injects resolved context and
77
+ * provides uniform logging / error handling for every tool.
78
+ */
79
+ function defineTool(opts) {
80
+ return tool(async (query) => {
81
+ logger.info('Tool invoked', {
82
+ toolName: opts.name,
83
+ context: { userId: resolvedContext.userId, scopeType: resolvedContext.scopeType, scopeId: resolvedContext.scopeId },
84
+ query: redactSensitiveFields(query),
85
+ });
86
+ try {
87
+ return await invokeToolRuntime({
88
+ toolName: opts.name,
89
+ tool: { handler: async ({ context, query }) => opts.handler({ context, query: query }) },
90
+ context: resolvedContext,
91
+ query,
92
+ });
93
+ }
94
+ catch (err) {
95
+ logger.error('Tool failed', {
96
+ toolName: opts.name,
97
+ error: err instanceof Error ? err.message : String(err),
98
+ });
99
+ const runtimeResult = toolRuntimeErrorToResult(err);
100
+ if (runtimeResult)
101
+ return runtimeResult;
102
+ const reason = err instanceof Error ? err.message : String(err);
103
+ return error(`Failed to execute ${opts.name}: ${reason}`);
104
+ }
105
+ }, { name: opts.name, description: opts.description, schema: opts.querySchema });
106
+ }
107
+ // ─── Compile subgraphs ─────────────────────────────────────────────────────
108
+ // Wrap questionerEnqueue to include scoped/session context when available.
109
+ const sessionAwareEnqueue = deps.questionerEnqueue
110
+ ? (input) => deps.questionerEnqueue({
111
+ ...input,
112
+ ...(resolvedContext.scopeType && resolvedContext.scopeId && !input.scopeId
113
+ ? { scopeType: resolvedContext.scopeType, scopeId: resolvedContext.scopeId }
114
+ : {}),
115
+ ...(resolvedContext.sessionId && !input.conversationId ? { conversationId: resolvedContext.sessionId } : {}),
116
+ })
117
+ : undefined;
118
+ const intentGraph = new IntentGraphFactory(database, embedder, deps.intentQueue, sessionAwareEnqueue).createGraph();
119
+ const premiseGraph = new PremiseGraphFactory(database, embedder).createGraph();
120
+ const profileGraph = new EnrichmentGraphFactory(database, scraper, deps.enricher, premiseGraph).createGraph();
121
+ const hydeCache = deps.hydeCache;
122
+ const lensInferrer = new LensInferrer();
123
+ const hydeGenerator = new HydeGenerator();
124
+ const compiledHydeGraph = new HydeGraphFactory(database, embedder, hydeCache, lensInferrer, hydeGenerator).createGraph();
125
+ const negotiationGraph = deps.agentDispatcher
126
+ ? new NegotiationGraphFactory(deps.negotiationDatabase, deps.agentDispatcher, deps.negotiationTimeoutQueue, sessionAwareEnqueue).createGraph()
127
+ : undefined;
128
+ const opportunityGraph = new OpportunityGraphFactory(database, embedder, compiledHydeGraph, undefined, // evaluator (default)
129
+ undefined, // queueNotification
130
+ negotiationGraph, deps.agentDispatcher, deps.queueNegotiateExisting, deps.stampNewbornOpportunities).createGraph();
131
+ const networkGraph = new NetworkGraphFactory(database).createGraph();
132
+ const networkMembershipGraph = new NetworkMembershipGraphFactory(database).createGraph();
133
+ const intentNetworkGraph = new IntentNetworkGraphFactory(database, new IntentIndexer()).createGraph();
134
+ // ─── Create context-bound databases ────────────────────────────────────────
135
+ // Use injected instances when provided (e.g. tests). Otherwise create from the same
136
+ // database used for graphs so that scope checks (e.g. ensureScopedMembership, opportunity
137
+ // update) use the same adapter as the rest of the tool pipeline.
138
+ //
139
+ // The systemDb's DB-level clamp derives concrete allowed network IDs from the
140
+ // focused scope envelope plus memberships, rather than consuming a transported
141
+ // legacy indexScope array.
142
+ const userDb = deps.userDb ?? deps.createUserDatabase(database, resolvedContext.userId);
143
+ const systemDb = deps.systemDb ?? deps.createSystemDatabase(database, resolvedContext.userId, allowedNetworkIds, embedder);
144
+ // ─── Assemble dependencies ─────────────────────────────────────────────────
145
+ const cache = deps.cache;
146
+ const integration = deps.integration;
147
+ const toolDeps = {
148
+ database,
149
+ userDb,
150
+ systemDb,
151
+ scraper,
152
+ embedder,
153
+ cache,
154
+ integration,
155
+ contactService: deps.contactService,
156
+ contactsEnabled: deps.contactsEnabled,
157
+ integrationImporter: deps.integrationImporter,
158
+ enricher: deps.enricher,
159
+ negotiationDatabase: deps.negotiationDatabase,
160
+ negotiationTimeoutQueue: deps.negotiationTimeoutQueue,
161
+ agentDatabase: deps.agentDatabase,
162
+ grantDefaultSystemPermissions: deps.grantDefaultSystemPermissions,
163
+ agentDispatcher: deps.agentDispatcher,
164
+ stampNewbornOpportunities: deps.stampNewbornOpportunities,
165
+ deliveryLedger: deps.deliveryLedger,
166
+ ...(deps.opportunityOwnerApproval && { opportunityOwnerApproval: deps.opportunityOwnerApproval }),
167
+ enrichmentRuns: deps.enrichmentRuns,
168
+ enrichmentRunQueue: deps.enrichmentRunQueue,
169
+ frontendUrl: deps.frontendUrl,
170
+ apiBaseUrl: deps.apiBaseUrl,
171
+ ...(deps.chatSummary && { chatSummary: deps.chatSummary }),
172
+ ...(sessionAwareEnqueue && { questionerEnqueue: sessionAwareEnqueue }),
173
+ ...(deps.findPendingQuestions && { findPendingQuestions: deps.findPendingQuestions }),
174
+ ...(deps.answerPendingQuestion && { answerPendingQuestion: deps.answerPendingQuestion }),
175
+ ...(deps.negotiationSummary && { negotiationSummary: deps.negotiationSummary }),
176
+ ...(deps.chatQuestions && { chatQuestions: deps.chatQuestions }),
177
+ ...(deps.chatSession && { chatSession: deps.chatSession }),
178
+ ...(deps.getUserContextText && { getUserContextText: deps.getUserContextText }),
179
+ ...(deps.intentProposalStore && { intentProposalStore: deps.intentProposalStore }),
180
+ graphs: {
181
+ profile: profileGraph,
182
+ intent: intentGraph,
183
+ index: networkGraph,
184
+ networkMembership: networkMembershipGraph,
185
+ intentIndex: intentNetworkGraph,
186
+ opportunity: opportunityGraph,
187
+ premise: premiseGraph,
188
+ },
189
+ };
190
+ // ─── Create domain tools ──────────────────────────────────────────────────
191
+ const profileTools = createEnrichmentTools(defineTool, toolDeps);
192
+ const intentTools = createIntentTools(defineTool, toolDeps);
193
+ // An intent-scoped conversation exists to refine its selected signal. Keep
194
+ // creation out of the model-visible registry; the update handler separately
195
+ // clamps writes to the exact scoped intent as a runtime backstop.
196
+ const intentToolsForChat = focusedIntentId(resolvedContext)
197
+ ? intentTools.filter((candidate) => candidate.name !== "create_intent")
198
+ : intentTools;
199
+ const networkTools = createNetworkTools(defineTool, toolDeps);
200
+ const opportunityTools = createOpportunityTools(defineTool, toolDeps);
201
+ const utilityTools = createUtilityTools(defineTool, toolDeps);
202
+ const contactTools = createContactTools(defineTool, toolDeps);
203
+ const agentTools = createAgentTools(defineTool, toolDeps);
204
+ const integrationTools = createIntegrationTools(defineTool, toolDeps);
205
+ const negotiationTools = deps.agentDispatcher
206
+ ? createNegotiationTools(defineTool, toolDeps)
207
+ : [];
208
+ const premiseTools = createPremiseTools(defineTool, toolDeps);
209
+ const questionerTools = createQuestionerTools(defineTool, toolDeps);
210
+ // Blocking mid-conversation questions — chat-only (never in the MCP registry),
211
+ // and only when the host provides the ChatQuestionsHost bridge.
212
+ const askUserQuestionTools = deps.chatQuestions
213
+ ? createAskUserQuestionTools(defineTool, toolDeps)
214
+ : [];
215
+ // confirm_opportunity_delivery is an OpenClaw-delivery ledger write and must not be
216
+ // callable from regular chat sessions.
217
+ const chatOpportunityToolExclusions = new Set([
218
+ "confirm_opportunity_delivery",
219
+ ]);
220
+ const opportunityToolsForChat = opportunityTools.filter((t) => !chatOpportunityToolExclusions.has(t.name));
221
+ return [
222
+ ...profileTools,
223
+ ...intentToolsForChat,
224
+ ...networkTools,
225
+ ...opportunityToolsForChat,
226
+ ...utilityTools,
227
+ ...integrationTools,
228
+ ...contactTools,
229
+ ...agentTools,
230
+ ...negotiationTools,
231
+ ...premiseTools,
232
+ ...questionerTools,
233
+ ...askUserQuestionTools,
234
+ ];
235
+ }
@@ -1,12 +1,24 @@
1
+ import type { ToolDeps, ToolRegistry } from './tool.helpers.js';
2
+ import type { ToolSurface } from './utility.tools.js';
3
+ import type { OpportunityOwnerApprovalDeps } from '../../opportunity/ports/opportunity.tools.port.js';
4
+ export interface CreateToolRegistryOptions {
5
+ /**
6
+ * Tool-surface profile. The default `'rest'` profile (direct HTTP Tool API)
7
+ * exposes contact/Gmail tools and `scrape_url`. The restricted `'mcp'`
8
+ * profile omits those surfaces (IND-596/597). Retired profile/profile-run
9
+ * compatibility aliases are absent from both profiles (IND-373/598).
10
+ */
11
+ surface?: ToolSurface;
12
+ }
1
13
  /**
2
- * Compatibility re-export shim — IND-543.
14
+ * Creates a tool registry containing all tool handlers indexed by name.
15
+ * Handlers are raw async functions (not LangChain tool() wrappers) that
16
+ * accept { context, query } and return a JSON string.
3
17
  *
4
- * The canonical implementation has moved to
5
- * runtime/foreground/composition/tool.registry.ts
6
- * (interaction-composition concern).
7
- *
8
- * This shim preserves all existing import paths inside the package and in
9
- * src/index.ts so that consumers need zero changes from this relocation.
10
- * It will be removed once direct importers are migrated.
18
+ * @param deps - Shared tool dependencies (graphs, database, embedder, etc.)
19
+ * @param options - Surface profile selecting the MCP-restricted or full REST set.
20
+ * @returns Map of tool name to raw tool definition.
11
21
  */
12
- export { createToolRegistry } from '../../runtime/foreground/composition/tool.registry.js';
22
+ /** Complete registry composition with the opportunity-local owner-proof port. */
23
+ export type ToolRegistryDeps = ToolDeps & OpportunityOwnerApprovalDeps;
24
+ export declare function createToolRegistry(deps: ToolRegistryDeps, options?: CreateToolRegistryOptions): ToolRegistry;
@@ -1,12 +1,80 @@
1
- /**
2
- * Compatibility re-export shim — IND-543.
3
- *
4
- * The canonical implementation has moved to
5
- * runtime/foreground/composition/tool.registry.ts
6
- * (interaction-composition concern).
7
- *
8
- * This shim preserves all existing import paths inside the package and in
9
- * src/index.ts so that consumers need zero changes from this relocation.
10
- * It will be removed once direct importers are migrated.
11
- */
12
- export { createToolRegistry } from '../../runtime/foreground/composition/tool.registry.js';
1
+ import { error, redactSensitiveFields } from './tool.helpers.js';
2
+ import { createEnrichmentTools } from '../../enrichment/enrichment.tools.js';
3
+ import { createIntentTools } from '../../signals/application/intent.tools.js';
4
+ import { createNetworkTools } from '../../capabilities/communities.facade.js';
5
+ import { createOpportunityTools } from '../../capabilities/opportunities.facade.js';
6
+ import { createUtilityTools } from './utility.tools.js';
7
+ import { createIntegrationTools } from '../../capabilities/integrations.facade.js';
8
+ import { createContactTools } from '../../capabilities/contacts.facade.js';
9
+ import { createAgentTools } from '../../capabilities/participant-agents.tools.facade.js';
10
+ import { createNegotiationTools } from '../../capabilities/negotiation.facade.js';
11
+ import { createChatTools } from '../../chat/chat.tools.js';
12
+ import { createPremiseTools } from '../../premise/premise.tools.js';
13
+ import { createQuestionerTools } from '../../capabilities/questions.facade.js';
14
+ import { protocolLogger } from '../observability/protocol.logger.js';
15
+ import { requestContext } from '../observability/request-context.js';
16
+ const logger = protocolLogger('ToolRegistry');
17
+ export function createToolRegistry(deps, options = {}) {
18
+ const registry = new Map();
19
+ const isMcpSurface = options.surface === 'mcp';
20
+ // defineTool that captures raw handlers into the registry
21
+ function defineTool(opts) {
22
+ const entry = {
23
+ name: opts.name,
24
+ description: opts.description,
25
+ schema: opts.querySchema,
26
+ handler: async (input) => {
27
+ logger.verbose('Tool invoked', {
28
+ toolName: opts.name,
29
+ context: { userId: input.context.userId, scopeType: input.context.scopeType, scopeId: input.context.scopeId },
30
+ query: redactSensitiveFields(input.query),
31
+ });
32
+ try {
33
+ return await opts.handler({ context: input.context, query: input.query });
34
+ }
35
+ catch (err) {
36
+ const abortSignal = requestContext.getStore()?.abortSignal;
37
+ if (abortSignal?.aborted) {
38
+ throw err;
39
+ }
40
+ logger.error('Tool failed', {
41
+ toolName: opts.name,
42
+ error: err instanceof Error ? err.message : String(err),
43
+ });
44
+ return error(`Failed to execute ${opts.name}: ${err instanceof Error ? err.message : String(err)}`);
45
+ }
46
+ },
47
+ };
48
+ registry.set(opts.name, entry);
49
+ // Return a dummy — create*Tools functions collect return values into arrays,
50
+ // but for the registry path we only need the side-effect on the Map.
51
+ return null;
52
+ }
53
+ // Create all tool domains -- each one calls defineTool() which populates the registry.
54
+ // The local defineTool is compatible with DefineTool (which returns any).
55
+ const dt = defineTool;
56
+ createEnrichmentTools(dt, deps);
57
+ createIntentTools(dt, deps);
58
+ createNetworkTools(dt, deps);
59
+ createOpportunityTools(dt, deps);
60
+ // Utility tools always register read_docs + read_activity_summary; on the
61
+ // MCP surface scrape_url is omitted and read_docs guidance is sanitized
62
+ // (IND-597). The retired report_agent_activity name retains no alias on
63
+ // either surface (IND-605).
64
+ createUtilityTools(dt, deps, { surface: isMcpSurface ? 'mcp' : 'rest' });
65
+ // Contact/Gmail import tools are omitted from the MCP surface (IND-596). Their
66
+ // implementations remain available to the REST Tool API and chat agent.
67
+ if (!isMcpSurface) {
68
+ createIntegrationTools(dt, deps);
69
+ createContactTools(dt, deps);
70
+ }
71
+ createAgentTools(dt, deps);
72
+ createNegotiationTools(dt, deps);
73
+ createPremiseTools(dt, deps);
74
+ createQuestionerTools(dt, deps);
75
+ if (deps.chatSession) {
76
+ createChatTools(dt, deps);
77
+ }
78
+ logger.verbose('Tool registry created', { toolCount: registry.size, surface: options.surface ?? 'rest' });
79
+ return registry;
80
+ }
@@ -4,7 +4,7 @@
4
4
  * Houses the LangGraph factory, model-binding adapters (inferrer, clarifier,
5
5
  * verifier, reconciler, indexer), and the tool-definition factory.
6
6
  * Participant-facing runtime tool registration lives in the foreground shell
7
- * (runtime/foreground/signals/intent.tools).
7
+ * (shared/agent/tool.factory).
8
8
  *
9
9
  * Boundary: may import from signals/domain and signals/ports, plus
10
10
  * only-when-needed LangGraph / model-binding seams inside this directory.
@@ -4,7 +4,7 @@
4
4
  * Houses the LangGraph factory, model-binding adapters (inferrer, clarifier,
5
5
  * verifier, reconciler, indexer), and the tool-definition factory.
6
6
  * Participant-facing runtime tool registration lives in the foreground shell
7
- * (runtime/foreground/signals/intent.tools).
7
+ * (shared/agent/tool.factory).
8
8
  *
9
9
  * Boundary: may import from signals/domain and signals/ports, plus
10
10
  * only-when-needed LangGraph / model-binding seams inside this directory.
@@ -4,10 +4,10 @@
4
4
  * Re-exports the stable contracts from domain, application, and ports.
5
5
  * Runtime adapter creation (createIntentTools) is NOT exported here; it is
6
6
  * accessible via capabilities/signals.facade for package consumers and via
7
- * the foreground shell (runtime/foreground/signals) for internal registries.
7
+ * the tool composition root (shared/agent) for internal registries.
8
8
  *
9
9
  * Boundary: public-compatibility. References only signals/domain,
10
- * signals/application, and signals/ports — never runtime/foreground or
10
+ * signals/application, and signals/ports — never the tool composition root (shared/agent) or
11
11
  * host implementations.
12
12
  */
13
13
  export { type VerifiedIntent, type IntentValidationFailureCategory, type IntentValidationFailure, type ExecutionResult, IntentGraphState, DEFAULT_SPECIFICITY_WARNING, } from "../domain/index.js";
@@ -4,10 +4,10 @@
4
4
  * Re-exports the stable contracts from domain, application, and ports.
5
5
  * Runtime adapter creation (createIntentTools) is NOT exported here; it is
6
6
  * accessible via capabilities/signals.facade for package consumers and via
7
- * the foreground shell (runtime/foreground/signals) for internal registries.
7
+ * the tool composition root (shared/agent) for internal registries.
8
8
  *
9
9
  * Boundary: public-compatibility. References only signals/domain,
10
- * signals/application, and signals/ports — never runtime/foreground or
10
+ * signals/application, and signals/ports — never the tool composition root (shared/agent) or
11
11
  * host implementations.
12
12
  */
13
13
  // ── Domain contracts ──────────────────────────────────────────────────────────
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indexnetwork/protocol",
3
- "version": "13.2.0-rc.466.1",
3
+ "version": "14.0.0-rc.468.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",
@@ -1,14 +0,0 @@
1
- /**
2
- * communities — domain-first module root.
3
- *
4
- * Re-exports the curated public surface. Other modules inside the communities
5
- * capability import directly from communities/domain, communities/application,
6
- * or communities/ports; this barrel is for cross-capability consumers that must
7
- * go through the communities public surface.
8
- *
9
- * IND-546: canonical home for network lifecycle, membership, scope, and signal
10
- * assignment behaviour previously spread across network/, network/membership/,
11
- * and network/indexer/. Legacy network/* paths remain as compatibility
12
- * re-exports pointing here.
13
- */
14
- export * from "./public/index.js";
@@ -1,14 +0,0 @@
1
- /**
2
- * communities — domain-first module root.
3
- *
4
- * Re-exports the curated public surface. Other modules inside the communities
5
- * capability import directly from communities/domain, communities/application,
6
- * or communities/ports; this barrel is for cross-capability consumers that must
7
- * go through the communities public surface.
8
- *
9
- * IND-546: canonical home for network lifecycle, membership, scope, and signal
10
- * assignment behaviour previously spread across network/, network/membership/,
11
- * and network/indexer/. Legacy network/* paths remain as compatibility
12
- * re-exports pointing here.
13
- */
14
- export * from "./public/index.js";
@@ -1,18 +0,0 @@
1
- /**
2
- * contacts — domain-first module root.
3
- *
4
- * Re-exports the curated public surface. Other modules inside the contacts
5
- * capability import directly from contacts/domain, contacts/application, or
6
- * contacts/ports; this barrel is for cross-capability consumers that must
7
- * go through the contacts public surface.
8
- *
9
- * IND-549: canonical home for contact management capabilities.
10
- *
11
- * Retains participant reachability semantics: all operations are scoped to
12
- * the owning user's personal network. Contacts are participants with whom
13
- * opportunity discovery is run.
14
- *
15
- * Compatibility path:
16
- * - capabilities/contacts.facade.ts — thin re-export via contacts/public
17
- */
18
- export * from "./public/index.js";
@@ -1,18 +0,0 @@
1
- /**
2
- * contacts — domain-first module root.
3
- *
4
- * Re-exports the curated public surface. Other modules inside the contacts
5
- * capability import directly from contacts/domain, contacts/application, or
6
- * contacts/ports; this barrel is for cross-capability consumers that must
7
- * go through the contacts public surface.
8
- *
9
- * IND-549: canonical home for contact management capabilities.
10
- *
11
- * Retains participant reachability semantics: all operations are scoped to
12
- * the owning user's personal network. Contacts are participants with whom
13
- * opportunity discovery is run.
14
- *
15
- * Compatibility path:
16
- * - capabilities/contacts.facade.ts — thin re-export via contacts/public
17
- */
18
- export * from "./public/index.js";
@@ -1,22 +0,0 @@
1
- /**
2
- * integrations — domain-first module root.
3
- *
4
- * Re-exports the curated public surface. Other modules inside the integrations
5
- * capability import directly from integrations/domain, integrations/application,
6
- * or integrations/ports; this barrel is for cross-capability consumers that
7
- * must go through the integrations public surface.
8
- *
9
- * IND-549: canonical home for integration capabilities.
10
- *
11
- * Retains host-integration configuration/actions semantics: the module owns
12
- * the OAuth session lifecycle and bulk contact import pipeline contracts.
13
- * Runtime foreground transport (authentication headers, request context) and
14
- * all-capability composition remain in runtime/foreground.
15
- *
16
- * Allowed outbound capability dependencies: none (empty set). The integrations
17
- * module is a leaf capability that only depends on shared/ primitives.
18
- *
19
- * Compatibility path:
20
- * - capabilities/integrations.facade.ts — thin re-export via integrations/public
21
- */
22
- export * from "./public/index.js";
@@ -1,22 +0,0 @@
1
- /**
2
- * integrations — domain-first module root.
3
- *
4
- * Re-exports the curated public surface. Other modules inside the integrations
5
- * capability import directly from integrations/domain, integrations/application,
6
- * or integrations/ports; this barrel is for cross-capability consumers that
7
- * must go through the integrations public surface.
8
- *
9
- * IND-549: canonical home for integration capabilities.
10
- *
11
- * Retains host-integration configuration/actions semantics: the module owns
12
- * the OAuth session lifecycle and bulk contact import pipeline contracts.
13
- * Runtime foreground transport (authentication headers, request context) and
14
- * all-capability composition remain in runtime/foreground.
15
- *
16
- * Allowed outbound capability dependencies: none (empty set). The integrations
17
- * module is a leaf capability that only depends on shared/ primitives.
18
- *
19
- * Compatibility path:
20
- * - capabilities/integrations.facade.ts — thin re-export via integrations/public
21
- */
22
- export * from "./public/index.js";
@@ -1,25 +0,0 @@
1
- /**
2
- * negotiation — domain-first module root.
3
- *
4
- * Re-exports the curated public surface. Other modules inside the negotiation
5
- * capability import directly from negotiation/domain, negotiation/application,
6
- * or negotiation/ports; this barrel is for cross-capability consumers that must
7
- * go through the negotiation public surface.
8
- *
9
- * IND-550: canonical home for the bilateral turn protocol, screening, memory,
10
- * consultation, settlement, and summary capabilities previously spread across
11
- * the flat negotiation/ directory and capabilities/negotiation*.facade.ts files.
12
- *
13
- * ## Module topology
14
- *
15
- * ```
16
- * negotiation/
17
- * ├── domain/ — pure types, protocol rules, policy functions, renderers
18
- * ├── application/ — LLM agents, LangGraph factory, MCP tool factory
19
- * ├── ports/ — injected dependency contracts (NegotiationToolDeps)
20
- * ├── public/ — curated re-export surface
21
- * └── index.ts — this file
22
- * ```
23
- *
24
- */
25
- export * from "./public/index.js";
@@ -1,25 +0,0 @@
1
- /**
2
- * negotiation — domain-first module root.
3
- *
4
- * Re-exports the curated public surface. Other modules inside the negotiation
5
- * capability import directly from negotiation/domain, negotiation/application,
6
- * or negotiation/ports; this barrel is for cross-capability consumers that must
7
- * go through the negotiation public surface.
8
- *
9
- * IND-550: canonical home for the bilateral turn protocol, screening, memory,
10
- * consultation, settlement, and summary capabilities previously spread across
11
- * the flat negotiation/ directory and capabilities/negotiation*.facade.ts files.
12
- *
13
- * ## Module topology
14
- *
15
- * ```
16
- * negotiation/
17
- * ├── domain/ — pure types, protocol rules, policy functions, renderers
18
- * ├── application/ — LLM agents, LangGraph factory, MCP tool factory
19
- * ├── ports/ — injected dependency contracts (NegotiationToolDeps)
20
- * ├── public/ — curated re-export surface
21
- * └── index.ts — this file
22
- * ```
23
- *
24
- */
25
- export * from "./public/index.js";
@@ -1,29 +0,0 @@
1
- /**
2
- * opportunity — domain-first module root.
3
- *
4
- * Re-exports the curated public surface. Other modules inside the opportunity
5
- * capability import directly from opportunity/domain, opportunity/application,
6
- * or opportunity/ports; this barrel is for cross-capability consumers that must
7
- * go through the opportunity public surface.
8
- *
9
- * IND-551: canonical home for candidate generation, evaluation, persistence,
10
- * lifecycle, feed projection, evidence, outcome, and safe presentation.
11
- *
12
- * ## Module topology
13
- *
14
- * ```
15
- * opportunity/
16
- * ├── domain/ — pure types, predicates, policy, safe-presentation
17
- * ├── application/ — LLM agents, LangGraph graphs, effectful orchestration
18
- * ├── ports/ — injected dependency contracts
19
- * ├── public/ — curated re-export surface
20
- * └── index.ts — this file
21
- * ```
22
- *
23
- * ## Subdirectories (domain and application files co-located)
24
- * - discriminator/ — pool question mining, scoring, assignment
25
- * - negotiation-evidence/ — Lens C evidence extraction and mining
26
- * - outcome/ — Lens B outcome hypothesis mining
27
- * - radar/ — radar graph (flat presenter-card list) and radar health
28
- */
29
- export * from "./public/index.js";