@vinaverse/client 0.1.0-alpha.5 → 0.1.0-alpha.7

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.
Files changed (35) hide show
  1. package/README.md +67 -7
  2. package/dist/agent/index.cjs +526 -78
  3. package/dist/agent/index.cjs.map +1 -1
  4. package/dist/agent/index.d.cts +2 -2
  5. package/dist/agent/index.d.ts +2 -2
  6. package/dist/agent/index.js +2 -2
  7. package/dist/backend/index.cjs +268 -0
  8. package/dist/backend/index.cjs.map +1 -0
  9. package/dist/backend/index.d.cts +72 -0
  10. package/dist/backend/index.d.ts +72 -0
  11. package/dist/backend/index.js +250 -0
  12. package/dist/backend/index.js.map +1 -0
  13. package/dist/chunk-3BLRAWNC.js +840 -0
  14. package/dist/chunk-3BLRAWNC.js.map +1 -0
  15. package/dist/{chunk-ZWG2TMUL.js → chunk-46D3FSLU.js} +24 -2
  16. package/dist/chunk-46D3FSLU.js.map +1 -0
  17. package/dist/conversation/index.cjs +22 -0
  18. package/dist/conversation/index.cjs.map +1 -1
  19. package/dist/conversation/index.d.cts +2 -2
  20. package/dist/conversation/index.d.ts +2 -2
  21. package/dist/conversation/index.js +2 -2
  22. package/dist/{runtime-DDxwWBBr.d.cts → runtime-C3ZknHdG.d.cts} +139 -20
  23. package/dist/{runtime-B4nKwOTF.d.ts → runtime-CZ1hLvAl.d.ts} +139 -20
  24. package/dist/{store-C7FtS5AY.d.cts → store-7WU1kD9W.d.cts} +31 -1
  25. package/dist/{store-DFk0ayh8.d.ts → store-DrXSPHu6.d.ts} +31 -1
  26. package/dist/testing/index.cjs +38 -1
  27. package/dist/testing/index.cjs.map +1 -1
  28. package/dist/testing/index.d.cts +14 -3
  29. package/dist/testing/index.d.ts +14 -3
  30. package/dist/testing/index.js +40 -3
  31. package/dist/testing/index.js.map +1 -1
  32. package/package.json +21 -2
  33. package/dist/chunk-3WR2SUG2.js +0 -416
  34. package/dist/chunk-3WR2SUG2.js.map +0 -1
  35. package/dist/chunk-ZWG2TMUL.js.map +0 -1
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,70 @@ 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__`.
131
+ and local development only, and the runtime warns outside `__DEV__` (through `onWarning`, your logger, else `console.warn`).
129
132
  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
- For a mock mode and tests, `@vinaverse/client/testing` has a scripted agent: `createMockAgent({ reply, refuse, welcome })`
133
- gives an `AgentBackend` and a WebSocket factory that speaks the protocol (`conversation.transport.webSocket`), and
134
- `mockCards` the cards your tools would.
133
+ session's end is ended when it is next shown, and `subscribe` then tells the binding to read the next one. One no view
134
+ shows ends at its session's end while the app's timers run, and on `sweep()` (the React Native parts call it when the
135
+ app comes back to the foreground).
136
+
137
+ **Your backend, in two lines** (`@vinaverse/client/backend`): `backendFromFetch({ routes, headers })` is an
138
+ `AgentBackend` over your own routes, sending the person's credentials from `headers`, never in a body.
139
+ `backendRoutes(base)` gives the routes the .NET SDK's `MapVinaverseAgentSessions` serves by default (`session`,
140
+ `refresh`, `status`, `feedback`, `end`, `context`, `delete`); give your own where they differ. Both sides speak
141
+ `vinaverse.agent-backend/1` (vinaverse-contracts `docs/agent-backend.md`, tested here against its fixture): successes
142
+ wrapped with the version (`{ version: 1, session }`, `{ version: 1, client_secret: { value, expires_at } }`,
143
+ `{ version: 1, status }`, or 204), and one failure body for every route. Every session creation (a first open, a
144
+ resume, continue-here, a rollover) carries a new `open_id`, the gateway's idempotency key; a creation that could not
145
+ reach your backend is asked again unchanged, under the same `open_id`, by the runtime's tries and the person's "try
146
+ again" alike, for 24 hours, so a lost answer never opens two sessions.
147
+
148
+ Failures, yours or the adapter's, are read by `decodeBackendFailure(status, body, headers)` without matching strings:
149
+ `{ version: 1, outcome, retryable, retry_after?, open_id?, current_revision?, code? }` at its outcome's status, one
150
+ meaning per outcome with the contract's client action (`OUTCOMES`): `conversation_not_found`, `_expired`, `_mismatch`
151
+ and `_completed` end the conversation (`not_found`, `expired`, `mismatch`, `completed`); `session_closed` on a refresh
152
+ rolls over to a new session of the same conversation; `feature_off`, `unauthorized` and `forbidden_ownership` refuse
153
+ (`off`, `auth`, `forbidden`); `rate_limited` is waited out, `retry_after` apart, at most 60 s; `unavailable` is retried
154
+ when `retryable`; `unknown_open` (the backend could not tell whether the session opened) is final, said as unavailable,
155
+ its `open_id` kept on the conversation's state (`openId`) for support; `context_conflict` (with `current_revision`)
156
+ resends the newest place once. `code` is the gateway's code it was translated from (`gatewayCode` on the error).
157
+ Anything else, another version, another status, a proxy page, a 2xx that is not the operation's success, is read by
158
+ its status alone (401 auth; 429, 408 and 5xx retried; anything else, a 404 or 410 too, unavailable, never "ended");
159
+ what `fetch` threw is a network failure, retried.
160
+
161
+ **Keys, forgetting, signing out, erasing.** Keys are encoded so no person, mode or business can pass for another (a
162
+ guest is `null`, never a subject named "guest"), and `agent` (the agent's id) is part of each, so two agents sharing a
163
+ device's storage never share a conversation. `dispose(key)` closes a conversation and keeps what continues it;
164
+ `forget(key)` also drops the conversation it continued and the transcript the device kept.
165
+ `deleteConversation(key, conversationId)` is history's delete: your backend deletes it (`AgentBackend.deleteConversation`),
166
+ then the device forgets it only where the key still continues that conversation (`conversationId` on its state). `signOut()` ends the sessions at your
167
+ backend while it removes everything the runtime ever kept under `conversation.persistenceKey`: its durable index finds
168
+ what an earlier process wrote and the alpha.5 and alpha.6 names of those conversations go too. Removal of keys no index
169
+ lists (an earlier version's, a write lost with its process) is guaranteed only with a storage that can list
170
+ (`keys(prefix)`: AsyncStorage's or MMKV's `getAllKeys()` filtered by the prefix) or clear (`removePrefix(prefix)`); without
171
+ 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,
172
+ and a write, a read or a status from before it lands nowhere. The launcher's greeting record outlives a sign-out on
173
+ purpose (no greeting again after signing back in), under `vinaverse.greeted.` (outside the transcripts' prefix); give
174
+ the runtime `greetingStorage` and `erase()` removes it too, with the analytics salt, for the person's erasure
175
+ (`forgetGreeting` is the low-level helper for one person and modes in a storage of your own). A thumbs rates a reply
176
+ against the session it was given in; a reply restored from the device or a resumed transcript cannot be rated
177
+ (`canRate(turnId)` is false, and `AgentChat` draws no thumbs for it).
178
+
179
+ **Places and steps.** `tell({ place })` with `undefined` keeps the place, with `null` clears it (`updateContext` gets
180
+ `{ screen: 'other' }`, no entity); revisions only grow across a conversation's sessions (`placeRevision` on the
181
+ session request), a `context_conflict` (409, with `current_revision`) sends the newest place once more above it, only while the session
182
+ and the person are the same, then says `moved`,
183
+ and a telling lands only on the session it was told to. `onEvent` also says `message_sent`, `reply_completed` and
184
+ `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
185
+ (the salt is kept at `<persistenceKey>:salt` in your storage, a new one after `erase()`), and
186
+ `session_opened` says where the chat was opened from (`entryPoint`: `launcher`, `ask`, `deep_link`, or your own).
187
+ `isRefusal(error)` recognises an `AgentRefusal` from any copy of the package (the mock, the backend helpers).
188
+
189
+ For a mock mode and tests, `@vinaverse/client/testing` has a scripted agent:
190
+ `createMockAgent({ script, reply, refuse, welcome })` gives an `AgentBackend` and a WebSocket factory that speaks the
191
+ protocol (`conversation.transport.webSocket`). `script` is the replies in order, one per turn, each with its text, its
192
+ cards or a failure; `reply` answers after it. `mockCards` gives the cards your tools would: `professional`,
193
+ `workspace`, `timeSlots`, `proposal` (pending, confirmed in your app) and `links`. Scripted history comes with the
194
+ runtime's history.
135
195
 
136
196
  The contract's types are exported too (`paths`, `components`, `operations`, `Schemas`): import them instead of copying
137
197
  the spec. Design: [docs/architecture/agent-runtime.md](../../docs/architecture/agent-runtime.md).