@datalayer/agent-runtimes 1.3.42 → 1.3.44

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.
@@ -135,6 +135,10 @@ export interface RuntimeMemory {
135
135
  scope?: string | null;
136
136
  created_at?: string | null;
137
137
  updated_at?: string | null;
138
+ /** Who corrected it, when it was corrected in place (LOOP R-34). */
139
+ corrected_by?: string | null;
140
+ /** When it was corrected (ISO). */
141
+ corrected_at?: string | null;
138
142
  metadata?: Record<string, unknown>;
139
143
  }
140
144
  /**
@@ -177,6 +181,42 @@ export declare const listRuntimeMemories: (token: string, options?: ListRuntimeM
177
181
  * Fetch one persisted memory by id from the runtimes API.
178
182
  */
179
183
  export declare const getRuntimeMemory: (token: string, memoryId: string, baseUrl?: string) => Promise<GetRuntimeMemoryResponse>;
184
+ /**
185
+ * What forgetting answers: how many memories were forgotten.
186
+ */
187
+ export interface ForgetRuntimeMemoriesResponse {
188
+ success: boolean;
189
+ forgotten: number;
190
+ }
191
+ /**
192
+ * Forget one of the caller's own persisted memories (LOOP R-18).
193
+ *
194
+ * Somebody else's is not found (404), whoever asks: forgetting is the
195
+ * person's own.
196
+ */
197
+ export declare const forgetRuntimeMemory: (token: string, memoryId: string, baseUrl?: string) => Promise<ForgetRuntimeMemoriesResponse>;
198
+ /**
199
+ * What a correction answers: the memory as it is now kept.
200
+ */
201
+ export interface CorrectRuntimeMemoryResponse {
202
+ success: boolean;
203
+ memory: RuntimeMemory;
204
+ }
205
+ /**
206
+ * Correct one of the caller's own persisted memories in place (LOOP R-34):
207
+ * its words become `text`, kept with who corrected it and when.
208
+ *
209
+ * Somebody else's is not found (404), whoever asks; empty words, more than
210
+ * the service keeps, or the words it already has are refused (422).
211
+ */
212
+ export declare const correctRuntimeMemory: (token: string, memoryId: string, text: string, baseUrl?: string) => Promise<CorrectRuntimeMemoryResponse>;
213
+ /**
214
+ * Forget everything one agent — an application, by its key `app:<uid>` —
215
+ * remembers of the caller, no more than `count`: the number the person was
216
+ * shown and confirmed. When it remembers more now, nothing is forgotten and
217
+ * the service refuses (409) in a sentence (LOOP R-18).
218
+ */
219
+ export declare const forgetRuntimeMemories: (token: string, agentId: string, count: number, baseUrl?: string) => Promise<ForgetRuntimeMemoriesResponse>;
180
220
  /**
181
221
  * Resume a paused runtime by restoring from a checkpoint (async).
182
222
  *
@@ -258,6 +258,73 @@ 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
+ * Correct one of the caller's own persisted memories in place (LOOP R-34):
282
+ * its words become `text`, kept with who corrected it and when.
283
+ *
284
+ * Somebody else's is not found (404), whoever asks; empty words, more than
285
+ * the service keeps, or the words it already has are refused (422).
286
+ */
287
+ export const correctRuntimeMemory = async (token, memoryId, text, baseUrl = DEFAULT_SERVICE_URLS.RUNTIMES) => {
288
+ validateToken(token);
289
+ validateRequiredString(memoryId, 'Memory id');
290
+ validateRequiredString(text, 'What it should remember');
291
+ const response = await requestDatalayerAPI({
292
+ url: `${baseUrl}${API_BASE_PATHS.RUNTIMES}/memories/${encodeURIComponent(memoryId)}`,
293
+ method: 'PATCH',
294
+ body: { memory: text },
295
+ token,
296
+ });
297
+ return {
298
+ success: Boolean(response?.success),
299
+ memory: response?.memory,
300
+ };
301
+ };
302
+ /**
303
+ * Forget everything one agent — an application, by its key `app:<uid>` —
304
+ * remembers of the caller, no more than `count`: the number the person was
305
+ * shown and confirmed. When it remembers more now, nothing is forgotten and
306
+ * the service refuses (409) in a sentence (LOOP R-18).
307
+ */
308
+ export const forgetRuntimeMemories = async (token, agentId, count, baseUrl = DEFAULT_SERVICE_URLS.RUNTIMES) => {
309
+ validateToken(token);
310
+ validateRequiredString(agentId, 'Agent id');
311
+ if (!Number.isInteger(count) || count < 0) {
312
+ throw new Error(`Forgetting needs the count confirmed, not ${count}.`);
313
+ }
314
+ const query = new URLSearchParams({
315
+ agent_id: agentId.trim(),
316
+ count: String(count),
317
+ });
318
+ const response = await requestDatalayerAPI({
319
+ url: `${baseUrl}${API_BASE_PATHS.RUNTIMES}/memories?${query.toString()}`,
320
+ method: 'DELETE',
321
+ token,
322
+ });
323
+ return {
324
+ success: Boolean(response?.success),
325
+ forgotten: Number(response?.forgotten ?? 0),
326
+ };
327
+ };
261
328
  /**
262
329
  * Resume a paused runtime by restoring from a checkpoint (async).
263
330
  *
@@ -58,6 +58,9 @@ 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
+ correctRuntimeMemory(memoryId: string, text: string): Promise<RuntimeMemory>;
63
+ forgetRuntimeMemories(agentId: string, count: number): Promise<number>;
61
64
  terminateAllRuntimes(): Promise<PromiseSettledResult<void>[]>;
62
65
  createSnapshot(runtimeName: string, name: string, description: string, stop?: boolean): Promise<CodeSandboxSnapshotDTO>;
63
66
  listSnapshots(): Promise<CodeSandboxSnapshotDTO[]>;
@@ -92,6 +95,9 @@ export interface AgentRuntimesClient extends DatalayerCoreClient {
92
95
  listRuntimes(): Promise<RuntimeDTO[]>;
93
96
  listRuntimeMemories(options?: ListRuntimeMemoriesOptions): Promise<RuntimeMemory[]>;
94
97
  getRuntimeMemory(memoryId: string): Promise<RuntimeMemory>;
98
+ forgetRuntimeMemory(memoryId: string): Promise<number>;
99
+ correctRuntimeMemory(memoryId: string, text: string): Promise<RuntimeMemory>;
100
+ forgetRuntimeMemories(agentId: string, count: number): Promise<number>;
95
101
  getRuntime(runtimeName: string): Promise<RuntimeDTO>;
96
102
  deleteRuntime(runtimeName: string): Promise<void>;
97
103
  terminateAllRuntimes(): Promise<PromiseSettledResult<void>[]>;
@@ -92,6 +92,20 @@ 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
+ * Correct one of the caller's own memories in place (LOOP R-34): its
101
+ * words become `text`, kept with who corrected it and when.
102
+ */
103
+ correctRuntimeMemory(memoryId: string, text: string): Promise<RuntimeMemory>;
104
+ /**
105
+ * Forget everything an agent or application (`app:<uid>`) remembers of
106
+ * the caller, no more than the `count` confirmed.
107
+ */
108
+ forgetRuntimeMemories(agentId: string, count: number): Promise<number>;
95
109
  /**
96
110
  * Terminate all runtimes.
97
111
  * Lists all runtimes and deletes them in parallel.
@@ -169,6 +169,35 @@ 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
+ * Correct one of the caller's own memories in place (LOOP R-34): its
183
+ * words become `text`, kept with who corrected it and when.
184
+ */
185
+ async correctRuntimeMemory(memoryId, text) {
186
+ const token = this.getToken();
187
+ const runtimesUrl = this.getRuntimesUrl();
188
+ const response = await runtimes.correctRuntimeMemory(token, memoryId, text, runtimesUrl);
189
+ return response.memory;
190
+ }
191
+ /**
192
+ * Forget everything an agent or application (`app:<uid>`) remembers of
193
+ * the caller, no more than the `count` confirmed.
194
+ */
195
+ async forgetRuntimeMemories(agentId, count) {
196
+ const token = this.getToken();
197
+ const runtimesUrl = this.getRuntimesUrl();
198
+ const response = await runtimes.forgetRuntimeMemories(token, agentId, count, runtimesUrl);
199
+ return response.forgotten;
200
+ }
172
201
  /**
173
202
  * Terminate all runtimes.
174
203
  * 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.44",
4
4
  "type": "module",
5
5
  "workspaces": [
6
6
  ".",