Files
loki/scripts/test/bare-confirmation.ts
CatoandClaude Opus 5.5 e47011e270 Security: the server's files belong to its owner; Loki answers general questions and recaps chats (#1260)
* fix(loki): answer general questions, plain words for who can build, one reminder at a time

- General questions get general answers. "What year was the Eiffel Tower
  built?" answered "Not in your data." live: the closed-world check flagged
  every name and year, and the repair pass deleted them. When the question
  names no surface of the person's records, only the sentences about their
  records are checked (cited, or naming a person/project/goal they have).
  Contract rule 11 says the same to the model.
- A bold "<project>: …" line that only the person can carry out (install the
  desktop app, sign in, add a key, approve, pay) is no longer offered to a
  "yes", and is rewritten as a plain sentence.
- The fleet facts and brief say "can new work start right now" in plain words
  (Loki's own computers / the desktop app) instead of runner/builder, and the
  two no longer disagree. Field names stop leaking ("the query returned none").
- One account reminder at a time: the OrangeCat link line first, then the
  verify-email line, each one row on a phone.
- Onboarding: no CLI/tenant wording; the folder field is asked only of someone
  whose code is already on this computer.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CG9dupSVqoXCCqKfBCfd9B

* fix(security): the server's files and telemetry are the operator's, not every account's

- /api/people/sync/openclaw read the OpenClaw contact book from the server's
  home directory — the site operator's WhatsApp/Telegram contacts — and
  wrote it into the CALLER's book. Any signed-in account with its private
  zone open (a new one has no PIN) could copy it. Now operator-only, and the
  People page no longer explains OpenClaw and Hermes to people who have
  neither.
- /system showed every account the box's RAM, disk, uptime, Hetzner capacity
  and "Recent telemetry" from debug_logs, which has no user column: every
  account's errors, sign-in failures and cron counts. Those cards and
  /api/system, /api/system/hetzner are now the operator's; a tenant keeps
  their own alarms, jobs and records.
- Suggestions: OrangeCat gift wishlists ("My Birthday Wishlist") are no
  longer offered as things to build, and each starter says what it is
  instead of one sentence repeated four times.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CG9dupSVqoXCCqKfBCfd9B

* fix(loki): name threads from the server; phone-sized targets and clamps

- A thread is named the moment its first answer is saved, server-side. The
  browser was the only caller, 3s after the answer, so a person who locked
  their phone or closed the tab left the thread named by its opening line.
  The browser's ask now also takes a title the server already set.
- /suggestions: the "Quiet today" links were 18px tall; now 44px targets.
- /packages: descriptions declared two lines and rendered four (a `block`
  utility beat line-clamp).
- /loki start screen: an untitled thread shows two lines of the question
  instead of one cut mid-word.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CG9dupSVqoXCCqKfBCfd9B

* fix(security): free-text folder paths and server files are the machine owner's

An audit of every route that touches the server's own filesystem or
processes, for an ordinary signed-in account on the hosted server:

- DELETE /api/projects/[id]?deleteLocal=1 removed any folder under the dev
  root that the account's free-text dirPath named — the operator's checkout,
  another tenant's preview. Now only an account allowed on the fleet machine.
- GET /api/projects/[id] returned the operator's OpenClaw cron jobs matched by
  a substring of the project name. Operator only.
- POST /api/control/agent rewrote the server's global agent preferences and
  Claude settings. Now the machine owner's: own desktop app, or the operator.
- GET /api/sessions read any project's handoff by name. Now only a project the
  account owns, where the server's files can be its own.
- merge-prompts fell back to the operator's OpenClaw agent with user text
  through a shell. Machine owner only, argv not shell, input bounded.
- /api/control ran git and a /proc scan on account-chosen folders. Machine
  owner only.
- Previews (public <slug>.orangecat.ch sites with the fleet's deploy key) are
  fleet infrastructure; preview owner lookup no longer lets a copied dirPath
  decide whose access code opens a preview.
- The feedback page picture no longer opens private-network addresses on the
  server (checked on every request the page makes).
- New cron jobs are addressed to the operator's Telegram only for the operator.

Also: "what did I ask you today?" never worked live — the thread source threw
on a timestamp the driver returned as a string, and returned nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CG9dupSVqoXCCqKfBCfd9B

* fix(models): the model table no longer pushes a tablet page sideways

At 768px the table needed ~910px and overflowed the page by 164px
(responsive audit against production, 2026-10-17). Rows stay cards up to the
laptop breakpoint, and the table scrolls inside its own box as a backstop.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CG9dupSVqoXCCqKfBCfd9B

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-10-17 17:51:39 +02:00

126 lines
3.7 KiB
TypeScript

/**
* "Yes, do it" — never work for whichever project is selected; it runs the
* line the previous answer offered, or stays a reply. Case from the live site
* (2026-10-15): "Yes, create it" (create projects for a podcast) was sent to
* the bakery as a build task.
*/
import {
demotePersonOnlyOffer,
isBareConfirmation,
isPersonOnlyStep,
offeredCommand,
} from "@/lib/loki/confirmation";
import { looksLikeDispatchTask, resolveCommand } from "@/lib/command-resolve";
let passed = 0;
function check(label: string, cond: boolean): void {
if (!cond) throw new Error(`✗ ${label}`);
passed++;
console.log(` ✓ ${label}`);
}
for (const t of [
"Yes, create it",
"yes please",
"Ok do it",
"go ahead",
"Sure, build that",
"Sounds good!",
"yep, send it",
"Yes, let's do it",
]) {
check(`"${t}" is a bare yes`, isBareConfirmation(t));
check(`"${t}" is not dispatched by itself`, !looksLikeDispatchTask(t));
}
for (const t of [
"build it",
"Yes, add a pricing page",
"create project night-shift",
"ok but make the header blue",
"yes",
"Fix the checkout bug on bakery",
]) {
if (t === "yes") {
check(`"yes" alone is a bare yes`, isBareConfirmation(t));
continue;
}
check(`"${t}" carries its own task`, !isBareConfirmation(t));
}
check(
"an answer ending in one create line offers it",
offeredCommand(
"You have one project.\n\nTo track the podcast:\n\n**create project night-shift**",
) === "create project night-shift",
);
check(
"an instruction line for a project is offered",
offeredCommand("Do this next.\n**bakery: add a menu page and ship**") ===
"bakery: add a menu page and ship",
);
check(
"two offered lines are a choice, not an offer",
offeredCommand("**create project a**\n**create project b**") === null,
);
check(
"bold inside a sentence is emphasis",
offeredCommand("This is **really** important.") === null,
);
check(
"a bold line that is not a command is not offered",
offeredCommand("Plan:\n**Not in your data.**") === null,
);
check("no answer, no offer", offeredCommand(undefined) === null);
// Live, 2026-10-17: a person-only step in command shape.
const installOffer =
"Nothing can build until a computer is connected.\n**prodtest-bakery: install the Fleet Runner desktop app and connect it**";
check(
"a step only the person can take is not offered to a yes",
offeredCommand(installOffer) === null,
);
for (const line of [
"bakery: sign in to GitHub and approve the request",
"bakery: approve the calendar draft",
"bakery: add your API key in Settings",
"bakery: verify your email",
"bakery: decide whether to keep the old menu",
"bakery: restart the Fleet Runner",
]) {
check(`"${line}" is the person's step`, isPersonOnlyStep(line));
}
for (const line of [
"bakery: add a sign-in page with email login",
"bakery: fix the 3 open reports and ship",
"bakery: install the analytics package and add a cookie banner",
"create project night-shift",
"bakery: add a pay button and a subscribe form",
]) {
check(`"${line}" is agent work`, !isPersonOnlyStep(line));
}
check(
"the person-only line is rewritten as a plain sentence",
demotePersonOnlyOffer(installOffer).endsWith(
"\nInstall the Fleet Runner desktop app and connect it.",
),
);
check(
"an agent offer is left exactly as written",
demotePersonOnlyOffer("Do this.\n**bakery: add a menu page**") ===
"Do this.\n**bakery: add a menu page**",
);
async function main() {
const r = await resolveCommand({
text: "Yes, create it",
projects: ["prodtest-bakery"],
selectedProject: "prodtest-bakery",
});
check(
"with one project selected, a bare yes resolves as chat",
r.kind === "chat" && r.projectKey === null,
);
console.log(`\nbare-confirmation: ${passed} passed`);
}
void main();