omp packages

omp-channel0.13.0

Oh My Pi extension that delivers messages from an external console into an agent session and sends replies back.

GitHub Actions Published 21 hours ago Apache-2.0 ~2.7K downloads/mo

Built for omp

The author tagged this package oh-my-pi.

Did it work for you?

Result

One report per person. A new report replaces your old one.

Reports 0

No reports yet.

Readme

omp-channel

CI

License: Apache-2.0 Node.js 20+

Documentation: https://tommasomarchionni.github.io/omp-channel/

omp-channel is an extension for Oh My Pi (OMP), a terminal agent harness. It delivers messages from an external service (any system that exchanges messages with a person) into an agent session, and sends the agent's replies back to that service.

It is for people who run an agent in a terminal and want an outside service to be able to send it work and receive the answers, including while the agent is busy. It is not a hosting service, it contains no models, and it does not manage accounts. You provide the service and the model; omp-channel is the link between them.

Status: alpha, version 0.4.0 on npm. The behaviour is covered by automated tests that use fakes and a loopback HTTP service. Startup, delivery to an idle session, queueing during a turn and abort have passed in a live Oh My Pi session; the status report and the attribution values are not yet verified. See docs/omp-verification.md for each check and what is open.

Contents

How it works

  1. A service has a message for the agent. omp-channel receives it, either by polling an HTTP endpoint or from an MCP server that pushes it.
  2. The message is handed to the agent as a follow-up, so it waits until the current turn ends if the agent is busy. The text is marked as data from an outside party.
  3. The agent answers with the reply tool, using the messageId of the message. omp-channel posts the reply to the service. The reply can show up to four images (PNG, JPEG or WebP, 5 MiB each) from the working folder or a temporary folder; the model is told which ones were not shown (docs/protocol.md, section 7.2). A message can also list files the sender attached (images, PDF, text, CSV, JSON, up to 10 MiB each). The model reads one with the attachment tool: omp-channel asks the service for it, checks size, type and SHA-256, and writes it to a private folder that is removed with the conversation (docs/protocol.md, section 3.7).
  4. While a turn runs, omp-channel reports working to the service; when the turn ends, free. A service that takes activity reports also learns which tools the agent is using, and one that takes reasoning reports, what the model is thinking. Both carry an order, so the steps and the blocks of thinking of a message can be shown in the order they happened (docs/protocol.md, section 11.1). An adapter module with a draft method gets the answer while the model writes it, before the reply (docs/protocol.md, section 12).
  5. A service can also learn how full the agent's context is (the window, the tokens in use and the model, docs/protocol.md section 13) and ask the agent to compact it with a compact event: Oh My Pi summarizes the older part of the session between two runs, never inside one, and the service receives the outcome with the numbers before and after and the summary (sections 3.6 and 14).
  6. Delivery is at least once with acknowledgements, so a message is neither lost nor handled twice when the extension restarts. Details are in docs/protocol.md.

One conversation is open at a time per agent session. A message for another conversation waits until the open one is closed.

Connect a service in three steps

0. Install the extension

omp install omp-channel

This installs the published package into Oh My Pi's plugin folder (~/.omp/plugins). The extension then loads in every session: no -e flag and no path to set. Check it by starting a session and running /channel-status: it shows the transport in use and, when an adapter is configured, what the adapter reports.

The configuration file is read from .omp/omp-channel.json in the directory where Oh My Pi starts, or from the path in OMP_CHANNEL_CONFIG when that variable is set. Without either, the extension has no transport and only offers MCP push. The steps below write this file.

A service that needs its own protocol connects through an adapter module (section 6 of docs/protocol.md). Point adapterModule at it in the configuration file, and give the adapter the environment it reads:

{
  "mcpServer": "my-service",
  "adapterModule": "/path/to/adapter.mjs",
  "delivery": { "deliverAs": "followUp" }
}

1. Install from a clone (for development)

Use this only to change the extension itself. The steps below need the built dist/index.js:

git clone https://github.com/tommasomarchionni/omp-channel.git
cd omp-channel
npm ci
npm run build

Load the built file with the -e flag, as in the example below, instead of omp install.

