// Start gateway first and wait for hello before accepting ACP requests.
gateway.start();
await gatewayReady.catch((err) => {
shutdown(); throw err;
}); if (stopped) { return closed;
}
const input = Writable.toWeb(process.stdout); const output = Readable.toWeb(process.stdin) as unknown as ReadableStream<Uint8Array>; const stream = ndJsonStream(input, output);
const _connection = new AgentSideConnection((conn: AgentSideConnection) => {
agent = new AcpGatewayAgent(conn, gateway, opts);
agent.start(); return agent;
}, stream);
return closed;
}
function parseArgs(args: string[]): AcpServerOptions { const opts: AcpServerOptions = {};
let tokenFile: string | undefined;
let passwordFile: string | undefined; for (let i = 0; i < args.length; i += 1) { const arg = args[i]; if (arg === "--url" || arg === "--gateway-url") {
opts.gatewayUrl = args[i + 1];
i += 1; continue;
} if (arg === "--token" || arg === "--gateway-token") {
opts.gatewayToken = args[i + 1];
i += 1; continue;
} if (arg === "--token-file" || arg === "--gateway-token-file") {
tokenFile = args[i + 1];
i += 1; continue;
} if (arg === "--password" || arg === "--gateway-password") {
opts.gatewayPassword = args[i + 1];
i += 1; continue;
} if (arg === "--password-file" || arg === "--gateway-password-file") {
passwordFile = args[i + 1];
i += 1; continue;
} if (arg === "--session") {
opts.defaultSessionKey = args[i + 1];
i += 1; continue;
} if (arg === "--session-label") {
opts.defaultSessionLabel = args[i + 1];
i += 1; continue;
} if (arg === "--require-existing") {
opts.requireExistingSession = true; continue;
} if (arg === "--reset-session") {
opts.resetSession = true; continue;
} if (arg === "--no-prefix-cwd") {
opts.prefixCwd = false; continue;
} if (arg === "--provenance") { const provenanceMode = normalizeAcpProvenanceMode(args[i + 1]); if (!provenanceMode) { thrownew Error("Invalid --provenance value. Use off, meta, or meta+receipt.");
}
opts.provenanceMode = provenanceMode;
i += 1; continue;
} if (arg === "--verbose" || arg === "-v") {
opts.verbose = true; continue;
} if (arg === "--help" || arg === "-h") {
printHelp();
process.exit(0);
}
} const gatewayToken = normalizeOptionalString(opts.gatewayToken); const gatewayPassword = normalizeOptionalString(opts.gatewayPassword); const normalizedTokenFile = normalizeOptionalString(tokenFile); const normalizedPasswordFile = normalizeOptionalString(passwordFile); if (gatewayToken && normalizedTokenFile) { thrownew Error("Use either --token or --token-file.");
} if (gatewayPassword && normalizedPasswordFile) { thrownew Error("Use either --password or --password-file.");
} if (normalizedTokenFile) {
opts.gatewayToken = readSecretFromFile(normalizedTokenFile, "Gateway token");
} if (normalizedPasswordFile) {
opts.gatewayPassword = readSecretFromFile(normalizedPasswordFile, "Gateway password");
} return opts;
}
function printHelp(): void {
console.log(`Usage: openclaw acp [options]
Gateway-backed ACP server for IDE integration.
Options:
--url <url> Gateway WebSocket URL
--token <token> Gateway auth token
--token-file <path> Read gateway auth token from file
--password <password> Gateway auth password
--password-file <path> Read gateway auth password from file
--session <key> Default session key (e.g. "agent:main:main")
--session-label <label> Default session label to resolve
--require-existing Fail if the session key/label does not exist
--reset-session Reset the session key before first use
--no-prefix-cwd Do not prefix prompts with the working directory
--provenance <mode> ACP provenance mode: off, meta, or meta+receipt
--verbose, -v Verbose logging to stderr
--help, -h Show this help message
`);
}
if (isMainModule({ currentFile: fileURLToPath(import.meta.url) })) { const argv = process.argv.slice(2); if (argv.includes("--token") || argv.includes("--gateway-token")) {
console.error( "Warning: --token can be exposed via process listings. Prefer --token-file or OPENCLAW_GATEWAY_TOKEN.",
);
} if (argv.includes("--password") || argv.includes("--gateway-password")) {
console.error( "Warning: --password can be exposed via process listings. Prefer --password-file or OPENCLAW_GATEWAY_PASSWORD.",
);
} const opts = parseArgs(argv);
serveAcpGateway(opts).catch((err) => {
console.error(String(err));
process.exit(1);
});
}
Messung V0.5 in Prozent
¤ Dauer der Verarbeitung: 0.48 Sekunden
(vorverarbeitet am 2026-06-06)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.