@meshagent/meshagent 0.38.4 → 0.39.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 +14 -2
- package/dist/browser/datasets-client.d.ts +415 -0
- package/dist/{node/database-client.js → browser/datasets-client.js} +480 -234
- package/dist/browser/entrypoint.js +9 -17
- package/dist/browser/index.d.ts +1 -2
- package/dist/browser/index.js +1 -2
- package/dist/browser/meshagent-client.d.ts +179 -3
- package/dist/browser/meshagent-client.js +333 -25
- package/dist/browser/participant-token.d.ts +5 -5
- package/dist/browser/participant-token.js +14 -13
- package/dist/browser/room-client.d.ts +5 -3
- package/dist/browser/room-client.js +70 -4
- package/dist/esm/datasets-client.d.ts +415 -0
- package/dist/esm/{database-client.js → datasets-client.js} +473 -227
- package/dist/esm/entrypoint.js +6 -12
- package/dist/esm/index.d.ts +1 -2
- package/dist/esm/index.js +1 -2
- package/dist/esm/meshagent-client.d.ts +179 -3
- package/dist/esm/meshagent-client.js +333 -25
- package/dist/esm/participant-token.d.ts +5 -5
- package/dist/esm/participant-token.js +12 -11
- package/dist/esm/room-client.d.ts +5 -3
- package/dist/esm/room-client.js +70 -4
- package/dist/node/datasets-client.d.ts +415 -0
- package/dist/{browser/database-client.js → node/datasets-client.js} +480 -234
- package/dist/node/entrypoint.js +6 -12
- package/dist/node/index.d.ts +1 -2
- package/dist/node/index.js +1 -2
- package/dist/node/meshagent-client.d.ts +179 -3
- package/dist/node/meshagent-client.js +333 -25
- package/dist/node/participant-token.d.ts +5 -5
- package/dist/node/participant-token.js +14 -13
- package/dist/node/room-client.d.ts +5 -3
- package/dist/node/room-client.js +70 -4
- package/package.json +3 -2
- package/dist/browser/data-types.d.ts +0 -67
- package/dist/browser/data-types.js +0 -192
- package/dist/browser/database-client.d.ts +0 -281
- package/dist/esm/data-types.d.ts +0 -67
- package/dist/esm/data-types.js +0 -179
- package/dist/esm/database-client.d.ts +0 -281
- package/dist/node/data-types.d.ts +0 -67
- package/dist/node/data-types.js +0 -192
- package/dist/node/database-client.d.ts +0 -281
|
@@ -226,6 +226,102 @@ class Meshagent {
|
|
|
226
226
|
annotations: annotations && typeof annotations === "object" ? annotations : {},
|
|
227
227
|
};
|
|
228
228
|
}
|
|
229
|
+
parseFeed(data) {
|
|
230
|
+
if (!data || typeof data !== "object") {
|
|
231
|
+
throw new requirement_1.RoomException("Invalid feed payload");
|
|
232
|
+
}
|
|
233
|
+
const { id, project_id: projectIdRaw, projectId, created_at: createdAtRaw, createdAt, name, description, visibility, paused, annotations, message_schema: messageSchemaRaw, messageSchema, } = data;
|
|
234
|
+
const projectIdValue = typeof projectId === "string"
|
|
235
|
+
? projectId
|
|
236
|
+
: typeof projectIdRaw === "string"
|
|
237
|
+
? projectIdRaw
|
|
238
|
+
: undefined;
|
|
239
|
+
const createdAtValue = typeof createdAt === "string"
|
|
240
|
+
? createdAt
|
|
241
|
+
: typeof createdAtRaw === "string"
|
|
242
|
+
? createdAtRaw
|
|
243
|
+
: undefined;
|
|
244
|
+
const visibilityValue = visibility === "public" || visibility === "project" || visibility === "private"
|
|
245
|
+
? visibility
|
|
246
|
+
: undefined;
|
|
247
|
+
const messageSchemaValue = typeof messageSchema === "boolean" || (messageSchema && typeof messageSchema === "object")
|
|
248
|
+
? messageSchema
|
|
249
|
+
: typeof messageSchemaRaw === "boolean" || (messageSchemaRaw && typeof messageSchemaRaw === "object")
|
|
250
|
+
? messageSchemaRaw
|
|
251
|
+
: null;
|
|
252
|
+
if (typeof id !== "string" ||
|
|
253
|
+
typeof projectIdValue !== "string" ||
|
|
254
|
+
typeof createdAtValue !== "string" ||
|
|
255
|
+
typeof name !== "string" ||
|
|
256
|
+
visibilityValue === undefined) {
|
|
257
|
+
throw new requirement_1.RoomException("Invalid feed payload: missing required fields");
|
|
258
|
+
}
|
|
259
|
+
return {
|
|
260
|
+
id,
|
|
261
|
+
projectId: projectIdValue,
|
|
262
|
+
createdAt: new Date(createdAtValue),
|
|
263
|
+
name,
|
|
264
|
+
description: typeof description === "string" ? description : "",
|
|
265
|
+
visibility: visibilityValue,
|
|
266
|
+
paused: paused === true,
|
|
267
|
+
annotations: annotations && typeof annotations === "object" ? annotations : {},
|
|
268
|
+
messageSchema: messageSchemaValue,
|
|
269
|
+
};
|
|
270
|
+
}
|
|
271
|
+
parseFeedSubscription(data) {
|
|
272
|
+
if (!data || typeof data !== "object") {
|
|
273
|
+
throw new requirement_1.RoomException("Invalid feed subscription payload");
|
|
274
|
+
}
|
|
275
|
+
const { id, feed_id: feedIdRaw, feedId, project_id: projectIdRaw, projectId, room, room_id: roomIdRaw, roomId, path, created_at: createdAtRaw, createdAt, annotations, } = data;
|
|
276
|
+
const feedIdValue = typeof feedId === "string" ? feedId : feedIdRaw;
|
|
277
|
+
const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
|
|
278
|
+
const createdAtValue = typeof createdAt === "string" ? createdAt : createdAtRaw;
|
|
279
|
+
const roomIdValue = typeof roomId === "string" ? roomId : roomIdRaw;
|
|
280
|
+
if (typeof id !== "string" ||
|
|
281
|
+
typeof feedIdValue !== "string" ||
|
|
282
|
+
typeof projectIdValue !== "string" ||
|
|
283
|
+
typeof room !== "string" ||
|
|
284
|
+
typeof path !== "string" ||
|
|
285
|
+
typeof createdAtValue !== "string") {
|
|
286
|
+
throw new requirement_1.RoomException("Invalid feed subscription payload: missing required fields");
|
|
287
|
+
}
|
|
288
|
+
return {
|
|
289
|
+
id,
|
|
290
|
+
feedId: feedIdValue,
|
|
291
|
+
projectId: projectIdValue,
|
|
292
|
+
room,
|
|
293
|
+
roomId: typeof roomIdValue === "string" ? roomIdValue : undefined,
|
|
294
|
+
path,
|
|
295
|
+
createdAt: new Date(createdAtValue),
|
|
296
|
+
annotations: annotations && typeof annotations === "object" ? annotations : {},
|
|
297
|
+
};
|
|
298
|
+
}
|
|
299
|
+
parseLLMLogger(data) {
|
|
300
|
+
if (!data || typeof data !== "object") {
|
|
301
|
+
throw new requirement_1.RoomException("Invalid LLM logger payload");
|
|
302
|
+
}
|
|
303
|
+
const { id, project_id: projectIdRaw, projectId, destination_feed_id: destinationFeedIdRaw, destinationFeedId, filter_expression: filterExpressionRaw, filterExpression, paused, created_at: createdAtRaw, createdAt, annotations, } = data;
|
|
304
|
+
const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
|
|
305
|
+
const destinationFeedIdValue = typeof destinationFeedId === "string" ? destinationFeedId : destinationFeedIdRaw;
|
|
306
|
+
const filterExpressionValue = typeof filterExpression === "string" ? filterExpression : filterExpressionRaw;
|
|
307
|
+
const createdAtValue = typeof createdAt === "string" ? createdAt : createdAtRaw;
|
|
308
|
+
if (typeof id !== "string" ||
|
|
309
|
+
typeof projectIdValue !== "string" ||
|
|
310
|
+
typeof destinationFeedIdValue !== "string" ||
|
|
311
|
+
typeof filterExpressionValue !== "string" ||
|
|
312
|
+
typeof createdAtValue !== "string") {
|
|
313
|
+
throw new requirement_1.RoomException("Invalid LLM logger payload: missing required fields");
|
|
314
|
+
}
|
|
315
|
+
return {
|
|
316
|
+
id,
|
|
317
|
+
projectId: projectIdValue,
|
|
318
|
+
destinationFeedId: destinationFeedIdValue,
|
|
319
|
+
filterExpression: filterExpressionValue,
|
|
320
|
+
paused: paused === true,
|
|
321
|
+
createdAt: new Date(createdAtValue),
|
|
322
|
+
annotations: annotations && typeof annotations === "object" ? annotations : {},
|
|
323
|
+
};
|
|
324
|
+
}
|
|
229
325
|
parseProjectRepository(data) {
|
|
230
326
|
if (!data || typeof data !== "object") {
|
|
231
327
|
throw new requirement_1.RoomException("Invalid repository payload");
|
|
@@ -313,11 +409,17 @@ class Meshagent {
|
|
|
313
409
|
const threshold = data.auto_recharge_threshold ?? data.autoRechargeThreshold;
|
|
314
410
|
const amount = data.auto_recharge_amount ?? data.autoRechargeAmount;
|
|
315
411
|
const lastRechargeRaw = data.last_recharge ?? data.lastRecharge;
|
|
412
|
+
const monthlyBudget = data.monthly_budget ?? data.monthlyBudget;
|
|
413
|
+
const autoRechargePaused = data.auto_recharge_paused ?? data.autoRechargePaused;
|
|
414
|
+
const autoRechargedThisMonth = data.auto_recharged_this_month ?? data.autoRechargedThisMonth;
|
|
316
415
|
return {
|
|
317
416
|
balance: balanceValue,
|
|
318
417
|
autoRechargeThreshold: typeof threshold === "number" ? threshold : null,
|
|
319
418
|
autoRechargeAmount: typeof amount === "number" ? amount : null,
|
|
320
419
|
lastRecharge: typeof lastRechargeRaw === "string" ? new Date(lastRechargeRaw) : null,
|
|
420
|
+
monthlyBudget: typeof monthlyBudget === "number" ? monthlyBudget : null,
|
|
421
|
+
autoRechargePaused: autoRechargePaused === true,
|
|
422
|
+
autoRechargedThisMonth: typeof autoRechargedThisMonth === "number" ? autoRechargedThisMonth : null,
|
|
321
423
|
};
|
|
322
424
|
}
|
|
323
425
|
parseTransaction(data) {
|
|
@@ -672,10 +774,18 @@ class Meshagent {
|
|
|
672
774
|
action: "update project settings",
|
|
673
775
|
});
|
|
674
776
|
}
|
|
675
|
-
async
|
|
676
|
-
|
|
777
|
+
async getUsersInProjectPage(projectId, options = {}) {
|
|
778
|
+
const { count = 100, offset = 0, filter } = options;
|
|
779
|
+
const data = await this.request(`/accounts/projects/${projectId}/users`, {
|
|
780
|
+
query: { count, offset, filter },
|
|
677
781
|
action: "fetch project users",
|
|
678
782
|
});
|
|
783
|
+
const users = Array.isArray(data?.users) ? data.users : [];
|
|
784
|
+
return { users, total: typeof data?.total === "number" ? data.total : users.length };
|
|
785
|
+
}
|
|
786
|
+
async getUsersInProject(projectId) {
|
|
787
|
+
const page = await this.getUsersInProjectPage(projectId);
|
|
788
|
+
return { users: page.users, total: page.total };
|
|
679
789
|
}
|
|
680
790
|
async getUserProfile(userId) {
|
|
681
791
|
return await this.request(`/accounts/profiles/${userId}`, {
|
|
@@ -746,10 +856,10 @@ class Meshagent {
|
|
|
746
856
|
const list = Array.isArray(data?.transactions) ? data.transactions : [];
|
|
747
857
|
return list.map((item) => this.parseTransaction(item));
|
|
748
858
|
}
|
|
749
|
-
async setAutoRecharge({ projectId, enabled, amount, threshold }) {
|
|
859
|
+
async setAutoRecharge({ projectId, enabled, amount, threshold, monthlyBudget = null, }) {
|
|
750
860
|
await this.request(`/accounts/projects/${projectId}/recharge`, {
|
|
751
861
|
method: "POST",
|
|
752
|
-
json: { enabled, amount, threshold },
|
|
862
|
+
json: { enabled, amount, threshold, monthly_budget: monthlyBudget },
|
|
753
863
|
action: "update auto recharge settings",
|
|
754
864
|
responseType: "void",
|
|
755
865
|
});
|
|
@@ -784,7 +894,7 @@ class Meshagent {
|
|
|
784
894
|
});
|
|
785
895
|
}
|
|
786
896
|
async getUsage(projectId, options = {}) {
|
|
787
|
-
const { start, end, interval, report, users, room, provider, model, usageType } = options;
|
|
897
|
+
const { start, end, interval, report, users, room, provider, model, usageType, client, annotations } = options;
|
|
788
898
|
const data = await this.request(`/accounts/projects/${projectId}/usage`, {
|
|
789
899
|
query: {
|
|
790
900
|
start: start ? start.toISOString() : undefined,
|
|
@@ -796,6 +906,8 @@ class Meshagent {
|
|
|
796
906
|
provider: provider && provider.trim().length > 0 ? provider.trim() : undefined,
|
|
797
907
|
model: model && model.trim().length > 0 ? model.trim() : undefined,
|
|
798
908
|
usage_type: usageType && usageType.trim().length > 0 ? usageType.trim() : undefined,
|
|
909
|
+
client: client && client.trim().length > 0 ? client.trim() : undefined,
|
|
910
|
+
annotations: annotations && Object.keys(annotations).length > 0 ? JSON.stringify(annotations) : undefined,
|
|
799
911
|
},
|
|
800
912
|
action: "retrieve usage",
|
|
801
913
|
});
|
|
@@ -898,24 +1010,32 @@ class Meshagent {
|
|
|
898
1010
|
responseType: "void",
|
|
899
1011
|
});
|
|
900
1012
|
}
|
|
901
|
-
|
|
1013
|
+
parseMailbox(item) {
|
|
1014
|
+
if (!item || typeof item !== "object") {
|
|
1015
|
+
throw new requirement_1.RoomException("Invalid mailbox payload");
|
|
1016
|
+
}
|
|
1017
|
+
const { address, room, room_id, queue } = item;
|
|
1018
|
+
if (typeof address !== "string" || typeof room !== "string" || typeof queue !== "string") {
|
|
1019
|
+
throw new requirement_1.RoomException("Invalid mailbox payload: missing fields");
|
|
1020
|
+
}
|
|
1021
|
+
if (room_id !== undefined && typeof room_id !== "string") {
|
|
1022
|
+
throw new requirement_1.RoomException("Invalid mailbox payload: invalid room_id");
|
|
1023
|
+
}
|
|
1024
|
+
return { address, room, roomId: room_id, queue };
|
|
1025
|
+
}
|
|
1026
|
+
async listMailboxesPage(projectId, options = {}) {
|
|
1027
|
+
const { count = 100, offset = 0, filter } = options;
|
|
902
1028
|
const data = await this.request(`/accounts/projects/${projectId}/mailboxes`, {
|
|
1029
|
+
query: { count, offset, filter },
|
|
903
1030
|
action: "list mailboxes",
|
|
904
1031
|
});
|
|
905
1032
|
const mailboxes = Array.isArray(data?.mailboxes) ? data.mailboxes : [];
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
throw new requirement_1.RoomException("Invalid mailbox payload: missing fields");
|
|
913
|
-
}
|
|
914
|
-
if (room_id !== undefined && typeof room_id !== "string") {
|
|
915
|
-
throw new requirement_1.RoomException("Invalid mailbox payload: invalid room_id");
|
|
916
|
-
}
|
|
917
|
-
return { address, room, roomId: room_id, queue };
|
|
918
|
-
});
|
|
1033
|
+
const parsed = mailboxes.map((item) => this.parseMailbox(item));
|
|
1034
|
+
return { mailboxes: parsed, total: typeof data?.total === "number" ? data.total : parsed.length };
|
|
1035
|
+
}
|
|
1036
|
+
async listMailboxes(projectId, options = {}) {
|
|
1037
|
+
const page = await this.listMailboxesPage(projectId, options);
|
|
1038
|
+
return page.mailboxes;
|
|
919
1039
|
}
|
|
920
1040
|
async deleteMailbox(projectId, address) {
|
|
921
1041
|
await this.request(`/accounts/projects/${projectId}/mailboxes/${address}`, {
|
|
@@ -924,6 +1044,182 @@ class Meshagent {
|
|
|
924
1044
|
responseType: "void",
|
|
925
1045
|
});
|
|
926
1046
|
}
|
|
1047
|
+
async createFeed(params) {
|
|
1048
|
+
const { projectId, name, description = "", visibility = "private", paused = false, annotations = {}, messageSchema = null, } = params;
|
|
1049
|
+
const data = await this.request(`/accounts/projects/${projectId}/feeds`, {
|
|
1050
|
+
method: "POST",
|
|
1051
|
+
json: {
|
|
1052
|
+
name,
|
|
1053
|
+
description,
|
|
1054
|
+
visibility,
|
|
1055
|
+
paused,
|
|
1056
|
+
annotations,
|
|
1057
|
+
message_schema: messageSchema,
|
|
1058
|
+
},
|
|
1059
|
+
action: "create feed",
|
|
1060
|
+
});
|
|
1061
|
+
return this.parseFeed(data.feed);
|
|
1062
|
+
}
|
|
1063
|
+
async updateFeed(params) {
|
|
1064
|
+
const { projectId, feedId, name, description = "", paused = false, annotations = {}, messageSchema = null, } = params;
|
|
1065
|
+
await this.request(`/accounts/projects/${projectId}/feeds/${feedId}`, {
|
|
1066
|
+
method: "PUT",
|
|
1067
|
+
json: {
|
|
1068
|
+
name,
|
|
1069
|
+
description,
|
|
1070
|
+
paused,
|
|
1071
|
+
annotations,
|
|
1072
|
+
message_schema: messageSchema,
|
|
1073
|
+
},
|
|
1074
|
+
action: "update feed",
|
|
1075
|
+
responseType: "void",
|
|
1076
|
+
});
|
|
1077
|
+
}
|
|
1078
|
+
async getFeed(projectId, feedId) {
|
|
1079
|
+
const data = await this.request(`/accounts/projects/${projectId}/feeds/${feedId}`, {
|
|
1080
|
+
action: "get feed",
|
|
1081
|
+
});
|
|
1082
|
+
return this.parseFeed(data.feed);
|
|
1083
|
+
}
|
|
1084
|
+
async listFeedsPage(projectId, options = {}) {
|
|
1085
|
+
const { count = 100, offset = 0, filter } = options;
|
|
1086
|
+
const data = await this.request(`/accounts/projects/${projectId}/feeds`, {
|
|
1087
|
+
query: { count, offset, filter },
|
|
1088
|
+
action: "list feeds",
|
|
1089
|
+
});
|
|
1090
|
+
const feeds = Array.isArray(data?.feeds) ? data.feeds : [];
|
|
1091
|
+
const parsed = feeds.map((item) => this.parseFeed(item));
|
|
1092
|
+
return { feeds: parsed, total: typeof data?.total === "number" ? data.total : parsed.length };
|
|
1093
|
+
}
|
|
1094
|
+
async listFeeds(projectId, options = {}) {
|
|
1095
|
+
const page = await this.listFeedsPage(projectId, options);
|
|
1096
|
+
return page.feeds;
|
|
1097
|
+
}
|
|
1098
|
+
async listRoomFeedsPage(projectId, roomName, options = {}) {
|
|
1099
|
+
const { count = 100, offset = 0, filter } = options;
|
|
1100
|
+
const data = await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/feeds`, {
|
|
1101
|
+
query: { count, offset, filter },
|
|
1102
|
+
action: "list room feeds",
|
|
1103
|
+
});
|
|
1104
|
+
const feeds = Array.isArray(data?.feeds) ? data.feeds : [];
|
|
1105
|
+
const parsed = feeds.map((item) => this.parseFeed(item));
|
|
1106
|
+
return { feeds: parsed, total: typeof data?.total === "number" ? data.total : parsed.length };
|
|
1107
|
+
}
|
|
1108
|
+
async listRoomFeeds(projectId, roomName, options = {}) {
|
|
1109
|
+
const page = await this.listRoomFeedsPage(projectId, roomName, options);
|
|
1110
|
+
return page.feeds;
|
|
1111
|
+
}
|
|
1112
|
+
async deleteFeed(projectId, feedId) {
|
|
1113
|
+
await this.request(`/accounts/projects/${projectId}/feeds/${feedId}`, {
|
|
1114
|
+
method: "DELETE",
|
|
1115
|
+
action: "delete feed",
|
|
1116
|
+
responseType: "void",
|
|
1117
|
+
});
|
|
1118
|
+
}
|
|
1119
|
+
async publishFeedMessage(params) {
|
|
1120
|
+
const { projectId, feedId, message } = params;
|
|
1121
|
+
await this.request(`/accounts/projects/${projectId}/feeds/${feedId}/messages`, {
|
|
1122
|
+
method: "POST",
|
|
1123
|
+
json: message,
|
|
1124
|
+
action: "publish feed message",
|
|
1125
|
+
responseType: "void",
|
|
1126
|
+
});
|
|
1127
|
+
}
|
|
1128
|
+
async publishFeedBatch(params) {
|
|
1129
|
+
const { projectId, feedId, messages } = params;
|
|
1130
|
+
await this.request(`/accounts/projects/${projectId}/feeds/${feedId}/messages/batch`, {
|
|
1131
|
+
method: "POST",
|
|
1132
|
+
json: messages,
|
|
1133
|
+
action: "publish feed messages",
|
|
1134
|
+
responseType: "void",
|
|
1135
|
+
});
|
|
1136
|
+
}
|
|
1137
|
+
async createFeedSubscription(params) {
|
|
1138
|
+
const { projectId, feedId, room, path, annotations = {} } = params;
|
|
1139
|
+
const data = await this.request(`/accounts/projects/${projectId}/feeds/${feedId}/subscriptions`, {
|
|
1140
|
+
method: "POST",
|
|
1141
|
+
json: { room, path, annotations },
|
|
1142
|
+
action: "create feed subscription",
|
|
1143
|
+
});
|
|
1144
|
+
return this.parseFeedSubscription(data.subscription);
|
|
1145
|
+
}
|
|
1146
|
+
async updateFeedSubscription(params) {
|
|
1147
|
+
const { projectId, feedId, subscriptionId, annotations = {} } = params;
|
|
1148
|
+
await this.request(`/accounts/projects/${projectId}/feeds/${feedId}/subscriptions/${subscriptionId}`, {
|
|
1149
|
+
method: "PUT",
|
|
1150
|
+
json: { annotations },
|
|
1151
|
+
action: "update feed subscription",
|
|
1152
|
+
responseType: "void",
|
|
1153
|
+
});
|
|
1154
|
+
}
|
|
1155
|
+
async getFeedSubscription(projectId, feedId, subscriptionId) {
|
|
1156
|
+
const data = await this.request(`/accounts/projects/${projectId}/feeds/${feedId}/subscriptions/${subscriptionId}`, {
|
|
1157
|
+
action: "get feed subscription",
|
|
1158
|
+
});
|
|
1159
|
+
return this.parseFeedSubscription(data.subscription);
|
|
1160
|
+
}
|
|
1161
|
+
async listFeedSubscriptions(projectId, feedId) {
|
|
1162
|
+
const data = await this.request(`/accounts/projects/${projectId}/feeds/${feedId}/subscriptions`, {
|
|
1163
|
+
action: "list feed subscriptions",
|
|
1164
|
+
});
|
|
1165
|
+
const subscriptions = Array.isArray(data?.subscriptions) ? data.subscriptions : [];
|
|
1166
|
+
return subscriptions.map((item) => this.parseFeedSubscription(item));
|
|
1167
|
+
}
|
|
1168
|
+
async deleteFeedSubscription(projectId, feedId, subscriptionId) {
|
|
1169
|
+
await this.request(`/accounts/projects/${projectId}/feeds/${feedId}/subscriptions/${subscriptionId}`, {
|
|
1170
|
+
method: "DELETE",
|
|
1171
|
+
action: "delete feed subscription",
|
|
1172
|
+
responseType: "void",
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
async createLLMLogger(params) {
|
|
1176
|
+
const { projectId, destinationFeedId, filterExpression, paused = false, annotations = {} } = params;
|
|
1177
|
+
const data = await this.request(`/accounts/projects/${projectId}/llm-loggers`, {
|
|
1178
|
+
method: "POST",
|
|
1179
|
+
json: {
|
|
1180
|
+
destination_feed_id: destinationFeedId,
|
|
1181
|
+
filter_expression: filterExpression,
|
|
1182
|
+
paused,
|
|
1183
|
+
annotations,
|
|
1184
|
+
},
|
|
1185
|
+
action: "create LLM logger",
|
|
1186
|
+
});
|
|
1187
|
+
return this.parseLLMLogger(data.logger);
|
|
1188
|
+
}
|
|
1189
|
+
async updateLLMLogger(params) {
|
|
1190
|
+
const { projectId, loggerId, destinationFeedId, filterExpression, paused = false, annotations = {} } = params;
|
|
1191
|
+
await this.request(`/accounts/projects/${projectId}/llm-loggers/${loggerId}`, {
|
|
1192
|
+
method: "PUT",
|
|
1193
|
+
json: {
|
|
1194
|
+
destination_feed_id: destinationFeedId,
|
|
1195
|
+
filter_expression: filterExpression,
|
|
1196
|
+
paused,
|
|
1197
|
+
annotations,
|
|
1198
|
+
},
|
|
1199
|
+
action: "update LLM logger",
|
|
1200
|
+
responseType: "void",
|
|
1201
|
+
});
|
|
1202
|
+
}
|
|
1203
|
+
async getLLMLogger(projectId, loggerId) {
|
|
1204
|
+
const data = await this.request(`/accounts/projects/${projectId}/llm-loggers/${loggerId}`, {
|
|
1205
|
+
action: "get LLM logger",
|
|
1206
|
+
});
|
|
1207
|
+
return this.parseLLMLogger(data.logger);
|
|
1208
|
+
}
|
|
1209
|
+
async listLLMLoggers(projectId) {
|
|
1210
|
+
const data = await this.request(`/accounts/projects/${projectId}/llm-loggers`, {
|
|
1211
|
+
action: "list LLM loggers",
|
|
1212
|
+
});
|
|
1213
|
+
const loggers = Array.isArray(data?.loggers) ? data.loggers : [];
|
|
1214
|
+
return loggers.map((item) => this.parseLLMLogger(item));
|
|
1215
|
+
}
|
|
1216
|
+
async deleteLLMLogger(projectId, loggerId) {
|
|
1217
|
+
await this.request(`/accounts/projects/${projectId}/llm-loggers/${loggerId}`, {
|
|
1218
|
+
method: "DELETE",
|
|
1219
|
+
action: "delete LLM logger",
|
|
1220
|
+
responseType: "void",
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
927
1223
|
async createRepository(params) {
|
|
928
1224
|
const { projectId, name, description = "", annotations = {} } = params;
|
|
929
1225
|
const data = await this.request(`/accounts/projects/${projectId}/repositories`, {
|
|
@@ -1463,14 +1759,19 @@ class Meshagent {
|
|
|
1463
1759
|
const rooms = Array.isArray(data?.rooms) ? data.rooms : [];
|
|
1464
1760
|
return rooms.map((item) => this.parseProjectRoomGrantCount(item));
|
|
1465
1761
|
}
|
|
1466
|
-
async
|
|
1467
|
-
const { limit =
|
|
1762
|
+
async listUniqueUsersWithGrantsPage(projectId, options = {}) {
|
|
1763
|
+
const { limit = 100, offset = 0, filter } = options;
|
|
1468
1764
|
const data = await this.request(`/accounts/projects/${projectId}/room-grants/by-user`, {
|
|
1469
|
-
query: { limit, offset },
|
|
1765
|
+
query: { limit, offset, filter },
|
|
1470
1766
|
action: "list unique users with grants",
|
|
1471
1767
|
});
|
|
1472
1768
|
const users = Array.isArray(data?.users) ? data.users : [];
|
|
1473
|
-
|
|
1769
|
+
const parsed = users.map((item) => this.parseProjectUserGrantCount(item));
|
|
1770
|
+
return { users: parsed, total: typeof data?.total === "number" ? data.total : parsed.length };
|
|
1771
|
+
}
|
|
1772
|
+
async listUniqueUsersWithGrants(projectId, options = {}) {
|
|
1773
|
+
const page = await this.listUniqueUsersWithGrantsPage(projectId, options);
|
|
1774
|
+
return page.users;
|
|
1474
1775
|
}
|
|
1475
1776
|
async createOAuthClient(projectId, params) {
|
|
1476
1777
|
const { grantTypes, responseTypes, redirectUris, scope, metadata = {} } = params;
|
|
@@ -1499,12 +1800,19 @@ class Meshagent {
|
|
|
1499
1800
|
action: "update oauth client",
|
|
1500
1801
|
});
|
|
1501
1802
|
}
|
|
1502
|
-
async
|
|
1803
|
+
async listOAuthClientsPage(projectId, options = {}) {
|
|
1804
|
+
const { count = 100, offset = 0, filter } = options;
|
|
1503
1805
|
const data = await this.request(`/accounts/projects/${projectId}/oauth/clients`, {
|
|
1806
|
+
query: { count, offset, filter },
|
|
1504
1807
|
action: "list oauth clients",
|
|
1505
1808
|
});
|
|
1506
1809
|
const clients = Array.isArray(data?.clients) ? data.clients : [];
|
|
1507
|
-
|
|
1810
|
+
const parsed = clients.map((item) => this.parseOAuthClient(item));
|
|
1811
|
+
return { clients: parsed, total: typeof data?.total === "number" ? data.total : parsed.length };
|
|
1812
|
+
}
|
|
1813
|
+
async listOAuthClients(projectId, options = {}) {
|
|
1814
|
+
const page = await this.listOAuthClientsPage(projectId, options);
|
|
1815
|
+
return page.clients;
|
|
1508
1816
|
}
|
|
1509
1817
|
async getOAuthClient(projectId, clientId) {
|
|
1510
1818
|
const data = await this.request(`/accounts/projects/${projectId}/oauth/clients/${clientId}`, {
|
|
@@ -71,7 +71,7 @@ export declare class TableGrant {
|
|
|
71
71
|
toJSON(): Record<string, any>;
|
|
72
72
|
static fromJSON(obj: unknown): TableGrant;
|
|
73
73
|
}
|
|
74
|
-
export declare class
|
|
74
|
+
export declare class DatasetGrant {
|
|
75
75
|
tables?: TableGrant[];
|
|
76
76
|
listTables: boolean;
|
|
77
77
|
constructor({ tables, listTables, }?: {
|
|
@@ -84,7 +84,7 @@ export declare class DatabaseGrant {
|
|
|
84
84
|
canAlter(table: string, namespace?: StringList): boolean;
|
|
85
85
|
canAccess(table: string, namespace?: StringList): boolean;
|
|
86
86
|
toJSON(): Record<string, any>;
|
|
87
|
-
static fromJSON(obj: unknown):
|
|
87
|
+
static fromJSON(obj: unknown): DatasetGrant;
|
|
88
88
|
}
|
|
89
89
|
export declare class MemoryPermissions {
|
|
90
90
|
create: boolean;
|
|
@@ -290,7 +290,7 @@ export declare class ApiScope {
|
|
|
290
290
|
livekit?: LivekitGrant;
|
|
291
291
|
queues?: QueuesGrant;
|
|
292
292
|
messaging?: MessagingGrant;
|
|
293
|
-
|
|
293
|
+
dataset?: DatasetGrant;
|
|
294
294
|
memory?: MemoryGrant;
|
|
295
295
|
sync?: SyncGrant;
|
|
296
296
|
storage?: StorageGrant;
|
|
@@ -302,11 +302,11 @@ export declare class ApiScope {
|
|
|
302
302
|
secrets?: SecretsGrant;
|
|
303
303
|
tunnels?: TunnelsGrant;
|
|
304
304
|
services?: ServicesGrant;
|
|
305
|
-
constructor({ livekit, queues, messaging,
|
|
305
|
+
constructor({ livekit, queues, messaging, dataset, memory, sync, storage, containers, developer, agents, llm, admin, secrets, tunnels, services, }?: {
|
|
306
306
|
livekit?: LivekitGrant;
|
|
307
307
|
queues?: QueuesGrant;
|
|
308
308
|
messaging?: MessagingGrant;
|
|
309
|
-
|
|
309
|
+
dataset?: DatasetGrant;
|
|
310
310
|
memory?: MemoryGrant;
|
|
311
311
|
sync?: SyncGrant;
|
|
312
312
|
storage?: StorageGrant;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ParticipantToken = exports.ParticipantGrant = exports.ApiScope = exports.LLMGrant = exports.ServicesGrant = exports.TunnelsGrant = exports.SecretsGrant = exports.OAuthEndpoint = exports.AdminGrant = exports.DeveloperGrant = exports.ContainersGrant = exports.ContainerRegistryGrant = exports.StorageGrant = exports.StoragePathGrant = exports.SyncGrant = exports.SyncPathGrant = exports.MemoryGrant = exports.MemoryEntryGrant = exports.MemoryPermissions = exports.
|
|
3
|
+
exports.ParticipantToken = exports.ParticipantGrant = exports.ApiScope = exports.LLMGrant = exports.ServicesGrant = exports.TunnelsGrant = exports.SecretsGrant = exports.OAuthEndpoint = exports.AdminGrant = exports.DeveloperGrant = exports.ContainersGrant = exports.ContainerRegistryGrant = exports.StorageGrant = exports.StoragePathGrant = exports.SyncGrant = exports.SyncPathGrant = exports.MemoryGrant = exports.MemoryEntryGrant = exports.MemoryPermissions = exports.DatasetGrant = exports.TableGrant = exports.MessagingGrant = exports.QueuesGrant = exports.LivekitGrant = exports.AgentsGrant = void 0;
|
|
4
4
|
const jose_1 = require("jose");
|
|
5
5
|
const api_keys_1 = require("./api_keys");
|
|
6
6
|
const version_1 = require("./version");
|
|
@@ -220,7 +220,7 @@ class TableGrant {
|
|
|
220
220
|
}
|
|
221
221
|
}
|
|
222
222
|
exports.TableGrant = TableGrant;
|
|
223
|
-
class
|
|
223
|
+
class DatasetGrant {
|
|
224
224
|
constructor({ tables, listTables, } = {}) {
|
|
225
225
|
this.tables = tables;
|
|
226
226
|
this.listTables = listTables ?? true;
|
|
@@ -286,9 +286,9 @@ class DatabaseGrant {
|
|
|
286
286
|
}
|
|
287
287
|
static fromJSON(obj) {
|
|
288
288
|
if (!isRecord(obj)) {
|
|
289
|
-
return new
|
|
289
|
+
return new DatasetGrant();
|
|
290
290
|
}
|
|
291
|
-
return new
|
|
291
|
+
return new DatasetGrant({
|
|
292
292
|
tables: Array.isArray(obj.tables)
|
|
293
293
|
? obj.tables.map((tableGrant) => TableGrant.fromJSON(tableGrant))
|
|
294
294
|
: undefined,
|
|
@@ -296,7 +296,7 @@ class DatabaseGrant {
|
|
|
296
296
|
});
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
|
-
exports.
|
|
299
|
+
exports.DatasetGrant = DatasetGrant;
|
|
300
300
|
class MemoryPermissions {
|
|
301
301
|
constructor({ create, drop, inspect, query, upsert, ingest, recall, optimize, } = {}) {
|
|
302
302
|
this.create = create ?? true;
|
|
@@ -922,11 +922,11 @@ class LLMGrant {
|
|
|
922
922
|
}
|
|
923
923
|
exports.LLMGrant = LLMGrant;
|
|
924
924
|
class ApiScope {
|
|
925
|
-
constructor({ livekit, queues, messaging,
|
|
925
|
+
constructor({ livekit, queues, messaging, dataset, memory, sync, storage, containers, developer, agents, llm, admin, secrets, tunnels, services, } = {}) {
|
|
926
926
|
this.livekit = livekit;
|
|
927
927
|
this.queues = queues;
|
|
928
928
|
this.messaging = messaging;
|
|
929
|
-
this.
|
|
929
|
+
this.dataset = dataset;
|
|
930
930
|
this.memory = memory;
|
|
931
931
|
this.sync = sync;
|
|
932
932
|
this.storage = storage;
|
|
@@ -944,7 +944,7 @@ class ApiScope {
|
|
|
944
944
|
livekit: new LivekitGrant(),
|
|
945
945
|
queues: new QueuesGrant(),
|
|
946
946
|
messaging: new MessagingGrant(),
|
|
947
|
-
|
|
947
|
+
dataset: new DatasetGrant(),
|
|
948
948
|
memory: new MemoryGrant(),
|
|
949
949
|
sync: new SyncGrant(),
|
|
950
950
|
storage: new StorageGrant(),
|
|
@@ -962,7 +962,7 @@ class ApiScope {
|
|
|
962
962
|
livekit: new LivekitGrant(),
|
|
963
963
|
queues: new QueuesGrant(),
|
|
964
964
|
messaging: new MessagingGrant(),
|
|
965
|
-
|
|
965
|
+
dataset: new DatasetGrant(),
|
|
966
966
|
memory: new MemoryGrant(),
|
|
967
967
|
sync: new SyncGrant(),
|
|
968
968
|
storage: new StorageGrant(),
|
|
@@ -978,7 +978,7 @@ class ApiScope {
|
|
|
978
978
|
livekit: new LivekitGrant(),
|
|
979
979
|
queues: new QueuesGrant(),
|
|
980
980
|
messaging: new MessagingGrant(),
|
|
981
|
-
|
|
981
|
+
dataset: new DatasetGrant(),
|
|
982
982
|
memory: new MemoryGrant(),
|
|
983
983
|
sync: new SyncGrant(),
|
|
984
984
|
storage: new StorageGrant(),
|
|
@@ -1003,8 +1003,8 @@ class ApiScope {
|
|
|
1003
1003
|
if (this.messaging !== undefined) {
|
|
1004
1004
|
json["messaging"] = this.messaging.toJSON();
|
|
1005
1005
|
}
|
|
1006
|
-
if (this.
|
|
1007
|
-
json["
|
|
1006
|
+
if (this.dataset !== undefined) {
|
|
1007
|
+
json["dataset"] = this.dataset.toJSON();
|
|
1008
1008
|
}
|
|
1009
1009
|
if (this.memory !== undefined) {
|
|
1010
1010
|
json["memory"] = this.memory.toJSON();
|
|
@@ -1045,11 +1045,12 @@ class ApiScope {
|
|
|
1045
1045
|
if (!isRecord(obj)) {
|
|
1046
1046
|
return new ApiScope();
|
|
1047
1047
|
}
|
|
1048
|
+
const rawDataset = obj.dataset ?? obj.database ?? obj.datasets;
|
|
1048
1049
|
return new ApiScope({
|
|
1049
1050
|
livekit: obj.livekit ? LivekitGrant.fromJSON(obj.livekit) : undefined,
|
|
1050
1051
|
queues: obj.queues ? QueuesGrant.fromJSON(obj.queues) : undefined,
|
|
1051
1052
|
messaging: obj.messaging ? MessagingGrant.fromJSON(obj.messaging) : undefined,
|
|
1052
|
-
|
|
1053
|
+
dataset: rawDataset ? DatasetGrant.fromJSON(rawDataset) : undefined,
|
|
1053
1054
|
memory: obj.memory ? MemoryGrant.fromJSON(obj.memory) : undefined,
|
|
1054
1055
|
sync: obj.sync ? SyncGrant.fromJSON(obj.sync) : undefined,
|
|
1055
1056
|
storage: obj.storage ? StorageGrant.fromJSON(obj.storage) : undefined,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { DatasetsClient } from "./datasets-client";
|
|
2
2
|
import { DeveloperClient } from "./developer-client";
|
|
3
3
|
import { type EventHandler, type EventName } from "./event-emitter";
|
|
4
4
|
import { MessagingClient } from "./messaging-client";
|
|
@@ -52,7 +52,7 @@ export declare class RoomClient {
|
|
|
52
52
|
readonly developer: DeveloperClient;
|
|
53
53
|
readonly messaging: MessagingClient;
|
|
54
54
|
readonly queues: QueuesClient;
|
|
55
|
-
readonly
|
|
55
|
+
readonly datasets: DatasetsClient;
|
|
56
56
|
readonly agents: AgentsClient;
|
|
57
57
|
readonly secrets: SecretsClient;
|
|
58
58
|
readonly containers: ContainersClient;
|
|
@@ -111,7 +111,9 @@ export declare class RoomClient {
|
|
|
111
111
|
on(eventName: EventName, callback: EventHandler<RoomEvent>): void;
|
|
112
112
|
off(eventName: EventName, callback: EventHandler<RoomEvent>): void;
|
|
113
113
|
emit(event: RoomEvent): void;
|
|
114
|
-
listen(
|
|
114
|
+
listen({ abortSignal }?: {
|
|
115
|
+
abortSignal?: AbortSignal;
|
|
116
|
+
}): AsyncIterable<RoomEvent>;
|
|
115
117
|
waitForClose(): Promise<void>;
|
|
116
118
|
waitUntilConnected(): Promise<void>;
|
|
117
119
|
_waitUntilConnectedForMessages(): Promise<void>;
|