@wolpertingerlabs/drawlatch 1.0.0-alpha.9.1 → 1.0.0-alpha.9.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/bin/drawlatch.js +35 -101
- package/dist/remote/server.js +12 -4
- package/package.json +1 -1
package/bin/drawlatch.js
CHANGED
|
@@ -38,7 +38,7 @@ const { generateKeyBundle, saveKeyBundle, extractPublicKeys, fingerprint, loadKe
|
|
|
38
38
|
);
|
|
39
39
|
|
|
40
40
|
// Import connection template helpers
|
|
41
|
-
const { listConnectionTemplates
|
|
41
|
+
const { listConnectionTemplates } = await import(
|
|
42
42
|
join(PKG_ROOT, "dist/shared/connections.js")
|
|
43
43
|
);
|
|
44
44
|
|
|
@@ -80,8 +80,6 @@ try {
|
|
|
80
80
|
lines: { type: "string", short: "n", default: "50" },
|
|
81
81
|
follow: { type: "boolean", default: false },
|
|
82
82
|
path: { type: "boolean", default: false },
|
|
83
|
-
connections: { type: "string" },
|
|
84
|
-
alias: { type: "string" },
|
|
85
83
|
full: { type: "boolean", default: false },
|
|
86
84
|
ttl: { type: "string", default: "300" },
|
|
87
85
|
},
|
|
@@ -105,7 +103,10 @@ if (values.version) {
|
|
|
105
103
|
}
|
|
106
104
|
if (values.help && !subcommand) {
|
|
107
105
|
printHelp();
|
|
108
|
-
const latestVersion = await
|
|
106
|
+
const latestVersion = await Promise.race([
|
|
107
|
+
updateCheckPromise,
|
|
108
|
+
new Promise((r) => setTimeout(() => r(null), 100)),
|
|
109
|
+
]);
|
|
109
110
|
if (latestVersion) console.log(formatUpdateNotice(latestVersion));
|
|
110
111
|
process.exit(0);
|
|
111
112
|
}
|
|
@@ -187,7 +188,10 @@ switch (subcommand) {
|
|
|
187
188
|
case "help":
|
|
188
189
|
printHelp();
|
|
189
190
|
{
|
|
190
|
-
const latestVersion = await
|
|
191
|
+
const latestVersion = await Promise.race([
|
|
192
|
+
updateCheckPromise,
|
|
193
|
+
new Promise((r) => setTimeout(() => r(null), 100)),
|
|
194
|
+
]);
|
|
191
195
|
if (latestVersion) console.log(formatUpdateNotice(latestVersion));
|
|
192
196
|
}
|
|
193
197
|
break;
|
|
@@ -207,28 +211,15 @@ async function cmdDefault() {
|
|
|
207
211
|
console.log("Drawlatch remote server is not running.\n");
|
|
208
212
|
printHelp();
|
|
209
213
|
}
|
|
210
|
-
|
|
214
|
+
// Show update notice only if the check already resolved (don't block on network)
|
|
215
|
+
const latestVersion = await Promise.race([
|
|
216
|
+
updateCheckPromise,
|
|
217
|
+
new Promise((r) => setTimeout(() => r(null), 100)),
|
|
218
|
+
]);
|
|
211
219
|
if (latestVersion) console.log(formatUpdateNotice(latestVersion));
|
|
212
220
|
}
|
|
213
221
|
|
|
214
222
|
async function cmdInit() {
|
|
215
|
-
const alias = values.alias || "default";
|
|
216
|
-
const connectionsList = values.connections
|
|
217
|
-
? values.connections.split(",").map((c) => c.trim()).filter(Boolean)
|
|
218
|
-
: [];
|
|
219
|
-
|
|
220
|
-
// Validate requested connections exist
|
|
221
|
-
if (connectionsList.length > 0) {
|
|
222
|
-
const available = listAvailableConnections();
|
|
223
|
-
const availableSet = new Set(available);
|
|
224
|
-
const invalid = connectionsList.filter((c) => !availableSet.has(c));
|
|
225
|
-
if (invalid.length > 0) {
|
|
226
|
-
console.error(`Unknown connection(s): ${invalid.join(", ")}`);
|
|
227
|
-
console.error(`Available: ${available.join(", ")}`);
|
|
228
|
-
process.exit(1);
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
|
|
232
223
|
console.log(`\nDrawlatch Setup`);
|
|
233
224
|
console.log(`===============\n`);
|
|
234
225
|
|
|
@@ -251,20 +242,7 @@ async function cmdInit() {
|
|
|
251
242
|
steps.push(`Server keys: CREATED (${fp})`);
|
|
252
243
|
}
|
|
253
244
|
|
|
254
|
-
// Step 3:
|
|
255
|
-
const callerKeysDir = join(getCallerKeysDir(), alias);
|
|
256
|
-
if (existsSync(join(callerKeysDir, "signing.key.pem"))) {
|
|
257
|
-
const existing = loadKeyBundle(callerKeysDir);
|
|
258
|
-
const fp = fingerprint(extractPublicKeys(existing));
|
|
259
|
-
steps.push(`Caller keys (${alias}): already exist (${fp})`);
|
|
260
|
-
} else {
|
|
261
|
-
const bundle = generateKeyBundle();
|
|
262
|
-
saveKeyBundle(bundle, callerKeysDir);
|
|
263
|
-
const fp = fingerprint(extractPublicKeys(bundle));
|
|
264
|
-
steps.push(`Caller keys (${alias}): CREATED (${fp})`);
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
// Step 4: Scaffold proxy.config.json
|
|
245
|
+
// Step 3: Scaffold proxy.config.json
|
|
268
246
|
const proxyConfigPath = getProxyConfigPath();
|
|
269
247
|
if (existsSync(proxyConfigPath)) {
|
|
270
248
|
steps.push(`Proxy config: already exists`);
|
|
@@ -278,7 +256,7 @@ async function cmdInit() {
|
|
|
278
256
|
steps.push(`Proxy config: CREATED`);
|
|
279
257
|
}
|
|
280
258
|
|
|
281
|
-
// Step
|
|
259
|
+
// Step 4: Scaffold remote.config.json
|
|
282
260
|
const remoteConfigPath = getRemoteConfigPath();
|
|
283
261
|
if (existsSync(remoteConfigPath)) {
|
|
284
262
|
steps.push(`Remote config: already exists`);
|
|
@@ -287,44 +265,22 @@ async function cmdInit() {
|
|
|
287
265
|
host: "0.0.0.0",
|
|
288
266
|
port: 9999,
|
|
289
267
|
rateLimitPerMinute: 60,
|
|
290
|
-
callers: {
|
|
291
|
-
[alias]: {
|
|
292
|
-
name: alias === "default" ? "Default Caller" : alias,
|
|
293
|
-
connections: connectionsList,
|
|
294
|
-
},
|
|
295
|
-
},
|
|
268
|
+
callers: {},
|
|
296
269
|
};
|
|
297
270
|
writeFileSync(remoteConfigPath, JSON.stringify(remoteConfig, null, 2) + "\n", { mode: 0o600 });
|
|
298
|
-
steps.push(`Remote config: CREATED
|
|
271
|
+
steps.push(`Remote config: CREATED`);
|
|
299
272
|
}
|
|
300
273
|
|
|
301
|
-
// Step
|
|
274
|
+
// Step 5: Scaffold .env file
|
|
302
275
|
if (existsSync(ENV_FILE)) {
|
|
303
276
|
steps.push(`.env file: already exists`);
|
|
304
277
|
} else {
|
|
305
278
|
const envLines = [
|
|
306
279
|
"# Drawlatch environment secrets",
|
|
307
|
-
"#
|
|
280
|
+
"# Set tokens for your enabled connections",
|
|
281
|
+
"# Secrets are prefixed per caller (e.g., DEFAULT_GITHUB_TOKEN)",
|
|
308
282
|
"",
|
|
309
283
|
];
|
|
310
|
-
|
|
311
|
-
// Get secret info for requested connections (or all if none specified)
|
|
312
|
-
const templates = listConnectionTemplates();
|
|
313
|
-
const relevantTemplates = connectionsList.length > 0
|
|
314
|
-
? templates.filter((t) => connectionsList.includes(t.alias))
|
|
315
|
-
: templates.filter((t) => ["github", "slack", "discord-bot", "openai", "anthropic"].includes(t.alias));
|
|
316
|
-
|
|
317
|
-
for (const t of relevantTemplates) {
|
|
318
|
-
envLines.push(`# ${t.name}`);
|
|
319
|
-
for (const s of t.requiredSecrets) {
|
|
320
|
-
envLines.push(`# ${s}=`);
|
|
321
|
-
}
|
|
322
|
-
for (const s of t.optionalSecrets) {
|
|
323
|
-
envLines.push(`# ${s}=`);
|
|
324
|
-
}
|
|
325
|
-
envLines.push("");
|
|
326
|
-
}
|
|
327
|
-
|
|
328
284
|
writeFileSync(ENV_FILE, envLines.join("\n") + "\n", { mode: 0o600 });
|
|
329
285
|
steps.push(`.env file: CREATED`);
|
|
330
286
|
}
|
|
@@ -335,25 +291,10 @@ async function cmdInit() {
|
|
|
335
291
|
}
|
|
336
292
|
|
|
337
293
|
console.log(`\nSetup complete! Next steps:\n`);
|
|
338
|
-
|
|
339
|
-
if (connectionsList.length > 0) {
|
|
340
|
-
const templates = listConnectionTemplates();
|
|
341
|
-
const enabledTemplates = templates.filter((t) => connectionsList.includes(t.alias));
|
|
342
|
-
const allSecrets = enabledTemplates.flatMap((t) => t.requiredSecrets);
|
|
343
|
-
if (allSecrets.length > 0) {
|
|
344
|
-
console.log(` 1. Set your API secrets in ${ENV_FILE}:`);
|
|
345
|
-
for (const s of [...new Set(allSecrets)]) {
|
|
346
|
-
console.log(` ${s}=your_token_here`);
|
|
347
|
-
}
|
|
348
|
-
console.log();
|
|
349
|
-
}
|
|
350
|
-
} else {
|
|
351
|
-
console.log(` 1. Edit ${remoteConfigPath} to add connections (e.g., "github", "slack")`);
|
|
352
|
-
console.log(` Then set the required secrets in ${ENV_FILE}\n`);
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
console.log(` 2. Start the remote server:`);
|
|
294
|
+
console.log(` 1. Start the remote server:`);
|
|
356
295
|
console.log(` drawlatch start\n`);
|
|
296
|
+
console.log(` 2. Add callers via key sync:`);
|
|
297
|
+
console.log(` drawlatch sync\n`);
|
|
357
298
|
console.log(` 3. Verify your setup:`);
|
|
358
299
|
console.log(` drawlatch doctor\n`);
|
|
359
300
|
}
|
|
@@ -869,14 +810,14 @@ async function cmdSync() {
|
|
|
869
810
|
console.log(
|
|
870
811
|
` Keys saved to: ${join(CONFIG_DIR, "keys", "callers", status.callerAlias)}/`,
|
|
871
812
|
);
|
|
872
|
-
console.log(
|
|
873
|
-
|
|
874
|
-
);
|
|
813
|
+
console.log(`\nThe caller can now connect (no server restart needed).`);
|
|
814
|
+
console.log(`\nTo grant API access, add connections in ${join(CONFIG_DIR, "remote.config.json")}:`);
|
|
875
815
|
console.log(` "callers": {`);
|
|
876
816
|
console.log(` "${status.callerAlias}": {`);
|
|
877
817
|
console.log(` "connections": ["github", "slack", ...]`);
|
|
878
818
|
console.log(` }`);
|
|
879
819
|
console.log(` }`);
|
|
820
|
+
console.log(`\nThen set the required secrets in ${ENV_FILE}`);
|
|
880
821
|
console.log();
|
|
881
822
|
process.exit(0);
|
|
882
823
|
}
|
|
@@ -1167,7 +1108,7 @@ drawlatch v${VERSION}
|
|
|
1167
1108
|
Usage: drawlatch [command] [options]
|
|
1168
1109
|
|
|
1169
1110
|
Commands:
|
|
1170
|
-
init Set up drawlatch (keys, config, .env)
|
|
1111
|
+
init Set up drawlatch server (keys, config, .env)
|
|
1171
1112
|
start Start the remote server (background by default)
|
|
1172
1113
|
stop Stop the background remote server
|
|
1173
1114
|
restart Restart the background remote server
|
|
@@ -1185,9 +1126,7 @@ Options:
|
|
|
1185
1126
|
Running 'drawlatch' with no arguments shows status (if running) or this help.
|
|
1186
1127
|
|
|
1187
1128
|
Examples:
|
|
1188
|
-
drawlatch init Set up
|
|
1189
|
-
drawlatch init --connections github Set up with GitHub connection
|
|
1190
|
-
drawlatch init --alias mybot Set up with custom caller alias
|
|
1129
|
+
drawlatch init Set up the remote server
|
|
1191
1130
|
drawlatch start Start remote server in background
|
|
1192
1131
|
drawlatch start -f Start remote server in foreground
|
|
1193
1132
|
drawlatch start -f --tunnel Start with a public tunnel for webhooks
|
|
@@ -1304,23 +1243,18 @@ function printInitHelp() {
|
|
|
1304
1243
|
console.log(`
|
|
1305
1244
|
drawlatch init
|
|
1306
1245
|
|
|
1307
|
-
Set up drawlatch
|
|
1308
|
-
files,
|
|
1246
|
+
Set up the drawlatch remote server. Generates server keys, creates
|
|
1247
|
+
config files, and scaffolds a .env template.
|
|
1248
|
+
|
|
1249
|
+
Callers are added separately via 'drawlatch sync' after the server
|
|
1250
|
+
is running.
|
|
1309
1251
|
|
|
1310
1252
|
Usage: drawlatch init [options]
|
|
1311
1253
|
|
|
1312
1254
|
Options:
|
|
1313
|
-
|
|
1314
|
-
--alias <name> Name for the local identity (default: "default")
|
|
1315
|
-
-h, --help Show this help message
|
|
1255
|
+
-h, --help Show this help message
|
|
1316
1256
|
|
|
1317
1257
|
All steps are idempotent — safe to re-run without overwriting existing files.
|
|
1318
|
-
|
|
1319
|
-
Examples:
|
|
1320
|
-
drawlatch init Set up with defaults
|
|
1321
|
-
drawlatch init --connections github Set up with GitHub enabled
|
|
1322
|
-
drawlatch init --alias laptop Use "laptop" as the caller alias
|
|
1323
|
-
drawlatch init --alias ci --connections github,slack
|
|
1324
1258
|
`);
|
|
1325
1259
|
}
|
|
1326
1260
|
|
package/dist/remote/server.js
CHANGED
|
@@ -1416,14 +1416,22 @@ export function main() {
|
|
|
1416
1416
|
}
|
|
1417
1417
|
const config = loadRemoteConfig();
|
|
1418
1418
|
const serverKeysDirPath = getServerKeysDir();
|
|
1419
|
-
|
|
1420
|
-
|
|
1419
|
+
const requiredKeyFiles = ['signing.key.pem', 'signing.pub.pem', 'exchange.key.pem', 'exchange.pub.pem'];
|
|
1420
|
+
const missingKeyFiles = requiredKeyFiles.filter((f) => !fs.existsSync(path.join(serverKeysDirPath, f)));
|
|
1421
|
+
if (missingKeyFiles.length > 0) {
|
|
1422
|
+
if (!fs.existsSync(serverKeysDirPath)) {
|
|
1423
|
+
console.error(`[remote] Error: Server keys not found at ${serverKeysDirPath}`);
|
|
1424
|
+
}
|
|
1425
|
+
else {
|
|
1426
|
+
console.error(`[remote] Error: Incomplete server keys in ${serverKeysDirPath}`);
|
|
1427
|
+
console.error(`[remote] Missing: ${missingKeyFiles.join(', ')}`);
|
|
1428
|
+
}
|
|
1421
1429
|
console.error('[remote] Run: drawlatch generate-keys server');
|
|
1422
1430
|
process.exit(1);
|
|
1423
1431
|
}
|
|
1424
1432
|
if (Object.keys(config.callers).length === 0) {
|
|
1425
|
-
console.
|
|
1426
|
-
console.
|
|
1433
|
+
console.log('[remote] No callers configured — server will accept sync requests.');
|
|
1434
|
+
console.log('[remote] To add callers, run: drawlatch sync');
|
|
1427
1435
|
}
|
|
1428
1436
|
const port = process.env.DRAWLATCH_PORT ? parseInt(process.env.DRAWLATCH_PORT, 10) : config.port;
|
|
1429
1437
|
const host = process.env.DRAWLATCH_HOST ?? config.host;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wolpertingerlabs/drawlatch",
|
|
3
|
-
"version": "1.0.0-alpha.9.
|
|
3
|
+
"version": "1.0.0-alpha.9.2",
|
|
4
4
|
"description": "Encrypted MCP proxy with mutual authentication. Local MCP server forwards requests through an encrypted channel to a remote secrets-holding server.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/mcp/server.js",
|