@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.
- package/CHANGELOG.md +49 -0
- package/dist/capabilities/participant-agents.facade.d.ts +1 -2
- package/dist/capabilities/participant-agents.facade.js +1 -2
- package/dist/chat/chat-streaming.types.d.ts +16 -40
- package/dist/chat/chat-streaming.types.js +1 -8
- package/dist/chat/chat.agent.d.ts +5 -25
- package/dist/chat/chat.agent.js +12 -46
- package/dist/chat/chat.graph.d.ts +4 -6
- package/dist/chat/chat.graph.js +2 -3
- package/dist/chat/chat.persona.d.ts +7 -21
- package/dist/chat/chat.persona.js +1 -24
- package/dist/chat/chat.prompt.d.ts +0 -13
- package/dist/chat/chat.prompt.js +6 -428
- package/dist/chat/chat.prompt.modules.d.ts +2 -32
- package/dist/chat/chat.prompt.modules.js +1 -235
- package/dist/chat/chat.streamer.js +2 -8
- package/dist/communities/public/index.d.ts +2 -2
- package/dist/communities/public/index.js +2 -2
- package/dist/contacts/public/index.d.ts +1 -1
- package/dist/contacts/public/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +0 -1
- package/dist/integrations/public/index.d.ts +1 -1
- package/dist/integrations/public/index.js +1 -1
- package/dist/mcp/mcp.server.d.ts +1 -1
- package/dist/mcp/mcp.server.js +1 -1
- package/dist/negotiation/public/index.d.ts +1 -1
- package/dist/negotiation/public/index.js +1 -1
- package/dist/participant-agents/public/index.d.ts +2 -2
- package/dist/participant-agents/public/index.js +2 -2
- package/dist/participant-context/application/index.js +1 -1
- package/dist/participant-context/domain/index.d.ts +1 -1
- package/dist/participant-context/domain/index.js +1 -1
- package/dist/participant-context/public/index.d.ts +2 -2
- package/dist/participant-context/public/index.js +2 -2
- package/dist/questions/public/index.d.ts +1 -1
- package/dist/questions/public/index.js +1 -1
- package/dist/shared/agent/tool.factory.d.ts +15 -4
- package/dist/shared/agent/tool.factory.js +233 -4
- package/dist/shared/agent/tool.registry.d.ts +21 -9
- package/dist/shared/agent/tool.registry.js +80 -12
- package/dist/signals/application/index.d.ts +1 -1
- package/dist/signals/application/index.js +1 -1
- package/dist/signals/public/index.d.ts +2 -2
- package/dist/signals/public/index.js +2 -2
- package/package.json +1 -1
- package/dist/communities/index.d.ts +0 -14
- package/dist/communities/index.js +0 -14
- package/dist/contacts/index.d.ts +0 -18
- package/dist/contacts/index.js +0 -18
- package/dist/integrations/index.d.ts +0 -22
- package/dist/integrations/index.js +0 -22
- package/dist/negotiation/index.d.ts +0 -25
- package/dist/negotiation/index.js +0 -25
- package/dist/opportunity/index.d.ts +0 -29
- package/dist/opportunity/index.js +0 -29
- package/dist/participant-agents/index.d.ts +0 -17
- package/dist/participant-agents/index.js +0 -17
- package/dist/platform/index.d.ts +0 -19
- package/dist/platform/index.js +0 -23
- package/dist/public/index.d.ts +0 -17
- package/dist/public/index.js +0 -17
- package/dist/questions/index.d.ts +0 -15
- package/dist/questions/index.js +0 -15
- package/dist/runtime/background/index.d.ts +0 -14
- package/dist/runtime/background/index.js +0 -14
- package/dist/runtime/foreground/composition/tool.factory.d.ts +0 -17
- package/dist/runtime/foreground/composition/tool.factory.js +0 -235
- package/dist/runtime/foreground/composition/tool.registry.d.ts +0 -24
- package/dist/runtime/foreground/composition/tool.registry.js +0 -80
- package/dist/runtime/foreground/index.d.ts +0 -13
- package/dist/runtime/foreground/index.js +0 -13
- package/dist/runtime/foreground/signals/intent.tools.d.ts +0 -13
- package/dist/runtime/foreground/signals/intent.tools.js +0 -13
- package/dist/signals/index.d.ts +0 -13
- package/dist/signals/index.js +0 -13
|
@@ -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";
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* participant-agents — domain-first module root.
|
|
3
|
-
*
|
|
4
|
-
* Re-exports the curated public surface. Other modules inside the
|
|
5
|
-
* participant-agents capability import directly from
|
|
6
|
-
* participant-agents/domain, participant-agents/application, or
|
|
7
|
-
* participant-agents/ports; this barrel is for cross-capability consumers
|
|
8
|
-
* that must go through the participant-agents public surface.
|
|
9
|
-
*
|
|
10
|
-
* IND-548: canonical home for agent registration, permission-aware behaviour,
|
|
11
|
-
* and dispatch contracts.
|
|
12
|
-
*
|
|
13
|
-
* Compatibility path:
|
|
14
|
-
* - shared/interfaces/agent-dispatcher.interface.ts — re-exports from
|
|
15
|
-
* participant-agents/ports
|
|
16
|
-
*/
|
|
17
|
-
export * from "./public/index.js";
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* participant-agents — domain-first module root.
|
|
3
|
-
*
|
|
4
|
-
* Re-exports the curated public surface. Other modules inside the
|
|
5
|
-
* participant-agents capability import directly from
|
|
6
|
-
* participant-agents/domain, participant-agents/application, or
|
|
7
|
-
* participant-agents/ports; this barrel is for cross-capability consumers
|
|
8
|
-
* that must go through the participant-agents public surface.
|
|
9
|
-
*
|
|
10
|
-
* IND-548: canonical home for agent registration, permission-aware behaviour,
|
|
11
|
-
* and dispatch contracts.
|
|
12
|
-
*
|
|
13
|
-
* Compatibility path:
|
|
14
|
-
* - shared/interfaces/agent-dispatcher.interface.ts — re-exports from
|
|
15
|
-
* participant-agents/ports
|
|
16
|
-
*/
|
|
17
|
-
export * from "./public/index.js";
|
package/dist/platform/index.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* platform — IND-543 outer shell.
|
|
3
|
-
*
|
|
4
|
-
* Curated contracts that are truly cross-domain: model primitives,
|
|
5
|
-
* observability extension hooks, timeout/abort/request-context.
|
|
6
|
-
*
|
|
7
|
-
* Boundary: neutral-platform. MUST NOT import any capability module
|
|
8
|
-
* internals (signals, communities, opportunities, negotiation, …).
|
|
9
|
-
* Permitted sources: shared/interfaces, shared/schemas, shared/observability,
|
|
10
|
-
* shared/agent model + runtime helpers.
|
|
11
|
-
*
|
|
12
|
-
* These re-exports are temporary aliases; the implementation files remain in
|
|
13
|
-
* shared/ until the domain migration issues land.
|
|
14
|
-
*/
|
|
15
|
-
export { getModelName } from '../shared/agent/model.config.js';
|
|
16
|
-
export { requestContext } from '../shared/observability/request-context.js';
|
|
17
|
-
export { setLoggerFactory } from '../shared/observability/log.js';
|
|
18
|
-
export { setTimingWrapper } from '../shared/observability/performance.js';
|
|
19
|
-
export { getToolTimeoutPolicy, invokeToolRuntime, toolRuntimeErrorToResult, } from '../shared/agent/tool.runtime.js';
|
package/dist/platform/index.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* platform — IND-543 outer shell.
|
|
3
|
-
*
|
|
4
|
-
* Curated contracts that are truly cross-domain: model primitives,
|
|
5
|
-
* observability extension hooks, timeout/abort/request-context.
|
|
6
|
-
*
|
|
7
|
-
* Boundary: neutral-platform. MUST NOT import any capability module
|
|
8
|
-
* internals (signals, communities, opportunities, negotiation, …).
|
|
9
|
-
* Permitted sources: shared/interfaces, shared/schemas, shared/observability,
|
|
10
|
-
* shared/agent model + runtime helpers.
|
|
11
|
-
*
|
|
12
|
-
* These re-exports are temporary aliases; the implementation files remain in
|
|
13
|
-
* shared/ until the domain migration issues land.
|
|
14
|
-
*/
|
|
15
|
-
// ── Model primitives ──────────────────────────────────────────────────────────
|
|
16
|
-
export { getModelName } from '../shared/agent/model.config.js';
|
|
17
|
-
// ── Request / abort context ───────────────────────────────────────────────────
|
|
18
|
-
export { requestContext } from '../shared/observability/request-context.js';
|
|
19
|
-
// ── Observability extension points ────────────────────────────────────────────
|
|
20
|
-
export { setLoggerFactory } from '../shared/observability/log.js';
|
|
21
|
-
export { setTimingWrapper } from '../shared/observability/performance.js';
|
|
22
|
-
// ── Tool invocation runtime ───────────────────────────────────────────────────
|
|
23
|
-
export { getToolTimeoutPolicy, invokeToolRuntime, toolRuntimeErrorToResult, } from '../shared/agent/tool.runtime.js';
|
package/dist/public/index.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
/**
|
|
3
|
-
* public — IND-543 outer shell.
|
|
4
|
-
*
|
|
5
|
-
* Curated root assembly and temporary compatibility aliases. This shell will
|
|
6
|
-
* eventually host a structured sub-barrel that feeds src/index.ts; during
|
|
7
|
-
* the outer-seam phase (IND-543) it establishes the boundary and naming
|
|
8
|
-
* convention without duplicating the existing root barrel.
|
|
9
|
-
*
|
|
10
|
-
* Boundary: public-compatibility. May only reference capability contracts
|
|
11
|
-
* via capabilities/*.facade.ts — never capability implementation internals.
|
|
12
|
-
* Must not introduce a second supported package entry point; src/index.ts
|
|
13
|
-
* remains the sole supported entry.
|
|
14
|
-
*
|
|
15
|
-
* Shell is intentionally declaration-only at this phase. Curated re-exports
|
|
16
|
-
* follow in subsequent issues once public/ is wired into src/index.ts.
|
|
17
|
-
*/
|
package/dist/public/index.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
/**
|
|
3
|
-
* public — IND-543 outer shell.
|
|
4
|
-
*
|
|
5
|
-
* Curated root assembly and temporary compatibility aliases. This shell will
|
|
6
|
-
* eventually host a structured sub-barrel that feeds src/index.ts; during
|
|
7
|
-
* the outer-seam phase (IND-543) it establishes the boundary and naming
|
|
8
|
-
* convention without duplicating the existing root barrel.
|
|
9
|
-
*
|
|
10
|
-
* Boundary: public-compatibility. May only reference capability contracts
|
|
11
|
-
* via capabilities/*.facade.ts — never capability implementation internals.
|
|
12
|
-
* Must not introduce a second supported package entry point; src/index.ts
|
|
13
|
-
* remains the sole supported entry.
|
|
14
|
-
*
|
|
15
|
-
* Shell is intentionally declaration-only at this phase. Curated re-exports
|
|
16
|
-
* follow in subsequent issues once public/ is wired into src/index.ts.
|
|
17
|
-
*/
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* questions — domain-first module root.
|
|
3
|
-
*
|
|
4
|
-
* Re-exports the curated public surface. Other modules inside the questions
|
|
5
|
-
* capability import directly from questions/domain, questions/application,
|
|
6
|
-
* or questions/ports; this barrel is for cross-capability consumers that must
|
|
7
|
-
* go through the questions public surface.
|
|
8
|
-
*
|
|
9
|
-
* IND-547: canonical home for question generation, eligibility, validation,
|
|
10
|
-
* provenance, settlement policy, and continuation behaviour.
|
|
11
|
-
*
|
|
12
|
-
* Compatibility paths:
|
|
13
|
-
* - capabilities/questions.facade.ts — re-exports from questions/public/index.js
|
|
14
|
-
*/
|
|
15
|
-
export * from "./public/index.js";
|
package/dist/questions/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* questions — domain-first module root.
|
|
3
|
-
*
|
|
4
|
-
* Re-exports the curated public surface. Other modules inside the questions
|
|
5
|
-
* capability import directly from questions/domain, questions/application,
|
|
6
|
-
* or questions/ports; this barrel is for cross-capability consumers that must
|
|
7
|
-
* go through the questions public surface.
|
|
8
|
-
*
|
|
9
|
-
* IND-547: canonical home for question generation, eligibility, validation,
|
|
10
|
-
* provenance, settlement policy, and continuation behaviour.
|
|
11
|
-
*
|
|
12
|
-
* Compatibility paths:
|
|
13
|
-
* - capabilities/questions.facade.ts — re-exports from questions/public/index.js
|
|
14
|
-
*/
|
|
15
|
-
export * from "./public/index.js";
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
/**
|
|
3
|
-
* runtime/background — IND-543 outer shell.
|
|
4
|
-
*
|
|
5
|
-
* Entry point for ambient / background workflow adapters: maintenance graphs,
|
|
6
|
-
* enrichment runners, negotiation schedulers, and other non-interactive
|
|
7
|
-
* entry points that operate without a live participant session.
|
|
8
|
-
*
|
|
9
|
-
* Boundary: ambient-background. May import from any capability via its
|
|
10
|
-
* capabilities/*.facade.ts contract. Must not import host implementations.
|
|
11
|
-
*
|
|
12
|
-
* Shell is intentionally empty at this phase (IND-543 outer seam only).
|
|
13
|
-
* Domain-level adapter relocations follow in subsequent issues.
|
|
14
|
-
*/
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export {};
|
|
2
|
-
/**
|
|
3
|
-
* runtime/background — IND-543 outer shell.
|
|
4
|
-
*
|
|
5
|
-
* Entry point for ambient / background workflow adapters: maintenance graphs,
|
|
6
|
-
* enrichment runners, negotiation schedulers, and other non-interactive
|
|
7
|
-
* entry points that operate without a live participant session.
|
|
8
|
-
*
|
|
9
|
-
* Boundary: ambient-background. May import from any capability via its
|
|
10
|
-
* capabilities/*.facade.ts contract. Must not import host implementations.
|
|
11
|
-
*
|
|
12
|
-
* Shell is intentionally empty at this phase (IND-543 outer seam only).
|
|
13
|
-
* Domain-level adapter relocations follow in subsequent issues.
|
|
14
|
-
*/
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { type ToolContext, type ResolvedToolContext } from "../../../shared/agent/tool.helpers.js";
|
|
2
|
-
import type { OpportunityOwnerApprovalDeps } from "../../../opportunity/ports/opportunity.tools.port.js";
|
|
3
|
-
export type { ToolContext, ResolvedToolContext, ProtocolDeps } from "../../../shared/agent/tool.helpers.js";
|
|
4
|
-
export type { ToolDeps } from "../../../shared/agent/tool.helpers.js";
|
|
5
|
-
/**
|
|
6
|
-
* Creates all chat tools bound to a specific user context.
|
|
7
|
-
* Resolves user/network identity from DB at init time.
|
|
8
|
-
* Tools are created fresh for each user session to ensure proper isolation.
|
|
9
|
-
*
|
|
10
|
-
* All external dependencies (cache, integration, queue, etc.) are provided
|
|
11
|
-
* via the `deps` parameter — the protocol lib never imports concrete adapters.
|
|
12
|
-
*/
|
|
13
|
-
export declare function createChatTools(deps: ToolContext & OpportunityOwnerApprovalDeps, preResolvedContext?: ResolvedToolContext): Promise<any[]>;
|
|
14
|
-
/**
|
|
15
|
-
* Type for the tools array returned by createChatTools.
|
|
16
|
-
*/
|
|
17
|
-
export type ChatTools = Awaited<ReturnType<typeof createChatTools>>;
|
|
@@ -1,235 +0,0 @@
|
|
|
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 "../../../shared/hyde/hyde.graph.js";
|
|
6
|
-
import { HydeGenerator } from "../../../shared/hyde/hyde.generator.js";
|
|
7
|
-
import { LensInferrer } from "../../../shared/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 "../../../shared/observability/protocol.logger.js";
|
|
13
|
-
import { resolveChatContext, error, redactSensitiveFields } from "../../../shared/agent/tool.helpers.js";
|
|
14
|
-
import { deriveAllowedNetworkIds, focusedIntentId, scopeFromNetworkId } from "../../../shared/agent/tool.scope.js";
|
|
15
|
-
import { invokeToolRuntime, toolRuntimeErrorToResult } from "../../../shared/agent/tool.runtime.js";
|
|
16
|
-
import { createEnrichmentTools } from "../../../enrichment/enrichment.tools.js";
|
|
17
|
-
import { createIntentTools } from "../signals/intent.tools.js";
|
|
18
|
-
import { createNetworkTools } from "../../../capabilities/communities.facade.js";
|
|
19
|
-
import { createOpportunityTools } from "../../../capabilities/opportunities.facade.js";
|
|
20
|
-
import { createUtilityTools } from "../../../shared/agent/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
|
-
// ═══════════════════════════════════════════════════════════════════════════════
|
|
32
|
-
/**
|
|
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.
|
|
39
|
-
*/
|
|
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,24 +0,0 @@
|
|
|
1
|
-
import type { ToolDeps, ToolRegistry } from '../../../shared/agent/tool.helpers.js';
|
|
2
|
-
import type { ToolSurface } from '../../../shared/agent/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
|
-
}
|
|
13
|
-
/**
|
|
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.
|
|
17
|
-
*
|
|
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.
|
|
21
|
-
*/
|
|
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,80 +0,0 @@
|
|
|
1
|
-
import { error, redactSensitiveFields } from '../../../shared/agent/tool.helpers.js';
|
|
2
|
-
import { createEnrichmentTools } from '../../../enrichment/enrichment.tools.js';
|
|
3
|
-
import { createIntentTools } from '../signals/intent.tools.js';
|
|
4
|
-
import { createNetworkTools } from '../../../capabilities/communities.facade.js';
|
|
5
|
-
import { createOpportunityTools } from '../../../capabilities/opportunities.facade.js';
|
|
6
|
-
import { createUtilityTools } from '../../../shared/agent/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 '../../../shared/observability/protocol.logger.js';
|
|
15
|
-
import { requestContext } from '../../../shared/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
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* runtime/foreground — IND-543 outer shell.
|
|
3
|
-
*
|
|
4
|
-
* Entry point for participant-directed (foreground) interaction composition:
|
|
5
|
-
* tool registry assembly, chat adapters, MCP adapters, persona adapters.
|
|
6
|
-
*
|
|
7
|
-
* Boundary: interaction-composition. May import from any capability via its
|
|
8
|
-
* capabilities/*.facade.ts contract. Must not import host implementations.
|
|
9
|
-
*
|
|
10
|
-
* Curated temporary alias — the canonical implementation lives here;
|
|
11
|
-
* shared/agent/tool.registry.ts is a backward-compat shim that delegates here.
|
|
12
|
-
*/
|
|
13
|
-
export { createToolRegistry } from './composition/tool.registry.js';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* runtime/foreground — IND-543 outer shell.
|
|
3
|
-
*
|
|
4
|
-
* Entry point for participant-directed (foreground) interaction composition:
|
|
5
|
-
* tool registry assembly, chat adapters, MCP adapters, persona adapters.
|
|
6
|
-
*
|
|
7
|
-
* Boundary: interaction-composition. May import from any capability via its
|
|
8
|
-
* capabilities/*.facade.ts contract. Must not import host implementations.
|
|
9
|
-
*
|
|
10
|
-
* Curated temporary alias — the canonical implementation lives here;
|
|
11
|
-
* shared/agent/tool.registry.ts is a backward-compat shim that delegates here.
|
|
12
|
-
*/
|
|
13
|
-
export { createToolRegistry } from './composition/tool.registry.js';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* runtime/foreground/signals/intent.tools — foreground signals-adapter seam.
|
|
3
|
-
*
|
|
4
|
-
* Canonical runtime registration point for intent/signal tools in the
|
|
5
|
-
* participant-facing (foreground) interaction layer. Re-exports the tool
|
|
6
|
-
* factory from the signals application layer so the foreground tool registry
|
|
7
|
-
* consumes the adapter rather than reaching directly into the signals
|
|
8
|
-
* implementation directory.
|
|
9
|
-
*
|
|
10
|
-
* Boundary: interaction-composition. Imports signals only via the signals
|
|
11
|
-
* application contracts; must not import host implementations.
|
|
12
|
-
*/
|
|
13
|
-
export { createIntentTools, setIntentClarifierForTesting, describeIntentUpdateFailure, } from "../../../signals/application/intent.tools.js";
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* runtime/foreground/signals/intent.tools — foreground signals-adapter seam.
|
|
3
|
-
*
|
|
4
|
-
* Canonical runtime registration point for intent/signal tools in the
|
|
5
|
-
* participant-facing (foreground) interaction layer. Re-exports the tool
|
|
6
|
-
* factory from the signals application layer so the foreground tool registry
|
|
7
|
-
* consumes the adapter rather than reaching directly into the signals
|
|
8
|
-
* implementation directory.
|
|
9
|
-
*
|
|
10
|
-
* Boundary: interaction-composition. Imports signals only via the signals
|
|
11
|
-
* application contracts; must not import host implementations.
|
|
12
|
-
*/
|
|
13
|
-
export { createIntentTools, setIntentClarifierForTesting, describeIntentUpdateFailure, } from "../../../signals/application/intent.tools.js";
|
package/dist/signals/index.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* signals — domain-first module root.
|
|
3
|
-
*
|
|
4
|
-
* Re-exports the curated public surface. Other modules inside the signals
|
|
5
|
-
* capability import directly from signals/domain, signals/application, or
|
|
6
|
-
* signals/ports; this barrel is for cross-capability consumers that must go
|
|
7
|
-
* through the signals public surface.
|
|
8
|
-
*
|
|
9
|
-
* IND-544: canonical home for intent/signal behaviour that was previously
|
|
10
|
-
* spread across intent/*. Legacy intent/* paths remain as compatibility
|
|
11
|
-
* re-exports pointing here.
|
|
12
|
-
*/
|
|
13
|
-
export * from "./public/index.js";
|