@theokit/gateway 0.7.0 → 0.7.1
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 +25 -0
- package/README.md +36 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,30 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 29e2e28: The seam between the three repositories is documented, and the reason given for one contract was corrected.
|
|
8
|
+
|
|
9
|
+
`@theokit/gateway`'s README — the npm page — now says which repository owns which half: TheoKit the
|
|
10
|
+
HTTP route and the signature check, these packages the translation of the payload it hands over, the
|
|
11
|
+
SDK one redaction helper. A `quality:integration-story` gate fails when that disappears and passes
|
|
12
|
+
when the prose is rewritten around the same facts.
|
|
13
|
+
|
|
14
|
+
Both adapters' published docblocks stated that a TheoKit app's `onMessage` runs AFTER the 200 is
|
|
15
|
+
answered, so a throw there had no status left to change. Measured against `theokit@0.48.14`,
|
|
16
|
+
`handleChannelWebhook` awaits `onMessage` BEFORE building the response and catches nothing around
|
|
17
|
+
it: a throw means the 200 is never built, and mounted in a TheoKit route the rejection reaches that
|
|
18
|
+
route's error boundary and is answered 500 where the platform expected an acknowledgement. `parseInbound` returning `null`
|
|
19
|
+
is unchanged and still the right contract — only the stated reason was wrong, and it was reaching
|
|
20
|
+
users through the `.d.ts` on hover.
|
|
21
|
+
|
|
22
|
+
`@theokit/gateway-sms`'s docblocks also named the wrong seam. Its `parseInbound` is
|
|
23
|
+
`(options, ctx)`, and the `SignatureContext` it needs carries the raw body, the headers and the URL
|
|
24
|
+
— none of which TheoKit's `ChannelMessage` provides, so the signature check cannot be performed
|
|
25
|
+
from inside `onMessage` for any provider. SMS goes through its own `createWebhookServer`, and the
|
|
26
|
+
published `.d.ts` says so now instead of claiming to be the gateway half of the channel seam.
|
|
27
|
+
|
|
3
28
|
## 0.7.0
|
|
4
29
|
|
|
5
30
|
### Minor Changes
|
package/README.md
CHANGED
|
@@ -50,6 +50,42 @@ const runner = new GatewayRunner({
|
|
|
50
50
|
await runner.start();
|
|
51
51
|
```
|
|
52
52
|
|
|
53
|
+
## Receiving from a TheoKit app
|
|
54
|
+
|
|
55
|
+
Three repositories share this path. `theokit` owns the HTTP route and the signature check —
|
|
56
|
+
`handleChannelWebhook` verifies the signature, parses the body, and hands your app the parsed JSON
|
|
57
|
+
as `payload: unknown`. These packages own the translation. `theokit-sdk` is used here for one thing
|
|
58
|
+
today: redacting a throw before it reaches a log, at two call sites.
|
|
59
|
+
|
|
60
|
+
```ts
|
|
61
|
+
import { parseInbound } from "@theokit/gateway-telegram";
|
|
62
|
+
|
|
63
|
+
// Inside onMessage. The signature and the JSON parse already happened.
|
|
64
|
+
const event = parseInbound(message.payload);
|
|
65
|
+
if (event !== null) {
|
|
66
|
+
console.log(`${event.platform} ${event.channel.id}: ${event.text}`);
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`parseInbound` returns `null` rather than throwing for a body it does not recognise. Measured
|
|
71
|
+
against `theokit@0.48.14`: `onMessage` is
|
|
72
|
+
awaited **before** the 200 is built, and nothing inside `handleChannelWebhook` catches — so a throw
|
|
73
|
+
on an unparseable payload means the 200 is never built. Mounted in a TheoKit route, the rejection
|
|
74
|
+
reaches that route's error boundary and is answered **500**: the platform sees a failed delivery
|
|
75
|
+
where it expected an acknowledgement.
|
|
76
|
+
|
|
77
|
+
`parseInbound` under that name exists on `@theokit/gateway-telegram` and `@theokit/gateway-sms`,
|
|
78
|
+
with different arguments: SMS takes `(options, ctx)` because the `SignatureContext` it needs carries
|
|
79
|
+
the raw body, the headers and the URL, and `ChannelMessage` provides none of the three — so it is wired through its
|
|
80
|
+
own `createWebhookServer` rather than this seam.
|
|
81
|
+
Every other adapter exports its translation under its own name — `gateway-line` has
|
|
82
|
+
`lineEventToMessageEvent`, `gateway-whatsapp` composes `parseWebhookPayload` with
|
|
83
|
+
`normalizeInboundMessages` — each with its own signature: read the one you are using rather than
|
|
84
|
+
assuming this one's.
|
|
85
|
+
|
|
86
|
+
Adapters whose transport is a long-lived connection rather than a webhook own that transport and do
|
|
87
|
+
not go through this seam.
|
|
88
|
+
|
|
53
89
|
## Design principles
|
|
54
90
|
|
|
55
91
|
- **Compose, don't reimplement.** The gateway never owns session persistence (SDK does), never owns scheduling (Cron does), never owns prompt resolution (SystemPromptResolver does).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@theokit/gateway",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Multi-platform messaging gateway core for @theokit/sdk — transport-agnostic primitives (BasePlatformAdapter, MessageEvent, SessionRouter, DeliveryRouter, GatewayRunner, hooks). Inspired by hermes-agent/gateway. ADRs D170-D181.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|