@vinaverse/client 0.1.0-alpha.6 → 0.1.0-alpha.8
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 +69 -7
- package/dist/agent/index.cjs +526 -75
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts +3 -3
- package/dist/agent/index.d.ts +3 -3
- package/dist/agent/index.js +2 -2
- package/dist/backend/index.cjs +268 -0
- package/dist/backend/index.cjs.map +1 -0
- package/dist/backend/index.d.cts +72 -0
- package/dist/backend/index.d.ts +72 -0
- package/dist/backend/index.js +250 -0
- package/dist/backend/index.js.map +1 -0
- package/dist/{chunk-ZWG2TMUL.js → chunk-46D3FSLU.js} +24 -2
- package/dist/chunk-46D3FSLU.js.map +1 -0
- package/dist/chunk-DI4DPUNA.js +843 -0
- package/dist/chunk-DI4DPUNA.js.map +1 -0
- package/dist/chunk-YNUHXJD6.js +9 -0
- package/dist/{chunk-VSJDVLCP.js.map → chunk-YNUHXJD6.js.map} +1 -1
- package/dist/contract-DmQs8amJ.d.cts +6 -0
- package/dist/contract-DmQs8amJ.d.ts +6 -0
- package/dist/conversation/index.cjs +24 -2
- package/dist/conversation/index.cjs.map +1 -1
- package/dist/conversation/index.d.cts +5 -5
- package/dist/conversation/index.d.ts +5 -5
- package/dist/conversation/index.js +3 -3
- package/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/{runtime-DLJbJkSr.d.ts → runtime-A4ovUdrc.d.cts} +147 -21
- package/dist/{runtime-CErMdYxJ.d.cts → runtime-B6_l8--U.d.ts} +147 -21
- package/dist/{session-8W3fRNeb.d.cts → session-CPz4pcPu.d.cts} +246 -7
- package/dist/{session-8W3fRNeb.d.ts → session-CPz4pcPu.d.ts} +246 -7
- package/dist/{store-C7FtS5AY.d.cts → store-BxiicOKG.d.cts} +32 -2
- package/dist/{store-DFk0ayh8.d.ts → store-DZka9T2-.d.ts} +32 -2
- package/dist/testing/index.cjs +38 -1
- package/dist/testing/index.cjs.map +1 -1
- package/dist/testing/index.d.cts +15 -4
- package/dist/testing/index.d.ts +15 -4
- package/dist/testing/index.js +40 -3
- package/dist/testing/index.js.map +1 -1
- package/package.json +41 -2
- package/dist/chunk-VSJDVLCP.js +0 -9
- package/dist/chunk-XPES5PZ3.js +0 -416
- package/dist/chunk-XPES5PZ3.js.map +0 -1
- package/dist/chunk-ZWG2TMUL.js.map +0 -1
- package/dist/contract-_NMdPjgN.d.cts +0 -6
- package/dist/contract-_NMdPjgN.d.ts +0 -6
package/README.md
CHANGED
|
@@ -9,7 +9,10 @@ dependencies.
|
|
|
9
9
|
npm install @vinaverse/client@alpha
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
Alphas are published under the `alpha` tag.
|
|
12
|
+
Alphas are published under the `alpha` tag. Upgrading from an earlier alpha: [MIGRATION.md](https://github.com/vinaverse-ai/vinaverse-js/blob/develop/MIGRATION.md)
|
|
13
|
+
lists every change against the alpha before and what your app does (often nothing); each package's changes are in its
|
|
14
|
+
changelog ([client](https://github.com/vinaverse-ai/vinaverse-js/blob/develop/packages/client/CHANGELOG.md), [react](https://github.com/vinaverse-ai/vinaverse-js/blob/develop/packages/react/CHANGELOG.md), [react-native](https://github.com/vinaverse-ai/vinaverse-js/blob/develop/packages/react-native/CHANGELOG.md),
|
|
15
|
+
[server](https://github.com/vinaverse-ai/vinaverse-js/blob/develop/packages/server/CHANGELOG.md), [tokens](https://github.com/vinaverse-ai/vinaverse-js/blob/develop/packages/tokens/CHANGELOG.md)).
|
|
13
16
|
|
|
14
17
|
## Use
|
|
15
18
|
|
|
@@ -125,13 +128,72 @@ History's "Continue" is `continue(key, conversationId)`: the key goes on with th
|
|
|
125
128
|
is said as `ended` (your backend throws `AgentRefusal('ended', { code })` on a 404 or 410). A session must have an id
|
|
126
129
|
and a secret, and `wss://` and `https://` addresses whatever transport you supply (a wrapper adding headers or logging
|
|
127
130
|
still gets only secure ones). `insecureAddresses: { realtime, turns }` allows plaintext for one leg: dangerous, for mocks
|
|
128
|
-
and local development only, and the runtime warns outside `__DEV__` (through `onWarning
|
|
131
|
+
and local development only, and the runtime warns outside `__DEV__` (through `onWarning(message, { code })`, your
|
|
132
|
+
logger, else `console.warn`; `code` is `insecure_addresses`, `callback_threw` with the `callback` that threw, or
|
|
133
|
+
`events_dropped`).
|
|
129
134
|
A UI binding reads the key's conversation with `peek(key)`, which ends nothing (a render must not): one past its
|
|
130
|
-
session's end is ended when it is next shown, and `subscribe` then tells the binding to read the next one.
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
`
|
|
135
|
+
session's end is ended when it is next shown, and `subscribe` then tells the binding to read the next one. One no view
|
|
136
|
+
shows ends at its session's end while the app's timers run, and on `sweep()` (the React Native parts call it when the
|
|
137
|
+
app comes back to the foreground).
|
|
138
|
+
|
|
139
|
+
**Your backend, in two lines** (`@vinaverse/client/backend`): `backendFromFetch({ routes, headers })` is an
|
|
140
|
+
`AgentBackend` over your own routes, sending the person's credentials from `headers`, never in a body.
|
|
141
|
+
`backendRoutes(base)` gives the routes the .NET SDK's `MapVinaverseAgentSessions` serves by default (`session`,
|
|
142
|
+
`refresh`, `status`, `feedback`, `end`, `context`, `delete`); give your own where they differ. Both sides speak
|
|
143
|
+
`vinaverse.agent-backend/1` (vinaverse-contracts `docs/agent-backend.md`, tested here against its fixture): successes
|
|
144
|
+
wrapped with the version (`{ version: 1, session }`, `{ version: 1, client_secret: { value, expires_at } }`,
|
|
145
|
+
`{ version: 1, status }`, or 204), and one failure body for every route. Every session creation (a first open, a
|
|
146
|
+
resume, continue-here, a rollover) carries a new `open_id`, the gateway's idempotency key; a creation that could not
|
|
147
|
+
reach your backend is asked again unchanged, under the same `open_id`, by the runtime's tries and the person's "try
|
|
148
|
+
again" alike, for 24 hours, so a lost answer never opens two sessions.
|
|
149
|
+
|
|
150
|
+
Failures, yours or the adapter's, are read by `decodeBackendFailure(status, body, headers)` without matching strings:
|
|
151
|
+
`{ version: 1, outcome, retryable, retry_after?, open_id?, current_revision?, code? }` at its outcome's status, one
|
|
152
|
+
meaning per outcome with the contract's client action (`OUTCOMES`): `conversation_not_found`, `_expired`, `_mismatch`
|
|
153
|
+
and `_completed` end the conversation (`not_found`, `expired`, `mismatch`, `completed`); `session_closed` on a refresh
|
|
154
|
+
rolls over to a new session of the same conversation; `feature_off`, `unauthorized` and `forbidden_ownership` refuse
|
|
155
|
+
(`off`, `auth`, `forbidden`); `rate_limited` is waited out, `retry_after` apart, at most 60 s; `unavailable` is retried
|
|
156
|
+
when `retryable`; `unknown_open` (the backend could not tell whether the session opened) is final, said as unavailable,
|
|
157
|
+
its `open_id` kept on the conversation's state (`openId`) for support; `context_conflict` (with `current_revision`)
|
|
158
|
+
resends the newest place once. `code` is the gateway's code it was translated from (`gatewayCode` on the error).
|
|
159
|
+
Anything else, another version, another status, a proxy page, a 2xx that is not the operation's success, is read by
|
|
160
|
+
its status alone (401 auth; 429, 408 and 5xx retried; anything else, a 404 or 410 too, unavailable, never "ended");
|
|
161
|
+
what `fetch` threw is a network failure, retried.
|
|
162
|
+
|
|
163
|
+
**Keys, forgetting, signing out, erasing.** Keys are encoded so no person, mode or business can pass for another (a
|
|
164
|
+
guest is `null`, never a subject named "guest"), and `agent` (the agent's id) is part of each, so two agents sharing a
|
|
165
|
+
device's storage never share a conversation. `dispose(key)` closes a conversation and keeps what continues it;
|
|
166
|
+
`forget(key)` also drops the conversation it continued and the transcript the device kept.
|
|
167
|
+
`deleteConversation(key, conversationId)` is history's delete: your backend deletes it (`AgentBackend.deleteConversation`),
|
|
168
|
+
then the device forgets it only where the key still continues that conversation (`conversationId` on its state). `signOut()` ends the sessions at your
|
|
169
|
+
backend while it removes everything the runtime ever kept under `conversation.persistenceKey`: its durable index finds
|
|
170
|
+
what an earlier process wrote and the alpha.5 and alpha.6 names of those conversations go too. Removal of keys no index
|
|
171
|
+
lists (an earlier version's, a write lost with its process) is guaranteed only with a storage that can list
|
|
172
|
+
(`keys(prefix)`: AsyncStorage's or MMKV's `getAllKeys()` filtered by the prefix) or clear (`removePrefix(prefix)`); without
|
|
173
|
+
either, the index, the shapes derived from it, and the `legacyKeys` you pass (what your earlier code wrote) go. It clears the status and the name,
|
|
174
|
+
and a write, a read or a status from before it lands nowhere. The launcher's greeting record outlives a sign-out on
|
|
175
|
+
purpose (no greeting again after signing back in), under `vinaverse.greeted.` (outside the transcripts' prefix); give
|
|
176
|
+
the runtime `greetingStorage` and `erase()` removes it too, with the analytics salt, for the person's erasure
|
|
177
|
+
(`forgetGreeting` is the low-level helper for one person and modes in a storage of your own). A thumbs rates a reply
|
|
178
|
+
against the session it was given in; a reply restored from the device or a resumed transcript cannot be rated
|
|
179
|
+
(`canRate(turnId)` is false, and `AgentChat` draws no thumbs for it).
|
|
180
|
+
|
|
181
|
+
**Places and steps.** `tell({ place })` with `undefined` keeps the place, with `null` clears it (`updateContext` gets
|
|
182
|
+
`{ screen: 'other' }`, no entity); revisions only grow across a conversation's sessions (`placeRevision` on the
|
|
183
|
+
session request), a `context_conflict` (409, with `current_revision`) sends the newest place once more above it, only while the session
|
|
184
|
+
and the person are the same, then says `moved`,
|
|
185
|
+
and a telling lands only on the session it was told to. `onEvent` also says `message_sent`, `reply_completed` and
|
|
186
|
+
`card_shown` (never the words), its `key` is a salted SHA-256 hash of the conversation's key (`hashKey`), never the person's id: stable per install
|
|
187
|
+
(the salt is kept at `<persistenceKey>:salt` in your storage, a new one after `erase()`), and
|
|
188
|
+
`session_opened` says where the chat was opened from (`entryPoint`: `launcher`, `ask`, `deep_link`, or your own).
|
|
189
|
+
`isRefusal(error)` recognises an `AgentRefusal` from any copy of the package (the mock, the backend helpers).
|
|
190
|
+
|
|
191
|
+
For a mock mode and tests, `@vinaverse/client/testing` has a scripted agent:
|
|
192
|
+
`createMockAgent({ script, reply, refuse, welcome })` gives an `AgentBackend` and a WebSocket factory that speaks the
|
|
193
|
+
protocol (`conversation.transport.webSocket`). `script` is the replies in order, one per turn, each with its text, its
|
|
194
|
+
cards or a failure; `reply` answers after it. `mockCards` gives the cards your tools would: `professional`,
|
|
195
|
+
`workspace`, `timeSlots`, `proposal` (pending, confirmed in your app) and `links`. Scripted history comes with the
|
|
196
|
+
runtime's history.
|
|
135
197
|
|
|
136
198
|
The contract's types are exported too (`paths`, `components`, `operations`, `Schemas`): import them instead of copying
|
|
137
199
|
the spec. Design: [docs/architecture/agent-runtime.md](../../docs/architecture/agent-runtime.md).
|