@meshagent/meshagent-ts-auth 0.47.0 → 0.47.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/CHANGELOG.md +5 -0
- package/dist/browser/ma-auth.global.js +325 -20
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,8 @@
|
|
|
1
|
+
## [0.47.1]
|
|
2
|
+
- Added duplex messaging stream subscriptions and replay-state alignment in the TypeScript chat clients, bringing the NodeJS SDK in line with the new streaming model.
|
|
3
|
+
- Reworked messaging and room client flow control so dispatch ordering, close behavior, and presence updates stay consistent under streaming loads.
|
|
4
|
+
- Expanded stream and presence test coverage for the new messaging behavior.
|
|
5
|
+
|
|
1
6
|
## [0.47.0]
|
|
2
7
|
- Improved TypeScript messaging clients so room delivery order and startup/presence behavior stay consistent.
|
|
3
8
|
- Moved managed-agent client routing onto the Rust tunnel path and hardened agent chat-client event handling.
|
|
@@ -14693,10 +14693,10 @@ ${err.toString()}`);
|
|
|
14693
14693
|
return false;
|
|
14694
14694
|
}
|
|
14695
14695
|
}
|
|
14696
|
-
|
|
14696
|
+
_sendToolCallResponseChunk(messageId, toolCallId, chunk) {
|
|
14697
14697
|
const [header, payload] = (0, utils_js_1.unpackMessage)(chunk.pack());
|
|
14698
14698
|
try {
|
|
14699
|
-
|
|
14699
|
+
this.client.protocol.sendNowait("room.tool_call_response_chunk", (0, utils_js_1.packMessage)({ tool_call_id: toolCallId, chunk: header }, payload.length > 0 ? payload : void 0), { id: messageId });
|
|
14700
14700
|
return true;
|
|
14701
14701
|
} catch (error) {
|
|
14702
14702
|
console.debug("unable to send tool call response chunk", error);
|
|
@@ -14792,10 +14792,10 @@ ${err.toString()}`);
|
|
|
14792
14792
|
return;
|
|
14793
14793
|
for await (const chunk of output.stream) {
|
|
14794
14794
|
this.toolkit.validateOutputContent(tool, chunk);
|
|
14795
|
-
if (!
|
|
14795
|
+
if (!this._sendToolCallResponseChunk(messageId, toolCallId, chunk))
|
|
14796
14796
|
return;
|
|
14797
14797
|
}
|
|
14798
|
-
|
|
14798
|
+
this._sendToolCallResponseChunk(messageId, toolCallId, new response_js_1.ControlContent({ method: "close" }));
|
|
14799
14799
|
return;
|
|
14800
14800
|
}
|
|
14801
14801
|
throw new Error(`tool ${toolName} returned unsupported output`);
|
|
@@ -14805,9 +14805,9 @@ ${err.toString()}`);
|
|
|
14805
14805
|
return;
|
|
14806
14806
|
}
|
|
14807
14807
|
if (!(error instanceof InvalidToolDataException)) {
|
|
14808
|
-
|
|
14808
|
+
this._sendToolCallResponseChunk(messageId, toolCallId, new response_js_1.ErrorContent({ text: String(error) }));
|
|
14809
14809
|
}
|
|
14810
|
-
|
|
14810
|
+
this._sendToolCallResponseChunk(messageId, toolCallId, new response_js_1.ControlContent({
|
|
14811
14811
|
method: "close",
|
|
14812
14812
|
statusCode: error instanceof InvalidToolDataException ? response_js_1.ControlCloseStatus.INVALID_DATA : void 0,
|
|
14813
14813
|
message: error instanceof InvalidToolDataException ? error.message : void 0
|
|
@@ -42002,6 +42002,9 @@ ${newlined}
|
|
|
42002
42002
|
addRoomGrant(roomName) {
|
|
42003
42003
|
this.grants.push(new ParticipantGrant({ name: "room", scope: roomName }));
|
|
42004
42004
|
}
|
|
42005
|
+
addSiteGrant(roomName) {
|
|
42006
|
+
this.grants.push(new ParticipantGrant({ name: "site", scope: roomName }));
|
|
42007
|
+
}
|
|
42005
42008
|
addApiGrant(grant) {
|
|
42006
42009
|
for (const existingGrant of this.grants) {
|
|
42007
42010
|
if (existingGrant.name === "api") {
|
|
@@ -43496,7 +43499,7 @@ ${newlined}
|
|
|
43496
43499
|
}
|
|
43497
43500
|
const parsedResource = this.parseAccessResource(data.resource);
|
|
43498
43501
|
const parsedSubject = this.parseAccessSubject(data.subject);
|
|
43499
|
-
const parsedDirectRoles = Array.isArray(data.direct_roles) ? data.direct_roles.filter((item) => item === "member" || item === "viewer" || item === "operator" || item === "developer" || item === "admin" || item === "room_creator" || item === "room_inventory" || item === "room_manager" || item === "session_inventory" || item === "agent_creator" || item === "agent_inventory" || item === "agent_manager" || item === "repository_creator" || item === "repository_inventory" || item === "repository_manager" || item === "feed_creator" || item === "feed_inventory" || item === "feed_manager" || item === "oauth_client_creator" || item === "oauth_client_inventory" || item === "oauth_client_manager" || item === "api_key_creator" || item === "api_key_inventory" || item === "api_key_manager" || item === "service_creator" || item === "service_inventory" || item === "service_manager" || item === "service_account_creator" || item === "service_account_inventory" || item === "service_account_manager" || item === "participant_token_creator" || item === "mailbox_creator" || item === "mailbox_inventory" || item === "mailbox_manager" || item === "route_creator" || item === "route_inventory" || item === "route_manager" || item === "scheduled_task_creator" || item === "scheduled_task_inventory" || item === "scheduled_task_manager" || item === "feed_subscription_creator" || item === "feed_subscription_inventory" || item === "feed_subscription_manager" || item === "llm_logger_creator" || item === "llm_logger_inventory" || item === "llm_logger_manager" || item === "llm_proxy_user" || item === "usage_reporter" || item === "billing_manager" || item === "group_manager" || item === "reader" || item === "subscriber" || item === "publisher" || item === "manager" || item === "list") : [];
|
|
43502
|
+
const parsedDirectRoles = Array.isArray(data.direct_roles) ? data.direct_roles.filter((item) => item === "member" || item === "site_user" || item === "viewer" || item === "operator" || item === "developer" || item === "admin" || item === "room_creator" || item === "room_inventory" || item === "room_manager" || item === "session_inventory" || item === "agent_creator" || item === "agent_inventory" || item === "agent_manager" || item === "repository_creator" || item === "repository_inventory" || item === "repository_manager" || item === "feed_creator" || item === "feed_inventory" || item === "feed_manager" || item === "oauth_client_creator" || item === "oauth_client_inventory" || item === "oauth_client_manager" || item === "api_key_creator" || item === "api_key_inventory" || item === "api_key_manager" || item === "service_creator" || item === "service_inventory" || item === "service_manager" || item === "service_account_creator" || item === "service_account_inventory" || item === "service_account_manager" || item === "participant_token_creator" || item === "mailbox_creator" || item === "mailbox_inventory" || item === "mailbox_manager" || item === "route_creator" || item === "route_inventory" || item === "route_manager" || item === "scheduled_task_creator" || item === "scheduled_task_inventory" || item === "scheduled_task_manager" || item === "feed_subscription_creator" || item === "feed_subscription_inventory" || item === "feed_subscription_manager" || item === "llm_logger_creator" || item === "llm_logger_inventory" || item === "llm_logger_manager" || item === "llm_proxy_user" || item === "usage_reporter" || item === "billing_manager" || item === "group_manager" || item === "reader" || item === "subscriber" || item === "publisher" || item === "manager" || item === "list") : [];
|
|
43500
43503
|
const room = {
|
|
43501
43504
|
id: parsedResource.id,
|
|
43502
43505
|
name: parsedResource.name ?? parsedResource.id,
|
|
@@ -44899,7 +44902,7 @@ ${newlined}
|
|
|
44899
44902
|
"../meshagent-ts/dist/browser/messaging-client.js"(exports) {
|
|
44900
44903
|
"use strict";
|
|
44901
44904
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
44902
|
-
exports.MessagingClient = void 0;
|
|
44905
|
+
exports.MessagingClient = exports.MessagingStream = void 0;
|
|
44903
44906
|
var completer_js_1 = require_completer();
|
|
44904
44907
|
var event_emitter_js_1 = require_event_emitter();
|
|
44905
44908
|
var participant_js_1 = require_participant();
|
|
@@ -44921,6 +44924,247 @@ ${newlined}
|
|
|
44921
44924
|
}
|
|
44922
44925
|
return globalScope.btoa(binary);
|
|
44923
44926
|
}
|
|
44927
|
+
function base64ToBytes(value) {
|
|
44928
|
+
if (globalScope.Buffer != null) {
|
|
44929
|
+
return new Uint8Array(globalScope.Buffer.from(value, "base64"));
|
|
44930
|
+
}
|
|
44931
|
+
const atob2 = globalThis.atob;
|
|
44932
|
+
if (atob2 == null) {
|
|
44933
|
+
throw new Error("base64 decoding is not available in this runtime");
|
|
44934
|
+
}
|
|
44935
|
+
const binary = atob2(value);
|
|
44936
|
+
return Uint8Array.from(binary, (character) => character.charCodeAt(0));
|
|
44937
|
+
}
|
|
44938
|
+
var MessagingStreamInput = class {
|
|
44939
|
+
constructor() {
|
|
44940
|
+
this.items = [];
|
|
44941
|
+
this.signal = null;
|
|
44942
|
+
this.active = null;
|
|
44943
|
+
this.closed = false;
|
|
44944
|
+
this.error = null;
|
|
44945
|
+
}
|
|
44946
|
+
enqueue(content, { wait = false } = {}) {
|
|
44947
|
+
if (this.closed) {
|
|
44948
|
+
return Promise.reject(this.error ?? new room_server_client_js_1.RoomServerException("the messaging stream is closed"));
|
|
44949
|
+
}
|
|
44950
|
+
const sent = wait ? new completer_js_1.Completer() : void 0;
|
|
44951
|
+
this.items.push({ content, sent });
|
|
44952
|
+
this.signal?.resolve();
|
|
44953
|
+
this.signal = null;
|
|
44954
|
+
return sent?.fut ?? Promise.resolve();
|
|
44955
|
+
}
|
|
44956
|
+
close(error = new room_server_client_js_1.RoomServerException("the messaging stream is closed")) {
|
|
44957
|
+
if (this.closed) {
|
|
44958
|
+
return;
|
|
44959
|
+
}
|
|
44960
|
+
this.closed = true;
|
|
44961
|
+
this.error = error;
|
|
44962
|
+
this.active?.sent?.reject(error);
|
|
44963
|
+
this.active = null;
|
|
44964
|
+
for (const item of this.items.splice(0)) {
|
|
44965
|
+
item.sent?.reject(error);
|
|
44966
|
+
}
|
|
44967
|
+
this.signal?.resolve();
|
|
44968
|
+
this.signal = null;
|
|
44969
|
+
}
|
|
44970
|
+
fail(error) {
|
|
44971
|
+
this.close(error);
|
|
44972
|
+
}
|
|
44973
|
+
async *stream() {
|
|
44974
|
+
try {
|
|
44975
|
+
while (true) {
|
|
44976
|
+
while (this.items.length === 0 && !this.closed) {
|
|
44977
|
+
this.signal ?? (this.signal = new completer_js_1.Completer());
|
|
44978
|
+
await this.signal.fut;
|
|
44979
|
+
}
|
|
44980
|
+
const item = this.items.shift();
|
|
44981
|
+
if (item == null) {
|
|
44982
|
+
return;
|
|
44983
|
+
}
|
|
44984
|
+
this.active = item;
|
|
44985
|
+
yield item.content;
|
|
44986
|
+
item.sent?.resolve();
|
|
44987
|
+
this.active = null;
|
|
44988
|
+
}
|
|
44989
|
+
} finally {
|
|
44990
|
+
if (this.active != null && this.closed) {
|
|
44991
|
+
this.active.sent?.reject(this.error ?? new room_server_client_js_1.RoomServerException("the messaging stream is closed"));
|
|
44992
|
+
this.active = null;
|
|
44993
|
+
}
|
|
44994
|
+
}
|
|
44995
|
+
}
|
|
44996
|
+
};
|
|
44997
|
+
var MessagingStream = class {
|
|
44998
|
+
constructor({ streamId, remoteParticipantId, input, output, inputClosed, onClosed }) {
|
|
44999
|
+
this.events = [];
|
|
45000
|
+
this.eventSignal = null;
|
|
45001
|
+
this.state = "accepted";
|
|
45002
|
+
this.streamId = streamId;
|
|
45003
|
+
this.remoteParticipantId = remoteParticipantId;
|
|
45004
|
+
this.input = input;
|
|
45005
|
+
this.output = output;
|
|
45006
|
+
this.inputDone = Promise.resolve(inputClosed).catch((error) => {
|
|
45007
|
+
this.input.fail(error);
|
|
45008
|
+
this.push({
|
|
45009
|
+
kind: "closed",
|
|
45010
|
+
streamId: this.streamId,
|
|
45011
|
+
reason: "error",
|
|
45012
|
+
message: error instanceof Error ? error.message : String(error)
|
|
45013
|
+
});
|
|
45014
|
+
void this.output.return?.();
|
|
45015
|
+
this.finish();
|
|
45016
|
+
});
|
|
45017
|
+
this.onClosed = onClosed;
|
|
45018
|
+
void this.consumeOutput();
|
|
45019
|
+
}
|
|
45020
|
+
get closed() {
|
|
45021
|
+
return this.state === "terminal";
|
|
45022
|
+
}
|
|
45023
|
+
push(event) {
|
|
45024
|
+
if (this.state !== "accepted") {
|
|
45025
|
+
return;
|
|
45026
|
+
}
|
|
45027
|
+
this.events.push(event);
|
|
45028
|
+
this.eventSignal?.resolve();
|
|
45029
|
+
this.eventSignal = null;
|
|
45030
|
+
}
|
|
45031
|
+
finish() {
|
|
45032
|
+
if (this.state === "terminal") {
|
|
45033
|
+
return;
|
|
45034
|
+
}
|
|
45035
|
+
this.state = "terminal";
|
|
45036
|
+
this.input.close();
|
|
45037
|
+
this.eventSignal?.resolve();
|
|
45038
|
+
this.eventSignal = null;
|
|
45039
|
+
void this.inputDone.finally(this.onClosed);
|
|
45040
|
+
}
|
|
45041
|
+
async consumeOutput() {
|
|
45042
|
+
try {
|
|
45043
|
+
while (true) {
|
|
45044
|
+
const next = await this.output.next();
|
|
45045
|
+
if (next.done) {
|
|
45046
|
+
return;
|
|
45047
|
+
}
|
|
45048
|
+
if (next.value instanceof response_js_1.ControlContent && next.value.method === "close") {
|
|
45049
|
+
this.push({
|
|
45050
|
+
kind: "client_disconnected",
|
|
45051
|
+
streamId: this.streamId,
|
|
45052
|
+
participantId: this.remoteParticipantId
|
|
45053
|
+
});
|
|
45054
|
+
return;
|
|
45055
|
+
}
|
|
45056
|
+
if (!(next.value instanceof response_js_1.JsonContent)) {
|
|
45057
|
+
throw new room_server_client_js_1.RoomServerException("unexpected chunk from messaging.stream");
|
|
45058
|
+
}
|
|
45059
|
+
const value = next.value.json;
|
|
45060
|
+
const kind = value["kind"];
|
|
45061
|
+
if (kind === "message") {
|
|
45062
|
+
const type = value["type"];
|
|
45063
|
+
const message2 = value["message"];
|
|
45064
|
+
if (typeof type !== "string" || typeof message2 !== "object" || message2 == null || Array.isArray(message2)) {
|
|
45065
|
+
throw new room_server_client_js_1.RoomServerException("invalid message chunk from messaging.stream");
|
|
45066
|
+
}
|
|
45067
|
+
const encodedAttachment = value["attachment_base64"];
|
|
45068
|
+
this.push({
|
|
45069
|
+
kind: "message",
|
|
45070
|
+
message: new room_event_js_1.RoomMessage({
|
|
45071
|
+
fromParticipantId: this.remoteParticipantId,
|
|
45072
|
+
type,
|
|
45073
|
+
message: message2,
|
|
45074
|
+
attachment: typeof encodedAttachment === "string" && encodedAttachment !== "" ? base64ToBytes(encodedAttachment) : void 0
|
|
45075
|
+
})
|
|
45076
|
+
});
|
|
45077
|
+
} else if (kind === "client_disconnected" && typeof value["participant_id"] === "string") {
|
|
45078
|
+
this.push({
|
|
45079
|
+
kind,
|
|
45080
|
+
streamId: this.streamId,
|
|
45081
|
+
participantId: value["participant_id"]
|
|
45082
|
+
});
|
|
45083
|
+
return;
|
|
45084
|
+
} else if (kind === "closed") {
|
|
45085
|
+
this.push({
|
|
45086
|
+
kind,
|
|
45087
|
+
streamId: this.streamId,
|
|
45088
|
+
reason: typeof value["reason"] === "string" ? value["reason"] : "closed",
|
|
45089
|
+
message: typeof value["message"] === "string" ? value["message"] : void 0
|
|
45090
|
+
});
|
|
45091
|
+
return;
|
|
45092
|
+
} else {
|
|
45093
|
+
throw new room_server_client_js_1.RoomServerException("unexpected chunk from messaging.stream");
|
|
45094
|
+
}
|
|
45095
|
+
}
|
|
45096
|
+
} catch (error) {
|
|
45097
|
+
this.input.fail(error);
|
|
45098
|
+
this.push({
|
|
45099
|
+
kind: "closed",
|
|
45100
|
+
streamId: this.streamId,
|
|
45101
|
+
reason: "error",
|
|
45102
|
+
message: error instanceof Error ? error.message : String(error)
|
|
45103
|
+
});
|
|
45104
|
+
} finally {
|
|
45105
|
+
this.finish();
|
|
45106
|
+
}
|
|
45107
|
+
}
|
|
45108
|
+
content({ type, message: message2, attachment }) {
|
|
45109
|
+
return new response_js_1.JsonContent({
|
|
45110
|
+
json: {
|
|
45111
|
+
type,
|
|
45112
|
+
message_json: JSON.stringify(message2),
|
|
45113
|
+
...attachment == null ? {} : { attachment_base64: bytesToBase64(attachment) }
|
|
45114
|
+
}
|
|
45115
|
+
});
|
|
45116
|
+
}
|
|
45117
|
+
sendMessageNowait(params) {
|
|
45118
|
+
if (this.state !== "accepted") {
|
|
45119
|
+
throw new room_server_client_js_1.RoomServerException("the messaging stream is closed");
|
|
45120
|
+
}
|
|
45121
|
+
void this.input.enqueue(this.content(params));
|
|
45122
|
+
}
|
|
45123
|
+
async sendMessage(params) {
|
|
45124
|
+
if (this.state !== "accepted") {
|
|
45125
|
+
throw new room_server_client_js_1.RoomServerException("the messaging stream is closed");
|
|
45126
|
+
}
|
|
45127
|
+
await this.input.enqueue(this.content(params), { wait: true });
|
|
45128
|
+
}
|
|
45129
|
+
async close() {
|
|
45130
|
+
if (this.state === "terminal") {
|
|
45131
|
+
await this.inputDone;
|
|
45132
|
+
return;
|
|
45133
|
+
}
|
|
45134
|
+
this.input.close();
|
|
45135
|
+
try {
|
|
45136
|
+
await this.inputDone;
|
|
45137
|
+
} finally {
|
|
45138
|
+
await this.output.return?.();
|
|
45139
|
+
this.finish();
|
|
45140
|
+
}
|
|
45141
|
+
}
|
|
45142
|
+
clientDisconnected(participantId) {
|
|
45143
|
+
if (this.state === "terminal") {
|
|
45144
|
+
return;
|
|
45145
|
+
}
|
|
45146
|
+
this.push({
|
|
45147
|
+
kind: "client_disconnected",
|
|
45148
|
+
streamId: this.streamId,
|
|
45149
|
+
participantId
|
|
45150
|
+
});
|
|
45151
|
+
this.finish();
|
|
45152
|
+
}
|
|
45153
|
+
async *[Symbol.asyncIterator]() {
|
|
45154
|
+
while (true) {
|
|
45155
|
+
while (this.events.length === 0 && this.state !== "terminal") {
|
|
45156
|
+
this.eventSignal ?? (this.eventSignal = new completer_js_1.Completer());
|
|
45157
|
+
await this.eventSignal.fut;
|
|
45158
|
+
}
|
|
45159
|
+
const event = this.events.shift();
|
|
45160
|
+
if (event == null) {
|
|
45161
|
+
return;
|
|
45162
|
+
}
|
|
45163
|
+
yield event;
|
|
45164
|
+
}
|
|
45165
|
+
}
|
|
45166
|
+
};
|
|
45167
|
+
exports.MessagingStream = MessagingStream;
|
|
44924
45168
|
var MessagingClient = class extends event_emitter_js_1.EventEmitter {
|
|
44925
45169
|
constructor({ room }) {
|
|
44926
45170
|
super();
|
|
@@ -44930,6 +45174,7 @@ ${newlined}
|
|
|
44930
45174
|
this._messageQueued = null;
|
|
44931
45175
|
this._sendTask = null;
|
|
44932
45176
|
this._sendOperations = /* @__PURE__ */ new Set();
|
|
45177
|
+
this._streams = /* @__PURE__ */ new Set();
|
|
44933
45178
|
this._messageQueueClosed = false;
|
|
44934
45179
|
this._desiredEnabled = false;
|
|
44935
45180
|
this._online = false;
|
|
@@ -44995,6 +45240,7 @@ ${newlined}
|
|
|
44995
45240
|
await sendTask;
|
|
44996
45241
|
}
|
|
44997
45242
|
await Promise.all(this._sendOperations);
|
|
45243
|
+
await Promise.all([...this._streams].map(async (stream) => stream.close()));
|
|
44998
45244
|
this._desiredEnabled = false;
|
|
44999
45245
|
this._clearCurrentConnectionState();
|
|
45000
45246
|
}
|
|
@@ -45058,6 +45304,9 @@ ${newlined}
|
|
|
45058
45304
|
}
|
|
45059
45305
|
}
|
|
45060
45306
|
_onRoomDisconnect({ reason: _reason }) {
|
|
45307
|
+
for (const stream of [...this._streams]) {
|
|
45308
|
+
stream.clientDisconnected(this.client.localParticipant?.id ?? stream.remoteParticipantId);
|
|
45309
|
+
}
|
|
45061
45310
|
this._clearCurrentConnectionState();
|
|
45062
45311
|
}
|
|
45063
45312
|
_onRoomReconnect() {
|
|
@@ -45246,6 +45495,46 @@ ${newlined}
|
|
|
45246
45495
|
throw error;
|
|
45247
45496
|
}
|
|
45248
45497
|
}
|
|
45498
|
+
async stream({ to, type, message: message2, attachment }) {
|
|
45499
|
+
const input = new MessagingStreamInput();
|
|
45500
|
+
void input.enqueue(new response_js_1.JsonContent({
|
|
45501
|
+
json: {
|
|
45502
|
+
to_participant_id: to.id,
|
|
45503
|
+
type,
|
|
45504
|
+
message_json: JSON.stringify(message2),
|
|
45505
|
+
...attachment == null ? {} : { attachment_base64: bytesToBase64(attachment) }
|
|
45506
|
+
}
|
|
45507
|
+
}));
|
|
45508
|
+
const outputResult = await this.client.invokeToolCall({
|
|
45509
|
+
toolkit: "messaging",
|
|
45510
|
+
tool: "stream",
|
|
45511
|
+
input: input.stream(),
|
|
45512
|
+
streamInput: true
|
|
45513
|
+
});
|
|
45514
|
+
if (outputResult.kind !== "stream") {
|
|
45515
|
+
input.close();
|
|
45516
|
+
throw new room_server_client_js_1.RoomServerException("unexpected return type from messaging.stream");
|
|
45517
|
+
}
|
|
45518
|
+
const outputIterable = outputResult.stream;
|
|
45519
|
+
const output = outputIterable[Symbol.asyncIterator]();
|
|
45520
|
+
const accepted = await output.next();
|
|
45521
|
+
if (accepted.done || !(accepted.value instanceof response_js_1.JsonContent) || accepted.value.json["kind"] !== "accepted" || typeof accepted.value.json["stream_id"] !== "string") {
|
|
45522
|
+
input.close();
|
|
45523
|
+
await output.return?.();
|
|
45524
|
+
throw new room_server_client_js_1.RoomServerException("messaging.stream did not acknowledge acceptance");
|
|
45525
|
+
}
|
|
45526
|
+
let stream;
|
|
45527
|
+
stream = new MessagingStream({
|
|
45528
|
+
streamId: accepted.value.json["stream_id"],
|
|
45529
|
+
remoteParticipantId: to.id,
|
|
45530
|
+
input,
|
|
45531
|
+
output,
|
|
45532
|
+
inputClosed: outputResult.inputClosed,
|
|
45533
|
+
onClosed: () => this._streams.delete(stream)
|
|
45534
|
+
});
|
|
45535
|
+
this._streams.add(stream);
|
|
45536
|
+
return stream;
|
|
45537
|
+
}
|
|
45249
45538
|
getParticipants() {
|
|
45250
45539
|
return this.remoteParticipants;
|
|
45251
45540
|
}
|
|
@@ -45339,6 +45628,9 @@ ${newlined}
|
|
|
45339
45628
|
this._wakeMessageQueue();
|
|
45340
45629
|
this._drainQueuedMessages({ error });
|
|
45341
45630
|
this._desiredEnabled = false;
|
|
45631
|
+
for (const stream of [...this._streams]) {
|
|
45632
|
+
stream.clientDisconnected(this.client.localParticipant?.id ?? stream.remoteParticipantId);
|
|
45633
|
+
}
|
|
45342
45634
|
this._clearCurrentConnectionState();
|
|
45343
45635
|
this.client.protocol.removeHandler("messaging.send", this._messageHandler);
|
|
45344
45636
|
super.dispose();
|
|
@@ -48913,6 +49205,11 @@ ${newlined}
|
|
|
48913
49205
|
this._sendLocalAttributesNowait(attributes);
|
|
48914
49206
|
}
|
|
48915
49207
|
async sendRequest(type, request, data, afterSend) {
|
|
49208
|
+
const response = this._dispatchRequest(type, request, data);
|
|
49209
|
+
afterSend?.();
|
|
49210
|
+
return await response;
|
|
49211
|
+
}
|
|
49212
|
+
_dispatchRequest(type, request, data) {
|
|
48916
49213
|
this._raiseIfTerminal();
|
|
48917
49214
|
if (this._entered && !this._connected && !this._allowDisconnectedRequests) {
|
|
48918
49215
|
throw this._disconnectedError({ baseMessage: "room connection is disconnected" });
|
|
@@ -48921,9 +49218,8 @@ ${newlined}
|
|
|
48921
49218
|
const completer = new completer_js_1.Completer();
|
|
48922
49219
|
this._pendingRequests.set(requestId, completer);
|
|
48923
49220
|
try {
|
|
48924
|
-
|
|
48925
|
-
|
|
48926
|
-
return await completer.fut;
|
|
49221
|
+
this._protocolInstance.sendNowait(type, (0, utils_js_1.packMessage)(request, data), { id: requestId });
|
|
49222
|
+
return completer.fut;
|
|
48927
49223
|
} catch (error) {
|
|
48928
49224
|
this._pendingRequests.delete(requestId);
|
|
48929
49225
|
throw error;
|
|
@@ -49022,7 +49318,6 @@ ${newlined}
|
|
|
49022
49318
|
let requestTask;
|
|
49023
49319
|
if (params.streamInput === true) {
|
|
49024
49320
|
request["arguments"] = { type: "control", method: "open" };
|
|
49025
|
-
requestTask = this._streamInvokeToolRequestChunks(toolCallId, params.input);
|
|
49026
49321
|
} else {
|
|
49027
49322
|
const input = params.input;
|
|
49028
49323
|
const packed = input.pack();
|
|
@@ -49038,9 +49333,14 @@ ${newlined}
|
|
|
49038
49333
|
if (params.onBehalfOfId != null) {
|
|
49039
49334
|
request["on_behalf_of_id"] = params.onBehalfOfId;
|
|
49040
49335
|
}
|
|
49336
|
+
const responseRequest = this._dispatchRequest("room.invoke_tool", request, requestData);
|
|
49337
|
+
params.afterSend?.();
|
|
49338
|
+
if (params.streamInput === true) {
|
|
49339
|
+
requestTask = this._streamInvokeToolRequestChunks(toolCallId, params.input);
|
|
49340
|
+
}
|
|
49041
49341
|
try {
|
|
49042
49342
|
const response = await Promise.race([
|
|
49043
|
-
|
|
49343
|
+
responseRequest,
|
|
49044
49344
|
preOpenError.fut
|
|
49045
49345
|
]);
|
|
49046
49346
|
this._toolCallPreOpenErrors.delete(toolCallId);
|
|
@@ -49094,9 +49394,10 @@ ${newlined}
|
|
|
49094
49394
|
if (params.onBehalfOfId != null) {
|
|
49095
49395
|
request["on_behalf_of_id"] = params.onBehalfOfId;
|
|
49096
49396
|
}
|
|
49397
|
+
const responseRequest = this._dispatchRequest("room.invoke_tool", request);
|
|
49097
49398
|
const requestTask = this._streamInvokeToolRequestChunks(toolCallId, params.input);
|
|
49098
49399
|
try {
|
|
49099
|
-
const response = await
|
|
49400
|
+
const response = await responseRequest;
|
|
49100
49401
|
await requestTask;
|
|
49101
49402
|
if (response instanceof response_js_1.ControlContent && response.method === "open") {
|
|
49102
49403
|
throw new room_server_client_js_1.RoomServerException(`unexpected return type from ${params.toolkit}.${params.tool}`);
|
|
@@ -49126,6 +49427,7 @@ ${newlined}
|
|
|
49126
49427
|
if (params.onBehalfOfId != null) {
|
|
49127
49428
|
request["on_behalf_of_id"] = params.onBehalfOfId;
|
|
49128
49429
|
}
|
|
49430
|
+
const responseRequest = this._dispatchRequest("room.invoke_tool", request);
|
|
49129
49431
|
const requestTask = this._streamInvokeToolRequestChunks(toolCallId, params.input);
|
|
49130
49432
|
void requestTask.catch((error) => {
|
|
49131
49433
|
const stream = this._toolCallStreams.get(toolCallId);
|
|
@@ -49139,7 +49441,7 @@ ${newlined}
|
|
|
49139
49441
|
let response;
|
|
49140
49442
|
try {
|
|
49141
49443
|
response = await Promise.race([
|
|
49142
|
-
|
|
49444
|
+
responseRequest,
|
|
49143
49445
|
preOpenError.fut
|
|
49144
49446
|
]);
|
|
49145
49447
|
} catch (error) {
|
|
@@ -49160,23 +49462,26 @@ ${newlined}
|
|
|
49160
49462
|
}
|
|
49161
49463
|
};
|
|
49162
49464
|
}
|
|
49163
|
-
|
|
49465
|
+
_dispatchToolCallRequestChunk(toolCallId, chunk) {
|
|
49466
|
+
this._raiseIfTerminal();
|
|
49467
|
+
if (this._entered && !this._connected && !this._allowDisconnectedRequests) {
|
|
49468
|
+
throw this._disconnectedError({ baseMessage: "room connection is disconnected" });
|
|
49469
|
+
}
|
|
49164
49470
|
const packed = chunk.pack();
|
|
49165
49471
|
const request = {
|
|
49166
49472
|
tool_call_id: toolCallId,
|
|
49167
49473
|
chunk: JSON.parse((0, utils_js_1.splitMessageHeader)(packed))
|
|
49168
49474
|
};
|
|
49169
49475
|
const payload = (0, utils_js_1.splitMessagePayload)(packed);
|
|
49170
|
-
|
|
49476
|
+
this._protocolInstance.sendNowait("room.tool_call_request_chunk", (0, utils_js_1.packMessage)(request, payload.length > 0 ? payload : void 0));
|
|
49171
49477
|
}
|
|
49172
49478
|
async _streamInvokeToolRequestChunks(toolCallId, input) {
|
|
49173
|
-
await Promise.resolve();
|
|
49174
49479
|
try {
|
|
49175
49480
|
for await (const item of input) {
|
|
49176
|
-
|
|
49481
|
+
this._dispatchToolCallRequestChunk(toolCallId, item);
|
|
49177
49482
|
}
|
|
49178
49483
|
} finally {
|
|
49179
|
-
|
|
49484
|
+
this._dispatchToolCallRequestChunk(toolCallId, new response_js_1.ControlContent({ method: "close" }));
|
|
49180
49485
|
}
|
|
49181
49486
|
}
|
|
49182
49487
|
_decodeToolCallContent(params) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meshagent/meshagent-ts-auth",
|
|
3
|
-
"version": "0.47.
|
|
3
|
+
"version": "0.47.1",
|
|
4
4
|
"description": "Meshagent Typescript Auth",
|
|
5
5
|
"homepage": "https://github.com/meshagent/meshagent-ts-auth",
|
|
6
6
|
"scripts": {
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"CHANGELOG.md"
|
|
40
40
|
],
|
|
41
41
|
"dependencies": {
|
|
42
|
-
"@meshagent/meshagent": "^0.47.
|
|
42
|
+
"@meshagent/meshagent": "^0.47.1",
|
|
43
43
|
"typescript": "^5.8.3"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|