mirror of
https://github.com/bitbaum/loki.git
synced 2026-12-04 08:18:10 +01:00
* feat(control): one task, several projects — write a cross-repo task once
A change that spans repositories ("make it so I can post prompts in
OrangeCat and Loki") had to be pasted into each project separately, and
each agent then tried to build the whole thing in its own repo.
- lib/multi-project-dispatch.ts fans one task out through injectPrompt
(same routing, serialisation, tracking as /api/inject). Names resolve
before anything is sent; an unknown name refuses the whole task and
lists the projects that would have worked.
- lib/multi-dispatch-prompt.ts: with 2+ projects each agent is told who
else got the task, which part is theirs, and to write down any
cross-repo contract it assumed.
- POST /api/inject/multi (session / agent token).
- POST /api/orangecat/task: signed OrangeCat rail, runs as the Loki user
linked to the actor, 409 with the next step when unlinked.
- Control: select projects on the rail -> "Send a task" opens the shared
Composer; a partial send keeps the draft and retries only the refused.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cwwmrb1uCjRv7wKDWLiA21
* fix(loki): the operator's OpenClaw agent and personal session are the operator's alone
Loki is multi-user with open sign-up, but three paths let any signed-in
account reach the instance operator's private agent:
- ask_openclaw (a `read` tool every user's tool loop advertised) queried
the operator's OpenClaw agent, which remembers their Telegram and
WhatsApp threads.
- The gateway fallback ran for every user whose tool loop failed, with
the operator's gateway token at operator.write scope.
- LOKI_PERSONAL_SESSION_KEY put every user's "Ask Loki" into the
operator's personal session.
Now: tools can be marked operatorOnly and runLokiTurn drops them unless
operator === true (fail closed); askLoki resolves "operator" from the
account (users.is_default) — never from a caller option — and only then
may fall back to the gateway; the personal session key applies to the
operator's account only. Everyone else keeps the shared chain and their
own per-user thread.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cwwmrb1uCjRv7wKDWLiA21
* feat(loki): a texting-app chat on phones
On a phone the chat got about a fifth of the screen: the app top bar, a
second row of two icons, a "save this exchange" row, a row of starter
chips, a four-row composer and the bottom tabs. Now:
- An open conversation takes the whole phone (useImmersiveChat hides
the app top bar and bottom tabs below md). Its own ThreadHeader is one
line: back to chats, the title with the project scope under it, and a
menu (New chat, All chats, Projects).
- Your messages are neutral bubbles, answers are plain 16px text, and
copy/retry are icon-only 44px targets on phones.
- The composer is one rounded card: words first, then one row —
attach · model · project on the left, mic beside send on the right.
The project pill sits inline (tap to change, × to drop) instead of a
header row, the builder badge is a coloured dot on phones, and starter
chips stay off phones mid-conversation. chatkit's stylesheet is
unlayered, so these overrides are unlayered too (a rule inside @layer
components silently loses to it).
- "Save this exchange to a project" scrolls with the thread instead of
holding a fixed row.
- The start screen is a messages inbox — round initials, title + time,
project under it, eight deep. It used to hide recent chats on every
phone because the desktop rail's pin (on by default) was treated as
"the rail is visible", so Back from a thread landed on nothing.
- On the start screen the chat's own two icons render inside the app
top bar's empty left half (TopbarSlot) instead of a second header.
Checked at 320/390 in light and dark: no horizontal overflow, send
never pushed off (model and project pills give up width first).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cwwmrb1uCjRv7wKDWLiA21
* feat(terminal): Claude Code as a conversation on your phone; a model sheet that reads like one
/terminal showed a Claude session only as its PTY — answers as 80-column
TUI cells, unreadable on a phone. Claude Code already writes the same
conversation as structured data, so now it is shown as one.
- lib/claude-transcript.ts (pure, tested): Claude Code's session JSONL
→ user / assistant / tool items. A tool's result lands on a later line
and updates its row in place; harness noise, sidechains and meta lines
are dropped; results are previews, never whole files. Consecutive tool
calls fold into one line ("Ran 2 commands, edited a file"), and a live
one says what is happening now ("Running git push").
- Runner (desktop 0.8.37): transcript-streamer.ts follows the newest log
for the folder the agent was launched in, reading only appended bytes
with fs/promises on a 1s timer, and only while someone watches — it
rides peek_start/peek_stop.
- Server: POST /api/control/transcript-frame (runner token) and
GET /api/control/transcript-stream (session). The server keeps the
latest conversation per (user, tab), so a phone that slept repaints at
once.
- ClaudeChatView: bubbles, readable answers, folded tool runs you can
open, an animated status line while Claude works, Allow / Always / Deny
when Claude may be asking, and a composer that types into the same PTY
(bracketed paste, so newlines do not send early). Stop is Esc; once you
type mid-run the slot becomes Send and Claude Code queues it. Chat is
the default view; the raw terminal is one tap away (header icon on
phones, "Chat" in the desktop pane chrome) and agents that write no
Claude log always get the terminal.
- Model picker: a bottom sheet on phones — plain names, one line on what
each is for, a check, locked rows saying why in words.
- Fix: the chat model you picked never reached the chat turn (askLoki had
no model; runLokiTurn always started at LOKI_MODEL). It now sets where
the free chain starts. And it is no longer handed to dispatched project
agents, which were being launched with a Groq/OpenRouter model id.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Cwwmrb1uCjRv7wKDWLiA21
---------
Co-authored-by: Claude <noreply@anthropic.com>
41 lines
1.7 KiB
TypeScript
41 lines
1.7 KiB
TypeScript
// One task, several projects — the pure half (src/lib/multi-dispatch-prompt.ts).
|
|
// Run: npx tsx scripts/test/multi-dispatch-prompt.ts
|
|
import { buildProjectTaskPrompt, normalizeTaskProjects } from "@/lib/multi-dispatch-prompt";
|
|
|
|
let pass = 0;
|
|
let fail = 0;
|
|
function ok(cond: boolean, label: string) {
|
|
if (cond) pass++;
|
|
else {
|
|
fail++;
|
|
console.error(`✗ ${label}`);
|
|
}
|
|
}
|
|
|
|
// normalize: trims, drops blanks, dedupes case-insensitively, keeps first spelling
|
|
const norm = normalizeTaskProjects([" OrangeCat ", "loki", "", "Loki", "orangecat", "solon"]);
|
|
ok(JSON.stringify(norm) === JSON.stringify(["OrangeCat", "loki", "solon"]), "normalize dedupes");
|
|
|
|
// one project → the task verbatim, no coordination preamble
|
|
ok(
|
|
buildProjectTaskPrompt(" Fix the header ", "Loki", ["Loki"]) === "Fix the header",
|
|
"single project verbatim",
|
|
);
|
|
|
|
// several → names everyone, names THIS project, and lists only the others as siblings
|
|
const p = buildProjectTaskPrompt("Post prompts from both apps", "Loki", ["OrangeCat", "Loki"]);
|
|
ok(p.includes("sent to 2 projects at once: OrangeCat, Loki"), "preamble lists all projects");
|
|
ok(p.includes("You are working in Loki."), "preamble names this project");
|
|
ok(p.includes("OrangeCat is handling its own part"), "siblings exclude this project (singular)");
|
|
ok(p.endsWith("Post prompts from both apps"), "task follows the preamble verbatim");
|
|
ok(p.includes("state the contract you assumed"), "asks for cross-repo contracts");
|
|
|
|
const three = buildProjectTaskPrompt("x", "solon", ["OrangeCat", "Loki", "Solon"]);
|
|
ok(
|
|
three.includes("OrangeCat, Loki are handling their own part"),
|
|
"siblings plural, case-insensitive self match",
|
|
);
|
|
|
|
console.log(`${pass}/${pass + fail} multi-dispatch-prompt cases passed`);
|
|
if (fail > 0) process.exit(1);
|