coze-bridge 0.2.4-alpha.1 → 0.2.4-alpha.3
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/coze-bridge.js +34 -0
- package/dist/index.js +632 -646
- package/package.json +6 -5
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { spawn } from 'node:child_process';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
|
|
6
|
+
const ENTRY = fileURLToPath(new URL('../dist/index.js', import.meta.url));
|
|
7
|
+
const MARKER = 'COZE_BRIDGE_WARNINGS_FILTERED';
|
|
8
|
+
|
|
9
|
+
if (process.env.COZE_BRIDGE_NODE_WARNINGS || process.env[MARKER] === '1') {
|
|
10
|
+
await import('../dist/index.js');
|
|
11
|
+
} else {
|
|
12
|
+
const major = Number(process.versions.node.split('.')[0] ?? '0');
|
|
13
|
+
const warningFlag = major >= 20 ? '--disable-warning=DEP0151' : '--no-warnings';
|
|
14
|
+
const child = spawn(process.execPath, [warningFlag, ENTRY, ...process.argv.slice(2)], {
|
|
15
|
+
stdio: 'inherit',
|
|
16
|
+
env: {
|
|
17
|
+
...process.env,
|
|
18
|
+
[MARKER]: '1',
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
child.once('error', (err) => {
|
|
23
|
+
process.stderr.write(`fatal: failed to launch coze-bridge: ${String(err)}\n`);
|
|
24
|
+
process.exit(1);
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
child.once('exit', (code, signal) => {
|
|
28
|
+
if (signal) {
|
|
29
|
+
process.kill(process.pid, signal);
|
|
30
|
+
return;
|
|
31
|
+
}
|
|
32
|
+
process.exit(code ?? 1);
|
|
33
|
+
});
|
|
34
|
+
}
|