Files
loki/scripts/mint-box-runner-token.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

47 lines
1.7 KiB
TypeScript

/**
* Provision a runner token for the headless box-runner and write it directly to
* the token file — the box-runner equivalent of the desktop "install runner"
* flow. Mints a fresh ck_ token (never an existing user secret), so it can be
* revoked independently from Settings.
*
* Usage (run on the box, from /opt/loki/runner, with DATABASE_URL set):
* tsx scripts/mint-box-runner-token.ts [outPath]
* Default outPath = ~/.config/loki/fleet-runner-token (token-store's path).
*
* Prints the owner userId + token PREFIX only (never the full token).
*/
import fs from "fs";
import path from "path";
import os from "os";
import { createAgentToken } from "@/db/queries/agent-tokens";
import { getSelfImprovementTarget } from "@/db/queries/frontier";
import { getUserById } from "@/db/queries/users";
async function main(): Promise<void> {
const target = await getSelfImprovementTarget();
if (!target) {
console.error("[mint] no owner found (no 'loki' entity). Aborting.");
process.exit(1);
}
const user = await getUserById(target.userId).catch(() => null);
const outPath =
process.argv[2] || path.join(os.homedir(), ".config", "loki", "fleet-runner-token");
const { token } = await createAgentToken(target.userId, "box-runner");
fs.mkdirSync(path.dirname(outPath), { recursive: true });
fs.writeFileSync(outPath, token, { mode: 0o600 });
fs.chmodSync(outPath, 0o600);
console.log(
`[mint] wrote box-runner token ${token.slice(0, 9)}… for user ${target.userId}` +
`${user?.email ? ` (${user.email})` : ""} → ${outPath}`,
);
process.exit(0);
}
main().catch((e) => {
console.error("[mint] failed:", e);
process.exit(1);
});