Files
loki/scripts/new-site-dispatch.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

65 lines
2.6 KiB
TypeScript

#!/usr/bin/env -S npx tsx
/**
* new-site-dispatch — ask the fleet to CREATE a site, rather than creating it
* yourself.
*
* Until now the fleet could analyze a repo (hosted_analyze) and change one
* (hosted_dispatch → Hermes → PR), but it could not bring one into existence.
* So every site so far was made by a person running new-site.sh in a terminal —
* causius on 2026-09-10 included. That is the one step of the factory that
* still required a human to start it, and this is the command that closes it.
*
* What it is NOT: a prompt. The older control path injects free text into a live
* terminal for an agent to obey, which is the shape that gets prompt-injected.
* This queues four validated fields that reach an audited script as an argument
* vector — nothing here can become shell syntax or an instruction.
*
* The runner that drains it must be armed (LOKI_SITE_FACTORY=1) and told
* where the script lives (LOKI_NEW_SITE_SCRIPT). A runner without both
* reports the refusal on the command instead of doing anything.
*
* Usage:
* DATABASE_URL=… npx tsx scripts/new-site-dispatch.ts <slug> "<Title>" [kind] [status]
* Example:
* … scripts/new-site-dispatch.ts causius "Causius" product validating
*/
import { getSelfImprovementTarget } from "@/db/queries/frontier";
import { requestNewSite } from "@/lib/hosted-runner/provision";
async function main() {
const [slug, title, kind = "product", status = "validating"] = process.argv.slice(2);
if (!slug) {
console.error('Usage: npx tsx scripts/new-site-dispatch.ts <slug> "<Title>" [kind] [status]');
process.exit(1);
}
const target = await getSelfImprovementTarget();
if (!target) {
console.error("No Loki owner resolved — nothing to dispatch for.");
process.exit(1);
}
const res = await requestNewSite(target.userId, { slug, title, kind, status });
if (!res.ok) {
console.error(`✗ ${res.error}`);
process.exit(1);
}
console.log(`✓ queued site creation ${res.commandId}`);
console.log(` slug: ${res.request.slug} title: ${res.request.title}`);
console.log(` kind: ${res.request.kind}/${res.request.status}`);
console.log(` host: https://${res.host} (once the runner has built it)`);
console.log(
` Drained by the hosted runner — repo → register → box → deploy. Minutes, not seconds.`,
);
console.log(
` Watch: journalctl -u loki-hosted-runner -f | Activity (source=hosted-runner)`,
);
process.exit(0);
}
main().catch((err) => {
console.error(err instanceof Error ? err.message : String(err));
process.exit(1);
});