@synapsync/syntra-mcp 0.0.0-stage → 0.1.1
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 +38 -2
- package/THIRD-PARTY-NOTICES.md +1255 -0
- package/bin/launcher.cjs +170 -0
- package/bin/setup.cjs +1317 -0
- package/bin/vendor/dependencies.json +32 -0
- package/bin/vendor/jsonc-parser/LICENSE.md +21 -0
- package/bin/vendor/jsonc-parser/lib/umd/impl/edit.js +201 -0
- package/bin/vendor/jsonc-parser/lib/umd/impl/format.js +275 -0
- package/bin/vendor/jsonc-parser/lib/umd/impl/parser.js +682 -0
- package/bin/vendor/jsonc-parser/lib/umd/impl/scanner.js +456 -0
- package/bin/vendor/jsonc-parser/lib/umd/impl/string-intern.js +42 -0
- package/bin/vendor/jsonc-parser/lib/umd/main.js +194 -0
- package/bin/vendor/smol-toml/LICENSE +24 -0
- package/bin/vendor/smol-toml/index.cjs +771 -0
- package/package.json +34 -4
- package/skills/syntra/SKILL.md +31 -0
- package/skills/syntra/references/tools.md +24 -0
package/bin/launcher.cjs
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
const { spawn } = require('node:child_process');
|
|
5
|
+
const fs = require('node:fs');
|
|
6
|
+
const path = require('node:path');
|
|
7
|
+
const packageManifest = require('../package.json');
|
|
8
|
+
|
|
9
|
+
const TARGETS = Object.freeze({
|
|
10
|
+
'linux/x64': Object.freeze({ packageName: '@synapsync/syntra-linux-x64', executable: 'bin/syntra' }),
|
|
11
|
+
'linux/arm64': Object.freeze({ packageName: '@synapsync/syntra-linux-arm64', executable: 'bin/syntra' }),
|
|
12
|
+
'darwin/x64': Object.freeze({ packageName: '@synapsync/syntra-darwin-x64', executable: 'bin/syntra' }),
|
|
13
|
+
'darwin/arm64': Object.freeze({ packageName: '@synapsync/syntra-darwin-arm64', executable: 'bin/syntra' }),
|
|
14
|
+
'win32/x64': Object.freeze({ packageName: '@synapsync/syntra-win32-x64', executable: 'bin/syntra.exe' }),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
const SUPPORTED_TARGETS = Object.keys(TARGETS).join(', ');
|
|
18
|
+
const SIGNALS = Object.freeze({
|
|
19
|
+
win32: Object.freeze(['SIGINT', 'SIGBREAK', 'SIGTERM']),
|
|
20
|
+
default: Object.freeze(['SIGHUP', 'SIGINT', 'SIGTERM']),
|
|
21
|
+
});
|
|
22
|
+
const SIGNAL_EXIT_CODES = Object.freeze({
|
|
23
|
+
SIGHUP: 129,
|
|
24
|
+
SIGINT: 130,
|
|
25
|
+
SIGBREAK: 149,
|
|
26
|
+
SIGTERM: 143,
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
function targetFor(platform, architecture) {
|
|
30
|
+
const target = TARGETS[`${platform}/${architecture}`];
|
|
31
|
+
if (!target) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
`Syntra does not provide a binary for ${platform}/${architecture}. ` +
|
|
34
|
+
`Supported targets: ${SUPPORTED_TARGETS}. Ask your administrator for a supported build.`,
|
|
35
|
+
);
|
|
36
|
+
}
|
|
37
|
+
return target;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
function resolveBinary(platform = process.platform, architecture = process.arch, resolve = require.resolve) {
|
|
41
|
+
const target = targetFor(platform, architecture);
|
|
42
|
+
const missingBinary = () => new Error(
|
|
43
|
+
`The Syntra binary for ${platform}/${architecture} is missing ` +
|
|
44
|
+
`(${target.packageName}). Reinstall @synapsync/syntra-mcp with optional dependencies enabled ` +
|
|
45
|
+
`(npm install --include=optional) and make sure the matching platform package is available.`,
|
|
46
|
+
);
|
|
47
|
+
let installedManifest;
|
|
48
|
+
let manifestPath;
|
|
49
|
+
try {
|
|
50
|
+
manifestPath = resolve(`${target.packageName}/package.json`);
|
|
51
|
+
installedManifest = JSON.parse(fs.readFileSync(manifestPath, 'utf8'));
|
|
52
|
+
} catch {
|
|
53
|
+
throw missingBinary();
|
|
54
|
+
}
|
|
55
|
+
const expectedVersion = packageManifest.optionalDependencies?.[target.packageName];
|
|
56
|
+
if (!installedManifest || typeof installedManifest !== 'object' || Array.isArray(installedManifest) ||
|
|
57
|
+
installedManifest.name !== target.packageName || expectedVersion !== packageManifest.version ||
|
|
58
|
+
installedManifest.version !== expectedVersion) {
|
|
59
|
+
throw new Error(
|
|
60
|
+
`The installed ${target.packageName} package does not match launcher version ${packageManifest.version}. ` +
|
|
61
|
+
`Reinstall @synapsync/syntra-mcp with its exact optional dependencies.`,
|
|
62
|
+
);
|
|
63
|
+
}
|
|
64
|
+
const executablePath = path.join(path.dirname(manifestPath), target.executable);
|
|
65
|
+
try {
|
|
66
|
+
if (!fs.lstatSync(executablePath).isFile()) throw new Error('not a regular file');
|
|
67
|
+
fs.accessSync(executablePath, platform === 'win32' ? fs.constants.F_OK : fs.constants.X_OK);
|
|
68
|
+
return executablePath;
|
|
69
|
+
} catch {
|
|
70
|
+
throw missingBinary();
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function signalNames(platform = process.platform) {
|
|
75
|
+
return platform === 'win32' ? SIGNALS.win32 : SIGNALS.default;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function signalExitCode(signal) {
|
|
79
|
+
return SIGNAL_EXIT_CODES[signal] || 1;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function launch(args = process.argv.slice(2)) {
|
|
83
|
+
if (args[0] === 'setup') {
|
|
84
|
+
let setup;
|
|
85
|
+
try {
|
|
86
|
+
setup = require('./setup.cjs');
|
|
87
|
+
process.stdout.write(setup.runSetup(args.slice(1)));
|
|
88
|
+
} catch (error) {
|
|
89
|
+
const message = setup && error instanceof setup.SetupError
|
|
90
|
+
? error.message
|
|
91
|
+
: 'Setup preview could not be completed safely.';
|
|
92
|
+
process.stderr.write(`syntra: ${message}\n`);
|
|
93
|
+
process.exitCode = 1;
|
|
94
|
+
}
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
let executable;
|
|
99
|
+
try {
|
|
100
|
+
executable = resolveBinary();
|
|
101
|
+
} catch (error) {
|
|
102
|
+
process.stderr.write(`syntra: ${error.message}\n`);
|
|
103
|
+
process.exitCode = 1;
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
let child;
|
|
108
|
+
try {
|
|
109
|
+
child = spawn(executable, args, {
|
|
110
|
+
shell: false,
|
|
111
|
+
stdio: 'inherit',
|
|
112
|
+
windowsHide: true,
|
|
113
|
+
});
|
|
114
|
+
} catch {
|
|
115
|
+
process.stderr.write(`syntra: unable to start the ${process.platform}/${process.arch} executable. Reinstall the matching platform package.\n`);
|
|
116
|
+
process.exitCode = 1;
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
let receivedSignal = null;
|
|
121
|
+
let handlersRemoved = false;
|
|
122
|
+
const handlers = new Map();
|
|
123
|
+
const removeHandlers = () => {
|
|
124
|
+
if (handlersRemoved) return;
|
|
125
|
+
handlersRemoved = true;
|
|
126
|
+
for (const [signal, handler] of handlers) process.removeListener(signal, handler);
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
for (const signal of signalNames()) {
|
|
130
|
+
const handler = () => {
|
|
131
|
+
receivedSignal = signal;
|
|
132
|
+
if (child.exitCode !== null || child.signalCode !== null) return;
|
|
133
|
+
try {
|
|
134
|
+
child.kill(signal);
|
|
135
|
+
} catch {
|
|
136
|
+
// The child may have exited between the state check and kill().
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
handlers.set(signal, handler);
|
|
140
|
+
process.on(signal, handler);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
child.once('error', () => {
|
|
144
|
+
removeHandlers();
|
|
145
|
+
process.stderr.write(`syntra: unable to start the ${process.platform}/${process.arch} executable. Reinstall the matching platform package.\n`);
|
|
146
|
+
process.exitCode = 1;
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
child.once('exit', (code, childSignal) => {
|
|
150
|
+
removeHandlers();
|
|
151
|
+
const signal = receivedSignal || childSignal;
|
|
152
|
+
if (signal) {
|
|
153
|
+
if (process.platform === 'win32') {
|
|
154
|
+
process.exitCode = signalExitCode(signal);
|
|
155
|
+
} else {
|
|
156
|
+
try {
|
|
157
|
+
process.kill(process.pid, signal);
|
|
158
|
+
} catch {
|
|
159
|
+
process.exitCode = signalExitCode(signal);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
process.exitCode = Number.isInteger(code) ? code : 1;
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (require.main === module) launch();
|
|
169
|
+
|
|
170
|
+
module.exports = { targetFor, resolveBinary, signalNames, signalExitCode };
|