society-protocol 1.0.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/LICENSE +21 -0
- package/README.md +111 -0
- package/dist/adapters.d.ts +101 -0
- package/dist/adapters.d.ts.map +1 -0
- package/dist/adapters.js +764 -0
- package/dist/adapters.js.map +1 -0
- package/dist/agents-md.d.ts +59 -0
- package/dist/agents-md.d.ts.map +1 -0
- package/dist/agents-md.js +204 -0
- package/dist/agents-md.js.map +1 -0
- package/dist/autoconfig.d.ts +137 -0
- package/dist/autoconfig.d.ts.map +1 -0
- package/dist/autoconfig.js +452 -0
- package/dist/autoconfig.js.map +1 -0
- package/dist/bootstrap.d.ts +68 -0
- package/dist/bootstrap.d.ts.map +1 -0
- package/dist/bootstrap.js +304 -0
- package/dist/bootstrap.js.map +1 -0
- package/dist/bridges/a2a-bridge.d.ts +156 -0
- package/dist/bridges/a2a-bridge.d.ts.map +1 -0
- package/dist/bridges/a2a-bridge.js +337 -0
- package/dist/bridges/a2a-bridge.js.map +1 -0
- package/dist/bridges/mcp-bridge.d.ts +87 -0
- package/dist/bridges/mcp-bridge.d.ts.map +1 -0
- package/dist/bridges/mcp-bridge.js +332 -0
- package/dist/bridges/mcp-bridge.js.map +1 -0
- package/dist/cache.d.ts +130 -0
- package/dist/cache.d.ts.map +1 -0
- package/dist/cache.js +257 -0
- package/dist/cache.js.map +1 -0
- package/dist/capsules.d.ts +23 -0
- package/dist/capsules.d.ts.map +1 -0
- package/dist/capsules.js +75 -0
- package/dist/capsules.js.map +1 -0
- package/dist/cli/commands.d.ts +8 -0
- package/dist/cli/commands.d.ts.map +1 -0
- package/dist/cli/commands.js +263 -0
- package/dist/cli/commands.js.map +1 -0
- package/dist/coc.d.ts +121 -0
- package/dist/coc.d.ts.map +1 -0
- package/dist/coc.js +629 -0
- package/dist/coc.js.map +1 -0
- package/dist/coc.test.d.ts +2 -0
- package/dist/coc.test.d.ts.map +1 -0
- package/dist/coc.test.js +80 -0
- package/dist/coc.test.js.map +1 -0
- package/dist/compression.d.ts +125 -0
- package/dist/compression.d.ts.map +1 -0
- package/dist/compression.js +573 -0
- package/dist/compression.js.map +1 -0
- package/dist/cot-stream.d.ts +220 -0
- package/dist/cot-stream.d.ts.map +1 -0
- package/dist/cot-stream.js +673 -0
- package/dist/cot-stream.js.map +1 -0
- package/dist/crypto-wasm.d.ts +100 -0
- package/dist/crypto-wasm.d.ts.map +1 -0
- package/dist/crypto-wasm.js +229 -0
- package/dist/crypto-wasm.js.map +1 -0
- package/dist/federation.d.ts +200 -0
- package/dist/federation.d.ts.map +1 -0
- package/dist/federation.js +691 -0
- package/dist/federation.js.map +1 -0
- package/dist/federation.test.d.ts +2 -0
- package/dist/federation.test.d.ts.map +1 -0
- package/dist/federation.test.js +71 -0
- package/dist/federation.test.js.map +1 -0
- package/dist/gateway/capability-router.d.ts +77 -0
- package/dist/gateway/capability-router.d.ts.map +1 -0
- package/dist/gateway/capability-router.js +222 -0
- package/dist/gateway/capability-router.js.map +1 -0
- package/dist/gateway/demand-spawner.d.ts +155 -0
- package/dist/gateway/demand-spawner.d.ts.map +1 -0
- package/dist/gateway/demand-spawner.js +426 -0
- package/dist/gateway/demand-spawner.js.map +1 -0
- package/dist/identity.d.ts +46 -0
- package/dist/identity.d.ts.map +1 -0
- package/dist/identity.js +102 -0
- package/dist/identity.js.map +1 -0
- package/dist/identity.test.d.ts +2 -0
- package/dist/identity.test.d.ts.map +1 -0
- package/dist/identity.test.js +45 -0
- package/dist/identity.test.js.map +1 -0
- package/dist/index.d.ts +36 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1572 -0
- package/dist/index.js.map +1 -0
- package/dist/integration.d.ts +210 -0
- package/dist/integration.d.ts.map +1 -0
- package/dist/integration.js +1105 -0
- package/dist/integration.js.map +1 -0
- package/dist/integration.test.d.ts +2 -0
- package/dist/integration.test.d.ts.map +1 -0
- package/dist/integration.test.js +155 -0
- package/dist/integration.test.js.map +1 -0
- package/dist/knowledge.d.ts +219 -0
- package/dist/knowledge.d.ts.map +1 -0
- package/dist/knowledge.js +543 -0
- package/dist/knowledge.js.map +1 -0
- package/dist/knowledge.test.d.ts +2 -0
- package/dist/knowledge.test.d.ts.map +1 -0
- package/dist/knowledge.test.js +72 -0
- package/dist/knowledge.test.js.map +1 -0
- package/dist/latent-space.d.ts +178 -0
- package/dist/latent-space.d.ts.map +1 -0
- package/dist/latent-space.js +385 -0
- package/dist/latent-space.js.map +1 -0
- package/dist/lib.d.ts +30 -0
- package/dist/lib.d.ts.map +1 -0
- package/dist/lib.js +30 -0
- package/dist/lib.js.map +1 -0
- package/dist/mcp/server.d.ts +74 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +1392 -0
- package/dist/mcp/server.js.map +1 -0
- package/dist/metrics.d.ts +98 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +222 -0
- package/dist/metrics.js.map +1 -0
- package/dist/p2p.d.ts +87 -0
- package/dist/p2p.d.ts.map +1 -0
- package/dist/p2p.js +606 -0
- package/dist/p2p.js.map +1 -0
- package/dist/persona/capabilities.d.ts +17 -0
- package/dist/persona/capabilities.d.ts.map +1 -0
- package/dist/persona/capabilities.js +224 -0
- package/dist/persona/capabilities.js.map +1 -0
- package/dist/persona/domains.d.ts +22 -0
- package/dist/persona/domains.d.ts.map +1 -0
- package/dist/persona/domains.js +176 -0
- package/dist/persona/domains.js.map +1 -0
- package/dist/persona/embeddings.d.ts +40 -0
- package/dist/persona/embeddings.d.ts.map +1 -0
- package/dist/persona/embeddings.js +265 -0
- package/dist/persona/embeddings.js.map +1 -0
- package/dist/persona/engine.d.ts +79 -0
- package/dist/persona/engine.d.ts.map +1 -0
- package/dist/persona/engine.js +1087 -0
- package/dist/persona/engine.js.map +1 -0
- package/dist/persona/index.d.ts +11 -0
- package/dist/persona/index.d.ts.map +1 -0
- package/dist/persona/index.js +11 -0
- package/dist/persona/index.js.map +1 -0
- package/dist/persona/lifecycle.d.ts +17 -0
- package/dist/persona/lifecycle.d.ts.map +1 -0
- package/dist/persona/lifecycle.js +36 -0
- package/dist/persona/lifecycle.js.map +1 -0
- package/dist/persona/retrieval.d.ts +6 -0
- package/dist/persona/retrieval.d.ts.map +1 -0
- package/dist/persona/retrieval.js +122 -0
- package/dist/persona/retrieval.js.map +1 -0
- package/dist/persona/sync.d.ts +15 -0
- package/dist/persona/sync.d.ts.map +1 -0
- package/dist/persona/sync.js +92 -0
- package/dist/persona/sync.js.map +1 -0
- package/dist/persona/types.d.ts +283 -0
- package/dist/persona/types.d.ts.map +1 -0
- package/dist/persona/types.js +2 -0
- package/dist/persona/types.js.map +1 -0
- package/dist/persona/zkp/engine.d.ts +26 -0
- package/dist/persona/zkp/engine.d.ts.map +1 -0
- package/dist/persona/zkp/engine.js +370 -0
- package/dist/persona/zkp/engine.js.map +1 -0
- package/dist/persona/zkp/types.d.ts +39 -0
- package/dist/persona/zkp/types.d.ts.map +1 -0
- package/dist/persona/zkp/types.js +2 -0
- package/dist/persona/zkp/types.js.map +1 -0
- package/dist/planner.d.ts +114 -0
- package/dist/planner.d.ts.map +1 -0
- package/dist/planner.js +522 -0
- package/dist/planner.js.map +1 -0
- package/dist/proactive/checkpoints.d.ts +9 -0
- package/dist/proactive/checkpoints.d.ts.map +1 -0
- package/dist/proactive/checkpoints.js +20 -0
- package/dist/proactive/checkpoints.js.map +1 -0
- package/dist/proactive/engine.d.ts +59 -0
- package/dist/proactive/engine.d.ts.map +1 -0
- package/dist/proactive/engine.js +406 -0
- package/dist/proactive/engine.js.map +1 -0
- package/dist/proactive/scheduler.d.ts +11 -0
- package/dist/proactive/scheduler.d.ts.map +1 -0
- package/dist/proactive/scheduler.js +45 -0
- package/dist/proactive/scheduler.js.map +1 -0
- package/dist/proactive/swarm-controller.d.ts +189 -0
- package/dist/proactive/swarm-controller.d.ts.map +1 -0
- package/dist/proactive/swarm-controller.js +477 -0
- package/dist/proactive/swarm-controller.js.map +1 -0
- package/dist/proactive/swarm-registry.d.ts +13 -0
- package/dist/proactive/swarm-registry.d.ts.map +1 -0
- package/dist/proactive/swarm-registry.js +122 -0
- package/dist/proactive/swarm-registry.js.map +1 -0
- package/dist/proactive/types.d.ts +145 -0
- package/dist/proactive/types.d.ts.map +1 -0
- package/dist/proactive/types.js +25 -0
- package/dist/proactive/types.js.map +1 -0
- package/dist/registry.d.ts +35 -0
- package/dist/registry.d.ts.map +1 -0
- package/dist/registry.js +88 -0
- package/dist/registry.js.map +1 -0
- package/dist/reputation.d.ts +123 -0
- package/dist/reputation.d.ts.map +1 -0
- package/dist/reputation.js +366 -0
- package/dist/reputation.js.map +1 -0
- package/dist/reputation.test.d.ts +5 -0
- package/dist/reputation.test.d.ts.map +1 -0
- package/dist/reputation.test.js +265 -0
- package/dist/reputation.test.js.map +1 -0
- package/dist/rooms.d.ts +96 -0
- package/dist/rooms.d.ts.map +1 -0
- package/dist/rooms.js +410 -0
- package/dist/rooms.js.map +1 -0
- package/dist/sdk/client.d.ts +290 -0
- package/dist/sdk/client.d.ts.map +1 -0
- package/dist/sdk/client.js +1287 -0
- package/dist/sdk/client.js.map +1 -0
- package/dist/sdk/index.d.ts +32 -0
- package/dist/sdk/index.d.ts.map +1 -0
- package/dist/sdk/index.js +70 -0
- package/dist/sdk/index.js.map +1 -0
- package/dist/security.d.ts +230 -0
- package/dist/security.d.ts.map +1 -0
- package/dist/security.js +652 -0
- package/dist/security.js.map +1 -0
- package/dist/skills/engine.d.ts +262 -0
- package/dist/skills/engine.d.ts.map +1 -0
- package/dist/skills/engine.js +788 -0
- package/dist/skills/engine.js.map +1 -0
- package/dist/skills/engine.test.d.ts +2 -0
- package/dist/skills/engine.test.d.ts.map +1 -0
- package/dist/skills/engine.test.js +134 -0
- package/dist/skills/engine.test.js.map +1 -0
- package/dist/skills/parser.d.ts +129 -0
- package/dist/skills/parser.d.ts.map +1 -0
- package/dist/skills/parser.js +318 -0
- package/dist/skills/parser.js.map +1 -0
- package/dist/social.d.ts +149 -0
- package/dist/social.d.ts.map +1 -0
- package/dist/social.js +401 -0
- package/dist/social.js.map +1 -0
- package/dist/storage-optimized.d.ts +116 -0
- package/dist/storage-optimized.d.ts.map +1 -0
- package/dist/storage-optimized.js +264 -0
- package/dist/storage-optimized.js.map +1 -0
- package/dist/storage.d.ts +584 -0
- package/dist/storage.d.ts.map +1 -0
- package/dist/storage.js +2703 -0
- package/dist/storage.js.map +1 -0
- package/dist/storage.test.d.ts +2 -0
- package/dist/storage.test.d.ts.map +1 -0
- package/dist/storage.test.js +78 -0
- package/dist/storage.test.js.map +1 -0
- package/dist/swp.d.ts +443 -0
- package/dist/swp.d.ts.map +1 -0
- package/dist/swp.js +223 -0
- package/dist/swp.js.map +1 -0
- package/dist/swp.test.d.ts +5 -0
- package/dist/swp.test.d.ts.map +1 -0
- package/dist/swp.test.js +127 -0
- package/dist/swp.test.js.map +1 -0
- package/dist/templates.d.ts +25 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +1048 -0
- package/dist/templates.js.map +1 -0
- package/dist/test-e2e.d.ts +14 -0
- package/dist/test-e2e.d.ts.map +1 -0
- package/dist/test-e2e.js +266 -0
- package/dist/test-e2e.js.map +1 -0
- package/dist/workers/research-worker.d.ts +19 -0
- package/dist/workers/research-worker.d.ts.map +1 -0
- package/dist/workers/research-worker.js +141 -0
- package/dist/workers/research-worker.js.map +1 -0
- package/package.json +110 -0
|
@@ -0,0 +1,1392 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Society Protocol — MCP (Model Context Protocol) Server
|
|
3
|
+
*
|
|
4
|
+
* Permite que agentes compatíveis com MCP (Claude, Cursor, etc)
|
|
5
|
+
* usem Society Protocol nativamente.
|
|
6
|
+
*/
|
|
7
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
8
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
9
|
+
import { CallToolRequestSchema, GetPromptRequestSchema, ListPromptsRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
10
|
+
export class SocietyMCPServer {
|
|
11
|
+
server;
|
|
12
|
+
client;
|
|
13
|
+
enableReadOnly;
|
|
14
|
+
constructor(config) {
|
|
15
|
+
this.client = config.client;
|
|
16
|
+
this.enableReadOnly = config.enableReadOnly ?? false;
|
|
17
|
+
this.server = new Server({
|
|
18
|
+
name: 'society',
|
|
19
|
+
version: '1.0.0',
|
|
20
|
+
}, {
|
|
21
|
+
capabilities: {
|
|
22
|
+
tools: {},
|
|
23
|
+
resources: {},
|
|
24
|
+
prompts: {},
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
this.registerToolHandlers();
|
|
28
|
+
this.registerResourceHandlers();
|
|
29
|
+
this.registerPromptHandlers();
|
|
30
|
+
}
|
|
31
|
+
registerToolHandlers() {
|
|
32
|
+
// List available tools
|
|
33
|
+
this.server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
34
|
+
tools: this.getTools(),
|
|
35
|
+
}));
|
|
36
|
+
// Handle tool calls
|
|
37
|
+
this.server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
38
|
+
const { name, arguments: args } = request.params;
|
|
39
|
+
try {
|
|
40
|
+
const result = await this.handleToolCall(name, args);
|
|
41
|
+
return {
|
|
42
|
+
content: [
|
|
43
|
+
{
|
|
44
|
+
type: 'text',
|
|
45
|
+
text: JSON.stringify(result, null, 2),
|
|
46
|
+
},
|
|
47
|
+
],
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
return {
|
|
52
|
+
content: [
|
|
53
|
+
{
|
|
54
|
+
type: 'text',
|
|
55
|
+
text: `Error: ${error.message}`,
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
isError: true,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
registerResourceHandlers() {
|
|
64
|
+
this.server.setRequestHandler(ListResourcesRequestSchema, async () => ({
|
|
65
|
+
resources: this.getResources(),
|
|
66
|
+
}));
|
|
67
|
+
this.server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
|
|
68
|
+
const uri = request.params?.uri;
|
|
69
|
+
const resource = await this.handleReadResource(uri);
|
|
70
|
+
return {
|
|
71
|
+
contents: [
|
|
72
|
+
{
|
|
73
|
+
uri,
|
|
74
|
+
mimeType: 'application/json',
|
|
75
|
+
text: JSON.stringify(resource, null, 2),
|
|
76
|
+
},
|
|
77
|
+
],
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
registerPromptHandlers() {
|
|
82
|
+
this.server.setRequestHandler(ListPromptsRequestSchema, async () => ({
|
|
83
|
+
prompts: this.getPrompts(),
|
|
84
|
+
}));
|
|
85
|
+
this.server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
86
|
+
const prompt = await this.handleGetPrompt(request.params?.name, request.params?.arguments || {});
|
|
87
|
+
return {
|
|
88
|
+
description: prompt.description,
|
|
89
|
+
messages: prompt.messages,
|
|
90
|
+
};
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
getTools() {
|
|
94
|
+
const tools = [
|
|
95
|
+
{
|
|
96
|
+
name: 'society_get_status',
|
|
97
|
+
description: 'Get current Society node status including identity, connected peers, and joined rooms',
|
|
98
|
+
inputSchema: {
|
|
99
|
+
type: 'object',
|
|
100
|
+
properties: {},
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: 'society_join_room',
|
|
105
|
+
description: 'Join a Society collaboration room to participate in multi-agent workflows',
|
|
106
|
+
inputSchema: {
|
|
107
|
+
type: 'object',
|
|
108
|
+
properties: {
|
|
109
|
+
room_id: {
|
|
110
|
+
type: 'string',
|
|
111
|
+
description: 'Unique identifier for the room',
|
|
112
|
+
},
|
|
113
|
+
display_name: {
|
|
114
|
+
type: 'string',
|
|
115
|
+
description: 'Display name to use in this room (optional)',
|
|
116
|
+
},
|
|
117
|
+
},
|
|
118
|
+
required: ['room_id'],
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'society_leave_room',
|
|
123
|
+
description: 'Leave a Society room',
|
|
124
|
+
inputSchema: {
|
|
125
|
+
type: 'object',
|
|
126
|
+
properties: {
|
|
127
|
+
room_id: {
|
|
128
|
+
type: 'string',
|
|
129
|
+
description: 'Room to leave',
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
required: ['room_id'],
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: 'society_list_rooms',
|
|
137
|
+
description: 'List all rooms currently joined',
|
|
138
|
+
inputSchema: {
|
|
139
|
+
type: 'object',
|
|
140
|
+
properties: {},
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
name: 'society_get_peers',
|
|
145
|
+
description: 'Get list of connected peers in a room',
|
|
146
|
+
inputSchema: {
|
|
147
|
+
type: 'object',
|
|
148
|
+
properties: {
|
|
149
|
+
room_id: {
|
|
150
|
+
type: 'string',
|
|
151
|
+
description: 'Room to get peers from',
|
|
152
|
+
},
|
|
153
|
+
},
|
|
154
|
+
required: ['room_id'],
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
name: 'society_request_peering',
|
|
159
|
+
description: 'Request peering between a local federation and a remote federation DID with trust policy',
|
|
160
|
+
inputSchema: {
|
|
161
|
+
type: 'object',
|
|
162
|
+
properties: {
|
|
163
|
+
source_federation_id: {
|
|
164
|
+
type: 'string',
|
|
165
|
+
description: 'Local federation ID that will initiate peering',
|
|
166
|
+
},
|
|
167
|
+
target_federation_did: {
|
|
168
|
+
type: 'string',
|
|
169
|
+
description: 'Remote federation DID (did:society:...)',
|
|
170
|
+
},
|
|
171
|
+
policy: {
|
|
172
|
+
type: 'object',
|
|
173
|
+
description: 'Optional trust policy (allowedTypes, maxRatePerMinute, privacyMode)',
|
|
174
|
+
},
|
|
175
|
+
},
|
|
176
|
+
required: ['source_federation_id', 'target_federation_did'],
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
name: 'society_list_peerings',
|
|
181
|
+
description: 'List peering requests and active peerings for a federation',
|
|
182
|
+
inputSchema: {
|
|
183
|
+
type: 'object',
|
|
184
|
+
properties: {
|
|
185
|
+
federation_id: {
|
|
186
|
+
type: 'string',
|
|
187
|
+
description: 'Federation ID',
|
|
188
|
+
},
|
|
189
|
+
status: {
|
|
190
|
+
type: 'string',
|
|
191
|
+
enum: ['pending', 'active', 'rejected', 'revoked'],
|
|
192
|
+
description: 'Optional status filter',
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
required: ['federation_id'],
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: 'society_open_bridge',
|
|
200
|
+
description: 'Open a mesh bridge between local and remote rooms through an active peering',
|
|
201
|
+
inputSchema: {
|
|
202
|
+
type: 'object',
|
|
203
|
+
properties: {
|
|
204
|
+
peering_id: {
|
|
205
|
+
type: 'string',
|
|
206
|
+
description: 'Active peering ID',
|
|
207
|
+
},
|
|
208
|
+
local_room_id: {
|
|
209
|
+
type: 'string',
|
|
210
|
+
description: 'Local room ID',
|
|
211
|
+
},
|
|
212
|
+
remote_room_id: {
|
|
213
|
+
type: 'string',
|
|
214
|
+
description: 'Remote room ID',
|
|
215
|
+
},
|
|
216
|
+
rules: {
|
|
217
|
+
type: 'object',
|
|
218
|
+
description: 'Optional bridge rules override',
|
|
219
|
+
},
|
|
220
|
+
},
|
|
221
|
+
required: ['peering_id', 'local_room_id', 'remote_room_id'],
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: 'society_list_bridges',
|
|
226
|
+
description: 'List federation mesh bridges and metrics',
|
|
227
|
+
inputSchema: {
|
|
228
|
+
type: 'object',
|
|
229
|
+
properties: {
|
|
230
|
+
federation_id: {
|
|
231
|
+
type: 'string',
|
|
232
|
+
description: 'Optional federation ID filter',
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
name: 'society_summon',
|
|
239
|
+
description: 'Start a new collaborative chain (workflow) with AI-generated or template-based plan',
|
|
240
|
+
inputSchema: {
|
|
241
|
+
type: 'object',
|
|
242
|
+
properties: {
|
|
243
|
+
goal: {
|
|
244
|
+
type: 'string',
|
|
245
|
+
description: 'High-level goal or objective for the collaboration',
|
|
246
|
+
},
|
|
247
|
+
room_id: {
|
|
248
|
+
type: 'string',
|
|
249
|
+
description: 'Room to create the chain in',
|
|
250
|
+
},
|
|
251
|
+
template: {
|
|
252
|
+
type: 'string',
|
|
253
|
+
description: 'Optional template to use (e.g., "software_feature", "research_swarm")',
|
|
254
|
+
},
|
|
255
|
+
priority: {
|
|
256
|
+
type: 'string',
|
|
257
|
+
enum: ['low', 'normal', 'high', 'critical'],
|
|
258
|
+
description: 'Priority level for this collaboration',
|
|
259
|
+
},
|
|
260
|
+
},
|
|
261
|
+
required: ['goal', 'room_id'],
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
name: 'society_start_mission',
|
|
266
|
+
description: 'Start a proactive scientific research mission with swarm workers',
|
|
267
|
+
inputSchema: {
|
|
268
|
+
type: 'object',
|
|
269
|
+
properties: {
|
|
270
|
+
room_id: { type: 'string', description: 'Mission room' },
|
|
271
|
+
goal: { type: 'string', description: 'Research goal' },
|
|
272
|
+
template: {
|
|
273
|
+
type: 'string',
|
|
274
|
+
enum: ['literature_review_continuous', 'hypothesis_swarm', 'research_monitor'],
|
|
275
|
+
description: 'Mission template',
|
|
276
|
+
},
|
|
277
|
+
cadence_ms: { type: 'number', description: 'Mission cadence in milliseconds' },
|
|
278
|
+
},
|
|
279
|
+
required: ['goal', 'room_id'],
|
|
280
|
+
},
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
name: 'society_pause_mission',
|
|
284
|
+
description: 'Pause a proactive mission',
|
|
285
|
+
inputSchema: {
|
|
286
|
+
type: 'object',
|
|
287
|
+
properties: {
|
|
288
|
+
mission_id: { type: 'string', description: 'Mission ID' },
|
|
289
|
+
},
|
|
290
|
+
required: ['mission_id'],
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
name: 'society_resume_mission',
|
|
295
|
+
description: 'Resume a proactive mission',
|
|
296
|
+
inputSchema: {
|
|
297
|
+
type: 'object',
|
|
298
|
+
properties: {
|
|
299
|
+
mission_id: { type: 'string', description: 'Mission ID' },
|
|
300
|
+
},
|
|
301
|
+
required: ['mission_id'],
|
|
302
|
+
},
|
|
303
|
+
},
|
|
304
|
+
{
|
|
305
|
+
name: 'society_stop_mission',
|
|
306
|
+
description: 'Stop a proactive mission',
|
|
307
|
+
inputSchema: {
|
|
308
|
+
type: 'object',
|
|
309
|
+
properties: {
|
|
310
|
+
mission_id: { type: 'string', description: 'Mission ID' },
|
|
311
|
+
reason: { type: 'string', description: 'Optional reason' },
|
|
312
|
+
},
|
|
313
|
+
required: ['mission_id'],
|
|
314
|
+
},
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
name: 'society_list_missions',
|
|
318
|
+
description: 'List proactive missions',
|
|
319
|
+
inputSchema: {
|
|
320
|
+
type: 'object',
|
|
321
|
+
properties: {
|
|
322
|
+
room_id: { type: 'string', description: 'Optional room filter' },
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
name: 'society_get_swarm_status',
|
|
328
|
+
description: 'Get worker visibility and capacity in the swarm',
|
|
329
|
+
inputSchema: {
|
|
330
|
+
type: 'object',
|
|
331
|
+
properties: {
|
|
332
|
+
room_id: { type: 'string', description: 'Optional room filter' },
|
|
333
|
+
},
|
|
334
|
+
},
|
|
335
|
+
},
|
|
336
|
+
{
|
|
337
|
+
name: 'society_start_research_swarm',
|
|
338
|
+
description: 'Start this node as a research worker for a room',
|
|
339
|
+
inputSchema: {
|
|
340
|
+
type: 'object',
|
|
341
|
+
properties: {
|
|
342
|
+
room_id: { type: 'string', description: 'Mission room' },
|
|
343
|
+
host_id: { type: 'string', description: 'Worker host identifier' },
|
|
344
|
+
runtime: { type: 'string', enum: ['nanobot', 'docker', 'ollama', 'custom'] },
|
|
345
|
+
specialties: { type: 'array', items: { type: 'string' } },
|
|
346
|
+
capabilities: { type: 'array', items: { type: 'string' } },
|
|
347
|
+
},
|
|
348
|
+
required: ['room_id', 'host_id', 'runtime'],
|
|
349
|
+
},
|
|
350
|
+
},
|
|
351
|
+
{
|
|
352
|
+
name: 'society_list_chains',
|
|
353
|
+
description: 'List active collaboration chains in a room',
|
|
354
|
+
inputSchema: {
|
|
355
|
+
type: 'object',
|
|
356
|
+
properties: {
|
|
357
|
+
room_id: {
|
|
358
|
+
type: 'string',
|
|
359
|
+
description: 'Room to list chains from',
|
|
360
|
+
},
|
|
361
|
+
status: {
|
|
362
|
+
type: 'string',
|
|
363
|
+
enum: ['all', 'open', 'running', 'completed'],
|
|
364
|
+
description: 'Filter by chain status',
|
|
365
|
+
},
|
|
366
|
+
},
|
|
367
|
+
required: ['room_id'],
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
{
|
|
371
|
+
name: 'society_get_chain',
|
|
372
|
+
description: 'Get detailed information about a specific chain including all steps and their status',
|
|
373
|
+
inputSchema: {
|
|
374
|
+
type: 'object',
|
|
375
|
+
properties: {
|
|
376
|
+
chain_id: {
|
|
377
|
+
type: 'string',
|
|
378
|
+
description: 'ID of the chain to get',
|
|
379
|
+
},
|
|
380
|
+
},
|
|
381
|
+
required: ['chain_id'],
|
|
382
|
+
},
|
|
383
|
+
},
|
|
384
|
+
{
|
|
385
|
+
name: 'society_get_pending_steps',
|
|
386
|
+
description: 'Get steps assigned to this agent that are ready to work on',
|
|
387
|
+
inputSchema: {
|
|
388
|
+
type: 'object',
|
|
389
|
+
properties: {},
|
|
390
|
+
},
|
|
391
|
+
},
|
|
392
|
+
{
|
|
393
|
+
name: 'society_submit_step',
|
|
394
|
+
description: 'Submit work result for a step you are assigned to',
|
|
395
|
+
inputSchema: {
|
|
396
|
+
type: 'object',
|
|
397
|
+
properties: {
|
|
398
|
+
step_id: {
|
|
399
|
+
type: 'string',
|
|
400
|
+
description: 'ID of the step to submit',
|
|
401
|
+
},
|
|
402
|
+
status: {
|
|
403
|
+
type: 'string',
|
|
404
|
+
enum: ['completed', 'failed', 'partial'],
|
|
405
|
+
description: 'Completion status of the step',
|
|
406
|
+
},
|
|
407
|
+
result: {
|
|
408
|
+
type: 'string',
|
|
409
|
+
description: 'Detailed result, output, or explanation of the work done',
|
|
410
|
+
},
|
|
411
|
+
artifacts: {
|
|
412
|
+
type: 'array',
|
|
413
|
+
description: 'Optional list of artifact references (file paths, URLs)',
|
|
414
|
+
items: {
|
|
415
|
+
type: 'string',
|
|
416
|
+
},
|
|
417
|
+
},
|
|
418
|
+
},
|
|
419
|
+
required: ['step_id', 'status', 'result'],
|
|
420
|
+
},
|
|
421
|
+
},
|
|
422
|
+
{
|
|
423
|
+
name: 'society_review_step',
|
|
424
|
+
description: 'Review a step that is pending approval',
|
|
425
|
+
inputSchema: {
|
|
426
|
+
type: 'object',
|
|
427
|
+
properties: {
|
|
428
|
+
step_id: {
|
|
429
|
+
type: 'string',
|
|
430
|
+
description: 'ID of the step to review',
|
|
431
|
+
},
|
|
432
|
+
decision: {
|
|
433
|
+
type: 'string',
|
|
434
|
+
enum: ['approved', 'rejected', 'needs_revision'],
|
|
435
|
+
description: 'Review decision',
|
|
436
|
+
},
|
|
437
|
+
notes: {
|
|
438
|
+
type: 'string',
|
|
439
|
+
description: 'Review notes and feedback',
|
|
440
|
+
},
|
|
441
|
+
},
|
|
442
|
+
required: ['step_id', 'decision', 'notes'],
|
|
443
|
+
},
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
name: 'society_cancel_chain',
|
|
447
|
+
description: 'Cancel an active chain',
|
|
448
|
+
inputSchema: {
|
|
449
|
+
type: 'object',
|
|
450
|
+
properties: {
|
|
451
|
+
chain_id: {
|
|
452
|
+
type: 'string',
|
|
453
|
+
description: 'ID of the chain to cancel',
|
|
454
|
+
},
|
|
455
|
+
reason: {
|
|
456
|
+
type: 'string',
|
|
457
|
+
description: 'Reason for cancellation',
|
|
458
|
+
},
|
|
459
|
+
},
|
|
460
|
+
required: ['chain_id'],
|
|
461
|
+
},
|
|
462
|
+
},
|
|
463
|
+
{
|
|
464
|
+
name: 'society_get_reputation',
|
|
465
|
+
description: 'Get reputation score for an agent (or yourself if no DID provided)',
|
|
466
|
+
inputSchema: {
|
|
467
|
+
type: 'object',
|
|
468
|
+
properties: {
|
|
469
|
+
did: {
|
|
470
|
+
type: 'string',
|
|
471
|
+
description: 'DID of the agent (optional, defaults to self)',
|
|
472
|
+
},
|
|
473
|
+
},
|
|
474
|
+
},
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
name: 'society_send_message',
|
|
478
|
+
description: 'Send a chat message to a room',
|
|
479
|
+
inputSchema: {
|
|
480
|
+
type: 'object',
|
|
481
|
+
properties: {
|
|
482
|
+
room_id: {
|
|
483
|
+
type: 'string',
|
|
484
|
+
description: 'Room to send message to',
|
|
485
|
+
},
|
|
486
|
+
message: {
|
|
487
|
+
type: 'string',
|
|
488
|
+
description: 'Message content',
|
|
489
|
+
},
|
|
490
|
+
reply_to: {
|
|
491
|
+
type: 'string',
|
|
492
|
+
description: 'Message ID to reply to (optional)',
|
|
493
|
+
},
|
|
494
|
+
},
|
|
495
|
+
required: ['room_id', 'message'],
|
|
496
|
+
},
|
|
497
|
+
},
|
|
498
|
+
{
|
|
499
|
+
name: 'society_list_templates',
|
|
500
|
+
description: 'List available collaboration templates',
|
|
501
|
+
inputSchema: {
|
|
502
|
+
type: 'object',
|
|
503
|
+
properties: {
|
|
504
|
+
category: {
|
|
505
|
+
type: 'string',
|
|
506
|
+
description: 'Filter by category (software, research, creative, medical, business)',
|
|
507
|
+
},
|
|
508
|
+
},
|
|
509
|
+
},
|
|
510
|
+
},
|
|
511
|
+
{
|
|
512
|
+
name: 'society_export_capsule',
|
|
513
|
+
description: 'Export a completed chain as a portable capsule',
|
|
514
|
+
inputSchema: {
|
|
515
|
+
type: 'object',
|
|
516
|
+
properties: {
|
|
517
|
+
chain_id: {
|
|
518
|
+
type: 'string',
|
|
519
|
+
description: 'Chain to export',
|
|
520
|
+
},
|
|
521
|
+
output_path: {
|
|
522
|
+
type: 'string',
|
|
523
|
+
description: 'Directory to save the capsule',
|
|
524
|
+
},
|
|
525
|
+
},
|
|
526
|
+
required: ['chain_id'],
|
|
527
|
+
},
|
|
528
|
+
},
|
|
529
|
+
{
|
|
530
|
+
name: 'persona_add_memory',
|
|
531
|
+
description: 'Add memory to Persona Vault',
|
|
532
|
+
inputSchema: {
|
|
533
|
+
type: 'object',
|
|
534
|
+
properties: {
|
|
535
|
+
capability_token: { type: 'string' },
|
|
536
|
+
zkp_proofs: { type: 'array', items: { type: 'object' } },
|
|
537
|
+
vault_id: { type: 'string' },
|
|
538
|
+
domain: { type: 'string' },
|
|
539
|
+
type: { type: 'string' },
|
|
540
|
+
title: { type: 'string' },
|
|
541
|
+
content: { type: 'string' },
|
|
542
|
+
tags: { type: 'array', items: { type: 'string' } },
|
|
543
|
+
confidence: { type: 'number' },
|
|
544
|
+
},
|
|
545
|
+
required: ['domain', 'type', 'title', 'content'],
|
|
546
|
+
},
|
|
547
|
+
},
|
|
548
|
+
{
|
|
549
|
+
name: 'persona_search_memories',
|
|
550
|
+
description: 'Search memories using hybrid lexical+graph retrieval',
|
|
551
|
+
inputSchema: {
|
|
552
|
+
type: 'object',
|
|
553
|
+
properties: {
|
|
554
|
+
capability_token: { type: 'string' },
|
|
555
|
+
zkp_proofs: { type: 'array', items: { type: 'object' } },
|
|
556
|
+
vault_id: { type: 'string' },
|
|
557
|
+
query: { type: 'string' },
|
|
558
|
+
domain: { type: 'string' },
|
|
559
|
+
limit: { type: 'number' },
|
|
560
|
+
},
|
|
561
|
+
},
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
name: 'persona_query_graph',
|
|
565
|
+
description: 'Query Persona Vault graph',
|
|
566
|
+
inputSchema: {
|
|
567
|
+
type: 'object',
|
|
568
|
+
properties: {
|
|
569
|
+
capability_token: { type: 'string' },
|
|
570
|
+
zkp_proofs: { type: 'array', items: { type: 'object' } },
|
|
571
|
+
vault_id: { type: 'string' },
|
|
572
|
+
root_node_id: { type: 'string' },
|
|
573
|
+
domain: { type: 'string' },
|
|
574
|
+
max_depth: { type: 'number' },
|
|
575
|
+
limit: { type: 'number' },
|
|
576
|
+
},
|
|
577
|
+
},
|
|
578
|
+
},
|
|
579
|
+
{
|
|
580
|
+
name: 'persona_update_preference',
|
|
581
|
+
description: 'Update user preference in Persona Vault',
|
|
582
|
+
inputSchema: {
|
|
583
|
+
type: 'object',
|
|
584
|
+
properties: {
|
|
585
|
+
capability_token: { type: 'string' },
|
|
586
|
+
zkp_proofs: { type: 'array', items: { type: 'object' } },
|
|
587
|
+
vault_id: { type: 'string' },
|
|
588
|
+
key: { type: 'string' },
|
|
589
|
+
value: {},
|
|
590
|
+
confidence: { type: 'number' },
|
|
591
|
+
domain: { type: 'string' },
|
|
592
|
+
},
|
|
593
|
+
required: ['key', 'value'],
|
|
594
|
+
},
|
|
595
|
+
},
|
|
596
|
+
{
|
|
597
|
+
name: 'persona_issue_capability',
|
|
598
|
+
description: 'Issue attenuable capability token for Persona Vault access',
|
|
599
|
+
inputSchema: {
|
|
600
|
+
type: 'object',
|
|
601
|
+
properties: {
|
|
602
|
+
capability_token: { type: 'string' },
|
|
603
|
+
zkp_proofs: { type: 'array', items: { type: 'object' } },
|
|
604
|
+
vault_id: { type: 'string' },
|
|
605
|
+
service_did: { type: 'string' },
|
|
606
|
+
scope: { type: 'string' },
|
|
607
|
+
caveats: { type: 'object' },
|
|
608
|
+
},
|
|
609
|
+
required: ['service_did', 'scope', 'caveats'],
|
|
610
|
+
},
|
|
611
|
+
},
|
|
612
|
+
{
|
|
613
|
+
name: 'persona_revoke_capability',
|
|
614
|
+
description: 'Revoke previously issued capability token',
|
|
615
|
+
inputSchema: {
|
|
616
|
+
type: 'object',
|
|
617
|
+
properties: {
|
|
618
|
+
capability_token: { type: 'string' },
|
|
619
|
+
zkp_proofs: { type: 'array', items: { type: 'object' } },
|
|
620
|
+
token_id: { type: 'string' },
|
|
621
|
+
reason: { type: 'string' },
|
|
622
|
+
},
|
|
623
|
+
required: ['token_id', 'reason'],
|
|
624
|
+
},
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
name: 'persona_attenuate_capability',
|
|
628
|
+
description: 'Attenuate an existing capability token caveat set',
|
|
629
|
+
inputSchema: {
|
|
630
|
+
type: 'object',
|
|
631
|
+
properties: {
|
|
632
|
+
capability_token: { type: 'string' },
|
|
633
|
+
zkp_proofs: { type: 'array', items: { type: 'object' } },
|
|
634
|
+
token_id: { type: 'string' },
|
|
635
|
+
caveats_patch: { type: 'object' },
|
|
636
|
+
},
|
|
637
|
+
required: ['token_id', 'caveats_patch'],
|
|
638
|
+
},
|
|
639
|
+
},
|
|
640
|
+
{
|
|
641
|
+
name: 'persona_issue_claim',
|
|
642
|
+
description: 'Issue a Persona claim (self-claim or issuer-claim)',
|
|
643
|
+
inputSchema: {
|
|
644
|
+
type: 'object',
|
|
645
|
+
properties: {
|
|
646
|
+
capability_token: { type: 'string' },
|
|
647
|
+
zkp_proofs: { type: 'array', items: { type: 'object' } },
|
|
648
|
+
vault_id: { type: 'string' },
|
|
649
|
+
schema: { type: 'string' },
|
|
650
|
+
payload: { type: 'object' },
|
|
651
|
+
subject_did: { type: 'string' },
|
|
652
|
+
issuer_did: { type: 'string' },
|
|
653
|
+
issuer_signature: { type: 'string' },
|
|
654
|
+
expires_at: { type: 'number' },
|
|
655
|
+
},
|
|
656
|
+
required: ['schema', 'payload'],
|
|
657
|
+
},
|
|
658
|
+
},
|
|
659
|
+
{
|
|
660
|
+
name: 'persona_generate_zk_proof',
|
|
661
|
+
description: 'Generate a ZKP bundle for a supported Persona circuit',
|
|
662
|
+
inputSchema: {
|
|
663
|
+
type: 'object',
|
|
664
|
+
properties: {
|
|
665
|
+
capability_token: { type: 'string' },
|
|
666
|
+
vault_id: { type: 'string' },
|
|
667
|
+
circuit_id: { type: 'string' },
|
|
668
|
+
private_inputs: { type: 'object' },
|
|
669
|
+
public_inputs: { type: 'object' },
|
|
670
|
+
claim_ids: { type: 'array', items: { type: 'string' } },
|
|
671
|
+
expires_at: { type: 'number' },
|
|
672
|
+
},
|
|
673
|
+
required: ['circuit_id', 'private_inputs'],
|
|
674
|
+
},
|
|
675
|
+
},
|
|
676
|
+
{
|
|
677
|
+
name: 'persona_verify_zk_proof',
|
|
678
|
+
description: 'Verify a ZKP bundle for a supported Persona circuit',
|
|
679
|
+
inputSchema: {
|
|
680
|
+
type: 'object',
|
|
681
|
+
properties: {
|
|
682
|
+
capability_token: { type: 'string' },
|
|
683
|
+
vault_id: { type: 'string' },
|
|
684
|
+
proof_bundle: { type: 'object' },
|
|
685
|
+
},
|
|
686
|
+
required: ['proof_bundle'],
|
|
687
|
+
},
|
|
688
|
+
},
|
|
689
|
+
{
|
|
690
|
+
name: 'persona_share_subgraph',
|
|
691
|
+
description: 'Export a portable subgraph from Persona Vault',
|
|
692
|
+
inputSchema: {
|
|
693
|
+
type: 'object',
|
|
694
|
+
properties: {
|
|
695
|
+
capability_token: { type: 'string' },
|
|
696
|
+
zkp_proofs: { type: 'array', items: { type: 'object' } },
|
|
697
|
+
vault_id: { type: 'string' },
|
|
698
|
+
domain: { type: 'string' },
|
|
699
|
+
node_ids: { type: 'array', items: { type: 'string' } },
|
|
700
|
+
include_neighbors: { type: 'boolean' },
|
|
701
|
+
},
|
|
702
|
+
},
|
|
703
|
+
},
|
|
704
|
+
{
|
|
705
|
+
name: 'persona_get_profile',
|
|
706
|
+
description: 'Get current Persona profile snapshot',
|
|
707
|
+
inputSchema: {
|
|
708
|
+
type: 'object',
|
|
709
|
+
properties: {
|
|
710
|
+
capability_token: { type: 'string' },
|
|
711
|
+
zkp_proofs: { type: 'array', items: { type: 'object' } },
|
|
712
|
+
vault_id: { type: 'string' },
|
|
713
|
+
},
|
|
714
|
+
},
|
|
715
|
+
},
|
|
716
|
+
{
|
|
717
|
+
name: 'persona_verify_access_log',
|
|
718
|
+
description: 'Verify signature integrity of one persona access log entry',
|
|
719
|
+
inputSchema: {
|
|
720
|
+
type: 'object',
|
|
721
|
+
properties: {
|
|
722
|
+
capability_token: { type: 'string' },
|
|
723
|
+
zkp_proofs: { type: 'array', items: { type: 'object' } },
|
|
724
|
+
log_id: { type: 'number' },
|
|
725
|
+
},
|
|
726
|
+
required: ['log_id'],
|
|
727
|
+
},
|
|
728
|
+
},
|
|
729
|
+
{
|
|
730
|
+
name: 'persona_run_retention_sweep',
|
|
731
|
+
description: 'Run retention cleanup sweep by vault/domain (supports dry-run)',
|
|
732
|
+
inputSchema: {
|
|
733
|
+
type: 'object',
|
|
734
|
+
properties: {
|
|
735
|
+
capability_token: { type: 'string' },
|
|
736
|
+
zkp_proofs: { type: 'array', items: { type: 'object' } },
|
|
737
|
+
vault_id: { type: 'string' },
|
|
738
|
+
domain: { type: 'string' },
|
|
739
|
+
dry_run: { type: 'boolean' },
|
|
740
|
+
},
|
|
741
|
+
},
|
|
742
|
+
},
|
|
743
|
+
];
|
|
744
|
+
if (this.enableReadOnly) {
|
|
745
|
+
// Filter to only read-only operations
|
|
746
|
+
return tools.filter(t => ['society_get_status', 'society_list_rooms', 'society_get_peers',
|
|
747
|
+
'society_list_chains', 'society_get_chain', 'society_get_pending_steps',
|
|
748
|
+
'society_get_reputation', 'society_list_templates',
|
|
749
|
+
'society_list_peerings', 'society_list_bridges',
|
|
750
|
+
'persona_search_memories', 'persona_query_graph', 'persona_get_profile',
|
|
751
|
+
'persona_verify_zk_proof', 'persona_verify_access_log'].includes(t.name));
|
|
752
|
+
}
|
|
753
|
+
return tools;
|
|
754
|
+
}
|
|
755
|
+
getResources() {
|
|
756
|
+
return [
|
|
757
|
+
{
|
|
758
|
+
uri: 'persona://profile',
|
|
759
|
+
name: 'Persona Profile',
|
|
760
|
+
description: 'Current profile snapshot from Persona Vault',
|
|
761
|
+
mimeType: 'application/json',
|
|
762
|
+
},
|
|
763
|
+
{
|
|
764
|
+
uri: 'persona://memory/{id}',
|
|
765
|
+
name: 'Persona Memory by ID',
|
|
766
|
+
description: 'Single memory resource by id',
|
|
767
|
+
mimeType: 'application/json',
|
|
768
|
+
},
|
|
769
|
+
{
|
|
770
|
+
uri: 'persona://preferences/{category}',
|
|
771
|
+
name: 'Persona Preferences by Category',
|
|
772
|
+
description: 'Preference subset by category',
|
|
773
|
+
mimeType: 'application/json',
|
|
774
|
+
},
|
|
775
|
+
{
|
|
776
|
+
uri: 'persona://graph/{domain}',
|
|
777
|
+
name: 'Persona Graph by Domain',
|
|
778
|
+
description: 'Graph view scoped to domain',
|
|
779
|
+
mimeType: 'application/json',
|
|
780
|
+
},
|
|
781
|
+
{
|
|
782
|
+
uri: 'persona://capabilities/{token_id}',
|
|
783
|
+
name: 'Persona Capability by Token',
|
|
784
|
+
description: 'Capability token metadata',
|
|
785
|
+
mimeType: 'application/json',
|
|
786
|
+
},
|
|
787
|
+
{
|
|
788
|
+
uri: 'persona://capabilities/active',
|
|
789
|
+
name: 'Persona Active Capabilities',
|
|
790
|
+
description: 'List active capability grants',
|
|
791
|
+
mimeType: 'application/json',
|
|
792
|
+
},
|
|
793
|
+
{
|
|
794
|
+
uri: 'persona://claims/{claim_id}',
|
|
795
|
+
name: 'Persona Claim by ID',
|
|
796
|
+
description: 'Claim metadata and status by claim id',
|
|
797
|
+
mimeType: 'application/json',
|
|
798
|
+
},
|
|
799
|
+
{
|
|
800
|
+
uri: 'persona://zkp/circuits',
|
|
801
|
+
name: 'Persona ZKP Circuits',
|
|
802
|
+
description: 'Supported ZKP circuits and metadata',
|
|
803
|
+
mimeType: 'application/json',
|
|
804
|
+
},
|
|
805
|
+
{
|
|
806
|
+
uri: 'persona://zkp/proofs/{proof_id}',
|
|
807
|
+
name: 'Persona ZKP Proof by ID',
|
|
808
|
+
description: 'Generated proof bundle metadata',
|
|
809
|
+
mimeType: 'application/json',
|
|
810
|
+
},
|
|
811
|
+
];
|
|
812
|
+
}
|
|
813
|
+
getPrompts() {
|
|
814
|
+
return [
|
|
815
|
+
{
|
|
816
|
+
name: 'persona_context',
|
|
817
|
+
description: 'Generate assistant context from Persona Vault profile',
|
|
818
|
+
arguments: [{ name: 'vault_id', description: 'Optional vault id', required: false }],
|
|
819
|
+
},
|
|
820
|
+
{
|
|
821
|
+
name: 'persona_preferences_snapshot',
|
|
822
|
+
description: 'Generate concise preference summary for personalization',
|
|
823
|
+
arguments: [{ name: 'vault_id', description: 'Optional vault id', required: false }],
|
|
824
|
+
},
|
|
825
|
+
{
|
|
826
|
+
name: 'persona_memory_digest',
|
|
827
|
+
description: 'Generate top memory digest for a query',
|
|
828
|
+
arguments: [
|
|
829
|
+
{ name: 'query', description: 'Query text', required: false },
|
|
830
|
+
{ name: 'vault_id', description: 'Optional vault id', required: false },
|
|
831
|
+
],
|
|
832
|
+
},
|
|
833
|
+
{
|
|
834
|
+
name: 'persona_zkp_challenge',
|
|
835
|
+
description: 'Generate a challenge prompt for proving persona claims with ZKP',
|
|
836
|
+
arguments: [
|
|
837
|
+
{ name: 'circuit_id', description: 'ZKP circuit id', required: true },
|
|
838
|
+
{ name: 'vault_id', description: 'Optional vault id', required: false },
|
|
839
|
+
],
|
|
840
|
+
},
|
|
841
|
+
];
|
|
842
|
+
}
|
|
843
|
+
async handleToolCall(name, args) {
|
|
844
|
+
switch (name) {
|
|
845
|
+
case 'society_get_status':
|
|
846
|
+
return this.handleGetStatus();
|
|
847
|
+
case 'society_join_room':
|
|
848
|
+
return this.handleJoinRoom(args);
|
|
849
|
+
case 'society_leave_room':
|
|
850
|
+
return this.handleLeaveRoom(args);
|
|
851
|
+
case 'society_list_rooms':
|
|
852
|
+
return this.handleListRooms();
|
|
853
|
+
case 'society_get_peers':
|
|
854
|
+
return this.handleGetPeers(args);
|
|
855
|
+
case 'society_request_peering':
|
|
856
|
+
return this.handleRequestPeering(args);
|
|
857
|
+
case 'society_list_peerings':
|
|
858
|
+
return this.handleListPeerings(args);
|
|
859
|
+
case 'society_open_bridge':
|
|
860
|
+
return this.handleOpenBridge(args);
|
|
861
|
+
case 'society_list_bridges':
|
|
862
|
+
return this.handleListBridges(args);
|
|
863
|
+
case 'society_summon':
|
|
864
|
+
return this.handleSummon(args);
|
|
865
|
+
case 'society_start_mission':
|
|
866
|
+
return this.handleStartMission(args);
|
|
867
|
+
case 'society_pause_mission':
|
|
868
|
+
return this.handlePauseMission(args);
|
|
869
|
+
case 'society_resume_mission':
|
|
870
|
+
return this.handleResumeMission(args);
|
|
871
|
+
case 'society_stop_mission':
|
|
872
|
+
return this.handleStopMission(args);
|
|
873
|
+
case 'society_list_missions':
|
|
874
|
+
return this.handleListMissions(args);
|
|
875
|
+
case 'society_get_swarm_status':
|
|
876
|
+
return this.handleGetSwarmStatus(args);
|
|
877
|
+
case 'society_start_research_swarm':
|
|
878
|
+
return this.handleStartResearchSwarm(args);
|
|
879
|
+
case 'society_list_chains':
|
|
880
|
+
return this.handleListChains(args);
|
|
881
|
+
case 'society_get_chain':
|
|
882
|
+
return this.handleGetChain(args);
|
|
883
|
+
case 'society_get_pending_steps':
|
|
884
|
+
return this.handleGetPendingSteps();
|
|
885
|
+
case 'society_submit_step':
|
|
886
|
+
return this.handleSubmitStep(args);
|
|
887
|
+
case 'society_review_step':
|
|
888
|
+
return this.handleReviewStep(args);
|
|
889
|
+
case 'society_cancel_chain':
|
|
890
|
+
return this.handleCancelChain(args);
|
|
891
|
+
case 'society_get_reputation':
|
|
892
|
+
return this.handleGetReputation(args);
|
|
893
|
+
case 'society_send_message':
|
|
894
|
+
return this.handleSendMessage(args);
|
|
895
|
+
case 'society_list_templates':
|
|
896
|
+
return this.handleListTemplates(args);
|
|
897
|
+
case 'society_export_capsule':
|
|
898
|
+
return this.handleExportCapsule(args);
|
|
899
|
+
case 'persona_add_memory':
|
|
900
|
+
return this.handlePersonaAddMemory(args);
|
|
901
|
+
case 'persona_search_memories':
|
|
902
|
+
return this.handlePersonaSearchMemories(args);
|
|
903
|
+
case 'persona_query_graph':
|
|
904
|
+
return this.handlePersonaQueryGraph(args);
|
|
905
|
+
case 'persona_update_preference':
|
|
906
|
+
return this.handlePersonaUpdatePreference(args);
|
|
907
|
+
case 'persona_issue_capability':
|
|
908
|
+
return this.handlePersonaIssueCapability(args);
|
|
909
|
+
case 'persona_revoke_capability':
|
|
910
|
+
return this.handlePersonaRevokeCapability(args);
|
|
911
|
+
case 'persona_attenuate_capability':
|
|
912
|
+
return this.handlePersonaAttenuateCapability(args);
|
|
913
|
+
case 'persona_issue_claim':
|
|
914
|
+
return this.handlePersonaIssueClaim(args);
|
|
915
|
+
case 'persona_generate_zk_proof':
|
|
916
|
+
return this.handlePersonaGenerateZkProof(args);
|
|
917
|
+
case 'persona_verify_zk_proof':
|
|
918
|
+
return this.handlePersonaVerifyZkProof(args);
|
|
919
|
+
case 'persona_share_subgraph':
|
|
920
|
+
return this.handlePersonaShareSubgraph(args);
|
|
921
|
+
case 'persona_get_profile':
|
|
922
|
+
return this.handlePersonaGetProfile(args);
|
|
923
|
+
case 'persona_verify_access_log':
|
|
924
|
+
return this.handlePersonaVerifyAccessLog(args);
|
|
925
|
+
case 'persona_run_retention_sweep':
|
|
926
|
+
return this.handlePersonaRunRetentionSweep(args);
|
|
927
|
+
default:
|
|
928
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
929
|
+
}
|
|
930
|
+
}
|
|
931
|
+
// ─── Tool Handlers ────────────────────────────────────────────
|
|
932
|
+
async handleGetStatus() {
|
|
933
|
+
return {
|
|
934
|
+
identity: this.client.getIdentity(),
|
|
935
|
+
network: {
|
|
936
|
+
peer_id: this.client.getPeerId(),
|
|
937
|
+
addresses: this.client.getMultiaddrs(),
|
|
938
|
+
},
|
|
939
|
+
rooms: this.client.getJoinedRooms(),
|
|
940
|
+
capabilities: this.client.getCapabilities(),
|
|
941
|
+
};
|
|
942
|
+
}
|
|
943
|
+
async handleJoinRoom(args) {
|
|
944
|
+
await this.client.joinRoom(args.room_id);
|
|
945
|
+
return { success: true, room_id: args.room_id };
|
|
946
|
+
}
|
|
947
|
+
async handleLeaveRoom(args) {
|
|
948
|
+
await this.client.leaveRoom(args.room_id);
|
|
949
|
+
return { success: true, room_id: args.room_id };
|
|
950
|
+
}
|
|
951
|
+
async handleListRooms() {
|
|
952
|
+
return { rooms: this.client.getJoinedRooms() };
|
|
953
|
+
}
|
|
954
|
+
async handleGetPeers(args) {
|
|
955
|
+
const peers = await this.client.getPeers(args.room_id);
|
|
956
|
+
return { room_id: args.room_id, peers };
|
|
957
|
+
}
|
|
958
|
+
async handleRequestPeering(args) {
|
|
959
|
+
const peering = await this.client.createPeering(args.source_federation_id, args.target_federation_did, args.policy);
|
|
960
|
+
return { peering };
|
|
961
|
+
}
|
|
962
|
+
async handleListPeerings(args) {
|
|
963
|
+
const peerings = this.client.listPeerings(args.federation_id, args.status);
|
|
964
|
+
return { peerings };
|
|
965
|
+
}
|
|
966
|
+
async handleOpenBridge(args) {
|
|
967
|
+
const bridge = await this.client.openBridge(args.peering_id, args.local_room_id, args.remote_room_id, args.rules);
|
|
968
|
+
return { bridge };
|
|
969
|
+
}
|
|
970
|
+
async handleListBridges(args) {
|
|
971
|
+
const bridges = this.client.listBridges(args.federation_id);
|
|
972
|
+
const stats = this.client.getMeshStats(args.federation_id);
|
|
973
|
+
return { bridges, stats };
|
|
974
|
+
}
|
|
975
|
+
async handleSummon(args) {
|
|
976
|
+
const chain = await this.client.summon({
|
|
977
|
+
goal: args.goal,
|
|
978
|
+
roomId: args.room_id,
|
|
979
|
+
template: args.template,
|
|
980
|
+
priority: args.priority,
|
|
981
|
+
});
|
|
982
|
+
return { chain_id: chain.id, steps: chain.steps.length };
|
|
983
|
+
}
|
|
984
|
+
async handleStartMission(args) {
|
|
985
|
+
const mission = await this.client.startMission({
|
|
986
|
+
roomId: args.room_id,
|
|
987
|
+
goal: args.goal,
|
|
988
|
+
missionType: 'scientific_research',
|
|
989
|
+
templateId: args.template,
|
|
990
|
+
mode: 'continuous',
|
|
991
|
+
cadenceMs: args.cadence_ms || 300000,
|
|
992
|
+
policy: {
|
|
993
|
+
autonomy: 'semiautonomous',
|
|
994
|
+
approvalGates: ['publish', 'external_write', 'costly_action'],
|
|
995
|
+
swarm: {
|
|
996
|
+
minWorkers: 2,
|
|
997
|
+
maxWorkers: 12,
|
|
998
|
+
targetUtilization: 0.7,
|
|
999
|
+
leaseMs: 120000,
|
|
1000
|
+
rebalanceIntervalMs: 30000,
|
|
1001
|
+
},
|
|
1002
|
+
retry: {
|
|
1003
|
+
maxStepRetries: 3,
|
|
1004
|
+
maxMissionReplans: 20,
|
|
1005
|
+
cooldownMs: 60000,
|
|
1006
|
+
},
|
|
1007
|
+
},
|
|
1008
|
+
research: {
|
|
1009
|
+
sources: ['arxiv', 'pubmed', 'crossref', 'semantic-scholar', 'web'],
|
|
1010
|
+
subdomainsPerCycle: 4,
|
|
1011
|
+
requireDualReview: true,
|
|
1012
|
+
requireCitationExtraction: true,
|
|
1013
|
+
requireContradictionScan: true,
|
|
1014
|
+
synthesisIntervalMs: args.cadence_ms || 300000,
|
|
1015
|
+
},
|
|
1016
|
+
knowledge: {
|
|
1017
|
+
autoIndex: true,
|
|
1018
|
+
},
|
|
1019
|
+
});
|
|
1020
|
+
return { mission };
|
|
1021
|
+
}
|
|
1022
|
+
async handlePauseMission(args) {
|
|
1023
|
+
await this.client.pauseMission(args.mission_id);
|
|
1024
|
+
return { success: true, mission_id: args.mission_id };
|
|
1025
|
+
}
|
|
1026
|
+
async handleResumeMission(args) {
|
|
1027
|
+
await this.client.resumeMission(args.mission_id);
|
|
1028
|
+
return { success: true, mission_id: args.mission_id };
|
|
1029
|
+
}
|
|
1030
|
+
async handleStopMission(args) {
|
|
1031
|
+
await this.client.stopMission(args.mission_id, args.reason);
|
|
1032
|
+
return { success: true, mission_id: args.mission_id };
|
|
1033
|
+
}
|
|
1034
|
+
async handleListMissions(args) {
|
|
1035
|
+
const missions = await this.client.listMissions(args.room_id);
|
|
1036
|
+
return { missions };
|
|
1037
|
+
}
|
|
1038
|
+
async handleGetSwarmStatus(args) {
|
|
1039
|
+
const swarm = await this.client.getSwarmStatus(args.room_id);
|
|
1040
|
+
return { swarm };
|
|
1041
|
+
}
|
|
1042
|
+
async handleStartResearchSwarm(args) {
|
|
1043
|
+
await this.client.startResearchWorker({
|
|
1044
|
+
roomId: args.room_id,
|
|
1045
|
+
hostId: args.host_id,
|
|
1046
|
+
runtime: args.runtime,
|
|
1047
|
+
specialties: args.specialties || [],
|
|
1048
|
+
capabilities: args.capabilities || [],
|
|
1049
|
+
});
|
|
1050
|
+
return { success: true, room_id: args.room_id, host_id: args.host_id };
|
|
1051
|
+
}
|
|
1052
|
+
async handleListChains(args) {
|
|
1053
|
+
const chains = await this.client.listChains(args.room_id);
|
|
1054
|
+
return { chains };
|
|
1055
|
+
}
|
|
1056
|
+
async handleGetChain(args) {
|
|
1057
|
+
const chain = await this.client.getChain(args.chain_id);
|
|
1058
|
+
return { chain };
|
|
1059
|
+
}
|
|
1060
|
+
async handleGetPendingSteps() {
|
|
1061
|
+
const steps = await this.client.getPendingSteps();
|
|
1062
|
+
return { steps, count: steps.length };
|
|
1063
|
+
}
|
|
1064
|
+
async handleSubmitStep(args) {
|
|
1065
|
+
await this.client.submitStep(args.step_id, {
|
|
1066
|
+
status: args.status,
|
|
1067
|
+
output: args.result,
|
|
1068
|
+
artifacts: args.artifacts,
|
|
1069
|
+
});
|
|
1070
|
+
return { success: true, step_id: args.step_id };
|
|
1071
|
+
}
|
|
1072
|
+
async handleReviewStep(args) {
|
|
1073
|
+
await this.client.reviewStep(args.step_id, args.decision, args.notes);
|
|
1074
|
+
return { success: true, step_id: args.step_id };
|
|
1075
|
+
}
|
|
1076
|
+
async handleCancelChain(args) {
|
|
1077
|
+
await this.client.cancelChain(args.chain_id, args.reason);
|
|
1078
|
+
return { success: true, chain_id: args.chain_id };
|
|
1079
|
+
}
|
|
1080
|
+
async handleGetReputation(args) {
|
|
1081
|
+
const did = args.did || this.client.getIdentity().did;
|
|
1082
|
+
const rep = await this.client.getReputation(did);
|
|
1083
|
+
return { did, reputation: rep };
|
|
1084
|
+
}
|
|
1085
|
+
async handleSendMessage(args) {
|
|
1086
|
+
await this.client.sendMessage(args.room_id, args.message, args.reply_to);
|
|
1087
|
+
return { success: true };
|
|
1088
|
+
}
|
|
1089
|
+
async handleListTemplates(args) {
|
|
1090
|
+
const templates = this.client.listTemplates(args.category);
|
|
1091
|
+
return { templates };
|
|
1092
|
+
}
|
|
1093
|
+
async handleExportCapsule(args) {
|
|
1094
|
+
const path = await this.client.exportCapsule(args.chain_id, args.output_path);
|
|
1095
|
+
return { success: true, path };
|
|
1096
|
+
}
|
|
1097
|
+
async handlePersonaAddMemory(args) {
|
|
1098
|
+
return this.client.addMemory({
|
|
1099
|
+
capabilityToken: args.capability_token,
|
|
1100
|
+
zkpProofs: args.zkp_proofs,
|
|
1101
|
+
vaultId: args.vault_id,
|
|
1102
|
+
domain: args.domain,
|
|
1103
|
+
type: args.type,
|
|
1104
|
+
title: args.title,
|
|
1105
|
+
content: args.content,
|
|
1106
|
+
tags: args.tags,
|
|
1107
|
+
confidence: args.confidence,
|
|
1108
|
+
source: { type: 'mcp', actorDid: this.client.getIdentity().did },
|
|
1109
|
+
});
|
|
1110
|
+
}
|
|
1111
|
+
async handlePersonaSearchMemories(args) {
|
|
1112
|
+
return this.client.queryMemories({
|
|
1113
|
+
capabilityToken: args.capability_token,
|
|
1114
|
+
zkpProofs: args.zkp_proofs,
|
|
1115
|
+
vaultId: args.vault_id,
|
|
1116
|
+
query: args.query,
|
|
1117
|
+
domain: args.domain,
|
|
1118
|
+
limit: args.limit,
|
|
1119
|
+
});
|
|
1120
|
+
}
|
|
1121
|
+
async handlePersonaQueryGraph(args) {
|
|
1122
|
+
return this.client.queryGraph({
|
|
1123
|
+
capabilityToken: args.capability_token,
|
|
1124
|
+
zkpProofs: args.zkp_proofs,
|
|
1125
|
+
vaultId: args.vault_id,
|
|
1126
|
+
rootNodeId: args.root_node_id,
|
|
1127
|
+
domain: args.domain,
|
|
1128
|
+
maxDepth: args.max_depth,
|
|
1129
|
+
limit: args.limit,
|
|
1130
|
+
});
|
|
1131
|
+
}
|
|
1132
|
+
async handlePersonaUpdatePreference(args) {
|
|
1133
|
+
return this.client.updatePreference({
|
|
1134
|
+
capabilityToken: args.capability_token,
|
|
1135
|
+
zkpProofs: args.zkp_proofs,
|
|
1136
|
+
vaultId: args.vault_id,
|
|
1137
|
+
key: args.key,
|
|
1138
|
+
value: args.value,
|
|
1139
|
+
confidence: args.confidence,
|
|
1140
|
+
domain: args.domain || 'preferences',
|
|
1141
|
+
});
|
|
1142
|
+
}
|
|
1143
|
+
async handlePersonaIssueCapability(args) {
|
|
1144
|
+
return this.client.issueCapability({
|
|
1145
|
+
capabilityToken: args.capability_token,
|
|
1146
|
+
zkpProofs: args.zkp_proofs,
|
|
1147
|
+
vaultId: args.vault_id,
|
|
1148
|
+
serviceDid: args.service_did,
|
|
1149
|
+
scope: args.scope,
|
|
1150
|
+
caveats: args.caveats,
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
async handlePersonaRevokeCapability(args) {
|
|
1154
|
+
await this.client.revokeCapability(args.token_id, args.reason, {
|
|
1155
|
+
capabilityToken: args.capability_token,
|
|
1156
|
+
zkpProofs: args.zkp_proofs,
|
|
1157
|
+
});
|
|
1158
|
+
return { success: true, token_id: args.token_id };
|
|
1159
|
+
}
|
|
1160
|
+
async handlePersonaAttenuateCapability(args) {
|
|
1161
|
+
const token = await this.client.attenuateCapability(args.token_id, args.caveats_patch || {}, {
|
|
1162
|
+
capabilityToken: args.capability_token,
|
|
1163
|
+
zkpProofs: args.zkp_proofs,
|
|
1164
|
+
});
|
|
1165
|
+
return { token };
|
|
1166
|
+
}
|
|
1167
|
+
async handlePersonaIssueClaim(args) {
|
|
1168
|
+
return this.client.issuePersonaClaim({
|
|
1169
|
+
capabilityToken: args.capability_token,
|
|
1170
|
+
zkpProofs: args.zkp_proofs,
|
|
1171
|
+
vaultId: args.vault_id,
|
|
1172
|
+
schema: args.schema,
|
|
1173
|
+
payload: args.payload || {},
|
|
1174
|
+
subjectDid: args.subject_did,
|
|
1175
|
+
issuerDid: args.issuer_did,
|
|
1176
|
+
issuerSignature: args.issuer_signature,
|
|
1177
|
+
expiresAt: args.expires_at,
|
|
1178
|
+
});
|
|
1179
|
+
}
|
|
1180
|
+
async handlePersonaGenerateZkProof(args) {
|
|
1181
|
+
return this.client.generatePersonaZkProof({
|
|
1182
|
+
capabilityToken: args.capability_token,
|
|
1183
|
+
vaultId: args.vault_id,
|
|
1184
|
+
circuitId: args.circuit_id,
|
|
1185
|
+
privateInputs: args.private_inputs || {},
|
|
1186
|
+
publicInputs: args.public_inputs || {},
|
|
1187
|
+
claimIds: args.claim_ids || [],
|
|
1188
|
+
expiresAt: args.expires_at,
|
|
1189
|
+
});
|
|
1190
|
+
}
|
|
1191
|
+
async handlePersonaVerifyZkProof(args) {
|
|
1192
|
+
return this.client.verifyPersonaZkProof({
|
|
1193
|
+
capabilityToken: args.capability_token,
|
|
1194
|
+
vaultId: args.vault_id,
|
|
1195
|
+
proofBundle: args.proof_bundle,
|
|
1196
|
+
});
|
|
1197
|
+
}
|
|
1198
|
+
async handlePersonaShareSubgraph(args) {
|
|
1199
|
+
return this.client.shareSubgraph({
|
|
1200
|
+
capabilityToken: args.capability_token,
|
|
1201
|
+
zkpProofs: args.zkp_proofs,
|
|
1202
|
+
vaultId: args.vault_id,
|
|
1203
|
+
domain: args.domain,
|
|
1204
|
+
nodeIds: args.node_ids,
|
|
1205
|
+
includeNeighbors: args.include_neighbors,
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
async handlePersonaGetProfile(args) {
|
|
1209
|
+
return this.client.getPersonaProfile(args.vault_id, {
|
|
1210
|
+
capabilityToken: args.capability_token,
|
|
1211
|
+
zkpProofs: args.zkp_proofs,
|
|
1212
|
+
});
|
|
1213
|
+
}
|
|
1214
|
+
async handlePersonaVerifyAccessLog(args) {
|
|
1215
|
+
return this.client.verifyPersonaAccessLog({
|
|
1216
|
+
logId: Number(args.log_id),
|
|
1217
|
+
capabilityToken: args.capability_token,
|
|
1218
|
+
zkpProofs: args.zkp_proofs,
|
|
1219
|
+
});
|
|
1220
|
+
}
|
|
1221
|
+
async handlePersonaRunRetentionSweep(args) {
|
|
1222
|
+
if (this.enableReadOnly) {
|
|
1223
|
+
throw new Error('Tool not available in read-only mode: persona_run_retention_sweep');
|
|
1224
|
+
}
|
|
1225
|
+
return this.client.runPersonaRetentionSweep({
|
|
1226
|
+
capabilityToken: args.capability_token,
|
|
1227
|
+
zkpProofs: args.zkp_proofs,
|
|
1228
|
+
vaultId: args.vault_id,
|
|
1229
|
+
domain: args.domain,
|
|
1230
|
+
dryRun: args.dry_run,
|
|
1231
|
+
});
|
|
1232
|
+
}
|
|
1233
|
+
async handleReadResource(uri) {
|
|
1234
|
+
if (!uri)
|
|
1235
|
+
throw new Error('Resource URI is required');
|
|
1236
|
+
if (uri === 'persona://profile') {
|
|
1237
|
+
return this.client.getPersonaProfile();
|
|
1238
|
+
}
|
|
1239
|
+
if (uri.startsWith('persona://memory/')) {
|
|
1240
|
+
const id = uri.slice('persona://memory/'.length);
|
|
1241
|
+
const result = await this.client.queryMemories({ query: id, limit: 5 });
|
|
1242
|
+
return { memoryId: id, matches: result.nodes };
|
|
1243
|
+
}
|
|
1244
|
+
if (uri.startsWith('persona://preferences/')) {
|
|
1245
|
+
const category = uri.slice('persona://preferences/'.length);
|
|
1246
|
+
const result = await this.client.queryMemories({
|
|
1247
|
+
domain: 'preferences',
|
|
1248
|
+
query: category === 'default' ? undefined : category,
|
|
1249
|
+
limit: 100,
|
|
1250
|
+
});
|
|
1251
|
+
return { category, preferences: result.nodes };
|
|
1252
|
+
}
|
|
1253
|
+
if (uri.startsWith('persona://graph/')) {
|
|
1254
|
+
const domain = uri.slice('persona://graph/'.length);
|
|
1255
|
+
return this.client.queryGraph({
|
|
1256
|
+
domain: domain,
|
|
1257
|
+
limit: 200,
|
|
1258
|
+
});
|
|
1259
|
+
}
|
|
1260
|
+
if (uri === 'persona://capabilities/active') {
|
|
1261
|
+
const capabilities = await this.client.listPersonaCapabilities();
|
|
1262
|
+
return {
|
|
1263
|
+
count: capabilities.filter((c) => c.status === 'active').length,
|
|
1264
|
+
capabilities: capabilities.filter((c) => c.status === 'active'),
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1267
|
+
if (uri.startsWith('persona://capabilities/')) {
|
|
1268
|
+
const tokenId = uri.slice('persona://capabilities/'.length);
|
|
1269
|
+
const cap = await this.client.getPersonaCapability(tokenId);
|
|
1270
|
+
if (!cap) {
|
|
1271
|
+
throw new Error(`Capability not found: ${tokenId}`);
|
|
1272
|
+
}
|
|
1273
|
+
return cap;
|
|
1274
|
+
}
|
|
1275
|
+
if (uri.startsWith('persona://claims/')) {
|
|
1276
|
+
const claimId = uri.slice('persona://claims/'.length);
|
|
1277
|
+
const claim = await this.client.getPersonaClaim(claimId);
|
|
1278
|
+
if (!claim) {
|
|
1279
|
+
throw new Error(`Claim not found: ${claimId}`);
|
|
1280
|
+
}
|
|
1281
|
+
return claim;
|
|
1282
|
+
}
|
|
1283
|
+
if (uri === 'persona://zkp/circuits') {
|
|
1284
|
+
return {
|
|
1285
|
+
circuits: this.client.listPersonaZkCircuits(),
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
if (uri.startsWith('persona://zkp/proofs/')) {
|
|
1289
|
+
const proofId = uri.slice('persona://zkp/proofs/'.length);
|
|
1290
|
+
const proof = this.client.getPersonaZkProof(proofId);
|
|
1291
|
+
if (!proof) {
|
|
1292
|
+
throw new Error(`Proof not found: ${proofId}`);
|
|
1293
|
+
}
|
|
1294
|
+
return proof;
|
|
1295
|
+
}
|
|
1296
|
+
throw new Error(`Unsupported resource URI: ${uri}`);
|
|
1297
|
+
}
|
|
1298
|
+
async handleGetPrompt(name, args = {}) {
|
|
1299
|
+
switch (name) {
|
|
1300
|
+
case 'persona_context': {
|
|
1301
|
+
const profile = await this.client.getPersonaProfile(args.vault_id);
|
|
1302
|
+
return {
|
|
1303
|
+
description: 'Persona context for assistant personalization',
|
|
1304
|
+
messages: [
|
|
1305
|
+
{
|
|
1306
|
+
role: 'user',
|
|
1307
|
+
content: {
|
|
1308
|
+
type: 'text',
|
|
1309
|
+
text: `Use this persona profile to personalize responses:\\n${JSON.stringify(profile, null, 2)}`,
|
|
1310
|
+
},
|
|
1311
|
+
},
|
|
1312
|
+
],
|
|
1313
|
+
};
|
|
1314
|
+
}
|
|
1315
|
+
case 'persona_preferences_snapshot': {
|
|
1316
|
+
const prefs = await this.client.queryMemories({
|
|
1317
|
+
vaultId: args.vault_id,
|
|
1318
|
+
domain: 'preferences',
|
|
1319
|
+
limit: 50,
|
|
1320
|
+
});
|
|
1321
|
+
return {
|
|
1322
|
+
description: 'Preference snapshot',
|
|
1323
|
+
messages: [
|
|
1324
|
+
{
|
|
1325
|
+
role: 'user',
|
|
1326
|
+
content: {
|
|
1327
|
+
type: 'text',
|
|
1328
|
+
text: `Preferences:\\n${JSON.stringify(prefs.nodes, null, 2)}`,
|
|
1329
|
+
},
|
|
1330
|
+
},
|
|
1331
|
+
],
|
|
1332
|
+
};
|
|
1333
|
+
}
|
|
1334
|
+
case 'persona_memory_digest': {
|
|
1335
|
+
const memories = await this.client.queryMemories({
|
|
1336
|
+
vaultId: args.vault_id,
|
|
1337
|
+
query: args.query,
|
|
1338
|
+
limit: 20,
|
|
1339
|
+
});
|
|
1340
|
+
return {
|
|
1341
|
+
description: 'Memory digest',
|
|
1342
|
+
messages: [
|
|
1343
|
+
{
|
|
1344
|
+
role: 'user',
|
|
1345
|
+
content: {
|
|
1346
|
+
type: 'text',
|
|
1347
|
+
text: `Top memories for query \"${args.query || ''}\":\\n${JSON.stringify(memories.nodes, null, 2)}`,
|
|
1348
|
+
},
|
|
1349
|
+
},
|
|
1350
|
+
],
|
|
1351
|
+
};
|
|
1352
|
+
}
|
|
1353
|
+
case 'persona_zkp_challenge': {
|
|
1354
|
+
const circuits = this.client.listPersonaZkCircuits();
|
|
1355
|
+
const circuit = circuits.find((item) => item.circuitId === args.circuit_id);
|
|
1356
|
+
if (!circuit) {
|
|
1357
|
+
throw new Error(`Unknown circuit: ${args.circuit_id}`);
|
|
1358
|
+
}
|
|
1359
|
+
return {
|
|
1360
|
+
description: 'Prompt template for ZKP challenge flow',
|
|
1361
|
+
messages: [
|
|
1362
|
+
{
|
|
1363
|
+
role: 'user',
|
|
1364
|
+
content: {
|
|
1365
|
+
type: 'text',
|
|
1366
|
+
text: `Prepare a ZKP challenge for circuit "${args.circuit_id}".\n` +
|
|
1367
|
+
`Use persona vault ${args.vault_id || '(default)'}.\n` +
|
|
1368
|
+
`Required public inputs: ${JSON.stringify(circuit.publicInputs || [])}\n` +
|
|
1369
|
+
`Return a JSON object with: { public_inputs, proof_request_reason, expires_at }.`,
|
|
1370
|
+
},
|
|
1371
|
+
},
|
|
1372
|
+
],
|
|
1373
|
+
};
|
|
1374
|
+
}
|
|
1375
|
+
default:
|
|
1376
|
+
throw new Error(`Unknown prompt: ${name}`);
|
|
1377
|
+
}
|
|
1378
|
+
}
|
|
1379
|
+
// ─── Lifecycle ───────────────────────────────────────────────
|
|
1380
|
+
async connect(transport) {
|
|
1381
|
+
await this.server.connect(transport);
|
|
1382
|
+
}
|
|
1383
|
+
async run() {
|
|
1384
|
+
const transport = new StdioServerTransport();
|
|
1385
|
+
await this.connect(transport);
|
|
1386
|
+
console.error('Society MCP Server running on stdio');
|
|
1387
|
+
}
|
|
1388
|
+
async stop() {
|
|
1389
|
+
await this.server.close();
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
//# sourceMappingURL=server.js.map
|