Files
claude-code-conduit/client/index.mjs
mikael-lovqvists-claude-agent e8bbcb293f Add ccc-server/client/queue bins and blessed queue TUI
- bin/ccc-server, ccc-client, ccc-queue wired up via package.json bin
- client/config.mjs: shared secrets/user resolution from CLI args or
  CCC_SECRETS/CCC_USER env vars
- ccc-queue: blessed TUI with two-pane layout (list + detail), polls
  every 2s, y/n to approve/deny selected item, r to refresh, q to quit

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-03-07 20:49:12 +00:00

64 lines
1.8 KiB
JavaScript

#!/usr/bin/env node
// Conduit client — thin CLI wrapper for Claude to call the conduit server.
// Usage:
// ccc-client '{"action": "list-actions"}'
// ccc-client '{"action":' '"edit-file",' '"filename": "/workspace/foo.mjs"}'
import { sign_request } from './auth.mjs';
import { load_client_config, get_remaining } from './config.mjs';
const BASE_URL = process.env.CONDUIT_URL || 'http://localhost:3015';
export async function call_action(payload, username, secret) {
const body_string = JSON.stringify(payload);
const res = await fetch(`${BASE_URL}/action`, {
method: 'POST',
headers: { 'Content-Type': 'application/json', ...sign_request(secret, username, body_string) },
body: body_string,
});
const body = await res.json();
return { status: res.status, body };
}
export async function get_queue(username, secret) {
const res = await fetch(`${BASE_URL}/queue`, {
headers: sign_request(secret, username, ''),
});
return res.json();
}
export async function resolve_queue_item(id, decision, username, secret) {
const res = await fetch(`${BASE_URL}/queue/${id}/${decision}`, {
method: 'POST',
headers: sign_request(secret, username, ''),
});
return res.json();
}
async function main() {
const { username, secret } = load_client_config(process.argv);
const remaining = get_remaining(process.argv);
if (!remaining.length) {
console.error('Usage: ccc-client <json payload>');
process.exit(1);
}
let payload;
try {
payload = JSON.parse(remaining.join(' '));
} catch (err) {
console.error(`Invalid JSON payload: ${err.message}`);
process.exit(1);
}
const { status, body } = await call_action(payload, username, secret);
console.log(JSON.stringify(body, null, 2));
process.exit(status >= 400 ? 1 : 0);
}
main().catch((err) => {
console.error('Conduit error:', err.message);
process.exit(1);
});