// Operator convenience (Guild C-2): print the commands-sync key that this // guild process actually has in its environment, so it can be copied into // the OpenClaw plugin's FABRIC_COMMANDS_SYNC_KEY. // // Usage (inside the deployed container — authoritative, reflects compose): // docker exec fabric-backend-guild node dist/cli/print-commands-sync-key.js // docker exec fabric-backend-guild node dist/cli/print-commands-sync-key.js --export // // Default: prints the raw value only (so KEY=$(... ) works). // --export: prints `FABRIC_COMMANDS_SYNC_KEY=` for pasting. // Exit 1 (no stdout) when unset — guild is then in the weaker // "any authenticated user" fallback for PUT /commands. const args = new Set(process.argv.slice(2)); if (args.has('--help') || args.has('-h')) { process.stderr.write( 'print-commands-sync-key: outputs FABRIC_BACKEND_GUILD_COMMANDS_SYNC_KEY\n' + ' (no flag) print the raw key value\n' + ' --export print FABRIC_COMMANDS_SYNC_KEY=\n', ); process.exit(0); } const key = (process.env.FABRIC_BACKEND_GUILD_COMMANDS_SYNC_KEY ?? '').trim(); if (!key) { process.stderr.write( 'FABRIC_BACKEND_GUILD_COMMANDS_SYNC_KEY is not set — PUT /commands is in ' + 'the fallback mode (any authenticated user). Set it to harden (Guild C-2).\n', ); process.exit(1); } process.stdout.write( (args.has('--export') ? `FABRIC_COMMANDS_SYNC_KEY=${key}` : key) + '\n', );