@mainsoft/agent-cms 0.0.0-stage → 0.7.0

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 (108) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/LICENSE +21 -0
  3. package/README.md +359 -2
  4. package/TODO.md +178 -0
  5. package/UPGRADE-0.6.md +236 -0
  6. package/dist/agent.cjs +250 -0
  7. package/dist/agent.d.cts +88 -0
  8. package/dist/agent.d.ts +88 -0
  9. package/dist/agent.js +24 -0
  10. package/dist/ai.cjs +555 -0
  11. package/dist/ai.d.cts +48 -0
  12. package/dist/ai.d.ts +48 -0
  13. package/dist/ai.js +73 -0
  14. package/dist/bin.js +1556 -0
  15. package/dist/chunk-2NTK7H4W.js +10 -0
  16. package/dist/chunk-52NUUZC7.js +1446 -0
  17. package/dist/chunk-6K5ZTGHQ.js +30 -0
  18. package/dist/chunk-AKN7SUXU.js +281 -0
  19. package/dist/chunk-CRDW6Q72.js +188 -0
  20. package/dist/chunk-DD56PTZ4.js +78 -0
  21. package/dist/chunk-DOADAH4L.js +52 -0
  22. package/dist/chunk-EXV6JNLY.js +251 -0
  23. package/dist/chunk-IGL2V6US.js +324 -0
  24. package/dist/chunk-IW3D4I7Q.js +317 -0
  25. package/dist/chunk-OQ55GEF3.js +6 -0
  26. package/dist/chunk-QC2M4NZY.js +158 -0
  27. package/dist/chunk-QQV6VLYJ.js +204 -0
  28. package/dist/chunk-T66ZKBHF.js +25 -0
  29. package/dist/chunk-VICZ76TR.js +118 -0
  30. package/dist/chunk-Y63XQS2J.js +6 -0
  31. package/dist/cli.cjs +1596 -0
  32. package/dist/cli.d.cts +89 -0
  33. package/dist/cli.d.ts +89 -0
  34. package/dist/cli.js +534 -0
  35. package/dist/client.cjs +185 -0
  36. package/dist/client.d.cts +228 -0
  37. package/dist/client.d.ts +228 -0
  38. package/dist/client.js +13 -0
  39. package/dist/cms-BPp01z-8.d.ts +411 -0
  40. package/dist/cms-D6D89-qZ.d.cts +411 -0
  41. package/dist/config.cjs +61 -0
  42. package/dist/config.d.cts +36 -0
  43. package/dist/config.d.ts +36 -0
  44. package/dist/config.js +11 -0
  45. package/dist/diff.cjs +316 -0
  46. package/dist/diff.d.cts +122 -0
  47. package/dist/diff.d.ts +122 -0
  48. package/dist/diff.js +29 -0
  49. package/dist/drizzle-repo-B1rt7r4j.d.ts +90 -0
  50. package/dist/drizzle-repo-Cn-kL2FK.d.cts +90 -0
  51. package/dist/errors.cjs +193 -0
  52. package/dist/errors.d.cts +109 -0
  53. package/dist/errors.d.ts +109 -0
  54. package/dist/errors.js +16 -0
  55. package/dist/frontmatter.cjs +103 -0
  56. package/dist/frontmatter.d.cts +32 -0
  57. package/dist/frontmatter.d.ts +32 -0
  58. package/dist/frontmatter.js +9 -0
  59. package/dist/http.cjs +1105 -0
  60. package/dist/http.d.cts +75 -0
  61. package/dist/http.d.ts +75 -0
  62. package/dist/http.js +321 -0
  63. package/dist/index.cjs +3066 -0
  64. package/dist/index.d.cts +19 -0
  65. package/dist/index.d.ts +19 -0
  66. package/dist/index.js +263 -0
  67. package/dist/markdown.cjs +220 -0
  68. package/dist/markdown.d.cts +88 -0
  69. package/dist/markdown.d.ts +88 -0
  70. package/dist/markdown.js +23 -0
  71. package/dist/mcp.cjs +652 -0
  72. package/dist/mcp.d.cts +43 -0
  73. package/dist/mcp.d.ts +43 -0
  74. package/dist/mcp.js +26 -0
  75. package/dist/messages/en.cjs +76 -0
  76. package/dist/messages/en.d.cts +7 -0
  77. package/dist/messages/en.d.ts +7 -0
  78. package/dist/messages/en.js +7 -0
  79. package/dist/messages/ko.cjs +76 -0
  80. package/dist/messages/ko.d.cts +7 -0
  81. package/dist/messages/ko.d.ts +7 -0
  82. package/dist/messages/ko.js +53 -0
  83. package/dist/registry/cms-audit.json +25 -0
  84. package/dist/registry/cms-command.json +23 -0
  85. package/dist/registry/cms-doc-editor.json +36 -0
  86. package/dist/registry/cms-doc-list.json +29 -0
  87. package/dist/registry/cms-empty.json +22 -0
  88. package/dist/registry/cms-keys.json +29 -0
  89. package/dist/registry/cms-lib.json +33 -0
  90. package/dist/registry/cms-merge.json +26 -0
  91. package/dist/registry/cms-shell.json +22 -0
  92. package/dist/registry/cms-versions.json +26 -0
  93. package/dist/registry/registry.json +255 -0
  94. package/dist/repo-BWI2Pkrv.d.ts +162 -0
  95. package/dist/repo-CeDxUxO6.d.cts +162 -0
  96. package/dist/tables.cjs +356 -0
  97. package/dist/tables.d.cts +3515 -0
  98. package/dist/tables.d.ts +3515 -0
  99. package/dist/tables.js +35 -0
  100. package/dist/tools.cjs +420 -0
  101. package/dist/tools.d.cts +27 -0
  102. package/dist/tools.d.ts +27 -0
  103. package/dist/tools.js +18 -0
  104. package/dist/types.cjs +226 -0
  105. package/dist/types.d.cts +286 -0
  106. package/dist/types.d.ts +286 -0
  107. package/dist/types.js +28 -0
  108. package/package.json +277 -4
