@indexnetwork/protocol 19.0.0-rc.482.1 → 20.0.0-rc.484.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 (35) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/IMPLEMENTATION.md +27 -10
  3. package/dist/index.d.ts +2 -3
  4. package/dist/index.js +4 -3
  5. package/dist/networks/{application/indexer.graph.d.ts → indexer.graph.d.ts} +11 -7
  6. package/dist/networks/{application/indexer.graph.js → indexer.graph.js} +6 -6
  7. package/dist/networks/{application/indexer.state.d.ts → indexer.state.d.ts} +7 -17
  8. package/dist/networks/{application/indexer.state.js → indexer.state.js} +6 -10
  9. package/dist/networks/{application/membership.graph.d.ts → membership.graph.d.ts} +2 -4
  10. package/dist/networks/{application/membership.graph.js → membership.graph.js} +3 -3
  11. package/dist/networks/{domain/membership.state.d.ts → membership.state.d.ts} +0 -2
  12. package/dist/networks/{domain/membership.state.js → membership.state.js} +0 -2
  13. package/dist/networks/{application/network.graph.d.ts → network.graph.d.ts} +2 -4
  14. package/dist/networks/{application/network.graph.js → network.graph.js} +3 -3
  15. package/dist/networks/network.module.d.ts +1314 -0
  16. package/dist/networks/network.module.js +83 -0
  17. package/dist/networks/{application/network.recommender.d.ts → network.recommender.d.ts} +0 -2
  18. package/dist/networks/{application/network.recommender.js → network.recommender.js} +4 -6
  19. package/dist/networks/{domain/network.state.d.ts → network.state.d.ts} +0 -2
  20. package/dist/networks/{domain/network.state.js → network.state.js} +0 -2
  21. package/dist/networks/{application/network.tools.d.ts → network.tools.d.ts} +5 -4
  22. package/dist/networks/{application/network.tools.js → network.tools.js} +5 -7
  23. package/dist/shared/agent/tool.factory.js +6 -6
  24. package/dist/shared/agent/tool.registry.js +2 -2
  25. package/package.json +1 -1
  26. package/dist/networks/application/index.d.ts +0 -45
  27. package/dist/networks/application/index.js +0 -50
  28. package/dist/networks/domain/index.d.ts +0 -29
  29. package/dist/networks/domain/index.js +0 -31
  30. package/dist/networks/index.d.ts +0 -9
  31. package/dist/networks/index.js +0 -8
  32. package/dist/networks/ports/communities.tools.port.d.ts +0 -5
  33. package/dist/networks/ports/communities.tools.port.js +0 -1
  34. package/dist/networks/ports/index.d.ts +0 -27
  35. package/dist/networks/ports/index.js +0 -23
package/CHANGELOG.md CHANGED
@@ -20,6 +20,36 @@ went 6.7.1 → 8.0.2 with no 7.x in between because the whole 7.x line shipped a
20
20
  prereleases between the two promotions. To track every change, read `rc`; to
21
21
  pin a supported release, use `latest`.
22
22
 
23
+ ## 20.0.0 - 2026-08-17
24
+
25
+ ### Changed
26
+
27
+ - **BREAKING**: The communities capability ships as one class, `Networks`,
28
+ mirroring `Intents`. `NetworkGraphFactory`, `NetworkMembershipGraphFactory`
29
+ and `IntentNetworkGraphFactory` are no longer exported from the package root;
30
+ construct `new Networks({ database, indexer })` and call `createGraph()`,
31
+ `createMembershipGraph()` or `createAssignmentGraph()`. `createNetworkTools`
32
+ is now `Networks.createTools`. Graph behaviour is unchanged.
33
+
34
+ ```typescript
35
+ // before
36
+ const indexGraph = new NetworkGraphFactory(database).createGraph();
37
+ const membershipGraph = new NetworkMembershipGraphFactory(database).createGraph();
38
+ const assignmentGraph = new IntentNetworkGraphFactory(database, intents).createGraph();
39
+
40
+ // after
41
+ const networks = new Networks({ database, indexer: intents });
42
+ const indexGraph = networks.createGraph();
43
+ const membershipGraph = networks.createMembershipGraph();
44
+ const assignmentGraph = networks.createAssignmentGraph();
45
+ ```
46
+
47
+ - `networks/` is flat: the `application/`, `domain/` and `ports/` directories are
48
+ gone, and `network.module.ts` is the capability's only public surface.
49
+ `NetworkToolDeps` now comes from that module rather than
50
+ `networks/ports/communities.tools.port.ts`, and the narrowed indexer port is
51
+ exported as `IntentNetworkIndexer`.
52
+
23
53
  ## 19.0.0 - 2026-08-17
