Skip to content

feat(plugins): expose engine.getChatHistory to plugins (#609)#613

Merged
rmyndharis merged 1 commit into
mainfrom
feat/plugin-getchathistory
Jul 3, 2026
Merged

feat(plugins): expose engine.getChatHistory to plugins (#609)#613
rmyndharis merged 1 commit into
mainfrom
feat/plugin-getchathistory

Conversation

@rmyndharis

Copy link
Copy Markdown
Owner

Part of #609 (initial history sync). Host-side prerequisite for the chatwoot-adapter history backfill.

Summary

Adds getChatHistory(sessionId, chatId, limit?, includeMedia?) to PluginEngineReadCapability, so a plugin can read recent messages for a chat (both directions) — the read a backfill needs. It sits alongside the existing engine reads (getChats, getContacts, …).

Gating & bounds

  • Bound in the loader through the same resolveEngineRead gate as the other engine reads: requires the engine:read permission and an active session for the plugin.
  • The limit is clamped inline to 100 (the REST non-deep ceiling) so an untrusted plugin cannot request an unbounded history fetch. Defaults to 50; a non-positive value clamps to 1.
  • Trust delta is modest — the plugin already receives live messages and contacts for its activated sessions; this exposes recent past ones under the same gate.

Tests

Delegation with the limit clamped (500 → 100), the default/clamp-to-1 cases, and a permission denial (no engine:readPluginCapabilityError, engine never resolved). Full backend suite green (1909 tests); lint and build clean.

Additive and backward-compatible. Targeted for the next patch (0.8.5), which the chatwoot-adapter backfill will pin.

Add a getChatHistory(sessionId, chatId, limit?, includeMedia?) method to
PluginEngineReadCapability, bound in the loader through the same
resolveEngineRead gate as the other engine reads (engine:read permission +
active session). The limit is clamped inline to 100 (the REST non-deep
ceiling) so an untrusted plugin can't request an unbounded fetch; both
message directions are returned.

Host-side prerequisite for the chatwoot-adapter history backfill.
@rmyndharis rmyndharis merged commit d476209 into main Jul 3, 2026
5 checks passed
@rmyndharis rmyndharis deleted the feat/plugin-getchathistory branch July 3, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant