omp-channel 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/LICENSE +201 -0
  3. package/NOTICE +8 -0
  4. package/README.md +318 -2
  5. package/dist/adapter.d.ts +46 -0
  6. package/dist/adapter.js +18 -0
  7. package/dist/adapter.js.map +1 -0
  8. package/dist/config.d.ts +58 -0
  9. package/dist/config.js +140 -0
  10. package/dist/config.js.map +1 -0
  11. package/dist/dispatcher.d.ts +53 -0
  12. package/dist/dispatcher.js +242 -0
  13. package/dist/dispatcher.js.map +1 -0
  14. package/dist/extension.d.ts +27 -0
  15. package/dist/extension.js +151 -0
  16. package/dist/extension.js.map +1 -0
  17. package/dist/http-adapter.d.ts +20 -0
  18. package/dist/http-adapter.js +140 -0
  19. package/dist/http-adapter.js.map +1 -0
  20. package/dist/index.d.ts +11 -0
  21. package/dist/index.js +50 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/module-adapter.d.ts +3 -0
  24. package/dist/module-adapter.js +21 -0
  25. package/dist/module-adapter.js.map +1 -0
  26. package/dist/protocol.d.ts +113 -0
  27. package/dist/protocol.js +222 -0
  28. package/dist/protocol.js.map +1 -0
  29. package/dist/redact.d.ts +11 -0
  30. package/dist/redact.js +65 -0
  31. package/dist/redact.js.map +1 -0
  32. package/dist/tool-schema.d.ts +13 -0
  33. package/dist/tool-schema.js +13 -0
  34. package/dist/tool-schema.js.map +1 -0
  35. package/dist/turn.d.ts +24 -0
  36. package/dist/turn.js +60 -0
  37. package/dist/turn.js.map +1 -0
  38. package/docs/protocol.md +334 -0
  39. package/package.json +76 -4
  40. package/schema/config.schema.json +159 -0
  41. package/schema/failure.schema.json +34 -0
  42. package/schema/inbound-event.schema.json +82 -0
  43. package/schema/outbound-reply.schema.json +34 -0
  44. package/schema/status.schema.json +22 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,54 @@
