@datalayer/agent-runtimes 1.3.43 → 1.3.45

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
  /**
@@ -191,6 +195,21 @@ export interface ForgetRuntimeMemoriesResponse {
191
195
  * person's own.
192
196
  */
193
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>;
194
213
  /**
195
214
  * Forget everything one agent — an application, by its key `app:<uid>` —
196
215
  * remembers of the caller, no more than `count`: the number the person was
@@ -277,6 +277,28 @@ export const forgetRuntimeMemory = async (token, memoryId, baseUrl = DEFAULT_SER
277
277
  forgotten: Number(response?.forgotten ?? 0),
278
278
  };
279
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
+ };
280
302
  /**
281
303
  * Forget everything one agent — an application, by its key `app:<uid>` —
282
304
  * remembers of the caller, no more than `count`: the number the person was
@@ -59,6 +59,7 @@ declare const AgentRuntimesClientWithMixins: {
59
59
  listRuntimeMemories(options?: ListRuntimeMemoriesOptions): Promise<RuntimeMemory[]>;
60
60
  getRuntimeMemory(memoryId: string): Promise<RuntimeMemory>;
61
61
  forgetRuntimeMemory(memoryId: string): Promise<number>;
62
+ correctRuntimeMemory(memoryId: string, text: string): Promise<RuntimeMemory>;
62
63
  forgetRuntimeMemories(agentId: string, count: number): Promise<number>;
63
64
  terminateAllRuntimes(): Promise<PromiseSettledResult<void>[]>;
64
65
  createSnapshot(runtimeName: string, name: string, description: string, stop?: boolean): Promise<CodeSandboxSnapshotDTO>;
@@ -95,6 +96,7 @@ export interface AgentRuntimesClient extends DatalayerCoreClient {
95
96
  listRuntimeMemories(options?: ListRuntimeMemoriesOptions): Promise<RuntimeMemory[]>;
96
97
  getRuntimeMemory(memoryId: string): Promise<RuntimeMemory>;
97
98
  forgetRuntimeMemory(memoryId: string): Promise<number>;
99
+ correctRuntimeMemory(memoryId: string, text: string): Promise<RuntimeMemory>;
98
100
  forgetRuntimeMemories(agentId: string, count: number): Promise<number>;
99
101
  getRuntime(runtimeName: string): Promise<RuntimeDTO>;
100
102
  deleteRuntime(runtimeName: string): Promise<void>;
@@ -96,6 +96,11 @@ export declare function RuntimesMixin<TBase extends Constructor>(Base: TBase): {
96
96
  * Forget one of the caller's own memories; answers how many were forgotten.
97
97
  */
98
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>;
99
104
  /**
100
105
  * Forget everything an agent or application (`app:<uid>`) remembers of
101
106
  * the caller, no more than the `count` confirmed.
@@ -178,6 +178,16 @@ export function RuntimesMixin(Base) {
178
178
  const response = await runtimes.forgetRuntimeMemory(token, memoryId, runtimesUrl);
179
179
  return response.forgotten;
180
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
+ }
181
191
  /**
182
192
  * Forget everything an agent or application (`app:<uid>`) remembers of
183
193
  * the caller, no more than the `count` confirmed.
@@ -71,6 +71,12 @@ export type AppInstance = {
71
71
  deploymentUid?: string;
72
72
  /** The version that runs. */
73
73
  version?: number;
74
+ /**
75
+ * The organization it belongs to: its agent keeps to that organization's
76
+ * contexts, read by the runtime from IAM (LOOP U-31); unsaid for an
77
+ * application of nobody's organization.
78
+ */
79
+ organizationUid?: string;
74
80
  };
75
81
  export type AppRendererProps = Omit<LoopEmbedProps, 'agentId'> & {
76
82
  /** The application to render. */
@@ -212,6 +212,9 @@ export function appDatalayerCreatePayload(app, instance) {
212
212
  app_uid: instance.appUid ?? '',
213
213
  deployment_uid: instance.deploymentUid ?? '',
214
214
  version: instance.version ?? 0,
215
+ ...(instance.organizationUid
216
+ ? { organization_uid: instance.organizationUid }
217
+ : {}),
215
218
  },
216
219
  }
