@band-ai/sdk 0.1.2
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/dist/CodexAdapter-A1k_LMdZ.d.ts +1278 -0
- package/dist/CodexAdapter-BbZD-nBd.d.cts +1278 -0
- package/dist/adapters.cjs +10643 -0
- package/dist/adapters.d.cts +217 -0
- package/dist/adapters.d.ts +217 -0
- package/dist/adapters.js +92 -0
- package/dist/backends-BnOLsG7w.d.cts +20 -0
- package/dist/backends-C4n6cKOf.d.ts +20 -0
- package/dist/chunk-3BKAC4OZ.js +44 -0
- package/dist/chunk-5CXIMAH2.js +52 -0
- package/dist/chunk-6AJA2OPC.js +3682 -0
- package/dist/chunk-A3TDK6GP.js +6674 -0
- package/dist/chunk-AVVDPXP4.js +39 -0
- package/dist/chunk-EDPKUUJL.js +177 -0
- package/dist/chunk-FUODYQRE.js +2562 -0
- package/dist/chunk-GVEQ3RAH.js +373 -0
- package/dist/chunk-INA6YZTZ.js +88 -0
- package/dist/chunk-IZPV6QS6.js +115 -0
- package/dist/chunk-LY55KYVI.js +0 -0
- package/dist/chunk-NIAQBANR.js +577 -0
- package/dist/chunk-OD2G5LFQ.js +78 -0
- package/dist/chunk-SFVKOEQH.js +103 -0
- package/dist/chunk-SG4WLD2H.js +1093 -0
- package/dist/chunk-YR3BOQNW.js +39 -0
- package/dist/chunk-ZZJRRBPQ.js +82 -0
- package/dist/claude-CcnQ5OUC.d.ts +53 -0
- package/dist/claude-CwTAxhwI.d.cts +53 -0
- package/dist/config.cjs +164 -0
- package/dist/config.d.cts +19 -0
- package/dist/config.d.ts +19 -0
- package/dist/config.js +9 -0
- package/dist/converters.cjs +1086 -0
- package/dist/converters.d.cts +143 -0
- package/dist/converters.d.ts +143 -0
- package/dist/converters.js +468 -0
- package/dist/core.cjs +185 -0
- package/dist/core.d.cts +22 -0
- package/dist/core.d.ts +22 -0
- package/dist/core.js +24 -0
- package/dist/customTools-BzF0IISO.d.cts +10 -0
- package/dist/customTools-BzF0IISO.d.ts +10 -0
- package/dist/dtos-DUpbIu8k.d.cts +163 -0
- package/dist/dtos-DUpbIu8k.d.ts +163 -0
- package/dist/history-ByessXNq.d.ts +24 -0
- package/dist/history-i6yN7neC.d.cts +24 -0
- package/dist/index.cjs +13914 -0
- package/dist/index.d.cts +63 -0
- package/dist/index.d.ts +63 -0
- package/dist/index.js +198 -0
- package/dist/linear.cjs +2207 -0
- package/dist/linear.d.cts +167 -0
- package/dist/linear.d.ts +167 -0
- package/dist/linear.js +2139 -0
- package/dist/logger-CABQOnlR.d.cts +21 -0
- package/dist/logger-CABQOnlR.d.ts +21 -0
- package/dist/mcp-claude.cjs +584 -0
- package/dist/mcp-claude.d.cts +4 -0
- package/dist/mcp-claude.d.ts +4 -0
- package/dist/mcp-claude.js +11 -0
- package/dist/mcp.cjs +1247 -0
- package/dist/mcp.d.cts +97 -0
- package/dist/mcp.d.ts +97 -0
- package/dist/mcp.js +27 -0
- package/dist/opencode-BBcDchcN.d.cts +159 -0
- package/dist/opencode-DthQQUsZ.d.ts +159 -0
- package/dist/pagination-BPiys10t.d.cts +25 -0
- package/dist/pagination-CcDkVFxK.d.ts +25 -0
- package/dist/protocols-CInhtFpA.d.cts +116 -0
- package/dist/protocols-DrhzOH6K.d.ts +116 -0
- package/dist/rest.cjs +1159 -0
- package/dist/rest.d.cts +144 -0
- package/dist/rest.d.ts +144 -0
- package/dist/rest.js +18 -0
- package/dist/runtime.cjs +5353 -0
- package/dist/runtime.d.cts +276 -0
- package/dist/runtime.d.ts +276 -0
- package/dist/runtime.js +274 -0
- package/dist/schemas-BpEBkq5V.d.cts +592 -0
- package/dist/schemas-vos1AaBc.d.ts +592 -0
- package/dist/sdk-HJUVSSWA.js +10 -0
- package/dist/simpleAdapter-9OE_p6QW.d.ts +29 -0
- package/dist/simpleAdapter-DqhvjsGr.d.cts +29 -0
- package/dist/testing.cjs +217 -0
- package/dist/testing.d.cts +126 -0
- package/dist/testing.d.ts +126 -0
- package/dist/testing.js +186 -0
- package/dist/types-7jVzOeOP.d.ts +446 -0
- package/dist/types-CSHFipIc.d.cts +331 -0
- package/dist/types-CovcHpYf.d.cts +446 -0
- package/dist/types-CxII3XkA.d.ts +331 -0
- package/package.json +189 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface Logger {
|
|
2
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
3
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
4
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
5
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
6
|
+
}
|
|
7
|
+
declare class NoopLogger implements Logger {
|
|
8
|
+
debug: () => void;
|
|
9
|
+
info: () => void;
|
|
10
|
+
warn: () => void;
|
|
11
|
+
error: () => void;
|
|
12
|
+
}
|
|
13
|
+
declare class ConsoleLogger implements Logger {
|
|
14
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
15
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
16
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
17
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
18
|
+
private emit;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { ConsoleLogger as C, type Logger as L, NoopLogger as N };
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
interface Logger {
|
|
2
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
3
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
4
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
5
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
6
|
+
}
|
|
7
|
+
declare class NoopLogger implements Logger {
|
|
8
|
+
debug: () => void;
|
|
9
|
+
info: () => void;
|
|
10
|
+
warn: () => void;
|
|
11
|
+
error: () => void;
|
|
12
|
+
}
|
|
13
|
+
declare class ConsoleLogger implements Logger {
|
|
14
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
15
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
16
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
17
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
18
|
+
private emit;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { ConsoleLogger as C, type Logger as L, NoopLogger as N };
|
|
@@ -0,0 +1,584 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/mcp/claude.ts
|
|
21
|
+
var claude_exports = {};
|
|
22
|
+
__export(claude_exports, {
|
|
23
|
+
createThenvoiSdkMcpServer: () => createThenvoiSdkMcpServer
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(claude_exports);
|
|
26
|
+
|
|
27
|
+
// src/mcp/sdk.ts
|
|
28
|
+
var import_claude_agent_sdk = require("@anthropic-ai/claude-agent-sdk");
|
|
29
|
+
var import_zod = require("zod");
|
|
30
|
+
|
|
31
|
+
// src/contracts/chatEvents.ts
|
|
32
|
+
var CHAT_EVENT_TYPES = ["tool_call", "tool_result", "thought", "error", "task"];
|
|
33
|
+
var CHAT_MESSAGE_TYPES = ["text", ...CHAT_EVENT_TYPES];
|
|
34
|
+
|
|
35
|
+
// src/runtime/tools/schemas.ts
|
|
36
|
+
var TOOL_MODELS = {
|
|
37
|
+
thenvoi_send_message: {
|
|
38
|
+
description: "Send a message to the chat room. Use this to respond to users or other agents. Messages require at least one @mention in the mentions array. You MUST use this tool to communicate \u2014 plain text responses won't reach users. When delegating, send the full task context in this message instead of assuming hidden state.",
|
|
39
|
+
properties: {
|
|
40
|
+
content: {
|
|
41
|
+
type: "string",
|
|
42
|
+
description: "The message content to send."
|
|
43
|
+
},
|
|
44
|
+
mentions: {
|
|
45
|
+
type: "array",
|
|
46
|
+
items: { type: "string" },
|
|
47
|
+
minItems: 1,
|
|
48
|
+
description: "List of participant handles to @mention. At least one required. For users: @<username> (e.g., '@john'). For agents: @<username>/<agent-name> (e.g., '@john/weather-agent'). Use the handle of someone already in the room."
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
required: ["content", "mentions"]
|
|
52
|
+
},
|
|
53
|
+
thenvoi_send_event: {
|
|
54
|
+
description: "Send an event to the chat room. No mentions required. 'thought': Share your reasoning or plan BEFORE taking actions. Explain what you're about to do and why. 'error': Report an error or problem that occurred. 'task': Report task progress or completion status. Always send a thought before complex actions to keep users informed.",
|
|
55
|
+
properties: {
|
|
56
|
+
content: {
|
|
57
|
+
type: "string",
|
|
58
|
+
description: "Human-readable event content."
|
|
59
|
+
},
|
|
60
|
+
message_type: {
|
|
61
|
+
type: "string",
|
|
62
|
+
enum: [...CHAT_EVENT_TYPES],
|
|
63
|
+
description: "Type of event."
|
|
64
|
+
},
|
|
65
|
+
metadata: {
|
|
66
|
+
type: "object",
|
|
67
|
+
description: "Optional structured data for the event."
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
required: ["content", "message_type"]
|
|
71
|
+
},
|
|
72
|
+
thenvoi_add_participant: {
|
|
73
|
+
description: "Add a participant (agent or user) to the chat room by name. IMPORTANT: Use thenvoi_lookup_peers() first to find available agents. Pass the exact peer name from thenvoi_lookup_peers, not the handle. For normal delegation, omit role or use 'member'.",
|
|
74
|
+
properties: {
|
|
75
|
+
name: {
|
|
76
|
+
type: "string",
|
|
77
|
+
description: "Name of participant to add (must match a name from thenvoi_lookup_peers)."
|
|
78
|
+
},
|
|
79
|
+
role: {
|
|
80
|
+
type: "string",
|
|
81
|
+
enum: ["owner", "admin", "member"],
|
|
82
|
+
description: "Role for the participant in this room."
|
|
83
|
+
}
|
|
84
|
+
},
|
|
85
|
+
required: ["name"]
|
|
86
|
+
},
|
|
87
|
+
thenvoi_remove_participant: {
|
|
88
|
+
description: "Remove a participant from the chat room by name.",
|
|
89
|
+
properties: {
|
|
90
|
+
name: {
|
|
91
|
+
type: "string",
|
|
92
|
+
description: "Name of the participant to remove."
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
required: ["name"]
|
|
96
|
+
},
|
|
97
|
+
thenvoi_get_participants: {
|
|
98
|
+
description: "Get a list of all participants in the current chat room.",
|
|
99
|
+
properties: {},
|
|
100
|
+
required: []
|
|
101
|
+
},
|
|
102
|
+
thenvoi_lookup_peers: {
|
|
103
|
+
description: "List available peers (agents and users) that can be added to this room. Automatically excludes peers already in the room. Returns dict with 'peers' list and 'metadata' (page, page_size, total_count, total_pages). Use this to find specialized agents (e.g., Weather Agent) when you cannot answer a question directly.",
|
|
104
|
+
properties: {
|
|
105
|
+
page: {
|
|
106
|
+
type: "integer",
|
|
107
|
+
description: "Page number."
|
|
108
|
+
},
|
|
109
|
+
page_size: {
|
|
110
|
+
type: "integer",
|
|
111
|
+
description: "Items per page (max 100).",
|
|
112
|
+
maximum: 100
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
required: []
|
|
116
|
+
},
|
|
117
|
+
thenvoi_create_chatroom: {
|
|
118
|
+
description: "Create a new chat room for a specific task or conversation.",
|
|
119
|
+
properties: {
|
|
120
|
+
task_id: {
|
|
121
|
+
type: "string",
|
|
122
|
+
description: "Associated task ID (optional)."
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
required: []
|
|
126
|
+
},
|
|
127
|
+
thenvoi_list_contacts: {
|
|
128
|
+
description: "List agent's contacts with pagination.",
|
|
129
|
+
properties: {
|
|
130
|
+
page: {
|
|
131
|
+
type: "integer",
|
|
132
|
+
description: "Page number.",
|
|
133
|
+
minimum: 1
|
|
134
|
+
},
|
|
135
|
+
page_size: {
|
|
136
|
+
type: "integer",
|
|
137
|
+
description: "Items per page.",
|
|
138
|
+
minimum: 1,
|
|
139
|
+
maximum: 100
|
|
140
|
+
}
|
|
141
|
+
},
|
|
142
|
+
required: []
|
|
143
|
+
},
|
|
144
|
+
thenvoi_add_contact: {
|
|
145
|
+
description: "Send a contact request to add someone as a contact. Returns 'pending' when request is created. Returns 'approved' when inverse request existed and was auto-accepted.",
|
|
146
|
+
properties: {
|
|
147
|
+
handle: {
|
|
148
|
+
type: "string",
|
|
149
|
+
description: "Handle of user/agent to add (e.g., '@john' or '@john/agent-name')."
|
|
150
|
+
},
|
|
151
|
+
message: {
|
|
152
|
+
type: "string",
|
|
153
|
+
description: "Optional message with the request."
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
required: ["handle"]
|
|
157
|
+
},
|
|
158
|
+
thenvoi_remove_contact: {
|
|
159
|
+
description: "Remove an existing contact by handle or ID.",
|
|
160
|
+
properties: {
|
|
161
|
+
handle: {
|
|
162
|
+
type: "string",
|
|
163
|
+
description: "Contact's handle."
|
|
164
|
+
},
|
|
165
|
+
contact_id: {
|
|
166
|
+
type: "string",
|
|
167
|
+
description: "Or contact record ID (UUID)."
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
required: []
|
|
171
|
+
},
|
|
172
|
+
thenvoi_list_contact_requests: {
|
|
173
|
+
description: "List both received and sent contact requests. Received requests are always filtered to pending status. Sent requests can be filtered by status.",
|
|
174
|
+
properties: {
|
|
175
|
+
page: {
|
|
176
|
+
type: "integer",
|
|
177
|
+
description: "Page number.",
|
|
178
|
+
minimum: 1
|
|
179
|
+
},
|
|
180
|
+
page_size: {
|
|
181
|
+
type: "integer",
|
|
182
|
+
description: "Items per page per direction (max 100).",
|
|
183
|
+
minimum: 1,
|
|
184
|
+
maximum: 100
|
|
185
|
+
},
|
|
186
|
+
sent_status: {
|
|
187
|
+
type: "string",
|
|
188
|
+
enum: ["pending", "approved", "rejected", "cancelled", "all"],
|
|
189
|
+
description: "Filter sent requests by status."
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
required: []
|
|
193
|
+
},
|
|
194
|
+
thenvoi_respond_contact_request: {
|
|
195
|
+
description: "Respond to a contact request. 'approve'/'reject': For requests you RECEIVED (handle = requester's handle). 'cancel': For requests you SENT (handle = recipient's handle).",
|
|
196
|
+
properties: {
|
|
197
|
+
action: {
|
|
198
|
+
type: "string",
|
|
199
|
+
enum: ["approve", "reject", "cancel"],
|
|
200
|
+
description: "Action to take."
|
|
201
|
+
},
|
|
202
|
+
handle: {
|
|
203
|
+
type: "string",
|
|
204
|
+
description: "Other party's handle."
|
|
205
|
+
},
|
|
206
|
+
request_id: {
|
|
207
|
+
type: "string",
|
|
208
|
+
description: "Or request ID (UUID)."
|
|
209
|
+
}
|
|
210
|
+
},
|
|
211
|
+
required: ["action"]
|
|
212
|
+
},
|
|
213
|
+
thenvoi_list_memories: {
|
|
214
|
+
description: "List memories accessible to the agent. Returns memories about the specified subject (cross-agent sharing) and organization-wide shared memories.",
|
|
215
|
+
properties: {
|
|
216
|
+
subject_id: {
|
|
217
|
+
type: "string",
|
|
218
|
+
description: "Filter by subject UUID (required for subject-scoped queries)."
|
|
219
|
+
},
|
|
220
|
+
scope: {
|
|
221
|
+
type: "string",
|
|
222
|
+
enum: ["subject", "organization", "all"],
|
|
223
|
+
description: "Filter by scope."
|
|
224
|
+
},
|
|
225
|
+
system: {
|
|
226
|
+
type: "string",
|
|
227
|
+
enum: ["sensory", "working", "long_term"],
|
|
228
|
+
description: "Filter by memory system."
|
|
229
|
+
},
|
|
230
|
+
type: {
|
|
231
|
+
type: "string",
|
|
232
|
+
enum: [
|
|
233
|
+
"iconic",
|
|
234
|
+
"echoic",
|
|
235
|
+
"haptic",
|
|
236
|
+
"episodic",
|
|
237
|
+
"semantic",
|
|
238
|
+
"procedural"
|
|
239
|
+
],
|
|
240
|
+
description: "Filter by memory type."
|
|
241
|
+
},
|
|
242
|
+
segment: {
|
|
243
|
+
type: "string",
|
|
244
|
+
enum: ["user", "agent", "tool", "guideline"],
|
|
245
|
+
description: "Filter by segment."
|
|
246
|
+
},
|
|
247
|
+
content_query: {
|
|
248
|
+
type: "string",
|
|
249
|
+
description: "Full-text search query."
|
|
250
|
+
},
|
|
251
|
+
page_size: {
|
|
252
|
+
type: "integer",
|
|
253
|
+
description: "Number of results per page.",
|
|
254
|
+
minimum: 1,
|
|
255
|
+
maximum: 50
|
|
256
|
+
},
|
|
257
|
+
status: {
|
|
258
|
+
type: "string",
|
|
259
|
+
enum: ["active", "superseded", "archived", "all"],
|
|
260
|
+
description: "Filter by status."
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
required: []
|
|
264
|
+
},
|
|
265
|
+
thenvoi_store_memory: {
|
|
266
|
+
description: "Store a new memory entry. The memory will be associated with the authenticated agent as the source. For subject-scoped memories, provide a subject_id. For organization-scoped memories, omit subject_id.",
|
|
267
|
+
properties: {
|
|
268
|
+
content: {
|
|
269
|
+
type: "string",
|
|
270
|
+
description: "The memory content."
|
|
271
|
+
},
|
|
272
|
+
system: {
|
|
273
|
+
type: "string",
|
|
274
|
+
enum: ["sensory", "working", "long_term"],
|
|
275
|
+
description: "Memory system tier."
|
|
276
|
+
},
|
|
277
|
+
type: {
|
|
278
|
+
type: "string",
|
|
279
|
+
enum: [
|
|
280
|
+
"iconic",
|
|
281
|
+
"echoic",
|
|
282
|
+
"haptic",
|
|
283
|
+
"episodic",
|
|
284
|
+
"semantic",
|
|
285
|
+
"procedural"
|
|
286
|
+
],
|
|
287
|
+
description: "Memory type (must be valid for selected system)."
|
|
288
|
+
},
|
|
289
|
+
segment: {
|
|
290
|
+
type: "string",
|
|
291
|
+
enum: ["user", "agent", "tool", "guideline"],
|
|
292
|
+
description: "Logical segment."
|
|
293
|
+
},
|
|
294
|
+
thought: {
|
|
295
|
+
type: "string",
|
|
296
|
+
description: "Agent's reasoning for storing this memory."
|
|
297
|
+
},
|
|
298
|
+
scope: {
|
|
299
|
+
type: "string",
|
|
300
|
+
enum: ["subject", "organization"],
|
|
301
|
+
description: "Visibility scope."
|
|
302
|
+
},
|
|
303
|
+
subject_id: {
|
|
304
|
+
type: "string",
|
|
305
|
+
description: "UUID of the subject this memory is about (required for subject scope)."
|
|
306
|
+
},
|
|
307
|
+
metadata: {
|
|
308
|
+
type: "object",
|
|
309
|
+
description: "Additional metadata (tags, references)."
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
required: ["content", "system", "type", "segment", "thought"]
|
|
313
|
+
},
|
|
314
|
+
thenvoi_get_memory: {
|
|
315
|
+
description: "Retrieve a specific memory by ID.",
|
|
316
|
+
properties: {
|
|
317
|
+
memory_id: {
|
|
318
|
+
type: "string",
|
|
319
|
+
description: "Memory ID (UUID)."
|
|
320
|
+
}
|
|
321
|
+
},
|
|
322
|
+
required: ["memory_id"]
|
|
323
|
+
},
|
|
324
|
+
thenvoi_supersede_memory: {
|
|
325
|
+
description: "Mark a memory as superseded (soft delete). Use when information is outdated or incorrect. The memory remains for audit trail but won't appear in normal queries. Only the source agent can supersede.",
|
|
326
|
+
properties: {
|
|
327
|
+
memory_id: {
|
|
328
|
+
type: "string",
|
|
329
|
+
description: "Memory ID (UUID)."
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
required: ["memory_id"]
|
|
333
|
+
},
|
|
334
|
+
thenvoi_archive_memory: {
|
|
335
|
+
description: "Archive a memory (hide but preserve). Use when memory is valid but not currently needed. Archived memories can be restored later by humans. Only the source agent can archive.",
|
|
336
|
+
properties: {
|
|
337
|
+
memory_id: {
|
|
338
|
+
type: "string",
|
|
339
|
+
description: "Memory ID (UUID)."
|
|
340
|
+
}
|
|
341
|
+
},
|
|
342
|
+
required: ["memory_id"]
|
|
343
|
+
}
|
|
344
|
+
};
|
|
345
|
+
var ALL_TOOL_NAMES = new Set(Object.keys(TOOL_MODELS));
|
|
346
|
+
var MEMORY_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
347
|
+
"thenvoi_list_memories",
|
|
348
|
+
"thenvoi_store_memory",
|
|
349
|
+
"thenvoi_get_memory",
|
|
350
|
+
"thenvoi_supersede_memory",
|
|
351
|
+
"thenvoi_archive_memory"
|
|
352
|
+
]);
|
|
353
|
+
var CONTACT_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
354
|
+
"thenvoi_list_contacts",
|
|
355
|
+
"thenvoi_add_contact",
|
|
356
|
+
"thenvoi_remove_contact",
|
|
357
|
+
"thenvoi_list_contact_requests",
|
|
358
|
+
"thenvoi_respond_contact_request"
|
|
359
|
+
]);
|
|
360
|
+
var BASE_TOOL_NAMES = new Set(
|
|
361
|
+
[...ALL_TOOL_NAMES].filter((name) => !MEMORY_TOOL_NAMES.has(name))
|
|
362
|
+
);
|
|
363
|
+
var CHAT_TOOL_NAMES = new Set(
|
|
364
|
+
[...BASE_TOOL_NAMES].filter((name) => !CONTACT_TOOL_NAMES.has(name))
|
|
365
|
+
);
|
|
366
|
+
var MCP_TOOL_PREFIX = "mcp__thenvoi__";
|
|
367
|
+
function mcpToolNames(names) {
|
|
368
|
+
return [...names].sort((a, b) => a.localeCompare(b)).map((name) => `${MCP_TOOL_PREFIX}${name}`);
|
|
369
|
+
}
|
|
370
|
+
function getToolDescription(name) {
|
|
371
|
+
const model = TOOL_MODELS[name];
|
|
372
|
+
return model?.description ?? `Execute ${name}`;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
// src/contracts/protocols.ts
|
|
376
|
+
var TOOL_EXECUTOR_ERROR_TYPES = [
|
|
377
|
+
"ToolArgumentsValidationError",
|
|
378
|
+
"ToolNotFoundError",
|
|
379
|
+
"ToolExecutionError"
|
|
380
|
+
];
|
|
381
|
+
function isToolExecutorError(value) {
|
|
382
|
+
if (!value || typeof value !== "object") {
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
const candidate = value;
|
|
386
|
+
return candidate.ok === false && typeof candidate.errorType === "string" && TOOL_EXECUTOR_ERROR_TYPES.includes(candidate.errorType) && typeof candidate.toolName === "string" && typeof candidate.message === "string" && typeof candidate.legacyMessage === "string";
|
|
387
|
+
}
|
|
388
|
+
function toLegacyToolExecutorErrorMessage(value) {
|
|
389
|
+
if (typeof value === "string") {
|
|
390
|
+
return value;
|
|
391
|
+
}
|
|
392
|
+
if (!isToolExecutorError(value)) {
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
return value.legacyMessage;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
// src/mcp/registrations.ts
|
|
399
|
+
function buildRoomScopedRegistrations(resolver, options = {}) {
|
|
400
|
+
const toolNames = resolveToolNames(options);
|
|
401
|
+
const registrations = buildRegistrations(toolNames, async (toolName, args) => {
|
|
402
|
+
const roomId = asNonEmptyString(args.room_id);
|
|
403
|
+
if (!roomId) {
|
|
404
|
+
return errorResult("Missing required room_id");
|
|
405
|
+
}
|
|
406
|
+
const tools = resolver(roomId);
|
|
407
|
+
if (!tools) {
|
|
408
|
+
return errorResult(`No tool context found for room_id ${roomId}`);
|
|
409
|
+
}
|
|
410
|
+
const toolArgs = { ...args };
|
|
411
|
+
delete toolArgs.room_id;
|
|
412
|
+
return executeToolCall(tools, toolName, toolArgs);
|
|
413
|
+
}, { injectRoomId: true });
|
|
414
|
+
if (options.additionalTools) {
|
|
415
|
+
registrations.push(...options.additionalTools);
|
|
416
|
+
}
|
|
417
|
+
return registrations;
|
|
418
|
+
}
|
|
419
|
+
function resolveToolNames(options) {
|
|
420
|
+
const names = /* @__PURE__ */ new Set();
|
|
421
|
+
for (const name of BASE_TOOL_NAMES) {
|
|
422
|
+
if (!options.enableContactTools && CONTACT_TOOL_NAMES.has(name)) {
|
|
423
|
+
continue;
|
|
424
|
+
}
|
|
425
|
+
names.add(name);
|
|
426
|
+
}
|
|
427
|
+
if (options.enableMemoryTools) {
|
|
428
|
+
for (const name of MEMORY_TOOL_NAMES) {
|
|
429
|
+
names.add(name);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
return names;
|
|
433
|
+
}
|
|
434
|
+
function buildRegistrations(toolNames, executor, opts) {
|
|
435
|
+
const registrations = [];
|
|
436
|
+
for (const toolName of toolNames) {
|
|
437
|
+
const model = TOOL_MODELS[toolName];
|
|
438
|
+
if (!model) {
|
|
439
|
+
continue;
|
|
440
|
+
}
|
|
441
|
+
const properties = { ...model.properties };
|
|
442
|
+
const required = [...model.required];
|
|
443
|
+
if (opts.injectRoomId) {
|
|
444
|
+
properties.room_id = { type: "string", description: "The room ID to execute this tool in" };
|
|
445
|
+
required.push("room_id");
|
|
446
|
+
}
|
|
447
|
+
registrations.push({
|
|
448
|
+
name: toolName,
|
|
449
|
+
description: getToolDescription(toolName),
|
|
450
|
+
inputSchema: {
|
|
451
|
+
type: "object",
|
|
452
|
+
properties,
|
|
453
|
+
required
|
|
454
|
+
},
|
|
455
|
+
execute: (args) => executor(toolName, args)
|
|
456
|
+
});
|
|
457
|
+
}
|
|
458
|
+
return registrations;
|
|
459
|
+
}
|
|
460
|
+
async function executeToolCall(tools, toolName, args) {
|
|
461
|
+
try {
|
|
462
|
+
const result = await tools.executeToolCall(toolName, args);
|
|
463
|
+
if (isToolExecutorError(result)) {
|
|
464
|
+
return errorResult(toLegacyToolExecutorErrorMessage(result) ?? result.message);
|
|
465
|
+
}
|
|
466
|
+
return successResult(result);
|
|
467
|
+
} catch (error) {
|
|
468
|
+
return errorResult(error instanceof Error ? error.message : String(error));
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
function asNonEmptyString(value) {
|
|
472
|
+
if (typeof value !== "string") {
|
|
473
|
+
return null;
|
|
474
|
+
}
|
|
475
|
+
const trimmed = value.trim();
|
|
476
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
477
|
+
}
|
|
478
|
+
function successResult(value) {
|
|
479
|
+
return {
|
|
480
|
+
content: [{
|
|
481
|
+
type: "text",
|
|
482
|
+
text: serializeValue(value)
|
|
483
|
+
}]
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
function errorResult(message) {
|
|
487
|
+
return {
|
|
488
|
+
content: [{ type: "text", text: message }],
|
|
489
|
+
isError: true
|
|
490
|
+
};
|
|
491
|
+
}
|
|
492
|
+
function serializeValue(value) {
|
|
493
|
+
if (value === void 0 || value === null) {
|
|
494
|
+
return "";
|
|
495
|
+
}
|
|
496
|
+
if (typeof value === "string") {
|
|
497
|
+
return value;
|
|
498
|
+
}
|
|
499
|
+
try {
|
|
500
|
+
const json = JSON.stringify(value);
|
|
501
|
+
return typeof json === "string" ? json : String(value);
|
|
502
|
+
} catch {
|
|
503
|
+
return String(value);
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
// src/mcp/zod.ts
|
|
508
|
+
function buildZodShape(z2, properties, required) {
|
|
509
|
+
const shape = {};
|
|
510
|
+
for (const [name, schema] of Object.entries(properties)) {
|
|
511
|
+
const validator = jsonSchemaToZod(z2, schema);
|
|
512
|
+
shape[name] = required.has(name) ? validator : validator.optional();
|
|
513
|
+
}
|
|
514
|
+
return shape;
|
|
515
|
+
}
|
|
516
|
+
function jsonSchemaToZod(z2, schema) {
|
|
517
|
+
const type = schema.type;
|
|
518
|
+
if (type === "string") {
|
|
519
|
+
if (Array.isArray(schema.enum) && schema.enum.every((v) => typeof v === "string")) {
|
|
520
|
+
const values = schema.enum;
|
|
521
|
+
if (values.length > 0) {
|
|
522
|
+
return z2.enum(values);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
return z2.string();
|
|
526
|
+
}
|
|
527
|
+
if (type === "integer" || type === "number") {
|
|
528
|
+
return z2.number();
|
|
529
|
+
}
|
|
530
|
+
if (type === "boolean") {
|
|
531
|
+
return z2.boolean();
|
|
532
|
+
}
|
|
533
|
+
if (type === "array") {
|
|
534
|
+
const itemSchema = schema.items;
|
|
535
|
+
if (itemSchema && typeof itemSchema === "object") {
|
|
536
|
+
return z2.array(jsonSchemaToZod(z2, itemSchema));
|
|
537
|
+
}
|
|
538
|
+
return z2.array(z2.unknown());
|
|
539
|
+
}
|
|
540
|
+
if (type === "object") {
|
|
541
|
+
return z2.record(z2.string(), z2.unknown());
|
|
542
|
+
}
|
|
543
|
+
return z2.unknown();
|
|
544
|
+
}
|
|
545
|
+
|
|
546
|
+
// src/mcp/sdk.ts
|
|
547
|
+
function createThenvoiSdkMcpServer(options) {
|
|
548
|
+
const registrations = buildRoomScopedRegistrations(
|
|
549
|
+
options.getToolsForRoom,
|
|
550
|
+
{
|
|
551
|
+
enableMemoryTools: options.enableMemoryTools,
|
|
552
|
+
enableContactTools: true,
|
|
553
|
+
additionalTools: options.additionalTools
|
|
554
|
+
}
|
|
555
|
+
);
|
|
556
|
+
const toolDefinitions = registrations.map(toSdkToolDefinition);
|
|
557
|
+
const toolNames = new Set(registrations.map((r) => r.name));
|
|
558
|
+
const serverConfig = (0, import_claude_agent_sdk.createSdkMcpServer)({
|
|
559
|
+
name: "thenvoi",
|
|
560
|
+
tools: toolDefinitions
|
|
561
|
+
});
|
|
562
|
+
return {
|
|
563
|
+
serverConfig,
|
|
564
|
+
allowedTools: mcpToolNames(toolNames),
|
|
565
|
+
toolDefinitions
|
|
566
|
+
};
|
|
567
|
+
}
|
|
568
|
+
function toSdkToolDefinition(registration) {
|
|
569
|
+
const shape = buildZodShape(
|
|
570
|
+
import_zod.z,
|
|
571
|
+
registration.inputSchema.properties,
|
|
572
|
+
new Set(registration.inputSchema.required)
|
|
573
|
+
);
|
|
574
|
+
return (0, import_claude_agent_sdk.tool)(
|
|
575
|
+
registration.name,
|
|
576
|
+
registration.description,
|
|
577
|
+
shape,
|
|
578
|
+
async (args) => registration.execute(args)
|
|
579
|
+
);
|
|
580
|
+
}
|
|
581
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
582
|
+
0 && (module.exports = {
|
|
583
|
+
createThenvoiSdkMcpServer
|
|
584
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import "./chunk-LY55KYVI.js";
|
|
2
|
+
import {
|
|
3
|
+
createThenvoiSdkMcpServer
|
|
4
|
+
} from "./chunk-5CXIMAH2.js";
|
|
5
|
+
import "./chunk-EDPKUUJL.js";
|
|
6
|
+
import "./chunk-GVEQ3RAH.js";
|
|
7
|
+
import "./chunk-3BKAC4OZ.js";
|
|
8
|
+
import "./chunk-YR3BOQNW.js";
|
|
9
|
+
export {
|
|
10
|
+
createThenvoiSdkMcpServer
|
|
11
|
+
};
|