[GH-ISSUE #8491] [Feature]: Capability packages: let a package hide or show chat messages from the AI #8379

Closed
opened 2026-11-07 16:42:35 +07:00 by bsakaguchi · 0 comments
Owner

Originally created by @Promansis on GitHub (Oct 30, 2026).
Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/8491

Originally assigned to: @Promansis on GitHub.

What problem does this solve?

The Engine's chat summary can hide the messages it summarised from the AI ("Hide summarised messages"), so the prompt carries the summary instead of the full history. A package that keeps its own memory of a chat can't do the same. The package persistence host can read chats and messages (listChats, getChat, listMessages), and with chat-write it can append messages and patch chat metadata. But it has no way to change a message's hiddenFromAI flag.

The first user is Long-Term Memory. When it imports a chat's messages into memory, it would like to optionally hide those messages from the AI, as the summary does (Agents issue to follow, linked below).

Proposed solution

Add one optional host method for packages:

/**
 * Capability API 1.388. Hides or shows messages of one chat from the AI, as the Engine's summary does. Requires
 * `chat-write`. Resolves the ids whose flag this call actually changed, so the package can record what it owns.
 * Ids not in the chat are ignored. A message whose visibility the user set by hand (`extra.visibilityManual`) is
 * never changed and is not returned.
 */
setMessagesHiddenFromAI?(chatId: string, messageIds: string[], hidden: boolean): Promise<string[]>;

It is optional on CapabilityPersistenceHost, like appendMessages (1.341), so packages feature-detect it and keep working on older Engines. (listChatSummaries sits on the transaction-scoped CapabilityPersistenceSession; this method writes through host chat storage like appendMessages, so it belongs on the host.)

Minimal fix

  • packages/shared/src/types/capability-runtime.ts: add the method to CapabilityPersistenceHost (~440), after appendMessages (~456), with the doc comment above.
  • packages/shared/src/schemas/capability-package.schema.ts (~1487–1489): add the // 1.388: line and set supportedCapabilityApi to minor: 388.
  • scripts/regressions/capability-package-lifecycle.regression.ts: the five hard-coded 387s (~107, ~143, ~147, ~209, ~226) move to 388: the supportedCapabilityApi assert, the two "this Engine supports 1.387" messages, a new [388, "hide messages from the AI"] row in supportedMinors, and the unsupported-minor probe becomes 1.389.
  • docs/development/optional-agent-packages.md (~1790): a "### Capability API 1.388: hide or show messages from the AI" section above the 1.387 one, in its shape (permission, what is skipped, what is returned, feature-detect).
  • packages/server/src/services/capability-packages/capability-persistence.service.ts, createCapabilityPersistenceHost (~732):
    • assertPermission("chat-write");
    • reject a chat that doesn't exist, like appendMessages;
    • read the chat's messages with hostChats().listMessages(chatId) (~2309) and drop the ids whose extra.visibilityManual === true (bulkSetHiddenFromAI does not skip them itself);
    • call hostChats().bulkSetHiddenFromAI(chatId, ids, hidden) (chats.storage.ts ~3048) with no extra argument, so the package never sets visibilityManual. That call already runs one transaction behind the message patch queues, updates every swipe, ignores ids from other chats (its where clause is scoped by chat), and returns only the ids it flipped.
    • No new storage code; the visibilityManual filter is the only logic the host adds. No lock: the helper takes the same queues the Engine's own routes do.
  • No change to generation: it already leaves out hiddenFromAI messages.

Regression in scripts/regressions/capability-runtime-host-services.regression.ts, next to the appendMessages checks (~252–310), with its full (chat-write) and reader (chat-read only) fixtures:

  1. Without chat-write the call rejects, and with only chat-read it still rejects.
  2. Hiding returns the ids that changed. A message that was already hidden is not returned, and hiding again returns [].
  3. The message and all its swipes have hiddenFromAI: true.
  4. Showing returns only the ids that changed back.
  5. A message with visibilityManual: true is unchanged and not returned.
  6. An id from another chat is ignored.
  7. An unknown chat rejects.

Alternatives considered

  • Let the package write a chat summary entry with messageIds, so the summary's own hiding runs. That puts the package's text into the chat's summary prompt and its summary list, which a memory package doesn't want, and the hiding path is in the summary route, not the host.
  • A general patchMessageExtra. It is broader than needed: a package could then change any message field. Hiding is the one thing a memory package needs.

Additional context

  • The summary records the ids it hid (hiddenMessageIds on each entry) and later shows only those again (summaryHidingPatch, generate-route-utils.ts ~867). Returning the flipped ids lets a package keep the same kind of ownership.
  • Both features use the same flag. A message hidden by the summary is not returned to the package, so the package never claims it. If the summary later shows it again, the package simply doesn't own it.
  • This is a package permission surface. It needs chat-write, which packages already have to declare in their manifest.
  • Skipping visibilityManual follows Advanced Memory (visibilitySettled, advanced-memory.ts ~968, #7192), the Engine's other automatic hider. The summary's own computeSummaryHideIds does not skip it; a package is an automatic writer, so it follows the stricter rule. No other code lists host methods: adding it to the object createCapabilityPersistenceHost returns is what exposes it.

Template check

  • I DID NOT read this template and provide the requested details.
Originally created by @Promansis on GitHub (Oct 30, 2026). Original GitHub issue: https://github.com/Pasta-Devs/Marinara-Engine/issues/8491 Originally assigned to: @Promansis on GitHub. ## What problem does this solve? The Engine's chat summary can hide the messages it summarised from the AI ("Hide summarised messages"), so the prompt carries the summary instead of the full history. A package that keeps its own memory of a chat can't do the same. The package persistence host can read chats and messages (`listChats`, `getChat`, `listMessages`), and with `chat-write` it can append messages and patch chat metadata. But it has no way to change a message's `hiddenFromAI` flag. The first user is Long-Term Memory. When it imports a chat's messages into memory, it would like to optionally hide those messages from the AI, as the summary does (Agents issue to follow, linked below). ## Proposed solution Add one optional host method for packages: ```ts /** * Capability API 1.388. Hides or shows messages of one chat from the AI, as the Engine's summary does. Requires * `chat-write`. Resolves the ids whose flag this call actually changed, so the package can record what it owns. * Ids not in the chat are ignored. A message whose visibility the user set by hand (`extra.visibilityManual`) is * never changed and is not returned. */ setMessagesHiddenFromAI?(chatId: string, messageIds: string[], hidden: boolean): Promise<string[]>; ``` It is optional on `CapabilityPersistenceHost`, like `appendMessages` (1.341), so packages feature-detect it and keep working on older Engines. (`listChatSummaries` sits on the transaction-scoped `CapabilityPersistenceSession`; this method writes through host chat storage like `appendMessages`, so it belongs on the host.) ### Minimal fix - `packages/shared/src/types/capability-runtime.ts`: add the method to `CapabilityPersistenceHost` (~440), after `appendMessages` (~456), with the doc comment above. - `packages/shared/src/schemas/capability-package.schema.ts` (~1487–1489): add the `// 1.388:` line and set `supportedCapabilityApi` to `minor: 388`. - `scripts/regressions/capability-package-lifecycle.regression.ts`: the five hard-coded `387`s (~107, ~143, ~147, ~209, ~226) move to 388: the `supportedCapabilityApi` assert, the two "this Engine supports 1.387" messages, a new `[388, "hide messages from the AI"]` row in `supportedMinors`, and the unsupported-minor probe becomes 1.389. - `docs/development/optional-agent-packages.md` (~1790): a "### Capability API 1.388: hide or show messages from the AI" section above the 1.387 one, in its shape (permission, what is skipped, what is returned, feature-detect). - `packages/server/src/services/capability-packages/capability-persistence.service.ts`, `createCapabilityPersistenceHost` (~732): - `assertPermission("chat-write")`; - reject a chat that doesn't exist, like `appendMessages`; - read the chat's messages with `hostChats().listMessages(chatId)` (~2309) and drop the ids whose `extra.visibilityManual === true` (`bulkSetHiddenFromAI` does not skip them itself); - call `hostChats().bulkSetHiddenFromAI(chatId, ids, hidden)` (`chats.storage.ts` ~3048) with no `extra` argument, so the package never sets `visibilityManual`. That call already runs one transaction behind the message patch queues, updates every swipe, ignores ids from other chats (its where clause is scoped by chat), and returns only the ids it flipped. - No new storage code; the `visibilityManual` filter is the only logic the host adds. No lock: the helper takes the same queues the Engine's own routes do. - No change to generation: it already leaves out `hiddenFromAI` messages. Regression in `scripts/regressions/capability-runtime-host-services.regression.ts`, next to the `appendMessages` checks (~252–310), with its `full` (chat-write) and `reader` (chat-read only) fixtures: 1. Without `chat-write` the call rejects, and with only `chat-read` it still rejects. 2. Hiding returns the ids that changed. A message that was already hidden is not returned, and hiding again returns `[]`. 3. The message and all its swipes have `hiddenFromAI: true`. 4. Showing returns only the ids that changed back. 5. A message with `visibilityManual: true` is unchanged and not returned. 6. An id from another chat is ignored. 7. An unknown chat rejects. ## Alternatives considered - **Let the package write a chat summary entry with `messageIds`, so the summary's own hiding runs.** That puts the package's text into the chat's summary prompt and its summary list, which a memory package doesn't want, and the hiding path is in the summary route, not the host. - **A general `patchMessageExtra`.** It is broader than needed: a package could then change any message field. Hiding is the one thing a memory package needs. ## Additional context - The summary records the ids it hid (`hiddenMessageIds` on each entry) and later shows only those again (`summaryHidingPatch`, `generate-route-utils.ts` ~867). Returning the flipped ids lets a package keep the same kind of ownership. - Both features use the same flag. A message hidden by the summary is not returned to the package, so the package never claims it. If the summary later shows it again, the package simply doesn't own it. - This is a package permission surface. It needs `chat-write`, which packages already have to declare in their manifest. - Skipping `visibilityManual` follows Advanced Memory (`visibilitySettled`, `advanced-memory.ts` ~968, #7192), the Engine's other automatic hider. The summary's own `computeSummaryHideIds` does not skip it; a package is an automatic writer, so it follows the stricter rule. No other code lists host methods: adding it to the object `createCapabilityPersistenceHost` returns is what exposes it. ## Template check - [ ] I DID NOT read this template and provide the requested details.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Pasta-Devs/Marinara-Engine#8379
No description provided.