Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## Unreleased

- The web sidebar shows pinned bots as portraits, like the Apple clients, and every bot's avatar shows its status even when its chat isn't open: thinking, working, or an exclamation mark when it needs you or its last reply failed. A retrying bot now shows as working. **Memory** and **Theme** moved to **Settings**, **Activity** and **Settings** are icons at the top, and search is `⌘K` (an icon on phones). `GET /v1/agents` returns `status` for each bot, and `/v1/events` sends `bot-status` events.
- Bots can mark a reply as a question with the `mark_question` tool. The bot has the status `question` until you answer.
- Remove repository-owned source comments, preserve consequential decisions in ADRs, and enforce a zero-comment baseline across source and configuration. Add the repository-local `/delete-comment` skill. Move migration separators into metadata without changing historical hashes or execution groups, and replace inline lint/type directives with configuration.

- Replace custom lint rules and vendored plugins with `@cloudflare/oxlint-config`.
Expand Down
8 changes: 8 additions & 0 deletions GLOSSARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ _Avoid_: Bot creation request
The continuous direct-message exchange between a bot and its owner, including work the bot performs in the background.
_Avoid_: Conversation session, new chat

**Chat question**:
A bot's reply that it marked as a question it needs the owner to answer before it can go on. It stays open until the owner's next message in the bot chat.
_Avoid_: Job question, prompt, notification

**Bot status**:
What a bot is doing (idle, thinking, or working) or that its latest turn failed, unless it needs the owner: it has a question (a job question or a chat question), or it is blocked by a request or held action that waits for the owner's decision. A retry is working, not blocked.
_Avoid_: Presence, online status

**Bot chat delivery**:
The progress of an owner's message from sending to confirmation in the bot chat's transcript, including failed sends and retries.
_Avoid_: Message execution, completed bot work
Expand Down
46 changes: 32 additions & 14 deletions apps/docs/content/clients/web.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,38 @@ Sign in with the account you created when you

## Sidebar

| Section | What's there |
| --------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| **Pinned** | Up to nine bot chats. Pin or unpin one from its **More** menu, and drag pins to reorder them. Your other apps show the same pins. |
| **Bots** | Each bot's chat, with its jobs and desktop. |
| **Memory** | Every bot's memories and your shared memories. Edit or delete them here. |
| **Automations** | Every automation with its schedule, next run, and status, plus a **Runs** tab with recent runs. |
| **Activity** | Everything bots did, by day. Filter by kind or bot, and revert a change to a skill or memory. |
| **Theme** | System, Light, or Dark. The choice is saved to your account, so your other devices use it too. |
| **Settings** | Providers, web search, credentials, logins, the judge and vision models, MCP integrations, skills, notifications, passkeys, and sign-out. |

Press `⌘K`, or `Ctrl+K`, or select **Search** in the sidebar to open the
command palette. It jumps to a bot, workspace page, or settings
section, creates a bot, and switches the theme. To search inside
conversations, ask a bot. It
| Part | What's there |
| --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Header** | The **Activity** and **Settings** icons. On a phone, a **Search** icon too. |
| **Pinned bots** | Up to nine bots as round portraits, three per row, above the list so they stay in view while you scroll. Right-click a portrait, or press and hold it, then select **Unpin**. Drag one onto another to reorder. Your other apps show the same pins. |
| **Automations** | Every automation with its schedule, next run, and status, plus a **Runs** tab with recent runs. |
| **Bots** | Each unpinned bot's chat, with its jobs and desktop. Select **+** to create a bot, or **More** > **Pin** on a bot to pin it. |

**Activity** lists everything bots did, by day. Filter by kind or bot, and
revert a change to a skill or memory.

Each bot's avatar shows what it's doing, and a dot marks a bot with replies you
haven't seen. The sidebar updates as bots work, whether or not their chats are
open. Point at a bot, or use a screen reader, to read why its avatar looks
the way it does, such as "has a question", "needs your decision", or "last reply
failed".

