@datalayer/agent-runtimes 1.3.42 → 1.3.43

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.
@@ -177,6 +177,27 @@ export declare const listRuntimeMemories: (token: string, options?: ListRuntimeM
177
177
  * Fetch one persisted memory by id from the runtimes API.
178
178
  */
179
179
  export declare const getRuntimeMemory: (token: string, memoryId: string, baseUrl?: string) => Promise<GetRuntimeMemoryResponse>;
180
+ /**
181
+ * What forgetting answers: how many memories were forgotten.
182
+ */
183
+ export interface ForgetRuntimeMemoriesResponse {
184
+ success: boolean;
185
+ forgotten: number;
186
+ }
187
+ /**
188
+ * Forget one of the caller's own persisted memories (LOOP R-18).
189
+ *
190
+ * Somebody else's is not found (404), whoever asks: forgetting is the
191
+ * person's own.
192
+ */
193
+ export declare const forgetRuntimeMemory: (token: string, memoryId: string, baseUrl?: string) => Promise<ForgetRuntimeMemoriesResponse>;
194
+ /**
195
+ * Forget everything one agent — an application, by its key `app:<uid>` —
196
+ * remembers of the caller, no more than `count`: the number the person was
197
+ * shown and confirmed. When it remembers more now, nothing is forgotten and
198
+ * the service refuses (409) in a sentence (LOOP R-18).
199
+ */
200
+ export declare const forgetRuntimeMemories: (token: string, agentId: string, count: number, baseUrl?: string) => Promise<ForgetRuntimeMemoriesResponse>;
180
201
  /**
181
202
  * Resume a paused runtime by restoring from a checkpoint (async).
182
203
  *
@@ -258,6 +258,51 @@ export const getRuntimeMemory = async (token, memoryId, baseUrl = DEFAULT_SERVIC
258
258
  memory: response?.memory,
259
259
  };
260
260
  };
261
+ /**
262
+ * Forget one of the caller's own persisted memories (LOOP R-18).
263
+ *
264
+ * Somebody else's is not found (404), whoever asks: forgetting is the
265
+ * person's own.
266
+ */
267
+ export const forgetRuntimeMemory = async (token, memoryId, baseUrl = DEFAULT_SERVICE_URLS.RUNTIMES) => {
268
+ validateToken(token);
269
+ validateRequiredString(memoryId, 'Memory id');
270
+ const response = await requestDatalayerAPI({
271
+ url: `${baseUrl}${API_BASE_PATHS.RUNTIMES}/memories/${encodeURIComponent(memoryId)}`,
272
+ method: 'DELETE',
273
+ token,
274
+ });
275
+ return {
276
+ success: Boolean(response?.success),
277
+ forgotten: Number(response?.forgotten ?? 0),
278
+ };
279
+ };
280
+ /**
281
+ * Forget everything one agent — an application, by its key `app:<uid>` —
282
+ * remembers of the caller, no more than `count`: the number the person was
283
+ * shown and confirmed. When it remembers more now, nothing is forgotten and
284
+ * the service refuses (409) in a sentence (LOOP R-18).
285
+ */
286
+ export const forgetRuntimeMemories = async (token, agentId, count, baseUrl = DEFAULT_SERVICE_URLS.RUNTIMES) => {
287
+ validateToken(token);
288
+ validateRequiredString(agentId, 'Agent id');
289
+ if (!Number.isInteger(count) || count < 0) {
290
+ throw new Error(`Forgetting needs the count confirmed, not ${count}.`);
291
+ }
292
+ const query = new URLSearchParams({
293
+ agent_id: agentId.trim(),
294
+ count: String(count),
295
+ });
296
+ const response = await requestDatalayerAPI({
297
+ url: `${baseUrl}${API_BASE_PATHS.RUNTIMES}/memories?${query.toString()}`,
298
+ method: 'DELETE',
299
+ token,
300
+ });
301
+ return {
302
+ success: Boolean(response?.success),
303
+ forgotten: Number(response?.forgotten ?? 0),
304
+ };
305
+ };
261
306
  /**
262
307
  * Resume a paused runtime by restoring from a checkpoint (async).
263
308
  *
@@ -58,6 +58,8 @@ declare const AgentRuntimesClientWithMixins: {
58
58
  deleteRuntime(runtimeName: string): Promise<void>;
59
59
  listRuntimeMemories(options?: ListRuntimeMemoriesOptions): Promise<RuntimeMemory[]>;
60
60
  getRuntimeMemory(memoryId: string): Promise<RuntimeMemory>;
61
+ forgetRuntimeMemory(memoryId: string): Promise<number>;
62
+ forgetRuntimeMemories(agentId: string, count: number): Promise<number>;
61
63
  terminateAllRuntimes(): Promise<PromiseSettledResult<void>[]>;
62
64
  createSnapshot(runtimeName: string, name: string, description: string, stop?: boolean): Promise<CodeSandboxSnapshotDTO>;
63
65
  listSnapshots(): Promise<CodeSandboxSnapshotDTO[]>;
@@ -92,6 +94,8 @@ export interface AgentRuntimesClient extends DatalayerCoreClient {
92
94
  listRuntimes(): Promise<RuntimeDTO[]>;
93
95
  listRuntimeMemories(options?: ListRuntimeMemoriesOptions): Promise<RuntimeMemory[]>;
94
96
  getRuntimeMemory(memoryId: string): Promise<RuntimeMemory>;
97
+ forgetRuntimeMemory(memoryId: string): Promise<number>;
98
+ forgetRuntimeMemories(agentId: string, count: number): Promise<number>;
95
99
  getRuntime(runtimeName: string): Promise<RuntimeDTO>;
96
100
  deleteRuntime(runtimeName: string): Promise<void>;
97
101
  terminateAllRuntimes(): Promise<PromiseSettledResult<void>[]>;
@@ -92,6 +92,15 @@ export declare function RuntimesMixin<TBase extends Constructor>(Base: TBase): {
92
92
  * Fetch one persisted memory by id.
93
93
  */
94
94
  getRuntimeMemory(memoryId: string): Promise<RuntimeMemory>;
95
+ /**
96
+ * Forget one of the caller's own memories; answers how many were forgotten.
97
+ */
98
+ forgetRuntimeMemory(memoryId: string): Promise<number>;
99
+ /**
100
+ * Forget everything an agent or application (`app:<uid>`) remembers of
101
+ * the caller, no more than the `count` confirmed.
102
+ */
103
+ forgetRuntimeMemories(agentId: string, count: number): Promise<number>;
95
104
  /**
96
105
  * Terminate all runtimes.
97
106
  * Lists all runtimes and deletes them in parallel.
@@ -169,6 +169,25 @@ export function RuntimesMixin(Base) {
169
169
  const response = await runtimes.getRuntimeMemory(token, memoryId, runtimesUrl);
170
170
  return response.memory;
171
171
  }
172
+ /**
173
+ * Forget one of the caller's own memories; answers how many were forgotten.
174
+ */
175
+ async forgetRuntimeMemory(memoryId) {
176
+ const token = this.getToken();
177
+ const runtimesUrl = this.getRuntimesUrl();
178
+ const response = await runtimes.forgetRuntimeMemory(token, memoryId, runtimesUrl);
179
+ return response.forgotten;
180
+ }
181
+ /**
182
+ * Forget everything an agent or application (`app:<uid>`) remembers of
183
+ * the caller, no more than the `count` confirmed.
184
+ */
185
+ async forgetRuntimeMemories(agentId, count) {
186
+ const token = this.getToken();
187
+ const runtimesUrl = this.getRuntimesUrl();
188
+ const response = await runtimes.forgetRuntimeMemories(token, agentId, count, runtimesUrl);
189
+ return response.forgotten;
190
+ }
172
191
  /**
173
192
  * Terminate all runtimes.
174
193
  * Lists all runtimes and deletes them in parallel.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/agent-runtimes",
3
- "version": "1.3.42",
3
+ "version": "1.3.43",
4
4
  "type": "module",
5
5
  "workspaces": [
6
6
  ".",