217
220
  : {}),
@@ -14,15 +14,23 @@ export interface AppCheck {
14
14
  * UI plugins, by the name a surface gives it.
15
15
  */
16
16
  export declare const componentNamed: (name: string) => ComponentSpec | undefined;
17
+ /** How an organization's own context is named: never a catalogue id (agentspecs' `ORGANIZATION_FRAME_PREFIX`). */
18
+ export declare const ORGANIZATION_FRAME_PREFIX = "org-";
19
+ /** Whether a reference names an organization's own context rather than the catalogue's (LOOP U-32). */
20
+ export declare const isOrganizationFrame: (ref: string) => boolean;
17
21
  /** The Guards the runtime executes (agent-runtimes `loop/apps/guards.py`). */
18
22
  export declare const EXECUTED_GUARDS: readonly string[];
19
23
  /**
20
24
  * Where an application is checked: the plugins its organization has turned
21
25
  * off (catalogue ids, `plugins_off` in IAM), none when it has decided nothing
22
- * or the checks run with no organization.
26
+ * or the checks run with no organization; and the ids of its organization's
27
+ * contexts (`frames` in IAM: its versions and its own, LOOP U-32), unsaid
28
+ * when no organization is known — a context of an organization's own is then
29
+ * refused.
23
30
  */
24
31
  export interface CheckContext {
25
32
  pluginsOff: readonly string[];
33
+ organizationFrames?: readonly string[];
26
34
  }
27
35
  /** The instant checks of an application as an editor holds it. */
28
36
  export declare function checkApp(app: AppSpec, read?: string[], context?: CheckContext): AppCheck;
@@ -134,8 +134,16 @@ function shapeProblems(app) {
134
134
  }
135
135
  return problems;
136
136
  }
