omp-channel 0.2.1 → 0.4.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.
package/docs/protocol.md CHANGED
@@ -19,6 +19,7 @@ The machine-readable schemas are in [`schema/`](https://github.com/tommasomarchi
19
19
  | `outbound-reply.schema.json` | a reply the agent posts to the service |
20
20
  | `status.schema.json` | agent state the agent reports to the service |
21
21
  | `failure.schema.json` | a turn that ended in an error and left a message unanswered |
22
+ | `activity.schema.json` | a tool the agent uses for a message (optional report) |
22
23
  | `config.schema.json` | the omp-channel configuration file |
23
24
 
24
25
  The TypeScript module `src/protocol.ts` implements the same rules. Both must change together.
@@ -57,16 +58,42 @@ are the defaults.
57
58
 
58
59
  ### 3.1 `message`
59
60
 
60
- | Field | Required | Type and limits | Meaning |
61
- | ---------------- | -------- | ---------------------------------------------------------------------------- | --------------------------------------------------------------------- |
62
- | `type` | yes | `"message"` | |
63
- | `conversationId` | yes | identifier | The conversation the message belongs to (section 5). |
64
- | `messageId` | yes | identifier | Unique id of this message. Used to reply and to deduplicate. |
65
- | `sender` | yes | string, 1 to 64 characters after cleanup | Display name. Control characters become spaces. |
66
- | `text` | yes | string, 1 to 4000 characters, no control characters except tab and line feed | The content. |
67
- | `sentAt` | no | ISO 8601 timestamp | Set by the service. Informational. |
68
- | `replyTo` | no | identifier | `messageId` of an earlier message this one answers. Informational. |
69
- | `attribution` | yes | `"user"` or `"agent"` | Who wrote the message. Passed to Oh My Pi unchanged. See section 3.4. |
61
+ | Field | Required | Type and limits | Meaning |
62
+ | ---------------- | -------- | ------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
63
+ | `type` | yes | `"message"` | |
64
+ | `conversationId` | yes | identifier | The conversation the message belongs to (section 5). |
65
+ | `messageId` | yes | identifier | Unique id of this message. Used to reply and to deduplicate. |
66
+ | `sender` | yes | string, 1 to 64 characters after cleanup | Display name. Control characters become spaces. |
67
+ | `text` | yes | string, 1 to 4000 characters, no control characters except tab and line feed | The content. |
68
+ | `sentAt` | no | ISO 8601 timestamp | Set by the service. Informational. |
69
+ | `replyTo` | no | identifier | `messageId` of an earlier message this one answers. Informational. |
70
+ | `attribution` | yes | `"user"` or `"agent"` | Who wrote the message. Passed to Oh My Pi unchanged. See section 3.4. |
71
+ | `context` | no | object: at most 8 keys; each key matches `^[a-z][a-z0-9_]{0,31}$`; each value is a string of at most 200 characters | Extra facts about the message. Shown to the model only for the keys in `context.include`. See below. |
72
+
73
+ **Context.** A service can send extra facts about a message (for example the page it was sent
74
+ from) without a change to omp-channel. The rules are checked when the event is parsed, and a message
75
+ that breaks one is rejected with the reason: more than 8 keys, a key that does not match the pattern,
76
+ a value that is not a string, or a `context` that is not an object. Inside a value, control
77
+ characters are removed (line feeds and tabs too), the value is trimmed, and a value still longer than
78
+ 200 characters is cut to 200 with a final ellipsis. A cut value is not an error. The schema asks senders
79
+ for values of at most 200 characters, so a sender that sends a longer one is accepted by the parser
80
+ but not by the schema.
81
+
82
+ The configuration decides what reaches the model: `context.include` lists the keys to show (default
83
+ `[]`, nothing is shown). A key that is listed and present is shown; a key that is not listed is
84
+ dropped silently; a listed key that the message does not carry is skipped. When at least one key is
85
+ shown, the message envelope gets a `channel-context` element before the body, with one attribute per
86
+ shown key, in the order of `context.include`. Values are escaped for attribute context (`&`, `<`,
87
+ `>`, `"`, `'`), so a value cannot close the element or the envelope. The body keeps its escaping, and
88
+ the sentence that marks the content as data is unchanged. With no shown key, the text is the same as
89
+ without `context`.
90
+
91
+ ```text
92
+ <channel-message messageId="m-1">
93
+ <channel-context route="/pricing" title="Prices"></channel-context>
94
+ What does a listener pay?
95
+ </channel-message>
96
+ ```
70
97
 
71
98
  ### 3.2 `interrupt`
72
99
 
@@ -130,6 +157,7 @@ Paths are relative to `service.url` and configurable in `service.paths`. Default
130
157
  | Reply | `POST /replies` | outbound reply (section 7) |
131
158
  | Status | `POST /status` | agent status (section 8) |
132
159
  | Failure | `POST /failures` | failed turn (section 9) |
160
+ | Activity | no default path | activity (section 10) |
133
161
 
134
162
  All calls carry `Authorization: Bearer <key>`. A non-2xx answer is an error. The key is never
135
163
  included in a log line, an error message or a tool result.
@@ -216,6 +244,7 @@ interface ChannelAdapter {
216
244
  ack?(deliveryId: string): Promise<void>; // after admission
217
245
  status?(status: OutboundStatus): Promise<void>; // best effort
218
246
  failure?(failure: OutboundFailure): Promise<void>; // a message got no answer (section 9)
247
+ activity?(activity: OutboundActivity): Promise<void>; // a tool in use (section 10)
219
248
  interrupt?(conversationId: string): Promise<void>; // after an interrupt is applied
220
249
  close?(conversationId: string): Promise<void>; // after a close is applied
221
250
  describe?(): Promise<string> | string; // plain-text state for the /channel-status command
@@ -316,11 +345,64 @@ The `failure` event:
316
345
  - A transport without the `failure` hook only logs the event. Over MCP push there is no way back
317
346
  to the service, so nothing is sent.
318
347
 
319
- ## 10. Activity (optional, not emitted in version 1)
348
+ ## 10. Activity (optional)
349
+
350
+ While the agent works on a message, omp-channel can tell the service which tools it uses: one
351
+ report when a tool starts and one when it ends. A service must not require these reports.
352
+
353
+ ```json
354
+ {
355
+ "type": "activity",
356
+ "conversationId": "c1",
357
+ "messageId": "a-9d02c7e4",
358
+ "replyTo": "m1",
359
+ "activityId": "t-51be",
360
+ "state": "running",
361
+ "text": "read: Reading the server log",
362
+ "at": "2026-11-26T10:00:00.000Z"
363
+ }
364
+ ```
320
365
 
321
- The protocol reserves an optional `activity` report (for example, a tool started or finished)
322
- for showing progress to the service. Version 1 of omp-channel does not emit it. A service must
323
- not require it.
366
+ | Field | Meaning |
367
+ | ------------ | -------------------------------------------------------------------------------- |
368
+ | `messageId` | Generated by the agent for each report. |
369
+ | `replyTo` | The `messageId` of the inbound message the agent is working on. |
370
+ | `activityId` | The same for the two reports about one use of a tool. Generated by the agent. |
371
+ | `state` | `running` when the tool starts, then `done` or `failed`. |
372
+ | `text` | The tool name, then `: ` and the intent of the call when there is one. One line. |
373
+
374
+ **When they are sent.** Only when both are true: `reports.activity` is not `false` (it is `true` by
375
+ default), and the transport takes the report. Over HTTP the path `service.paths.activity` has no
376
+ default, so a service that does not configure it receives no new request. A custom adapter takes
377
+ the reports when it has the `activity` method. MCP push has no way back, so nothing is sent.
378
+
379
+ **What a report holds.** The tool name and the intent that Oh My Pi states for the call. Oh My Pi
380
+ 19.2.1 asks the model for intents in its terminal interface by default, and not in print, RPC, ACP
381
+ or SDK processes unless its setting `tools.intentTracing` is on: without an intent the line is the
382
+ tool name alone. The arguments and the result of the tool are never sent. The intent is free text written by the model,
383
+ and some tools build it from their arguments, so before sending:
384
+
385
+ - every argument value quoted in it as whole words (4 characters or more) is replaced with `…`;
386
+ - common shapes of secrets and the home folder name are hidden (`[hidden]`), as in section 9;
387
+ - words that look like a path or an address become `[path]`;
388
+ - the line is cut at 240 characters.
389
+
390
+ These are known shapes and exact quotes, not a guarantee: an intent can still describe a command or
391
+ name a file in its own words. `reports.activity: false` keeps all of it on the machine.
392
+
393
+ **Which message.** The newest unanswered message among those of the last prompt that carried one.
394
+ A prompt typed at the terminal ends it: the tools used for that prompt are not reported. Switching
395
+ to another session ends it too. The `reply` tool is not reported.
396
+
397
+ **Limits.** At most 200 tool uses for one message. Reports leave one at a time, in order. At most
398
+ 100 wait to be sent; more are dropped. A report that takes more than 5 seconds counts as refused.
399
+ A refused report is not sent again, and is logged once until a report is accepted. The agent never
400
+ waits for a report, except that a reply or a failure report waits up to 1 second for the reports
401
+ made before it.
402
+
403
+ **What a service can count on.** Delivery is best effort: a report can be missing, either of the
404
+ two. Nothing is sent about a message after its reply or failure report. A use still `running` when
405
+ that arrives has ended without a known outcome.
324
406
 
325
407
  ## 11. Security rules
326
408
 
@@ -334,6 +416,8 @@ not require it.
334
416
  says so, and angle brackets are escaped so the text cannot close the envelope.
335
417
  - Inbound events are validated before use. Unknown fields and out-of-range values are rejected.
336
418
  - The error text of a failed turn is cleaned of known secret shapes before it is sent (section 9).
419
+ - An activity report holds the tool name and the cleaned intent only, never arguments or results
420
+ (section 10).
337
421
 
338
422
  ## 12. Versioning
339
423
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omp-channel",
3
- "version": "0.2.1",
3
+ "version": "0.4.0",
4
4
  "description": "Oh My Pi extension that delivers messages from an external console into an agent session and sends replies back.",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
@@ -0,0 +1,50 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://example.com/omp-channel/schema/activity.schema.json",
4
+ "title": "Activity (agent to service)",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "type",
9
+ "conversationId",
10
+ "messageId",
11
+ "replyTo",
12
+ "activityId",
13
+ "state",
14
+ "text",
15
+ "at"
16
+ ],
17
+ "properties": {
18
+ "type": { "const": "activity" },
19
+ "conversationId": {
20
+ "type": "string",
21
+ "minLength": 1,
22
+ "maxLength": 128,
23
+ "pattern": "^[A-Za-z0-9._:-]+$"
24
+ },
25
+ "messageId": {
26
+ "type": "string",
27
+ "minLength": 1,
28
+ "maxLength": 128,
29
+ "pattern": "^[A-Za-z0-9._:-]+$"
30
+ },
31
+ "replyTo": {
32
+ "type": "string",
33
+ "minLength": 1,
34
+ "maxLength": 128,
35
+ "pattern": "^[A-Za-z0-9._:-]+$"
36
+ },
37
+ "activityId": {
38
+ "type": "string",
39
+ "minLength": 1,
40
+ "maxLength": 128,
41
+ "pattern": "^[A-Za-z0-9._:-]+$"
42
+ },
43
+ "state": { "type": "string", "enum": ["running", "done", "failed"] },
44
+ "text": { "type": "string", "minLength": 1, "maxLength": 240 },
45
+ "at": {
46
+ "type": "string",
47
+ "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(Z|[+-]\\d{2}:\\d{2})$"
48
+ }
49
+ }
50
+ }
@@ -67,6 +67,11 @@
67
67
  "type": "string",
