@dotcms/ai 26.10.20-1 → 26.10.21-1

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 (72) hide show
  1. package/README.md +203 -29
  2. package/adapter.cjs.default.js +1 -0
  3. package/adapter.cjs.js +14 -0
  4. package/adapter.cjs.mjs +2 -0
  5. package/adapter.cjs2.js +0 -0
  6. package/adapter.d.ts +1 -0
  7. package/adapter.esm.js +2 -0
  8. package/adapter.esm2.js +0 -0
  9. package/errors.cjs.js +192 -0
  10. package/errors.esm.js +180 -0
  11. package/format-result.cjs.js +833 -0
  12. package/format-result.esm.js +825 -0
  13. package/package.json +25 -20
  14. package/runtime.cjs.js +0 -0
  15. package/runtime.esm.js +0 -0
  16. package/sandbox.cjs.default.js +1 -0
  17. package/sandbox.cjs.js +69 -0
  18. package/sandbox.cjs.mjs +2 -0
  19. package/sandbox.d.ts +1 -0
  20. package/sandbox.esm.js +50 -0
  21. package/spec.cjs.default.js +1 -0
  22. package/spec.cjs.js +3 -23912
  23. package/spec.cjs.mjs +2 -0
  24. package/spec.cjs2.js +23916 -0
  25. package/spec.d.ts +1 -0
  26. package/spec.esm.js +1 -23914
  27. package/spec.esm2.js +23914 -0
  28. package/src/adapter/context.d.ts +11 -0
  29. package/src/adapter/request-core.d.ts +30 -0
  30. package/src/adapter.d.ts +1 -0
  31. package/src/runtime.d.ts +5 -4
  32. package/src/sandbox/errors.d.ts +23 -1
  33. package/src/sandbox/index.d.ts +1 -1
  34. package/src/sandbox.d.ts +1 -0
  35. package/src/spec.d.ts +1 -0
  36. package/src/tools/definitions/download-assets.d.ts +27 -0
  37. package/src/tools/definitions/execute.d.ts +15 -0
  38. package/src/tools/definitions/page-create.d.ts +23 -0
  39. package/src/tools/definitions/page-place-content.d.ts +32 -0
  40. package/src/tools/definitions/page-verify.d.ts +20 -0
  41. package/src/tools/definitions/search.d.ts +13 -0
  42. package/src/tools/definitions/upload-assets.d.ts +23 -0
  43. package/src/tools/index.d.ts +40 -0
  44. package/src/tools/operations/download-assets.d.ts +55 -0
  45. package/src/tools/operations/page-create.d.ts +81 -0
  46. package/src/tools/operations/page-place-content.d.ts +102 -0
  47. package/src/tools/operations/page-verify.d.ts +164 -0
  48. package/src/tools/operations/shared/asset-common.d.ts +28 -0
  49. package/src/tools/operations/shared/glob.d.ts +22 -0
  50. package/src/tools/operations/shared/local-root.d.ts +11 -0
  51. package/src/tools/operations/shared/page-common.d.ts +45 -0
  52. package/src/tools/operations/shared/page-path.d.ts +49 -0
  53. package/src/tools/operations/shared/resolve.d.ts +43 -0
  54. package/src/tools/operations/upload-assets.d.ts +64 -0
  55. package/src/tools/toolkit/connection.d.ts +56 -0
  56. package/src/tools/toolkit/create-tool.d.ts +66 -0
  57. package/src/tools/toolkit/endpoints.d.ts +52 -0
  58. package/src/tools/toolkit/lenient-boolean.d.ts +14 -0
  59. package/src/tools/toolkit/results.d.ts +32 -0
  60. package/src/tools/toolkit/tool-runtime.d.ts +108 -0
  61. package/src/tools/toolkit/types.d.ts +120 -0
  62. package/src/tools.d.ts +1 -0
  63. package/tools.cjs.default.js +1 -0
  64. package/tools.cjs.js +3850 -0
  65. package/tools.cjs.mjs +2 -0
  66. package/tools.d.ts +1 -0
  67. package/tools.esm.js +3817 -0
  68. package/index.cjs.default.js +0 -1
  69. package/index.cjs.js +0 -7
  70. package/index.cjs.mjs +0 -2
  71. package/index.d.ts +0 -1
  72. package/index.esm.js +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dotcms/ai",
3
- "version": "26.10.20-1",
3
+ "version": "26.10.21-1",
4
4
  "description": "The dotCMS agentic runtime — run model-written or human-written code safely against a dotCMS instance, with auth and policy owned in one place.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -8,6 +8,7 @@
8
8
  "directory": "core-web/libs/sdk/ai"
9
9
  },
10
10
  "dependencies": {
11
+ "@dotcms/types": "26.10.21-1",
11
12
  "tslib": "^2.3.0",
12
13
  "zod": "^4.1.9"
13
14
  },