137
- /** Every reference that does not resolve, in sentences. */
138
- function referenceProblems(app) {
137
+ /** How an organization's own context is named: never a catalogue id (agentspecs' `ORGANIZATION_FRAME_PREFIX`). */
138
+ export const ORGANIZATION_FRAME_PREFIX = 'org-';
139
+ /** Whether a reference names an organization's own context rather than the catalogue's (LOOP U-32). */
140
+ export const isOrganizationFrame = (ref) => idOf(ref).startsWith(ORGANIZATION_FRAME_PREFIX);
141
+ /**
142
+ * Every reference that does not resolve, in sentences. A context of an
143
+ * organization's own resolves among `organizationFrames`, the contexts of the
144
+ * organization the application belongs to; with none known, it is refused.
145
+ */
146
+ function referenceProblems(app, organizationFrames) {
139
147
  const problems = [];
140
148
  const missing = (what, ref) => problems.push(`There is no ${what} named “${ref}”.`);
141
149
  if (app.agent && !getAgentspecs(idOf(app.agent)) && !getCog(app.agent)) {
@@ -145,8 +153,16 @@ function referenceProblems(app) {
145
153
  missing('team', app.team);
146
154
  }
147
155
  for (const ref of app.context) {
148
- if (!getFrame(idOf(ref)))
149
- missing('Frame', ref);
156
+ if (!isOrganizationFrame(ref)) {
157
+ if (!getFrame(idOf(ref)))
158
+ missing('Frame', ref);
159
+ }
160
+ else if (organizationFrames === undefined) {
161
+ problems.push(`“${ref}” is a context of an organization’s own: it is checked with the organization the application belongs to, which was not said.`);
162
+ }
163
+ else if (!organizationFrames.includes(idOf(ref))) {
164
+ problems.push(`Its organization has no context named “${ref}”.`);
165
+ }
150
166
  }
151
167
  for (const connection of app.connections) {
152
168
  if (!own(MCP_SERVER_LIBRARY, idOf(connection.server))) {
@@ -340,7 +356,11 @@ function setupNotes(app) {
340
356
  const NO_ORGANIZATION = { pluginsOff: [] };
341
357
  /** The instant checks of an application as an editor holds it. */
342
358
  export function checkApp(app, read = [], context = NO_ORGANIZATION) {
343
- const problems = [...read, ...shapeProblems(app), ...referenceProblems(app)];
359
+ const problems = [
360
+ ...read,
361
+ ...shapeProblems(app),
362
+ ...referenceProblems(app, context.organizationFrames),
363
+ ];
344
364
  // A block its page uses from a plugin its organization turned off is said
345
365
  // with the rest of what is not enabled today (C-12).
346
366
  const setup = [
@@ -72,4 +72,4 @@ export { EMBED_ATTRIBUTES, EMBED_HOST_VARIABLES, EMBED_TAG, embedLookOf, embedSn
72
72
  export { SubagentActivityPlugin, SubagentPulse, SUBAGENT_ACTIVITY_PLUGIN_NAME, } from './plugins/subagent-activity';
73
73
  export { loopPlugins, type LoopPresetOptions } from './presets';
74
74
  export { DocumentExtension, NotebookExtension } from './extensions';
75
- export { BEHAVIOURS as APP_BEHAVIOUR_ORDER, DEFAULT_BEHAVIOURS as APP_DEFAULT_BEHAVIOURS, behaviourFor, classesOf, isReadOnly, toolBehaviours, toolEscalations, type BehaviourOptions, type ToolArguments, APP_SCHEMA, APPSPEC_KEY_ORDER, DEFAULT_LAYOUTS as APP_DEFAULT_LAYOUTS, dumpAppspec, emptyAppspec, parseAppspec, AppRenderer, checkApp, checkAppspec, type AppCheck, type CheckContext, defineAppPlugin, type AppRendererProps, type AppInstance, appLayoutOptions, readAppspecYaml, writeAppspecYaml, type ParsedAppspec, } from './apps';
75
+ export { BEHAVIOURS as APP_BEHAVIOUR_ORDER, DEFAULT_BEHAVIOURS as APP_DEFAULT_BEHAVIOURS, behaviourFor, classesOf, isReadOnly, toolBehaviours, toolEscalations, type BehaviourOptions, type ToolArguments, APP_SCHEMA, APPSPEC_KEY_ORDER, DEFAULT_LAYOUTS as APP_DEFAULT_LAYOUTS, dumpAppspec, emptyAppspec, parseAppspec, AppRenderer, checkApp, checkAppspec, isOrganizationFrame, ORGANIZATION_FRAME_PREFIX, type AppCheck, type CheckContext, defineAppPlugin, type AppRendererProps, type AppInstance, appLayoutOptions, readAppspecYaml, writeAppspecYaml, type ParsedAppspec, } from './apps';
package/lib/loop/index.js CHANGED
@@ -98,4 +98,4 @@ export { loopPlugins } from './presets';
98
98
  export { DocumentExtension, NotebookExtension } from './extensions';
99
99
  // Applications: what one does when its agent calls a tool — the rules a
100
100
  // person wrote, decided on what the tool does.
101
- export { BEHAVIOURS as APP_BEHAVIOUR_ORDER, DEFAULT_BEHAVIOURS as APP_DEFAULT_BEHAVIOURS, behaviourFor, classesOf, isReadOnly, toolBehaviours, toolEscalations, APP_SCHEMA, APPSPEC_KEY_ORDER, DEFAULT_LAYOUTS as APP_DEFAULT_LAYOUTS, dumpAppspec, emptyAppspec, parseAppspec, AppRenderer, checkApp, checkAppspec, defineAppPlugin, appLayoutOptions, readAppspecYaml, writeAppspecYaml, } from './apps';
101
+ export { BEHAVIOURS as APP_BEHAVIOUR_ORDER, DEFAULT_BEHAVIOURS as APP_DEFAULT_BEHAVIOURS, behaviourFor, classesOf, isReadOnly, toolBehaviours, toolEscalations, APP_SCHEMA, APPSPEC_KEY_ORDER, DEFAULT_LAYOUTS as APP_DEFAULT_LAYOUTS, dumpAppspec, emptyAppspec, parseAppspec, AppRenderer, checkApp, checkAppspec, isOrganizationFrame, ORGANIZATION_FRAME_PREFIX, defineAppPlugin, appLayoutOptions, readAppspecYaml, writeAppspecYaml, } from './apps';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datalayer/agent-runtimes",
3
- "version": "1.3.43",
3
+ "version": "1.3.45",
4
4
  "type": "module",
5
5
  "workspaces": [
6
6
  ".",