When the web app loses its connection to the server, the sidebar shows
**Reconnecting…** or **Disconnected** below the header.

Memory, theme, and sign-out live in **Settings**:

- **Settings** > **General** > **Appearance** sets the theme to System, Light,
or Dark. The choice is saved to your account, so your other devices use it
too.
- **Settings** > **Memory** shows every bot's memories and your shared
memories. Edit or delete them there. The old `/memory` address redirects to
it.

On a computer, press `⌘K` or `Ctrl+K` to open the command palette. On a phone,
select **Search** in the sidebar header. The palette jumps to a bot, workspace
page, or settings section, creates a bot, and switches the theme. To search
inside conversations, ask a bot. It
[searches its transcripts](/concepts/chats#searching-the-transcript) for you.

## Request Cards
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/concepts/memory-and-skills.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ A memory is either the bot's own, or **shared** with every one of your bots
that has memory turned on. Every memory records where it came from: a bot
chat, you, a scheduled task, or another bot.

Review and edit memories on the **Memory** page.
Review and edit memories in **Settings** > **Memory**.

The bot's [jobs](/concepts/workspaces#jobs) see its memories too, but only
read them.
Expand Down
5 changes: 3 additions & 2 deletions apps/docs/content/getting-started/first-bot.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@ choice. Live avatars respect your system's reduced-motion setting.

An avatar shows what its bot is doing. While the bot thinks, its body turns
into three hopping dots. While it writes, searches, remembers, or uses tools, it
bends over the work. When it retries, it shows an exclamation mark. When a reply
finishes, it celebrates for a few seconds.
bends over the work, including while it retries. When it has a question for you,
needs your decision, or its last reply failed, it shows an exclamation mark.
When a reply finishes, it celebrates for a few seconds.

Bots without a saved definition get a fresh gallery avatar with default colors.
The bot ID selects the shape; previous avatar shapes and colors don't affect it.
Expand Down
8 changes: 7 additions & 1 deletion apps/server/src/app/core-layer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { PushDatabase } from "../push/push-database";
import { DesktopControl } from "../bot-desktop/desktop-control";
import { HeldActions } from "../bot-desktop/held-actions";
import { BotDeletion } from "../bot-ports/bot-deletion";
import { BotNeeds } from "../bot-ports/bot-needs";
import { BotNotices } from "../bot-ports/bot-notices";
import { CallNotes } from "../bot-ports/call-notes";
import { CredentialAuthorities } from "../credentials/credential-authority";
Expand Down Expand Up @@ -53,7 +54,12 @@ export const coreLayer = (dataDir: string) =>
Layer.mergeAll(BotSecretRequests.layer, BotSecretUses.layer),
),
Layer.provideMerge(
Layer.mergeAll(BotNotices.layer, BotDeletion.layer, CallNotes.layer),
Layer.mergeAll(
BotNotices.layer,
BotDeletion.layer,
CallNotes.layer,
BotNeeds.layer,
),
),
Layer.provideMerge(secretsLayer(passwordManagers)),
Layer.provideMerge(PushDatabase.layer(dataDir)),
Expand Down
35 changes: 35 additions & 0 deletions apps/server/src/app/job-wiring.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
import { Effect, Layer } from "effect";
import { BotExtensions, ExtensionPosition } from "../bot-ports/bot-extensions";
import { BotNeeds } from "../bot-ports/bot-needs";
import { AgentRepository } from "../bot-store/agent-repository";
import { ConversationRepository } from "../bot-store/conversation-repository";
import { Bots } from "../bots/bots";
import { BotRuntime } from "../bots/runtime";
import { BotMessaging } from "../bot-messaging/bot-messaging";
import { jobExtensions, pluginJobKinds, Plugins } from "../plugins/plugins";

Expand All @@ -24,6 +28,37 @@ export const jobTools = Layer.effectDiscard(
}),
);

