@origonai/web-sdk 0.1.0 → 0.1.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/README.md +55 -10
- package/dist/index.d.ts +90 -10
- package/dist/origon-web-sdk.js +1310 -1046
- package/dist/origon-web-sdk.js.map +1 -1
- package/docs/contract.md +59 -0
- package/docs/new-chat-protocol.md +21 -3
- package/package.json +1 -1
package/docs/contract.md
CHANGED
|
@@ -38,6 +38,65 @@ Run typecheck, unit tests, and the production build, then rebuild the linked
|
|
|
38
38
|
`workspace/web/chat` consumer before publication. Publishing to npm remains an
|
|
39
39
|
owner action and is never part of an implementation spin.
|
|
40
40
|
|
|
41
|
+
## Live-chat monitoring LCM-2 hardcut candidate
|
|
42
|
+
|
|
43
|
+
- The unpublished candidate is generated from workspace wave base
|
|
44
|
+
`a7a731d62cc938f8221d3749cbf7b05474f0f9b4` plus the coordinated dirty
|
|
45
|
+
LCM-2 proto/golden inputs by
|
|
46
|
+
`web/kit/scripts/ship-orpc.sh`; `src/orpc-gen/PROVENANCE` pins the candidate
|
|
47
|
+
proto and both golden-fixture hashes. It remains unpublished and is consumed
|
|
48
|
+
only through the exact local links recorded in the workspace artifact ledger;
|
|
49
|
+
monitoring endpoint/lifecycle activation remains LCM-3.
|
|
50
|
+
- `Message.metadata` and `TypingEvent.metadata` are required server outputs,
|
|
51
|
+
with audience exactly `internal|all`; missing or unknown output metadata fails
|
|
52
|
+
closed. Current ordinary calls inject `all`. CX additionally accepts an
|
|
53
|
+
omitted `MessageRequest.metadata` or `TypingRequest.metadata` only from an
|
|
54
|
+
authenticated participant-purpose legacy client and normalizes it to `all`;
|
|
55
|
+
monitor-purpose omission remains invalid.
|
|
56
|
+
- `onTyping` receives exactly `{participantId, role, userId, userName, state,
|
|
57
|
+
metadata}`. Inbound watchdogs are participant-keyed; one participant's off
|
|
58
|
+
or message cannot clear an unrelated participant.
|
|
59
|
+
|
|
60
|
+
## Authenticated attachment lane
|
|
61
|
+
|
|
62
|
+
- `Credentials.attachmentBaseUrl` is the only lane selector. It accepts an
|
|
63
|
+
HTTP(S) absolute or root-relative base only when its resolved origin exactly
|
|
64
|
+
matches `Credentials.endpoint`; credentials, query, fragment, raw/encoded/
|
|
65
|
+
backslash traversal, malformed encodings, and cross-origin inputs fail during
|
|
66
|
+
`initialize()` before network.
|
|
67
|
+
- Selecting this authenticated lane requires the otherwise-optional top-level
|
|
68
|
+
token; omission fails during `initialize()`.
|
|
69
|
+
- When the explicit base is present, XHR upload and fetch delete send the
|
|
70
|
+
existing top-level token as `Authorization: Bearer …`. When it is absent, the
|
|
71
|
+
widget endpoint lane suppresses the token even if one was supplied for other
|
|
72
|
+
APIs. Error surfaces redact the bearer.
|
|
73
|
+
- Upload progress, cancellation-by-upload-id, and delete behavior are shared by
|
|
74
|
+
both lanes. An upload response may omit `Attachment.url`; the canonical chat
|
|
75
|
+
message echo is the first required server-URL carrier.
|
|
76
|
+
|
|
77
|
+
## Provisioned chat recovery
|
|
78
|
+
|
|
79
|
+
- `joinSession({channel:'chat', ..., chat:{recovery}})` is the only provisioned
|
|
80
|
+
recovery opt-in. `recovery` requires `replay:'server'`, an explicit 1–8 entry
|
|
81
|
+
finite non-negative `delaysMs` schedule, and caller-owned `reauthorize`.
|
|
82
|
+
- Recoverable transport error, clean FIN, `stream_overflow`, and an
|
|
83
|
+
unauthenticated Attach serialize through that callback. Every invocation
|
|
84
|
+
carries the original `sessionId`, one-based attempt, monotonic generation,
|
|
85
|
+
and cause. A successful result must be a fresh `{sessionId,url,token}` for
|
|
86
|
+
that exact same session; a changed id, empty credential, or late generation
|
|
87
|
+
fails closed and is never attached.
|
|
88
|
+
- `reauthorize` owns the authenticated monitor start request. The SDK never
|
|
89
|
+
calls visitor `POST /session/start` or `GET /session/:id` in provisioned
|
|
90
|
+
recovery. Attach is the authoritative full server replay; existing message
|
|
91
|
+
ids dedupe replay/live overlap while preserving stream order.
|
|
92
|
+
- A callback may return `{terminal:'ended'|'revoked'|'removed'|'capacity'}`.
|
|
93
|
+
These, terminal Attach refusals, and exhausted schedules stop recovery.
|
|
94
|
+
Participant/audience typing watchdogs clear independently at each transport
|
|
95
|
+
boundary and terminal. Leave is sent only for a live Attach; after an in-band
|
|
96
|
+
`sessionEnded`, local close emits no Leave.
|
|
97
|
+
- Omitting `chat.recovery` preserves ordinary visitor behavior exactly,
|
|
98
|
+
including overflow history reconciliation and same-id visitor re-mint.
|
|
99
|
+
|
|
41
100
|
## Provisioned receive-only voice join
|
|
42
101
|
|
|
43
102
|
The active in-workspace consumer is `workspace/web/cx` Insights Live. Its
|
|
@@ -12,8 +12,8 @@ arms that descriptor carries.
|
|
|
12
12
|
| Direction | RPC (`chat.v1.Session/…`) | Payload |
|
|
13
13
|
|-----------|-------------------------------|---------|
|
|
14
14
|
| attach | `Attach` (server-streaming) | initial `AttachResponse {participantId, role}`, then one `ChatEvent` per frame |
|
|
15
|
-
| send | `Message` (unary) | `MessageRequest {clientMessageId, text?, html?, attachments, value?, galleryLabel
|
|
16
|
-
| typing | `Typing` (unary) | `TypingRequest {state: "on"\|"off"}` |
|
|
15
|
+
| send | `Message` (unary) | `MessageRequest {clientMessageId, text?, html?, attachments, value?, galleryLabel?, metadata:{audience}}` → the canonical `Message` echo |
|
|
16
|
+
| typing | `Typing` (unary) | `TypingRequest {state: "on"\|"off", metadata:{audience}}` |
|
|
17
17
|
| leave | `Leave` (unary) | empty; immediate server-side finalize |
|
|
18
18
|
|
|
19
19
|
`ChatEvent` is a oneof: `message`, `typing`, `participant_joined`,
|
|
@@ -22,6 +22,21 @@ arms that descriptor carries.
|
|
|
22
22
|
it does not know — is consumed and dropped. That tolerance is the
|
|
23
23
|
forward-compat contract.
|
|
24
24
|
|
|
25
|
+
The live-monitoring metadata is a deliberate hardcut: every `Message`,
|
|
26
|
+
`MessageRequest`, `TypingRequest`, and `TypingEvent` carries audience
|
|
27
|
+
`internal|all`. Missing/unknown audience fails closed. Ordinary visitor sends
|
|
28
|
+
inject `all`; monitor callers can select `internal`. The public typing callback
|
|
29
|
+
is the participant-aware `{participantId, role, userId, userName, state,
|
|
30
|
+
metadata}` object, and watchdog state is keyed by participant.
|
|
31
|
+
|
|
32
|
+
Provisioned monitor recovery is an SDK control seam, not a new wire arm. With
|
|
33
|
+
`joinSession(... chat.recovery)`, transport error/FIN/overflow triggers a
|
|
34
|
+
caller-owned reauthorization request followed by a fresh Attach. Attach replays
|
|
35
|
+
the authoritative full transcript; the client never substitutes visitor
|
|
36
|
+
history/start APIs. Existing message ids dedupe replay/live overlap, while the
|
|
37
|
+
stream retains canonical sequence order. Ordinary visitor overflow recovery is
|
|
38
|
+
unchanged.
|
|
39
|
+
|
|
25
40
|
## The extension rule: proto arms first
|
|
26
41
|
|
|
27
42
|
**A chat feature does not exist until it has a proto arm.** The path for
|
|
@@ -80,7 +95,7 @@ default). Mapping vs. the legacy chat-sdk:
|
|
|
80
95
|
`sendMessage`'s wire carrier is `MessageRequest`:
|
|
81
96
|
`clientMessageId` (SDK-minted idempotency key), `text`, `html`,
|
|
82
97
|
`attachments` (ids/names only — URLs are server-assigned on the echo),
|
|
83
|
-
`value`, `galleryLabel`. The public payload surface also accepts the local
|
|
98
|
+
`value`, `galleryLabel`, and required `metadata`. The public payload surface also accepts the local
|
|
84
99
|
typed `buttonReply {value,label?}` adapter and maps it to those two top-level
|
|
85
100
|
wire fields; the nested adapter never rides ORPC. Two other local-only fields
|
|
86
101
|
are stripped before send: `role` (the provisional-row hint) and
|
|
@@ -89,3 +104,6 @@ SSE-era fields with no wire carrier (`type`/`results`/`meta`/`context`/
|
|
|
89
104
|
`createSystem`/`mode`) were deleted with 0.5.0 (owner decision,
|
|
90
105
|
2026-08-07) — a new outbound field starts with a proto arm, per the
|
|
91
106
|
extension rule above.
|
|
107
|
+
|
|
108
|
+
Accordingly, the public `Attachment.url` is optional on provisional/upload
|
|
109
|
+
responses and becomes authoritative only on the canonical message echo.
|