@@ -23,34 +24,34 @@
23
24
  "default": "./runtime.cjs.js"
24
25
  },
25
26
  "./sandbox": {
26
- "module": "./runtime.esm.js",
27
- "types": "./src/sandbox/index.d.ts",
28
- "import": "./runtime.cjs.mjs",
29
- "default": "./runtime.cjs.js"
27
+ "module": "./sandbox.esm.js",
28
+ "types": "./sandbox.d.ts",
29
+ "import": "./sandbox.cjs.mjs",
30
+ "default": "./sandbox.cjs.js"
30
31
  },
31
32
  "./adapter": {
32
- "module": "./runtime.esm.js",
33
- "types": "./src/adapter/index.d.ts",
34
- "import": "./runtime.cjs.mjs",
35
- "default": "./runtime.cjs.js"
33
+ "module": "./adapter.esm.js",
34
+ "types": "./adapter.d.ts",
35
+ "import": "./adapter.cjs.mjs",
36
+ "default": "./adapter.cjs.js"
36
37
  },
37
38
  "./spec": {
38
39
  "module": "./spec.esm.js",
39
- "types": "./src/spec/index.d.ts",
40
- "import": "./spec.cjs.js",
40
+ "types": "./spec.d.ts",
41
+ "import": "./spec.cjs.mjs",
41
42
  "default": "./spec.cjs.js"
42
43
  },
44
+ "./tools": {
45
+ "module": "./tools.esm.js",
46
+ "types": "./tools.d.ts",
47
+ "import": "./tools.cjs.mjs",
48
+ "default": "./tools.cjs.js"
49
+ },
43
50
  ".": {
44
51
  "module": "./runtime.esm.js",
45
52
  "types": "./runtime.d.ts",
46
53
  "import": "./runtime.cjs.mjs",
47
54
  "default": "./runtime.cjs.js"
48
- },
49
- "./index": {
50
- "module": "./index.esm.js",
51
- "types": "./index.d.ts",
52
- "import": "./index.cjs.mjs",
53
- "default": "./index.cjs.js"
54
55
  }
55
56
  },
56
57
  "typesVersions": {
@@ -59,13 +60,16 @@
59
60
  "./runtime.d.ts"
60
61
  ],
61
62
  "sandbox": [
62
- "./src/sandbox/index.d.ts"
63
+ "./sandbox.d.ts"
63
64
  ],
64
65
  "adapter": [
65
- "./src/adapter/index.d.ts"
66
+ "./adapter.d.ts"
66
67
  ],
67
68
  "spec": [
68
- "./src/spec/index.d.ts"
69
+ "./spec.d.ts"
70
+ ],
71
+ "tools": [
72
+ "./tools.d.ts"
69
73
  ]
70
74
  }
71
75
  },
@@ -77,6 +81,7 @@
77
81
  "agentic",
78
82
  "runtime",
79
83
  "sandbox",
84
+ "tools",
80
85
  "MCP",
81
86
  "model-context-protocol"
82
87
  ],