export const jobNeeds = Layer.effectDiscard(
Effect.gen(function* () {
const needs = yield* BotNeeds;
const agents = yield* AgentRepository;
const conversations = yield* ConversationRepository;
const runtime = yield* BotRuntime;
const jobKinds = pluginJobKinds(yield* Plugins);

yield* needs.provide(
Effect.fnUntraced(function* (agentId) {
const agent = yield* agents.get(agentId);

if (!agent || !(yield* conversations.list(agentId, true)).length) {
return undefined;
}

return yield* Effect.promise(() => runtime.jobNeed(agent));
}),
);

yield* whileOpen(() =>
jobKinds.flatMap(
(kind) =>
kind.onChange?.(
(agentId) => void Effect.runPromise(needs.changed(agentId)),
) ?? [],
),
);
}),
);

export const jobAnswers = Layer.effectDiscard(
Effect.gen(function* () {
const bots = yield* Bots;
Expand Down
5 changes: 4 additions & 1 deletion apps/server/src/app/tenant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { BotMessaging } from "../bot-messaging/bot-messaging";
import { BotActivity } from "../bots/bot-activity";
import { reviewConversations } from "../learning/review-kind";
import { BotExtensions } from "../bot-ports/bot-extensions";
import { markQuestionTools } from "../bots/mark-question";
import { reactionTools } from "../bots/reaction";
import { codemodeTools } from "../integrations/codemode";
import { configuredWebSearchTools } from "../web-search/web-search-tools";
Expand Down Expand Up @@ -57,7 +58,7 @@ import type { CoreServices } from "./core-layer";
import { runnerOf } from "../shared/runner";
import { builtinPlugins, builtinVendors } from "./builtin-plugins";
import { heldActionNotices } from "../bot-desktop/held-action-notices";
import { jobAnswers, jobQuestions, jobTools } from "./job-wiring";
import { jobAnswers, jobNeeds, jobQuestions, jobTools } from "./job-wiring";
import {
conversationEnv,
jobExtensions,
Expand Down Expand Up @@ -294,6 +295,7 @@ function accountLayer(options: TenantOptions, dataDir: string) {
curation,
skillUpdateChecks,
jobAnswers,
jobNeeds,
jobQuestions,
heldActionNotices,
jobTools,
Expand Down Expand Up @@ -329,6 +331,7 @@ function accountLayer(options: TenantOptions, dataDir: string) {
displayTools,
configuredWebSearchTools,
reactionTools,
markQuestionTools,
);

const signIns = Layer.mergeAll(ProviderSignIns.layer, integrations);
Expand Down
1 change: 1 addition & 0 deletions apps/server/src/bot-desktop/desktop-jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export const desktopPlugin = (
env: (agentId, target, context) =>
desktop.env(workspaces, agentId, target, context),
onAnswer: desktop.onAnswer,
onChange: desktop.onChange,
},
]
: [],
Expand Down
30 changes: 28 additions & 2 deletions apps/server/src/bot-desktop/held-actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { and, desc, eq } from "drizzle-orm";
import { Context, Deferred, Effect, Layer } from "effect";
import { z } from "zod";
import type { OwnerMessage } from "../jobs/owner-request";
import { BotNeeds, needWhen } from "../bot-ports/bot-needs";
import { Conflict, NotFound } from "../shared/errors";
import { ProductDatabase } from "../shared/product-database";
import { HELD_ACTION_STATUSES, OWNER_MESSAGE_SOURCES } from "../shared/domain";
Expand Down Expand Up @@ -109,6 +110,7 @@ export class HeldActions extends Context.Service<
HeldActions,
Effect.gen(function* () {
const db = yield* ProductDatabase;
const needs = yield* BotNeeds;
const listeners = keyedListeners<HoldDecision>();

const heldListeners = new Set<
Expand All @@ -131,6 +133,25 @@ export class HeldActions extends Context.Service<
return found;
});

yield* needs.provide(
needWhen("blocked", (agentId) =>
db
.select({ id: heldActions.id })
.from(heldActions)
.where(
and(
eq(heldActions.agentId, agentId),
eq(heldActions.status, "pending"),
),
)
.limit(1)
.pipe(
Effect.orDie,
Effect.map((rows) => rows.length > 0),
),
),
);

const hold = Effect.fn("HeldActions.hold")(function* (input: HoldInput) {
const values = {
...input,
Expand All @@ -143,6 +164,7 @@ export class HeldActions extends Context.Service<
};

yield* db.insert(heldActions).values(values).pipe(Effect.orDie);
yield* needs.changed(input.agentId);

return heldOf(values);
});
Expand Down Expand Up @@ -186,6 +208,7 @@ export class HeldActions extends Context.Service<

if (decided) {
listeners.notify(id, decision);
yield* needs.changed(agentId);

return heldOf(decided);
}
Expand All @@ -204,11 +227,14 @@ export class HeldActions extends Context.Service<
.update(heldActions)
.set({ status: "expired", decidedAt: yield* nowIso })
.where(and(eq(heldActions.id, id), eq(heldActions.status, "pending")))
.returning({ id: heldActions.id })
.returning({ id: heldActions.id, agentId: heldActions.agentId })
.pipe(Effect.orDie);

if (changed.length) {
const [expired] = changed;

if (expired) {
listeners.notify(id, { status: "expired" });
yield* needs.changed(expired.agentId);
}
});

Expand Down
1 change: 1 addition & 0 deletions apps/server/src/bot-ports/bot-extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const ExtensionPosition = {
desktopScreenshot: 62,
webSearch: 65,
reaction: 70,
markQuestion: 72,
voice: 75,
callRequests: 76,
jobs: 80,
Expand Down
79 changes: 79 additions & 0 deletions apps/server/src/bot-ports/bot-needs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import { Context, Effect, Layer, Ref } from "effect";
import type { Scope } from "effect";

export type BotNeed = "blocked" | "question" | "working";

const STRENGTH: Record<BotNeed, number> = {
blocked: 3,
question: 2,
working: 1,
};

export type NeedSource = (
agentId: string,
) => Effect.Effect<BotNeed | undefined>;

export const strongest = (
needs: ReadonlyArray<BotNeed | undefined>,
): BotNeed | undefined =>
needs.reduce<BotNeed | undefined>(
(best, need) =>
need && (!best || STRENGTH[need] > STRENGTH[best]) ? need : best,
undefined,
);

export const needWhen =
(need: BotNeed, pending: (agentId: string) => Effect.Effect<boolean>) =>
(agentId: string) =>
Effect.map(pending(agentId), (found) => (found ? need : undefined));

export class BotNeeds extends Context.Service<
BotNeeds,
{
readonly provide: (
source: NeedSource,
) => Effect.Effect<void, never, Scope.Scope>;
readonly current: (agentId: string) => Effect.Effect<BotNeed | undefined>;
readonly changed: (agentId: string) => Effect.Effect<void>;
readonly onChanged: (listener: (agentId: string) => void) => () => void;
}
>()("crumble/bot-ports/BotNeeds") {
static readonly layer = Layer.effect(
BotNeeds,
Effect.gen(function* () {
const sources = yield* Ref.make<ReadonlyArray<NeedSource>>([]);
const listeners = new Set<(agentId: string) => void>();

return BotNeeds.of({
provide: (source) =>
Effect.acquireRelease(
Ref.update(sources, (current) => [...current, source]),
() =>
Ref.update(sources, (current) =>
current.filter((each) => each !== source),
),
),
current: (agentId) =>
Effect.flatMap(Ref.get(sources), (current) =>
Effect.map(
Effect.forEach(current, (source) => source(agentId), {
concurrency: "unbounded",
}),
strongest,
),
),
changed: (agentId) =>
Effect.sync(() => {
for (const listener of listeners) {
listener(agentId);
}
}),
onChanged: (listener) => {
listeners.add(listener);

return () => void listeners.delete(listener);
},
});
}),
);
}
Loading