Skip to content
Merged
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
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,10 @@ PLOMPY_CODEX_BIN=codex
# Explicit acknowledgement: OpenCode runs with service-account host permissions.
# PLOMPY_OPENCODE_HOST_EXECUTION=allow
PLOMPY_TASK_TIMEOUT_MS=1200000

# Optional personal assistant preview. Use a dedicated thread in the configured
# private owner forum, then choose the maximum age of missed reminders (1–1440 min).
# PLOMPY_ASSISTANT_THREAD_ID=555555555555555555
# PLOMPY_ASSISTANT_TIME_ZONE=UTC
# PLOMPY_ASSISTANT_LOCALE=en
# PLOMPY_ASSISTANT_MAX_LATE_MINUTES=60
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## 1.0.0-alpha.1

- Add the optional [personal assistant preview](docs/personal-assistant.md) with private notes, open tasks, and reminder questions that survive restart.
- Schedule, move and cancel one-time reminders in a dedicated owner thread. A separate delivery loop runs while the coding worker is busy.
- Record confirmed, failed, overdue and uncertain delivery attempts. The owner chooses a lateness window before enabling the assistant.
- Keep assistant data in its own versioned SQLite file. The coding engine continues to use schema 6.

## 0.13.0 (2026-11-12): Local tools for your agent

- Add an authenticated local MCP gateway for independently running Codex, Claude Code, OpenCode and compatible clients, without Discord or a second model account in the container.
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ COPY packages/mcp-bridge/package.json packages/mcp-bridge/package-lock.json ./
RUN npm ci --omit=dev --ignore-scripts --no-audit --no-fund

FROM node:26.13.0-bookworm-slim@sha256:add5c17c14752c54d2f3d519ec46a3815684d41c33f198bcb09fb998f7dcbf68 AS runtime
ARG VERSION=0.13.0
ARG VERSION=1.0.0-alpha.1
ARG REVISION=unknown
LABEL org.opencontainers.image.title="Plompy Engine" \
org.opencontainers.image.description="Self-hosted Discord agent engine with durable jobs and private Markdown memory" \
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile.local
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# syntax=docker/dockerfile:1
FROM node:26.13.0-bookworm-slim@sha256:add5c17c14752c54d2f3d519ec46a3815684d41c33f198bcb09fb998f7dcbf68 AS local-base
ARG VERSION=0.13.0
ARG VERSION=1.0.0-alpha.1
ARG REVISION=unknown
LABEL org.opencontainers.image.title="Plompy Local MCP" \
org.opencontainers.image.description="Local integration tools for an external MCP client" \
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,12 @@ integrations, and print the appropriate client configuration without embedding s
- **Delivery and maintenance:** result receipts, transcript exports and scoped local Git commits have separate durable state.
- **Deployment checks:** owner/forum authorization, local diagnostics, versioned migrations and verified state snapshots.

The public edition has **one global worker**. Work sessions yield between verified steps;
they do not interrupt a running step. Still-image input and supervised goals use Codex.
There is no built-in scheduler, publication broker or message-history catch-up after an outage.
The public edition has **one global worker** for coding agents. Work sessions yield between verified steps.
Still-image input and supervised goals use Codex.

The [personal assistant preview](docs/personal-assistant.md) adds notes, tasks, follow-up
questions and one-time reminders in a dedicated private Discord thread. The reminder
scheduler runs independently of the coding worker.

## Quick start

