@meshagent/meshagent 0.38.3 → 0.39.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 +12 -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 +109 -1
- package/dist/browser/meshagent-client.js +269 -3
- 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 +109 -1
- package/dist/esm/meshagent-client.js +269 -3
- 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 +109 -1
- package/dist/node/meshagent-client.js +269 -3
- 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
package/dist/esm/entrypoint.js
CHANGED
|
@@ -6386,23 +6386,17 @@ for (let i = 0; i < 256; ++i) {
|
|
|
6386
6386
|
function unsafeStringify(arr, offset = 0) {
|
|
6387
6387
|
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
6388
6388
|
}
|
|
6389
|
-
var getRandomValues2;
|
|
6390
6389
|
var rnds8 = new Uint8Array(16);
|
|
6391
6390
|
function rng() {
|
|
6392
|
-
|
|
6393
|
-
if (typeof crypto === "undefined" || !crypto.getRandomValues) {
|
|
6394
|
-
throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
|
|
6395
|
-
}
|
|
6396
|
-
getRandomValues2 = crypto.getRandomValues.bind(crypto);
|
|
6397
|
-
}
|
|
6398
|
-
return getRandomValues2(rnds8);
|
|
6391
|
+
return crypto.getRandomValues(rnds8);
|
|
6399
6392
|
}
|
|
6400
|
-
var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
6401
|
-
var native_default = { randomUUID };
|
|
6402
6393
|
function v4(options, buf, offset) {
|
|
6403
|
-
if (
|
|
6404
|
-
return
|
|
6394
|
+
if (!buf && !options && crypto.randomUUID) {
|
|
6395
|
+
return crypto.randomUUID();
|
|
6405
6396
|
}
|
|
6397
|
+
return _v4(options, buf, offset);
|
|
6398
|
+
}
|
|
6399
|
+
function _v4(options, buf, offset) {
|
|
6406
6400
|
options = options || {};
|
|
6407
6401
|
const rnds = options.random ?? options.rng?.() ?? rng();
|
|
6408
6402
|
if (rnds.length < 16) {
|
package/dist/esm/index.d.ts
CHANGED
|
@@ -4,8 +4,7 @@ export * from './event-emitter';
|
|
|
4
4
|
export * from './client';
|
|
5
5
|
export * from './completer';
|
|
6
6
|
export * from './containers-client';
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './database-client';
|
|
7
|
+
export * from './datasets-client';
|
|
9
8
|
export * from './developer-client';
|
|
10
9
|
export * from './document';
|
|
11
10
|
export * from './meshagent-client';
|
package/dist/esm/index.js
CHANGED
|
@@ -4,8 +4,7 @@ export * from './event-emitter';
|
|
|
4
4
|
export * from './client';
|
|
5
5
|
export * from './completer';
|
|
6
6
|
export * from './containers-client';
|
|
7
|
-
export * from './
|
|
8
|
-
export * from './database-client';
|
|
7
|
+
export * from './datasets-client';
|
|
9
8
|
export * from './developer-client';
|
|
10
9
|
export * from './document';
|
|
11
10
|
export * from './meshagent-client';
|
|
@@ -202,6 +202,37 @@ export interface Mailbox {
|
|
|
202
202
|
roomId?: string;
|
|
203
203
|
queue: string;
|
|
204
204
|
}
|
|
205
|
+
export type FeedVisibility = "public" | "project" | "private";
|
|
206
|
+
export interface Feed {
|
|
207
|
+
id: string;
|
|
208
|
+
projectId: string;
|
|
209
|
+
createdAt: Date;
|
|
210
|
+
name: string;
|
|
211
|
+
description: string;
|
|
212
|
+
visibility: FeedVisibility;
|
|
213
|
+
paused: boolean;
|
|
214
|
+
annotations: Record<string, string>;
|
|
215
|
+
messageSchema?: Record<string, unknown> | boolean | null;
|
|
216
|
+
}
|
|
217
|
+
export interface FeedSubscription {
|
|
218
|
+
id: string;
|
|
219
|
+
feedId: string;
|
|
220
|
+
projectId: string;
|
|
221
|
+
room: string;
|
|
222
|
+
roomId?: string | null;
|
|
223
|
+
path: string;
|
|
224
|
+
createdAt: Date;
|
|
225
|
+
annotations: Record<string, string>;
|
|
226
|
+
}
|
|
227
|
+
export interface LLMLogger {
|
|
228
|
+
id: string;
|
|
229
|
+
projectId: string;
|
|
230
|
+
destinationFeedId: string;
|
|
231
|
+
filterExpression: string;
|
|
232
|
+
paused: boolean;
|
|
233
|
+
createdAt: Date;
|
|
234
|
+
annotations: Record<string, string>;
|
|
235
|
+
}
|
|
205
236
|
export interface ProjectRepository {
|
|
206
237
|
id: string;
|
|
207
238
|
projectId: string;
|
|
@@ -215,6 +246,9 @@ export interface Balance {
|
|
|
215
246
|
autoRechargeThreshold?: number | null;
|
|
216
247
|
autoRechargeAmount?: number | null;
|
|
217
248
|
lastRecharge?: Date | null;
|
|
249
|
+
monthlyBudget?: number | null;
|
|
250
|
+
autoRechargePaused?: boolean;
|
|
251
|
+
autoRechargedThisMonth?: number | null;
|
|
218
252
|
}
|
|
219
253
|
export interface Transaction {
|
|
220
254
|
id: string;
|
|
@@ -274,6 +308,7 @@ export interface ExternalOAuthClientRegistration {
|
|
|
274
308
|
clientId: string;
|
|
275
309
|
clientSecret?: string | null;
|
|
276
310
|
}
|
|
311
|
+
type JsonRequest = Record<string, unknown> | Array<unknown> | string | number | boolean | null;
|
|
277
312
|
export declare class Meshagent {
|
|
278
313
|
private readonly baseUrl;
|
|
279
314
|
private readonly token?;
|
|
@@ -286,6 +321,9 @@ export declare class Meshagent {
|
|
|
286
321
|
private parseRoomShare;
|
|
287
322
|
private parseRoomSession;
|
|
288
323
|
private parseRoom;
|
|
324
|
+
private parseFeed;
|
|
325
|
+
private parseFeedSubscription;
|
|
326
|
+
private parseLLMLogger;
|
|
289
327
|
private parseProjectRepository;
|
|
290
328
|
private parseProjectRoomGrant;
|
|
291
329
|
private parseProjectRoomGrantCount;
|
|
@@ -339,11 +377,12 @@ export declare class Meshagent {
|
|
|
339
377
|
getStatus(projectId: string): Promise<boolean>;
|
|
340
378
|
getBalance(projectId: string): Promise<Balance>;
|
|
341
379
|
getRecentTransactions(projectId: string): Promise<Transaction[]>;
|
|
342
|
-
setAutoRecharge({ projectId, enabled, amount, threshold }: {
|
|
380
|
+
setAutoRecharge({ projectId, enabled, amount, threshold, monthlyBudget, }: {
|
|
343
381
|
projectId: string;
|
|
344
382
|
enabled: boolean;
|
|
345
383
|
amount: number;
|
|
346
384
|
threshold: number;
|
|
385
|
+
monthlyBudget?: number | null;
|
|
347
386
|
}): Promise<void>;
|
|
348
387
|
getCheckoutUrl(projectId: string, { successUrl, cancelUrl }: {
|
|
349
388
|
successUrl: string;
|
|
@@ -365,6 +404,8 @@ export declare class Meshagent {
|
|
|
365
404
|
provider?: string;
|
|
366
405
|
model?: string;
|
|
367
406
|
usageType?: string;
|
|
407
|
+
client?: string;
|
|
408
|
+
annotations?: Record<string, string>;
|
|
368
409
|
}): Promise<Record<string, unknown>[]>;
|
|
369
410
|
getSession(projectId: string, sessionId: string): Promise<Record<string, unknown>>;
|
|
370
411
|
listActiveSessions(projectId: string): Promise<RoomSession[]>;
|
|
@@ -407,6 +448,72 @@ export declare class Meshagent {
|
|
|
407
448
|
}): Promise<void>;
|
|
408
449
|
listMailboxes(projectId: string): Promise<Mailbox[]>;
|
|
409
450
|
deleteMailbox(projectId: string, address: string): Promise<void>;
|
|
451
|
+
createFeed(params: {
|
|
452
|
+
projectId: string;
|
|
453
|
+
name: string;
|
|
454
|
+
description?: string;
|
|
455
|
+
visibility?: FeedVisibility;
|
|
456
|
+
paused?: boolean;
|
|
457
|
+
annotations?: Record<string, string>;
|
|
458
|
+
messageSchema?: Record<string, unknown> | boolean | null;
|
|
459
|
+
}): Promise<Feed>;
|
|
460
|
+
updateFeed(params: {
|
|
461
|
+
projectId: string;
|
|
462
|
+
feedId: string;
|
|
463
|
+
name: string;
|
|
464
|
+
description?: string;
|
|
465
|
+
paused?: boolean;
|
|
466
|
+
annotations?: Record<string, string>;
|
|
467
|
+
messageSchema?: Record<string, unknown> | boolean | null;
|
|
468
|
+
}): Promise<void>;
|
|
469
|
+
getFeed(projectId: string, feedId: string): Promise<Feed>;
|
|
470
|
+
listFeeds(projectId: string): Promise<Feed[]>;
|
|
471
|
+
listRoomFeeds(projectId: string, roomName: string): Promise<Feed[]>;
|
|
472
|
+
deleteFeed(projectId: string, feedId: string): Promise<void>;
|
|
473
|
+
publishFeedMessage(params: {
|
|
474
|
+
projectId: string;
|
|
475
|
+
feedId: string;
|
|
476
|
+
message: JsonRequest;
|
|
477
|
+
}): Promise<void>;
|
|
478
|
+
publishFeedBatch(params: {
|
|
479
|
+
projectId: string;
|
|
480
|
+
feedId: string;
|
|
481
|
+
messages: JsonRequest[];
|
|
482
|
+
}): Promise<void>;
|
|
483
|
+
createFeedSubscription(params: {
|
|
484
|
+
projectId: string;
|
|
485
|
+
feedId: string;
|
|
486
|
+
room: string;
|
|
487
|
+
path: string;
|
|
488
|
+
annotations?: Record<string, string>;
|
|
489
|
+
}): Promise<FeedSubscription>;
|
|
490
|
+
updateFeedSubscription(params: {
|
|
491
|
+
projectId: string;
|
|
492
|
+
feedId: string;
|
|
493
|
+
subscriptionId: string;
|
|
494
|
+
annotations?: Record<string, string>;
|
|
495
|
+
}): Promise<void>;
|
|
496
|
+
getFeedSubscription(projectId: string, feedId: string, subscriptionId: string): Promise<FeedSubscription>;
|
|
497
|
+
listFeedSubscriptions(projectId: string, feedId: string): Promise<FeedSubscription[]>;
|
|
498
|
+
deleteFeedSubscription(projectId: string, feedId: string, subscriptionId: string): Promise<void>;
|
|
499
|
+
createLLMLogger(params: {
|
|
500
|
+
projectId: string;
|
|
501
|
+
destinationFeedId: string;
|
|
502
|
+
filterExpression: string;
|
|
503
|
+
paused?: boolean;
|
|
504
|
+
annotations?: Record<string, string>;
|
|
505
|
+
}): Promise<LLMLogger>;
|
|
506
|
+
updateLLMLogger(params: {
|
|
507
|
+
projectId: string;
|
|
508
|
+
loggerId: string;
|
|
509
|
+
destinationFeedId: string;
|
|
510
|
+
filterExpression: string;
|
|
511
|
+
paused?: boolean;
|
|
512
|
+
annotations?: Record<string, string>;
|
|
513
|
+
}): Promise<void>;
|
|
514
|
+
getLLMLogger(projectId: string, loggerId: string): Promise<LLMLogger>;
|
|
515
|
+
listLLMLoggers(projectId: string): Promise<LLMLogger[]>;
|
|
516
|
+
deleteLLMLogger(projectId: string, loggerId: string): Promise<void>;
|
|
410
517
|
createRepository(params: {
|
|
411
518
|
projectId: string;
|
|
412
519
|
name: string;
|
|
@@ -628,3 +735,4 @@ export declare class Meshagent {
|
|
|
628
735
|
getOAuthClient(projectId: string, clientId: string): Promise<OAuthClient>;
|
|
629
736
|
deleteOAuthClient(projectId: string, clientId: string): Promise<void>;
|
|
630
737
|
}
|
|
738
|
+
export {};
|
|
@@ -223,6 +223,102 @@ export class Meshagent {
|
|
|
223
223
|
annotations: annotations && typeof annotations === "object" ? annotations : {},
|
|
224
224
|
};
|
|
225
225
|
}
|
|
226
|
+
parseFeed(data) {
|
|
227
|
+
if (!data || typeof data !== "object") {
|
|
228
|
+
throw new RoomException("Invalid feed payload");
|
|
229
|
+
}
|
|
230
|
+
const { id, project_id: projectIdRaw, projectId, created_at: createdAtRaw, createdAt, name, description, visibility, paused, annotations, message_schema: messageSchemaRaw, messageSchema, } = data;
|
|
231
|
+
const projectIdValue = typeof projectId === "string"
|
|
232
|
+
? projectId
|
|
233
|
+
: typeof projectIdRaw === "string"
|
|
234
|
+
? projectIdRaw
|
|
235
|
+
: undefined;
|
|
236
|
+
const createdAtValue = typeof createdAt === "string"
|
|
237
|
+
? createdAt
|
|
238
|
+
: typeof createdAtRaw === "string"
|
|
239
|
+
? createdAtRaw
|
|
240
|
+
: undefined;
|
|
241
|
+
const visibilityValue = visibility === "public" || visibility === "project" || visibility === "private"
|
|
242
|
+
? visibility
|
|
243
|
+
: undefined;
|
|
244
|
+
const messageSchemaValue = typeof messageSchema === "boolean" || (messageSchema && typeof messageSchema === "object")
|
|
245
|
+
? messageSchema
|
|
246
|
+
: typeof messageSchemaRaw === "boolean" || (messageSchemaRaw && typeof messageSchemaRaw === "object")
|
|
247
|
+
? messageSchemaRaw
|
|
248
|
+
: null;
|
|
249
|
+
if (typeof id !== "string" ||
|
|
250
|
+
typeof projectIdValue !== "string" ||
|
|
251
|
+
typeof createdAtValue !== "string" ||
|
|
252
|
+
typeof name !== "string" ||
|
|
253
|
+
visibilityValue === undefined) {
|
|
254
|
+
throw new RoomException("Invalid feed payload: missing required fields");
|
|
255
|
+
}
|
|
256
|
+
return {
|
|
257
|
+
id,
|
|
258
|
+
projectId: projectIdValue,
|
|
259
|
+
createdAt: new Date(createdAtValue),
|
|
260
|
+
name,
|
|
261
|
+
description: typeof description === "string" ? description : "",
|
|
262
|
+
visibility: visibilityValue,
|
|
263
|
+
paused: paused === true,
|
|
264
|
+
annotations: annotations && typeof annotations === "object" ? annotations : {},
|
|
265
|
+
messageSchema: messageSchemaValue,
|
|
266
|
+
};
|
|
267
|
+
}
|
|
268
|
+
parseFeedSubscription(data) {
|
|
269
|
+
if (!data || typeof data !== "object") {
|
|
270
|
+
throw new RoomException("Invalid feed subscription payload");
|
|
271
|
+
}
|
|
272
|
+
const { id, feed_id: feedIdRaw, feedId, project_id: projectIdRaw, projectId, room, room_id: roomIdRaw, roomId, path, created_at: createdAtRaw, createdAt, annotations, } = data;
|
|
273
|
+
const feedIdValue = typeof feedId === "string" ? feedId : feedIdRaw;
|
|
274
|
+
const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
|
|
275
|
+
const createdAtValue = typeof createdAt === "string" ? createdAt : createdAtRaw;
|
|
276
|
+
const roomIdValue = typeof roomId === "string" ? roomId : roomIdRaw;
|
|
277
|
+
if (typeof id !== "string" ||
|
|
278
|
+
typeof feedIdValue !== "string" ||
|
|
279
|
+
typeof projectIdValue !== "string" ||
|
|
280
|
+
typeof room !== "string" ||
|
|
281
|
+
typeof path !== "string" ||
|
|
282
|
+
typeof createdAtValue !== "string") {
|
|
283
|
+
throw new RoomException("Invalid feed subscription payload: missing required fields");
|
|
284
|
+
}
|
|
285
|
+
return {
|
|
286
|
+
id,
|
|
287
|
+
feedId: feedIdValue,
|
|
288
|
+
projectId: projectIdValue,
|
|
289
|
+
room,
|
|
290
|
+
roomId: typeof roomIdValue === "string" ? roomIdValue : undefined,
|
|
291
|
+
path,
|
|
292
|
+
createdAt: new Date(createdAtValue),
|
|
293
|
+
annotations: annotations && typeof annotations === "object" ? annotations : {},
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
parseLLMLogger(data) {
|
|
297
|
+
if (!data || typeof data !== "object") {
|
|
298
|
+
throw new RoomException("Invalid LLM logger payload");
|
|
299
|
+
}
|
|
300
|
+
const { id, project_id: projectIdRaw, projectId, destination_feed_id: destinationFeedIdRaw, destinationFeedId, filter_expression: filterExpressionRaw, filterExpression, paused, created_at: createdAtRaw, createdAt, annotations, } = data;
|
|
301
|
+
const projectIdValue = typeof projectId === "string" ? projectId : projectIdRaw;
|
|
302
|
+
const destinationFeedIdValue = typeof destinationFeedId === "string" ? destinationFeedId : destinationFeedIdRaw;
|
|
303
|
+
const filterExpressionValue = typeof filterExpression === "string" ? filterExpression : filterExpressionRaw;
|
|
304
|
+
const createdAtValue = typeof createdAt === "string" ? createdAt : createdAtRaw;
|
|
305
|
+
if (typeof id !== "string" ||
|
|
306
|
+
typeof projectIdValue !== "string" ||
|
|
307
|
+
typeof destinationFeedIdValue !== "string" ||
|
|
308
|
+
typeof filterExpressionValue !== "string" ||
|
|
309
|
+
typeof createdAtValue !== "string") {
|
|
310
|
+
throw new RoomException("Invalid LLM logger payload: missing required fields");
|
|
311
|
+
}
|
|
312
|
+
return {
|
|
313
|
+
id,
|
|
314
|
+
projectId: projectIdValue,
|
|
315
|
+
destinationFeedId: destinationFeedIdValue,
|
|
316
|
+
filterExpression: filterExpressionValue,
|
|
317
|
+
paused: paused === true,
|
|
318
|
+
createdAt: new Date(createdAtValue),
|
|
319
|
+
annotations: annotations && typeof annotations === "object" ? annotations : {},
|
|
320
|
+
};
|
|
321
|
+
}
|
|
226
322
|
parseProjectRepository(data) {
|
|
227
323
|
if (!data || typeof data !== "object") {
|
|
228
324
|
throw new RoomException("Invalid repository payload");
|
|
@@ -310,11 +406,17 @@ export class Meshagent {
|
|
|
310
406
|
const threshold = data.auto_recharge_threshold ?? data.autoRechargeThreshold;
|
|
311
407
|
const amount = data.auto_recharge_amount ?? data.autoRechargeAmount;
|
|
312
408
|
const lastRechargeRaw = data.last_recharge ?? data.lastRecharge;
|
|
409
|
+
const monthlyBudget = data.monthly_budget ?? data.monthlyBudget;
|
|
410
|
+
const autoRechargePaused = data.auto_recharge_paused ?? data.autoRechargePaused;
|
|
411
|
+
const autoRechargedThisMonth = data.auto_recharged_this_month ?? data.autoRechargedThisMonth;
|
|
313
412
|
return {
|
|
314
413
|
balance: balanceValue,
|
|
315
414
|
autoRechargeThreshold: typeof threshold === "number" ? threshold : null,
|
|
316
415
|
autoRechargeAmount: typeof amount === "number" ? amount : null,
|
|
317
416
|
lastRecharge: typeof lastRechargeRaw === "string" ? new Date(lastRechargeRaw) : null,
|
|
417
|
+
monthlyBudget: typeof monthlyBudget === "number" ? monthlyBudget : null,
|
|
418
|
+
autoRechargePaused: autoRechargePaused === true,
|
|
419
|
+
autoRechargedThisMonth: typeof autoRechargedThisMonth === "number" ? autoRechargedThisMonth : null,
|
|
318
420
|
};
|
|
319
421
|
}
|
|
320
422
|
parseTransaction(data) {
|
|
@@ -743,10 +845,10 @@ export class Meshagent {
|
|
|
743
845
|
const list = Array.isArray(data?.transactions) ? data.transactions : [];
|
|
744
846
|
return list.map((item) => this.parseTransaction(item));
|
|
745
847
|
}
|
|
746
|
-
async setAutoRecharge({ projectId, enabled, amount, threshold }) {
|
|
848
|
+
async setAutoRecharge({ projectId, enabled, amount, threshold, monthlyBudget = null, }) {
|
|
747
849
|
await this.request(`/accounts/projects/${projectId}/recharge`, {
|
|
748
850
|
method: "POST",
|
|
749
|
-
json: { enabled, amount, threshold },
|
|
851
|
+
json: { enabled, amount, threshold, monthly_budget: monthlyBudget },
|
|
750
852
|
action: "update auto recharge settings",
|
|
751
853
|
responseType: "void",
|
|
752
854
|
});
|
|
@@ -781,7 +883,7 @@ export class Meshagent {
|
|
|
781
883
|
});
|
|
782
884
|
}
|
|
783
885
|
async getUsage(projectId, options = {}) {
|
|
784
|
-
const { start, end, interval, report, users, room, provider, model, usageType } = options;
|
|
886
|
+
const { start, end, interval, report, users, room, provider, model, usageType, client, annotations } = options;
|
|
785
887
|
const data = await this.request(`/accounts/projects/${projectId}/usage`, {
|
|
786
888
|
query: {
|
|
787
889
|
start: start ? start.toISOString() : undefined,
|
|
@@ -793,6 +895,8 @@ export class Meshagent {
|
|
|
793
895
|
provider: provider && provider.trim().length > 0 ? provider.trim() : undefined,
|
|
794
896
|
model: model && model.trim().length > 0 ? model.trim() : undefined,
|
|
795
897
|
usage_type: usageType && usageType.trim().length > 0 ? usageType.trim() : undefined,
|
|
898
|
+
client: client && client.trim().length > 0 ? client.trim() : undefined,
|
|
899
|
+
annotations: annotations && Object.keys(annotations).length > 0 ? JSON.stringify(annotations) : undefined,
|
|
796
900
|
},
|
|
797
901
|
action: "retrieve usage",
|
|
798
902
|
});
|
|
@@ -921,6 +1025,168 @@ export class Meshagent {
|
|
|
921
1025
|
responseType: "void",
|
|
922
1026
|
});
|
|
923
1027
|
}
|
|
1028
|
+
async createFeed(params) {
|
|
1029
|
+
const { projectId, name, description = "", visibility = "private", paused = false, annotations = {}, messageSchema = null, } = params;
|
|
1030
|
+
const data = await this.request(`/accounts/projects/${projectId}/feeds`, {
|
|
1031
|
+
method: "POST",
|
|
1032
|
+
json: {
|
|
1033
|
+
name,
|
|
1034
|
+
description,
|
|
1035
|
+
visibility,
|
|
1036
|
+
paused,
|
|
1037
|
+
annotations,
|
|
1038
|
+
message_schema: messageSchema,
|
|
1039
|
+
},
|
|
1040
|
+
action: "create feed",
|
|
1041
|
+
});
|
|
1042
|
+
return this.parseFeed(data.feed);
|
|
1043
|
+
}
|
|
1044
|
+
async updateFeed(params) {
|
|
1045
|
+
const { projectId, feedId, name, description = "", paused = false, annotations = {}, messageSchema = null, } = params;
|
|
1046
|
+
await this.request(`/accounts/projects/${projectId}/feeds/${feedId}`, {
|
|
1047
|
+
method: "PUT",
|
|
1048
|
+
json: {
|
|
1049
|
+
name,
|
|
1050
|
+
description,
|
|
1051
|
+
paused,
|
|
1052
|
+
annotations,
|
|
1053
|
+
message_schema: messageSchema,
|
|
1054
|
+
},
|
|
1055
|
+
action: "update feed",
|
|
1056
|
+
responseType: "void",
|
|
1057
|
+
});
|
|
1058
|
+
}
|
|
1059
|
+
async getFeed(projectId, feedId) {
|
|
1060
|
+
const data = await this.request(`/accounts/projects/${projectId}/feeds/${feedId}`, {
|
|
1061
|
+
action: "get feed",
|
|
1062
|
+
});
|
|
1063
|
+
return this.parseFeed(data.feed);
|
|
1064
|
+
}
|
|
1065
|
+
async listFeeds(projectId) {
|
|
1066
|
+
const data = await this.request(`/accounts/projects/${projectId}/feeds`, {
|
|
1067
|
+
action: "list feeds",
|
|
1068
|
+
});
|
|
1069
|
+
const feeds = Array.isArray(data?.feeds) ? data.feeds : [];
|
|
1070
|
+
return feeds.map((item) => this.parseFeed(item));
|
|
1071
|
+
}
|
|
1072
|
+
async listRoomFeeds(projectId, roomName) {
|
|
1073
|
+
const data = await this.request(`/accounts/projects/${projectId}/rooms/${roomName}/feeds`, {
|
|
1074
|
+
action: "list room feeds",
|
|
1075
|
+
});
|
|
1076
|
+
const feeds = Array.isArray(data?.feeds) ? data.feeds : [];
|
|
1077
|
+
return feeds.map((item) => this.parseFeed(item));
|
|
1078
|
+
}
|
|
1079
|
+
async deleteFeed(projectId, feedId) {
|
|
1080
|
+
await this.request(`/accounts/projects/${projectId}/feeds/${feedId}`, {
|
|
1081
|
+
method: "DELETE",
|
|
1082
|
+
action: "delete feed",
|
|
1083
|
+
responseType: "void",
|
|
1084
|
+
});
|
|
1085
|
+
}
|
|
1086
|
+
async publishFeedMessage(params) {
|
|
1087
|
+
const { projectId, feedId, message } = params;
|
|
1088
|
+
await this.request(`/accounts/projects/${projectId}/feeds/${feedId}/messages`, {
|
|
1089
|
+
method: "POST",
|
|
1090
|
+
json: message,
|
|
1091
|
+
action: "publish feed message",
|
|
1092
|
+
responseType: "void",
|
|
1093
|
+
});
|
|
1094
|
+
}
|
|
1095
|
+
async publishFeedBatch(params) {
|
|
1096
|
+
const { projectId, feedId, messages } = params;
|
|
1097
|
+
await this.request(`/accounts/projects/${projectId}/feeds/${feedId}/messages/batch`, {
|
|
1098
|
+
method: "POST",
|
|
1099
|
+
json: messages,
|
|
1100
|
+
action: "publish feed messages",
|
|
1101
|
+
responseType: "void",
|
|
1102
|
+
});
|
|
1103
|
+
}
|
|
1104
|
+
async createFeedSubscription(params) {
|
|
1105
|
+
const { projectId, feedId, room, path, annotations = {} } = params;
|
|
1106
|
+
const data = await this.request(`/accounts/projects/${projectId}/feeds/${feedId}/subscriptions`, {
|
|
1107
|
+
method: "POST",
|
|
1108
|
+
json: { room, path, annotations },
|
|
1109
|
+
action: "create feed subscription",
|
|
1110
|
+
});
|
|
1111
|
+
return this.parseFeedSubscription(data.subscription);
|
|
1112
|
+
}
|
|
1113
|
+
async updateFeedSubscription(params) {
|
|
1114
|
+
const { projectId, feedId, subscriptionId, annotations = {} } = params;
|
|
1115
|
+
await this.request(`/accounts/projects/${projectId}/feeds/${feedId}/subscriptions/${subscriptionId}`, {
|
|
1116
|
+
method: "PUT",
|
|
1117
|
+
json: { annotations },
|
|
1118
|
+
action: "update feed subscription",
|
|
1119
|
+
responseType: "void",
|
|
1120
|
+
});
|
|
1121
|
+
}
|
|
1122
|
+
async getFeedSubscription(projectId, feedId, subscriptionId) {
|
|
1123
|
+
const data = await this.request(`/accounts/projects/${projectId}/feeds/${feedId}/subscriptions/${subscriptionId}`, {
|
|
1124
|
+
action: "get feed subscription",
|
|
1125
|
+
});
|
|
1126
|
+
return this.parseFeedSubscription(data.subscription);
|
|
1127
|
+
}
|
|
1128
|
+
async listFeedSubscriptions(projectId, feedId) {
|
|
1129
|
+
const data = await this.request(`/accounts/projects/${projectId}/feeds/${feedId}/subscriptions`, {
|
|
1130
|
+
action: "list feed subscriptions",
|
|
1131
|
+
});
|
|
1132
|
+
const subscriptions = Array.isArray(data?.subscriptions) ? data.subscriptions : [];
|
|
1133
|
+
return subscriptions.map((item) => this.parseFeedSubscription(item));
|
|
1134
|
+
}
|
|
1135
|
+
async deleteFeedSubscription(projectId, feedId, subscriptionId) {
|
|
1136
|
+
await this.request(`/accounts/projects/${projectId}/feeds/${feedId}/subscriptions/${subscriptionId}`, {
|
|
1137
|
+
method: "DELETE",
|
|
1138
|
+
action: "delete feed subscription",
|
|
1139
|
+
responseType: "void",
|
|
1140
|
+
});
|
|
1141
|
+
}
|
|
1142
|
+
async createLLMLogger(params) {
|
|
1143
|
+
const { projectId, destinationFeedId, filterExpression, paused = false, annotations = {} } = params;
|
|
1144
|
+
const data = await this.request(`/accounts/projects/${projectId}/llm-loggers`, {
|
|
1145
|
+
method: "POST",
|
|
1146
|
+
json: {
|
|
1147
|
+
destination_feed_id: destinationFeedId,
|
|
1148
|
+
filter_expression: filterExpression,
|
|
1149
|
+
paused,
|
|
1150
|
+
annotations,
|
|
1151
|
+
},
|
|
1152
|
+
action: "create LLM logger",
|
|
1153
|
+
});
|
|
1154
|
+
return this.parseLLMLogger(data.logger);
|
|
1155
|
+
}
|
|
1156
|
+
async updateLLMLogger(params) {
|
|
1157
|
+
const { projectId, loggerId, destinationFeedId, filterExpression, paused = false, annotations = {} } = params;
|
|
1158
|
+
await this.request(`/accounts/projects/${projectId}/llm-loggers/${loggerId}`, {
|
|
1159
|
+
method: "PUT",
|
|
1160
|
+
json: {
|
|
1161
|
+
destination_feed_id: destinationFeedId,
|
|
1162
|
+
filter_expression: filterExpression,
|
|
1163
|
+
paused,
|
|
1164
|
+
annotations,
|
|
1165
|
+
},
|
|
1166
|
+
action: "update LLM logger",
|
|
1167
|
+
responseType: "void",
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
async getLLMLogger(projectId, loggerId) {
|
|
1171
|
+
const data = await this.request(`/accounts/projects/${projectId}/llm-loggers/${loggerId}`, {
|
|
1172
|
+
action: "get LLM logger",
|
|
1173
|
+
});
|
|
1174
|
+
return this.parseLLMLogger(data.logger);
|
|
1175
|
+
}
|
|
1176
|
+
async listLLMLoggers(projectId) {
|
|
1177
|
+
const data = await this.request(`/accounts/projects/${projectId}/llm-loggers`, {
|
|
1178
|
+
action: "list LLM loggers",
|
|
1179
|
+
});
|
|
1180
|
+
const loggers = Array.isArray(data?.loggers) ? data.loggers : [];
|
|
1181
|
+
return loggers.map((item) => this.parseLLMLogger(item));
|
|
1182
|
+
}
|
|
1183
|
+
async deleteLLMLogger(projectId, loggerId) {
|
|
1184
|
+
await this.request(`/accounts/projects/${projectId}/llm-loggers/${loggerId}`, {
|
|
1185
|
+
method: "DELETE",
|
|
1186
|
+
action: "delete LLM logger",
|
|
1187
|
+
responseType: "void",
|
|
1188
|
+
});
|
|
1189
|
+
}
|
|
924
1190
|
async createRepository(params) {
|
|
925
1191
|
const { projectId, name, description = "", annotations = {} } = params;
|
|
926
1192
|
const data = await this.request(`/accounts/projects/${projectId}/repositories`, {
|
|
@@ -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;
|
|
@@ -212,7 +212,7 @@ export class TableGrant {
|
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
214
|
}
|
|
215
|
-
export class
|
|
215
|
+
export class DatasetGrant {
|
|
216
216
|
constructor({ tables, listTables, } = {}) {
|
|
217
217
|
this.tables = tables;
|
|
218
218
|
this.listTables = listTables ?? true;
|
|
@@ -278,9 +278,9 @@ export class DatabaseGrant {
|
|
|
278
278
|
}
|
|
279
279
|
static fromJSON(obj) {
|
|
280
280
|
if (!isRecord(obj)) {
|
|
281
|
-
return new
|
|
281
|
+
return new DatasetGrant();
|
|
282
282
|
}
|
|
283
|
-
return new
|
|
283
|
+
return new DatasetGrant({
|
|
284
284
|
tables: Array.isArray(obj.tables)
|
|
285
285
|
? obj.tables.map((tableGrant) => TableGrant.fromJSON(tableGrant))
|
|
286
286
|
: undefined,
|
|
@@ -897,11 +897,11 @@ export class LLMGrant {
|
|
|
897
897
|
}
|
|
898
898
|
}
|
|
899
899
|
export class ApiScope {
|
|
900
|
-
constructor({ livekit, queues, messaging,
|
|
900
|
+
constructor({ livekit, queues, messaging, dataset, memory, sync, storage, containers, developer, agents, llm, admin, secrets, tunnels, services, } = {}) {
|
|
901
901
|
this.livekit = livekit;
|
|
902
902
|
this.queues = queues;
|
|
903
903
|
this.messaging = messaging;
|
|
904
|
-
this.
|
|
904
|
+
this.dataset = dataset;
|
|
905
905
|
this.memory = memory;
|
|
906
906
|
this.sync = sync;
|
|
907
907
|
this.storage = storage;
|
|
@@ -919,7 +919,7 @@ export class ApiScope {
|
|
|
919
919
|
livekit: new LivekitGrant(),
|
|
920
920
|
queues: new QueuesGrant(),
|
|
921
921
|
messaging: new MessagingGrant(),
|
|
922
|
-
|
|
922
|
+
dataset: new DatasetGrant(),
|
|
923
923
|
memory: new MemoryGrant(),
|
|
924
924
|
sync: new SyncGrant(),
|
|
925
925
|
storage: new StorageGrant(),
|
|
@@ -937,7 +937,7 @@ export class ApiScope {
|
|
|
937
937
|
livekit: new LivekitGrant(),
|
|
938
938
|
queues: new QueuesGrant(),
|
|
939
939
|
messaging: new MessagingGrant(),
|
|
940
|
-
|
|
940
|
+
dataset: new DatasetGrant(),
|
|
941
941
|
memory: new MemoryGrant(),
|
|
942
942
|
sync: new SyncGrant(),
|
|
943
943
|
storage: new StorageGrant(),
|
|
@@ -953,7 +953,7 @@ export class ApiScope {
|
|
|
953
953
|
livekit: new LivekitGrant(),
|
|
954
954
|
queues: new QueuesGrant(),
|
|
955
955
|
messaging: new MessagingGrant(),
|
|
956
|
-
|
|
956
|
+
dataset: new DatasetGrant(),
|
|
957
957
|
memory: new MemoryGrant(),
|
|
958
958
|
sync: new SyncGrant(),
|
|
959
959
|
storage: new StorageGrant(),
|
|
@@ -978,8 +978,8 @@ export class ApiScope {
|
|
|
978
978
|
if (this.messaging !== undefined) {
|
|
979
979
|
json["messaging"] = this.messaging.toJSON();
|
|
980
980
|
}
|
|
981
|
-
if (this.
|
|
982
|
-
json["
|
|
981
|
+
if (this.dataset !== undefined) {
|
|
982
|
+
json["dataset"] = this.dataset.toJSON();
|
|
983
983
|
}
|
|
984
984
|
if (this.memory !== undefined) {
|
|
985
985
|
json["memory"] = this.memory.toJSON();
|
|
@@ -1020,11 +1020,12 @@ export class ApiScope {
|
|
|
1020
1020
|
if (!isRecord(obj)) {
|
|
1021
1021
|
return new ApiScope();
|
|
1022
1022
|
}
|
|
1023
|
+
const rawDataset = obj.dataset ?? obj.database ?? obj.datasets;
|
|
1023
1024
|
return new ApiScope({
|
|
1024
1025
|
livekit: obj.livekit ? LivekitGrant.fromJSON(obj.livekit) : undefined,
|
|
1025
1026
|
queues: obj.queues ? QueuesGrant.fromJSON(obj.queues) : undefined,
|
|
1026
1027
|
messaging: obj.messaging ? MessagingGrant.fromJSON(obj.messaging) : undefined,
|
|
1027
|
-
|
|
1028
|
+
dataset: rawDataset ? DatasetGrant.fromJSON(rawDataset) : undefined,
|
|
1028
1029
|
memory: obj.memory ? MemoryGrant.fromJSON(obj.memory) : undefined,
|
|
1029
1030
|
sync: obj.sync ? SyncGrant.fromJSON(obj.sync) : undefined,
|
|
1030
1031
|
storage: obj.storage ? StorageGrant.fromJSON(obj.storage) : undefined,
|