24
54
 
25
55
  ### Removed
package/IMPLEMENTATION.md CHANGED
@@ -148,9 +148,6 @@ import {
148
148
  PremiseGraphFactory,
149
149
  NegotiationGraphFactory,
150
150
  HydeGraphFactory,
151
- NetworkGraphFactory,
152
- NetworkMembershipGraphFactory,
153
- IntentNetworkGraphFactory,
154
151
  RadarGraphFactory,
155
152
  MaintenanceGraphFactory,
156
153
  } from "@indexnetwork/protocol";
@@ -159,8 +156,9 @@ import {
159
156
  Each factory takes its typed dependencies in the constructor and exposes a
160
157
  `.createGraph()` method that returns a compiled LangGraph ready for `.invoke()`.
161
158
 
162
- The intent lifecycle graph is the exception: it is reached through the `Intents`
163
- module rather than a factory of its own (see [Intents](#intents) below).
159
+ The intent and community graphs are the exceptions: they are reached through the
160
+ `Intents` and `Networks` module classes rather than factories of their own (see
161
+ [Intents](#intents) and [Networks](#networks) below).
164
162
 
165
163
  | Factory | Workflow |
166
164
  |---|---|
@@ -170,9 +168,6 @@ module rather than a factory of its own (see [Intents](#intents) below).
170
168
  | `PremiseGraphFactory` | Decompose and index a user's premises |
171
169
  | `NegotiationGraphFactory` | Multi-turn bilateral negotiation flows |
172
170
  | `HydeGraphFactory` | Generate hypothetical documents and embed them (cache-aware) |
173
- | `NetworkGraphFactory` | Manage network/network CRUD |
174
- | `NetworkMembershipGraphFactory` | Manage network/network member join/leave |
175
- | `IntentNetworkGraphFactory` | Evaluate and assign/unassign intents to indexes |
176
171
  | `RadarGraphFactory` | Build the radar view: flat presenter-card list, optionally intent-scoped |
177
172
  | `MaintenanceGraphFactory` | Periodic maintenance (feed health, opportunity expiration) |
178
173
 
@@ -213,12 +208,34 @@ first use, so an unused method costs nothing.
213
208
  | `Intents.normalizeDescription(description)` | Normalize a description to its persisted form |
214
209
  | `Intents.FALLBACK_INTAKE_QUESTION` | The static round-1 question used when generation is unavailable |
215
210
 
216
- `IntentNetworkGraphFactory` takes an `Intents` instance as its evaluator:
211
+ ## Networks
212
+
213
+ Communities ship the same way: one class covering the community lifecycle graph,
214
+ the membership graph, signal↔community assignment, and the agent-facing
215
+ community tools.
217
216
 
218
217
  ```typescript
219
- const intentNetworkGraph = new IntentNetworkGraphFactory(database, intents).createGraph();
218
+ import { Networks } from "@indexnetwork/protocol";
219
+
220
+ const networks = new Networks({
221
+ database, // community, roster, and assignment persistence
222
+ indexer: intents, // an `Intents` instance — scores a signal against a community
223
+ });
220
224
  ```
221
225
 
226
+ Both dependencies are optional; each method names what it requires, so a host
227
+ that only registers tools can construct `new Networks()` with nothing.
228
+
229
+ | Method | Purpose |
230
+ |---|---|
231
+ | `createGraph()` | Compile the community lifecycle graph — create, read, update, delete. Requires `database` |
232
+ | `createMembershipGraph()` | Compile the roster graph — add, list, remove members. Requires `database` |
233
+ | `createAssignmentGraph()` | Compile signal↔community assignment, direct or model-evaluated. Requires `database` and `indexer` |
234
+ | `Networks.createTools(defineTool, deps)` | Register the agent-facing community tools |
235
+
236
+ Assignment takes an `Intents` instance as its evaluator — the `indexer`
237
+ dependency is narrowed to the single `indexIntent` method it calls.
238
+
222
239
  ## MCP server
223
240
 
224
241
  The package exports a factory that registers every chat tool over the Model Context Protocol and attaches a canonical `instructions` block (`MCP_INSTRUCTIONS`) that every connecting runtime follows. The factory takes three arguments:
package/dist/index.d.ts CHANGED
@@ -39,9 +39,8 @@ export { REPORTER_PERSONA_ID, REPORTER_PERSONA, REPORTER_BRIEFING_KICKOFF, } fro
39
39
  export { ONBOARDING_PERSONA_ID, ONBOARDING_PERSONA, } from "./agents/index.js";
40
40
  export { RadarGraphFactory } from "./opportunities/index.js";
41
41
  export { HydeGraphFactory } from "./discovery/index.js";
42
- export { NetworkGraphFactory } from "./networks/index.js";
43
- export { NetworkMembershipGraphFactory } from "./networks/index.js";
44
- export { IntentNetworkGraphFactory } from "./networks/index.js";
42
+ export { Networks } from "./networks/network.module.js";
43
+ export type { IntentNetworkIndexer, NetworksDeps, NetworkToolDeps, } from "./networks/network.module.js";
45
44
  export { Intents } from "./intents/intent.module.js";
46
45
  export type { FollowUpPlan, FollowUpPlanInput, IntakeAnswer, IntakePack, IntakePackInput, IntakePackQuestion, IntakePackQuestionOption, IntakeRound, IntentIndexerOutput, IntentsDeps, IntentToolDeps, SynthesisInput, SynthesisResult, } from "./intents/intent.module.js";
47
46
  export { MaintenanceGraphFactory } from "./maintenance/maintenance.graph.js";
package/dist/index.js CHANGED
@@ -35,9 +35,10 @@ export { REPORTER_PERSONA_ID, REPORTER_PERSONA, REPORTER_BRIEFING_KICKOFF, } fro
35
35
  export { ONBOARDING_PERSONA_ID, ONBOARDING_PERSONA, } from "./agents/index.js";
36
36
  export { RadarGraphFactory } from "./opportunities/index.js";
37
37
  export { HydeGraphFactory } from "./discovery/index.js";
38
- export { NetworkGraphFactory } from "./networks/index.js";
39
- export { NetworkMembershipGraphFactory } from "./networks/index.js";
40
- export { IntentNetworkGraphFactory } from "./networks/index.js";
38
+ // ─── Networks ─────────────────────────────────────────────────────────────────
39
+ // The whole capability behind one class: the community lifecycle graph, the
40
+ // membership graph, signal assignment, and the agent-facing tools.
41
+ export { Networks } from "./networks/network.module.js";
41
42
  // ─── Intents ──────────────────────────────────────────────────────────────────
42
43
  // The whole capability behind one class: lifecycle graph, verification,
43
44
  // network indexing, guided intake, and the agent-facing tools.
@@ -1,7 +1,14 @@
1
- import type { IntentNetworkGraphDatabase } from "../ports/index.js";
2
- import type { DebugMetaAgent } from "../../agents/index.js";
3
- import type { IntentNetworkIndexer } from "../ports/index.js";
1
+ import type { IntentNetworkGraphDatabase } from "../shared/interfaces/database.interface.js";
2
+ import type { DebugMetaAgent } from "../agents/index.js";
3
+ import type { Intents } from "../intents/intent.module.js";
4
4
  import { IntentNetworkGraphState, type AssignmentResult } from "./indexer.state.js";
5
+ /**
6
+ * The one intents method assignment calls: score a signal against a network.
7
+ *
8
+ * Naming the single method rather than accepting the whole capability keeps the
9
+ * injected surface auditable, and lets a test pass a one-method stub.
10
+ */
11
+ export type IntentNetworkIndexer = Pick<Intents, "indexIntent">;
5
12
  /**
6
13
  * Factory class to build and compile the Intent–Network (indexer) Graph.
7
14
  *
@@ -12,7 +19,7 @@ import { IntentNetworkGraphState, type AssignmentResult } from "./indexer.state.
12
19
  *
13
20
  * ## Signal assignment policy
14
21
  *
15
- * The indexer is injected at construction time via the communities ports layer,
22
+ * The indexer is injected at construction time as {@link IntentNetworkIndexer},
16
23
  * which narrows the intents module to the one method used here — this factory
17
24
  * never reaches intents internals directly.
18
25
  *
@@ -40,9 +47,6 @@ import { IntentNetworkGraphState, type AssignmentResult } from "./indexer.state.
40
47
  * read: readNode → END
41
48
  * delete: unassignNode → END
42
49
  * }
43
- *
44
- * IND-546: canonical home — previously network/indexer/indexer.graph.ts.
45
- * Signals dependency consumed via capabilities/signals.facade.ts (through ports).
46
50
  */
47
51
  /** The graph's channel state, as every node sees it. */
48
52
  export type IntentNetworkState = typeof IntentNetworkGraphState.State;
@@ -1,9 +1,9 @@
1
1
  import { StateGraph, START, END } from "@langchain/langgraph";
2
- import { buildNetworkAssignmentDecision } from "../../shared/assignment/network-assignment.policy.js";
3
- import { protocolLogger } from "../../shared/observability/protocol.logger.js";
4
- import { timed } from "../../shared/observability/performance.js";
5
- import { requestContext } from "../../shared/observability/request-context.js";
6
- import { renderNetworkContext } from "../../shared/network/metadata.renderer.js";
2
+ import { buildNetworkAssignmentDecision } from "../shared/assignment/network-assignment.policy.js";
3
+ import { protocolLogger } from "../shared/observability/protocol.logger.js";
4
+ import { timed } from "../shared/observability/performance.js";
5
+ import { requestContext } from "../shared/observability/request-context.js";
6
+ import { renderNetworkContext } from "../shared/network/metadata.renderer.js";
7
7
  import { IntentNetworkGraphState } from "./indexer.state.js";
8
8
  const logger = protocolLogger("IntentNetworkGraphFactory");
9
9
  export class IntentNetworkGraphFactory {
@@ -141,7 +141,7 @@ export async function assignNode(state, deps) {
141
141
  const sourceName = intentForIndexing.sourceType
142
142
  ? `${intentForIndexing.sourceType}:${intentForIndexing.sourceId ?? ""}`
143
143
  : undefined;
144
- // Score the signal against the network (intents module, injected via ports)
144
+ // Score the signal against the network (intents module, injected as IntentNetworkIndexer)
145
145
  const _traceEmitter = requestContext.getStore()?.traceEmitter;
146
146
  const _indexerStart = Date.now();
147
147
  _traceEmitter?.({ type: "agent_start", name: "intent-networker" });
@@ -1,9 +1,7 @@
1
- import type { DebugMetaAgent } from "../../agents/index.js";
1
+ import type { DebugMetaAgent } from "../agents/index.js";
2
2
  /**
3
3
  * Intent payload and metadata loaded for network evaluation.
4
4
  * Loaded from the database before LLM-based assignment scoring.
5
- *
6
- * IND-546: canonical home — previously network/indexer/indexer.state.ts.
7
5
  */
8
6
  export interface IntentForIndexing {
9
7
  id: string;
@@ -15,8 +13,6 @@ export interface IntentForIndexing {
15
13
  /**
16
14
  * Index and member prompts for a single network (user must be member with autoAssign).
17
15
  * Used by the evaluated assignment path in IntentNetworkGraphFactory.
18
- *
19
- * IND-546: canonical home — previously network/indexer/indexer.state.ts.
20
16
  */
21
17
  export interface IndexMemberContext {
22
18
  networkId: string;
@@ -26,8 +22,6 @@ export interface IndexMemberContext {
26
22
  /**
27
23
  * Result of executing an assignment decision.
28
24
  * Returned from the assign node as a structured output alongside mutationResult.
29
- *
30
- * IND-546: canonical home — previously network/indexer/indexer.state.ts.
31
25
  */
32
26
  export interface AssignmentResult {
33
27
  networkId: string;
@@ -44,13 +38,13 @@ export interface AssignmentResult {
44
38
  * Two assignment paths, selected via `skipEvaluation`:
45
39
  * - `true` (direct / manual_override): writes the link immediately with a fixed
46
40
  * score of 1 and mode `manual_override`. No LLM call.
47
- * - `false` (automatic / evaluated): loads intent + network context, calls
48
- * IntentIndexer from the signals public facade, then applies
49
- * `buildNetworkAssignmentDecision` to produce the threshold / metadata.
50
- * A no-prompt fast path skips the LLM when both prompts are absent.
41
+ * - `false` (automatic / evaluated): loads intent + network context, calls the
42
+ * injected indexer, then applies `buildNetworkAssignmentDecision` to produce
43
+ * the threshold / metadata. A no-prompt fast path skips the LLM when both
44
+ * prompts are absent.
51
45
  *
52
- * The IntentIndexer is injected as a constructor argument — communities never
53
- * imports signals internals directly.
46
+ * The indexer is injected as a constructor argument — communities never imports
47
+ * signals internals directly.
54
48
  *
55
49
  * Flow:
56
50
  * START → router → {
@@ -58,10 +52,6 @@ export interface AssignmentResult {
58
52
  * read: readNode → END
59
53
  * delete: unassignNode → END
60
54
  * }
61
- *
62
- * IND-546: canonical home — previously network/indexer/indexer.state.ts.
63
- * LangGraph state carries IntentIndexerOutput and DebugMetaAgent which are
64
- * cross-capability types; this file therefore belongs in the application layer.
65
55
  */
66
56
  export declare const IntentNetworkGraphState: import("@langchain/langgraph").AnnotationRoot<{
67
57
  /** User performing the action. Always required. */
@@ -8,13 +8,13 @@ import { Annotation } from "@langchain/langgraph";
8
8
  * Two assignment paths, selected via `skipEvaluation`:
9
9
  * - `true` (direct / manual_override): writes the link immediately with a fixed
10
10
  * score of 1 and mode `manual_override`. No LLM call.
11
- * - `false` (automatic / evaluated): loads intent + network context, calls
12
- * IntentIndexer from the signals public facade, then applies
13
- * `buildNetworkAssignmentDecision` to produce the threshold / metadata.
14
- * A no-prompt fast path skips the LLM when both prompts are absent.
11
+ * - `false` (automatic / evaluated): loads intent + network context, calls the
12
+ * injected indexer, then applies `buildNetworkAssignmentDecision` to produce
13
+ * the threshold / metadata. A no-prompt fast path skips the LLM when both
14
+ * prompts are absent.
15
15
  *
16
- * The IntentIndexer is injected as a constructor argument — communities never
17
- * imports signals internals directly.
16
+ * The indexer is injected as a constructor argument — communities never imports
17
+ * signals internals directly.
18
18
  *
19
19
  * Flow:
20
20
  * START → router → {
@@ -22,10 +22,6 @@ import { Annotation } from "@langchain/langgraph";
22
22
  * read: readNode → END
23
23
  * delete: unassignNode → END
24
24
  * }
25
- *
26
- * IND-546: canonical home — previously network/indexer/indexer.state.ts.
27
- * LangGraph state carries IntentIndexerOutput and DebugMetaAgent which are
28
- * cross-capability types; this file therefore belongs in the application layer.
29
25
  */
30
26
  export const IntentNetworkGraphState = Annotation.Root({
31
27
  // --- Core Inputs (from ChatGraph via ToolContext) ---
@@ -1,5 +1,5 @@
1
- import type { NetworkMembershipGraphDatabase } from "../ports/index.js";
2
- import { NetworkMembershipGraphState } from "../domain/index.js";
1
+ import type { NetworkMembershipGraphDatabase } from "../shared/interfaces/database.interface.js";
2
+ import { NetworkMembershipGraphState } from "./membership.state.js";
3
3
  /**
4
4
  * Factory class to build and compile the Network Membership Graph.
5
5
  *
@@ -26,8 +26,6 @@ import { NetworkMembershipGraphState } from "../domain/index.js";
26
26
  *
27
27
  * Flow:
28
28
  * START → routerNode → {addMemberNode | listMembersNode | removeMemberNode} → END
29
- *
30
- * IND-546: canonical home — previously network/membership/membership.graph.ts.
31
29
  */
32
30
  /** The graph's channel state, as every node sees it. */
33
31
  export type NetworkMembershipState = typeof NetworkMembershipGraphState.State;
@@ -1,7 +1,7 @@
1
1
  import { StateGraph, START, END } from "@langchain/langgraph";
2
- import { protocolLogger } from "../../shared/observability/protocol.logger.js";
3
- import { timed } from "../../shared/observability/performance.js";
4
- import { NetworkMembershipGraphState } from "../domain/index.js";
2
+ import { protocolLogger } from "../shared/observability/protocol.logger.js";
3
+ import { timed } from "../shared/observability/performance.js";
4
+ import { NetworkMembershipGraphState } from "./membership.state.js";
5
5
  const logger = protocolLogger("NetworkMembershipGraphFactory");
6
6
  export class NetworkMembershipGraphFactory {
7
7
  constructor(database) {
@@ -13,8 +13,6 @@
13
13
  *
14
14
  * Flow:
15
15
  * START → routerNode → {addMemberNode | listMembersNode | removeMemberNode} → END
16
- *
17
- * IND-546: canonical home — previously network/membership/membership.state.ts.
18
16
  */
19
17
  export declare const NetworkMembershipGraphState: import("@langchain/langgraph").AnnotationRoot<{
20
18
  /** User performing the action (the actor). Always required. */
@@ -14,8 +14,6 @@ import { Annotation } from "@langchain/langgraph";
14
14
  *
15
15
  * Flow:
16
16
  * START → routerNode → {addMemberNode | listMembersNode | removeMemberNode} → END
17
- *
18
- * IND-546: canonical home — previously network/membership/membership.state.ts.
19
17
  */
20
18
  export const NetworkMembershipGraphState = Annotation.Root({
21
19
  // --- Core Inputs (from ChatGraph via ToolContext) ---
@@ -1,5 +1,5 @@
1
- import type { NetworkGraphDatabase } from "../ports/index.js";
2
- import { NetworkGraphState } from "../domain/index.js";
1
+ import type { NetworkGraphDatabase } from "../shared/interfaces/database.interface.js";
2
+ import { NetworkGraphState } from "./network.state.js";
3
3
  /**
4
4
  * Factory class to build and compile the Network (community) lifecycle graph.
5
5
  *
@@ -25,8 +25,6 @@ import { NetworkGraphState } from "../domain/index.js";
25
25
  *
26
26
  * Flow:
27
27
  * START → routerNode → {createNode | readNode | updateNode | deleteNode} → END
28
- *
29
- * IND-546: canonical home — previously network/network.graph.ts.
30
28
  */
31
29
  /** The graph's channel state, as every node sees it. */
32
30
  export type NetworkState = typeof NetworkGraphState.State;
@@ -1,7 +1,7 @@
1
1
  import { StateGraph, START, END } from "@langchain/langgraph";
2
- import { protocolLogger } from "../../shared/observability/protocol.logger.js";
3
- import { timed } from "../../shared/observability/performance.js";
4
- import { NetworkGraphState } from "../domain/index.js";
2
+ import { protocolLogger } from "../shared/observability/protocol.logger.js";
3
+ import { timed } from "../shared/observability/performance.js";
4
+ import { NetworkGraphState } from "./network.state.js";
5
5
  const logger = protocolLogger("NetworkGraphFactory");
6
6
  export class NetworkGraphFactory {
7
7
  constructor(database) {