@datalayer/agent-runtimes 1.3.45 → 1.3.46
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.
|
@@ -217,6 +217,34 @@ export declare const correctRuntimeMemory: (token: string, memoryId: string, tex
|
|
|
217
217
|
* the service refuses (409) in a sentence (LOOP R-18).
|
|
218
218
|
*/
|
|
219
219
|
export declare const forgetRuntimeMemories: (token: string, agentId: string, count: number, baseUrl?: string) => Promise<ForgetRuntimeMemoriesResponse>;
|
|
220
|
+
/**
|
|
221
|
+
* One allowance of a person (LOOP R-35): `reader` uses what `source`
|
|
222
|
+
* remembers of them, both applications by their key `app:<uid>`.
|
|
223
|
+
*/
|
|
224
|
+
export interface RuntimeMemoryShare {
|
|
225
|
+
source: string;
|
|
226
|
+
reader: string;
|
|
227
|
+
/** When it was allowed (ISO). */
|
|
228
|
+
allowed_at: string | null;
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* The caller's allowances: who reads what one application remembers of them
|
|
232
|
+
* (`source`), or what one application reads besides its own (`reader`).
|
|
233
|
+
*/
|
|
234
|
+
export declare const listRuntimeMemoryShares: (token: string, filter: {
|
|
235
|
+
source?: string;
|
|
236
|
+
reader?: string;
|
|
237
|
+
}, baseUrl?: string) => Promise<RuntimeMemoryShare[]>;
|
|
238
|
+
/**
|
|
239
|
+
* Allow `reader` to use what `source` remembers of the caller (LOOP R-35).
|
|
240
|
+
* Allowed again, it is kept as it was.
|
|
241
|
+
*/
|
|
242
|
+
export declare const allowRuntimeMemoryShare: (token: string, source: string, reader: string, baseUrl?: string) => Promise<RuntimeMemoryShare>;
|
|
243
|
+
/**
|
|
244
|
+
* Stop sharing what `source` remembers of the caller with `reader`
|
|
245
|
+
* (LOOP R-35); the service refuses (404) what was never allowed.
|
|
246
|
+
*/
|
|
247
|
+
export declare const stopRuntimeMemoryShare: (token: string, source: string, reader: string, baseUrl?: string) => Promise<void>;
|
|
220
248
|
/**
|
|
221
249
|
* Resume a paused runtime by restoring from a checkpoint (async).
|
|
222
250
|
*
|
|
@@ -325,6 +325,60 @@ export const forgetRuntimeMemories = async (token, agentId, count, baseUrl = DEF
|
|
|
325
325
|
forgotten: Number(response?.forgotten ?? 0),
|
|
326
326
|
};
|
|
327
327
|
};
|
|
328
|
+
/**
|
|
329
|
+
* The caller's allowances: who reads what one application remembers of them
|
|
330
|
+
* (`source`), or what one application reads besides its own (`reader`).
|
|
331
|
+
*/
|
|
332
|
+
export const listRuntimeMemoryShares = async (token, filter, baseUrl = DEFAULT_SERVICE_URLS.RUNTIMES) => {
|
|
333
|
+
validateToken(token);
|
|
334
|
+
const query = new URLSearchParams();
|
|
335
|
+
if (filter.source) {
|
|
336
|
+
query.set('source', filter.source.trim());
|
|
337
|
+
}
|
|
338
|
+
if (filter.reader) {
|
|
339
|
+
query.set('reader', filter.reader.trim());
|
|
340
|
+
}
|
|
341
|
+
const response = await requestDatalayerAPI({
|
|
342
|
+
url: `${baseUrl}${API_BASE_PATHS.RUNTIMES}/memory-shares?${query.toString()}`,
|
|
343
|
+
method: 'GET',
|
|
344
|
+
token,
|
|
345
|
+
});
|
|
346
|
+
return Array.isArray(response?.shares) ? response.shares : [];
|
|
347
|
+
};
|
|
348
|
+
/**
|
|
349
|
+
* Allow `reader` to use what `source` remembers of the caller (LOOP R-35).
|
|
350
|
+
* Allowed again, it is kept as it was.
|
|
351
|
+
*/
|
|
352
|
+
export const allowRuntimeMemoryShare = async (token, source, reader, baseUrl = DEFAULT_SERVICE_URLS.RUNTIMES) => {
|
|
353
|
+
validateToken(token);
|
|
354
|
+
validateRequiredString(source, 'The application remembering');
|
|
355
|
+
validateRequiredString(reader, 'The application reading');
|
|
356
|
+
const response = await requestDatalayerAPI({
|
|
357
|
+
url: `${baseUrl}${API_BASE_PATHS.RUNTIMES}/memory-shares`,
|
|
358
|
+
method: 'PUT',
|
|
359
|
+
body: { source: source.trim(), reader: reader.trim() },
|
|
360
|
+
token,
|
|
361
|
+
});
|
|
362
|
+
return response?.share;
|
|
363
|
+
};
|
|
364
|
+
/**
|
|
365
|
+
* Stop sharing what `source` remembers of the caller with `reader`
|
|
366
|
+
* (LOOP R-35); the service refuses (404) what was never allowed.
|
|
367
|
+
*/
|
|
368
|
+
export const stopRuntimeMemoryShare = async (token, source, reader, baseUrl = DEFAULT_SERVICE_URLS.RUNTIMES) => {
|
|
369
|
+
validateToken(token);
|
|
370
|
+
validateRequiredString(source, 'The application remembering');
|
|
371
|
+
validateRequiredString(reader, 'The application reading');
|
|
372
|
+
const query = new URLSearchParams({
|
|
373
|
+
source: source.trim(),
|
|
374
|
+
reader: reader.trim(),
|
|
375
|
+
});
|
|
376
|
+
await requestDatalayerAPI({
|
|
377
|
+
url: `${baseUrl}${API_BASE_PATHS.RUNTIMES}/memory-shares?${query.toString()}`,
|
|
378
|
+
method: 'DELETE',
|
|
379
|
+
token,
|
|
380
|
+
});
|
|
381
|
+
};
|
|
328
382
|
/**
|
|
329
383
|
* Resume a paused runtime by restoring from a checkpoint (async).
|
|
330
384
|
*
|
|
@@ -14,7 +14,7 @@ import type { SpaceDTO, UpdateSpaceRequest } from '../models/SpaceDTO';
|
|
|
14
14
|
import type { NotebookDTO } from '../models/NotebookDTO';
|
|
15
15
|
import type { LexicalDTO } from '../models/LexicalDTO';
|
|
16
16
|
import type { ProjectDTO, ProjectDefaultItems } from '../models/ProjectDTO';
|
|
17
|
-
import type { RuntimeMemory, ListRuntimeMemoriesOptions } from '../api/runtimes/runtimes';
|
|
17
|
+
import type { RuntimeMemory, RuntimeMemoryShare, ListRuntimeMemoriesOptions } from '../api/runtimes/runtimes';
|
|
18
18
|
declare const AgentRuntimesClientWithMixins: {
|
|
19
19
|
new (...args: any[]): {
|
|
20
20
|
getMySpaces(): Promise<SpaceDTO[]>;
|
|
@@ -61,6 +61,12 @@ declare const AgentRuntimesClientWithMixins: {
|
|
|
61
61
|
forgetRuntimeMemory(memoryId: string): Promise<number>;
|
|
62
62
|
correctRuntimeMemory(memoryId: string, text: string): Promise<RuntimeMemory>;
|
|
63
63
|
forgetRuntimeMemories(agentId: string, count: number): Promise<number>;
|
|
64
|
+
listRuntimeMemoryShares(filter: {
|
|
65
|
+
source?: string;
|
|
66
|
+
reader?: string;
|
|
67
|
+
}): Promise<RuntimeMemoryShare[]>;
|
|
68
|
+
allowRuntimeMemoryShare(source: string, reader: string): Promise<RuntimeMemoryShare>;
|
|
69
|
+
stopRuntimeMemoryShare(source: string, reader: string): Promise<void>;
|
|
64
70
|
terminateAllRuntimes(): Promise<PromiseSettledResult<void>[]>;
|
|
65
71
|
createSnapshot(runtimeName: string, name: string, description: string, stop?: boolean): Promise<CodeSandboxSnapshotDTO>;
|
|
66
72
|
listSnapshots(): Promise<CodeSandboxSnapshotDTO[]>;
|
|
@@ -98,6 +104,12 @@ export interface AgentRuntimesClient extends DatalayerCoreClient {
|
|
|
98
104
|
forgetRuntimeMemory(memoryId: string): Promise<number>;
|
|
99
105
|
correctRuntimeMemory(memoryId: string, text: string): Promise<RuntimeMemory>;
|
|
100
106
|
forgetRuntimeMemories(agentId: string, count: number): Promise<number>;
|
|
107
|
+
listRuntimeMemoryShares(filter: {
|
|
108
|
+
source?: string;
|
|
109
|
+
reader?: string;
|
|
110
|
+
}): Promise<RuntimeMemoryShare[]>;
|
|
111
|
+
allowRuntimeMemoryShare(source: string, reader: string): Promise<RuntimeMemoryShare>;
|
|
112
|
+
stopRuntimeMemoryShare(source: string, reader: string): Promise<void>;
|
|
101
113
|
getRuntime(runtimeName: string): Promise<RuntimeDTO>;
|
|
102
114
|
deleteRuntime(runtimeName: string): Promise<void>;
|
|
103
115
|
terminateAllRuntimes(): Promise<PromiseSettledResult<void>[]>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { RuntimeMemory, ListRuntimeMemoriesOptions } from '../../api/runtimes/runtimes';
|
|
1
|
+
import type { RuntimeMemory, RuntimeMemoryShare, ListRuntimeMemoriesOptions } from '../../api/runtimes/runtimes';
|
|
2
2
|
import type { Constructor } from '@datalayer/core/lib/client/utils/mixins';
|
|
3
3
|
import { EnvironmentDTO } from '../../models/EnvironmentDTO';
|
|
4
4
|
import { RuntimeDTO } from '../../models/RuntimeDTO';
|
|
@@ -106,6 +106,18 @@ export declare function RuntimesMixin<TBase extends Constructor>(Base: TBase): {
|
|
|
106
106
|
* the caller, no more than the `count` confirmed.
|
|
107
107
|
*/
|
|
108
108
|
forgetRuntimeMemories(agentId: string, count: number): Promise<number>;
|
|
109
|
+
/**
|
|
110
|
+
* The caller's allowances to share what an application remembers of
|
|
111
|
+
* them with another (LOOP R-35), by `source` or by `reader`.
|
|
112
|
+
*/
|
|
113
|
+
listRuntimeMemoryShares(filter: {
|
|
114
|
+
source?: string;
|
|
115
|
+
reader?: string;
|
|
116
|
+
}): Promise<RuntimeMemoryShare[]>;
|
|
117
|
+
/** Allow `reader` to use what `source` remembers of the caller. */
|
|
118
|
+
allowRuntimeMemoryShare(source: string, reader: string): Promise<RuntimeMemoryShare>;
|
|
119
|
+
/** Stop sharing what `source` remembers of the caller with `reader`. */
|
|
120
|
+
stopRuntimeMemoryShare(source: string, reader: string): Promise<void>;
|
|
109
121
|
/**
|
|
110
122
|
* Terminate all runtimes.
|
|
111
123
|
* Lists all runtimes and deletes them in parallel.
|
|
@@ -198,6 +198,27 @@ export function RuntimesMixin(Base) {
|
|
|
198
198
|
const response = await runtimes.forgetRuntimeMemories(token, agentId, count, runtimesUrl);
|
|
199
199
|
return response.forgotten;
|
|
200
200
|
}
|
|
201
|
+
/**
|
|
202
|
+
* The caller's allowances to share what an application remembers of
|
|
203
|
+
* them with another (LOOP R-35), by `source` or by `reader`.
|
|
204
|
+
*/
|
|
205
|
+
async listRuntimeMemoryShares(filter) {
|
|
206
|
+
const token = this.getToken();
|
|
207
|
+
const runtimesUrl = this.getRuntimesUrl();
|
|
208
|
+
return runtimes.listRuntimeMemoryShares(token, filter, runtimesUrl);
|
|
209
|
+
}
|
|
210
|
+
/** Allow `reader` to use what `source` remembers of the caller. */
|
|
211
|
+
async allowRuntimeMemoryShare(source, reader) {
|
|
212
|
+
const token = this.getToken();
|
|
213
|
+
const runtimesUrl = this.getRuntimesUrl();
|
|
214
|
+
return runtimes.allowRuntimeMemoryShare(token, source, reader, runtimesUrl);
|
|
215
|
+
}
|
|
216
|
+
/** Stop sharing what `source` remembers of the caller with `reader`. */
|
|
217
|
+
async stopRuntimeMemoryShare(source, reader) {
|
|
218
|
+
const token = this.getToken();
|
|
219
|
+
const runtimesUrl = this.getRuntimesUrl();
|
|
220
|
+
await runtimes.stopRuntimeMemoryShare(token, source, reader, runtimesUrl);
|
|
221
|
+
}
|
|
201
222
|
/**
|
|
202
223
|
* Terminate all runtimes.
|
|
203
224
|
* Lists all runtimes and deletes them in parallel.
|