package/dist/ai.js ADDED
@@ -0,0 +1,73 @@
1
+ import {
2
+ createCmsClient,
3
+ isCmsRemoteError
4
+ } from "./chunk-QC2M4NZY.js";
5
+ import {
6
+ CMS_TOOLS,
7
+ toolsFor
8
+ } from "./chunk-QQV6VLYJ.js";
9
+ import {
10
+ coreOf
11
+ } from "./chunk-52NUUZC7.js";
12
+ import "./chunk-6K5ZTGHQ.js";
13
+ import "./chunk-OQ55GEF3.js";
14
+ import "./chunk-AKN7SUXU.js";
15
+ import {
16
+ isCmsError
17
+ } from "./chunk-VICZ76TR.js";
18
+ import "./chunk-DOADAH4L.js";
19
+ import "./chunk-CRDW6Q72.js";
20
+ import "./chunk-2NTK7H4W.js";
21
+
22
+ // src/ai.ts
23
+ import { tool, zodSchema } from "ai";
24
+ function wrap(def, run) {
25
+ return tool({
26
+ description: def.description,
27
+ inputSchema: zodSchema(def.input),
28
+ execute: async (args) => {
29
+ try {
30
+ return await run(args);
31
+ } catch (err) {
32
+ if (isCmsError(err)) return err.toJSON();
33
+ if (isCmsRemoteError(err)) return { error: err.code, kind: err.kind, message: err.message, params: err.params ?? {}, ...err.diagnostics ? { diagnostics: err.diagnostics } : {}, ...err.current !== void 0 ? { current: err.current } : {} };
34
+ throw err;
35
+ }
36
+ }
37
+ });
38
+ }
39
+ function cmsTools(cms, actor, opts = {}) {
40
+ const core = coreOf(cms);
41
+ const tagged = { ...actor, via: actor.via ?? "ai" };
42
+ const out = {};
43
+ for (const def of toolsFor(core, tagged, opts.only)) {
44
+ out[(opts.prefix ?? "") + def.name] = wrap(def, async (args) => {
45
+ try {
46
+ return await def.run(core, tagged, def.input.parse(args));
47
+ } catch (e) {
48
+ if (isCmsError(e)) Object.defineProperty(e, "message", { value: core.message(e) });
49
+ throw e;
50
+ }
51
+ });
52
+ }
53
+ return out;
54
+ }
55
+ function remoteCmsTools(client, opts = {}) {
56
+ const api = createCmsClient(client);
57
+ const out = {};
58
+ for (const def of CMS_TOOLS) {
59
+ if (opts.only && !opts.only.includes(def.name)) continue;
60
+ out[(opts.prefix ?? "") + def.name] = wrap(def, (args) => api.call(def.name, args));
61
+ }
62
+ return out;
63
+ }
64
+ async function remoteCmsToolsFor(client, opts = {}) {
65
+ const allowed = new Set((await createCmsClient(client).listTools()).map((t) => t.name));
66
+ const names = CMS_TOOLS.map((t) => t.name).filter((n) => allowed.has(n) && (!opts.only || opts.only.includes(n)));
67
+ return remoteCmsTools(client, { ...opts, only: names });
68
+ }
69
+ export {
70
+ cmsTools,
71
+ remoteCmsTools,
72
+ remoteCmsToolsFor
73
+ };