@indexnetwork/protocol 14.3.2-rc.477.1 → 17.0.0-rc.479.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 (184) hide show
  1. package/CHANGELOG.md +141 -0
  2. package/IMPLEMENTATION.md +50 -52
  3. package/STABILITY.md +3 -3
  4. package/dist/chat/chat.agent.js +2 -3
  5. package/dist/chat/chat.graph.d.ts +41 -1
  6. package/dist/chat/chat.graph.js +108 -127
  7. package/dist/chat/negotiator.persona.d.ts +1 -1
  8. package/dist/chat/negotiator.persona.js +1 -4
  9. package/dist/chat/negotiator.prompt.js +1 -2
  10. package/dist/chat/onboarding.persona.js +0 -1
  11. package/dist/chat/reporter.persona.js +0 -1
  12. package/dist/chat/signal.persona.js +0 -1
  13. package/dist/contacts/application/contact.tools.d.ts +6 -9
  14. package/dist/contacts/application/contact.tools.js +11 -92
  15. package/dist/contacts/application/index.d.ts +2 -14
  16. package/dist/contacts/application/index.js +2 -13
  17. package/dist/contacts/domain/contact.types.d.ts +0 -23
  18. package/dist/contacts/domain/index.d.ts +2 -6
  19. package/dist/contacts/index.d.ts +1 -1
  20. package/dist/contacts/index.js +1 -1
  21. package/dist/contacts/ports/contact.repository.port.d.ts +5 -12
  22. package/dist/contacts/ports/contact.repository.port.js +4 -6
  23. package/dist/contacts/ports/contact.tools.port.d.ts +1 -3
  24. package/dist/contacts/ports/contact.tools.port.js +1 -2
  25. package/dist/contacts/ports/index.d.ts +1 -1
  26. package/dist/contacts/ports/index.js +1 -1
  27. package/dist/discovery/hyde.frame.d.ts +4 -4
  28. package/dist/discovery/hyde.graph.d.ts +71 -12
  29. package/dist/discovery/hyde.graph.js +337 -335
  30. package/dist/discovery/lens.inferrer.d.ts +6 -6
  31. package/dist/enrichment/enrichment.graph.d.ts +127 -9
  32. package/dist/enrichment/enrichment.graph.js +633 -655
  33. package/dist/enrichment/enrichment.state.d.ts +1 -1
  34. package/dist/enrichment/enrichment.tools.context-read.d.ts +10 -0
  35. package/dist/enrichment/enrichment.tools.context-read.js +353 -0
  36. package/dist/enrichment/enrichment.tools.context-write.d.ts +9 -0
  37. package/dist/enrichment/enrichment.tools.context-write.js +417 -0
  38. package/dist/enrichment/enrichment.tools.d.ts +11 -1
  39. package/dist/enrichment/enrichment.tools.helpers.d.ts +139 -0
  40. package/dist/enrichment/enrichment.tools.helpers.js +234 -0
  41. package/dist/enrichment/enrichment.tools.js +16 -975
  42. package/dist/index.d.ts +27 -50
  43. package/dist/index.js +17 -28
  44. package/dist/intents/application/intent.graph.d.ts +71 -67
  45. package/dist/intents/application/intent.graph.execute.d.ts +59 -0
  46. package/dist/intents/application/intent.graph.execute.js +301 -0
  47. package/dist/intents/application/intent.graph.infer.d.ts +44 -0
  48. package/dist/intents/application/intent.graph.infer.js +97 -0
  49. package/dist/intents/application/intent.graph.js +96 -888
  50. package/dist/intents/application/intent.graph.reconcile.d.ts +71 -0
  51. package/dist/intents/application/intent.graph.reconcile.js +274 -0
  52. package/dist/intents/application/intent.graph.shared.d.ts +70 -0
  53. package/dist/intents/application/intent.graph.shared.js +153 -0
  54. package/dist/intents/domain/intent.state.d.ts +1 -1
  55. package/dist/maintenance/maintenance.graph.d.ts +66 -3
  56. package/dist/maintenance/maintenance.graph.js +155 -156
  57. package/dist/mcp/mcp.authorization-policy.d.ts +24 -28
  58. package/dist/mcp/mcp.authorization-policy.js +14 -34
  59. package/dist/mcp/mcp.server.d.ts +3 -3
  60. package/dist/mcp/mcp.server.js +14 -20
  61. package/dist/negotiations/application/negotiation.candidates.d.ts +83 -0
  62. package/dist/negotiations/application/negotiation.candidates.js +162 -0
  63. package/dist/negotiations/application/negotiation.graph.d.ts +91 -157
  64. package/dist/negotiations/application/negotiation.graph.finalize.d.ts +5 -0
  65. package/dist/negotiations/application/negotiation.graph.finalize.js +280 -0
  66. package/dist/negotiations/application/negotiation.graph.init.d.ts +54 -0
  67. package/dist/negotiations/application/negotiation.graph.init.js +227 -0
  68. package/dist/negotiations/application/negotiation.graph.js +69 -1388
  69. package/dist/negotiations/application/negotiation.graph.screen.d.ts +23 -0
  70. package/dist/negotiations/application/negotiation.graph.screen.js +108 -0
  71. package/dist/negotiations/application/negotiation.graph.shared.d.ts +75 -0
  72. package/dist/negotiations/application/negotiation.graph.shared.js +125 -0
  73. package/dist/negotiations/application/negotiation.graph.turn.d.ts +105 -0
  74. package/dist/negotiations/application/negotiation.graph.turn.js +484 -0
  75. package/dist/negotiations/domain/negotiation.state.d.ts +1 -1
  76. package/dist/negotiations/domain/negotiation.state.js +0 -1
  77. package/dist/networks/application/indexer.graph.d.ts +165 -7
  78. package/dist/networks/application/indexer.graph.js +339 -388
  79. package/dist/networks/application/indexer.state.d.ts +1 -1
  80. package/dist/networks/application/membership.graph.d.ts +83 -5
  81. package/dist/networks/application/membership.graph.js +177 -207
  82. package/dist/networks/application/network.graph.d.ts +148 -5
  83. package/dist/networks/application/network.graph.js +249 -278
  84. package/dist/networks/domain/membership.state.d.ts +1 -1
  85. package/dist/networks/domain/network.state.d.ts +1 -1
  86. package/dist/opportunities/application/delivery-card.cache.d.ts +1 -1
  87. package/dist/opportunities/application/delivery-card.cache.js +2 -2
  88. package/dist/opportunities/application/index.d.ts +2 -2
  89. package/dist/opportunities/application/index.js +2 -2
  90. package/dist/opportunities/application/opportunity.evaluator.js +1 -1
  91. package/dist/opportunities/application/opportunity.graph.d.ts +686 -473
  92. package/dist/opportunities/application/opportunity.graph.discovery-strategies.d.ts +109 -0
  93. package/dist/opportunities/application/opportunity.graph.discovery-strategies.js +451 -0
  94. package/dist/opportunities/application/opportunity.graph.discovery.d.ts +69 -0
  95. package/dist/opportunities/application/opportunity.graph.discovery.js +397 -0
  96. package/dist/opportunities/application/opportunity.graph.evaluation.d.ts +82 -0
  97. package/dist/opportunities/application/opportunity.graph.evaluation.js +608 -0
  98. package/dist/opportunities/application/opportunity.graph.js +120 -3690
  99. package/dist/opportunities/application/opportunity.graph.modes.d.ts +538 -0
  100. package/dist/opportunities/application/opportunity.graph.modes.js +538 -0
  101. package/dist/opportunities/application/opportunity.graph.negotiate.d.ts +109 -0
  102. package/dist/opportunities/application/opportunity.graph.negotiate.js +392 -0
  103. package/dist/opportunities/application/opportunity.graph.persist-node.d.ts +93 -0
  104. package/dist/opportunities/application/opportunity.graph.persist-node.js +765 -0
  105. package/dist/opportunities/application/opportunity.graph.prep.d.ts +150 -0
  106. package/dist/opportunities/application/opportunity.graph.prep.js +381 -0
  107. package/dist/opportunities/application/opportunity.graph.shared.d.ts +173 -0
  108. package/dist/opportunities/application/opportunity.graph.shared.js +199 -0
  109. package/dist/opportunities/application/opportunity.presentation.d.ts +399 -0
  110. package/dist/opportunities/application/{opportunity.presenter.js → opportunity.presentation.js} +735 -9
  111. package/dist/opportunities/application/opportunity.tools.cards.d.ts +152 -0
  112. package/dist/opportunities/application/opportunity.tools.cards.js +235 -0
  113. package/dist/opportunities/application/opportunity.tools.d.ts +8 -114
  114. package/dist/opportunities/application/opportunity.tools.js +28 -711
  115. package/dist/opportunities/application/opportunity.tools.list.d.ts +10 -0
  116. package/dist/opportunities/application/opportunity.tools.list.js +493 -0
  117. package/dist/opportunities/domain/index.d.ts +3 -3
  118. package/dist/opportunities/domain/index.js +3 -3
  119. package/dist/opportunities/domain/opportunity.state.d.ts +19 -19
  120. package/dist/opportunities/index.d.ts +6 -6
  121. package/dist/opportunities/index.js +4 -4
  122. package/dist/opportunities/ports/opportunity.tools.port.d.ts +1 -1
  123. package/dist/opportunities/radar/radar.graph.d.ts +57 -13
  124. package/dist/opportunities/radar/radar.graph.js +470 -471
  125. package/dist/premises/premise.graph.d.ts +88 -20
  126. package/dist/premises/premise.graph.js +207 -218
  127. package/dist/questions/domain/question.schema.d.ts +40 -40
  128. package/dist/shared/agent/tool.factory.js +0 -8
  129. package/dist/shared/agent/tool.helpers.d.ts +21 -45
  130. package/dist/shared/agent/tool.helpers.js +1 -2
  131. package/dist/shared/agent/tool.registry.d.ts +4 -3
  132. package/dist/shared/agent/tool.registry.js +2 -4
  133. package/dist/shared/agent/tool.runtime.js +0 -2
  134. package/dist/shared/agent/utility.tools.js +9 -13
  135. package/dist/shared/interfaces/database.capabilities.d.ts +100 -0
  136. package/dist/shared/interfaces/database.capabilities.js +7 -0
  137. package/dist/shared/interfaces/database.entities.d.ts +533 -0
  138. package/dist/shared/interfaces/database.entities.js +10 -0
  139. package/dist/shared/interfaces/database.identity-queries.d.ts +294 -0
  140. package/dist/shared/interfaces/database.identity-queries.js +4 -0
  141. package/dist/shared/interfaces/database.interface.d.ts +15 -2277
  142. package/dist/shared/interfaces/database.interface.js +8 -0
  143. package/dist/shared/interfaces/database.member-queries.d.ts +221 -0
  144. package/dist/shared/interfaces/database.member-queries.js +4 -0
  145. package/dist/shared/interfaces/database.negotiation.d.ts +305 -0
  146. package/dist/shared/interfaces/database.negotiation.js +26 -0
  147. package/dist/shared/interfaces/database.network-queries.d.ts +277 -0
  148. package/dist/shared/interfaces/database.network-queries.js +4 -0
  149. package/dist/shared/interfaces/database.opportunity-queries.d.ts +285 -0
  150. package/dist/shared/interfaces/database.opportunity-queries.js +4 -0
  151. package/dist/shared/interfaces/database.port.d.ts +322 -0
  152. package/dist/shared/interfaces/database.port.js +29 -0
  153. package/dist/shared/schemas/discovery-question.schema.d.ts +14 -14
  154. package/dist/shared/schemas/negotiation-digest.schema.d.ts +2 -2
  155. package/package.json +2 -15
  156. package/dist/contacts/application/contact.inviter.d.ts +0 -49
  157. package/dist/contacts/application/contact.inviter.js +0 -64
  158. package/dist/integrations/application/index.d.ts +0 -14
  159. package/dist/integrations/application/index.js +0 -14
  160. package/dist/integrations/application/integration.tools.d.ts +0 -27
  161. package/dist/integrations/application/integration.tools.js +0 -98
  162. package/dist/integrations/domain/index.d.ts +0 -16
  163. package/dist/integrations/domain/index.js +0 -1
  164. package/dist/integrations/domain/integration.types.d.ts +0 -51
  165. package/dist/integrations/domain/integration.types.js +0 -9
  166. package/dist/integrations/index.d.ts +0 -10
  167. package/dist/integrations/index.js +0 -8
  168. package/dist/integrations/ports/index.d.ts +0 -25
  169. package/dist/integrations/ports/index.js +0 -23
  170. package/dist/integrations/ports/integration.adapter.port.d.ts +0 -62
  171. package/dist/integrations/ports/integration.adapter.port.js +0 -15
  172. package/dist/integrations/ports/integration.importer.port.d.ts +0 -31
  173. package/dist/integrations/ports/integration.importer.port.js +0 -15
  174. package/dist/integrations/ports/integration.tools.port.d.ts +0 -25
  175. package/dist/integrations/ports/integration.tools.port.js +0 -18
  176. package/dist/opportunities/application/opportunity.card-presentation.d.ts +0 -44
  177. package/dist/opportunities/application/opportunity.card-presentation.js +0 -93
  178. package/dist/opportunities/application/opportunity.presenter.d.ts +0 -156
  179. package/dist/opportunities/domain/opportunity.presentation-cache.d.ts +0 -5
  180. package/dist/opportunities/domain/opportunity.presentation-cache.js +0 -11
  181. package/dist/opportunities/domain/opportunity.presentation.d.ts +0 -76
  182. package/dist/opportunities/domain/opportunity.presentation.js +0 -516
  183. package/dist/opportunities/domain/opportunity.safe-presentation.d.ts +0 -104
  184. package/dist/opportunities/domain/opportunity.safe-presentation.js +0 -102
