@clawchatsai/connector 0.1.42 → 0.1.43
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/package.json +1 -1
- package/server/peer/sharing.js +9 -0
- package/server/peer/sharing.test.js +12 -0
- package/server/team.js +2 -0
package/package.json
CHANGED
package/server/peer/sharing.js
CHANGED
|
@@ -394,6 +394,15 @@ export class SharingManager {
|
|
|
394
394
|
}
|
|
395
395
|
|
|
396
396
|
/** The room (and who asked) behind a guest session of this gateway, or null. */
|
|
397
|
+
/** Sessions here answering `roomId` of the room hosted by `hostGatewayId` (hidden from the list while a copy exists). */
|
|
398
|
+
guestSessionKeysFor(hostGatewayId, roomId) {
|
|
399
|
+
const keys = [];
|
|
400
|
+
for (const r of this._db().prepare('SELECT p.session_key, g.grant_json FROM peer_sessions p JOIN peer_grants g ON g.share_id = p.share_id WHERE p.room_id = ?').all(roomId)) {
|
|
401
|
+
try { if (JSON.parse(r.grant_json).requesterGatewayId === hostGatewayId) keys.push(r.session_key); } catch { /* unreadable grant */ }
|
|
402
|
+
}
|
|
403
|
+
return keys;
|
|
404
|
+
}
|
|
405
|
+
|
|
397
406
|
guestSessionOf(key) {
|
|
398
407
|
if (!this._guestKeys) {
|
|
399
408
|
this._guestKeys = new Map();
|
|
@@ -160,6 +160,18 @@ test('a gateway with no id can\'t sign a grant (the server would refuse it silen
|
|
|
160
160
|
assert.ok(frames.at(-2).message.includes('as it was'));
|
|
161
161
|
});
|
|
162
162
|
|
|
163
|
+
test("the sessions answering a host's room are listed per host and room, so their approvals can show in the room", async () => {
|
|
164
|
+
const s = setup();
|
|
165
|
+
s.owner.approve('sh1', { agents: [{ id: 'jarvis-guest', name: 'Jarvis' }], access: 'trusted', dailyCap: 10 });
|
|
166
|
+
s.activate();
|
|
167
|
+
await s.req.turn('peer:sh1:jarvis-guest', { turnId: 't1', roomId: 'room1', roomTitle: 'Rivers', message: 'hi' });
|
|
168
|
+
await s.req.turn('peer:sh1:jarvis-guest', { turnId: 't2', roomId: 'room2', roomTitle: 'Lakes', message: 'hi' });
|
|
169
|
+
const key = s.ownerCalls.find(c => c.method === 'sessions.create').params.key;
|
|
170
|
+
assert.deepEqual(s.owner.guestSessionKeysFor('gwH', 'room1'), [key]);
|
|
171
|
+
assert.deepEqual(s.owner.guestSessionKeysFor('gwH', 'room3'), []);
|
|
172
|
+
assert.deepEqual(s.owner.guestSessionKeysFor('gwOther', 'room1'), [], 'another host with the same room id is not this room');
|
|
173
|
+
});
|
|
174
|
+
|
|
163
175
|
test('approve → verified on the requester → turn runs in a guest session on the owner, text streams back', async () => {
|
|
164
176
|
const s = setup();
|
|
165
177
|
assert.deepEqual(s.req.remoteAgents(), []);
|
package/server/team.js
CHANGED
|
@@ -293,6 +293,8 @@ export class TeamCoordinator {
|
|
|
293
293
|
running: live ? [...live.running.keys()] : [],
|
|
294
294
|
queued: live?.queued || 0,
|
|
295
295
|
people: r.people.map(p => ({ personId: p.personId, name: p.name })),
|
|
296
|
+
// In a copy: the sessions this gateway's agents answer the host's room in. Their approvals and questions belong to the room.
|
|
297
|
+
...(r.host ? { answeringKeys: this.remote?.guestSessionKeysFor?.(r.host.gatewayId, r.host.roomId) || [] } : {}),
|
|
296
298
|
...(r.host ? this._replicaPublic(r) : {}),
|
|
297
299
|
};
|
|
298
300
|
}
|