68
68
  "pattern": "^/",
69
69
  "default": "/failures"
70
+ },
71
+ "activity": {
72
+ "description": "Where activity reports are posted. No default: without it none are sent.",
73
+ "type": "string",
74
+ "pattern": "^/"
70
75
  }
71
76
  },
72
77
  "default": {}
@@ -162,6 +167,37 @@
162
167
  },
163
168
  "default": {}
164
169
  },
170
+ "reports": {
171
+ "description": "Optional reports about the work on a message.",
172
+ "type": "object",
173
+ "additionalProperties": false,
174
+ "properties": {
175
+ "activity": {
176
+ "description": "Report the tools used for a message (name and intent, never arguments or results), when the transport takes it.",
177
+ "type": "boolean",
178
+ "default": true
179
+ }
180
+ },
181
+ "default": {}
182
+ },
183
+ "context": {
184
+ "description": "Extra facts of a message (the context object of the inbound event). The model sees only the keys listed here, and only when the message has them.",
185
+ "type": "object",
186
+ "additionalProperties": false,
187
+ "properties": {
188
+ "include": {
189
+ "description": "Keys of the message context to show to the model, as data inside the message envelope. Keys not listed are not shown.",
190
+ "type": "array",
191
+ "uniqueItems": true,
192
+ "items": {
193
+ "type": "string",
194
+ "pattern": "^[a-z][a-z0-9_]{0,31}$"
195
+ },
196
+ "default": []
197
+ }
198
+ },
199
+ "default": {}
200
+ },
165
201
  "adapterModule": {
166
202
  "description": "Path (relative to the working directory) of a JavaScript module whose default export implements ChannelAdapter. Replaces the HTTP service transport.",
167
203
  "type": "string",
@@ -47,6 +47,18 @@
47
47
  "attribution": {
48
48
  "type": "string",
49
49
  "enum": ["user", "agent"]
50
+ },
51
+ "context": {
52
+ "description": "Extra facts about the message, shown to the model only for the keys listed in context.include. Values longer than 200 characters are cut by omp-channel.",
53
+ "type": "object",
54
+ "additionalProperties": false,
55
+ "maxProperties": 8,
56
+ "patternProperties": {
57
+ "^[a-z][a-z0-9_]{0,31}$": {
58
+ "type": "string",
59
+ "maxLength": 200
60
+ }
61
+ }
50
62
  }
51
63
  }
52
64
  },