package/CHANGELOG.md CHANGED
@@ -20,6 +20,146 @@ 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
+ ## 17.0.0 - 2026-08-17
24
+
25
+ ### Removed
26
+
27
+ - **BREAKING**: Remove the `integrations` capability entirely
28
+ (`src/integrations/`) and its public exports: `IntegrationAdapter`,
29
+ `IntegrationConnection`, `IntegrationSession`, `IntegrationSessionOptions`,
30
+ `ToolActionResponse`. Hosts that typed a Composio adapter against these
31
+ should declare the shape locally — `services/api` already carries a
32
+ structurally identical copy in `adapters/integration.adapter.ts`.
33
+ - **BREAKING**: Remove `generateInviteMessage` (and `InviteInput` /
34
+ `InviteOutput`). It generated outreach copy for ghost-user counterparts and
35
+ required `recipient.isGhost`; with ghost users retired it can never fire.
36
+ - **BREAKING**: Remove the `import_gmail_contacts`, `import_contacts` and
37
+ `add_contact` tools. These were the only paths that minted ghost users.
38
+ Contacts are now established solely by accepting an opportunity, which writes
39
+ the mutual `contact` memberships. `list_contacts`, `remove_contact` and
40
+ `search_contacts` are unchanged.
41
+ - **BREAKING**: Remove `contactsEnabled` from `ToolDeps`, the tool-registry
42
+ composition deps, and `resolveChatContext`. The `CONTACTS_ENABLED` flag gated
43
+ only the removed write paths and no longer exists.
44
+ - **BREAKING**: Remove `integration` and `integrationImporter` from `ToolDeps`.
45
+ Nothing in the protocol consumed them once the integration tools were removed.
46
+ - Remove `createGhostUser` from the database interface. No protocol code path
47
+ creates users any more.
48
+
49
+ ### Changed
50
+
51
+ - `ContactServiceAdapter` narrows to `listContacts` / `removeContact` /
52
+ `searchContacts`; `importContacts` and `addContact` are gone, along with the
53
+ `ContactInput`, `ContactResult` and `ContactImportResult` domain types.
54
+ - Orchestrator, negotiator, signal and onboarding prompt surfaces no longer
55
+ advertise contact import or Gmail import.
56
+
57
+ ## 16.1.0 - 2026-08-17
58
+
59
+ ### Removed
60
+
61
+ - Remove the eval harnesses (`eval/`) and the 13 `eval:*` package scripts. No
62
+ public API change: `src/` never imported `eval/`, so the package build,
63
+ architecture gates and source tests are unaffected. The final state is
64
+ preserved in the `archive/eval-2026-08-16` tag; restore with
65
+ `git checkout archive/eval-2026-08-16 -- packages/protocol/eval`.
66
+
67
+ ## 16.0.0 - 2026-08-17
68
+
69
+ ### Removed
70
+
71
+ - **Breaking:** MCP no longer gates on web/CLI onboarding. Incomplete
72
+ onboarding does not restrict the MCP inventory, `onboarding_human` and
73
+ `onboarding_required` are gone, and `complete_onboarding` is omitted from
74
+ the MCP registry. `read_user_contexts` no longer returns
75
+ `onboardingComplete` on MCP. Web onboarding chat and the REST Tool API
76
+ keep the existing completion flow.
77
+
78
+ ## 15.0.0 - 2026-08-17
79
+
80
+ Public-surface prune. `src/index.ts` goes from 443 exported symbols across 164
81
+ export statements to 312 across 143. No implementation changed: every removed
82
+ symbol still exists and still works inside the package — it is simply no longer
83
+ re-exported from the barrel.
84
+
85
+ A symbol was kept whenever a retained export could not be *used* without it —
86
+ parameter and member types of exported functions, interfaces, and unions stay
87
+ public even with no direct importer, because an exported symbol whose members
88
+ cannot be named is not usable.
89
+
90
+ The removal set was derived by parsing every barrel export and resolving it
91
+ against every consumer reference in `services/`, `apps/`, `packages/*`,
92
+ `docs/`, `.claude/`, and the protocol's own `eval/` and `skills/` trees —
93
+ covering static named imports, `import type` queries, `import('...').Sym` type
94
+ positions, `await import()` destructuring, namespace aliases, and `mock.module`
95
+ shapes. A symbol was removed only when nothing outside the package imported it
96
+ from the package root.
97
+
98
+ ### Removed from the public API (BREAKING)
99
+
100
+ 131 symbols. None were deleted; all remain internal. The largest groups:
101
+
102
+ - **Capability tool factories** — `createChatTools`, `createAgentTools`,
103
+ `createIntentTools`, `createNetworkTools`, `createOpportunityTools`,
104
+ `createNegotiationTools`, `createQuestionerTools`,
105
+ `createAskUserQuestionTools`, `createContactTools`, `createIntegrationTools`,
106
+ `createPremiseTools`, and their `*ToolDeps` types. These are composed
107
+ internally by `createMcpServer` / `createToolRegistry`, which remain public.
108
+ `createEnrichmentTools` and `EnrichmentToolDeps` stay exported — the API
109
+ service calls them directly from its enrichment-run worker.
110
+ - **MCP authorization policy** — 27 symbols from `mcp/mcp.authorization-policy.ts`
111
+ (`MCP_AGENT_ADMIN_TOOLS`, `McpCapabilityPolicy`, `McpToolAccessRuleSchema`,
112
+ `defineMcpToolAccessRules`, the `Mcp*` policy types, …). Four stay public
113
+ because a host cannot type its own `createMcpServer` call without them:
114
+ `CANONICAL_MCP_CAPABILITY_POLICY_OPTIONS`, `McpCapabilityPolicyOptions` (the
115
+ fourth parameter), `McpAuthorizationObserver`, and
116
+ `McpAuthorizationDenialEvent` (the observer callback's only argument).
117
+ - **Activity projection** — 15 symbols from `shared/agent/activity-projection.ts`
118
+ (`projectActivitySummary`, `ActivitySummaryResponseSchema`,
119
+ `QUESTION_MODE_TO_DOMAIN`, `READ_ACTIVITY_SUMMARY_TOOL_NAME`, …).
120
+ - **Persona helpers** — the `filter*Tools` / `narrow*Tools` helpers, the
121
+ `*_TOOL_NAMES` constants, and the `SIGNAL_NEW_SIGNAL_KICKOFF` /
122
+ `ONBOARDING_PROFILE_KICKOFF` constants. The persona IDs, the prompt
123
+ constants, and `REPORTER_BRIEFING_KICKOFF` stay — `apps/web` imports the
124
+ latter.
125
+ - **Discovery env accessors** — `discoveryAllowedTypes`, `discoveryMinSimilarity`,
126
+ `discoveryProfileSource`, `discoveryIntentMatchingEnabled`,
127
+ `discoveryProfileMatchingEnabled`, the `validate*` helpers, and the
128
+ `DISCOVERY_*_DEFAULT` constants. `discoveryEvaluatorMinScore` stays: its one
129
+ importer is `services/api/src/cli/discovery-env-matrix.main.ts`. That CLI is
130
+ slated for removal with the eval harnesses, and this accessor should be
131
+ pruned in the same change. These back live Railway configuration and are
132
+ unchanged in behaviour; only the re-export is gone.
133
+ - **Signal-intake types** — `IntakePack`, `IntakePackInput`, `SynthesisInput`,
134
+ `SynthesisResult`, `FollowUpPlan`, `answerLabel`, `normalizeIntakePack`, …
135
+
136
+ Two of the removed symbols (`createAgentTools` and
137
+ `CANONICAL_MCP_TOOL_ACCESS_RULES`) are referenced by `services/api` tests
138
+ through deep source paths rather than the package root, so those tests are
139
+ unaffected by the barrel change.
140
+
141
+ ### Changed
142
+
143
+ - `IMPLEMENTATION.md` §1 no longer documents a `modelConfig` override on
144
+ `ToolDeps` — that field does not exist there. `modelConfig` lives on the
145
+ internal `ToolContext` / `ProtocolDeps` composition, which is not exported, so
146
+ the section now documents the environment variables as the supported
147
+ configuration path and states plainly that programmatic override is outside
148
+ the public contract.
149
+ - `IMPLEMENTATION.md` §3 now documents `createMcpServer` and
150
+ `createToolRegistry` + `invokeToolRuntime` as the supported tool entry points,
151
+ replacing the `createChatTools` walkthrough.
152
+ - `STABILITY.md` — the **Capability tools** tier now covers
153
+ `createEnrichmentTools` only; the **Public API** row names `createToolRegistry`
154
+ and corrects `ToolContext` to the actually-exported `ResolvedToolContext`.
155
+
156
+ ### Migration
157
+
158
+ Hosts composing tools by capability should call `createMcpServer` (full MCP
159
+ server, policy applied) or `createToolRegistry` (raw handler map, invoked via
160
+ `invokeToolRuntime`). Both take the same dependency object the individual
161
+ factories did.
162
+
23
163
  ## 14.3.2 - 2026-08-16
24
164
 
25
165
  No source change. The public contract in `src/index.ts` is untouched; only
@@ -419,6 +559,7 @@ No public API change: all 441 exported symbols are byte-identical to 13.2.0, and
419
559
  ## [Unreleased]
420
560
 
421
561
  ### Changed
562
+ - Behaviour-neutral internal refactor (16.1.1): split the six largest modules and hoist every graph node to a top-level function. The opportunity graph is now the discovery pipeline only — its eight non-pipeline modes (read, update, delete, send, negotiate_existing, approve_introduction, and the two introduction stages) are plain functions on `OpportunityGraphFactory` instead of `operationMode` conditional-edge routing. `database.interface.ts` becomes a barrel over entity, query-group, and capability-view modules; every `Pick<Database, ...>` resolves as before. The opportunity presentation cluster is one module. `opportunity.graph.ts` 4167 → 250 lines, `database.interface.ts` 2925 → 17, `negotiation.graph.ts` 1619 → 111, `opportunity.tools.ts` 1200 → 354, `enrichment.tools.ts` 1198 → 178, `intent.graph.ts` 1091 → 174. No public export, feature flag, or environment variable changed.
422
563
  - Move the opportunity-presentation review checklist into `src/opportunity/AGENTS.md` and repoint the `opportunity.safe-presentation.ts` and `discriminator.adjustments.ts` comments at it. Comment-only; no runtime change.
423
564
 
424
565
  ### Removed
package/IMPLEMENTATION.md CHANGED
@@ -10,7 +10,7 @@ supported entry point is the package root (`import { ... } from "@indexnetwork/p
10
10
  deep imports are not part of the contract. Every symbol is re-exported explicitly from
11
11
  `src/index.ts` and tagged with a stability tier:
12
12
 
13
- - **Stable** — interfaces, graph factories, agents, `createChatTools`, the
13
+ - **Stable** — interfaces, graph factories, agents, `createMcpServer`, the
14
14
  tool/runtime helpers, and shared schemas. Breaking changes require a major bump.
15
15
  - **Experimental** (`@experimental`) — advanced graph-state types and internal
16
16
  helpers; may change in a minor release.
@@ -35,27 +35,15 @@ npm install @indexnetwork/protocol
35
35
 
36
36
  The package reads `OPENROUTER_API_KEY` (required), `CHAT_MODEL`, and `CHAT_REASONING_EFFORT` from environment variables. No startup call is needed.
37
37
 
38
- To override the chat model or reasoning effort when using the built-in chat runtime (`ChatGraphFactory` / `ChatAgent`), pass `modelConfig` on `ToolContext`. `ChatAgent` reads these fields when the chat graph runs; the tools themselves do not consume `modelConfig`:
38
+ Environment variables are the supported way to configure models. `CHAT_MODEL` and `CHAT_REASONING_EFFORT` (`minimal | low | medium | high | xhigh`) drive the built-in chat runtime (`ChatGraphFactory` / `ChatAgent`); every other protocol agent evaluators, generators, miners reads `OPENROUTER_API_KEY` from the environment.
39
39
 
40
- ```typescript
41
- import { createChatTools } from "@indexnetwork/protocol";
42
-
43
- const tools = await createChatTools({
44
- // ... other deps ...
45
- modelConfig: {
46
- chatModel: "google/gemini-2.5-flash", // optional — has a default
47
- chatReasoningEffort: "low", // optional: minimal | low | medium | high | xhigh
48
- },
49
- });
50
- ```
51
-
52
- `apiKey` and `baseURL` can also be overridden this way. All other protocol agents (evaluators, generators, etc.) rely on `OPENROUTER_API_KEY` set in the environment regardless of `modelConfig`.
40
+ There is a per-instance `modelConfig` (chat model, reasoning effort, `apiKey`, `baseURL`) that `ChatAgent` reads off the resolved tool context, but it lives on the internal composition types (`ToolContext` / `ProtocolDeps`), not on `ToolDeps`, and those types are not exported. **Programmatic model override is therefore not part of the public contract in 15.0.0** — use the environment variables. If you need a typed override path, open an issue rather than reaching through a deep import.
53
41
 
54
42
  ### 2. Implement the adapters
55
43
 
56
44
  The package defines interfaces — your application provides the concrete implementations.
57
45
 
58
- **Required** (always needed by `createChatTools`):
46
+ **Required** (always needed by the tool registry):
59
47
 
60
48
  | Interface | Responsibility |
61
49
  |---|---|
@@ -90,50 +78,60 @@ All interfaces are exported from the package root — import them with `import t
90
78
 
91
79
  ### 3. Create tools
92
80
 
93
- Pass your adapter implementations to `createChatTools` to get a set of LangChain-compatible tools bound to a user session:
81
+ Two entry points are supported, both taking a single dependency object built
82
+ from the adapters above.
83
+
84
+ `createMcpServer` is the complete integration: it composes every capability's
85
+ tools internally, applies the authorization policy, and returns a ready MCP
86
+ server.
94
87
 
95
88
  ```typescript
96
- import { createChatTools } from "@indexnetwork/protocol";
89
+ import { createMcpServer, CANONICAL_MCP_CAPABILITY_POLICY_OPTIONS } from "@indexnetwork/protocol";
97
90
 
98
- const tools = await createChatTools({
99
- userId: "user-uuid",
91
+ const server = createMcpServer(
92
+ deps, // ToolDeps + the opportunity owner-approval port
93
+ authResolver, // McpAuthResolver
94
+ scopedDepsFactory, // ScopedDepsFactory — builds per-user scoped userDb/systemDb
95
+ CANONICAL_MCP_CAPABILITY_POLICY_OPTIONS,
96
+ authorizationObserver, // optional McpAuthorizationObserver
97
+ );
98
+ ```
99
+
100
+ `createToolRegistry` is the lower-level surface for hosts running their own
101
+ runtime. It returns a `Map` of tool name to `RawToolDefinition` — raw async
102
+ handlers taking `{ context, query }` — which you invoke through
103
+ `invokeToolRuntime`:
104
+
105
+ ```typescript
106
+ import { createToolRegistry, invokeToolRuntime, resolveChatContext } from "@indexnetwork/protocol";
100
107
 
101
- // ── Required adapters ──
102
- database, // ChatGraphCompositeDatabase
103
- embedder, // Embedder
104
- scraper, // Scraper
105
- cache, // Cache
106
- hydeCache, // HydeCache
107
- integration, // IntegrationAdapter
108
- intentQueue, // IntentGraphQueue
109
- contactService, // ContactServiceAdapter
110
- chatSession, // ChatSessionReader
111
- enricher, // ProfileEnricher
112
- negotiationDatabase, // NegotiationGraphDatabase
113
- integrationImporter, // bulk contact import
114
- createUserDatabase, // (db, userId) => UserDatabase
115
- createSystemDatabase, // (db, userId, indexScope, embedder?) => SystemDatabase
116
-
117
- // ── Optional scoping ──
118
- networkId: "optional-network-uuid", // scope tools to a specific index/network
119
- sessionId: "chat-session-id", // enables draft opportunities with conversation context
120
-
121
- // ── Optional capabilities (enable when the host supports them) ──
122
- agentDatabase, // AgentDatabase — agent registry
123
- agentDispatcher, // AgentDispatcher — routes negotiation turns to personal agents
124
- deliveryLedger, // DeliveryLedger — OpenClaw delivery commits
125
- enrichmentRuns, // EnrichmentRunStore (+ enrichmentRunQueue) — async MCP enrichment runs
126
- mintConnectLink, // short connect links for opportunity accepts
127
- modelConfig, // override chat model / reasoning effort (see above)
108
+ const registry = createToolRegistry(deps, { surface: "mcp" }); // omit `surface` for the full REST set
109
+
110
+ const context = await resolveChatContext({
111
+ database, // the ChatGraphCompositeDatabase reads listed above
112
+ userId: "user-uuid",
113
+ networkId, // optional — scopes tools to one network
114
+ sessionId, // optional — enables draft opportunities
128
115
  });
129
116
 
130
- // tools is an array of LangChain Tool objects ready to bind to an agent
117
+ const tool = registry.get("search_intents")!;
118
+ const result = await invokeToolRuntime({
119
+ toolName: tool.name,
120
+ tool,
121
+ context,
122
+ query: { /* validated against tool.schema */ },
123
+ });
131
124
  ```
132
125
 
133
- `createChatTools` accepts a single `ToolContext` object. The required adapters
134
- above are always needed; optional capabilities default to a degraded-but-
135
- functional mode when omitted (for example, without `agentDispatcher` the
136
- negotiation tools are not registered).
126
+ The dependency object carries the required adapters listed above; optional
127
+ capabilities default to a degraded-but-functional mode when omitted (for
128
+ example, without `agentDispatcher` the negotiation tools are not registered).
129
+
130
+ The per-capability tool factories behind these entry points
131
+ (`createChatTools`, `createIntentTools`, `createNegotiationTools`, …) are
132
+ package-internal as of 15.0.0 and are not part of the supported surface.
133
+ `createEnrichmentTools` remains exported for hosts that run enrichment on its
134
+ own worker, separately from the chat runtime.
137
135
 
138
136
  ## Graphs
139
137
 
package/STABILITY.md CHANGED
@@ -30,13 +30,13 @@ Covered by SemVer below. Breaking changes require a **major** bump.
30
30
 
31
31
  | Barrel section | What it is |
32
32
  |---|---|
33
- | **Public API** | `createChatTools`, model config helpers, tool/runtime helpers (`ToolContext`, `ToolDeps`, `invokeToolRuntime`, …), `requestContext`. |
33
+ | **Public API** | `createToolRegistry`, model config helpers, tool/runtime helpers (`ResolvedToolContext`, `ToolDeps`, `invokeToolRuntime`, …), `requestContext`. |
34
34
  | **Interfaces** | Every `*.interface.ts` port you implement to inject infrastructure (databases, embedder, cache, scraper, queues, integration, agent dispatcher, …). |
35
35
  | **Shared schemas** | Zod schemas + inferred types that cross the boundary (questions, identity, network-assignment, chat-context, …). |
36
36
  | **Graph factories** | `*GraphFactory` classes (`ChatGraphFactory`, `OpportunityGraphFactory`, `NegotiationGraphFactory`, …). |
37
37
  | **Agents** | Structured LLM agents (`UserContextGenerator`, `IndexNegotiator`, `OpportunityEvaluator`, …). |
38
- | **MCP** | `createMcpServer` and its supporting types. |
39
- | **Capability tools** | Named tool-factory entry points for Signals, Participant context, Communities, Opportunities, Negotiation, Questions, Participant agents, Contacts, and Integrations. |
38
+ | **MCP** | `createMcpServer` plus the types needed to call it: `ScopedDepsFactory`, `McpCapabilityPolicyOptions`, `CANONICAL_MCP_CAPABILITY_POLICY_OPTIONS`, `McpAuthorizationObserver`, `McpAuthorizationDenialEvent`. The rest of `mcp.authorization-policy.ts` is package-internal as of 15.0.0. |
39
+ | **Capability tools** | `createEnrichmentTools` only. The other per-capability tool factories became package-internal in 15.0.0 compose them through `createMcpServer` or `createToolRegistry`. |
40
40
 
41
41
  ### Experimental
42
42
 
@@ -204,7 +204,6 @@ export class ChatAgent {
204
204
  userId: context.userId,
205
205
  networkId: scopedNetworkId,
206
206
  sessionId: context.sessionId,
207
- contactsEnabled: context.contactsEnabled,
208
207
  actionToolsEnabled: context.actionToolsEnabled,
209
208
  });
210
209
  if (explicitScope.scopeType && explicitScope.scopeId) {
@@ -327,8 +326,8 @@ export class ChatAgent {
327
326
  }
328
327
  try {
329
328
  logger.verbose("Executing tool", { name: tc.name, args: tc.args });
330
- let result = await tool.invoke(tc.args);
331
- let resultStr = typeof result === "string" ? result : JSON.stringify(result);
329
+ const result = await tool.invoke(tc.args);
330
+ const resultStr = typeof result === "string" ? result : JSON.stringify(result);
332
331
  logger.debug("Tool response", { name: tc.name, result: resultStr });
333
332
  logger.verbose("Tool completed", {
334
333
  name: tc.name,
@@ -1,5 +1,6 @@
1
- import { BaseCheckpointSaver } from "@langchain/langgraph";
1
+ import { BaseCheckpointSaver, type LangGraphRunnableConfig } from "@langchain/langgraph";
2
2
  import { BaseMessage } from "@langchain/core/messages";
3
+ import { ChatGraphState } from "./chat.state.js";
3
4
  import type { ChatPersonaConfig } from "./chat.persona.js";
4
5
  import type { ChatGraphCompositeDatabase } from "../shared/interfaces/database.interface.js";
5
6
  import type { Embedder } from "../shared/interfaces/embedder.interface.js";
@@ -21,6 +22,16 @@ import type { ProtocolDeps } from "../shared/agent/tool.helpers.js";
21
22
  * with a flexible, LLM-driven approach that can handle multi-step
22
23
  * reasoning and self-correction.
23
24
  */
25
+ /** The graph's channel state, as the agent loop sees it. */
26
+ export type ChatState = typeof ChatGraphState.State;
27
+ /** Everything the agent loop node reaches for. */
28
+ export interface ChatGraphNodeDeps {
29
+ database: ChatGraphCompositeDatabase;
30
+ embedder: Embedder;
31
+ scraper: Scraper;
32
+ protocolDeps: ProtocolDeps;
33
+ persona: ChatPersonaConfig;
34
+ }
24
35
  export declare class ChatGraphFactory {
25
36
  private database;
26
37
  private embedder;
@@ -382,3 +393,32 @@ export declare class ChatGraphFactory {
382
393
  */
383
394
  private buildGraph;
384
395
  }
396
+ /**
397
+ * The main agent loop node.
398
+ * Runs a ReAct-style agent that calls tools until it decides to respond.
399
+ *
400
+ * Uses `agent.streamRun()` + `config.writer` so that text tokens and
401
+ * tool-activity events are pushed into the graph's custom stream in
402
+ * real-time rather than batched at the end.
403
+ */
404
+ export declare function agentLoopNode(state: ChatState, config: LangGraphRunnableConfig, deps: ChatGraphNodeDeps): Promise<{
405
+ messages: BaseMessage<import("@langchain/core/messages").MessageStructure<import("@langchain/core/messages").MessageToolSet>, import("@langchain/core/messages").MessageType>[];
406
+ responseText: string;
407
+ iterationCount: number;
408
+ shouldContinue: boolean;
409
+ debugMeta: {
410
+ graph: string;
411
+ iterations: number;
412
+ tools: import("./chat-streaming.types.js").DebugMetaToolCall[];
413
+ llm: import("./chat-streaming.types.js").DebugMetaLlm;
414
+ orchestratorNegotiations?: import("./chat-streaming.types.js").DebugMetaOrchestratorNegotiations;
415
+ };
416
+ error?: undefined;
417
+ } | {
418
+ error: string;
419
+ responseText: string;
420
+ shouldContinue: boolean;
421
+ messages?: undefined;
422
+ iterationCount?: undefined;
423
+ debugMeta?: undefined;
424
+ }>;