@meshagent/meshagent 0.41.4 → 0.41.6
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 -0
- package/dist/browser/agent-client.d.ts +10 -0
- package/dist/browser/agent-client.js +36 -1
- package/dist/browser/agent.d.ts +109 -14
- package/dist/browser/agent.js +533 -68
- package/dist/browser/datasets-client.d.ts +70 -0
- package/dist/browser/datasets-client.js +79 -0
- package/dist/browser/entrypoint.d.ts +1464 -1426
- package/dist/browser/index.d.ts +2 -0
- package/dist/browser/index.js +2 -0
- package/dist/browser/oauth-scopes.d.ts +2 -0
- package/dist/browser/oauth-scopes.js +21 -0
- package/dist/browser/participant-token.d.ts +1 -3
- package/dist/browser/participant-token.js +2 -3
- package/dist/browser/room-client.d.ts +16 -0
- package/dist/browser/room-client.js +69 -0
- package/dist/browser/storage-client.d.ts +3 -1
- package/dist/browser/storage-client.js +5 -2
- package/dist/browser/tool-content-type.d.ts +1 -1
- package/dist/browser/tool-content-type.js +3 -2
- package/dist/browser/toolkit-config.d.ts +84 -0
- package/dist/browser/toolkit-config.js +415 -0
- package/dist/esm/agent-client.d.ts +10 -0
- package/dist/esm/agent-client.js +36 -1
- package/dist/esm/agent.d.ts +109 -14
- package/dist/esm/agent.js +533 -68
- package/dist/esm/datasets-client.d.ts +70 -0
- package/dist/esm/datasets-client.js +79 -0
- package/dist/esm/entrypoint.d.ts +1464 -1426
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.js +2 -0
- package/dist/esm/oauth-scopes.d.ts +2 -0
- package/dist/esm/oauth-scopes.js +21 -0
- package/dist/esm/participant-token.d.ts +1 -3
- package/dist/esm/participant-token.js +2 -3
- package/dist/esm/room-client.d.ts +16 -0
- package/dist/esm/room-client.js +69 -0
- package/dist/esm/storage-client.d.ts +3 -1
- package/dist/esm/storage-client.js +5 -2
- package/dist/esm/tool-content-type.d.ts +1 -1
- package/dist/esm/tool-content-type.js +3 -2
- package/dist/esm/toolkit-config.d.ts +84 -0
- package/dist/esm/toolkit-config.js +415 -0
- package/dist/node/agent-client.d.ts +10 -0
- package/dist/node/agent-client.js +36 -1
- package/dist/node/agent.d.ts +109 -14
- package/dist/node/agent.js +533 -68
- package/dist/node/datasets-client.d.ts +70 -0
- package/dist/node/datasets-client.js +79 -0
- package/dist/node/entrypoint.d.ts +1464 -1426
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.js +2 -0
- package/dist/node/oauth-scopes.d.ts +2 -0
- package/dist/node/oauth-scopes.js +21 -0
- package/dist/node/participant-token.d.ts +1 -3
- package/dist/node/participant-token.js +2 -3
- package/dist/node/room-client.d.ts +16 -0
- package/dist/node/room-client.js +69 -0
- package/dist/node/storage-client.d.ts +3 -1
- package/dist/node/storage-client.js +5 -2
- package/dist/node/tool-content-type.d.ts +1 -1
- package/dist/node/tool-content-type.js +3 -2
- package/dist/node/toolkit-config.d.ts +84 -0
- package/dist/node/toolkit-config.js +415 -0
- package/package.json +1 -1
package/dist/browser/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export * from './document';
|
|
|
10
10
|
export * from './meshagent-client';
|
|
11
11
|
export * from './messaging-client';
|
|
12
12
|
export * from './memory-client';
|
|
13
|
+
export * from './oauth-scopes';
|
|
13
14
|
export * from './participant-token';
|
|
14
15
|
export * from './participant';
|
|
15
16
|
export * from './protocol';
|
|
@@ -29,5 +30,6 @@ export * from './sync-client';
|
|
|
29
30
|
export * from './api_keys';
|
|
30
31
|
export * from './helpers';
|
|
31
32
|
export * from './tool-content-type';
|
|
33
|
+
export * from './toolkit-config';
|
|
32
34
|
export * from './utils';
|
|
33
35
|
export * from './version';
|
package/dist/browser/index.js
CHANGED
|
@@ -26,6 +26,7 @@ __exportStar(require("./document"), exports);
|
|
|
26
26
|
__exportStar(require("./meshagent-client"), exports);
|
|
27
27
|
__exportStar(require("./messaging-client"), exports);
|
|
28
28
|
__exportStar(require("./memory-client"), exports);
|
|
29
|
+
__exportStar(require("./oauth-scopes"), exports);
|
|
29
30
|
__exportStar(require("./participant-token"), exports);
|
|
30
31
|
__exportStar(require("./participant"), exports);
|
|
31
32
|
__exportStar(require("./protocol"), exports);
|
|
@@ -45,5 +46,6 @@ __exportStar(require("./sync-client"), exports);
|
|
|
45
46
|
__exportStar(require("./api_keys"), exports);
|
|
46
47
|
__exportStar(require("./helpers"), exports);
|
|
47
48
|
__exportStar(require("./tool-content-type"), exports);
|
|
49
|
+
__exportStar(require("./toolkit-config"), exports);
|
|
48
50
|
__exportStar(require("./utils"), exports);
|
|
49
51
|
__exportStar(require("./version"), exports);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fullOAuthScope = exports.fullOAuthScopes = void 0;
|
|
4
|
+
exports.fullOAuthScopes = [
|
|
5
|
+
'profile',
|
|
6
|
+
'project/*',
|
|
7
|
+
'room/*',
|
|
8
|
+
'create_users',
|
|
9
|
+
'create_rooms',
|
|
10
|
+
'create_agents',
|
|
11
|
+
'managed_agents',
|
|
12
|
+
'llm_proxy',
|
|
13
|
+
'admin',
|
|
14
|
+
'developer',
|
|
15
|
+
'connect_room',
|
|
16
|
+
'delete_room',
|
|
17
|
+
'update_room',
|
|
18
|
+
'delete_agent',
|
|
19
|
+
'update_agent',
|
|
20
|
+
];
|
|
21
|
+
exports.fullOAuthScope = 'profile project/* room/* create_users create_rooms create_agents managed_agents llm_proxy admin developer connect_room delete_room update_room delete_agent update_agent';
|
|
@@ -319,9 +319,7 @@ export declare class ApiScope {
|
|
|
319
319
|
tunnels?: TunnelsGrant;
|
|
320
320
|
services?: ServicesGrant;
|
|
321
321
|
});
|
|
322
|
-
static agentDefault(
|
|
323
|
-
tunnels?: boolean;
|
|
324
|
-
}): ApiScope;
|
|
322
|
+
static agentDefault(): ApiScope;
|
|
325
323
|
static userDefault(): ApiScope;
|
|
326
324
|
static full(): ApiScope;
|
|
327
325
|
toJSON(): Record<string, any>;
|
|
@@ -939,7 +939,7 @@ class ApiScope {
|
|
|
939
939
|
this.tunnels = tunnels;
|
|
940
940
|
this.services = services;
|
|
941
941
|
}
|
|
942
|
-
static agentDefault(
|
|
942
|
+
static agentDefault() {
|
|
943
943
|
return new ApiScope({
|
|
944
944
|
livekit: new LivekitGrant(),
|
|
945
945
|
queues: new QueuesGrant(),
|
|
@@ -952,9 +952,7 @@ class ApiScope {
|
|
|
952
952
|
developer: new DeveloperGrant(),
|
|
953
953
|
agents: new AgentsGrant(),
|
|
954
954
|
llm: new LLMGrant(),
|
|
955
|
-
secrets: new SecretsGrant(),
|
|
956
955
|
services: new ServicesGrant(),
|
|
957
|
-
tunnels: tunnels ? new TunnelsGrant() : undefined,
|
|
958
956
|
});
|
|
959
957
|
}
|
|
960
958
|
static userDefault() {
|
|
@@ -969,6 +967,7 @@ class ApiScope {
|
|
|
969
967
|
containers: new ContainersGrant(),
|
|
970
968
|
developer: new DeveloperGrant(),
|
|
971
969
|
agents: new AgentsGrant(),
|
|
970
|
+
llm: new LLMGrant(),
|
|
972
971
|
secrets: new SecretsGrant(),
|
|
973
972
|
services: new ServicesGrant(),
|
|
974
973
|
});
|
|
@@ -204,6 +204,22 @@ export declare class RoomClient {
|
|
|
204
204
|
participantId?: string;
|
|
205
205
|
onBehalfOfId?: string;
|
|
206
206
|
}): Promise<Content>;
|
|
207
|
+
invokeToolCall(params: {
|
|
208
|
+
toolkit: string;
|
|
209
|
+
tool: string;
|
|
210
|
+
input: Content | AsyncIterable<Content>;
|
|
211
|
+
streamInput?: boolean;
|
|
212
|
+
participantId?: string;
|
|
213
|
+
onBehalfOfId?: string;
|
|
214
|
+
}): Promise<{
|
|
215
|
+
kind: "content";
|
|
216
|
+
content: Content;
|
|
217
|
+
inputClosed?: Promise<void>;
|
|
218
|
+
} | {
|
|
219
|
+
kind: "stream";
|
|
220
|
+
stream: AsyncIterable<Content>;
|
|
221
|
+
inputClosed?: Promise<void>;
|
|
222
|
+
}>;
|
|
207
223
|
invokeWithStreamInput(params: {
|
|
208
224
|
toolkit: string;
|
|
209
225
|
tool: string;
|
|
@@ -1229,6 +1229,75 @@ class RoomClient {
|
|
|
1229
1229
|
}
|
|
1230
1230
|
return await this.sendRequest("room.invoke_tool", request, requestData);
|
|
1231
1231
|
}
|
|
1232
|
+
async invokeToolCall(params) {
|
|
1233
|
+
const toolCallId = `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
1234
|
+
const controller = new stream_controller_1.StreamController();
|
|
1235
|
+
const responseIterator = controller.stream[Symbol.asyncIterator]();
|
|
1236
|
+
this._toolCallStreams.set(toolCallId, controller);
|
|
1237
|
+
const request = {
|
|
1238
|
+
toolkit: params.toolkit,
|
|
1239
|
+
tool: params.tool,
|
|
1240
|
+
tool_call_id: toolCallId,
|
|
1241
|
+
};
|
|
1242
|
+
let requestData;
|
|
1243
|
+
let requestTask;
|
|
1244
|
+
if (params.streamInput === true) {
|
|
1245
|
+
request["arguments"] = { type: "control", method: "open" };
|
|
1246
|
+
requestTask = this._streamInvokeToolRequestChunks(toolCallId, params.input);
|
|
1247
|
+
}
|
|
1248
|
+
else {
|
|
1249
|
+
const input = params.input;
|
|
1250
|
+
const packed = input.pack();
|
|
1251
|
+
request["arguments"] = JSON.parse((0, utils_1.splitMessageHeader)(packed));
|
|
1252
|
+
const payload = (0, utils_1.splitMessagePayload)(packed);
|
|
1253
|
+
if (payload.length > 0) {
|
|
1254
|
+
requestData = payload;
|
|
1255
|
+
}
|
|
1256
|
+
}
|
|
1257
|
+
if (params.participantId != null) {
|
|
1258
|
+
request["participant_id"] = params.participantId;
|
|
1259
|
+
}
|
|
1260
|
+
if (params.onBehalfOfId != null) {
|
|
1261
|
+
request["on_behalf_of_id"] = params.onBehalfOfId;
|
|
1262
|
+
}
|
|
1263
|
+
try {
|
|
1264
|
+
const response = await this.sendRequest("room.invoke_tool", request, requestData);
|
|
1265
|
+
if (response instanceof response_1.ControlContent && response.method === "open") {
|
|
1266
|
+
if (requestTask != null) {
|
|
1267
|
+
void requestTask.catch((error) => {
|
|
1268
|
+
const stream = this._toolCallStreams.get(toolCallId);
|
|
1269
|
+
if (stream == null) {
|
|
1270
|
+
return;
|
|
1271
|
+
}
|
|
1272
|
+
stream.add(new response_1.ErrorContent({ text: `request stream failed: ${String(error)}` }));
|
|
1273
|
+
stream.close();
|
|
1274
|
+
this._toolCallStreams.delete(toolCallId);
|
|
1275
|
+
});
|
|
1276
|
+
}
|
|
1277
|
+
return {
|
|
1278
|
+
kind: "stream",
|
|
1279
|
+
stream: {
|
|
1280
|
+
[Symbol.asyncIterator]() {
|
|
1281
|
+
return responseIterator;
|
|
1282
|
+
},
|
|
1283
|
+
},
|
|
1284
|
+
inputClosed: requestTask,
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
if (requestTask != null) {
|
|
1288
|
+
await requestTask;
|
|
1289
|
+
}
|
|
1290
|
+
this._toolCallStreams.delete(toolCallId);
|
|
1291
|
+
controller.close();
|
|
1292
|
+
return { kind: "content", content: response, inputClosed: requestTask };
|
|
1293
|
+
}
|
|
1294
|
+
catch (error) {
|
|
1295
|
+
await Promise.resolve(requestTask).catch(() => undefined);
|
|
1296
|
+
this._toolCallStreams.delete(toolCallId);
|
|
1297
|
+
controller.close();
|
|
1298
|
+
throw error;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1232
1301
|
async invokeWithStreamInput(params) {
|
|
1233
1302
|
const toolCallId = `${Date.now()}-${Math.random().toString(16).slice(2)}`;
|
|
1234
1303
|
const request = {
|
|
@@ -66,6 +66,8 @@ export declare class StorageClient extends EventEmitter<RoomEvent> {
|
|
|
66
66
|
downloadStream(path: string, { chunkSize, }?: {
|
|
67
67
|
chunkSize?: number;
|
|
68
68
|
}): Promise<AsyncIterable<BinaryContent>>;
|
|
69
|
-
downloadUrl(path: string
|
|
69
|
+
downloadUrl(path: string, options?: {
|
|
70
|
+
download?: boolean;
|
|
71
|
+
}): Promise<string>;
|
|
70
72
|
}
|
|
71
73
|
export {};
|
|
@@ -372,8 +372,11 @@ class StorageClient extends event_emitter_1.EventEmitter {
|
|
|
372
372
|
},
|
|
373
373
|
};
|
|
374
374
|
}
|
|
375
|
-
async downloadUrl(path) {
|
|
376
|
-
const response = await this._invoke("download_url", {
|
|
375
|
+
async downloadUrl(path, options = {}) {
|
|
376
|
+
const response = await this._invoke("download_url", {
|
|
377
|
+
path,
|
|
378
|
+
download: options.download ?? false,
|
|
379
|
+
});
|
|
377
380
|
if (!(response instanceof response_1.JsonContent)) {
|
|
378
381
|
throw this._unexpectedResponseError("download_url");
|
|
379
382
|
}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ToolContentSpec = void 0;
|
|
4
4
|
const SUPPORTED_TOOL_CONTENT_TYPES = new Set([
|
|
5
|
+
"binary",
|
|
5
6
|
"json",
|
|
6
7
|
"text",
|
|
7
8
|
"file",
|
|
@@ -58,10 +59,10 @@ class ToolContentSpec {
|
|
|
58
59
|
const rawStream = value["stream"];
|
|
59
60
|
const stream = typeof rawStream === "boolean" ? rawStream : false;
|
|
60
61
|
const rawSchema = value["schema"];
|
|
61
|
-
if (rawSchema !== undefined && !isRecord(rawSchema)) {
|
|
62
|
+
if (rawSchema !== undefined && rawSchema !== null && !isRecord(rawSchema)) {
|
|
62
63
|
throw new Error("ToolContentSpec.schema must be an object when provided");
|
|
63
64
|
}
|
|
64
|
-
const schema = rawSchema;
|
|
65
|
+
const schema = rawSchema == null ? undefined : rawSchema;
|
|
65
66
|
return new ToolContentSpec({ types, stream, schema });
|
|
66
67
|
}
|
|
67
68
|
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { ConnectorRef, OAuthClientConfig, ServiceSpec } from "./meshagent-client";
|
|
2
|
+
import type { RemoteParticipant } from "./participant";
|
|
3
|
+
import type { RoomClient } from "./room-client";
|
|
4
|
+
export declare class MCPHeader {
|
|
5
|
+
readonly name: string;
|
|
6
|
+
readonly value: string;
|
|
7
|
+
constructor({ name, value }: {
|
|
8
|
+
name: string;
|
|
9
|
+
value: string;
|
|
10
|
+
});
|
|
11
|
+
static fromJson(json: Record<string, unknown>): MCPHeader;
|
|
12
|
+
toJson(): Record<string, string>;
|
|
13
|
+
}
|
|
14
|
+
export type MCPRequireApproval = "always" | "never";
|
|
15
|
+
export declare class MCPServer {
|
|
16
|
+
readonly serverLabel: string;
|
|
17
|
+
readonly authorization?: string;
|
|
18
|
+
readonly serverUrl?: string;
|
|
19
|
+
readonly allowedTools?: string[];
|
|
20
|
+
readonly headers?: MCPHeader[];
|
|
21
|
+
readonly requireApproval?: MCPRequireApproval;
|
|
22
|
+
readonly alwaysRequireApproval?: string[];
|
|
23
|
+
readonly neverRequireApproval?: string[];
|
|
24
|
+
readonly openaiConnectorId?: string;
|
|
25
|
+
constructor({ serverLabel, authorization, serverUrl, allowedTools, headers, requireApproval, alwaysRequireApproval, neverRequireApproval, openaiConnectorId, }: {
|
|
26
|
+
serverLabel: string;
|
|
27
|
+
authorization?: string | null;
|
|
28
|
+
serverUrl?: string | null;
|
|
29
|
+
allowedTools?: string[] | null;
|
|
30
|
+
headers?: MCPHeader[] | null;
|
|
31
|
+
requireApproval?: MCPRequireApproval | null;
|
|
32
|
+
alwaysRequireApproval?: string[] | null;
|
|
33
|
+
neverRequireApproval?: string[] | null;
|
|
34
|
+
openaiConnectorId?: string | null;
|
|
35
|
+
});
|
|
36
|
+
static fromJson(json: Record<string, unknown>): MCPServer;
|
|
37
|
+
static fromJsonString(data: string): MCPServer;
|
|
38
|
+
toJson(): Record<string, unknown>;
|
|
39
|
+
toJsonString(): string;
|
|
40
|
+
copyWith({ serverLabel, authorization, serverUrl, allowedTools, headers, requireApproval, alwaysRequireApproval, neverRequireApproval, openaiConnectorId, }: {
|
|
41
|
+
serverLabel?: string;
|
|
42
|
+
authorization?: string | null;
|
|
43
|
+
serverUrl?: string | null;
|
|
44
|
+
allowedTools?: string[] | null;
|
|
45
|
+
headers?: MCPHeader[] | null;
|
|
46
|
+
requireApproval?: MCPRequireApproval | null;
|
|
47
|
+
alwaysRequireApproval?: string[] | null;
|
|
48
|
+
neverRequireApproval?: string[] | null;
|
|
49
|
+
openaiConnectorId?: string | null;
|
|
50
|
+
}): MCPServer;
|
|
51
|
+
}
|
|
52
|
+
export declare class Connector {
|
|
53
|
+
readonly name: string;
|
|
54
|
+
readonly oauth?: OAuthClientConfig;
|
|
55
|
+
readonly server: MCPServer;
|
|
56
|
+
constructor({ name, server, oauth, }: {
|
|
57
|
+
name: string;
|
|
58
|
+
server: MCPServer;
|
|
59
|
+
oauth?: OAuthClientConfig | null;
|
|
60
|
+
});
|
|
61
|
+
private static oauthClientSecretIdFromHeaders;
|
|
62
|
+
static buildConnectorRef({ server, oauth, }: {
|
|
63
|
+
server: MCPServer;
|
|
64
|
+
oauth?: OAuthClientConfig | null;
|
|
65
|
+
}): ConnectorRef | null;
|
|
66
|
+
private buildConnectorRef;
|
|
67
|
+
isConnected(room: RoomClient, agentName: string): Promise<boolean>;
|
|
68
|
+
authenticate(client: RoomClient, agent: RemoteParticipant, redirectUri: string | URL): Promise<string | null>;
|
|
69
|
+
}
|
|
70
|
+
export declare function mcpConnectorsFromRoomServices({ services, agentName, }: {
|
|
71
|
+
services: Iterable<ServiceSpec>;
|
|
72
|
+
agentName?: string | null;
|
|
73
|
+
}): Connector[];
|
|
74
|
+
export declare class OpenAIConnectors {
|
|
75
|
+
static readonly dropbox: Connector;
|
|
76
|
+
static readonly gmail: Connector;
|
|
77
|
+
static readonly googleCalendar: Connector;
|
|
78
|
+
static readonly googleDrive: Connector;
|
|
79
|
+
static readonly microsoftTeams: Connector;
|
|
80
|
+
static readonly outlookCalendar: Connector;
|
|
81
|
+
static readonly outlookEmail: Connector;
|
|
82
|
+
static readonly sharepoint: Connector;
|
|
83
|
+
static readonly all: Connector[];
|
|
84
|
+
}
|