mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 00:37:00 +01:00
A step behind the operator's own login ended in Loki listing fields to type. On 2026-10-11 npm's trusted-publisher form took three rounds of chat and a phone screenshot, and still hid two traps: an autofilled "Bitbaum" that cannot be edited once saved, and "Allow npm publish" off by default. Now Fleet Runner opens the page in Loki's own browser window (persist:loki-browser, so a sign-in sticks), fills it, outlines the final button and stops. The operator presses it and confirms any passkey. - config/browser-tasks.ts: recipes are the SSOT and the only thing a queued row can name — no raw url or free-form steps reach the runner. First recipe: npm-trusted-publisher. - lib/browser-fill.ts: one self-contained filler, found by visible label, React-safe value setter, idempotent, never presses the hand-off button. - browser_task pending command, channel "local"; validated on both sides. - Loki chat tool fill_web_form and MCP tool loki_browser_task (loki.act). - Fleet Runner 0.8.41. Tests: scripts/test/browser-fill.ts drives a React form built like npm's in Chromium, against a runner-style bundle and the actual Fleet Runner build (35/35; mutation-checked: a plain .value set fails 3). mcp-server 75/75, desktop-command-validator 17/17. Claude-Session: https://claude.ai/code/session_01BWXjqiHm8jFta4FXuc7Tck Co-authored-by: Claude <noreply@anthropic.com>
102 lines
3.2 KiB
TypeScript
102 lines
3.2 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import { validateCommand } from "../../desktop/src/main/command-validator";
|
|
|
|
const validCases = [
|
|
{ type: "inject", payload: { tab: "truthseeker", prompt: "summarize this repo" } },
|
|
{ type: "close_tab", payload: { tab: "truthseeker" } },
|
|
{
|
|
type: "launch_agent",
|
|
payload: {
|
|
tab: "truthseeker",
|
|
dir: "/home/g/dev/truthseeker",
|
|
agent: "claude",
|
|
model: "sonnet",
|
|
},
|
|
},
|
|
{
|
|
type: "switch_agent",
|
|
payload: {
|
|
tab: "truthseeker",
|
|
dir: "/home/g/dev/truthseeker",
|
|
toAgent: "codex",
|
|
fromAgent: "claude",
|
|
},
|
|
},
|
|
{ type: "auto_continue", payload: { tab: "truthseeker", enabled: true } },
|
|
{ type: "install_cli", payload: { agent: "gemini" } },
|
|
{ type: "peek_tab", payload: { tab: "truthseeker" } },
|
|
] as const;
|
|
|
|
for (const command of validCases) {
|
|
const result = validateCommand(command);
|
|
assert.equal(result.ok, true, `${command.type} should validate`);
|
|
if (result.ok) assert.equal(result.command.type, command.type);
|
|
}
|
|
|
|
const invalidCases = [
|
|
{ command: { type: "inject", payload: { tab: "truthseeker" } }, error: "prompt" },
|
|
{
|
|
command: { type: "launch_agent", payload: { tab: "truthseeker", agent: "claude" } },
|
|
error: "dir",
|
|
},
|
|
{
|
|
command: { type: "switch_agent", payload: { tab: "truthseeker", dir: "/tmp" } },
|
|
error: "toAgent",
|
|
},
|
|
{
|
|
command: { type: "auto_continue", payload: { tab: "truthseeker", enabled: "true" } },
|
|
error: "enabled",
|
|
},
|
|
{ command: { type: "install_cli", payload: {} }, error: "agent" },
|
|
{ command: { type: "peek_tab", payload: {} }, error: "tab" },
|
|
{ command: { type: "transcribe", payload: {} }, error: "does not handle" },
|
|
{ command: { type: "repair_helper", payload: {} }, error: "does not handle" },
|
|
// A row can only name a recipe — never a raw url or free-form steps.
|
|
{
|
|
command: { type: "browser_task", payload: { url: "https://evil.example" } },
|
|
error: "unknown recipe",
|
|
},
|
|
{
|
|
command: {
|
|
type: "browser_task",
|
|
payload: {
|
|
recipe: "npm-trusted-publisher",
|
|
params: { package: "x", owner: "a b", repo: "r", workflow: "p.yml" },
|
|
},
|
|
},
|
|
error: "invalid params",
|
|
},
|
|
] as const;
|
|
|
|
const browser = validateCommand({
|
|
type: "browser_task",
|
|
payload: {
|
|
recipe: "npm-trusted-publisher",
|
|
params: {
|
|
package: "@bitbaum/chatkit",
|
|
owner: "bitbaum",
|
|
repo: "chatkit",
|
|
workflow: "publish.yml",
|
|
},
|
|
channel: "local",
|
|
},
|
|
});
|
|
assert.equal(browser.ok, true, "browser_task with a known recipe validates");
|
|
if (browser.ok && browser.command.type === "browser_task") {
|
|
assert.equal(
|
|
browser.command.payload.task.url,
|
|
"https://www.npmjs.com/package/@bitbaum/chatkit/access",
|
|
);
|
|
assert.equal(browser.command.payload.task.handoff.button, "Set up connection");
|
|
}
|
|
|
|
for (const { command, error } of invalidCases) {
|
|
const result = validateCommand(command);
|
|
assert.equal(result.ok, false, `${command.type} should fail validation`);
|
|
if (!result.ok) assert.match(result.error, new RegExp(error));
|
|
}
|
|
|
|
console.log(
|
|
`${validCases.length + invalidCases.length}/${validCases.length + invalidCases.length} desktop command validator cases passed`,
|
|
);
|