@dncore/synapse 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.
Files changed (3) hide show
  1. package/README.md +23 -0
  2. package/bin/synapse.js +39 -0
  3. package/package.json +26 -0
package/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # @dncore/synapse (npm distribution)
2
+
3
+ The synapse protocol adapter distributed as prebuilt native binaries —
4
+ the Node.js runtime is only a launcher; the daemon itself is the original
5
+ Go binary (esbuild-style distribution).
6
+
7
+ ```bash
8
+ npm install -g @dncore/synapse
9
+ synapse --config config.yaml
10
+ ```
11
+
12
+ - Requires npm >= 7 (optionalDependencies install the matching platform
13
+ package automatically).
14
+ - `SYNAPSE_BINARY=/path/to/binary` overrides resolution (e.g. when
15
+ installed outside npm).
16
+ - Signals (Ctrl-C, SIGTERM) are forwarded to the daemon, which drains
17
+ gracefully.
18
+
19
+ Platform packages: `@dncore/synapse-linux-x64`, `-linux-arm64`,
20
+ `-darwin-x64`, `-darwin-arm64`.
21
+
22
+ See the [repo README](https://github.com/dncore/synapse-protocol-adapter)
23
+ for configuration, deployment, and protocol semantics.
package/bin/synapse.js ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+ // Launcher for the prebuilt synapse binary (esbuild-style distribution):
3
+ // resolve the platform package installed as an optionalDependency and exec
4
+ // the native binary, forwarding signals and the exit code.
5
+ 'use strict';
6
+ const { spawn } = require('child_process');
7
+ const path = require('path');
8
+
9
+ const platformPackage = (() => {
10
+ const os = process.platform === 'win32' ? 'windows' : process.platform;
11
+ return `@dncore/synapse-${os}-${process.arch}`;
12
+ })();
13
+
14
+ function resolveBinary() {
15
+ if (process.env.SYNAPSE_BINARY) return process.env.SYNAPSE_BINARY;
16
+ try {
17
+ const pkg = require.resolve(`${platformPackage}/package.json`);
18
+ return path.join(path.dirname(pkg), 'bin', 'synapse');
19
+ } catch {
20
+ console.error(
21
+ `synapse: platform package ${platformPackage} is not installed.\n` +
22
+ ` npm may have skipped optional dependencies (e.g. --no-optional or --omit=optional).\n` +
23
+ ` Reinstall without those flags, or point SYNAPSE_BINARY at a binary.`
24
+ );
25
+ process.exit(1);
26
+ }
27
+ }
28
+
29
+ const child = spawn(resolveBinary(), process.argv.slice(2), { stdio: 'inherit' });
30
+ for (const sig of ['SIGINT', 'SIGTERM']) {
31
+ process.on(sig, () => child.kill(sig)); // forward Ctrl-C / stop; the daemon drains gracefully
32
+ }
33
+ child.on('error', (err) => {
34
+ console.error(`synapse: failed to start binary: ${err.message}`);
35
+ process.exit(1);
36
+ });
37
+ child.on('exit', (code, signal) => {
38
+ process.exit(signal ? 128 + 15 : (code ?? 0));
39
+ });
package/package.json ADDED
@@ -0,0 +1,26 @@
1
+ {
2
+ "name": "@dncore/synapse",
3
+ "version": "0.1.0",
4
+ "description": "Stateless, high-concurrency OpenAI Responses API to Chat Completions protocol adapter (prebuilt Go binary)",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/dncore/synapse-protocol-adapter.git"
9
+ },
10
+ "bin": {
11
+ "synapse": "bin/synapse.js"
12
+ },
13
+ "files": [
14
+ "bin/",
15
+ "README.md"
16
+ ],
17
+ "optionalDependencies": {
18
+ "@dncore/synapse-linux-x64": "0.1.0",
19
+ "@dncore/synapse-linux-arm64": "0.1.0",
20
+ "@dncore/synapse-darwin-x64": "0.1.0",
21
+ "@dncore/synapse-darwin-arm64": "0.1.0"
22
+ },
23
+ "engines": {
24
+ "node": ">=16"
25
+ }
26
+ }