Expand Down
4 changes: 2 additions & 2 deletions apps/discord-agent/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion apps/discord-agent/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@plompy/discord-agent",
"version": "0.13.0",
"version": "1.0.0-alpha.1",
"private": true,
"type": "module",
"engines": {
Expand Down
146 changes: 146 additions & 0 deletions apps/discord-agent/src/assistant-delivery.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@
import type { DeliveryClaim, AssistantStore } from "./assistant-store.js";

type DeliveryStore = Pick<
AssistantStore,
"claimDue" | "beginDelivery" | "finishDelivery" | "recoverDeliveries"
>;

export type ReminderSendResult =
| { kind: "sent"; messageId: string }
| { kind: "retry"; retryAfterMs?: number }
| { kind: "failed" }
| { kind: "ambiguous" };

type SendReminder = (
threadId: string,
content: string,
) => Promise<ReminderSendResult>;

interface Options {
threadId: string;
locale: "en" | "pl";
maxLatenessMs: number;
now?: () => number;
onError?: () => void;
}

const POLL_MS = 5_000;
const FIRST_BACKOFF_MS = 15_000;
const MAX_ATTEMPTS = 3;
const MAX_PER_TICK = 4;
const MESSAGE_LIMIT = 1_800;

function messageFor(
claim: DeliveryClaim,
locale: Options["locale"],
now: number,
): string {
const late = now - claim.dueAt >= 60_000;
const heading =
locale === "pl"
? late
? "Opóźnione przypomnienie"
: "Przypomnienie"
: late
? "Delayed reminder"
: "Reminder";
const due = new Intl.DateTimeFormat(locale === "pl" ? "pl-PL" : "en-GB", {
timeZone: claim.zone,
dateStyle: "long",
timeStyle: "short",
hourCycle: "h23",
}).format(claim.dueAt);
return `**${heading} ${claim.id}** · ${due} (${claim.zone})\n${claim.text}`;
}

export class ReminderScheduler {
private timer: NodeJS.Timeout | undefined;
private inFlight: Promise<void> | undefined;
private stopped = false;
private readonly now: () => number;

constructor(
private readonly store: DeliveryStore,
private readonly send: SendReminder,
private readonly options: Options,
) {
this.now = options.now ?? Date.now;
}

start(): void {
if (this.timer || this.stopped) return;
this.store.recoverDeliveries(this.now());
const poll = (): void => {
void this.tick().catch(() => this.options.onError?.());
};
this.timer = setInterval(poll, POLL_MS);
poll();
}

tick(): Promise<void> {
if (this.inFlight) return this.inFlight;
if (this.stopped) return Promise.resolve();
this.inFlight = Promise.resolve()
.then(() => this.deliverDue())
.finally(() => {
this.inFlight = undefined;
});
return this.inFlight;
}

async stop(): Promise<void> {
this.stopped = true;
clearInterval(this.timer);
this.timer = undefined;
await this.inFlight;
}

private async deliverDue(): Promise<void> {
for (let index = 0; index < MAX_PER_TICK && !this.stopped; index++) {
const now = this.now();
const claim = this.store.claimDue(now, this.options.maxLatenessMs);
if (!claim) return;
const content = messageFor(claim, this.options.locale, now);
// Assignment alone does not authorize a send. Cancellation/rescheduling
// may have superseded the claim before this durable transition.
if (!this.store.beginDelivery(claim, this.now())) continue;
const result = await this.dispatch(content);
const finishedAt = this.now();
if (result.kind !== "retry") {
this.store.finishDelivery(claim, result, finishedAt);
continue;
}
if (claim.attempt >= MAX_ATTEMPTS) {
this.store.finishDelivery(claim, { kind: "failed" }, finishedAt);
continue;
}
const backoff = FIRST_BACKOFF_MS * 2 ** (claim.attempt - 1);
const requested = result.retryAfterMs ?? 0;
const delay = Number.isFinite(requested)
? Math.max(backoff, requested)
: backoff;
const retryAt = finishedAt + Math.ceil(delay);
// A definitive rejection still cannot be retried earlier than Discord
// allows, or later than the configured delivery window.
const canRetry =
Number.isFinite(new Date(retryAt).getTime()) &&
retryAt <= claim.dueAt + this.options.maxLatenessMs;
this.store.finishDelivery(
claim,
canRetry ? { kind: "retry", retryAt } : { kind: "failed" },
finishedAt,
);
}
}

private async dispatch(content: string): Promise<ReminderSendResult> {
if (content.length > MESSAGE_LIMIT) return { kind: "failed" };
try {
return await this.send(this.options.threadId, content);
} catch {
// A rejected promise alone does not establish that Discord rejected the
// request. Only explicit, known pre-dispatch/rejection outcomes can retry.
return { kind: "ambiguous" };
}
}
}
Loading