2. Choose how messages arrive

  • HTTP service (most integrations). Set service.url in the configuration file. omp-channel then polls GET <url>/messages, acknowledges with POST <url>/messages/ack, and posts replies and status to <url>/replies and <url>/status. The service needs to implement those calls; the contract is in docs/protocol.md. No code is needed.
  • MCP push (local tools and tests). Run an MCP server that sends the notification notifications/omp/channel. The example in examples/mcp-server does this. Messages pushed this way are not leased, so they are not redelivered if lost. Replies still need an HTTP service or an adapter module.
  • Adapter module (custom protocol). Point adapterModule at a JavaScript module that exports a ChannelAdapter. See examples/adapter-module.

3. Configure the URL and the key

The key is never written in the configuration file or in the code. The file names the environment variable that holds it:

export EXAMPLE_CHANNEL_KEY="replace-with-the-key-from-your-service"

Or put the key in a file and name that file with the variable <keyEnv>_FILE, for example EXAMPLE_CHANNEL_KEY_FILE=/path/to/key.

Complete example

This example uses a placeholder service (chat.example.com). Replace the URL and the key with your own. It also includes a local MCP test message that needs no service.

1. Configuration file (examples/config/omp-channel.json, which you can copy):

{
  "$schema": "../../schema/config.schema.json",
  "mcpServer": "omp-channel",
  "service": {
    "url": "https://chat.example.com/api/omp-channel",
    "keyEnv": "EXAMPLE_CHANNEL_KEY"
  },
  "delivery": {
    "deliverAs": "followUp"
  }
}

2. Environment:

export OMP_CHANNEL_CONFIG="$PWD/examples/config/omp-channel.json"
export EXAMPLE_CHANNEL_KEY="replace-with-your-key"

3. Start Oh My Pi with the extension:

omp -e "$PWD/dist/index.js"

4. Test message without any service. Run the example MCP server by itself. It prints the notification that it would push to the agent once the client sends notifications/initialized:

printf '%s\n' \
  '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' \
  '{"jsonrpc":"2.0","method":"notifications/initialized"}' \
  | node examples/mcp-server/server.mjs

The second line of output is the test message:

{
  "jsonrpc": "2.0",
  "method": "notifications/omp/channel",
  "params": {
    "type": "message",
    "conversationId": "example-conversation",
    "messageId": "example-1",
    "sender": "example-user",
    "text": "Hello from the example service.",
    "sentAt": "..."
  }
}

To make Oh My Pi use the example server, add it to the MCP configuration of Oh My Pi. The exact file and key depend on the Oh My Pi version; the entry runs node on the example file:

{
  "mcpServers": {
    "omp-channel": {
      "command": "node",
      "args": ["/absolute/path/to/omp-channel/examples/mcp-server/server.mjs"]
    }
  }
}

The name omp-channel must equal mcpServer in the configuration file.

Configuration

Every message the service sends must carry attribution ("user" for text a person wrote, "agent" for text another agent wrote). That value is passed to Oh My Pi unchanged. How Oh My Pi records each value is still unverified; see docs/protocol.md, section 3.4.

The configuration file is read from OMP_CHANNEL_CONFIG, or from .omp/omp-channel.json in the working directory when it exists. Without a file the defaults apply and nothing is connected: the extension still receives MCP pushes, but replies are reported as not configured. The file is validated against schema/config.schema.json. An invalid file disables the extension and writes the reason (with its path) to stderr.

