mirror of
https://github.com/QwenLM/qwen-code.git
synced 2026-04-28 19:52:02 +00:00
- Update channel-base to use built dist/ output with proper exports - Add README with quick start guide and usage instructions - Add qwen-extension.json manifest for extension discovery - Add start-server CLI for running the mock WebSocket server - Update dependencies from local file: to npm version This enables the plugin-example package to be published and installed as a standalone extension for testing the channel plugin system. Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
#!/usr/bin/env node
|
|
/* eslint-disable no-console */
|
|
/**
|
|
* Start the mock WebSocket server for testing the plugin-example channel.
|
|
*
|
|
* Usage:
|
|
* npx qwen-channel-plugin-example-server
|
|
* # or
|
|
* node node_modules/@qwen-code/channel-plugin-example/dist/start-server.js
|
|
*
|
|
* Environment variables:
|
|
* HTTP_PORT (default: 9200)
|
|
* WS_PORT (default: 9201)
|
|
*/
|
|
import { createMockServer } from './mock-server.js';
|
|
|
|
const httpPort = parseInt(process.env['HTTP_PORT'] || '9200', 10);
|
|
const wsPort = parseInt(process.env['WS_PORT'] || '9201', 10);
|
|
|
|
const server = await createMockServer({ httpPort, wsPort });
|
|
|
|
console.log(`Mock server running:`);
|
|
console.log(` HTTP: http://localhost:${server.httpPort}`);
|
|
console.log(` WS: ws://localhost:${server.wsPort}`);
|
|
console.log();
|
|
console.log(`Send a test message:`);
|
|
console.log(` curl -sX POST http://localhost:${server.httpPort}/message \\`);
|
|
console.log(` -H 'Content-Type: application/json' \\`);
|
|
console.log(
|
|
` -d '{"senderId":"user1","senderName":"Tester","text":"Hello"}'`,
|
|
);
|
|
|
|
process.on('SIGINT', async () => {
|
|
await server.close();
|
|
process.exit(0);
|
|
});
|