Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
docs: document proactive messages
  • Loading branch information
zakiego committed Nov 24, 2026
commit 11969af5b5679e46d47bb232dcb13231c77a4b13
4 changes: 4 additions & 0 deletions apps/site/content/docs/changelog.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ Palui Agent uses [semantic versioning](https://semver.org). Each release is a gi

- Changed: `/report` without a note no longer adds a tip asking you to describe what went wrong. ([#20](https://github.com/zakiego/palui/pull/20))

### Agents

- Added: Proactive messages per agent. It checks your calendar and WhatsApp, then tells you when to leave or who is waiting. Adds a migration.

### Tools

- Added: Set tool permissions per connector and per read, write or destructive group. A choice there locks the tools under it. ([#17](https://github.com/zakiego/palui/pull/17))
Expand Down
1 change: 1 addition & 0 deletions apps/site/content/docs/connectors/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Everything optional in Palui is a connector. You add, test, pause and remove the
| [Flows](/docs/connectors/flows) | `skill` | Automations built from chat: triggers plus steps that read tools, decide, ask, wait and send, logged step by step. |
| [Attachments](/docs/connectors/attachments) | `skill` | Keeps the important files you send in chat, encrypted, on the Attachments page. |
| [Jobs](/docs/connectors/jobs) | `skill` | Scheduled agent jobs, the daily briefing and the heartbeat. |
| [Proactive](/docs/connectors/proactive) | `skill` | Checks your calendar and WhatsApp and messages you first, each thing once. |
| [Chat history](/docs/connectors/chat-history) | `skill` | Finds the agent's other chats and reads their recent messages, read-only. |
| [Instructions & preferences](/docs/connectors/notes) | `skill` | Standing instructions and your defaults, in every turn. |
| [Settings](/docs/connectors/settings) | `skill` | Palui reads its own setup and changes settings when you ask. |
Expand Down
1 change: 1 addition & 0 deletions apps/site/content/docs/connectors/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"reminders",
"flows",
"jobs",
"proactive",
"chat-history",
"notes",
"settings",
Expand Down
61 changes: 61 additions & 0 deletions apps/site/content/docs/connectors/proactive.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
---
title: Proactive
description: An agent checks your calendar and WhatsApp on its own and messages you first, each thing once.
---

Kind: `skill`. With proactive on, an agent checks your calendar and your personal WhatsApp every 30 minutes and tells you what matters before you ask: when to leave for a place, a meeting about to start, an event that moved, a chat waiting for your reply. It also sends a morning and an evening summary. It's per agent and off for every agent until you turn it on.

## Connect

Proactive is built in. Set it up on an agent's page, in the **Proactive** tab:

1. Pick where messages go: your own DM or the web chat. Groups and other people's chats can't be picked.
2. Pick the sources:
- **Calendar**: a [Google Calendar](/docs/connectors/google-calendar) connector.
- **WhatsApp**: an [MCP server](/docs/connectors/mcp) connector pointing at [wa-hub](https://github.com/zakiego/wa-hub), with its `list_chats` tool classified **read**. wa-hub needs the version whose `list_chats` returns structured content.
3. Switch on **Message me first**.

You can do the same from chat: "nyalain proactive di chat ini".

## Settings

| Setting | Default | What it does |
|---|---|---|
| Check every | 30 min | How often sources are read. Reading costs no tokens when nothing is new. |
| At most | 4 per hour | Messages over the limit wait and go out together later. |
| Morning / evening summary | 07:00 / 20:00 | Today's events, reminders and waiting chats; tomorrow's events and when to leave. |
| Quiet hours | 22:00 to 07:00 | Nothing is sent. What was held goes into the morning summary. |
| Urgent calendar changes still come through | on | An event inside the next 3 hours that moved still reaches you in quiet hours. |
| Time to leave | 30 min before | For events with a physical location. |
| Online meeting | 10 min before | For events with a video link, with the link. |
| Unanswered after | 2 h | How long a chat waits before you're told. |
| Remind again after | 4 h | One more reminder if it's still unanswered. Never a third. |
| Skip groups | on | Only direct chats count. |
| Important contacts | none | Always told, whatever the model thinks. Star a chat in the tab's activity list to add it. |
| Guess from memory | on | The agent's memory helps judge who else matters. |

## Tools

All offered only in your own turns in your DM or the web chat:

- `get_proactive` reads the agent's settings.
- `update_proactive` turns it on or off, picks the current chat as the target, or changes the settings with a merge patch ("jam tenang jadi 23:00").
- `mute_proactive` and `unmute_proactive` stop or resume reminders about one chat or event, by name.
- `list_nudges` lists what proactive found today and what it did with each.
- `check_proactive_now` checks within a minute.

Each proactive message has buttons: **Selesai**, **1j**, **3j**, **Besok** and **Jangan ingetin**. On WhatsApp, reply to the message with "done", "tunda 3 jam" or "jangan ingetin". Replying to the person on your phone closes the reminder too.

## Safety

<Callout type="warn" title="Chat previews go to your model provider">
To judge what matters and word the message, the agent sends the names, chat previews and event titles it found to your model. That call has no tools, so a message written to trick the model can only change the wording of one message to you.
</Callout>

- Messages only go to a chat whose audience is you. If the target becomes shared, proactive pauses and says why on the tab.
- Time-bound messages (leave now, meeting starting) come from a fixed template, without the model, so a down model provider never makes you late.
- The ledger keeps what was found for 30 days.

## Pause and remove

Pausing this connector hides the chat tools only. To stop proactive messages, switch off **Message me first** on the agent's Proactive tab.
18 changes: 18 additions & 0 deletions docs/PLAN.md
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,20 @@ Automations the agent builds from chat out of triggers and steps (`apps/server/i
- Tools: `create_flow`, `update_flow` (a full definition or a merge patch, `steps`/`triggers` patchable by id), `check_flow`, `test_flow`, `list_flows`, `get_flow`, `pause_flow`, `delete_flow`, `run_flow`, `flow_history`, `get_run`, `explain_flow`, `answer_checkin`, `cancel_run`, and `flows__recap` (the recap as data, usable as a step). Offered only in owner turns in the owner's DMs and the web chat. `palui__search_tools` hits carry `class` and `untrusted`, and leave destructive tools out with `for: "flow"`.
- Dashboard: a read-only Flows page and a flow page (triggers, steps with branches, write calls, versions with their diffs, recent runs); a flow run opens its step log on the run page.

## 6d. Proactive

An agent tells the owner what matters without being asked (`apps/server/internal/proactive`, tools in the `proactive` connector, the agent page's Proactive tab). Accepted from `docs/rfc/proactive.md`, which keeps the reasoning and the rejected alternatives; this section is the source of truth for behavior.

- Per agent (`agent_proactive`, config JSON validated by `proactive.Config.Validate`), off for every agent until the owner turns it on. The target must be a chat whose audience is `owner`, checked at save and at every tick; a target that stops being one pauses proactive with `paused_reason`.
- Sources: a gcal connector (its `events` action, now to 36 hours ahead) and a wa-hub MCP connector (`list_chats tab=unanswered since=<now - maxAgeDays>`, structured content only, the tool classified read). Each must be a connector the agent may use. A source failing 3 ticks in a row tells the owner once a day.
- The tick (every `checkEveryMin`, default 30, a scheduler extension with a lease): collect without the model, reconcile into the `nudges` ledger (one row per key, unique per agent), then decide. The first tick only seeds chats already waiting. A tick with nothing pending costs no tokens.
- Calendar: an event with a physical location gets a `cal_depart` nudge at start minus `departLeadMin`; one with a video link a `cal_start` nudge at start minus `onlineLeadMin`. These are timed: sent at their minute from a template, never by the model, and expired instead of sent late. A moved event (start or location) gets one `cal_changed` nudge and its timed nudges follow. Declined, cancelled and all-day events get no timed nudge.
- WhatsApp: one wait is one nudge (`wa:<chatId>:<awaitingSince>`); groups skipped by default, waits shorter than `waitHours` or older than `maxAgeDays` ignored. A chat no longer waiting closes its nudge. One escalation after `escalateHours`, never a second.
- Decide: one call on the agent's `modelRole` (default `fast`) with zero tools, the turn tainted, every source field in `<untrusted>`, JSON out (`send`, `drop` with a reason, `text`). Contacts in `contacts`, `cal_changed` and escalations are always told; a nudge the model keeps skipping goes out from its template after 2 ticks. With `contactsAuto` the call gets the agent's memory profile, read once a day. Tokens count toward the global and the agent's daily cap; over a cap, only must-tell nudges go out, from templates.
- Delivery: quiet hours hold everything except a change to an event within 3 hours (when `urgentPasses`); `maxPerHour` caps messages, extra ones wait and merge. Morning and evening summaries (07:00 and 20:00 by default) always go out, at most 2 hours late; the morning one carries what quiet hours held. Messages go through the outbox with `source = proactive:<agentId>`, plain text, capped at 700 characters, expiring after 6 hours.
- Owner actions: `ndg:done:<id>`, `ndg:snooze:<id>:<1h|3h|tomorrow>`, `ndg:mute:<id>` buttons, or a WhatsApp reply quoting the message ("done", "tunda 3 jam", "jangan ingetin"). An action applies to every nudge in that message. A mute (`proactive_mutes`) drops every open and future nudge on that subject.
- Retention: nudges and `proactive_ticks` 30 days (open nudges stay).

## 7. Scheduled jobs

- A job is an RRULE, a zone, a prompt, a target chat, a tool scope and a model role.
Expand Down Expand Up @@ -369,6 +383,10 @@ Example: `/report-fix` with the report attached and a prompt telling the agent t
| `flow_runs` | id, flow_id, version_id, chat_id, trigger_id, trigger_kind, run_key (unique per flow), parent_run_id, item_index, status, skip_reason, trigger json, vars json, taint json, cursor, wait json, wake_at, lease_until, steps_done, messages_sent, scheduled_at, started_at, ended_at, error, legacy_occurrence_id (retired, unused), dry_run |
| `flow_step_runs` | id, run_id, seq, step_id, kind, attempt, status, input, output, tainted, branch, tool_call_id, turn_run_id, error, started_at, ms |
| `outbox` | id, chat_id, connector_id, payload, status, attempts, next_attempt_at, claimed_at, channel_msg_id, source |
| `agent_proactive` | agent_id, enabled, chat_id, config json, next_tick_at, last_tick_at, tick_lease_until, paused_reason |
| `nudges` | id, agent_id, key (unique per agent), kind, subject, status, wake_at, sent_at, escalated_at, snapshot json, reason, outbox_id |
| `proactive_mutes` | agent_id, subject, label |
| `proactive_ticks` | id, agent_id, started_at, finished_at, sources json, found, sent, tokens, error (30 days) |
| `events` | id, at, level, connector_id, kind, message |
| `reports` | id, chat_id, session_id, note, text, created_at (one row per `/report`, kept until deleted) |
| `settings` | key, value |
Expand Down
2 changes: 1 addition & 1 deletion docs/rfc/proactive.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RFC: Proactive

Status: draft, decisions settled in section 17, 2026-11-24. Author: Palui agent session. Reviewer: the maintainer.
Status: accepted and built, 2026-11-24. Decisions are in section 17. Author: Palui agent session. Reviewer: the maintainer.
Scope: the design and its reasoning. Once accepted, the behavior moves to `docs/PLAN.md` (a new section next to 6c and 7, plus the tables in 9), and that section wins where the two differ.

## TL;DR
Expand Down
Loading