@datalayer/agent-runtimes 1.3.95 → 1.3.97

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.
Files changed (37) hide show
  1. package/dist-embed/datalayer-app-main.js +6 -6
  2. package/dist-embed/datalayer-app.js +1 -1
  3. package/lib/apps/__tests__/fixtures/sceneCheckCases.json +352 -0
  4. package/lib/apps/apps/sceneChecks.d.ts +92 -0
  5. package/lib/apps/apps/sceneChecks.js +649 -0
  6. package/lib/apps/apps/sceneShape.d.ts +8 -0
  7. package/lib/apps/apps/sceneShape.js +191 -0
  8. package/lib/apps/apps/sceneYaml.d.ts +64 -0
  9. package/lib/apps/apps/sceneYaml.js +253 -0
  10. package/lib/apps/core/canvasParts.d.ts +28 -0
  11. package/lib/apps/core/canvasParts.js +14 -0
  12. package/lib/apps/core/index.d.ts +1 -0
  13. package/lib/apps/core/index.js +2 -0
  14. package/lib/apps/embed/loader.js +10 -0
  15. package/lib/apps/plugins/agents/SandboxSelector.js +13 -2
  16. package/lib/apps/plugins/agents/host.d.ts +2 -0
  17. package/lib/apps/plugins/agents/host.js +16 -0
  18. package/lib/apps/plugins/agents/plugin.js +10 -2
  19. package/lib/apps/plugins/agents/switchable.d.ts +12 -0
  20. package/lib/apps/plugins/agents/switchable.js +28 -0
  21. package/lib/apps/plugins/canvas-parts/index.d.ts +44 -0
  22. package/lib/apps/plugins/canvas-parts/index.js +209 -0
  23. package/lib/chat/base/loopStep.d.ts +2 -1
  24. package/lib/chat/base/loopStep.js +2 -3
  25. package/lib/chat/tools/ToolCallDisplay.js +2 -1
  26. package/lib/hooks/useAgUi.js +4 -1
  27. package/lib/protocols/AGUIAdapter.js +5 -1
  28. package/lib/protocols/agUiRefusal.d.ts +47 -0
  29. package/lib/protocols/agUiRefusal.js +87 -0
  30. package/lib/specs/agents/agents.d.ts +1 -0
  31. package/lib/specs/agents/agents.js +49 -0
  32. package/lib/specs/apps.js +20 -12
  33. package/lib/specs/scenes.js +103 -98
  34. package/lib/specs/teams/teams.js +1 -1
  35. package/package.json +4 -2
  36. package/scripts/dist-embed.mjs +121 -0
  37. package/scripts/record-scene-checks.py +600 -0
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env node
2
+ /*
3
+ * Copyright (c) 2025-2026 Datalayer, Inc.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+
7
+ /**
8
+ * Put `dist-embed/` in a checkout: the embed element's own bundle.
9
+ *
10
+ * `dist-embed/datalayer-app.js` is what a page loads to put an application on
11
+ * someone else's site (LOOP D-08). A release carries it — `npm run build:embed`
12
+ * runs in the release, and the npm package ships the folder — but a workspace
13
+ * checkout has never run it, and the folder is gitignored. The landing's
14
+ * production build refuses to ship without it, because an embed bundle that
15
+ * does not match the runtime it talks to is worse than none:
16
+ *
17
+ * Error: @datalayer/agent-runtimes has no dist-embed/datalayer-app.js …
18
+ * install a release that carries the embed bundle (1.3.93 or later)
19
+ *
20
+ * Two ways to get it, and the right one depends on what you are doing:
21
+ *
22
+ * node scripts/dist-embed.mjs # build it here, from this tree
23
+ * node scripts/dist-embed.mjs --release # take the published one of this
24
+ * # package's own version
25
+ * node scripts/dist-embed.mjs --release 1.3.95 # or of the one named
26
+ *
27
+ * Build it when you changed the embed's own code and want to see it. Take the
28
+ * release when you only need the landing to build: the download is seconds
29
+ * against minutes, and it is byte for byte what the deployed runtime serves.
30
+ * `--force` replaces a folder that is already there; without it, an existing
31
+ * `dist-embed/datalayer-app.js` is left alone and said so.
32
+ *
33
+ * @module scripts/dist-embed
34
+ */
35
+
36
+ import { execFileSync } from 'node:child_process';
37
+ import { existsSync, mkdtempSync, rmSync, cpSync, readFileSync, statSync } from 'node:fs';
38
+ import { tmpdir } from 'node:os';
39
+ import { dirname, join } from 'node:path';
40
+ import { fileURLToPath } from 'node:url';
41
+
42
+ const HERE = dirname(fileURLToPath(import.meta.url));
43
+ const ROOT = join(HERE, '..');
44
+ const OUT = join(ROOT, 'dist-embed');
45
+ const MADE = join(OUT, 'datalayer-app.js');
46
+
47
+ const args = process.argv.slice(2);
48
+ const wants = (name) => args.includes(name);
49
+ /** The value after a flag, when it is not another flag. */
50
+ const after = (name) => {
51
+ const at = args.indexOf(name);
52
+ const value = at < 0 ? '' : String(args[at + 1] ?? '');
53
+ return value.startsWith('-') ? '' : value;
54
+ };
55
+
56
+ const say = (line) => process.stdout.write(`${line}\n`);
57
+
58
+ const ownVersion = () => JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8')).version;
59
+
60
+ /** How big the folder is, in words a person reads. */
61
+ const sizeOf = (path) => {
62
+ const bytes = Number(
63
+ execFileSync('du', ['-sb', path], { encoding: 'utf8' }).split(/\s+/)[0] || 0
64
+ );
65
+ return bytes > 1024 * 1024 ? `${Math.round(bytes / (1024 * 1024))} MB` : `${Math.round(bytes / 1024)} KB`;
66
+ };
67
+
68
+ function fromRelease(version) {
69
+ const named = `@datalayer/agent-runtimes@${version}`;
70
+ say(`Taking the embed bundle of ${named} from npm…`);
71
+ const work = mkdtempSync(join(tmpdir(), 'dist-embed-'));
72
+ try {
73
+ const packed = execFileSync('npm', ['pack', named, '--silent'], {
74
+ cwd: work,
75
+ encoding: 'utf8',
76
+ })
77
+ .trim()
78
+ .split('\n')
79
+ .pop();
80
+ const tarball = join(work, packed);
81
+ if (!existsSync(tarball)) {
82
+ throw new Error(`npm pack wrote no tarball for ${named}`);
83
+ }
84
+ execFileSync('tar', ['xzf', tarball, 'package/dist-embed'], { cwd: work });
85
+ const taken = join(work, 'package', 'dist-embed');
86
+ if (!existsSync(join(taken, 'datalayer-app.js'))) {
87
+ throw new Error(`${named} carries no dist-embed/datalayer-app.js: it predates the embed bundle`);
88
+ }
89
+ rmSync(OUT, { recursive: true, force: true });
90
+ cpSync(taken, OUT, { recursive: true });
91
+ } finally {
92
+ rmSync(work, { recursive: true, force: true });
93
+ }
94
+ }
95
+
96
+ function build() {
97
+ say('Building the embed bundle from this tree (vite.embed.config.ts)…');
98
+ execFileSync('npm', ['run', 'build:embed'], { cwd: ROOT, stdio: 'inherit' });
99
+ }
100
+
101
+ if (existsSync(MADE) && !wants('--force')) {
102
+ say(`dist-embed is already here (${sizeOf(OUT)}): nothing done. Pass --force to replace it.`);
103
+ process.exit(0);
104
+ }
105
+
106
+ try {
107
+ if (wants('--release')) {
108
+ fromRelease(after('--release') || ownVersion());
109
+ } else {
110
+ build();
111
+ }
112
+ } catch (refused) {
113
+ say(`The embed bundle could not be made: ${refused.message}`);
114
+ process.exit(1);
115
+ }
116
+
117
+ if (!existsSync(MADE)) {
118
+ say('The embed bundle was not made: dist-embed/datalayer-app.js is absent.');
119
+ process.exit(1);
120
+ }
121
+ say(`dist-embed is ready: ${sizeOf(OUT)}, ${Math.round(statSync(MADE).size / 1024)} KB of loader.`);