@mercury-fw/channel-http 0.13.0 → 0.13.2

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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # @mercury-fw/channel-http
2
2
 
3
+ ## 0.13.2
4
+
5
+ ### Patch Changes
6
+
7
+ - 1e7fdeb: - `POST /turn { resume: true }` with nothing left to resume streams a single `final` whose text says the answer is no longer available, instead of an empty one, which a UI shows like any answer; an empty `final` now always means the model had nothing to add.
8
+ - Needs the framework at 0.61 or later (peer range raised).
9
+
10
+ ## 0.13.1
11
+
12
+ ### Patch Changes
13
+
14
+ - f631dd5: README: a link to the package's page on Mercury's documentation site (https://lucabro81.github.io/mercury-fw/), published from this release on. The HTTP channel's README points to the HTTP API reference there, and the core's memory section to the page that explains it.
15
+
3
16
  ## 0.13.0
4
17
 
5
18
  ### Minor Changes
package/README.md CHANGED
@@ -2,7 +2,9 @@
2
2
 
3
3
  Gives a [Mercury](https://github.com/lucabro81/mercury-fw) agent an HTTP surface to build a custom UI on: one conversational turn per request, streamed back as Server-Sent Events, plus confirmation and read-only routes over what the agent holds (conversations, the wiki, memory, its plugins).
4
4
 
5
- This version is written for version 6 of the channel contract, the one that brings the channels' texts in the person's language, and needs the framework at 0.59 or later, the first whose core gives channels its version (`GET /version`). A core with an older contract skips it, and the log says why.
5
+ On Mercury's documentation site: [its page](https://lucabro81.github.io/mercury-fw/plugins/channel-http/).
6
+
7
+ This version is written for version 6 of the channel contract, the one that brings the channels' texts in the person's language, and needs the framework at 0.61 or later, the first whose core says when a resumed turn's answer is no longer available (`resume` below); since 0.59 the core gives channels its version (`GET /version`). A core with an older contract skips it, and the log says why.
6
8
 
7
9
  ```bash
8
10
  bun add @mercury-fw/channel-http
@@ -35,7 +37,7 @@ It's active whenever it's declared in `mercury.config.ts`'s `channels` with an a
35
37
 
36
38
  **CORS** is enabled on every response and every route answers an `OPTIONS` preflight, so a browser UI on another origin can call it. The allowed origin is `HTTP_SURFACE_CORS_ORIGIN` (default `*`: the token travels in a header, never in a cookie the browser would send on its own).
37
39
 
38
- The full contract is described by an **OpenAPI document**, served raw at `GET /openapi.yaml` and published as a rendered docs page on GitHub Pages (see `packages/channels/channel-http/openapi.yaml`, the single source of truth).
40
+ The full contract is described by an **OpenAPI document**, served raw at `GET /openapi.yaml` and published as [the HTTP API reference](https://lucabro81.github.io/mercury-fw/reference/http-api/) on the documentation site (see `packages/channels/channel-http/openapi.yaml`, the single source of truth).
39
41
 
40
42
  All responses are JSON except `POST /turn`, which streams `text/event-stream`. Every JSON response is either `{ "ok": true, ... }` or, on error, `{ "ok": false, "error": "<message>" }` with HTTP `400`/`401`/`500`.
41
43
 
@@ -49,7 +51,7 @@ Runs one conversational turn; the reply streams back as Server-Sent Events.
49
51
  |---|---|---|---|
50
52
  | `text` | string | yes, unless `opening` or `resume` | The user message. A bare confirmation token here confirms a staged action (see the `pending` event) without invoking the model; when the action hands its result back to the model, the model's answer streams on this same request. |
51
53
  | `opening` | `true` | no | The assistant speaks first, before the person writes anything: what a UI asks right after someone signs in, when `GET /me` says the assistant doesn't know their name. It introduces itself and asks how to call them, and saves the answer once they give it. For someone it already knows, the stream is a single `final` with an empty text. Needs `conversationId`; `text` is ignored. |
52
- | `resume` | `true` | no | The turn a `POST /confirm` answered `resume: true` for: the model answers on what the confirmed action handed back. Needs `conversationId`; `text` is ignored. With nothing to resume, the stream is a single `final` with an empty text. |
54
+ | `resume` | `true` | no | The turn a `POST /confirm` answered `resume: true` for: the model answers on what the confirmed action handed back. Needs `conversationId`; `text` is ignored. With nothing left to resume (more than five minutes after the confirmation, a restart in between, or a turn already resumed), the stream is a single `final` whose text says the answer is no longer available, in the person's language. |
53
55
  | `conversationId` | string | no | Opaque, client-owned id that continues one of your conversations: letters, digits, `-` and `_`, up to 128 characters (a UUID fits) once surrounding whitespace is trimmed, `400` otherwise. Sent again, however long after, it continues that conversation, rebuilt from the archive if Mercury had freed it (see `HTTP_SURFACE_RESUME_MAX_CHARS`). Omitted ⇒ a fresh one-off session that can't be continued. |
54
56
 
55
57
  **Responses**: `200 text/event-stream` (the events below); `400` if `text` is missing, an opening has no `conversationId`, the body isn't JSON, or `conversationId` has other characters than the ones above.
@@ -47,9 +47,9 @@ export type TurnRequestDeps = {
47
47
  };
48
48
  /**
49
49
  * Serves the OpenAPI document that describes this surface — the single source
50
- * of truth in this package's `openapi.yaml`, also rendered as the GitHub Pages
51
- * API docs. Served raw as `text/yaml` (no YAML parser needed at runtime); most
52
- * tooling (Redoc, Swagger UI, Postman) reads YAML directly.
50
+ * of truth in this package's `openapi.yaml`, also rendered as the docs site's
51
+ * HTTP API reference. Served raw as `text/yaml` (no YAML parser needed at
52
+ * runtime); most tooling (Redoc, Swagger UI, Postman) reads YAML directly.
53
53
  */
54
54
  export declare function openApiResponse(corsOrigin?: string): Response;
55
55
  /**
package/http-server.ts CHANGED
@@ -153,9 +153,9 @@ function preflight(origin: string): Response {
153
153
 
154
154
  /**
155
155
  * Serves the OpenAPI document that describes this surface — the single source
156
- * of truth in this package's `openapi.yaml`, also rendered as the GitHub Pages
157
- * API docs. Served raw as `text/yaml` (no YAML parser needed at runtime); most
158
- * tooling (Redoc, Swagger UI, Postman) reads YAML directly.
156
+ * of truth in this package's `openapi.yaml`, also rendered as the docs site's
157
+ * HTTP API reference. Served raw as `text/yaml` (no YAML parser needed at
158
+ * runtime); most tooling (Redoc, Swagger UI, Postman) reads YAML directly.
159
159
  */
160
160
  export function openApiResponse(corsOrigin = "*"): Response {
161
161
  const file = Bun.file(new URL("./openapi.yaml", import.meta.url));
package/openapi.yaml CHANGED
@@ -80,7 +80,9 @@ info:
80
80
  (a page read after the caller allowed it, for example). Confirming one by
81
81
  `POST /turn` streams the model's answer on that same stream; `POST /confirm`
82
82
  answers `resume: true`, and the client then opens
83
- `POST /turn { resume: true, conversationId }` to hear it.
83
+ `POST /turn { resume: true, conversationId }` to hear it. The answer waits
84
+ five minutes and is heard once: later, after a restart, or a second time,
85
+ that `final`'s text says it's no longer available.
84
86
  security:
85
87
  - bearerAuth: []
86
88
  servers:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mercury-fw/channel-http",
3
- "version": "0.13.0",
3
+ "version": "0.13.2",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -18,11 +18,11 @@
18
18
  "access": "public"
19
19
  },
20
20
  "peerDependencies": {
21
- "@mercury-fw/channel-types": ">=0.59.0 <1.0.0"
21
+ "@mercury-fw/channel-types": ">=0.61.0 <1.0.0"
22
22
  },
23
23
  "devDependencies": {
24
- "@mercury-fw/channel-types": "0.59.0",
25
- "@mercury-fw/plugin-types": "0.59.0",
24
+ "@mercury-fw/channel-types": "0.61.0",
25
+ "@mercury-fw/plugin-types": "0.61.0",
26
26
  "@mercury-fw/typescript-config": "*",
27
27
  "@types/bun": "^1.4.2",
28
28
  "typescript": "^6.0.3"