A TypeScript/JavaScript wrapper for interacting with the Q Developer CLI.
npm install q-developer-wrapperFor TypeScript development, also install:
npm install -D typescript @types/node ts-nodeimport QDeveloperWrapper from 'q-developer-wrapper';
const q = new QDeveloperWrapper();
// Simple chat (no tools)
const answer = await q.chat('What are TypeScript best practices?');
console.log(answer);
// Execute with tools enabled (can create/modify files)
const code = await q.execute('Create a function to validate emails');
console.log(code);
// Full control
const response = await q.ask({
message: 'Help me debug this code',
acceptAllTools: true,
timeout: 60000
});
if (response.success) {
console.log(response.content);
} else {
console.error(response.error);
}See the complete interactive chat example at examples/chat.ts.
Quick start:
# Option 1: Install ts-node globally (one time)
npm install -g ts-node
ts-node examples/chat.ts
# Option 2: Use local installation
npm install -D typescript @types/node ts-node
npx ts-node examples/chat.tsFeatures:
- Interactive question/answer loop
/tools- Enable tools for next question/notool- Disable tools/exit- Exit session- Real-time streaming responses
ask(request: QRequest): Promise<QResponse>
request.message: Your promptrequest.acceptAllTools: Enable tool execution (default: false)request.timeout: Timeout in ms (default: 120000)
chat(message: string): Promise<string>
- Simple chat without tools, throws on error
execute(message: string): Promise<string>
- Chat with tools enabled, throws on error
isAvailable(): Promise<boolean>
- Check if Q CLI is available and authenticated
interface QRequest {
message: string;
acceptAllTools?: boolean;
timeout?: number;
}
interface QResponse {
success: boolean;
content: string;
error?: string;
}Uses q chat --no-interactive with stdin input:
- Sends messages via stdin (like
echo "message" | q chat --no-interactive) - Tools run with
--trust-all-toolsflag when enabled - Real-time streaming output
- Clean, programmatic interface
Perfect for automation, CI/CD, and interactive applications.
- Node.js 14+
- Q Developer CLI installed and accessible in PATH