@meshagent/meshagent 0.40.2 → 0.41.0
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 +9 -0
- package/dist/browser/agent-client.d.ts +2 -8
- package/dist/browser/agent-client.js +2 -14
- package/dist/browser/agent.d.ts +2 -6
- package/dist/browser/agent.js +2 -6
- package/dist/browser/meshagent-client.d.ts +88 -0
- package/dist/browser/meshagent-client.js +92 -0
- package/dist/browser/room-client.d.ts +1 -5
- package/dist/browser/room-client.js +1 -11
- package/dist/browser/storage-client.js +1 -2
- package/dist/esm/agent-client.d.ts +2 -8
- package/dist/esm/agent-client.js +2 -14
- package/dist/esm/agent.d.ts +2 -6
- package/dist/esm/agent.js +2 -6
- package/dist/esm/meshagent-client.d.ts +88 -0
- package/dist/esm/meshagent-client.js +92 -0
- package/dist/esm/room-client.d.ts +1 -5
- package/dist/esm/room-client.js +1 -11
- package/dist/esm/storage-client.js +1 -2
- package/dist/node/agent-client.d.ts +2 -8
- package/dist/node/agent-client.js +2 -14
- package/dist/node/agent.d.ts +2 -6
- package/dist/node/agent.js +2 -6
- package/dist/node/meshagent-client.d.ts +88 -0
- package/dist/node/meshagent-client.js +92 -0
- package/dist/node/room-client.d.ts +1 -5
- package/dist/node/room-client.js +1 -11
- package/dist/node/storage-client.js +1 -2
- package/package.json +1 -1
|
@@ -207,6 +207,38 @@ export interface ServiceSpec {
|
|
|
207
207
|
container?: ContainerSpec | null;
|
|
208
208
|
external?: ExternalServiceSpec | null;
|
|
209
209
|
}
|
|
210
|
+
export interface RouteMetadata {
|
|
211
|
+
name: string;
|
|
212
|
+
annotations?: Record<string, string>;
|
|
213
|
+
}
|
|
214
|
+
export interface RouteBackendTarget {
|
|
215
|
+
name: string;
|
|
216
|
+
}
|
|
217
|
+
export interface RouteBackend {
|
|
218
|
+
room?: RouteBackendTarget | null;
|
|
219
|
+
agent?: RouteBackendTarget | null;
|
|
220
|
+
}
|
|
221
|
+
export interface RoutePathSpec {
|
|
222
|
+
path?: string;
|
|
223
|
+
pathType?: "prefix" | "exact";
|
|
224
|
+
targetPort: string | number;
|
|
225
|
+
}
|
|
226
|
+
export interface RouteSpec {
|
|
227
|
+
version: "v1";
|
|
228
|
+
kind: "Route";
|
|
229
|
+
metadata: RouteMetadata;
|
|
230
|
+
domain: string;
|
|
231
|
+
backend: RouteBackend;
|
|
232
|
+
paths?: RoutePathSpec[];
|
|
233
|
+
}
|
|
234
|
+
export interface Route {
|
|
235
|
+
domain: string;
|
|
236
|
+
spec: RouteSpec;
|
|
237
|
+
}
|
|
238
|
+
export interface RoutesPage {
|
|
239
|
+
routes: Route[];
|
|
240
|
+
total: number;
|
|
241
|
+
}
|
|
210
242
|
export interface Mailbox {
|
|
211
243
|
address: string;
|
|
212
244
|
room: string;
|
|
@@ -344,6 +376,7 @@ export declare class Meshagent {
|
|
|
344
376
|
private parseRoomShare;
|
|
345
377
|
private parseRoomSession;
|
|
346
378
|
private parseRoom;
|
|
379
|
+
private parseRoute;
|
|
347
380
|
private parseFeed;
|
|
348
381
|
private parseFeedSubscription;
|
|
349
382
|
private parseLLMLogger;
|
|
@@ -752,6 +785,61 @@ export declare class Meshagent {
|
|
|
752
785
|
offset?: number;
|
|
753
786
|
orderBy?: string;
|
|
754
787
|
}): Promise<RoomInfo[]>;
|
|
788
|
+
createRoute(params: {
|
|
789
|
+
projectId: string;
|
|
790
|
+
spec: RouteSpec;
|
|
791
|
+
}): Promise<void>;
|
|
792
|
+
updateRoute(params: {
|
|
793
|
+
projectId: string;
|
|
794
|
+
domain: string;
|
|
795
|
+
spec: RouteSpec;
|
|
796
|
+
}): Promise<void>;
|
|
797
|
+
getRoute(params: {
|
|
798
|
+
projectId: string;
|
|
799
|
+
domain: string;
|
|
800
|
+
}): Promise<Route>;
|
|
801
|
+
listRoutesPage(projectId: string, options?: {
|
|
802
|
+
count?: number;
|
|
803
|
+
offset?: number;
|
|
804
|
+
filter?: string;
|
|
805
|
+
}): Promise<RoutesPage>;
|
|
806
|
+
listRoutes(projectId: string, options?: {
|
|
807
|
+
count?: number;
|
|
808
|
+
offset?: number;
|
|
809
|
+
filter?: string;
|
|
810
|
+
}): Promise<Route[]>;
|
|
811
|
+
listRoomRoutesPage(params: {
|
|
812
|
+
projectId: string;
|
|
813
|
+
roomName: string;
|
|
814
|
+
count?: number;
|
|
815
|
+
offset?: number;
|
|
816
|
+
filter?: string;
|
|
817
|
+
}): Promise<RoutesPage>;
|
|
818
|
+
listRoomRoutes(params: {
|
|
819
|
+
projectId: string;
|
|
820
|
+
roomName: string;
|
|
821
|
+
count?: number;
|
|
822
|
+
offset?: number;
|
|
823
|
+
filter?: string;
|
|
824
|
+
}): Promise<Route[]>;
|
|
825
|
+
listAgentRoutesPage(params: {
|
|
826
|
+
projectId: string;
|
|
827
|
+
agentName: string;
|
|
828
|
+
count?: number;
|
|
829
|
+
offset?: number;
|
|
830
|
+
filter?: string;
|
|
831
|
+
}): Promise<RoutesPage>;
|
|
832
|
+
listAgentRoutes(params: {
|
|
833
|
+
projectId: string;
|
|
834
|
+
agentName: string;
|
|
835
|
+
count?: number;
|
|
836
|
+
offset?: number;
|
|
837
|
+
filter?: string;
|
|
838
|
+
}): Promise<Route[]>;
|
|
839
|
+
deleteRoute(params: {
|
|
840
|
+
projectId: string;
|
|
841
|
+
domain: string;
|
|
842
|
+
}): Promise<void>;
|
|
755
843
|
listRoomGrants(projectId: string, options?: {
|
|
756
844
|
limit?: number;
|
|
757
845
|
offset?: number;
|
|
@@ -231,6 +231,28 @@ class Meshagent {
|
|
|
231
231
|
annotations: annotations && typeof annotations === "object" ? annotations : {},
|
|
232
232
|
};
|
|
233
233
|
}
|
|
234
|
+
parseRoute(data) {
|
|
235
|
+
if (!data || typeof data !== "object") {
|
|
236
|
+
throw new requirement_1.RoomException("Invalid route payload: expected object");
|
|
237
|
+
}
|
|
238
|
+
if (data.spec && typeof data.spec === "object") {
|
|
239
|
+
return { domain: String(data.domain ?? data.spec.domain), spec: data.spec };
|
|
240
|
+
}
|
|
241
|
+
if (typeof data.domain === "string" && typeof data.room_name === "string") {
|
|
242
|
+
return {
|
|
243
|
+
domain: data.domain,
|
|
244
|
+
spec: {
|
|
245
|
+
version: "v1",
|
|
246
|
+
kind: "Route",
|
|
247
|
+
metadata: { name: data.domain, annotations: data.annotations ?? {} },
|
|
248
|
+
domain: data.domain,
|
|
249
|
+
backend: { room: { name: data.room_name } },
|
|
250
|
+
paths: [{ path: "/", pathType: "prefix", targetPort: data.port }],
|
|
251
|
+
},
|
|
252
|
+
};
|
|
253
|
+
}
|
|
254
|
+
throw new requirement_1.RoomException("Invalid route payload: missing spec");
|
|
255
|
+
}
|
|
234
256
|
parseFeed(data) {
|
|
235
257
|
if (!data || typeof data !== "object") {
|
|
236
258
|
throw new requirement_1.RoomException("Invalid feed payload");
|
|
@@ -1726,6 +1748,76 @@ class Meshagent {
|
|
|
1726
1748
|
const rooms = Array.isArray(data?.rooms) ? data.rooms : [];
|
|
1727
1749
|
return rooms.map((item) => this.parseRoom(item));
|
|
1728
1750
|
}
|
|
1751
|
+
async createRoute(params) {
|
|
1752
|
+
await this.request(`/accounts/projects/${params.projectId}/routes`, {
|
|
1753
|
+
method: "POST",
|
|
1754
|
+
json: { spec: params.spec },
|
|
1755
|
+
action: "create route",
|
|
1756
|
+
responseType: "void",
|
|
1757
|
+
});
|
|
1758
|
+
}
|
|
1759
|
+
async updateRoute(params) {
|
|
1760
|
+
const domain = this.encodePathComponent(params.domain);
|
|
1761
|
+
await this.request(`/accounts/projects/${params.projectId}/routes/${domain}`, {
|
|
1762
|
+
method: "PUT",
|
|
1763
|
+
json: { spec: params.spec },
|
|
1764
|
+
action: "update route",
|
|
1765
|
+
responseType: "void",
|
|
1766
|
+
});
|
|
1767
|
+
}
|
|
1768
|
+
async getRoute(params) {
|
|
1769
|
+
const domain = this.encodePathComponent(params.domain);
|
|
1770
|
+
const data = await this.request(`/accounts/projects/${params.projectId}/routes/${domain}`, {
|
|
1771
|
+
action: "get route",
|
|
1772
|
+
});
|
|
1773
|
+
return this.parseRoute(data.route);
|
|
1774
|
+
}
|
|
1775
|
+
async listRoutesPage(projectId, options = {}) {
|
|
1776
|
+
const { count = 100, offset = 0, filter } = options;
|
|
1777
|
+
const data = await this.request(`/accounts/projects/${projectId}/routes`, {
|
|
1778
|
+
query: { count, offset, filter },
|
|
1779
|
+
action: "list routes",
|
|
1780
|
+
});
|
|
1781
|
+
const routes = Array.isArray(data.routes) ? data.routes.map((item) => this.parseRoute(item)) : [];
|
|
1782
|
+
return { routes, total: Number(data.total ?? routes.length) };
|
|
1783
|
+
}
|
|
1784
|
+
async listRoutes(projectId, options = {}) {
|
|
1785
|
+
return (await this.listRoutesPage(projectId, options)).routes;
|
|
1786
|
+
}
|
|
1787
|
+
async listRoomRoutesPage(params) {
|
|
1788
|
+
const { projectId, roomName, count = 100, offset = 0, filter } = params;
|
|
1789
|
+
const room = this.encodePathComponent(roomName);
|
|
1790
|
+
const data = await this.request(`/accounts/projects/${projectId}/rooms/${room}/routes`, {
|
|
1791
|
+
query: { count, offset, filter },
|
|
1792
|
+
action: "list room routes",
|
|
1793
|
+
});
|
|
1794
|
+
const routes = Array.isArray(data.routes) ? data.routes.map((item) => this.parseRoute(item)) : [];
|
|
1795
|
+
return { routes, total: Number(data.total ?? routes.length) };
|
|
1796
|
+
}
|
|
1797
|
+
async listRoomRoutes(params) {
|
|
1798
|
+
return (await this.listRoomRoutesPage(params)).routes;
|
|
1799
|
+
}
|
|
1800
|
+
async listAgentRoutesPage(params) {
|
|
1801
|
+
const { projectId, agentName, count = 100, offset = 0, filter } = params;
|
|
1802
|
+
const agent = this.encodePathComponent(agentName);
|
|
1803
|
+
const data = await this.request(`/accounts/projects/${projectId}/agents/${agent}/routes`, {
|
|
1804
|
+
query: { count, offset, filter },
|
|
1805
|
+
action: "list agent routes",
|
|
1806
|
+
});
|
|
1807
|
+
const routes = Array.isArray(data.routes) ? data.routes.map((item) => this.parseRoute(item)) : [];
|
|
1808
|
+
return { routes, total: Number(data.total ?? routes.length) };
|
|
1809
|
+
}
|
|
1810
|
+
async listAgentRoutes(params) {
|
|
1811
|
+
return (await this.listAgentRoutesPage(params)).routes;
|
|
1812
|
+
}
|
|
1813
|
+
async deleteRoute(params) {
|
|
1814
|
+
const domain = this.encodePathComponent(params.domain);
|
|
1815
|
+
await this.request(`/accounts/projects/${params.projectId}/routes/${domain}`, {
|
|
1816
|
+
method: "DELETE",
|
|
1817
|
+
action: "delete route",
|
|
1818
|
+
responseType: "void",
|
|
1819
|
+
});
|
|
1820
|
+
}
|
|
1729
1821
|
async listRoomGrants(projectId, options = {}) {
|
|
1730
1822
|
const { limit = 50, offset = 0, orderBy = "room_name" } = options;
|
|
1731
1823
|
const data = await this.request(`/accounts/projects/${projectId}/room-grants`, {
|
|
@@ -176,13 +176,12 @@ export declare class RoomClient {
|
|
|
176
176
|
label: string;
|
|
177
177
|
expectResponse?: boolean;
|
|
178
178
|
}): number | null;
|
|
179
|
-
invokeNowait({ toolkit, tool, input, participantId, onBehalfOfId,
|
|
179
|
+
invokeNowait({ toolkit, tool, input, participantId, onBehalfOfId, }: {
|
|
180
180
|
toolkit: string;
|
|
181
181
|
tool: string;
|
|
182
182
|
input?: Content;
|
|
183
183
|
participantId?: string;
|
|
184
184
|
onBehalfOfId?: string;
|
|
185
|
-
callerContext?: Record<string, unknown>;
|
|
186
185
|
}): void;
|
|
187
186
|
_sendLocalAttributesNowait(attributes: Record<string, unknown>): void;
|
|
188
187
|
_resendLocalAttributesNowait(): void;
|
|
@@ -204,7 +203,6 @@ export declare class RoomClient {
|
|
|
204
203
|
input?: Record<string, unknown> | Content;
|
|
205
204
|
participantId?: string;
|
|
206
205
|
onBehalfOfId?: string;
|
|
207
|
-
callerContext?: Record<string, unknown>;
|
|
208
206
|
}): Promise<Content>;
|
|
209
207
|
invokeWithStreamInput(params: {
|
|
210
208
|
toolkit: string;
|
|
@@ -212,7 +210,6 @@ export declare class RoomClient {
|
|
|
212
210
|
input: AsyncIterable<Content>;
|
|
213
211
|
participantId?: string;
|
|
214
212
|
onBehalfOfId?: string;
|
|
215
|
-
callerContext?: Record<string, unknown>;
|
|
216
213
|
}): Promise<Content>;
|
|
217
214
|
invokeStream(params: {
|
|
218
215
|
toolkit: string;
|
|
@@ -220,7 +217,6 @@ export declare class RoomClient {
|
|
|
220
217
|
input: AsyncIterable<Content>;
|
|
221
218
|
participantId?: string;
|
|
222
219
|
onBehalfOfId?: string;
|
|
223
|
-
callerContext?: Record<string, unknown>;
|
|
224
220
|
}): Promise<AsyncIterable<Content>>;
|
|
225
221
|
private _sendToolCallRequestChunk;
|
|
226
222
|
private _streamInvokeToolRequestChunks;
|
package/dist/node/room-client.js
CHANGED
|
@@ -1108,7 +1108,7 @@ class RoomClient {
|
|
|
1108
1108
|
expectResponse,
|
|
1109
1109
|
});
|
|
1110
1110
|
}
|
|
1111
|
-
invokeNowait({ toolkit, tool, input, participantId, onBehalfOfId,
|
|
1111
|
+
invokeNowait({ toolkit, tool, input, participantId, onBehalfOfId, }) {
|
|
1112
1112
|
const resolvedInput = input ?? new response_1.EmptyContent();
|
|
1113
1113
|
const packedInput = (0, utils_1.unpackMessage)(resolvedInput.pack());
|
|
1114
1114
|
const request = {
|
|
@@ -1116,7 +1116,6 @@ class RoomClient {
|
|
|
1116
1116
|
tool,
|
|
1117
1117
|
participant_id: participantId,
|
|
1118
1118
|
on_behalf_of_id: onBehalfOfId,
|
|
1119
|
-
caller_context: callerContext,
|
|
1120
1119
|
tool_call_id: `${Date.now()}-${Math.random().toString(16).slice(2)}`,
|
|
1121
1120
|
arguments: packedInput[0],
|
|
1122
1121
|
};
|
|
@@ -1228,9 +1227,6 @@ class RoomClient {
|
|
|
1228
1227
|
if (params.onBehalfOfId != null) {
|
|
1229
1228
|
request["on_behalf_of_id"] = params.onBehalfOfId;
|
|
1230
1229
|
}
|
|
1231
|
-
if (params.callerContext != null) {
|
|
1232
|
-
request["caller_context"] = params.callerContext;
|
|
1233
|
-
}
|
|
1234
1230
|
return await this.sendRequest("room.invoke_tool", request, requestData);
|
|
1235
1231
|
}
|
|
1236
1232
|
async invokeWithStreamInput(params) {
|
|
@@ -1247,9 +1243,6 @@ class RoomClient {
|
|
|
1247
1243
|
if (params.onBehalfOfId != null) {
|
|
1248
1244
|
request["on_behalf_of_id"] = params.onBehalfOfId;
|
|
1249
1245
|
}
|
|
1250
|
-
if (params.callerContext != null) {
|
|
1251
|
-
request["caller_context"] = params.callerContext;
|
|
1252
|
-
}
|
|
1253
1246
|
const requestTask = this._streamInvokeToolRequestChunks(toolCallId, params.input);
|
|
1254
1247
|
try {
|
|
1255
1248
|
const response = await this.sendRequest("room.invoke_tool", request);
|
|
@@ -1281,9 +1274,6 @@ class RoomClient {
|
|
|
1281
1274
|
if (params.onBehalfOfId != null) {
|
|
1282
1275
|
request["on_behalf_of_id"] = params.onBehalfOfId;
|
|
1283
1276
|
}
|
|
1284
|
-
if (params.callerContext != null) {
|
|
1285
|
-
request["caller_context"] = params.callerContext;
|
|
1286
|
-
}
|
|
1287
1277
|
const requestTask = this._streamInvokeToolRequestChunks(toolCallId, params.input);
|
|
1288
1278
|
void requestTask.catch((error) => {
|
|
1289
1279
|
const stream = this._toolCallStreams.get(toolCallId);
|
|
@@ -136,12 +136,11 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
136
136
|
updatedAt: _parseStorageTimestamp(value["updated_at"], operation),
|
|
137
137
|
});
|
|
138
138
|
}
|
|
139
|
-
async _invoke(operation, input
|
|
139
|
+
async _invoke(operation, input) {
|
|
140
140
|
return await this.client.invoke({
|
|
141
141
|
toolkit: "storage",
|
|
142
142
|
tool: operation,
|
|
143
143
|
input,
|
|
144
|
-
callerContext,
|
|
145
144
|
});
|
|
146
145
|
}
|
|
147
146
|
async list(path) {
|