@indexnetwork/protocol 0.8.0-rc.25.1 → 0.8.0-rc.27.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 (2) hide show
  1. package/README.md +42 -4
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -40,6 +40,10 @@ The package defines interfaces — your application provides the concrete implem
40
40
  | `ChatSessionReader` | Load conversation history |
41
41
  | `ProfileEnricher` | Enrich profiles from external sources |
42
42
  | `NegotiationDatabase` | Negotiation state persistence |
43
+ | `AgentDatabase` | Agent registry CRUD (agents, transports, permissions) |
44
+ | `AgentDispatcher` | Resolves and invokes agents during negotiation turns |
45
+ | `McpAuthResolver` | Resolves `{ userId, agentId }` from an incoming MCP HTTP request |
46
+ | `WebhookAdapter` | Dispatches webhook events to registered agent transports |
43
47
 
44
48
  All interfaces are exported from the package root — import them with `import type { ... } from "@indexnetwork/protocol"`.
45
49
 
@@ -85,18 +89,52 @@ Each factory exposes a `.createGraph()` method that returns a compiled LangGraph
85
89
 
86
90
  ## MCP server
87
91
 
88
- To expose tools over the Model Context Protocol:
92
+ 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:
89
93
 
90
94
  ```typescript
91
- import { createMcpServer } from "@indexnetwork/protocol";
95
+ import { createMcpServer, type McpAuthResolver } from "@indexnetwork/protocol";
96
+
97
+ const authResolver: McpAuthResolver = {
98
+ async resolveIdentity(req) {
99
+ // Look up the API key in `x-api-key` and return { userId, agentId? }.
100
+ // `agentId` should come from Better Auth token metadata so downstream
101
+ // tool handlers can attribute every call to a concrete agent identity.
102
+ return resolveFromApiKey(req);
103
+ },
104
+ };
92
105
 
93
106
  const server = createMcpServer(
94
107
  deps,
95
- (req) => resolveUserIdFromRequest(req),
96
- { create: (userId, scope) => createScopedDeps(userId, scope) }
108
+ authResolver,
109
+ {
110
+ // Per-request factory for scoped user/system databases.
111
+ create: (userId, indexScope) => createScopedDeps(userId, indexScope),
112
+ },
97
113
  );
98
114
  ```
99
115
 
116
+ On every tool call the server:
117
+
118
+ 1. Extracts the HTTP request from the MCP `ServerContext`.
119
+ 2. Calls `authResolver.resolveIdentity(req)` to get `{ userId, agentId }`.
120
+ 3. Gates access: MCP callers without a resolved `agentId` are blocked from every tool except `register_agent`, `read_docs`, and `scrape_url` until they register.
121
+ 4. Builds per-request scoped databases via `scopedDepsFactory` and invokes the tool handler.
122
+
123
+ ### `MCP_INSTRUCTIONS`
124
+
125
+ The instructions string is the single canonical behavioral contract for every runtime that connects to Index Network — voice, entity model, discovery-first rule, output rules, and the **Negotiation turn mode** block that tells a silent subagent how to handle a live negotiation turn when its session key is prefixed `index:negotiation:`. Plugin skills and bootstrap scripts do **not** redefine this guidance; they defer to whatever ships in `MCP_INSTRUCTIONS`.
126
+
127
+ ### Negotiation-facing tools
128
+
129
+ Personal agents participate in bilateral negotiation via a small set of MCP tools:
130
+
131
+ | Tool | Purpose |
132
+ |---|---|
133
+ | `get_negotiation` | Fetch the full turn history and assessment seed for a negotiation |
134
+ | `list_negotiations` | List negotiations awaiting a response from this agent's user |
135
+ | `respond_to_negotiation` | Submit a turn (propose / counter / accept / reject / question) |
136
+ | `add_webhook_transport` | Register the caller's own webhook URL, secret, and event subscriptions on the acting agent so it can receive `negotiation.turn_received` and `negotiation.completed` deliveries |
137
+
100
138
  ## Publishing
101
139
 
102
140
  Publishing is handled via CI:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indexnetwork/protocol",
3
- "version": "0.8.0-rc.25.1",
3
+ "version": "0.8.0-rc.27.1",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",