Key Default Meaning
mcpServer "omp-channel" MCP server name that may push messages.
service.url none Base URL of the service. https required; http only for loopback.
service.keyEnv "OMP_CHANNEL_KEY" Environment variable holding the key (<keyEnv>_FILE for a file). Required with service.url.
service.requestTimeoutMs 10000 Timeout of each request. Raise it if replies with images are large and the link is slow.
service.paths.* /messages, /messages/ack, /replies, /status, /failures Endpoint paths.
service.paths.activity none Where activity reports are posted. Without it none are sent over HTTP.
service.paths.reasoning none Where reasoning reports are posted. Without it none are sent over HTTP.
service.paths.context none Where context reports are posted. Without it none are sent over HTTP.
service.paths.compacted none Where the outcomes of compact requests are posted. Without it they are only logged.
service.paths.attachment none Where the content of an attachment is read (GET, with {attachmentId}). Without it attachments cannot be read.
poll.intervalMs 2000 Wait between polls when the queue is empty.
poll.maxBackoffMs 30000 Longest wait after failed polls.
poll.batchSize 10 Deliveries requested per poll.
limits.maxTextLength 4000 Longest text of an incoming message, in characters.
limits.maxReplyLength 100000 Longest reply, in characters. A longer final text is cut and says so.
limits.maxSenderLength 64 Longest sender name.
limits.maxPending 5 Events waiting to be admitted; more are dropped and not acknowledged.
delivery.deliverAs "followUp" How a message is queued in Oh My Pi: steer, followUp or aside.
failures.includeReason true Send the cleaned error text when a turn fails and leaves a message unanswered.
replies.fromFinalText true Send the cleaned final text of the model as the reply when it did not use the reply tool.
replies.images true Let the reply tool send image files from the working and temporary folders (docs/protocol.md 7.2).
replies.plainText false Answer with plain text, which becomes the reply; reply only for questions and images. Needs fromFinalText.
reports.activity true Report the tools used for a message, when the transport takes it (docs/protocol.md 10).
reports.reasoning true Report the thinking of the model for a message, when the transport takes it (docs/protocol.md 11).
reports.drafts true Give the answer to the adapter while the model writes it, when the adapter has draft (docs/protocol.md 12).
reports.context true Report how full the context is (window, tokens in use, model), when the transport takes it (docs/protocol.md 13).
attachments.enabled true Let the model read the attachments of a message with the attachment tool, when the transport can fetch them.
context.include [] Keys of the message context shown to the model, inside the envelope. Other keys are dropped (docs/protocol.md 3.1).
adapterModule none Path to a module that exports a ChannelAdapter. Replaces the HTTP transport.

Environment variables:

Variable Meaning
OMP_CHANNEL_CONFIG Path of the configuration file. Must exist when set.
<keyEnv> (for example EXAMPLE_CHANNEL_KEY) The service key.
<keyEnv>_FILE Path of a file that holds the key, used when <keyEnv> is not set.

Security

  • The key stays out of the model. It is used only in HTTP headers. It is not in tool results, prompts, logs or error messages. Error messages name the HTTP status or the error type only.
  • Inbound text is data. Messages are wrapped in an envelope that tells the model the content comes from an outside party and must not change its rules. Angle brackets are escaped so the text cannot close the envelope.
  • Strict validation. Events with unknown fields, invalid identifiers, control characters or text over the limit are rejected before they reach the agent.
  • Transport. https is required for the service. Plain http is accepted only for loopback addresses, for local tests.
  • Replies are limited. The reply tool accepts only a messageId that was delivered in the current session.
  • Images are limited to two places. The reply tool reads an image file only from the working folder of the session or a temporary folder, never through a link or .. that leads outside. A working folder that is the home folder, one above it or a file system root does not count. Only PNG, JPEG and WebP content up to 5 MiB is sent. This does not confine an agent that can copy files with other tools; replies.images: false turns images off. See docs/protocol.md, section 15.
  • Questions go to the chat. The built-in ask tool opens a dialog in the terminal that no one in the chat can answer, so it is blocked; the model asks through reply instead, with a question (one line, up to 6 options and/or a free answer, docs/protocol.md section 7.1). The answer comes back as a new message.
  • Activity says little. An activity report holds the tool name and the stated intent, never commands, arguments or results as such. Secrets, paths, addresses and quoted argument values are taken out of the intent; it is still text written by the model. See docs/protocol.md, section 10, or set reports.activity: false.
  • Reasoning says a lot. A reasoning report holds what the model writes while it thinks, with known secret shapes and the home folder name hidden. The model can write anything there, and the filter knows shapes, not meaning. See docs/protocol.md, section 11, or set reports.reasoning: false.
  • Drafts come before the reply. A draft holds the answer while it is written, with the same hiding as reasoning. With replies.plainText it can also hold text written before a tool call that never becomes the reply. Only an adapter module with a draft method gets drafts. See docs/protocol.md, section 12, or set reports.drafts: false.
  • A compaction summary covers the whole session. The outcome of a compact request carries the summary Oh My Pi wrote, tool results included, with known secret shapes hidden. Only a service that sends compact and takes the outcome receives it (docs/protocol.md, section 14).
  • Attachments are checked and kept private. The content of an attachment is fetched only when the model asks for it, and written only when its size, type and SHA-256 match what the message declared, to a private folder (0700, files 0600, never through a link) under a name omp-channel builds from the id: the sender's file name is never a path. The folder is removed when the conversation closes, the session ends and at the next start. The content is not scanned, and the model is told it is data, not instructions. attachments.enabled: false turns them off. See docs/protocol.md, sections 3.7 and 15.
  • Error text is cleaned. When a turn fails, the error from the model provider is sent with known secret shapes and the home folder name hidden. failures.includeReason: false keeps it on the machine.

