@meshagent/meshagent 0.46.4 → 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 +10 -2
- package/dist/browser/agent.js +6 -6
- package/dist/browser/meshagent-client.d.ts +10 -1
- package/dist/browser/meshagent-client.js +28 -0
- package/dist/browser/messaging-client.d.ts +74 -1
- package/dist/browser/messaging-client.js +350 -28
- package/dist/browser/participant-token.d.ts +1 -0
- package/dist/browser/participant-token.js +3 -0
- package/dist/browser/room-client.d.ts +5 -2
- package/dist/browser/room-client.js +27 -12
- package/dist/esm/agent.js +6 -6
- package/dist/esm/meshagent-client.d.ts +10 -1
- package/dist/esm/meshagent-client.js +28 -0
- package/dist/esm/messaging-client.d.ts +74 -1
- package/dist/esm/messaging-client.js +349 -28
- package/dist/esm/participant-token.d.ts +1 -0
- package/dist/esm/participant-token.js +3 -0
- package/dist/esm/room-client.d.ts +5 -2
- package/dist/esm/room-client.js +27 -12
- package/dist/node/agent.js +6 -6
- package/dist/node/meshagent-client.d.ts +10 -1
- package/dist/node/meshagent-client.js +28 -0
- package/dist/node/messaging-client.d.ts +74 -1
- package/dist/node/messaging-client.js +350 -28
- package/dist/node/participant-token.d.ts +1 -0
- package/dist/node/participant-token.js +3 -0
- package/dist/node/room-client.d.ts +5 -2
- package/dist/node/room-client.js +27 -12
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
|
-
## [0.
|
|
2
|
-
-
|
|
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
|
+
|
|
6
|
+
## [0.47.0]
|
|
7
|
+
- Improved TypeScript messaging clients so room delivery order and startup/presence behavior stay consistent.
|
|
8
|
+
- Moved managed-agent client routing onto the Rust tunnel path and hardened agent chat-client event handling.
|
|
9
|
+
- Added a `test:rust-process-e2e` entry point for the agents-ts package and expanded live chat/process-agent coverage.
|
|
10
|
+
- Finished aligning CLI pagination behavior across feeds, rooms, mailboxes, scheduled tasks, and shared helpers.
|
|
3
11
|
|
|
4
12
|
## [0.46.3]
|
|
5
13
|
- `LivekitProtocolChannel.sendData` now clones outgoing `Uint8Array` payloads before publishing, avoiding shared-buffer mutation issues.
|
package/dist/browser/agent.js
CHANGED
|
@@ -530,10 +530,10 @@ class _RemoteToolkitWrapper {
|
|
|
530
530
|
return false;
|
|
531
531
|
}
|
|
532
532
|
}
|
|
533
|
-
|
|
533
|
+
_sendToolCallResponseChunk(messageId, toolCallId, chunk) {
|
|
534
534
|
const [header, payload] = (0, utils_js_1.unpackMessage)(chunk.pack());
|
|
535
535
|
try {
|
|
536
|
-
|
|
536
|
+
this.client.protocol.sendNowait("room.tool_call_response_chunk", (0, utils_js_1.packMessage)({ tool_call_id: toolCallId, chunk: header }, payload.length > 0 ? payload : undefined), { id: messageId });
|
|
537
537
|
return true;
|
|
538
538
|
}
|
|
539
539
|
catch (error) {
|
|
@@ -634,10 +634,10 @@ class _RemoteToolkitWrapper {
|
|
|
634
634
|
return;
|
|
635
635
|
for await (const chunk of output.stream) {
|
|
636
636
|
this.toolkit.validateOutputContent(tool, chunk);
|
|
637
|
-
if (!
|
|
637
|
+
if (!this._sendToolCallResponseChunk(messageId, toolCallId, chunk))
|
|
638
638
|
return;
|
|
639
639
|
}
|
|
640
|
-
|
|
640
|
+
this._sendToolCallResponseChunk(messageId, toolCallId, new response_js_1.ControlContent({ method: "close" }));
|
|
641
641
|
return;
|
|
642
642
|
}
|
|
643
643
|
throw new Error(`tool ${toolName} returned unsupported output`);
|
|
@@ -648,9 +648,9 @@ class _RemoteToolkitWrapper {
|
|
|
648
648
|
return;
|
|
649
649
|
}
|
|
650
650
|
if (!(error instanceof InvalidToolDataException)) {
|
|
651
|
-
|
|
651
|
+
this._sendToolCallResponseChunk(messageId, toolCallId, new response_js_1.ErrorContent({ text: String(error) }));
|
|
652
652
|
}
|
|
653
|
-
|
|
653
|
+
this._sendToolCallResponseChunk(messageId, toolCallId, new response_js_1.ControlContent({
|
|
654
654
|
method: "close",
|
|
655
655
|
statusCode: error instanceof InvalidToolDataException ? response_js_1.ControlCloseStatus.INVALID_DATA : undefined,
|
|
656
656
|
message: error instanceof InvalidToolDataException ? error.message : undefined,
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { ApiScope } from "./participant-token.js";
|
|
2
2
|
export type ProjectRole = "member" | "admin" | "developer" | "room_creator" | "room_inventory" | "room_manager" | "session_inventory" | "agent_creator" | "agent_inventory" | "agent_manager" | "repository_creator" | "repository_inventory" | "repository_manager" | "feed_creator" | "feed_inventory" | "feed_manager" | "oauth_client_creator" | "oauth_client_inventory" | "oauth_client_manager" | "api_key_creator" | "api_key_inventory" | "api_key_manager" | "service_creator" | "service_inventory" | "service_manager" | "service_account_creator" | "service_account_inventory" | "service_account_manager" | "participant_token_creator" | "mailbox_creator" | "mailbox_inventory" | "mailbox_manager" | "route_creator" | "route_inventory" | "route_manager" | "scheduled_task_creator" | "scheduled_task_inventory" | "scheduled_task_manager" | "feed_subscription_creator" | "feed_subscription_inventory" | "feed_subscription_manager" | "llm_logger_creator" | "llm_logger_inventory" | "llm_logger_manager" | "llm_proxy_user" | "usage_reporter" | "billing_manager" | "group_manager";
|
|
3
3
|
export type ResourceRole = "viewer" | "operator" | "developer" | "admin";
|
|
4
|
+
export type RoomRole = "site_user" | ResourceRole;
|
|
4
5
|
export type FeedRole = "reader" | "subscriber" | "publisher" | "manager";
|
|
5
6
|
export type SecretRole = "use_proxy";
|
|
6
|
-
export type AccessRole = ProjectRole |
|
|
7
|
+
export type AccessRole = ProjectRole | RoomRole | FeedRole | SecretRole | "list";
|
|
7
8
|
export type AccessSubjectType = "user" | "group" | "agent" | "service_account" | "userset";
|
|
8
9
|
export type AccessResourceType = "project" | "room" | "agent" | "group" | "repository" | "feed" | "secret";
|
|
9
10
|
export interface AccessSubject {
|
|
@@ -29,6 +30,12 @@ export interface RoomConnectionInfo {
|
|
|
29
30
|
projectId: string;
|
|
30
31
|
roomUrl: string;
|
|
31
32
|
}
|
|
33
|
+
export interface AgentConnectionInfo {
|
|
34
|
+
jwt: string;
|
|
35
|
+
agentName: string;
|
|
36
|
+
projectId: string;
|
|
37
|
+
agentUrl: string;
|
|
38
|
+
}
|
|
32
39
|
export declare class RoomSession {
|
|
33
40
|
readonly id: string;
|
|
34
41
|
readonly roomId?: string | null;
|
|
@@ -559,6 +566,7 @@ export declare class Meshagent {
|
|
|
559
566
|
private parseTransaction;
|
|
560
567
|
private parseOAuthClient;
|
|
561
568
|
private parseRoomConnectionInfo;
|
|
569
|
+
private parseAgentConnectionInfo;
|
|
562
570
|
private encodePathComponent;
|
|
563
571
|
upload({ projectId, path, data }: {
|
|
564
572
|
projectId: string;
|
|
@@ -908,6 +916,7 @@ export declare class Meshagent {
|
|
|
908
916
|
subjectId: string;
|
|
909
917
|
}): Promise<void>;
|
|
910
918
|
connectRoom(projectId: string, room: string): Promise<RoomConnectionInfo>;
|
|
919
|
+
connectAgent(projectId: string, agentName: string): Promise<AgentConnectionInfo>;
|
|
911
920
|
listRooms(projectId: string, options?: {
|
|
912
921
|
pageSize?: number;
|
|
913
922
|
continuationToken?: string;
|
|
@@ -659,6 +659,7 @@ class Meshagent {
|
|
|
659
659
|
const parsedSubject = this.parseAccessSubject(data.subject);
|
|
660
660
|
const parsedDirectRoles = Array.isArray(data.direct_roles)
|
|
661
661
|
? data.direct_roles.filter((item) => item === "member" ||
|
|
662
|
+
item === "site_user" ||
|
|
662
663
|
item === "viewer" ||
|
|
663
664
|
item === "operator" ||
|
|
664
665
|
item === "developer" ||
|
|
@@ -822,6 +823,25 @@ class Meshagent {
|
|
|
822
823
|
}
|
|
823
824
|
return { jwt, roomName: roomNameValue, projectId: projectIdValue, roomUrl: roomUrlValue };
|
|
824
825
|
}
|
|
826
|
+
parseAgentConnectionInfo(data) {
|
|
827
|
+
if (!data || typeof data !== "object") {
|
|
828
|
+
throw new requirement_js_1.RoomException("Invalid agent connection payload");
|
|
829
|
+
}
|
|
830
|
+
const { jwt, agent_name: agentNameRaw, agentName, project_id: projectIdRaw, projectId, agent_url: agentUrlRaw, agentUrl } = data;
|
|
831
|
+
const agentNameValue = typeof agentName === "string" ? agentName : agentNameRaw;
|
|
832
|
+
const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
|
|
833
|
+
const agentUrlValue = typeof agentUrl === "string" ? agentUrl : agentUrlRaw;
|
|
834
|
+
if (typeof jwt !== "string" || typeof agentNameValue !== "string" || typeof projectIdValue !== "string" || typeof agentUrlValue !== "string") {
|
|
835
|
+
throw new requirement_js_1.RoomException("Invalid agent connection payload: missing fields");
|
|
836
|
+
}
|
|
837
|
+
const parsedUrl = new URL(agentUrlValue);
|
|
838
|
+
const legacySuffix = `/accounts/projects/${encodeURIComponent(projectIdValue)}/agents/${encodeURIComponent(agentNameValue)}/messages`;
|
|
839
|
+
if (parsedUrl.pathname.endsWith(legacySuffix)) {
|
|
840
|
+
const prefix = parsedUrl.pathname.slice(0, -legacySuffix.length);
|
|
841
|
+
parsedUrl.pathname = `${prefix}/agents/${encodeURIComponent(projectIdValue)}/${encodeURIComponent(agentNameValue)}/messages`;
|
|
842
|
+
}
|
|
843
|
+
return { jwt, agentName: agentNameValue, projectId: projectIdValue, agentUrl: parsedUrl.toString() };
|
|
844
|
+
}
|
|
825
845
|
encodePathComponent(value) {
|
|
826
846
|
return encodeURIComponent(value);
|
|
827
847
|
}
|
|
@@ -1847,6 +1867,14 @@ class Meshagent {
|
|
|
1847
1867
|
});
|
|
1848
1868
|
return this.parseRoomConnectionInfo(data);
|
|
1849
1869
|
}
|
|
1870
|
+
async connectAgent(projectId, agentName) {
|
|
1871
|
+
const data = await this.request(`/accounts/projects/${projectId}/agents/${encodeURIComponent(agentName)}/connect`, {
|
|
1872
|
+
method: "POST",
|
|
1873
|
+
json: {},
|
|
1874
|
+
action: "connect agent",
|
|
1875
|
+
});
|
|
1876
|
+
return this.parseAgentConnectionInfo(data);
|
|
1877
|
+
}
|
|
1850
1878
|
async listRooms(projectId, options = {}) {
|
|
1851
1879
|
const { pageSize = 50, continuationToken, filter, view } = options;
|
|
1852
1880
|
const data = await this.request(`/accounts/projects/${projectId}/rooms`, {
|
|
@@ -1,8 +1,72 @@
|
|
|
1
1
|
import { EventEmitter } from "./event-emitter.js";
|
|
2
2
|
import { Participant, RemoteParticipant } from "./participant.js";
|
|
3
|
+
import { Content } from "./response.js";
|
|
3
4
|
import { RoomClient } from "./room-client.js";
|
|
4
|
-
import { RoomMessageEvent } from "./room-event.js";
|
|
5
|
+
import { RoomMessage, RoomMessageEvent } from "./room-event.js";
|
|
5
6
|
type MessagePayload = Record<string, unknown>;
|
|
7
|
+
export type MessagingStreamEvent = {
|
|
8
|
+
kind: "message";
|
|
9
|
+
message: RoomMessage;
|
|
10
|
+
} | {
|
|
11
|
+
kind: "client_disconnected";
|
|
12
|
+
streamId: string;
|
|
13
|
+
participantId: string;
|
|
14
|
+
} | {
|
|
15
|
+
kind: "closed";
|
|
16
|
+
streamId: string;
|
|
17
|
+
reason: string;
|
|
18
|
+
message?: string;
|
|
19
|
+
};
|
|
20
|
+
declare class MessagingStreamInput {
|
|
21
|
+
private readonly items;
|
|
22
|
+
private signal;
|
|
23
|
+
private active;
|
|
24
|
+
private closed;
|
|
25
|
+
private error;
|
|
26
|
+
enqueue(content: Content, { wait }?: {
|
|
27
|
+
wait?: boolean;
|
|
28
|
+
}): Promise<void>;
|
|
29
|
+
close(error?: unknown): void;
|
|
30
|
+
fail(error: unknown): void;
|
|
31
|
+
stream(): AsyncIterable<Content>;
|
|
32
|
+
}
|
|
33
|
+
export declare class MessagingStream implements AsyncIterable<MessagingStreamEvent> {
|
|
34
|
+
readonly streamId: string;
|
|
35
|
+
readonly remoteParticipantId: string;
|
|
36
|
+
private readonly input;
|
|
37
|
+
private readonly output;
|
|
38
|
+
private readonly inputDone;
|
|
39
|
+
private readonly onClosed;
|
|
40
|
+
private readonly events;
|
|
41
|
+
private eventSignal;
|
|
42
|
+
private state;
|
|
43
|
+
constructor({ streamId, remoteParticipantId, input, output, inputClosed, onClosed, }: {
|
|
44
|
+
streamId: string;
|
|
45
|
+
remoteParticipantId: string;
|
|
46
|
+
input: MessagingStreamInput;
|
|
47
|
+
output: AsyncIterator<Content>;
|
|
48
|
+
inputClosed?: Promise<void>;
|
|
49
|
+
onClosed: () => void;
|
|
50
|
+
});
|
|
51
|
+
get closed(): boolean;
|
|
52
|
+
private push;
|
|
53
|
+
private finish;
|
|
54
|
+
private consumeOutput;
|
|
55
|
+
private content;
|
|
56
|
+
sendMessageNowait(params: {
|
|
57
|
+
type: string;
|
|
58
|
+
message: MessagePayload;
|
|
59
|
+
attachment?: Uint8Array;
|
|
60
|
+
}): void;
|
|
61
|
+
sendMessage(params: {
|
|
62
|
+
type: string;
|
|
63
|
+
message: MessagePayload;
|
|
64
|
+
attachment?: Uint8Array;
|
|
65
|
+
}): Promise<void>;
|
|
66
|
+
close(): Promise<void>;
|
|
67
|
+
clientDisconnected(participantId: string): void;
|
|
68
|
+
[Symbol.asyncIterator](): AsyncIterator<MessagingStreamEvent>;
|
|
69
|
+
}
|
|
6
70
|
export declare class MessagingClient extends EventEmitter<RoomMessageEvent> {
|
|
7
71
|
private readonly client;
|
|
8
72
|
private readonly _messageHandler;
|
|
@@ -10,6 +74,8 @@ export declare class MessagingClient extends EventEmitter<RoomMessageEvent> {
|
|
|
10
74
|
private readonly _messageQueue;
|
|
11
75
|
private _messageQueued;
|
|
12
76
|
private _sendTask;
|
|
77
|
+
private readonly _sendOperations;
|
|
78
|
+
private readonly _streams;
|
|
13
79
|
private _messageQueueClosed;
|
|
14
80
|
private _desiredEnabled;
|
|
15
81
|
private _online;
|
|
@@ -42,6 +108,7 @@ export declare class MessagingClient extends EventEmitter<RoomMessageEvent> {
|
|
|
42
108
|
private _dropQueuedMessage;
|
|
43
109
|
private _drainQueuedMessages;
|
|
44
110
|
private _sendMessages;
|
|
111
|
+
private _sendQueuedMessage;
|
|
45
112
|
sendMessage({ to, type, message, attachment, ignoreOffline, }: {
|
|
46
113
|
to: Participant;
|
|
47
114
|
type: string;
|
|
@@ -62,6 +129,12 @@ export declare class MessagingClient extends EventEmitter<RoomMessageEvent> {
|
|
|
62
129
|
message: MessagePayload;
|
|
63
130
|
attachment?: Uint8Array;
|
|
64
131
|
}): Promise<void>;
|
|
132
|
+
stream({ to, type, message, attachment, }: {
|
|
133
|
+
to: Participant;
|
|
134
|
+
type: string;
|
|
135
|
+
message: MessagePayload;
|
|
136
|
+
attachment?: Uint8Array;
|
|
137
|
+
}): Promise<MessagingStream>;
|
|
65
138
|
getParticipants(): RemoteParticipant[];
|
|
66
139
|
getParticipant(id: string): RemoteParticipant | null;
|
|
67
140
|
getParticipantByName(name: string): RemoteParticipant | null;
|