@meshagent/meshagent 0.29.2 → 0.30.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 -0
- package/dist/browser/agent-client.js +3 -28
- package/dist/browser/agent.js +6 -6
- package/dist/browser/containers-client.d.ts +125 -0
- package/dist/browser/containers-client.js +458 -0
- package/dist/browser/database-client.d.ts +42 -6
- package/dist/browser/database-client.js +610 -77
- package/dist/browser/developer-client.d.ts +2 -2
- package/dist/browser/developer-client.js +60 -15
- package/dist/browser/helpers.js +4 -3
- package/dist/browser/index.d.ts +1 -0
- package/dist/browser/index.js +1 -0
- package/dist/browser/lk-client.js +12 -3
- package/dist/browser/meshagent-client.d.ts +5 -0
- package/dist/browser/messaging-client.d.ts +1 -0
- package/dist/browser/messaging-client.js +52 -8
- package/dist/browser/queues-client.d.ts +2 -0
- package/dist/browser/queues-client.js +34 -7
- package/dist/browser/response.d.ts +28 -0
- package/dist/browser/response.js +76 -1
- package/dist/browser/room-client.d.ts +43 -1
- package/dist/browser/room-client.js +204 -0
- package/dist/browser/secrets-client.d.ts +1 -0
- package/dist/browser/secrets-client.js +32 -27
- package/dist/browser/storage-client.d.ts +22 -7
- package/dist/browser/storage-client.js +353 -15
- package/dist/browser/sync-client.d.ts +12 -13
- package/dist/browser/sync-client.js +263 -65
- package/dist/esm/agent-client.js +3 -28
- package/dist/esm/agent.js +6 -6
- package/dist/esm/containers-client.d.ts +125 -0
- package/dist/esm/containers-client.js +453 -0
- package/dist/esm/database-client.d.ts +42 -6
- package/dist/esm/database-client.js +611 -78
- package/dist/esm/developer-client.d.ts +2 -2
- package/dist/esm/developer-client.js +61 -16
- package/dist/esm/helpers.js +4 -3
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/lk-client.js +12 -3
- package/dist/esm/meshagent-client.d.ts +5 -0
- package/dist/esm/messaging-client.d.ts +1 -0
- package/dist/esm/messaging-client.js +52 -8
- package/dist/esm/queues-client.d.ts +2 -0
- package/dist/esm/queues-client.js +35 -8
- package/dist/esm/response.d.ts +28 -0
- package/dist/esm/response.js +73 -0
- package/dist/esm/room-client.d.ts +43 -1
- package/dist/esm/room-client.js +207 -3
- package/dist/esm/secrets-client.d.ts +1 -0
- package/dist/esm/secrets-client.js +33 -28
- package/dist/esm/storage-client.d.ts +22 -7
- package/dist/esm/storage-client.js +353 -15
- package/dist/esm/sync-client.d.ts +12 -13
- package/dist/esm/sync-client.js +263 -64
- package/dist/node/agent-client.js +3 -28
- package/dist/node/agent.js +6 -6
- package/dist/node/containers-client.d.ts +125 -0
- package/dist/node/containers-client.js +458 -0
- package/dist/node/database-client.d.ts +42 -6
- package/dist/node/database-client.js +610 -77
- package/dist/node/developer-client.d.ts +2 -2
- package/dist/node/developer-client.js +60 -15
- package/dist/node/helpers.js +4 -3
- package/dist/node/index.d.ts +1 -0
- package/dist/node/index.js +1 -0
- package/dist/node/lk-client.js +12 -3
- package/dist/node/meshagent-client.d.ts +5 -0
- package/dist/node/messaging-client.d.ts +1 -0
- package/dist/node/messaging-client.js +52 -8
- package/dist/node/queues-client.d.ts +2 -0
- package/dist/node/queues-client.js +34 -7
- package/dist/node/response.d.ts +28 -0
- package/dist/node/response.js +76 -1
- package/dist/node/room-client.d.ts +43 -1
- package/dist/node/room-client.js +204 -0
- package/dist/node/secrets-client.d.ts +1 -0
- package/dist/node/secrets-client.js +32 -27
- package/dist/node/storage-client.d.ts +22 -7
- package/dist/node/storage-client.js +353 -15
- package/dist/node/sync-client.d.ts +12 -13
- package/dist/node/sync-client.js +263 -65
- package/package.json +1 -1
package/dist/node/room-client.js
CHANGED
|
@@ -13,6 +13,7 @@ const queues_client_1 = require("./queues-client");
|
|
|
13
13
|
const database_client_1 = require("./database-client");
|
|
14
14
|
const agent_client_1 = require("./agent-client");
|
|
15
15
|
const secrets_client_1 = require("./secrets-client");
|
|
16
|
+
const containers_client_1 = require("./containers-client");
|
|
16
17
|
const room_server_client_1 = require("./room-server-client");
|
|
17
18
|
const response_1 = require("./response");
|
|
18
19
|
class RoomClient {
|
|
@@ -21,10 +22,12 @@ class RoomClient {
|
|
|
21
22
|
this._ready = new completer_1.Completer();
|
|
22
23
|
this._localParticipant = null;
|
|
23
24
|
this._eventsController = new stream_controller_1.StreamController();
|
|
25
|
+
this._toolCallStreams = new Map();
|
|
24
26
|
this.protocol = protocol;
|
|
25
27
|
protocol.addHandler("room_ready", this._handleRoomReady.bind(this));
|
|
26
28
|
protocol.addHandler("connected", this._handleParticipant.bind(this));
|
|
27
29
|
protocol.addHandler("__response__", this._handleResponse.bind(this));
|
|
30
|
+
protocol.addHandler("room.tool_call_response_chunk", this._handleToolCallResponseChunk.bind(this));
|
|
28
31
|
this.sync = new sync_client_1.SyncClient({ room: this });
|
|
29
32
|
this.storage = new storage_client_1.StorageClient({ room: this });
|
|
30
33
|
this.developer = new developer_client_1.DeveloperClient({ room: this });
|
|
@@ -33,6 +36,7 @@ class RoomClient {
|
|
|
33
36
|
this.database = new database_client_1.DatabaseClient({ room: this });
|
|
34
37
|
this.agents = new agent_client_1.AgentsClient({ room: this });
|
|
35
38
|
this.secrets = new secrets_client_1.SecretsClient({ room: this });
|
|
39
|
+
this.containers = new containers_client_1.ContainersClient({ room: this });
|
|
36
40
|
}
|
|
37
41
|
get localParticipant() {
|
|
38
42
|
return this._localParticipant;
|
|
@@ -51,6 +55,10 @@ class RoomClient {
|
|
|
51
55
|
this._pendingRequests.delete(prKey);
|
|
52
56
|
}
|
|
53
57
|
this.sync.dispose();
|
|
58
|
+
for (const stream of this._toolCallStreams.values()) {
|
|
59
|
+
stream.close();
|
|
60
|
+
}
|
|
61
|
+
this._toolCallStreams.clear();
|
|
54
62
|
this.protocol.dispose();
|
|
55
63
|
this._localParticipant = null;
|
|
56
64
|
}
|
|
@@ -62,6 +70,202 @@ class RoomClient {
|
|
|
62
70
|
await this.protocol.send(type, message, requestId);
|
|
63
71
|
return await pr.fut;
|
|
64
72
|
}
|
|
73
|
+
async call(params) {
|
|
74
|
+
await this.sendRequest("room.call", params);
|
|
75
|
+
}
|
|
76
|
+
async listToolkits(params) {
|
|
77
|
+
const request = {};
|
|
78
|
+
if (params?.participantId != null) {
|
|
79
|
+
request["participant_id"] = params.participantId;
|
|
80
|
+
}
|
|
81
|
+
if (params?.participantName != null) {
|
|
82
|
+
request["participant_name"] = params.participantName;
|
|
83
|
+
}
|
|
84
|
+
if (params?.timeout !== undefined) {
|
|
85
|
+
request["timeout"] = params.timeout;
|
|
86
|
+
}
|
|
87
|
+
const result = await this.sendRequest("room.list_toolkits", request);
|
|
88
|
+
if (!(result instanceof response_1.JsonContent)) {
|
|
89
|
+
throw new room_server_client_1.RoomServerException("unexpected return type from room.list_toolkits");
|
|
90
|
+
}
|
|
91
|
+
const tools = result.json["tools"];
|
|
92
|
+
if (typeof tools !== "object" || tools === null || Array.isArray(tools)) {
|
|
93
|
+
throw new room_server_client_1.RoomServerException("unexpected return type from room.list_toolkits");
|
|
94
|
+
}
|
|
95
|
+
const toolkits = [];
|
|
96
|
+
for (const [name, data] of Object.entries(tools)) {
|
|
97
|
+
if (typeof data !== "object" || data === null || Array.isArray(data)) {
|
|
98
|
+
throw new room_server_client_1.RoomServerException("unexpected toolkit description from room.list_toolkits");
|
|
99
|
+
}
|
|
100
|
+
toolkits.push(agent_client_1.ToolkitDescription.fromJson(data, { name }));
|
|
101
|
+
}
|
|
102
|
+
return toolkits;
|
|
103
|
+
}
|
|
104
|
+
async invoke(params) {
|
|
105
|
+
const input = params.input ?? params.arguments ?? new response_1.EmptyContent();
|
|
106
|
+
const request = {
|
|
107
|
+
toolkit: params.toolkit,
|
|
108
|
+
tool: params.tool,
|
|
109
|
+
};
|
|
110
|
+
let requestData;
|
|
111
|
+
if (input instanceof response_1.BinaryContent ||
|
|
112
|
+
input instanceof response_1.EmptyContent ||
|
|
113
|
+
input instanceof response_1.ErrorContent ||
|
|
114
|
+
input instanceof response_1.FileContent ||
|
|
115
|
+
input instanceof response_1.JsonContent ||
|
|
116
|
+
input instanceof response_1.LinkContent ||
|
|
117
|
+
input instanceof response_1.TextContent) {
|
|
118
|
+
const packed = input.pack();
|
|
119
|
+
request["arguments"] = JSON.parse((0, utils_1.splitMessageHeader)(packed));
|
|
120
|
+
const payload = (0, utils_1.splitMessagePayload)(packed);
|
|
121
|
+
if (payload.length > 0) {
|
|
122
|
+
requestData = payload;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else if (typeof input === "object" && input !== null && !Array.isArray(input)) {
|
|
126
|
+
request["arguments"] = {
|
|
127
|
+
type: "json",
|
|
128
|
+
json: input,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
throw new room_server_client_1.RoomServerException("invoke input must be a content value or JSON object");
|
|
133
|
+
}
|
|
134
|
+
if (params.participantId != null) {
|
|
135
|
+
request["participant_id"] = params.participantId;
|
|
136
|
+
}
|
|
137
|
+
if (params.onBehalfOfId != null) {
|
|
138
|
+
request["on_behalf_of_id"] = params.onBehalfOfId;
|
|
139
|
+
}
|
|
140
|
+
if (params.callerContext != null) {
|
|
141
|
+
request["caller_context"] = params.callerContext;
|
|
142
|
+
}
|
|
143
|
+
return await this.sendRequest("room.invoke_tool", request, requestData);
|
|
144
|
+
}
|
|
145
|
+
async invokeWithStreamInput(params) {
|
|
146
|
+
const toolCallId = `${Date.now()}-${this.protocol.getNextMessageId()}-${Math.random().toString(16).slice(2)}`;
|
|
147
|
+
const request = {
|
|
148
|
+
toolkit: params.toolkit,
|
|
149
|
+
tool: params.tool,
|
|
150
|
+
tool_call_id: toolCallId,
|
|
151
|
+
arguments: { type: "control", method: "open" },
|
|
152
|
+
};
|
|
153
|
+
if (params.participantId != null) {
|
|
154
|
+
request["participant_id"] = params.participantId;
|
|
155
|
+
}
|
|
156
|
+
if (params.onBehalfOfId != null) {
|
|
157
|
+
request["on_behalf_of_id"] = params.onBehalfOfId;
|
|
158
|
+
}
|
|
159
|
+
if (params.callerContext != null) {
|
|
160
|
+
request["caller_context"] = params.callerContext;
|
|
161
|
+
}
|
|
162
|
+
const requestTask = this._streamInvokeToolRequestChunks(toolCallId, params.input);
|
|
163
|
+
try {
|
|
164
|
+
const response = await this.sendRequest("room.invoke_tool", request);
|
|
165
|
+
await requestTask;
|
|
166
|
+
if (response instanceof response_1.ControlContent && response.method === "open") {
|
|
167
|
+
throw new room_server_client_1.RoomServerException(`unexpected return type from ${params.toolkit}.${params.tool}`);
|
|
168
|
+
}
|
|
169
|
+
return response;
|
|
170
|
+
}
|
|
171
|
+
catch (error) {
|
|
172
|
+
await Promise.resolve(requestTask).catch(() => undefined);
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
async invokeStream(params) {
|
|
177
|
+
const toolCallId = `${Date.now()}-${this.protocol.getNextMessageId()}-${Math.random().toString(16).slice(2)}`;
|
|
178
|
+
const controller = new stream_controller_1.StreamController();
|
|
179
|
+
const responseIterator = controller.stream[Symbol.asyncIterator]();
|
|
180
|
+
this._toolCallStreams.set(toolCallId, controller);
|
|
181
|
+
const request = {
|
|
182
|
+
toolkit: params.toolkit,
|
|
183
|
+
tool: params.tool,
|
|
184
|
+
tool_call_id: toolCallId,
|
|
185
|
+
arguments: { type: "control", method: "open" },
|
|
186
|
+
};
|
|
187
|
+
if (params.participantId != null) {
|
|
188
|
+
request["participant_id"] = params.participantId;
|
|
189
|
+
}
|
|
190
|
+
if (params.onBehalfOfId != null) {
|
|
191
|
+
request["on_behalf_of_id"] = params.onBehalfOfId;
|
|
192
|
+
}
|
|
193
|
+
if (params.callerContext != null) {
|
|
194
|
+
request["caller_context"] = params.callerContext;
|
|
195
|
+
}
|
|
196
|
+
const requestTask = this._streamInvokeToolRequestChunks(toolCallId, params.input);
|
|
197
|
+
void requestTask.catch((error) => {
|
|
198
|
+
const stream = this._toolCallStreams.get(toolCallId);
|
|
199
|
+
if (!stream) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
stream.add(new response_1.ErrorContent({ text: `request stream failed: ${String(error)}` }));
|
|
203
|
+
stream.close();
|
|
204
|
+
this._toolCallStreams.delete(toolCallId);
|
|
205
|
+
});
|
|
206
|
+
const response = await this.sendRequest("room.invoke_tool", request);
|
|
207
|
+
if (!(response instanceof response_1.ControlContent) || response.method !== "open") {
|
|
208
|
+
this._toolCallStreams.delete(toolCallId);
|
|
209
|
+
controller.close();
|
|
210
|
+
throw new room_server_client_1.RoomServerException(`unexpected return type from ${params.toolkit}.${params.tool}`);
|
|
211
|
+
}
|
|
212
|
+
return {
|
|
213
|
+
[Symbol.asyncIterator]() {
|
|
214
|
+
return responseIterator;
|
|
215
|
+
},
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
async _sendToolCallRequestChunk(toolCallId, chunk) {
|
|
219
|
+
const packed = chunk.pack();
|
|
220
|
+
const request = {
|
|
221
|
+
tool_call_id: toolCallId,
|
|
222
|
+
chunk: JSON.parse((0, utils_1.splitMessageHeader)(packed)),
|
|
223
|
+
};
|
|
224
|
+
const payload = (0, utils_1.splitMessagePayload)(packed);
|
|
225
|
+
await this.sendRequest("room.tool_call_request_chunk", request, payload.length > 0 ? payload : undefined);
|
|
226
|
+
}
|
|
227
|
+
async _streamInvokeToolRequestChunks(toolCallId, input) {
|
|
228
|
+
await Promise.resolve();
|
|
229
|
+
try {
|
|
230
|
+
for await (const item of input) {
|
|
231
|
+
await this._sendToolCallRequestChunk(toolCallId, item);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
finally {
|
|
235
|
+
await this._sendToolCallRequestChunk(toolCallId, new response_1.ControlContent({ method: "close" }));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
_decodeToolCallContent(params) {
|
|
239
|
+
const chunk = params.header["chunk"];
|
|
240
|
+
if (typeof chunk === "object" && chunk !== null && !Array.isArray(chunk)) {
|
|
241
|
+
const chunkMap = chunk;
|
|
242
|
+
if (typeof chunkMap["type"] === "string") {
|
|
243
|
+
return (0, response_1.unpackContent)((0, utils_1.packMessage)(chunkMap, params.payload.length > 0 ? params.payload : undefined));
|
|
244
|
+
}
|
|
245
|
+
return new response_1.JsonContent({ json: chunkMap });
|
|
246
|
+
}
|
|
247
|
+
return new response_1.JsonContent({ json: { chunk } });
|
|
248
|
+
}
|
|
249
|
+
async _handleToolCallResponseChunk(protocol, messageId, type, data) {
|
|
250
|
+
if (!data) {
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
const [header, payload] = (0, utils_1.unpackMessage)(data);
|
|
254
|
+
const toolCallId = header["tool_call_id"];
|
|
255
|
+
if (typeof toolCallId !== "string" || toolCallId.length === 0) {
|
|
256
|
+
return;
|
|
257
|
+
}
|
|
258
|
+
const stream = this._toolCallStreams.get(toolCallId);
|
|
259
|
+
if (!stream) {
|
|
260
|
+
return;
|
|
261
|
+
}
|
|
262
|
+
const content = this._decodeToolCallContent({ header, payload });
|
|
263
|
+
stream.add(content);
|
|
264
|
+
if (content instanceof response_1.ControlContent && content.method === "close") {
|
|
265
|
+
stream.close();
|
|
266
|
+
this._toolCallStreams.delete(toolCallId);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
65
269
|
async _handleResponse(protocol, messageId, type, data) {
|
|
66
270
|
if (!data) {
|
|
67
271
|
console.error("No data in response");
|
|
@@ -6,43 +6,50 @@ class SecretsClient {
|
|
|
6
6
|
constructor({ room }) {
|
|
7
7
|
this.client = room;
|
|
8
8
|
}
|
|
9
|
+
unexpectedResponse(operation) {
|
|
10
|
+
return new Error(`unexpected return type from secrets.${operation}`);
|
|
11
|
+
}
|
|
9
12
|
async setSecret({ secretId, data, mimeType, name, delegatedTo, forIdentity, }) {
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
const response = await this.client.invoke({
|
|
14
|
+
toolkit: "secrets",
|
|
15
|
+
tool: "set_secret",
|
|
16
|
+
input: new response_1.BinaryContent({
|
|
17
|
+
data,
|
|
18
|
+
headers: {
|
|
19
|
+
secret_id: secretId,
|
|
20
|
+
type: mimeType ?? null,
|
|
21
|
+
name: name ?? null,
|
|
22
|
+
delegated_to: delegatedTo ?? null,
|
|
23
|
+
for_identity: forIdentity ?? null,
|
|
24
|
+
has_data: true,
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
});
|
|
22
28
|
if (response instanceof response_1.EmptyContent || response instanceof response_1.JsonContent) {
|
|
23
29
|
return;
|
|
24
30
|
}
|
|
25
|
-
throw
|
|
31
|
+
throw this.unexpectedResponse("set_secret");
|
|
26
32
|
}
|
|
27
33
|
async getSecret({ secretId, delegatedTo, }) {
|
|
28
34
|
const req = {
|
|
29
35
|
secret_id: secretId,
|
|
36
|
+
type: null,
|
|
37
|
+
name: null,
|
|
38
|
+
delegated_to: delegatedTo ?? null,
|
|
30
39
|
};
|
|
31
|
-
|
|
32
|
-
req.delegated_to = delegatedTo;
|
|
33
|
-
const response = await this.client.sendRequest("secrets.get_secret", req);
|
|
40
|
+
const response = await this.client.invoke({ toolkit: "secrets", tool: "get_secret", input: req });
|
|
34
41
|
if (response instanceof response_1.EmptyContent) {
|
|
35
42
|
return null;
|
|
36
43
|
}
|
|
37
44
|
if (response instanceof response_1.FileContent) {
|
|
38
45
|
return response;
|
|
39
46
|
}
|
|
40
|
-
throw
|
|
47
|
+
throw this.unexpectedResponse("get_secret");
|
|
41
48
|
}
|
|
42
49
|
async listSecrets() {
|
|
43
|
-
const response = await this.client.
|
|
50
|
+
const response = await this.client.invoke({ toolkit: "secrets", tool: "list_secrets", input: {} });
|
|
44
51
|
if (!(response instanceof response_1.JsonContent)) {
|
|
45
|
-
throw
|
|
52
|
+
throw this.unexpectedResponse("list_secrets");
|
|
46
53
|
}
|
|
47
54
|
const secrets = Array.isArray(response.json?.secrets) ? response.json.secrets : [];
|
|
48
55
|
return secrets.map((item) => ({
|
|
@@ -55,27 +62,25 @@ class SecretsClient {
|
|
|
55
62
|
async deleteSecret({ secretId, delegatedTo, }) {
|
|
56
63
|
const req = {
|
|
57
64
|
id: secretId,
|
|
65
|
+
delegated_to: delegatedTo ?? null,
|
|
58
66
|
};
|
|
59
|
-
|
|
60
|
-
req.delegated_to = delegatedTo;
|
|
61
|
-
const response = await this.client.sendRequest("secrets.delete_secret", req);
|
|
67
|
+
const response = await this.client.invoke({ toolkit: "secrets", tool: "delete_secret", input: req });
|
|
62
68
|
if (response instanceof response_1.EmptyContent || response instanceof response_1.JsonContent) {
|
|
63
69
|
return;
|
|
64
70
|
}
|
|
65
|
-
throw
|
|
71
|
+
throw this.unexpectedResponse("delete_secret");
|
|
66
72
|
}
|
|
67
73
|
async deleteRequestedSecret({ url, type, delegatedTo, }) {
|
|
68
74
|
const req = {
|
|
69
75
|
url,
|
|
70
76
|
type,
|
|
77
|
+
delegated_to: delegatedTo ?? null,
|
|
71
78
|
};
|
|
72
|
-
|
|
73
|
-
req.delegated_to = delegatedTo;
|
|
74
|
-
const response = await this.client.sendRequest("secrets.delete_requested_secret", req);
|
|
79
|
+
const response = await this.client.invoke({ toolkit: "secrets", tool: "delete_requested_secret", input: req });
|
|
75
80
|
if (response instanceof response_1.EmptyContent || response instanceof response_1.JsonContent) {
|
|
76
81
|
return;
|
|
77
82
|
}
|
|
78
|
-
throw
|
|
83
|
+
throw this.unexpectedResponse("delete_requested_secret");
|
|
79
84
|
}
|
|
80
85
|
}
|
|
81
86
|
exports.SecretsClient = SecretsClient;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { RoomClient } from "./room-client";
|
|
2
2
|
import { RoomEvent } from "./room-event";
|
|
3
|
-
import { FileContent } from "./response";
|
|
3
|
+
import { BinaryContent, FileContent } from "./response";
|
|
4
4
|
import { EventEmitter } from "./event-emitter";
|
|
5
5
|
export declare class FileHandle {
|
|
6
6
|
id: number;
|
|
@@ -11,9 +11,11 @@ export declare class FileHandle {
|
|
|
11
11
|
declare class StorageEntry {
|
|
12
12
|
name: string;
|
|
13
13
|
isFolder: boolean;
|
|
14
|
-
|
|
14
|
+
size: number | null;
|
|
15
|
+
constructor({ name, isFolder, size }: {
|
|
15
16
|
name: string;
|
|
16
17
|
isFolder: boolean;
|
|
18
|
+
size?: number | null;
|
|
17
19
|
});
|
|
18
20
|
nameWithoutExtension(): string;
|
|
19
21
|
}
|
|
@@ -24,15 +26,28 @@ export declare class StorageClient extends EventEmitter<RoomEvent> {
|
|
|
24
26
|
});
|
|
25
27
|
private _handleFileUpdated;
|
|
26
28
|
private _handleFileDeleted;
|
|
29
|
+
private _unexpectedResponseError;
|
|
30
|
+
private _invoke;
|
|
27
31
|
list(path: string): Promise<StorageEntry[]>;
|
|
28
32
|
delete(path: string): Promise<void>;
|
|
29
|
-
open(path: string, { overwrite }: {
|
|
30
|
-
overwrite: boolean;
|
|
31
|
-
}): Promise<FileHandle>;
|
|
32
33
|
exists(path: string): Promise<boolean>;
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
private _defaultUploadName;
|
|
35
|
+
upload(path: string, bytes: Uint8Array, { overwrite, name, mimeType, }?: {
|
|
36
|
+
overwrite?: boolean;
|
|
37
|
+
name?: string | null;
|
|
38
|
+
mimeType?: string | null;
|
|
39
|
+
}): Promise<void>;
|
|
40
|
+
uploadStream(path: string, chunks: AsyncIterable<Uint8Array>, { overwrite, chunkSize, size, name, mimeType, }?: {
|
|
41
|
+
overwrite?: boolean;
|
|
42
|
+
chunkSize?: number;
|
|
43
|
+
size?: number | null;
|
|
44
|
+
name?: string | null;
|
|
45
|
+
mimeType?: string | null;
|
|
46
|
+
}): Promise<void>;
|
|
35
47
|
download(path: string): Promise<FileContent>;
|
|
48
|
+
downloadStream(path: string, { chunkSize, }?: {
|
|
49
|
+
chunkSize?: number;
|
|
50
|
+
}): Promise<AsyncIterable<BinaryContent>>;
|
|
36
51
|
downloadUrl(path: string): Promise<string>;
|
|
37
52
|
}
|
|
38
53
|
export {};
|