@datalayer/agent-runtimes 1.3.44 → 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.
- package/lib/api/runtimes/runtimes.d.ts +28 -0
- package/lib/api/runtimes/runtimes.js +54 -0
- package/lib/client/AgentRuntimesClient.d.ts +13 -1
- package/lib/client/mixins/RuntimesMixin.d.ts +13 -1
- package/lib/client/mixins/RuntimesMixin.js +21 -0
- package/lib/loop/apps/AppRenderer.d.ts +6 -0
- package/lib/loop/apps/AppRenderer.js +3 -0
- package/lib/loop/apps/checks.d.ts +9 -1
- package/lib/loop/apps/checks.js +25 -5
- package/lib/loop/index.d.ts +1 -1
- package/lib/loop/index.js +1 -1
- package/package.json +1 -1
|
@@ -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.
|
|
@@ -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;
|
package/lib/loop/apps/checks.js
CHANGED
|
@@ -134,8 +134,16 @@ function shapeProblems(app) {
|
|
|
134
134
|
}
|
|
135
135
|
return problems;
|
|
136
136
|
}
|
|
137
|
-
/**
|
|
138
|
-
|
|
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 (!
|
|
149
|
-
|
|
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 = [
|
|
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 = [
|
package/lib/loop/index.d.ts
CHANGED
|
@@ -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';
|