1
+ # Changelog
2
+
3
+ All notable changes are recorded here. The format follows [Keep a Changelog](https://keepachangelog.com),
4
+ and the project uses [Semantic Versioning](https://semver.org) once it reaches 1.0.
5
+
6
+ ## [Unreleased]
7
+
8
+ ## [0.2.0] - 2026-11-27
9
+
10
+ ### Added
11
+
12
+ - Failed turn report: when a run ends in a model error, each message it left unanswered is
13
+ reported to the service (`failure` event, `ChannelAdapter.failure`, `service.paths.failures`,
14
+ `schema/failure.schema.json`). `failures.includeReason` controls the error text, which is
15
+ cleaned of known secret shapes.
16
+
17
+ ### Fixed
18
+
19
+ - The state stays `working` while Oh My Pi retries a request, instead of turning `free` between
20
+ attempts.
21
+
22
+ ## [0.1.0] - 2026-11-27
23
+
24
+ ### Changed
25
+
26
+ - Configuration errors name the unknown key, the allowed keys or values, and the allowed range.
27
+ A configuration file that is a JSON array is refused.
28
+ - `package.json` publishes with `provenance` and public access, ships the changelog, and builds
29
+ before packing.
30
+ - CI runs the pack check and a dependency audit; the release workflow has an opt-in npm publish job
31
+ that uses trusted publishing.
32
+ - Oh My Pi types now come from the exact devDependency `@oh-my-pi/pi-coding-agent@19.2.1`; the
33
+ hand-written declaration subset was removed.
34
+ - `attribution` is required on every message and has no configuration default. The example server
35
+ sends `"user"`. The effect of each value in Oh My Pi is not verified; see docs/protocol.md,
36
+ section 3.4.
37
+
38
+ ### Fixed
39
+
40
+ - The Oh My Pi check gives the extension a valid configuration. Before, the extension disabled
41
+ itself and the check never exercised it.
42
+ - The Oh My Pi check waits up to `OMP_E2E_TURN_TIMEOUT_MS` (default 600000 ms) for each turn, so a
43
+ slow local model is not reported as a failure.
44
+
45
+ ### Added
46
+
47
+ - `/channel-status` command: shows the transport in use and the optional `describe()` text of the
48
+ adapter (`ChannelAdapter`, docs/protocol.md section 6).
49
+ - Initial alpha: extension for Oh My Pi with MCP push, an HTTP transport with leases and
50
+ acknowledgements, a custom adapter module interface, a validated configuration file,
51
+ `reply` tool, agent status reports, and interrupt and close handling.
52
+ - Integration protocol version 1 (`docs/protocol.md`) with JSON Schemas in `schema/`.
53
+ - Oh My Pi verification script (`npm run omp:e2e`), opt-in: needs `OMP_E2E=1` and a model.
54
+ - Example MCP server (`examples/mcp-server`), example configuration and example adapter module.
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "{}"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright (C) 2014-present SheetJS LLC
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,8 @@
1
+ omp-channel
2
+ Copyright 2026 The omp-channel contributors
3
+
4
+ This product is licensed under the Apache License, Version 2.0 (see LICENSE).
5
+
6
+ This project is an independent extension. It is not affiliated with, endorsed by,
7
+ or sponsored by the Oh My Pi project. It loads into Oh My Pi through its public
8
+ extension mechanism and does not include any Oh My Pi source code.
package/README.md CHANGED
@@ -1,3 +1,319 @@
1
- # Temporary Holding Version
1
+ # omp-channel
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![CI](https://github.com/tommasomarchionni/omp-channel/actions/workflows/ci.yml/badge.svg)](https://github.com/tommasomarchionni/omp-channel/actions/workflows/ci.yml)
4
+
5
+ [![License: Apache-2.0](https://img.shields.io/badge/license-Apache--2.0-blue.svg)](LICENSE)
6
+ ![Node.js 20+](https://img.shields.io/badge/node-%3E%3D20-brightgreen.svg)
7
+
8
+ Documentation: <https://tommasomarchionni.github.io/omp-channel/>
9
+
10
+ **omp-channel** is an extension for [Oh My Pi](https://github.com/can1357/oh-my-pi) (OMP), a
11
+ terminal agent harness. It delivers messages from an external service (any system that exchanges messages
12
+ with a person) into an agent session, and sends the agent's replies
13
+ back to that service.
14
+
15
+ It is for people who run an agent in a terminal and want an outside service to be able to send
16
+ it work and receive the answers, including while the agent is busy. It is **not** a hosting
17
+ service, it contains **no models**, and it does **not** manage accounts. You provide the service
18
+ and the model; omp-channel is the link between them.
19
+
20
+ > **Status: alpha, version 0.2.0 on npm.** The behaviour is covered by automated tests that use fakes and
21
+ > a loopback HTTP service. Startup, delivery to an idle session, queueing during a turn and abort
22
+ > have passed in a live Oh My Pi session; the status report and the attribution values are not yet
23
+ > verified. See
24
+ > [docs/omp-verification.md](docs/omp-verification.md) for each check and what is open.
25
+
26
+ ## Contents
27
+
28
+ - [How it works](#how-it-works)
29
+ - [Connect a service in three steps](#connect-a-service-in-three-steps)
30
+ - [Complete example](#complete-example)
31
+ - [Configuration](#configuration)
32
+ - [Security](#security)
33
+ - [Compatibility](#compatibility)
34
+ - [Troubleshooting](#troubleshooting)
35
+ - [Development](#development)
36
+ - [Documentation](#documentation)
37
+ - [License](#license)
38
+
39
+ ## How it works
40
+
41
+ 1. A service has a message for the agent. omp-channel receives it, either by polling an HTTP
42
+ endpoint or from an MCP server that pushes it.
43
+ 2. The message is handed to the agent as a follow-up, so it waits until the current turn ends if
44
+ the agent is busy. The text is marked as data from an outside party.
45
+ 3. The agent answers with the `reply` tool, using the `messageId` of the message. omp-channel posts
46
+ the reply to the service.
47
+ 4. While a turn runs, omp-channel reports `working` to the service; when the turn ends, `free`.
48
+ 5. Delivery is at least once with acknowledgements, so a message is neither lost nor handled
49
+ twice when the extension restarts. Details are in [docs/protocol.md](docs/protocol.md).
50
+
51
+ One conversation is open at a time per agent session. A message for another conversation waits
52
+ until the open one is closed.
53
+
54
+ ## Connect a service in three steps
55
+
56
+ ### 0. Install the extension
57
+
58
+ ```sh
59
+ omp install omp-channel
60
+ ```
61
+
62
+ This installs the published package into Oh My Pi's plugin folder (`~/.omp/plugins`). The
63
+ extension then loads in every session: no `-e` flag and no path to set. Check it by starting a
64
+ session and running `/channel-status`: it shows the transport in use and, when an adapter is
65
+ configured, what the adapter reports.
66
+
67
+ The configuration file is read from `.omp/omp-channel.json` in the directory where Oh My Pi
68
+ starts, or from the path in `OMP_CHANNEL_CONFIG` when that variable is set. Without either, the
69
+ extension has no transport and only offers MCP push. The steps below write this file.
70
+
71
+ A service that needs its own protocol connects through an adapter module (section 6 of
72
+ [docs/protocol.md](docs/protocol.md)). Point `adapterModule` at it in the configuration file, and
73
+ give the adapter the environment it reads:
74
+
75
+ ```json
76
+ {
77
+ "mcpServer": "my-service",
78
+ "adapterModule": "/path/to/adapter.mjs",
79
+ "delivery": { "deliverAs": "followUp" }
80
+ }
81
+ ```
82
+
83
+ ### 1. Install from a clone (for development)
84
+
85
+ Use this only to change the extension itself. The steps below need the built `dist/index.js`:
86
+
87
+ ```sh
88
+ git clone https://github.com/tommasomarchionni/omp-channel.git
89
+ cd omp-channel
90
+ npm ci
91
+ npm run build
92
+ ```
93
+
94
+ Load the built file with the `-e` flag, as in the example below, instead of `omp install`.
95
+
96
+ ### 2. Choose how messages arrive
97
+
98
+ - **HTTP service (most integrations).** Set `service.url` in the configuration file. omp-channel
99
+ then polls `GET <url>/messages`, acknowledges with `POST <url>/messages/ack`, and posts replies
100
+ and status to `<url>/replies` and `<url>/status`. The service needs to implement those calls;
101
+ the contract is in [docs/protocol.md](docs/protocol.md). No code is needed.
102
+ - **MCP push (local tools and tests).** Run an MCP server that sends the notification
103
+ `notifications/omp/channel`. The example in [examples/mcp-server](examples/mcp-server) does this.
104
+ Messages pushed this way are not leased, so they are not redelivered if lost. Replies still need
105
+ an HTTP service or an adapter module.
106
+ - **Adapter module (custom protocol).** Point `adapterModule` at a JavaScript module that exports
107
+ a `ChannelAdapter`. See [examples/adapter-module](examples/adapter-module).
108
+
109
+ ### 3. Configure the URL and the key
110
+
111
+ The key is never written in the configuration file or in the code. The file names the
112
+ environment variable that holds it:
113
+
114
+ ```sh
115
+ export EXAMPLE_CHANNEL_KEY="replace-with-the-key-from-your-service"
116
+ ```
117
+
118
+ Or put the key in a file and name that file with the variable `<keyEnv>_FILE`, for example
119
+ `EXAMPLE_CHANNEL_KEY_FILE=/path/to/key`.
120
+
121
+ ## Complete example
122
+
123
+ This example uses a placeholder service (`chat.example.com`). Replace the URL and the key with
124
+ your own. It also includes a local MCP test message that needs no service.
125
+
126
+ **1. Configuration file** (`examples/config/omp-channel.json`, which you can copy):
127
+
128
+ ```json
129
+ {
130
+ "$schema": "../../schema/config.schema.json",
131
+ "mcpServer": "omp-channel",
132
+ "service": {
133
+ "url": "https://chat.example.com/api/omp-channel",
134
+ "keyEnv": "EXAMPLE_CHANNEL_KEY"
135
+ },
136
+ "delivery": {
137
+ "deliverAs": "followUp"
138
+ }
139
+ }
140
+ ```
141
+
142
+ **2. Environment:**
143
+
144
+ ```sh
145
+ export OMP_CHANNEL_CONFIG="$PWD/examples/config/omp-channel.json"
146
+ export EXAMPLE_CHANNEL_KEY="replace-with-your-key"
147
+ ```
148
+
149
+ **3. Start Oh My Pi with the extension:**
150
+
151
+ ```sh
152
+ omp -e "$PWD/dist/index.js"
153
+ ```
154
+
155
+ **4. Test message without any service.** Run the example MCP server by itself. It prints the
156
+ notification that it would push to the agent once the client sends `notifications/initialized`:
157
+
158
+ ```sh
159
+ printf '%s\n' \
160
+ '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{}}' \
161
+ '{"jsonrpc":"2.0","method":"notifications/initialized"}' \
162
+ | node examples/mcp-server/server.mjs
163
+ ```
164
+
165
+ The second line of output is the test message:
166
+
167
+ ```json
168
+ {
169
+ "jsonrpc": "2.0",
170
+ "method": "notifications/omp/channel",
171
+ "params": {
172
+ "type": "message",
173
+ "conversationId": "example-conversation",
174
+ "messageId": "example-1",
175
+ "sender": "example-user",
176
+ "text": "Hello from the example service.",
177
+ "sentAt": "..."
178
+ }
179
+ }
180
+ ```
181
+
182
+ To make Oh My Pi use the example server, add it to the MCP configuration of Oh My Pi. The exact
183
+ file and key depend on the Oh My Pi version; the entry runs `node` on the example file:
184
+
185
+ ```json
186
+ {
187
+ "mcpServers": {
188
+ "omp-channel": {
189
+ "command": "node",
190
+ "args": ["/absolute/path/to/omp-channel/examples/mcp-server/server.mjs"]
191
+ }
192
+ }
193
+ }
194
+ ```
195
+
196
+ The name `omp-channel` must equal `mcpServer` in the configuration file.
197
+
198
+ ## Configuration
199
+
200
+ Every message the service sends must carry `attribution` (`"user"` for text a person wrote,
201
+ `"agent"` for text another agent wrote). That value is passed to Oh My Pi unchanged. How Oh My Pi
202
+ records each value is still unverified; see [docs/protocol.md](docs/protocol.md), section 3.4.
203
+
204
+ The configuration file is read from `OMP_CHANNEL_CONFIG`, or from `.omp/omp-channel.json` in the
205
+ working directory when it exists. Without a file the defaults apply and nothing is connected: the
206
+ extension still receives MCP pushes, but replies are reported as not configured. The file is
207
+ validated against [schema/config.schema.json](schema/config.schema.json). An invalid file disables
208
+ the extension and writes the reason (with its path) to stderr.
209
+
210
+ | Key | Default | Meaning |
211
+ | -------------------------- | ---------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- |
212
+ | `mcpServer` | `"omp-channel"` | MCP server name that may push messages. |
213
+ | `service.url` | none | Base URL of the service. `https` required; `http` only for loopback. |
214
+ | `service.keyEnv` | `"OMP_CHANNEL_KEY"` | Environment variable holding the key (`<keyEnv>_FILE` for a file). Required with `service.url`. |
215
+ | `service.requestTimeoutMs` | `10000` | Timeout of each request. |
216
+ | `service.paths.*` | `/messages`, `/messages/ack`, `/replies`, `/status`, `/failures` | Endpoint paths. |
217
+ | `poll.intervalMs` | `2000` | Wait between polls when the queue is empty. |
218
+ | `poll.maxBackoffMs` | `30000` | Longest wait after failed polls. |
219
+ | `poll.batchSize` | `10` | Deliveries requested per poll. |
220
+ | `limits.maxTextLength` | `4000` | Longest message text, in characters. |
221
+ | `limits.maxSenderLength` | `64` | Longest sender name. |
222
+ | `limits.maxPending` | `5` | Events waiting to be admitted; more are dropped and not acknowledged. |
223
+ | `delivery.deliverAs` | `"followUp"` | How a message is queued in Oh My Pi: `steer`, `followUp` or `aside`. |
224
+ | `failures.includeReason` | `true` | Send the cleaned error text when a turn fails and leaves a message unanswered. |
225
+ | `adapterModule` | none | Path to a module that exports a `ChannelAdapter`. Replaces the HTTP transport. |
226
+
227
+ Environment variables:
228
+
229
+ | Variable | Meaning |
230
+ | ---------------------------------------------- | ------------------------------------------------------------------- |
231
+ | `OMP_CHANNEL_CONFIG` | Path of the configuration file. Must exist when set. |
232
+ | `<keyEnv>` (for example `EXAMPLE_CHANNEL_KEY`) | The service key. |
233
+ | `<keyEnv>_FILE` | Path of a file that holds the key, used when `<keyEnv>` is not set. |
234
+
235
+ ## Security
236
+
237
+ - **The key stays out of the model.** It is used only in HTTP headers. It is not in tool results,
238
+ prompts, logs or error messages. Error messages name the HTTP status or the error type only.
239
+ - **Inbound text is data.** Messages are wrapped in an envelope that tells the model the content
240
+ comes from an outside party and must not change its rules. Angle brackets are escaped so the
241
+ text cannot close the envelope.
242
+ - **Strict validation.** Events with unknown fields, invalid identifiers, control characters or
243
+ text over the limit are rejected before they reach the agent.
244
+ - **Transport.** `https` is required for the service. Plain `http` is accepted only for loopback
245
+ addresses, for local tests.
246
+ - **Replies are limited.** The `reply` tool accepts only a `messageId` that was delivered in the
247
+ current session.
248
+ - **Error text is cleaned.** When a turn fails, the error from the model provider is sent with
249
+ known secret shapes and the home folder name hidden. `failures.includeReason: false` keeps it on
250
+ the machine.
251
+
252
+ ## When a turn fails
253
+
254
+ If the model request fails (the model is not loaded, the key is refused, the service is down) the
255
+ service receives a `failure` report for each message that got no answer, so the person is not left
256
+ waiting. Oh My Pi retries some errors first; the report is sent only when it gives up. See
257
+ [docs/protocol.md](docs/protocol.md), section 9.
258
+
259
+ Report vulnerabilities privately, as described in [SECURITY.md](SECURITY.md).
260
+
261
+ ## Compatibility
262
+
263
+ | Component | Version | Status |
264
+ | ------------------ | --------------------- | --------------------------------------------------------------- |
265
+ | Node.js | 20 and 22 (CI matrix) | Tested in CI on both. `.nvmrc` pins 22 for development. |
266
+ | Oh My Pi | 19.2.1 | Starts and loads the extension. Delivery not yet verified live. |
267
+ | Bun (for Oh My Pi) | 1.4.4 or later | Required by Oh My Pi itself, not by omp-channel. |
268
+ | Protocol | 1 (alpha) | Fields may still change before 1.0; see the changelog. |
269
+
270
+ - The extension types come from the exact devDependency `@oh-my-pi/pi-coding-agent@19.2.1`. They
271
+ are imported, not copied. One gap is documented in `src/tool-schema.ts`: the tool parameters are
272
+ plain JSON Schema where Oh My Pi declares a TypeBox schema.
273
+ - **Verified in a live Oh My Pi session (19.2.1, local model):** startup, delivery of a pushed
274
+ message to an idle session, a message pushed during a turn (taken at a turn boundary, see
275
+ [docs/protocol.md](docs/protocol.md) section 3.5), abort, and the report of a refused model request.
276
+ - **Not verified yet:** the status report (`working`/`free`) to a service, and the effect of each
277
+ `attribution` value. See [docs/omp-verification.md](docs/omp-verification.md).
278
+ - `npm ci` also installs the Oh My Pi package for type checking; it is large.
279
+
280
+ ## Troubleshooting
281
+
282
+ The extension never stops Oh My Pi. When it cannot start it writes one line to stderr and stays
283
+ off:
284
+
285
+ | Message | Cause and fix |
286
+ | --------------------------------------------------------- | --------------------------------------------------------------------------------- |
287
+ | `disabled: invalid configuration: unknown key "x" at ...` | A key is misspelled. The message lists the allowed keys. |
288
+ | `disabled: ... must be one of: ...` | A value is not allowed. The message lists the allowed values. |
289
+ | `disabled: set <keyEnv> (or <keyEnv>_FILE) ...` | The key variable named in `service.keyEnv` is not set in the `omp` process. |
290
+ | `disabled: OMP_CHANNEL_CONFIG points to a file ...` | The path in `OMP_CHANNEL_CONFIG` does not exist. |
291
+ | `disabled: service.url must use https ...` | Use `https`, or a loopback address for local tests. |
292
+ | Messages arrive but replies fail | Without `service` or `adapterModule`, MCP pushes work but replies cannot be sent. |
293
+
294
+ ## Development
295
+
296
+ ```sh
297
+ npm ci
298
+ npm run check # typecheck, lint, format check and tests
299
+ npm run pack:check # list the files that would be published (publishes nothing)
300
+ npm run build # compile to dist/
301
+ OMP_E2E=1 OMP_E2E_MODEL=<provider/model> npm run omp:e2e # real Oh My Pi check, runs a model
302
+ ```
303
+
304
+ Single commands: `npm run typecheck`, `npm run lint`, `npm run format` (writes), `npm run
305
+ format:check`, `npm test`. Tests use the Node.js built-in test runner through `tsx`; see
306
+ [CONTRIBUTING.md](CONTRIBUTING.md).
307
+
308
+ ## Documentation
309
+
310
+ - [docs/protocol.md](docs/protocol.md): the integration contract, lease policy and decisions.
311
+ - [schema/](schema): JSON Schemas of the events, replies, status and configuration.
312
+ - [docs/omp-verification.md](docs/omp-verification.md): what was checked in a real session and what is open.
313
+ - [docs/releasing.md](docs/releasing.md): how a release is made.
314
+ - [CONTRIBUTING.md](CONTRIBUTING.md), [SECURITY.md](SECURITY.md), [SUPPORT.md](SUPPORT.md), [CHANGELOG.md](CHANGELOG.md).
315
+
316
+ ## License
317
+
318
+ Apache License 2.0. See [LICENSE](LICENSE) and [NOTICE](NOTICE). This project is independent and
319
+ is not affiliated with or endorsed by the Oh My Pi project.
@@ -0,0 +1,46 @@
1
+ import type { InboundEvent, OutboundFailure, OutboundReply, OutboundStatus } from "./protocol.js";
2
+ /** One event from a service, with the lease id that the service uses for acknowledgement. */
3
+ export interface Delivery {
4
+ /** Present when the transport leases deliveries (the HTTP transport does). */
5
+ readonly deliveryId?: string;
6
+ readonly event: InboundEvent;
7
+ }
8
+ /**
9
+ * Contract a service implements to connect to omp-channel from code (see docs/protocol.md).
10
+ * Only `receive` and `reply` are required. The others are optional hooks.
11
+ */
12
+ export interface ChannelAdapter {
13
+ /**
14
+ * Yields deliveries in the order the service sent them. The consumer awaits each one before
15
+ * asking for the next, so the order is kept. Stops when `signal` aborts.
16
+ */
17
+ receive(signal: AbortSignal): AsyncIterable<Delivery>;
18
+ /** Posts a reply. Throws when the service does not accept it. */
19
+ reply(reply: OutboundReply): Promise<void>;
20
+ /** Acknowledges a delivery once the agent has admitted it. Without it, the service may redeliver. */
21
+ ack?(deliveryId: string): Promise<void>;
22
+ /** Reports agent state for a conversation. Best effort. */
23
+ status?(status: OutboundStatus): Promise<void>;
24
+ /**
25
+ * Reports that a message got no answer because the turn ended in an error. Without it the
26
+ * service learns nothing and the message stays unanswered. Throws when it is not accepted.
27
+ */
28
+ failure?(failure: OutboundFailure): Promise<void>;
29
+ /** Tells the service that an interrupt was applied. Optional. */
30
+ interrupt?(conversationId: string): Promise<void>;
31
+ /** Tells the service that a conversation was closed on the agent side. Optional. */
32
+ close?(conversationId: string): Promise<void>;
33
+ /**
34
+ * A short plain-text description of the adapter's state, shown by the `/channel-status` command.
35
+ * It is for the person who runs the agent: it must not contain keys or message text. Optional.
36
+ */
37
+ describe?(): Promise<string> | string;
38
+ }
39
+ export declare function isChannelAdapter(value: unknown): value is ChannelAdapter;
40
+ /**
41
+ * Error raised by adapters. Its message is safe to show to the model or to log: it must never
42
+ * contain the service key, request bodies, or message text.
43
+ */
44
+ export declare class AdapterError extends Error {
45
+ constructor(message: string);
46
+ }
@@ -0,0 +1,18 @@
1
+ export function isChannelAdapter(value) {
2
+ if (typeof value !== "object" || value === null) {
3
+ return false;
4
+ }
5
+ const candidate = value;
6
+ return typeof candidate.receive === "function" && typeof candidate.reply === "function";
7
+ }
8
+ /**
9
+ * Error raised by adapters. Its message is safe to show to the model or to log: it must never
10
+ * contain the service key, request bodies, or message text.
11
+ */
12
+ export class AdapterError extends Error {
13
+ constructor(message) {
14
+ super(message);
15
+ this.name = "AdapterError";
16
+ }
17
+ }
18
+ //# sourceMappingURL=adapter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"adapter.js","sourceRoot":"","sources":["../src/adapter.ts"],"names":[],"mappings":"AAyCA,MAAM,UAAU,gBAAgB,CAAC,KAAc;IAC7C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAChD,OAAO,KAAK,CAAC;IACf,CAAC;IACD,MAAM,SAAS,GAAG,KAAgC,CAAC;IACnD,OAAO,OAAO,SAAS,CAAC,OAAO,KAAK,UAAU,IAAI,OAAO,SAAS,CAAC,KAAK,KAAK,UAAU,CAAC;AAC1F,CAAC;AAED;;;GAGG;AACH,MAAM,OAAO,YAAa,SAAQ,KAAK;IACrC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;IAC7B,CAAC;CACF"}