No message is left waiting

If the model answers at the terminal without calling reply, its final text is sent as the reply. If there is no answer to send (a model error, a stopped turn, a closed session) the service receives a failure report with the reason. All cases are listed in docs/protocol.md, section 9.

Report vulnerabilities privately, as described in SECURITY.md.

Compatibility

Component Version Status
Node.js 20 and 22 (CI matrix) Tested in CI on both. .nvmrc pins 22 for development.
Oh My Pi 19.2.1 Starts and loads the extension. Delivery not yet verified live.
Bun (for Oh My Pi) 1.4.4 or later Required by Oh My Pi itself, not by omp-channel.
Protocol 1 (alpha) Fields may still change before 1.0; see the changelog.
  • The extension types come from the exact devDependency @oh-my-pi/pi-coding-agent@19.2.1. They are imported, not copied. One gap is documented in src/tool-schema.ts: the tool parameters are plain JSON Schema where Oh My Pi declares a TypeBox schema.
  • Verified in a live Oh My Pi session (19.2.1, local model): startup, delivery of a pushed message to an idle session, a message pushed during a turn (taken at a turn boundary, see docs/protocol.md section 3.5), abort, and the report of a refused model request.
  • Activity and reasoning reports were checked in a live session in RPC mode with a scripted model that streams thinking; not yet with a real model or in the terminal interface. Their order was checked the same way with Oh My Pi 19.4.1 (docs/omp-verification.md).
  • Drafts were checked with Oh My Pi 19.4.0 in RPC mode, a scripted model endpoint on loopback and an adapter module that records them: from a streamed reply call and, with replies.plainText, from plain text with a tool call in between. Not yet with a real model or in the terminal interface (docs/omp-verification.md).
  • Context reports and compaction were checked with Oh My Pi 19.4.1 in RPC mode, a scripted model endpoint on loopback and an adapter module: the start hook, the reports, a compaction asked between two runs and one asked during a run, the refusals, and a message sent during a compaction, which Oh My Pi held until the compaction ended. Not yet with a real model or in the terminal interface (docs/omp-verification.md).
  • Not verified yet: the status report (working/free) to a service, the effect of each attribution value, images with a reply and attachments (the attachment tool, and an image in its result) in a live session (automated tests only). See docs/omp-verification.md.
  • npm ci also installs the Oh My Pi package for type checking; it is large.

Troubleshooting

The extension never stops Oh My Pi. When it cannot start it writes one line to stderr and stays off:

Message Cause and fix
disabled: invalid configuration: unknown key "x" at ... A key is misspelled. The message lists the allowed keys.
disabled: ... must be one of: ... A value is not allowed. The message lists the allowed values.
disabled: set <keyEnv> (or <keyEnv>_FILE) ... The key variable named in service.keyEnv is not set in the omp process.
disabled: OMP_CHANNEL_CONFIG points to a file ... The path in OMP_CHANNEL_CONFIG does not exist.
disabled: service.url must use https ... Use https, or a loopback address for local tests.
Messages arrive but replies fail Without service or adapterModule, MCP pushes work but replies cannot be sent.

Development

npm ci
npm run check          # typecheck, lint, format check and tests
npm run pack:check     # list the files that would be published (publishes nothing)
npm run build          # compile to dist/
OMP_E2E=1 OMP_E2E_MODEL=<provider/model> npm run omp:e2e   # real Oh My Pi check, runs a model

Single commands: npm run typecheck, npm run lint, npm run format (writes), npm run format:check, npm test. Tests use the Node.js built-in test runner through tsx; see CONTRIBUTING.md.

Documentation

License

Apache License 2.0. See LICENSE and NOTICE. This project is independent and is not affiliated with or endorsed by the Oh My Pi project.