@memextend/opencode 0.1.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/README.md +277 -0
- package/dist/config/index.d.ts +118 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +153 -0
- package/dist/config/index.js.map +1 -0
- package/dist/index.d.ts +31 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +35 -0
- package/dist/index.js.map +1 -0
- package/dist/mcp/index.d.ts +7 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +15 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/server.cjs +14664 -0
- package/dist/mcp/server.d.ts +2 -0
- package/dist/mcp/server.d.ts.map +1 -0
- package/dist/mcp/server.js +283 -0
- package/dist/mcp/server.js.map +1 -0
- package/package.json +66 -0
- package/scripts/build.js +47 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
// packages/adapters/opencode/src/mcp/server.ts
|
|
2
|
+
// Copyright (c) 2026 ZodTTD LLC. MIT License.
|
|
3
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
4
|
+
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
|
|
6
|
+
import { randomUUID } from 'crypto';
|
|
7
|
+
import { existsSync } from 'fs';
|
|
8
|
+
import { join } from 'path';
|
|
9
|
+
import { homedir } from 'os';
|
|
10
|
+
import { SQLiteStorage, LanceDBStorage, MemoryRetriever, createEmbedFunction } from '@memextend/core';
|
|
11
|
+
const MEMEXTEND_DIR = join(homedir(), '.memextend');
|
|
12
|
+
const DB_PATH = join(MEMEXTEND_DIR, 'memextend.db');
|
|
13
|
+
const VECTORS_PATH = join(MEMEXTEND_DIR, 'vectors');
|
|
14
|
+
const MODELS_PATH = join(MEMEXTEND_DIR, 'models');
|
|
15
|
+
// Lazy-loaded storage instances
|
|
16
|
+
let sqlite = null;
|
|
17
|
+
let lancedb = null;
|
|
18
|
+
let retriever = null;
|
|
19
|
+
let embedder = null;
|
|
20
|
+
async function getStorage() {
|
|
21
|
+
if (!sqlite || !lancedb || !retriever || !embedder) {
|
|
22
|
+
if (!existsSync(DB_PATH)) {
|
|
23
|
+
throw new Error('memextend not initialized. Run `memextend init` first.');
|
|
24
|
+
}
|
|
25
|
+
sqlite = new SQLiteStorage(DB_PATH);
|
|
26
|
+
lancedb = await LanceDBStorage.create(VECTORS_PATH);
|
|
27
|
+
embedder = await createEmbedFunction(MODELS_PATH);
|
|
28
|
+
retriever = new MemoryRetriever(sqlite, lancedb, embedder.embedQuery);
|
|
29
|
+
}
|
|
30
|
+
return { sqlite, lancedb, retriever, embedder };
|
|
31
|
+
}
|
|
32
|
+
const server = new Server({
|
|
33
|
+
name: 'memextend',
|
|
34
|
+
version: '0.1.0',
|
|
35
|
+
}, {
|
|
36
|
+
capabilities: {
|
|
37
|
+
tools: {},
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
// List available tools
|
|
41
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
42
|
+
return {
|
|
43
|
+
tools: [
|
|
44
|
+
{
|
|
45
|
+
name: 'memextend_search',
|
|
46
|
+
description: 'Search through your memories. Use this to recall past work, decisions, or context.',
|
|
47
|
+
inputSchema: {
|
|
48
|
+
type: 'object',
|
|
49
|
+
properties: {
|
|
50
|
+
query: {
|
|
51
|
+
type: 'string',
|
|
52
|
+
description: 'Search query (e.g., "Redis caching", "authentication setup")',
|
|
53
|
+
},
|
|
54
|
+
limit: {
|
|
55
|
+
type: 'number',
|
|
56
|
+
description: 'Maximum number of results (default: 5)',
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
required: ['query'],
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: 'memextend_save',
|
|
64
|
+
description: 'Save a memory for this project. Use this to remember important decisions, patterns, or context.',
|
|
65
|
+
inputSchema: {
|
|
66
|
+
type: 'object',
|
|
67
|
+
properties: {
|
|
68
|
+
content: {
|
|
69
|
+
type: 'string',
|
|
70
|
+
description: 'The memory content to save',
|
|
71
|
+
},
|
|
72
|
+
projectId: {
|
|
73
|
+
type: 'string',
|
|
74
|
+
description: 'Project ID (optional, defaults to current project)',
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
required: ['content'],
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
name: 'memextend_save_global',
|
|
82
|
+
description: 'Save a global preference or fact that applies across all projects.',
|
|
83
|
+
inputSchema: {
|
|
84
|
+
type: 'object',
|
|
85
|
+
properties: {
|
|
86
|
+
content: {
|
|
87
|
+
type: 'string',
|
|
88
|
+
description: 'The preference or fact to remember globally',
|
|
89
|
+
},
|
|
90
|
+
type: {
|
|
91
|
+
type: 'string',
|
|
92
|
+
enum: ['preference', 'pattern', 'fact'],
|
|
93
|
+
description: 'Type of global memory',
|
|
94
|
+
},
|
|
95
|
+
},
|
|
96
|
+
required: ['content', 'type'],
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
name: 'memextend_forget',
|
|
101
|
+
description: 'Delete a specific memory by ID.',
|
|
102
|
+
inputSchema: {
|
|
103
|
+
type: 'object',
|
|
104
|
+
properties: {
|
|
105
|
+
memoryId: {
|
|
106
|
+
type: 'string',
|
|
107
|
+
description: 'The ID of the memory to delete',
|
|
108
|
+
},
|
|
109
|
+
},
|
|
110
|
+
required: ['memoryId'],
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
name: 'memextend_status',
|
|
115
|
+
description: 'Get memextend status and memory statistics.',
|
|
116
|
+
inputSchema: {
|
|
117
|
+
type: 'object',
|
|
118
|
+
properties: {},
|
|
119
|
+
},
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
name: 'memextend_context',
|
|
123
|
+
description: 'Get relevant context for the current session. Returns recent memories, global preferences, and semantically related memories.',
|
|
124
|
+
inputSchema: {
|
|
125
|
+
type: 'object',
|
|
126
|
+
properties: {
|
|
127
|
+
projectId: {
|
|
128
|
+
type: 'string',
|
|
129
|
+
description: 'Project ID to get context for (optional)',
|
|
130
|
+
},
|
|
131
|
+
limit: {
|
|
132
|
+
type: 'number',
|
|
133
|
+
description: 'Maximum number of memories to return (default: 10)',
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
],
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
// Handle tool calls
|
|
142
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
143
|
+
const { name, arguments: args } = request.params;
|
|
144
|
+
try {
|
|
145
|
+
switch (name) {
|
|
146
|
+
case 'memextend_search': {
|
|
147
|
+
const { retriever } = await getStorage();
|
|
148
|
+
const query = args?.query;
|
|
149
|
+
const limit = args?.limit ?? 5;
|
|
150
|
+
const results = await retriever.hybridSearch(query, { limit });
|
|
151
|
+
if (results.length === 0) {
|
|
152
|
+
return { content: [{ type: 'text', text: 'No memories found matching your query.' }] };
|
|
153
|
+
}
|
|
154
|
+
const formatted = results.map((r, i) => {
|
|
155
|
+
const date = new Date(r.memory.createdAt).toLocaleDateString();
|
|
156
|
+
return `${i + 1}. [${date}] (score: ${r.score.toFixed(3)}) [ID: ${r.memory.id}]\n ${r.memory.content.split('\n')[0]}`;
|
|
157
|
+
}).join('\n\n');
|
|
158
|
+
return { content: [{ type: 'text', text: `Found ${results.length} memories:\n\n${formatted}` }] };
|
|
159
|
+
}
|
|
160
|
+
case 'memextend_save': {
|
|
161
|
+
const { sqlite, lancedb, embedder } = await getStorage();
|
|
162
|
+
const content = args?.content;
|
|
163
|
+
const projectId = args?.projectId ?? 'default';
|
|
164
|
+
// Validate content
|
|
165
|
+
if (!content || content.length < 10) {
|
|
166
|
+
return { content: [{ type: 'text', text: 'Memory content too short (minimum 10 characters).' }], isError: true };
|
|
167
|
+
}
|
|
168
|
+
if (content.length > 50000) {
|
|
169
|
+
return { content: [{ type: 'text', text: 'Memory content too long (maximum 50KB).' }], isError: true };
|
|
170
|
+
}
|
|
171
|
+
const memoryId = randomUUID();
|
|
172
|
+
sqlite.insertMemory({
|
|
173
|
+
id: memoryId,
|
|
174
|
+
projectId,
|
|
175
|
+
content,
|
|
176
|
+
type: 'manual',
|
|
177
|
+
sourceTool: null,
|
|
178
|
+
createdAt: new Date().toISOString(),
|
|
179
|
+
sessionId: null,
|
|
180
|
+
metadata: null,
|
|
181
|
+
});
|
|
182
|
+
const vector = await embedder.embed(content);
|
|
183
|
+
await lancedb.insertVector(memoryId, vector);
|
|
184
|
+
return { content: [{ type: 'text', text: `Memory saved with ID: ${memoryId}` }] };
|
|
185
|
+
}
|
|
186
|
+
case 'memextend_save_global': {
|
|
187
|
+
const { sqlite } = await getStorage();
|
|
188
|
+
const content = args?.content;
|
|
189
|
+
const type = args?.type;
|
|
190
|
+
// Validate content
|
|
191
|
+
if (!content || content.length < 5) {
|
|
192
|
+
return { content: [{ type: 'text', text: 'Content too short (minimum 5 characters).' }], isError: true };
|
|
193
|
+
}
|
|
194
|
+
if (content.length > 10000) {
|
|
195
|
+
return { content: [{ type: 'text', text: 'Content too long (maximum 10KB for global profiles).' }], isError: true };
|
|
196
|
+
}
|
|
197
|
+
const profileId = randomUUID();
|
|
198
|
+
sqlite.insertGlobalProfile({
|
|
199
|
+
id: profileId,
|
|
200
|
+
key: type,
|
|
201
|
+
content,
|
|
202
|
+
createdAt: new Date().toISOString(),
|
|
203
|
+
});
|
|
204
|
+
return { content: [{ type: 'text', text: `Global ${type} saved: "${content}"` }] };
|
|
205
|
+
}
|
|
206
|
+
case 'memextend_forget': {
|
|
207
|
+
const { sqlite, lancedb } = await getStorage();
|
|
208
|
+
const memoryId = args?.memoryId;
|
|
209
|
+
const deleted = sqlite.deleteMemory(memoryId);
|
|
210
|
+
if (deleted) {
|
|
211
|
+
// Also delete the vector embedding
|
|
212
|
+
await lancedb.deleteVector(memoryId);
|
|
213
|
+
return { content: [{ type: 'text', text: `Memory ${memoryId} deleted.` }] };
|
|
214
|
+
}
|
|
215
|
+
else {
|
|
216
|
+
return { content: [{ type: 'text', text: `Memory ${memoryId} not found.` }] };
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
case 'memextend_status': {
|
|
220
|
+
const { sqlite, lancedb, embedder } = await getStorage();
|
|
221
|
+
const memoryCount = sqlite.getMemoryCount();
|
|
222
|
+
const vectorCount = await lancedb.getVectorCount();
|
|
223
|
+
return {
|
|
224
|
+
content: [{
|
|
225
|
+
type: 'text',
|
|
226
|
+
text: `memextend Status:
|
|
227
|
+
- Total memories: ${memoryCount}
|
|
228
|
+
- Vector embeddings: ${vectorCount}
|
|
229
|
+
- Using real embeddings: ${embedder.isReal ? 'Yes' : 'No (fallback mode)'}
|
|
230
|
+
- Database: ${DB_PATH}
|
|
231
|
+
- Vectors: ${VECTORS_PATH}`
|
|
232
|
+
}]
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
case 'memextend_context': {
|
|
236
|
+
const { retriever, sqlite } = await getStorage();
|
|
237
|
+
const projectId = args?.projectId ?? 'default';
|
|
238
|
+
const limit = args?.limit ?? 10;
|
|
239
|
+
const context = await retriever.getContextForSession(projectId, {
|
|
240
|
+
limit,
|
|
241
|
+
includeGlobal: true,
|
|
242
|
+
});
|
|
243
|
+
const sections = [];
|
|
244
|
+
if (context.recentMemories.length > 0) {
|
|
245
|
+
sections.push('## Recent Memories');
|
|
246
|
+
for (const memory of context.recentMemories) {
|
|
247
|
+
const date = new Date(memory.createdAt).toLocaleDateString();
|
|
248
|
+
sections.push(`- [${date}] ${memory.content.split('\n')[0]}`);
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
if (context.globalProfile.length > 0) {
|
|
252
|
+
sections.push('\n## Global Preferences');
|
|
253
|
+
for (const profile of context.globalProfile) {
|
|
254
|
+
sections.push(`- [${profile.key}] ${profile.content}`);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
if (context.relevantMemories.length > 0) {
|
|
258
|
+
sections.push('\n## Relevant Past Work');
|
|
259
|
+
for (const result of context.relevantMemories) {
|
|
260
|
+
sections.push(`- ${result.memory.content.split('\n')[0]}`);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
if (sections.length === 0) {
|
|
264
|
+
return { content: [{ type: 'text', text: 'No context available for this project yet.' }] };
|
|
265
|
+
}
|
|
266
|
+
return { content: [{ type: 'text', text: sections.join('\n') }] };
|
|
267
|
+
}
|
|
268
|
+
default:
|
|
269
|
+
return { content: [{ type: 'text', text: `Unknown tool: ${name}` }], isError: true };
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
catch (error) {
|
|
273
|
+
const message = error instanceof Error ? error.message : 'Unknown error';
|
|
274
|
+
return { content: [{ type: 'text', text: `Error: ${message}` }], isError: true };
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
// Start server
|
|
278
|
+
async function main() {
|
|
279
|
+
const transport = new StdioServerTransport();
|
|
280
|
+
await server.connect(transport);
|
|
281
|
+
}
|
|
282
|
+
main().catch(console.error);
|
|
283
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/mcp/server.ts"],"names":[],"mappings":"AAAA,+CAA+C;AAC/C,8CAA8C;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,GACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,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AAI,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC;YACpE,CAAC;YAED;gBACE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,IAAI,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;QACzF,CAAC;IACH,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;QACzE,OAAO,EAAE,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,OAAO,EAAE,EAAE,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACnF,CAAC;AACH,CAAC,CAAC,CAAC;AAEH,eAAe;AACf,KAAK,UAAU,IAAI;IACjB,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@memextend/opencode",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "OpenCode adapter for memextend - MCP server for anomalyco/opencode AI memory",
|
|
5
|
+
"author": "ZodTTD LLC <repo@zodttd.com>",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"main": "dist/index.js",
|
|
9
|
+
"types": "dist/index.d.ts",
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"import": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./mcp": {
|
|
16
|
+
"types": "./dist/mcp/index.d.ts",
|
|
17
|
+
"import": "./dist/mcp/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"bin": {
|
|
21
|
+
"memextend-opencode-mcp": "dist/mcp/server.cjs"
|
|
22
|
+
},
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsc && npm run build:bundle",
|
|
25
|
+
"build:bundle": "node scripts/build.js",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"setup": "node dist/setup.js"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@memextend/core": "^0.1.0",
|
|
31
|
+
"@modelcontextprotocol/sdk": "^1.0.0"
|
|
32
|
+
},
|
|
33
|
+
"devDependencies": {
|
|
34
|
+
"esbuild": "^0.20.0"
|
|
35
|
+
},
|
|
36
|
+
"repository": {
|
|
37
|
+
"type": "git",
|
|
38
|
+
"url": "https://github.com/zodttd/memextend.git",
|
|
39
|
+
"directory": "packages/adapters/opencode"
|
|
40
|
+
},
|
|
41
|
+
"bugs": {
|
|
42
|
+
"url": "https://github.com/zodttd/memextend/issues"
|
|
43
|
+
},
|
|
44
|
+
"homepage": "https://github.com/zodttd/memextend#readme",
|
|
45
|
+
"keywords": [
|
|
46
|
+
"memextend",
|
|
47
|
+
"opencode",
|
|
48
|
+
"anomalyco",
|
|
49
|
+
"mcp",
|
|
50
|
+
"model-context-protocol",
|
|
51
|
+
"ai-memory",
|
|
52
|
+
"ai-coding",
|
|
53
|
+
"coding-agent"
|
|
54
|
+
],
|
|
55
|
+
"files": [
|
|
56
|
+
"dist",
|
|
57
|
+
"scripts",
|
|
58
|
+
"README.md"
|
|
59
|
+
],
|
|
60
|
+
"engines": {
|
|
61
|
+
"node": ">=18.0.0"
|
|
62
|
+
},
|
|
63
|
+
"publishConfig": {
|
|
64
|
+
"access": "public"
|
|
65
|
+
}
|
|
66
|
+
}
|
package/scripts/build.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Build script for bundling MCP server with esbuild
|
|
2
|
+
// Copyright (c) 2026 ZodTTD LLC. MIT License.
|
|
3
|
+
|
|
4
|
+
import { build } from 'esbuild';
|
|
5
|
+
import { join, dirname } from 'path';
|
|
6
|
+
import { fileURLToPath } from 'url';
|
|
7
|
+
import { mkdir } from 'fs/promises';
|
|
8
|
+
|
|
9
|
+
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
10
|
+
const srcDir = join(__dirname, '..', 'src');
|
|
11
|
+
const distDir = join(__dirname, '..', 'dist');
|
|
12
|
+
|
|
13
|
+
const commonOptions = {
|
|
14
|
+
bundle: true,
|
|
15
|
+
platform: 'node',
|
|
16
|
+
target: 'node18',
|
|
17
|
+
format: 'cjs',
|
|
18
|
+
// External packages that should not be bundled
|
|
19
|
+
// These are native modules or have complex dependencies
|
|
20
|
+
external: ['better-sqlite3', 'node-llama-cpp', '@lancedb/lancedb'],
|
|
21
|
+
logLevel: 'warning',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
async function buildMCP() {
|
|
25
|
+
const mcpDir = join(distDir, 'mcp');
|
|
26
|
+
await mkdir(mcpDir, { recursive: true });
|
|
27
|
+
|
|
28
|
+
try {
|
|
29
|
+
await build({
|
|
30
|
+
...commonOptions,
|
|
31
|
+
entryPoints: [join(srcDir, 'mcp', 'server.ts')],
|
|
32
|
+
outfile: join(mcpDir, 'server.cjs'),
|
|
33
|
+
});
|
|
34
|
+
console.log(`Built mcp/server.cjs`);
|
|
35
|
+
} catch (e) {
|
|
36
|
+
console.log(`Failed to build MCP server: ${e.message}`);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
async function main() {
|
|
42
|
+
console.log('Building memextend OpenCode adapter...\n');
|
|
43
|
+
await buildMCP();
|
|
44
|
+
console.log('\nBuild complete!');
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
main().catch(console.error);
|