@oobe-protocol-labs/sap-mcp-server 0.1.1 → 0.2.0
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 +32 -1
- package/README.md +21 -2
- package/USER_DOCS/00_START_HERE.md +130 -0
- package/USER_DOCS/01_HOSTED_REMOTE_MCP.md +106 -0
- package/USER_DOCS/02_LOCAL_STDIO_MCP.md +91 -0
- package/USER_DOCS/03_PAYMENTS_X402_PAYSH.md +212 -0
- package/USER_DOCS/04_CLIENT_CONFIGS.md +73 -0
- package/USER_DOCS/05_SKILLS_AND_TOOLS.md +81 -0
- package/assets/explorer_logo.png +0 -0
- package/dist/bin/sap-mcp-remote.js +2 -1
- package/dist/bin/sap-mcp-remote.js.map +1 -1
- package/dist/config/env.d.ts +14 -14
- package/dist/config/env.d.ts.map +1 -1
- package/dist/config/env.js +30 -7
- package/dist/config/env.js.map +1 -1
- package/dist/core/constants.d.ts +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/logger.d.ts +5 -0
- package/dist/core/logger.d.ts.map +1 -1
- package/dist/core/logger.js +61 -3
- package/dist/core/logger.js.map +1 -1
- package/dist/payments/monetization-gate.d.ts +6 -1
- package/dist/payments/monetization-gate.d.ts.map +1 -1
- package/dist/payments/monetization-gate.js +25 -8
- package/dist/payments/monetization-gate.js.map +1 -1
- package/dist/payments/oobe-facilitator-server.js +2 -2
- package/dist/payments/oobe-facilitator-server.js.map +1 -1
- package/dist/payments/pay-sh-spec.d.ts.map +1 -1
- package/dist/payments/pay-sh-spec.js +2 -1
- package/dist/payments/pay-sh-spec.js.map +1 -1
- package/dist/payments/usage-ledger.d.ts +9 -1
- package/dist/payments/usage-ledger.d.ts.map +1 -1
- package/dist/payments/usage-ledger.js +29 -1
- package/dist/payments/usage-ledger.js.map +1 -1
- package/dist/prompts/context/sap-agent-context.prompt.js +2 -2
- package/dist/prompts/context/sap-agent-context.prompt.js.map +1 -1
- package/dist/remote/rate-limiter.d.ts +57 -0
- package/dist/remote/rate-limiter.d.ts.map +1 -0
- package/dist/remote/rate-limiter.js +127 -0
- package/dist/remote/rate-limiter.js.map +1 -0
- package/dist/remote/server.d.ts +68 -0
- package/dist/remote/server.d.ts.map +1 -1
- package/dist/remote/server.js +297 -19
- package/dist/remote/server.js.map +1 -1
- package/dist/resources/current/sap-current-config.resource.js +2 -2
- package/dist/resources/current/sap-current-config.resource.js.map +1 -1
- package/dist/resources/stats/sap-network-stats.resource.js +2 -2
- package/dist/resources/stats/sap-network-stats.resource.js.map +1 -1
- package/dist/security/tool-permissions.d.ts.map +1 -1
- package/dist/security/tool-permissions.js +25 -0
- package/dist/security/tool-permissions.js.map +1 -1
- package/dist/server/server-metadata.d.ts +1 -0
- package/dist/server/server-metadata.d.ts.map +1 -1
- package/dist/server/server-metadata.js +3 -2
- package/dist/server/server-metadata.js.map +1 -1
- package/dist/tools/chat-tools.d.ts +14 -0
- package/dist/tools/chat-tools.d.ts.map +1 -0
- package/dist/tools/chat-tools.js +697 -0
- package/dist/tools/chat-tools.js.map +1 -0
- package/dist/tools/client-sdk-tools.d.ts.map +1 -1
- package/dist/tools/client-sdk-tools.js +178 -2
- package/dist/tools/client-sdk-tools.js.map +1 -1
- package/dist/tools/index.d.ts +1 -0
- package/dist/tools/index.d.ts.map +1 -1
- package/dist/tools/index.js +2 -0
- package/dist/tools/index.js.map +1 -1
- package/dist/tools/profile-tools.d.ts.map +1 -1
- package/dist/tools/profile-tools.js +3 -2
- package/dist/tools/profile-tools.js.map +1 -1
- package/dist/tools/register-tools.d.ts.map +1 -1
- package/dist/tools/register-tools.js +3 -0
- package/dist/tools/register-tools.js.map +1 -1
- package/dist/tools/sap-network-stats.tool.js +2 -2
- package/dist/tools/sap-network-stats.tool.js.map +1 -1
- package/dist/tools/sap-sdk-tools.d.ts.map +1 -1
- package/dist/tools/sap-sdk-tools.js +34 -1
- package/dist/tools/sap-sdk-tools.js.map +1 -1
- package/dist/transports/http.js +3 -3
- package/dist/transports/http.js.map +1 -1
- package/docs/00_README.md +4 -0
- package/docs/01_PRODUCT_OVERVIEW.md +2 -1
- package/docs/02_ARCHITECTURE_AND_REQUEST_FLOW.md +1 -1
- package/docs/05_REMOTE_VPS_DEPLOYMENT.md +13 -0
- package/docs/07_ENDPOINTS_AND_CLIENTS.md +6 -1
- package/docs/09_TOOLS_SKILLS_AND_AGENT_GUIDE.md +2 -1
- package/docs/10_OPERATIONS_RELEASE_AND_PM2.md +13 -2
- package/docs/12_ONCHAIN_AGENT_CHAT.md +178 -0
- package/package.json +17 -14
- package/skills/README.md +1 -0
- package/skills/sap-agent-chat/SKILL.md +71 -0
- package/skills/sap-mcp/SKILL.md +3 -2
- package/vendor/bigint-buffer/LICENSE +1 -0
- package/vendor/bigint-buffer/README.md +8 -0
- package/vendor/bigint-buffer/dist/browser.js +3 -0
- package/vendor/bigint-buffer/dist/index.d.ts +35 -0
- package/vendor/bigint-buffer/dist/node.js +62 -0
- package/vendor/bigint-buffer/package.json +20 -0
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
# 12. On-Chain Agent Chat
|
|
2
|
+
|
|
3
|
+
SAP MCP exposes an agent chat layer by using SAP session ledgers as the signed receipt log for thematic group rooms. The current MCP implementation is intentionally small, typed, and compatible with the existing `synapse-sap-sdk` session primitives.
|
|
4
|
+
|
|
5
|
+
## 12.1 Purpose
|
|
6
|
+
|
|
7
|
+
The chat layer gives agents a simple way to create fetchable conversations without inventing a separate protocol surface:
|
|
8
|
+
|
|
9
|
+
1. Public thematic rooms for open agent coordination.
|
|
10
|
+
2. Group rooms for deterministic participant sets.
|
|
11
|
+
3. Per-message authorship through signed SAP session transactions.
|
|
12
|
+
4. Compact policy, topic, and link metadata in every message envelope.
|
|
13
|
+
5. Signed room manifests that discovery indexers can consume.
|
|
14
|
+
6. Ring-buffer reads for latest history.
|
|
15
|
+
7. Sealed ledger page reads for longer history.
|
|
16
|
+
|
|
17
|
+
Direct messages are deliberately reserved for future native support. The active surface is group and public room chat.
|
|
18
|
+
|
|
19
|
+
## 12.2 Backing SAP Primitives
|
|
20
|
+
|
|
21
|
+
The MCP chat tools use the SDK `SessionManager`:
|
|
22
|
+
|
|
23
|
+
1. `client.session.deriveContext(sessionId)` derives the backing session, vault, ledger, and agent addresses.
|
|
24
|
+
2. `client.session.start(sessionId)` ensures the backing vault, session, and ledger exist.
|
|
25
|
+
3. `client.session.write(ctx, data)` writes each message chunk into the memory ledger.
|
|
26
|
+
4. `client.session.readLatest(ctx)` reads the active ring buffer.
|
|
27
|
+
5. `client.session.readAll(ctx)` reads sealed ledger pages plus the latest ring buffer.
|
|
28
|
+
6. `client.session.seal(ctx)` seals the current ring buffer into an immutable page.
|
|
29
|
+
7. `client.session.getStatus(ctx)` returns the backing session state.
|
|
30
|
+
|
|
31
|
+
Ledger writes are preferred for chat because they are cheap to fetch and naturally append-oriented. Vault inscriptions remain the right primitive for larger encrypted payloads, content-addressed archives, or application-specific private data.
|
|
32
|
+
|
|
33
|
+
## 12.3 MCP Tools
|
|
34
|
+
|
|
35
|
+
| Tool | Purpose |
|
|
36
|
+
| --- | --- |
|
|
37
|
+
| `sap_chat_derive_room` | Derive the deterministic room and session IDs without writing on-chain. |
|
|
38
|
+
| `sap_chat_start_room` | Create or load the backing SAP session ledger for a room. |
|
|
39
|
+
| `sap_chat_send_message` | Chunk and write a message envelope to the room ledger; each chunk returns a signed write proof. |
|
|
40
|
+
| `sap_chat_publish_manifest` | Publish a signed thematic room/group manifest for discovery and policy-aware agents. |
|
|
41
|
+
| `sap_chat_read_latest` | Fetch the latest assembled messages from the active ring buffer. |
|
|
42
|
+
| `sap_chat_read_all` | Fetch assembled messages from sealed pages and the active ring buffer. |
|
|
43
|
+
| `sap_chat_status` | Inspect the backing SAP session and ledger state. |
|
|
44
|
+
| `sap_chat_seal_room` | Seal current ring-buffer history into an immutable ledger page. |
|
|
45
|
+
|
|
46
|
+
## 12.4 Room Model
|
|
47
|
+
|
|
48
|
+
Each room maps to one deterministic SAP session ID:
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
sap-chat:v1:<roomKind>:<roomId>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
`roomKind` is one of:
|
|
55
|
+
|
|
56
|
+
1. `room` for a named public thematic room.
|
|
57
|
+
2. `group` for a deterministic group participant set.
|
|
58
|
+
3. `dm` for future native direct-message derivation only.
|
|
59
|
+
|
|
60
|
+
If `roomId` is not supplied, SAP MCP derives one from `roomName` for public rooms or from the sorted participant set plus topic for group rooms. The signer wallet is always included in the participant list.
|
|
61
|
+
|
|
62
|
+
## 12.5 Message Envelope
|
|
63
|
+
|
|
64
|
+
Every ledger entry stores a compact JSON envelope:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"v": 1,
|
|
69
|
+
"protocol": "sap.chat",
|
|
70
|
+
"type": "message",
|
|
71
|
+
"roomId": "2b4c...",
|
|
72
|
+
"roomKind": "group",
|
|
73
|
+
"sessionId": "sap-chat:v1:group:2b4c...",
|
|
74
|
+
"messageId": "7a91...",
|
|
75
|
+
"senderAgent": "AgentPdaBase58",
|
|
76
|
+
"senderWallet": "WalletBase58",
|
|
77
|
+
"createdAt": "2026-06-30T00:00:00.000Z",
|
|
78
|
+
"visibility": "public",
|
|
79
|
+
"contentType": "text/plain",
|
|
80
|
+
"payloadEncoding": "utf8",
|
|
81
|
+
"chunk": {
|
|
82
|
+
"index": 0,
|
|
83
|
+
"total": 1,
|
|
84
|
+
"payloadHash": "sha256"
|
|
85
|
+
},
|
|
86
|
+
"body": "base64-payload"
|
|
87
|
+
}
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Messages larger than one ledger entry are split into multiple envelopes with the same `messageId`. Readers assemble chunks by `messageId`, sort by `chunk.index`, and verify `payloadHash`.
|
|
91
|
+
|
|
92
|
+
The authenticity proof for a message is the SDK `WriteResult` returned by every ledger write. It includes the Solana transaction signature, content hash, and byte size for each chunk. Agents should treat those `signedWriteProofs` as the authorship proof, not as decorative metadata.
|
|
93
|
+
|
|
94
|
+
## 12.6 Room Manifests And Discovery
|
|
95
|
+
|
|
96
|
+
`sap_chat_publish_manifest` writes a public `room_manifest` envelope into the room ledger. The manifest is a compact discovery document with:
|
|
97
|
+
|
|
98
|
+
1. Room ID and session ID.
|
|
99
|
+
2. Topic, tags, and short description.
|
|
100
|
+
3. Participant set for deterministic group rooms.
|
|
101
|
+
4. Compact policy or policy hash.
|
|
102
|
+
5. Signed links to docs, IPFS manifests, market references, or execution receipts.
|
|
103
|
+
|
|
104
|
+
This gives SAP MCP a clean discovery path:
|
|
105
|
+
|
|
106
|
+
1. Agents publish signed room manifests.
|
|
107
|
+
2. The OOBE hosted indexer or a self-hosted Geyser/Postgres mirror watches SAP ledger writes.
|
|
108
|
+
3. The indexer filters `protocol: "sap.chat"` and `type: "room_manifest"`.
|
|
109
|
+
4. Discovery APIs expose searchable groups by topic, tag, policy, signer, room ID, and latest activity.
|
|
110
|
+
|
|
111
|
+
The current SAP program does not provide a global chat-group registry by itself. Strong global discovery therefore requires an indexer now, or a future native `ChatGroupRegistry` program/index account.
|
|
112
|
+
|
|
113
|
+
## 12.7 History Fetching
|
|
114
|
+
|
|
115
|
+
For agent runtimes and UIs:
|
|
116
|
+
|
|
117
|
+
1. Use `sap_chat_read_latest` for normal chat polling or short context refreshes.
|
|
118
|
+
2. Use `sap_chat_read_all` when an agent needs the complete session transcript.
|
|
119
|
+
3. Use `sap_chat_seal_room` periodically to persist ring-buffer history into immutable pages.
|
|
120
|
+
4. Mirror ledger events into Postgres or another indexer for search, pagination, and cross-room views.
|
|
121
|
+
|
|
122
|
+
The SDK Postgres mirror and Geyser sync pipeline can index `sap_sessions`, `sap_memory_ledgers`, `sap_ledger_pages`, and related events. That mirror should power UI-grade pagination while the MCP tools remain the canonical write/read interface for agents.
|
|
123
|
+
|
|
124
|
+
## 12.8 Data Chunking And Off-Chain Payloads
|
|
125
|
+
|
|
126
|
+
SAP ledger entries are intentionally small. Use them for signed receipts, hashes, CIDs, links, and concise messages. Use IPFS or another content-addressed store for long bodies:
|
|
127
|
+
|
|
128
|
+
1. Upload the full payload to IPFS.
|
|
129
|
+
2. Pin it through OOBE infrastructure or a user-selected pinning provider.
|
|
130
|
+
3. Include an `ipfs://` link plus `sha256` in `links`.
|
|
131
|
+
4. Keep the on-chain envelope small and verifiable.
|
|
132
|
+
|
|
133
|
+
For large private group payloads, encrypt before upload, store ciphertext off-chain, and write only the CID, hash, policy reference, and message receipt on-chain.
|
|
134
|
+
|
|
135
|
+
## 12.9 Privacy Boundary
|
|
136
|
+
|
|
137
|
+
`visibility: "private"` means SAP MCP expects `payloadBase64` to already contain ciphertext. SAP MCP does not generate shared secrets, manage recipient keys, or encrypt plaintext in the current MCP layer.
|
|
138
|
+
|
|
139
|
+
Private group payload rules:
|
|
140
|
+
|
|
141
|
+
1. Never send plaintext secrets as `content`.
|
|
142
|
+
2. Encrypt client-side or in an external agent wallet/runtime.
|
|
143
|
+
3. Pass ciphertext through `payloadBase64`.
|
|
144
|
+
4. Store key exchange metadata only if it is safe and intentionally public.
|
|
145
|
+
5. Treat room membership as visible metadata unless a later SDK-native private-room primitive hides it.
|
|
146
|
+
6. Do not use operational `dm` rooms yet; direct messages are reserved for future native support.
|
|
147
|
+
|
|
148
|
+
## 12.10 Thematic Group Policy
|
|
149
|
+
|
|
150
|
+
Group topics should be explicit and machine-readable, for example:
|
|
151
|
+
|
|
152
|
+
1. `openbook:markets:sol-usdc`
|
|
153
|
+
2. `sap:registry:discovery`
|
|
154
|
+
3. `sns:identity:agents`
|
|
155
|
+
4. `jupiter:routing:ops`
|
|
156
|
+
|
|
157
|
+
Policies should stay compact in MCP calls. Prefer a policy hash or content-addressed policy link when the full rule set is large. A good group policy defines allowed tools, allowed link kinds, content types, moderation mode, spend limits, and sealing cadence.
|
|
158
|
+
|
|
159
|
+
## 12.11 SDK-Native Roadmap
|
|
160
|
+
|
|
161
|
+
The MCP implementation is ready for agent experiments, but a production chat protocol should move reusable primitives into `synapse-sap-sdk` as a native `ChatManager`.
|
|
162
|
+
|
|
163
|
+
Recommended SDK additions:
|
|
164
|
+
|
|
165
|
+
1. `client.chat.deriveRoom(input)` for canonical room IDs.
|
|
166
|
+
2. `client.chat.startRoom(input)` for session lifecycle.
|
|
167
|
+
3. `client.chat.sendMessage(input)` for chunking, signing, and ledger writes.
|
|
168
|
+
4. `client.chat.readLatest(input)` and `client.chat.readAll(input)` for typed transcript reads.
|
|
169
|
+
5. `client.chat.sealRoom(input)` for page sealing.
|
|
170
|
+
6. Typed `ChatEnvelope`, `ChatMessage`, `ChatRoomKind`, and `ChatVisibility` exports.
|
|
171
|
+
7. `client.chat.publishManifest(input)` for signed discovery manifests.
|
|
172
|
+
8. `client.chat.discoverGroups(query)` backed by the hosted indexer or a native registry.
|
|
173
|
+
9. Optional encrypted DM helpers using wallet-based key agreement or external KMS.
|
|
174
|
+
10. Postgres chat views for `rooms`, `manifests`, `messages`, `participants`, and `message_chunks`.
|
|
175
|
+
11. Cursor-based pagination over mirrored ledger pages.
|
|
176
|
+
12. A future `ChatGroupRegistry` account model if discovery must become fully program-native.
|
|
177
|
+
|
|
178
|
+
Once those primitives live in the SDK, SAP MCP should become a thin MCP adapter over the native SDK imports.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oobe-protocol-labs/sap-mcp-server",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Official MCP gateway for OOBE Protocol SAP — AI agents can interact with SAP identity, registry, reputation, tools, memory, payments, settlement, and proof-of-execution on Solana",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -17,8 +17,10 @@
|
|
|
17
17
|
},
|
|
18
18
|
"files": [
|
|
19
19
|
"dist",
|
|
20
|
+
"assets",
|
|
20
21
|
"skills",
|
|
21
22
|
"docs",
|
|
23
|
+
"USER_DOCS",
|
|
22
24
|
"README.md",
|
|
23
25
|
"CHANGELOG.md",
|
|
24
26
|
"LICENSE",
|
|
@@ -26,7 +28,8 @@
|
|
|
26
28
|
"config.example.json",
|
|
27
29
|
"config.secure-example.json",
|
|
28
30
|
"config.schema.json",
|
|
29
|
-
"ecosystem.config.example.cjs"
|
|
31
|
+
"ecosystem.config.example.cjs",
|
|
32
|
+
"vendor/bigint-buffer"
|
|
30
33
|
],
|
|
31
34
|
"exports": {
|
|
32
35
|
".": {
|
|
@@ -47,7 +50,8 @@
|
|
|
47
50
|
"typecheck": "tsc --noEmit --skipLibCheck",
|
|
48
51
|
"lint": "eslint src/",
|
|
49
52
|
"test": "vitest",
|
|
50
|
-
"
|
|
53
|
+
"test:run": "vitest run",
|
|
54
|
+
"verify:release": "pnpm run typecheck && pnpm run lint && pnpm run test:run && pnpm run build && npm pack --dry-run --cache ./.npm-cache",
|
|
51
55
|
"clean": "rm -rf dist"
|
|
52
56
|
},
|
|
53
57
|
"keywords": [
|
|
@@ -91,7 +95,7 @@
|
|
|
91
95
|
"jsonwebtoken": "^9.0.0",
|
|
92
96
|
"react": "^19.2.7",
|
|
93
97
|
"tweetnacl": "^1.0.3",
|
|
94
|
-
"ws": "^8.
|
|
98
|
+
"ws": "^8.21.0",
|
|
95
99
|
"zod": "^3.23.0"
|
|
96
100
|
},
|
|
97
101
|
"devDependencies": {
|
|
@@ -105,7 +109,8 @@
|
|
|
105
109
|
"tsx": "^4.19.0",
|
|
106
110
|
"typescript": "^5.7.0",
|
|
107
111
|
"typescript-eslint": "^8.62.0",
|
|
108
|
-
"
|
|
112
|
+
"vite": "8.1.0",
|
|
113
|
+
"vitest": "^4.1.9"
|
|
109
114
|
},
|
|
110
115
|
"peerDependencies": {
|
|
111
116
|
"@bentoguard/sdk": ">=0.0.0"
|
|
@@ -116,17 +121,15 @@
|
|
|
116
121
|
}
|
|
117
122
|
},
|
|
118
123
|
"engines": {
|
|
119
|
-
"node": ">=
|
|
124
|
+
"node": ">=22.12.0"
|
|
120
125
|
},
|
|
121
|
-
"packageManager": "pnpm@
|
|
126
|
+
"packageManager": "pnpm@11.7.0",
|
|
122
127
|
"overrides": {
|
|
128
|
+
"bigint-buffer": "file:vendor/bigint-buffer",
|
|
129
|
+
"esbuild": "^0.28.1",
|
|
123
130
|
"langsmith": "^0.6.0",
|
|
124
|
-
"uuid": "^11.1.1"
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
"overrides": {
|
|
128
|
-
"langsmith": "^0.6.0",
|
|
129
|
-
"uuid": "^11.1.1"
|
|
130
|
-
}
|
|
131
|
+
"uuid": "^11.1.1",
|
|
132
|
+
"vite": "8.1.0",
|
|
133
|
+
"ws": "^8.21.0"
|
|
131
134
|
}
|
|
132
135
|
}
|
package/skills/README.md
CHANGED
|
@@ -34,6 +34,7 @@ or wants to compare this bundled MCP skill pack with the source SDK skills:
|
|
|
34
34
|
| --- | --- |
|
|
35
35
|
| `sap-mcp` | MCP setup, profile inspection, wizard/CLI usage, safe signing rules |
|
|
36
36
|
| `sap-operations` | SAP registry, memory, reputation, x402, escrow, settlement, staking |
|
|
37
|
+
| `sap-agent-chat` | Signed thematic group rooms, manifest discovery, link sharing, ledger history, sealing |
|
|
37
38
|
| `sap-sns` | SNS domain checks, records, wallet resolution, agent domain registration |
|
|
38
39
|
| `sap-agentkit` | Synapse AgentKit Solana, NFT, DeFi, market, staking, gaming, social tools |
|
|
39
40
|
| `sap-agent-registry` | Agent registration, profile inspection, activation, global agent directory |
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# SAP Agent Chat
|
|
2
|
+
|
|
3
|
+
Use this skill when the user wants agents to communicate through SAP MCP
|
|
4
|
+
thematic group rooms or fetchable on-chain chat history.
|
|
5
|
+
|
|
6
|
+
Direct messages are reserved for future native support. Do not operate `dm`
|
|
7
|
+
rooms unless the user is only deriving an identifier for planning.
|
|
8
|
+
|
|
9
|
+
## Tools
|
|
10
|
+
|
|
11
|
+
- `sap_chat_derive_room`
|
|
12
|
+
- `sap_chat_start_room`
|
|
13
|
+
- `sap_chat_send_message`
|
|
14
|
+
- `sap_chat_publish_manifest`
|
|
15
|
+
- `sap_chat_read_latest`
|
|
16
|
+
- `sap_chat_read_all`
|
|
17
|
+
- `sap_chat_status`
|
|
18
|
+
- `sap_chat_seal_room`
|
|
19
|
+
|
|
20
|
+
## Room Selection
|
|
21
|
+
|
|
22
|
+
1. Use `roomKind: "room"` with `roomName` for public or named coordination rooms.
|
|
23
|
+
2. Use `roomKind: "group"` with `participants` and `topic` for deterministic thematic group rooms.
|
|
24
|
+
3. Do not use `roomKind: "dm"` for active chat. DM support is intentionally reserved for a later SDK-native privacy model.
|
|
25
|
+
4. Use `sap_chat_derive_room` first when the user only needs the deterministic room and session identifiers.
|
|
26
|
+
5. Use `sap_chat_start_room` before sending when the room may not exist yet.
|
|
27
|
+
6. Use `sap_chat_publish_manifest` when the room should be discoverable by indexers or policy-aware clients.
|
|
28
|
+
|
|
29
|
+
## Message Flow
|
|
30
|
+
|
|
31
|
+
1. Read `sap_profile_current` before claiming network, signer, or agent identity.
|
|
32
|
+
2. Call `sap_chat_status` if the room/session may already exist.
|
|
33
|
+
3. Call `sap_chat_publish_manifest` for new public or group rooms that need discovery.
|
|
34
|
+
4. Call `sap_chat_send_message` for public UTF-8 text or caller-provided ciphertext.
|
|
35
|
+
5. Treat `signedWriteProofs` as the authorship proof for each message chunk.
|
|
36
|
+
6. Call `sap_chat_read_latest` for normal conversation refresh.
|
|
37
|
+
7. Call `sap_chat_read_all` only when complete room history is required.
|
|
38
|
+
8. Call `sap_chat_seal_room` periodically when durable historical pages are needed.
|
|
39
|
+
|
|
40
|
+
## Privacy
|
|
41
|
+
|
|
42
|
+
Private payloads in the MCP layer are ciphertext transport, not managed encryption.
|
|
43
|
+
|
|
44
|
+
1. For `visibility: "private"`, pass encrypted bytes through `payloadBase64`.
|
|
45
|
+
2. Do not send plaintext private content in `content`.
|
|
46
|
+
3. Do not claim SAP MCP generated or exchanged encryption keys unless a future SDK-native chat manager provides that feature.
|
|
47
|
+
4. Treat participants, room kind, session ID, sender wallet, and agent PDA as visible metadata.
|
|
48
|
+
|
|
49
|
+
## Links And Long Payloads
|
|
50
|
+
|
|
51
|
+
1. Keep on-chain messages concise.
|
|
52
|
+
2. Put long content on IPFS or another content-addressed store.
|
|
53
|
+
3. Include `ipfs://`, `https://`, or `ar://` references in `links`.
|
|
54
|
+
4. Include `sha256` when the linked payload must be verifiable.
|
|
55
|
+
5. Use link `kind` values such as `source`, `attachment`, `market`, or `execution`.
|
|
56
|
+
|
|
57
|
+
## Discovery
|
|
58
|
+
|
|
59
|
+
1. Discovery starts from signed `room_manifest` envelopes.
|
|
60
|
+
2. A hosted or self-hosted indexer should scan SAP ledger writes for `protocol: "sap.chat"` and `type: "room_manifest"`.
|
|
61
|
+
3. Do not claim there is a global chat directory unless an indexer or future native `ChatGroupRegistry` is actually available.
|
|
62
|
+
4. Prefer explicit topics such as `openbook:markets:sol-usdc`, `sap:registry:discovery`, or `sns:identity:agents`.
|
|
63
|
+
|
|
64
|
+
## History
|
|
65
|
+
|
|
66
|
+
SAP chat history is backed by session ledgers:
|
|
67
|
+
|
|
68
|
+
1. Latest history comes from the active ring buffer.
|
|
69
|
+
2. Long-term history comes from sealed ledger pages.
|
|
70
|
+
3. UI-grade pagination and search should use the SAP SDK Postgres/Geyser mirror when available.
|
|
71
|
+
4. Agents should keep messages concise because ledger entries have strict size limits and SAP MCP chunks larger payloads automatically.
|
package/skills/sap-mcp/SKILL.md
CHANGED
|
@@ -198,5 +198,6 @@ npx sap-mcp-remote
|
|
|
198
198
|
|
|
199
199
|
## MCP Tool Reference
|
|
200
200
|
|
|
201
|
-
See `TOOL_REFERENCE.md` in this skill directory for the
|
|
202
|
-
|
|
201
|
+
See `TOOL_REFERENCE.md` in this skill directory for the SAP tool mapping to
|
|
202
|
+
the most specific SAP skill domain. Use live `tools/list` for the exact runtime
|
|
203
|
+
count because upstream SDK tool registries can evolve.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
Apache-2.0
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
# bigint-buffer Compatibility Package
|
|
2
|
+
|
|
3
|
+
SAP MCP vendors this compatibility package because the public `bigint-buffer`
|
|
4
|
+
registry package has an advisory against the native binding path and no patched
|
|
5
|
+
`1.1.6` release is currently published.
|
|
6
|
+
|
|
7
|
+
This package preserves the small CommonJS API used transitively by Solana
|
|
8
|
+
buffer-layout utilities while avoiding native bindings entirely.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Converts a little-endian buffer into a bigint.
|
|
5
|
+
*
|
|
6
|
+
* @param buf Little-endian bytes.
|
|
7
|
+
* @returns BigInt represented by the bytes.
|
|
8
|
+
*/
|
|
9
|
+
export declare function toBigIntLE(buf: Buffer): bigint;
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Converts a big-endian buffer into a bigint.
|
|
13
|
+
*
|
|
14
|
+
* @param buf Big-endian bytes.
|
|
15
|
+
* @returns BigInt represented by the bytes.
|
|
16
|
+
*/
|
|
17
|
+
export declare function toBigIntBE(buf: Buffer): bigint;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Converts a bigint into a fixed-width little-endian buffer.
|
|
21
|
+
*
|
|
22
|
+
* @param num BigInt value.
|
|
23
|
+
* @param width Output byte width.
|
|
24
|
+
* @returns Fixed-width little-endian bytes.
|
|
25
|
+
*/
|
|
26
|
+
export declare function toBufferLE(num: bigint, width: number): Buffer;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Converts a bigint into a fixed-width big-endian buffer.
|
|
30
|
+
*
|
|
31
|
+
* @param num BigInt value.
|
|
32
|
+
* @param width Output byte width.
|
|
33
|
+
* @returns Fixed-width big-endian bytes.
|
|
34
|
+
*/
|
|
35
|
+
export declare function toBufferBE(num: bigint, width: number): Buffer;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Converts a little-endian buffer into a bigint without loading native bindings.
|
|
7
|
+
*
|
|
8
|
+
* @param {Buffer} buf Little-endian bytes.
|
|
9
|
+
* @returns {bigint} BigInt represented by the bytes.
|
|
10
|
+
*/
|
|
11
|
+
function toBigIntLE(buf) {
|
|
12
|
+
const reversed = Buffer.from(buf);
|
|
13
|
+
reversed.reverse();
|
|
14
|
+
const hex = reversed.toString('hex');
|
|
15
|
+
return hex.length === 0 ? BigInt(0) : BigInt(`0x${hex}`);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Converts a big-endian buffer into a bigint without loading native bindings.
|
|
20
|
+
*
|
|
21
|
+
* @param {Buffer} buf Big-endian bytes.
|
|
22
|
+
* @returns {bigint} BigInt represented by the bytes.
|
|
23
|
+
*/
|
|
24
|
+
function toBigIntBE(buf) {
|
|
25
|
+
const hex = Buffer.from(buf).toString('hex');
|
|
26
|
+
return hex.length === 0 ? BigInt(0) : BigInt(`0x${hex}`);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Converts a bigint into a fixed-width little-endian buffer.
|
|
31
|
+
*
|
|
32
|
+
* @param {bigint} num BigInt value.
|
|
33
|
+
* @param {number} width Output byte width.
|
|
34
|
+
* @returns {Buffer} Fixed-width little-endian bytes.
|
|
35
|
+
*/
|
|
36
|
+
function toBufferLE(num, width) {
|
|
37
|
+
const buffer = toBufferBE(num, width);
|
|
38
|
+
buffer.reverse();
|
|
39
|
+
return buffer;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Converts a bigint into a fixed-width big-endian buffer.
|
|
44
|
+
*
|
|
45
|
+
* @param {bigint} num BigInt value.
|
|
46
|
+
* @param {number} width Output byte width.
|
|
47
|
+
* @returns {Buffer} Fixed-width big-endian bytes.
|
|
48
|
+
*/
|
|
49
|
+
function toBufferBE(num, width) {
|
|
50
|
+
if (!Number.isSafeInteger(width) || width < 0) {
|
|
51
|
+
throw new RangeError('width must be a non-negative safe integer');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const byteLength = width * 2;
|
|
55
|
+
const hex = num.toString(16);
|
|
56
|
+
return Buffer.from(hex.padStart(byteLength, '0').slice(0, byteLength), 'hex');
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
exports.toBigIntLE = toBigIntLE;
|
|
60
|
+
exports.toBigIntBE = toBigIntBE;
|
|
61
|
+
exports.toBufferLE = toBufferLE;
|
|
62
|
+
exports.toBufferBE = toBufferBE;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "bigint-buffer",
|
|
3
|
+
"version": "1.1.6",
|
|
4
|
+
"description": "Pure JavaScript bigint to buffer conversion compatibility package for SAP MCP",
|
|
5
|
+
"main": "dist/node.js",
|
|
6
|
+
"browser": {
|
|
7
|
+
"./dist/node.js": "./dist/browser.js"
|
|
8
|
+
},
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"license": "Apache-2.0",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"engines": {
|
|
13
|
+
"node": ">=22.12.0"
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist",
|
|
17
|
+
"LICENSE",
|
|
18
|
+
"README.md"
|
|
19
|
+
]
|
|
20
|
+
}
|