@kybernesis/buzz 0.4.3 → 0.4.4
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/dist/bridge.js +18 -4
- package/package.json +1 -1
package/dist/bridge.js
CHANGED
|
@@ -39,6 +39,13 @@ export function buzzBridge(options) {
|
|
|
39
39
|
* same conversation through a client built for the person sending it, which
|
|
40
40
|
* is what the runtime reads to decide whose memory and whose connections the
|
|
41
41
|
* turn may touch.
|
|
42
|
+
*
|
|
43
|
+
* The stream position is kept beside the id for a reason that cost an
|
|
44
|
+
* afternoon: attaching defaults to index 0, so a turn reads the conversation
|
|
45
|
+
* from its beginning and reports the FIRST completed message it finds — the
|
|
46
|
+
* previous person's answer. The turn itself runs correctly, as the right
|
|
47
|
+
* person, against the right connections; only the text posted back is
|
|
48
|
+
* somebody else's, which is the most convincing way to look broken.
|
|
42
49
|
*/
|
|
43
50
|
const sessions = new Map();
|
|
44
51
|
/** Who has already been sent a link, so a room full of strangers is not a room full of spam. */
|
|
@@ -57,9 +64,12 @@ export function buzzBridge(options) {
|
|
|
57
64
|
const existing = sessions.get(channel);
|
|
58
65
|
if (existing) {
|
|
59
66
|
try {
|
|
60
|
-
const session = client.sessions.attach(existing);
|
|
67
|
+
const session = client.sessions.attach(existing.id, { streamIndex: existing.streamIndex });
|
|
61
68
|
const response = await session.send(text);
|
|
62
|
-
|
|
69
|
+
const result = await response.result();
|
|
70
|
+
// Where this turn left the conversation, so the next one starts after it.
|
|
71
|
+
sessions.set(channel, { id: existing.id, streamIndex: session.state.streamIndex });
|
|
72
|
+
return result.message ?? "";
|
|
63
73
|
}
|
|
64
74
|
catch (error) {
|
|
65
75
|
// A session the agent no longer holds cannot be resumed. Starting a new one loses the
|
|
@@ -69,8 +79,12 @@ export function buzzBridge(options) {
|
|
|
69
79
|
}
|
|
70
80
|
}
|
|
71
81
|
const created = await client.sessions.create({ message: text });
|
|
72
|
-
|
|
73
|
-
|
|
82
|
+
const message = (await created.response.result()).message ?? "";
|
|
83
|
+
sessions.set(channel, {
|
|
84
|
+
id: created.session.state.sessionId,
|
|
85
|
+
streamIndex: created.session.state.streamIndex,
|
|
86
|
+
});
|
|
87
|
+
return message;
|
|
74
88
|
}
|
|
75
89
|
/**
|
|
76
90
|
* Send someone the link that makes them known, privately.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kybernesis/buzz",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.4",
|
|
4
4
|
"description": "Put an eve agent in a Buzz workspace as a member: per-speaker verified identity resolved through the control plane, self-service identity linking, presence, typing and seen signals.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "module",
|