package/runtime.cjs.js CHANGED
Binary file
package/runtime.esm.js CHANGED
Binary file
@@ -0,0 +1 @@
1
+ exports._default = require('./sandbox.cjs.js').default;
package/sandbox.cjs.js ADDED
@@ -0,0 +1,69 @@
1
+ 'use strict';
2
+
3
+ var formatResult = require('./format-result.cjs.js');
4
+ require('node:worker_threads');
5
+ var errors = require('./errors.cjs.js');
6
+ require('zod');
7
+
8
+ /**
9
+ * `@dotcms/ai/sandbox` — the generic execution engine. ZERO dotCMS code lives here (a
10
+ * lint-enforced module boundary); this subpath is fully generic. The dotCMS wiring lives in
11
+ * `@dotcms/ai/adapter`, and the front door that combines them in `@dotcms/ai`.
12
+ */
13
+ /**
14
+ * Create a sandbox over a set of adapters — the generic entry point.
15
+ *
16
+ * `defineAdapter` results are bound to the injected host `request` (and a per-run abort
17
+ * signal) via `withContext`; plain hand-built adapters are passed through untouched. Each
18
+ * `run()` gets its own `AbortController`, so a timeout aborts in-flight host work.
19
+ */
20
+ function createSandbox(config) {
21
+ return {
22
+ async run(code) {
23
+ const controller = new AbortController();
24
+ const ctx = {
25
+ request: config.request ?? notProvided,
26
+ signal: controller.signal
27
+ };
28
+ const adapters = config.adapters.map((a) => formatResult.isDefinedAdapter(a) ? a.withContext(ctx) : a);
29
+ const executor = new formatResult.Executor({
30
+ config: {
31
+ adapters,
32
+ sandbox: {
33
+ timeout: config.timeout,
34
+ globals: config.globals,
35
+ resourceLimits: config.resourceLimits,
36
+ onTeardown: () => controller.abort()
37
+ }
38
+ }
39
+ });
40
+ return executor.execute(code, {
41
+ adapters: adapters.map((a) => a.name)
42
+ });
43
+ }
44
+ };
45
+ }
46
+ const notProvided = () => {
47
+ throw new Error('This adapter needs a host `request` capability. Pass `request` to createSandbox(), ' +
48
+ 'or use createRuntime() from "@dotcms/ai/runtime" which provides one.');
49
+ };
50
+
51
+ exports.Executor = formatResult.Executor;
52
+ exports.createExecutor = formatResult.createExecutor;
53
+ exports.createWorkerSandbox = formatResult.createWorkerSandbox;
54
+ exports.defineAdapter = formatResult.defineAdapter;
55
+ exports.describeAdapterForLLM = formatResult.describeAdapterForLLM;
56
+ exports.formatSandboxResult = formatResult.formatSandboxResult;
57
+ exports.isDefinedAdapter = formatResult.isDefinedAdapter;
58
+ exports.AbortError = errors.AbortError;
59
+ exports.DotCMSError = errors.DotCMSError;
60
+ exports.HttpError = errors.HttpError;
61
+ exports.NetworkError = errors.NetworkError;
62
+ exports.PolicyError = errors.PolicyError;
63
+ exports.RuntimeError = errors.RuntimeError;
64
+ exports.SandboxError = errors.SandboxError;
65
+ exports.TimeoutError = errors.TimeoutError;
66
+ exports.ValidationError = errors.ValidationError;
67
+ exports.isDotCMSError = errors.isDotCMSError;
68
+ exports.serializeError = errors.serializeError;
69
+ exports.createSandbox = createSandbox;
@@ -0,0 +1,2 @@
1
+ export * from './sandbox.cjs.js';
2
+ export { _default as default } from './sandbox.cjs.default.js';
package/sandbox.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from "./src/sandbox";
package/sandbox.esm.js ADDED
@@ -0,0 +1,50 @@
1
+ import { i as isDefinedAdapter, E as Executor } from './format-result.esm.js';
2
+ export { c as createExecutor, a as createWorkerSandbox, d as defineAdapter, b as describeAdapterForLLM, f as formatSandboxResult } from './format-result.esm.js';
3
+ import 'node:worker_threads';
4
+ export { A as AbortError, D as DotCMSError, H as HttpError, N as NetworkError, P as PolicyError, R as RuntimeError, S as SandboxError, T as TimeoutError, V as ValidationError, i as isDotCMSError, s as serializeError } from './errors.esm.js';
5
+ import 'zod';
6
+
7
+ /**
8
+ * `@dotcms/ai/sandbox` — the generic execution engine. ZERO dotCMS code lives here (a
9
+ * lint-enforced module boundary); this subpath is fully generic. The dotCMS wiring lives in
10
+ * `@dotcms/ai/adapter`, and the front door that combines them in `@dotcms/ai`.
11
+ */
12
+ /**
13
+ * Create a sandbox over a set of adapters — the generic entry point.
14
+ *
15
+ * `defineAdapter` results are bound to the injected host `request` (and a per-run abort
16
+ * signal) via `withContext`; plain hand-built adapters are passed through untouched. Each
17
+ * `run()` gets its own `AbortController`, so a timeout aborts in-flight host work.
18
+ */
19
+ function createSandbox(config) {
20
+ return {
21
+ async run(code) {
22
+ const controller = new AbortController();
23
+ const ctx = {
24
+ request: config.request ?? notProvided,
25
+ signal: controller.signal
26
+ };
27
+ const adapters = config.adapters.map((a) => isDefinedAdapter(a) ? a.withContext(ctx) : a);
28
+ const executor = new Executor({
29
+ config: {
30
+ adapters,
31
+ sandbox: {
32
+ timeout: config.timeout,
33
+ globals: config.globals,
34
+ resourceLimits: config.resourceLimits,
35
+ onTeardown: () => controller.abort()
36
+ }
37
+ }
38
+ });
39
+ return executor.execute(code, {
40
+ adapters: adapters.map((a) => a.name)
41
+ });
42
+ }
43
+ };
44
+ }
45
+ const notProvided = () => {
46
+ throw new Error('This adapter needs a host `request` capability. Pass `request` to createSandbox(), ' +
47
+ 'or use createRuntime() from "@dotcms/ai/runtime" which provides one.');
48
+ };
49
+
50
+ export { Executor, createSandbox, isDefinedAdapter };
@@ -0,0 +1 @@
1
+ exports._default = require('./spec.cjs.js').default;