@meshagent/meshagent 0.41.4 → 0.41.5
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 +3 -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/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/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/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
|
@@ -206,6 +206,31 @@ export declare class DatasetsClient {
|
|
|
206
206
|
branch?: string;
|
|
207
207
|
metadata?: Record<string, unknown>;
|
|
208
208
|
}): Promise<void>;
|
|
209
|
+
createTableWithArrowSchema({ name, schema, batches, mode, namespace, branch, metadata }: {
|
|
210
|
+
name: string;
|
|
211
|
+
schema: Schema;
|
|
212
|
+
batches?: ArrowTableChunks;
|
|
213
|
+
mode?: CreateMode;
|
|
214
|
+
namespace?: string[];
|
|
215
|
+
branch?: string;
|
|
216
|
+
metadata?: Record<string, unknown>;
|
|
217
|
+
}): Promise<void>;
|
|
218
|
+
createTableFromArrowBatches({ name, batches, mode, namespace, branch, metadata }: {
|
|
219
|
+
name: string;
|
|
220
|
+
batches: ArrowTableChunks;
|
|
221
|
+
mode?: CreateMode;
|
|
222
|
+
namespace?: string[];
|
|
223
|
+
branch?: string;
|
|
224
|
+
metadata?: Record<string, unknown>;
|
|
225
|
+
}): Promise<void>;
|
|
226
|
+
createTableFromArrowTable({ name, table, mode, namespace, branch, metadata }: {
|
|
227
|
+
name: string;
|
|
228
|
+
table: Table;
|
|
229
|
+
mode?: CreateMode;
|
|
230
|
+
namespace?: string[];
|
|
231
|
+
branch?: string;
|
|
232
|
+
metadata?: Record<string, unknown>;
|
|
233
|
+
}): Promise<void>;
|
|
209
234
|
createTableFromData({ name, data, mode, namespace, branch, metadata }: {
|
|
210
235
|
name: string;
|
|
211
236
|
data?: Iterable<Table> | Table;
|
|
@@ -237,6 +262,12 @@ export declare class DatasetsClient {
|
|
|
237
262
|
namespace?: string[];
|
|
238
263
|
branch?: string;
|
|
239
264
|
}): Promise<void>;
|
|
265
|
+
renameTable({ name, newName, namespace, branch }: {
|
|
266
|
+
name: string;
|
|
267
|
+
newName: string;
|
|
268
|
+
namespace?: string[];
|
|
269
|
+
branch?: string;
|
|
270
|
+
}): Promise<void>;
|
|
240
271
|
importFromStorage({ table, path, mode, format, on, sheet, batchSize, namespace, branch }: {
|
|
241
272
|
table: string;
|
|
242
273
|
path: string;
|
|
@@ -256,6 +287,13 @@ export declare class DatasetsClient {
|
|
|
256
287
|
branch?: string;
|
|
257
288
|
version?: number;
|
|
258
289
|
}): Promise<void>;
|
|
290
|
+
updateColumnMetadata({ table, column, metadata, namespace, branch }: {
|
|
291
|
+
table: string;
|
|
292
|
+
column: string;
|
|
293
|
+
metadata: Record<string, string>;
|
|
294
|
+
namespace?: string[];
|
|
295
|
+
branch?: string;
|
|
296
|
+
}): Promise<void>;
|
|
259
297
|
dropIndex({ table, name, namespace, branch }: {
|
|
260
298
|
table: string;
|
|
261
299
|
name: string;
|
|
@@ -280,6 +318,12 @@ export declare class DatasetsClient {
|
|
|
280
318
|
namespace?: string[];
|
|
281
319
|
branch?: string;
|
|
282
320
|
}): Promise<void>;
|
|
321
|
+
insertTable({ table, records, namespace, branch }: {
|
|
322
|
+
table: string;
|
|
323
|
+
records: Table;
|
|
324
|
+
namespace?: string[];
|
|
325
|
+
branch?: string;
|
|
326
|
+
}): Promise<void>;
|
|
283
327
|
insertStream({ table, chunks, namespace, branch }: {
|
|
284
328
|
table: string;
|
|
285
329
|
chunks: ArrowTableChunks;
|
|
@@ -306,6 +350,13 @@ export declare class DatasetsClient {
|
|
|
306
350
|
namespace?: string[];
|
|
307
351
|
branch?: string;
|
|
308
352
|
}): Promise<void>;
|
|
353
|
+
mergeTable({ table, on, records, namespace, branch }: {
|
|
354
|
+
table: string;
|
|
355
|
+
on: string;
|
|
356
|
+
records: Table;
|
|
357
|
+
namespace?: string[];
|
|
358
|
+
branch?: string;
|
|
359
|
+
}): Promise<void>;
|
|
309
360
|
mergeStream({ table, on, chunks, namespace, branch }: {
|
|
310
361
|
table: string;
|
|
311
362
|
on: string;
|
|
@@ -320,6 +371,13 @@ export declare class DatasetsClient {
|
|
|
320
371
|
namespace?: string[];
|
|
321
372
|
branch?: string;
|
|
322
373
|
}): Promise<Table[]>;
|
|
374
|
+
sqlTable({ query, tables, params, namespace, branch }: {
|
|
375
|
+
query: string;
|
|
376
|
+
tables?: Array<TableRef | string>;
|
|
377
|
+
params?: Table;
|
|
378
|
+
namespace?: string[];
|
|
379
|
+
branch?: string;
|
|
380
|
+
}): Promise<Table>;
|
|
323
381
|
openSqlQuery({ query, tables, params, namespace, branch }: {
|
|
324
382
|
query: string;
|
|
325
383
|
tables?: Array<TableRef | string>;
|
|
@@ -369,6 +427,18 @@ export declare class DatasetsClient {
|
|
|
369
427
|
branch?: string;
|
|
370
428
|
version?: number;
|
|
371
429
|
}): Promise<Table[]>;
|
|
430
|
+
searchTable({ table, text, vector, where, offset, limit, select, namespace, branch, version }: {
|
|
431
|
+
table: string;
|
|
432
|
+
text?: string;
|
|
433
|
+
vector?: number[];
|
|
434
|
+
where?: DatasetWhere;
|
|
435
|
+
offset?: number;
|
|
436
|
+
limit?: number;
|
|
437
|
+
select?: string[];
|
|
438
|
+
namespace?: string[];
|
|
439
|
+
branch?: string;
|
|
440
|
+
version?: number;
|
|
441
|
+
}): Promise<Table>;
|
|
372
442
|
searchStream({ table, text, vector, where, offset, limit, select, namespace, branch, version }: {
|
|
373
443
|
table: string;
|
|
374
444
|
text?: string;
|
|
@@ -537,6 +537,13 @@ function tableFromIPCBytes(data) {
|
|
|
537
537
|
}
|
|
538
538
|
return table;
|
|
539
539
|
}
|
|
540
|
+
function tableFromChunks(chunks) {
|
|
541
|
+
if (chunks.length === 0) {
|
|
542
|
+
return new apache_arrow_1.Table(new apache_arrow_1.Schema([]), []);
|
|
543
|
+
}
|
|
544
|
+
const [first, ...rest] = chunks;
|
|
545
|
+
return first.concat(...rest);
|
|
546
|
+
}
|
|
540
547
|
function schemaFromIPCBytes(data) {
|
|
541
548
|
return tableFromIPCBytes(data).schema;
|
|
542
549
|
}
|
|
@@ -846,6 +853,38 @@ class DatasetsClient {
|
|
|
846
853
|
metadata,
|
|
847
854
|
});
|
|
848
855
|
}
|
|
856
|
+
async createTableWithArrowSchema({ name, schema, batches, mode = "create", namespace, branch, metadata }) {
|
|
857
|
+
return this.createTable({
|
|
858
|
+
name,
|
|
859
|
+
schema,
|
|
860
|
+
data: batches,
|
|
861
|
+
mode,
|
|
862
|
+
namespace,
|
|
863
|
+
branch,
|
|
864
|
+
metadata,
|
|
865
|
+
});
|
|
866
|
+
}
|
|
867
|
+
async createTableFromArrowBatches({ name, batches, mode = "create", namespace, branch, metadata }) {
|
|
868
|
+
return this.createTable({
|
|
869
|
+
name,
|
|
870
|
+
data: batches,
|
|
871
|
+
mode,
|
|
872
|
+
namespace,
|
|
873
|
+
branch,
|
|
874
|
+
metadata,
|
|
875
|
+
});
|
|
876
|
+
}
|
|
877
|
+
async createTableFromArrowTable({ name, table, mode = "create", namespace, branch, metadata }) {
|
|
878
|
+
return this.createTableWithArrowSchema({
|
|
879
|
+
name,
|
|
880
|
+
schema: table.schema,
|
|
881
|
+
batches: [table],
|
|
882
|
+
mode,
|
|
883
|
+
namespace,
|
|
884
|
+
branch,
|
|
885
|
+
metadata,
|
|
886
|
+
});
|
|
887
|
+
}
|
|
849
888
|
async createTableFromData({ name, data, mode = "create", namespace, branch, metadata }) {
|
|
850
889
|
return this.createTable({
|
|
851
890
|
name,
|
|
@@ -882,6 +921,14 @@ class DatasetsClient {
|
|
|
882
921
|
},
|
|
883
922
|
});
|
|
884
923
|
}
|
|
924
|
+
async renameTable({ name, newName, namespace, branch }) {
|
|
925
|
+
await this.invoke("rename_table", {
|
|
926
|
+
name,
|
|
927
|
+
new_name: newName,
|
|
928
|
+
namespace: namespace ?? null,
|
|
929
|
+
branch: branch ?? null,
|
|
930
|
+
});
|
|
931
|
+
}
|
|
885
932
|
async importFromStorage({ table, path, mode = "create", format = "auto", on, sheet, batchSize, namespace, branch }) {
|
|
886
933
|
const input = {
|
|
887
934
|
table,
|
|
@@ -908,6 +955,15 @@ class DatasetsClient {
|
|
|
908
955
|
version: version ?? null,
|
|
909
956
|
});
|
|
910
957
|
}
|
|
958
|
+
async updateColumnMetadata({ table, column, metadata, namespace, branch }) {
|
|
959
|
+
await this.invoke("update_column_metadata", {
|
|
960
|
+
table,
|
|
961
|
+
column,
|
|
962
|
+
metadata: metadataEntries(metadata),
|
|
963
|
+
namespace: namespace ?? null,
|
|
964
|
+
branch: branch ?? null,
|
|
965
|
+
});
|
|
966
|
+
}
|
|
911
967
|
async dropIndex({ table, name, namespace, branch }) {
|
|
912
968
|
await this.room.invoke({
|
|
913
969
|
toolkit: "dataset",
|
|
@@ -949,6 +1005,9 @@ class DatasetsClient {
|
|
|
949
1005
|
async insert({ table, records, namespace, branch }) {
|
|
950
1006
|
await this.insertStream({ table, chunks: [records], namespace, branch });
|
|
951
1007
|
}
|
|
1008
|
+
async insertTable({ table, records, namespace, branch }) {
|
|
1009
|
+
await this.insertStream({ table, chunks: [records], namespace, branch });
|
|
1010
|
+
}
|
|
952
1011
|
async insertStream({ table, chunks, namespace, branch }) {
|
|
953
1012
|
const input = new DatasetArrowWriteInputStream({
|
|
954
1013
|
kind: "start",
|
|
@@ -981,6 +1040,9 @@ class DatasetsClient {
|
|
|
981
1040
|
async merge({ table, on, records, namespace, branch }) {
|
|
982
1041
|
await this.mergeStream({ table, on, chunks: [records], namespace, branch });
|
|
983
1042
|
}
|
|
1043
|
+
async mergeTable({ table, on, records, namespace, branch }) {
|
|
1044
|
+
await this.mergeStream({ table, on, chunks: [records], namespace, branch });
|
|
1045
|
+
}
|
|
984
1046
|
async mergeStream({ table, on, chunks, namespace, branch }) {
|
|
985
1047
|
const input = new DatasetArrowWriteInputStream({
|
|
986
1048
|
kind: "start",
|
|
@@ -998,6 +1060,9 @@ class DatasetsClient {
|
|
|
998
1060
|
}
|
|
999
1061
|
return results;
|
|
1000
1062
|
}
|
|
1063
|
+
async sqlTable({ query, tables, params, namespace, branch }) {
|
|
1064
|
+
return tableFromChunks(await this.sql({ query, tables, params, namespace, branch }));
|
|
1065
|
+
}
|
|
1001
1066
|
async openSqlQuery({ query, tables, params, namespace, branch }) {
|
|
1002
1067
|
const response = await this.invokeContent("open_sql_query", new response_1.BinaryContent({
|
|
1003
1068
|
data: params == null ? new Uint8Array() : (0, apache_arrow_1.tableToIPC)(params, "stream"),
|
|
@@ -1126,6 +1191,20 @@ class DatasetsClient {
|
|
|
1126
1191
|
}
|
|
1127
1192
|
return results;
|
|
1128
1193
|
}
|
|
1194
|
+
async searchTable({ table, text, vector, where, offset, limit, select, namespace, branch, version }) {
|
|
1195
|
+
return tableFromChunks(await this.search({
|
|
1196
|
+
table,
|
|
1197
|
+
text,
|
|
1198
|
+
vector,
|
|
1199
|
+
where,
|
|
1200
|
+
offset,
|
|
1201
|
+
limit,
|
|
1202
|
+
select,
|
|
1203
|
+
namespace,
|
|
1204
|
+
branch,
|
|
1205
|
+
version,
|
|
1206
|
+
}));
|
|
1207
|
+
}
|
|
1129
1208
|
async *searchStream({ table, text, vector, where, offset, limit, select, namespace, branch, version }) {
|
|
1130
1209
|
yield* this.streamArrow("search", {
|
|
1131
1210
|
kind: "start",
|
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
|
+
}
|