Files
loki/scripts/solon/cast-vote.ts
CatoandClaude Fable 5.1 95c40a9cd8 refactor: rename the product from FleetCrown to Loki (#695)
The product, its assistant, the repo, the host and every unit on the box now
share one name. 638 files, ~3,000 mentions: UI copy, config, env keys
(FLEETCROWN_* -> LOKI_*), systemd units (fleetcrown-* -> loki-*), docs,
articles, the deploy workflow other repos reuse, and nine file names.

- Three article slugs carried the old name and had been shared; permanent
  redirects keep those links alive (next.config.ts).
- test-no-retired-name.sh now also forbids the old product name across the
  whole repo, so the rename cannot creep back through templates and examples.
- ASSISTANT_STACK collapses the product and the assistant into one entry,
  because they are now the same name.

Infra was cut over ahead of this merge: /opt/loki, loki-* units, the `loki`
database and role, loki.orangecat.ch (old host 308s to it; /api, /widget,
/embed keep proxying), GitHub repos bitbaum/loki and bitbaum/loki-releases.
The Resend sending domain stays fleetcrown.orangecat.ch until the new domain
is verified in DNS.


Claude-Session: https://claude.ai/code/session_016YJVAanfj8keVSXyZnTemh

Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-13 16:13:10 -07:00

59 lines
2.0 KiB
TypeScript

/**
* Cast Loki's Bitcoin-signed vote on a Solon session — from this box, with
* this system's own key. A vote cast here is Loki's attested judgment;
* the private key never leaves the environment.
*
* v1 casts are operator-run. A future autonomous path stays behind the
* approval queue (no auto-approve, ever) and reuses this as its `executed`
* step — nothing here is throwaway.
*
* Usage (on the box, where LOKI_SOLON_PRIVKEY is set):
* npx tsx scripts/solon/cast-vote.ts --session <sessionId> --choice yes|no|abstain
*/
import { parseArgs } from "node:util";
import {
addressFromPrivateKey,
signBitcoinMessage,
solonVoteMessage,
} from "../../src/lib/integrations/solon-message";
const { values } = parseArgs({
options: {
session: { type: "string" },
choice: { type: "string" },
},
});
async function main() {
const { session, choice } = values;
if (!session || !choice || !["yes", "no", "abstain"].includes(choice)) {
console.error("required: --session <sessionId> --choice yes|no|abstain");
process.exit(1);
}
const privateKey = process.env.LOKI_SOLON_PRIVKEY;
if (!privateKey) {
console.error("LOKI_SOLON_PRIVKEY is not set — Loki votes only from its own environment");
process.exit(1);
}
const address = addressFromPrivateKey(privateKey);
const message = solonVoteMessage({ sessionId: session, choice, memberAddress: address });
const signature = signBitcoinMessage(message, privateKey);
const base = process.env.SOLON_BASE_URL || "https://solon.orangecat.ch";
console.log(`voting as ${address} (Loki) on session ${session}: ${choice}`);
const res = await fetch(`${base}/api/sessions/${encodeURIComponent(session)}/votes`, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({ choice, address, signature }),
});
const verdict = await res.json();
console.log(JSON.stringify(verdict, null, 2));
if (!verdict.stored) process.exit(1);
}
main().catch((e) => {
console.error(e);
process.exit(1);
});