dexto 1.0.2 → 1.1.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 (165) hide show
  1. package/README.md +1 -1
  2. package/agents/agent-registry.json +53 -0
  3. package/agents/database-agent/README.md +35 -0
  4. package/agents/database-agent/data/example.db +0 -0
  5. package/agents/database-agent/database-agent-example.sql +98 -0
  6. package/agents/database-agent/database-agent.yml +116 -0
  7. package/agents/database-agent/setup-database.sh +64 -0
  8. package/agents/{agent.yml → default-agent.yml} +1 -1
  9. package/agents/image-editor-agent/Lenna.webp +0 -0
  10. package/agents/image-editor-agent/README.md +435 -0
  11. package/agents/image-editor-agent/image-editor-agent.yml +45 -0
  12. package/agents/music-agent/README.md +294 -0
  13. package/agents/music-agent/music-agent.yml +43 -0
  14. package/agents/product-name-researcher/README.md +98 -0
  15. package/agents/product-name-researcher/product-name-researcher.yml +161 -0
  16. package/agents/talk2pdf-agent/README.md +166 -0
  17. package/agents/talk2pdf-agent/talk2pdf-agent.yml +42 -0
  18. package/agents/triage-demo/README.md +337 -0
  19. package/agents/triage-demo/billing-agent.yml +76 -0
  20. package/agents/triage-demo/docs/billing-policies.md +246 -0
  21. package/agents/triage-demo/docs/company-overview.md +94 -0
  22. package/agents/triage-demo/docs/escalation-policies.md +301 -0
  23. package/agents/triage-demo/docs/product-features.md +253 -0
  24. package/agents/triage-demo/docs/technical-documentation.md +226 -0
  25. package/agents/triage-demo/escalation-agent.yml +82 -0
  26. package/agents/triage-demo/product-info-agent.yml +86 -0
  27. package/agents/triage-demo/technical-support-agent.yml +71 -0
  28. package/agents/triage-demo/test-scenarios.md +209 -0
  29. package/agents/triage-demo/triage-agent.yml +172 -0
  30. package/dist/src/app/chunk-CLDYRNV6.js +10139 -0
  31. package/dist/src/app/chunk-DYNVXGAH.js +137 -0
  32. package/dist/src/app/chunk-PW2PHCHR.js +83 -0
  33. package/dist/src/app/chunk-R4Q522DR.js +205 -0
  34. package/dist/src/app/chunk-UXCBS3TR.js +281 -0
  35. package/dist/src/app/chunk-X6LEX724.js +108 -0
  36. package/dist/src/app/chunk-Y33BS5SA.js +39 -0
  37. package/dist/src/app/{cli-confirmation-handler-EZF6AMUS.js → cli-confirmation-handler-GJHPLGOL.js} +4 -1
  38. package/dist/src/app/errors-5MNETGOV.js +8 -0
  39. package/dist/src/app/index.js +1604 -8978
  40. package/dist/src/app/loader-EFMKWNNQ.js +20 -0
  41. package/dist/src/app/path-7FT4SZMO.js +23 -0
  42. package/dist/src/app/{postgres-backend-7HVVW3RL.js → postgres-backend-U5MIIMUY.js} +12 -1
  43. package/dist/src/app/{redis-backend-2YBZSSSV.js → redis-backend-NGI67ILT.js} +38 -9
  44. package/dist/src/app/registry-RALMVM3P.js +14 -0
  45. package/dist/src/app/sqlite-backend-752UUBD4.js +245 -0
  46. package/dist/src/app/webui/.next/standalone/.next/BUILD_ID +1 -1
  47. package/dist/src/app/webui/.next/standalone/.next/app-build-manifest.json +20 -21
  48. package/dist/src/app/webui/.next/standalone/.next/app-path-routes-manifest.json +0 -1
  49. package/dist/src/app/webui/.next/standalone/.next/build-manifest.json +4 -4
  50. package/dist/src/app/webui/.next/standalone/.next/prerender-manifest.json +4 -82
  51. package/dist/src/app/webui/.next/standalone/.next/required-server-files.json +2 -3
  52. package/dist/src/app/webui/.next/standalone/.next/routes-manifest.json +0 -6
  53. package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found/page.js +1 -1
  54. package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found/page.js.nft.json +1 -1
  55. package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found/page_client-reference-manifest.js +1 -1
  56. package/dist/src/app/webui/.next/standalone/.next/server/app/page.js +7 -3
  57. package/dist/src/app/webui/.next/standalone/.next/server/app/page.js.nft.json +1 -1
  58. package/dist/src/app/webui/.next/standalone/.next/server/app/page_client-reference-manifest.js +1 -1
  59. package/dist/src/app/webui/.next/standalone/.next/server/app/playground/page.js +8 -8
  60. package/dist/src/app/webui/.next/standalone/.next/server/app/playground/page.js.nft.json +1 -1
  61. package/dist/src/app/webui/.next/standalone/.next/server/app/playground/page_client-reference-manifest.js +1 -1
  62. package/dist/src/app/webui/.next/standalone/.next/server/app-paths-manifest.json +0 -1
  63. package/dist/src/app/webui/.next/standalone/.next/server/chunks/176.js +1 -0
  64. package/dist/src/app/webui/.next/standalone/.next/server/chunks/195.js +24 -0
  65. package/dist/src/app/webui/.next/standalone/.next/server/chunks/620.js +1 -0
  66. package/dist/src/app/webui/.next/standalone/.next/server/chunks/80.js +5 -0
  67. package/dist/src/app/webui/.next/standalone/.next/server/middleware-build-manifest.js +1 -1
  68. package/dist/src/app/webui/.next/standalone/.next/server/pages/500.html +1 -1
  69. package/dist/src/app/webui/.next/standalone/.next/server/pages-manifest.json +1 -2
  70. package/dist/src/app/webui/.next/standalone/.next/server/server-reference-manifest.json +1 -1
  71. package/dist/src/app/webui/.next/standalone/.next/server/webpack-runtime.js +1 -1
  72. package/dist/src/app/webui/.next/standalone/.next/static/chunks/190-b897ef36fde616bf.js +1 -0
  73. package/dist/src/app/webui/.next/standalone/.next/static/chunks/487-a77054bd2c64c79c.js +1 -0
  74. package/dist/src/app/webui/.next/standalone/.next/static/chunks/588-dbe47a44489742dd.js +1 -0
  75. package/dist/src/app/webui/.next/standalone/.next/static/chunks/62-35030b5cb176bd7b.js +1 -0
  76. package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/layout-91c0cb9eb1ee327a.js +1 -0
  77. package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/page-3279aaf14db87f45.js +1 -0
  78. package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/playground/page-200aad53af9ca53f.js +1 -0
  79. package/dist/src/app/webui/.next/standalone/.next/static/css/af71306827be150e.css +3 -0
  80. package/dist/src/app/webui/.next/standalone/.next/static/tpCURR82LyyGfdALJ4Qvl/_buildManifest.js +1 -0
  81. package/dist/src/app/webui/.next/standalone/package.json +4 -3
  82. package/dist/src/app/webui/.next/standalone/public/favicon2.ico +0 -0
  83. package/dist/src/app/webui/.next/standalone/public/logo.svg +1 -0
  84. package/dist/src/app/webui/.next/standalone/public/logo_no_text.png +0 -0
  85. package/dist/src/app/webui/.next/standalone/server.js +1 -1
  86. package/dist/src/app/webui/.next/static/chunks/190-b897ef36fde616bf.js +1 -0
  87. package/dist/src/app/webui/.next/static/chunks/487-a77054bd2c64c79c.js +1 -0
  88. package/dist/src/app/webui/.next/static/chunks/588-dbe47a44489742dd.js +1 -0
  89. package/dist/src/app/webui/.next/static/chunks/62-35030b5cb176bd7b.js +1 -0
  90. package/dist/src/app/webui/.next/static/chunks/app/layout-91c0cb9eb1ee327a.js +1 -0
  91. package/dist/src/app/webui/.next/static/chunks/app/page-3279aaf14db87f45.js +1 -0
  92. package/dist/src/app/webui/.next/static/chunks/app/playground/page-200aad53af9ca53f.js +1 -0
  93. package/dist/src/app/webui/.next/static/css/af71306827be150e.css +3 -0
  94. package/dist/src/app/webui/.next/static/tpCURR82LyyGfdALJ4Qvl/_buildManifest.js +1 -0
  95. package/dist/src/app/webui/package.json +4 -3
  96. package/dist/src/app/webui/public/favicon2.ico +0 -0
  97. package/dist/src/app/webui/public/logo.svg +1 -0
  98. package/dist/src/app/webui/public/logo_no_text.png +0 -0
  99. package/dist/src/core/chunk-7A6NQKQ3.js +193 -0
  100. package/dist/src/core/chunk-CZIXQNMZ.js +12191 -0
  101. package/dist/src/core/index.cjs +10605 -8030
  102. package/dist/src/core/index.d.cts +4339 -3927
  103. package/dist/src/core/index.d.ts +4339 -3927
  104. package/dist/src/core/index.js +113 -8381
  105. package/dist/src/core/{postgres-backend-ERZ6DP76.js → postgres-backend-LOLKTD2T.js} +9 -2
  106. package/dist/src/core/{redis-backend-46O7Y44C.js → redis-backend-APZ576PJ.js} +35 -10
  107. package/dist/src/core/sqlite-backend-KQ75DPR7.js +245 -0
  108. package/package.json +18 -11
  109. package/dist/src/app/chunk-W7G44EAE.js +0 -463
  110. package/dist/src/app/sqlite-backend-VRXGIKHQ.js +0 -180
  111. package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found.html +0 -1
  112. package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found.meta +0 -8
  113. package/dist/src/app/webui/.next/standalone/.next/server/app/_not-found.rsc +0 -21
  114. package/dist/src/app/webui/.next/standalone/.next/server/app/favicon.ico/route.js +0 -1
  115. package/dist/src/app/webui/.next/standalone/.next/server/app/favicon.ico/route.js.nft.json +0 -1
  116. package/dist/src/app/webui/.next/standalone/.next/server/app/favicon.ico.body +0 -0
  117. package/dist/src/app/webui/.next/standalone/.next/server/app/favicon.ico.meta +0 -1
  118. package/dist/src/app/webui/.next/standalone/.next/server/app/index.html +0 -1
  119. package/dist/src/app/webui/.next/standalone/.next/server/app/index.meta +0 -7
  120. package/dist/src/app/webui/.next/standalone/.next/server/app/index.rsc +0 -22
  121. package/dist/src/app/webui/.next/standalone/.next/server/app/playground.html +0 -1
  122. package/dist/src/app/webui/.next/standalone/.next/server/app/playground.meta +0 -7
  123. package/dist/src/app/webui/.next/standalone/.next/server/app/playground.rsc +0 -25
  124. package/dist/src/app/webui/.next/standalone/.next/server/chunks/447.js +0 -20
  125. package/dist/src/app/webui/.next/standalone/.next/server/chunks/504.js +0 -1
  126. package/dist/src/app/webui/.next/standalone/.next/server/chunks/54.js +0 -5
  127. package/dist/src/app/webui/.next/standalone/.next/server/chunks/624.js +0 -1
  128. package/dist/src/app/webui/.next/standalone/.next/server/chunks/985.js +0 -5
  129. package/dist/src/app/webui/.next/standalone/.next/server/pages/404.html +0 -1
  130. package/dist/src/app/webui/.next/standalone/.next/static/L4341-2-iEIknMYuTWeoz/_buildManifest.js +0 -1
  131. package/dist/src/app/webui/.next/standalone/.next/static/chunks/125-9b34ec01f112cdb2.js +0 -1
  132. package/dist/src/app/webui/.next/standalone/.next/static/chunks/487-c6ea8b63ca68db1c.js +0 -1
  133. package/dist/src/app/webui/.next/standalone/.next/static/chunks/588-20dc7f3a8664c387.js +0 -1
  134. package/dist/src/app/webui/.next/standalone/.next/static/chunks/687-3e614f30982093f6.js +0 -1
  135. package/dist/src/app/webui/.next/standalone/.next/static/chunks/879-cf875984faa0b72f.js +0 -1
  136. package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/layout-ed56660b7ecaf47b.js +0 -1
  137. package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/page-b05580de36ce0e36.js +0 -1
  138. package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/playground/page-ac5443cddbe824aa.js +0 -1
  139. package/dist/src/app/webui/.next/standalone/.next/static/css/d44f09bc2605dc76.css +0 -3
  140. package/dist/src/app/webui/.next/standalone/node_modules/next/dist/compiled/next-server/app-route.runtime.prod.js +0 -19
  141. package/dist/src/app/webui/.next/standalone/public/favicon.svg +0 -26
  142. package/dist/src/app/webui/.next/standalone/public/logo.png +0 -0
  143. package/dist/src/app/webui/.next/static/L4341-2-iEIknMYuTWeoz/_buildManifest.js +0 -1
  144. package/dist/src/app/webui/.next/static/chunks/125-9b34ec01f112cdb2.js +0 -1
  145. package/dist/src/app/webui/.next/static/chunks/487-c6ea8b63ca68db1c.js +0 -1
  146. package/dist/src/app/webui/.next/static/chunks/588-20dc7f3a8664c387.js +0 -1
  147. package/dist/src/app/webui/.next/static/chunks/687-3e614f30982093f6.js +0 -1
  148. package/dist/src/app/webui/.next/static/chunks/879-cf875984faa0b72f.js +0 -1
  149. package/dist/src/app/webui/.next/static/chunks/app/layout-ed56660b7ecaf47b.js +0 -1
  150. package/dist/src/app/webui/.next/static/chunks/app/page-b05580de36ce0e36.js +0 -1
  151. package/dist/src/app/webui/.next/static/chunks/app/playground/page-ac5443cddbe824aa.js +0 -1
  152. package/dist/src/app/webui/.next/static/css/d44f09bc2605dc76.css +0 -3
  153. package/dist/src/app/webui/public/favicon.svg +0 -26
  154. package/dist/src/app/webui/public/logo.png +0 -0
  155. package/dist/src/core/chunk-6VYPSHEV.js +0 -2153
  156. package/dist/src/core/chunk-BYHW25EA.js +0 -41
  157. package/dist/src/core/sqlite-backend-M2ZPSSIZ.js +0 -184
  158. /package/dist/src/app/webui/.next/standalone/.next/static/chunks/{4bd1b696-2df85d4b3b58aed5.js → 4bd1b696-c95fa02060335229.js} +0 -0
  159. /package/dist/src/app/webui/.next/standalone/.next/static/chunks/{684-058c08971e023037.js → 684-2e7175657246b549.js} +0 -0
  160. /package/dist/src/app/webui/.next/standalone/.next/static/chunks/app/_not-found/{page-7b137d85f9de4771.js → page-b63df5a8d3225455.js} +0 -0
  161. /package/dist/src/app/webui/.next/standalone/.next/static/{L4341-2-iEIknMYuTWeoz → tpCURR82LyyGfdALJ4Qvl}/_ssgManifest.js +0 -0
  162. /package/dist/src/app/webui/.next/static/chunks/{4bd1b696-2df85d4b3b58aed5.js → 4bd1b696-c95fa02060335229.js} +0 -0
  163. /package/dist/src/app/webui/.next/static/chunks/{684-058c08971e023037.js → 684-2e7175657246b549.js} +0 -0
  164. /package/dist/src/app/webui/.next/static/chunks/app/_not-found/{page-7b137d85f9de4771.js → page-b63df5a8d3225455.js} +0 -0
  165. /package/dist/src/app/webui/.next/static/{L4341-2-iEIknMYuTWeoz → tpCURR82LyyGfdALJ4Qvl}/_ssgManifest.js +0 -0
@@ -0,0 +1,137 @@
1
+ import {
2
+ DextoRuntimeError
3
+ } from "./chunk-Y33BS5SA.js";
4
+
5
+ // src/core/agent/registry/errors.ts
6
+ var RegistryError = class {
7
+ // Agent lookup errors
8
+ static agentNotFound(agentName, availableAgents) {
9
+ return new DextoRuntimeError(
10
+ "registry_agent_not_found" /* AGENT_NOT_FOUND */,
11
+ "agent_registry" /* AGENT_REGISTRY */,
12
+ "user" /* USER */,
13
+ `Agent '${agentName}' not found in registry`,
14
+ { agentName, availableAgents },
15
+ `Available agents: ${availableAgents.join(", ")}. Use a file path for custom agents.`
16
+ );
17
+ }
18
+ static agentInvalidEntry(agentName, reason) {
19
+ return new DextoRuntimeError(
20
+ "registry_agent_invalid_entry" /* AGENT_INVALID_ENTRY */,
21
+ "agent_registry" /* AGENT_REGISTRY */,
22
+ "system" /* SYSTEM */,
23
+ `Registry entry for '${agentName}' is invalid: ${reason}`,
24
+ { agentName, reason },
25
+ "This indicates a problem with the agent registry - please report this issue"
26
+ );
27
+ }
28
+ // Installation errors
29
+ static installationFailed(agentName, cause) {
30
+ return new DextoRuntimeError(
31
+ "registry_installation_failed" /* INSTALLATION_FAILED */,
32
+ "agent_registry" /* AGENT_REGISTRY */,
33
+ "system" /* SYSTEM */,
34
+ `Failed to install agent '${agentName}': ${cause}`,
35
+ { agentName, cause },
36
+ "Check network connection and available disk space"
37
+ );
38
+ }
39
+ static installationValidationFailed(agentName, missingPath) {
40
+ return new DextoRuntimeError(
41
+ "registry_installation_validation_failed" /* INSTALLATION_VALIDATION_FAILED */,
42
+ "agent_registry" /* AGENT_REGISTRY */,
43
+ "system" /* SYSTEM */,
44
+ `Installation validation failed for '${agentName}': missing main config`,
45
+ { agentName, missingPath },
46
+ "This indicates a problem with the agent bundle - please report this issue"
47
+ );
48
+ }
49
+ // Config file errors
50
+ static configNotFound(configPath) {
51
+ return new DextoRuntimeError(
52
+ "registry_config_not_found" /* CONFIG_NOT_FOUND */,
53
+ "agent_registry" /* AGENT_REGISTRY */,
54
+ "system" /* SYSTEM */,
55
+ `Agent config file not found: ${configPath}`,
56
+ { configPath },
57
+ "This indicates a problem with the agent installation"
58
+ );
59
+ }
60
+ static mainConfigMissing(agentName, expectedPath) {
61
+ return new DextoRuntimeError(
62
+ "registry_main_config_missing" /* MAIN_CONFIG_MISSING */,
63
+ "agent_registry" /* AGENT_REGISTRY */,
64
+ "system" /* SYSTEM */,
65
+ `Main config file not found for agent '${agentName}': ${expectedPath}`,
66
+ { agentName, expectedPath },
67
+ "This indicates a problem with the agent bundle structure"
68
+ );
69
+ }
70
+ // Uninstallation errors
71
+ static agentNotInstalled(agentName) {
72
+ return new DextoRuntimeError(
73
+ "registry_agent_not_installed" /* AGENT_NOT_INSTALLED */,
74
+ "agent_registry" /* AGENT_REGISTRY */,
75
+ "user" /* USER */,
76
+ `Agent '${agentName}' is not installed`,
77
+ { agentName },
78
+ 'Use "dexto list-agents --installed" to see installed agents'
79
+ );
80
+ }
81
+ static agentProtected(agentName) {
82
+ return new DextoRuntimeError(
83
+ "registry_agent_protected" /* AGENT_PROTECTED */,
84
+ "agent_registry" /* AGENT_REGISTRY */,
85
+ "user" /* USER */,
86
+ `Agent '${agentName}' is protected and cannot be uninstalled. Use --force to override (not recommended for critical agents)`,
87
+ { agentName },
88
+ "Use --force to override (not recommended for critical agents)"
89
+ );
90
+ }
91
+ static uninstallationFailed(agentName, cause) {
92
+ return new DextoRuntimeError(
93
+ "registry_uninstallation_failed" /* UNINSTALLATION_FAILED */,
94
+ "agent_registry" /* AGENT_REGISTRY */,
95
+ "system" /* SYSTEM */,
96
+ `Failed to uninstall agent '${agentName}': ${cause}`,
97
+ { agentName, cause },
98
+ "Check file permissions and ensure no processes are using the agent"
99
+ );
100
+ }
101
+ // Registry file errors
102
+ static registryNotFound(registryPath) {
103
+ return new DextoRuntimeError(
104
+ "registry_file_not_found" /* REGISTRY_NOT_FOUND */,
105
+ "agent_registry" /* AGENT_REGISTRY */,
106
+ "system" /* SYSTEM */,
107
+ `Agent registry not found: ${registryPath}`,
108
+ { registryPath },
109
+ "This indicates a problem with the Dexto installation - please reinstall or report this issue"
110
+ );
111
+ }
112
+ static registryParseError(registryPath, cause) {
113
+ return new DextoRuntimeError(
114
+ "registry_parse_error" /* REGISTRY_PARSE_ERROR */,
115
+ "agent_registry" /* AGENT_REGISTRY */,
116
+ "system" /* SYSTEM */,
117
+ `Failed to parse agent registry from ${registryPath}: ${cause}`,
118
+ { registryPath, cause },
119
+ "This indicates a corrupted registry file - please reinstall Dexto"
120
+ );
121
+ }
122
+ // Auto-install control errors
123
+ static agentNotInstalledAutoInstallDisabled(agentName, availableAgents) {
124
+ return new DextoRuntimeError(
125
+ "registry_agent_not_installed_auto_install_disabled" /* AGENT_NOT_INSTALLED_AUTO_INSTALL_DISABLED */,
126
+ "agent_registry" /* AGENT_REGISTRY */,
127
+ "user" /* USER */,
128
+ `Agent '${agentName}' is not installed locally and auto-install is disabled`,
129
+ { agentName, availableAgents },
130
+ `Use 'dexto install ${agentName}' to install it manually, or use a file path for custom agents`
131
+ );
132
+ }
133
+ };
134
+
135
+ export {
136
+ RegistryError
137
+ };
@@ -0,0 +1,83 @@
1
+ import {
2
+ DextoRuntimeError
3
+ } from "./chunk-Y33BS5SA.js";
4
+
5
+ // src/core/storage/errors.ts
6
+ var StorageError = class {
7
+ /**
8
+ * Connection failed error
9
+ */
10
+ static connectionFailed(reason, config) {
11
+ return new DextoRuntimeError(
12
+ "storage_connection_failed" /* CONNECTION_FAILED */,
13
+ "storage" /* STORAGE */,
14
+ "third_party" /* THIRD_PARTY */,
15
+ `Storage connection failed: ${reason}`,
16
+ { reason, config }
17
+ );
18
+ }
19
+ /**
20
+ * Backend not connected error
21
+ */
22
+ static notConnected(backendType) {
23
+ return new DextoRuntimeError(
24
+ "storage_connection_failed" /* CONNECTION_FAILED */,
25
+ "storage" /* STORAGE */,
26
+ "system" /* SYSTEM */,
27
+ `${backendType} not connected`,
28
+ { backendType }
29
+ );
30
+ }
31
+ /**
32
+ * Read operation failed
33
+ */
34
+ static readFailed(operation, reason, details) {
35
+ return new DextoRuntimeError(
36
+ "storage_read_failed" /* READ_FAILED */,
37
+ "storage" /* STORAGE */,
38
+ "system" /* SYSTEM */,
39
+ `Storage read failed for ${operation}: ${reason}`,
40
+ { operation, reason, ...details }
41
+ );
42
+ }
43
+ /**
44
+ * Write operation failed
45
+ */
46
+ static writeFailed(operation, reason, details) {
47
+ return new DextoRuntimeError(
48
+ "storage_write_failed" /* WRITE_FAILED */,
49
+ "storage" /* STORAGE */,
50
+ "system" /* SYSTEM */,
51
+ `Storage write failed for ${operation}: ${reason}`,
52
+ { operation, reason, ...details }
53
+ );
54
+ }
55
+ /**
56
+ * Delete operation failed
57
+ */
58
+ static deleteFailed(operation, reason, details) {
59
+ return new DextoRuntimeError(
60
+ "storage_delete_failed" /* DELETE_FAILED */,
61
+ "storage" /* STORAGE */,
62
+ "system" /* SYSTEM */,
63
+ `Storage delete failed for ${operation}: ${reason}`,
64
+ { operation, reason, ...details }
65
+ );
66
+ }
67
+ /**
68
+ * Migration failed error
69
+ */
70
+ static migrationFailed(reason, details) {
71
+ return new DextoRuntimeError(
72
+ "storage_migration_failed" /* MIGRATION_FAILED */,
73
+ "storage" /* STORAGE */,
74
+ "system" /* SYSTEM */,
75
+ `Database migration failed: ${reason}`,
76
+ { reason, ...details }
77
+ );
78
+ }
79
+ };
80
+
81
+ export {
82
+ StorageError
83
+ };
@@ -0,0 +1,205 @@
1
+ import {
2
+ LLM_PROVIDERS,
3
+ NonEmptyTrimmed,
4
+ getDextoGlobalPath,
5
+ getSupportedModels,
6
+ isValidProviderModel,
7
+ logger
8
+ } from "./chunk-CLDYRNV6.js";
9
+ import {
10
+ DextoValidationError
11
+ } from "./chunk-X6LEX724.js";
12
+ import {
13
+ DextoRuntimeError
14
+ } from "./chunk-Y33BS5SA.js";
15
+
16
+ // src/core/preferences/loader.ts
17
+ import { existsSync } from "fs";
18
+ import { promises as fs } from "fs";
19
+ import { parse as parseYaml, stringify as stringifyYaml } from "yaml";
20
+
21
+ // src/core/preferences/schemas.ts
22
+ import { z } from "zod";
23
+ var PreferenceLLMSchema = z.object({
24
+ provider: z.enum(LLM_PROVIDERS).describe("LLM provider (openai, anthropic, google, etc.)"),
25
+ model: NonEmptyTrimmed.describe("Model name for the provider"),
26
+ apiKey: z.string().regex(
27
+ /^\$[A-Z_][A-Z0-9_]*$/,
28
+ "Must be environment variable reference (e.g., $OPENAI_API_KEY)"
29
+ ).describe("Environment variable reference for API key")
30
+ }).strict().superRefine((data, ctx) => {
31
+ if (!isValidProviderModel(data.provider, data.model)) {
32
+ const supportedModels = getSupportedModels(data.provider);
33
+ ctx.addIssue({
34
+ code: z.ZodIssueCode.custom,
35
+ path: ["model"],
36
+ message: `Model '${data.model}' is not supported by provider '${data.provider}'. Supported models: ${supportedModels.join(", ")}`,
37
+ params: {
38
+ code: "preference_model_incompatible" /* MODEL_INCOMPATIBLE */,
39
+ scope: "preference" /* PREFERENCE */,
40
+ type: "user" /* USER */
41
+ }
42
+ });
43
+ }
44
+ });
45
+ var PreferenceDefaultsSchema = z.object({
46
+ defaultAgent: z.string().min(1).describe("Default agent name for global CLI usage (required)")
47
+ }).strict();
48
+ var PreferenceSetupSchema = z.object({
49
+ completed: z.boolean().default(false).describe("Whether initial setup has been completed")
50
+ }).strict();
51
+ var GlobalPreferencesSchema = z.object({
52
+ llm: PreferenceLLMSchema.describe("LLM configuration preferences"),
53
+ defaults: PreferenceDefaultsSchema.describe("Default behavior preferences (required)"),
54
+ setup: PreferenceSetupSchema.default({ completed: false }).describe(
55
+ "Setup completion tracking"
56
+ )
57
+ }).strict();
58
+
59
+ // src/core/preferences/constants.ts
60
+ var PREFERENCES_FILE = "preferences.yml";
61
+
62
+ // src/core/preferences/errors.ts
63
+ var PreferenceError = class {
64
+ static fileNotFound(preferencesPath) {
65
+ return new DextoRuntimeError(
66
+ "preference_file_not_found" /* FILE_NOT_FOUND */,
67
+ "preference" /* PREFERENCE */,
68
+ "user" /* USER */,
69
+ `Preferences file not found: ${preferencesPath}`,
70
+ { preferencesPath },
71
+ "Run `dexto setup` to create preferences"
72
+ );
73
+ }
74
+ static fileReadError(preferencesPath, cause) {
75
+ return new DextoRuntimeError(
76
+ "preference_file_read_error" /* FILE_READ_ERROR */,
77
+ "preference" /* PREFERENCE */,
78
+ "system" /* SYSTEM */,
79
+ `Failed to read preferences: ${cause}`,
80
+ { preferencesPath, cause },
81
+ "Check file permissions and ensure the file is not corrupted"
82
+ );
83
+ }
84
+ static fileWriteError(preferencesPath, cause) {
85
+ return new DextoRuntimeError(
86
+ "preference_file_write_error" /* FILE_WRITE_ERROR */,
87
+ "preference" /* PREFERENCE */,
88
+ "system" /* SYSTEM */,
89
+ `Failed to save preferences: ${cause}`,
90
+ { preferencesPath, cause },
91
+ "Check file permissions and available disk space"
92
+ );
93
+ }
94
+ static validationFailed(zodError) {
95
+ const issues = zodError.issues.map((issue) => ({
96
+ code: "preference_validation_error" /* VALIDATION_ERROR */,
97
+ message: `${issue.path.join(".")}: ${issue.message}`,
98
+ scope: "preference" /* PREFERENCE */,
99
+ type: "user" /* USER */,
100
+ severity: "error"
101
+ }));
102
+ return new DextoValidationError(issues);
103
+ }
104
+ };
105
+
106
+ // src/core/preferences/loader.ts
107
+ async function loadGlobalPreferences() {
108
+ const preferencesPath = getDextoGlobalPath(PREFERENCES_FILE);
109
+ if (!existsSync(preferencesPath)) {
110
+ throw PreferenceError.fileNotFound(preferencesPath);
111
+ }
112
+ try {
113
+ const fileContent = await fs.readFile(preferencesPath, "utf-8");
114
+ const rawPreferences = parseYaml(fileContent);
115
+ const validation = GlobalPreferencesSchema.safeParse(rawPreferences);
116
+ if (!validation.success) {
117
+ throw PreferenceError.validationFailed(validation.error);
118
+ }
119
+ logger.debug(`Loaded global preferences from: ${preferencesPath}`);
120
+ return validation.data;
121
+ } catch (error) {
122
+ if (error instanceof DextoValidationError || error instanceof DextoRuntimeError) {
123
+ throw error;
124
+ }
125
+ throw PreferenceError.fileReadError(
126
+ preferencesPath,
127
+ error instanceof Error ? error.message : String(error)
128
+ );
129
+ }
130
+ }
131
+ async function saveGlobalPreferences(preferences) {
132
+ const preferencesPath = getDextoGlobalPath(PREFERENCES_FILE);
133
+ const validation = GlobalPreferencesSchema.safeParse(preferences);
134
+ if (!validation.success) {
135
+ throw PreferenceError.validationFailed(validation.error);
136
+ }
137
+ try {
138
+ logger.info(`Saving global preferences to: ${preferencesPath}`);
139
+ const dextoDir = getDextoGlobalPath("");
140
+ await fs.mkdir(dextoDir, { recursive: true });
141
+ const yamlContent = stringifyYaml(preferences, {
142
+ indent: 2,
143
+ lineWidth: 100,
144
+ minContentWidth: 20
145
+ });
146
+ await fs.writeFile(preferencesPath, yamlContent, "utf-8");
147
+ logger.info(
148
+ `\u2713 Saved global preferences ${JSON.stringify(preferences)} to: ${preferencesPath}`
149
+ );
150
+ } catch (error) {
151
+ throw PreferenceError.fileWriteError(
152
+ preferencesPath,
153
+ error instanceof Error ? error.message : String(error)
154
+ );
155
+ }
156
+ }
157
+ function globalPreferencesExist() {
158
+ const preferencesPath = getDextoGlobalPath(PREFERENCES_FILE);
159
+ return existsSync(preferencesPath);
160
+ }
161
+ function getGlobalPreferencesPath() {
162
+ return getDextoGlobalPath(PREFERENCES_FILE);
163
+ }
164
+ function createInitialPreferences(provider, model, apiKeyVar, defaultAgent = "default-agent") {
165
+ return {
166
+ llm: {
167
+ provider,
168
+ model,
169
+ apiKey: `$${apiKeyVar}`
170
+ },
171
+ defaults: {
172
+ defaultAgent
173
+ },
174
+ setup: {
175
+ completed: true
176
+ }
177
+ };
178
+ }
179
+ async function updateGlobalPreferences(updates) {
180
+ const existing = await loadGlobalPreferences();
181
+ const merged = {
182
+ ...existing,
183
+ ...updates,
184
+ // LLM section requires complete replacement (high coherence - provider/model/apiKey must match)
185
+ llm: updates.llm || existing.llm,
186
+ // Defaults and setup sections allow partial updates (low coherence - independent fields)
187
+ defaults: updates.defaults ? { ...existing.defaults, ...updates.defaults } : existing.defaults,
188
+ setup: updates.setup ? { ...existing.setup, ...updates.setup } : existing.setup
189
+ };
190
+ const validation = GlobalPreferencesSchema.safeParse(merged);
191
+ if (!validation.success) {
192
+ throw PreferenceError.validationFailed(validation.error);
193
+ }
194
+ await saveGlobalPreferences(validation.data);
195
+ return validation.data;
196
+ }
197
+
198
+ export {
199
+ loadGlobalPreferences,
200
+ saveGlobalPreferences,
201
+ globalPreferencesExist,
202
+ getGlobalPreferencesPath,
203
+ createInitialPreferences,
204
+ updateGlobalPreferences
205
+ };
@@ -0,0 +1,281 @@
1
+ import {
2
+ loadGlobalPreferences
3
+ } from "./chunk-R4Q522DR.js";
4
+ import {
5
+ copyDirectory,
6
+ getDextoGlobalPath,
7
+ logger,
8
+ resolveBundledScript,
9
+ writePreferencesToAgent
10
+ } from "./chunk-CLDYRNV6.js";
11
+ import {
12
+ RegistryError
13
+ } from "./chunk-DYNVXGAH.js";
14
+
15
+ // src/core/agent/registry/registry.ts
16
+ import { existsSync, readFileSync } from "fs";
17
+ import { promises as fs } from "fs";
18
+ import path from "path";
19
+
20
+ // src/core/agent/registry/types.ts
21
+ import { z } from "zod";
22
+ var AgentRegistryEntrySchema = z.object({
23
+ description: z.string(),
24
+ author: z.string(),
25
+ tags: z.array(z.string()),
26
+ source: z.string(),
27
+ main: z.string().optional()
28
+ }).strict();
29
+ var RegistrySchema = z.object({
30
+ version: z.string(),
31
+ agents: z.record(z.string(), AgentRegistryEntrySchema)
32
+ }).strict();
33
+
34
+ // src/core/agent/registry/registry.ts
35
+ var cachedRegistry = null;
36
+ var LocalAgentRegistry = class {
37
+ _registry = null;
38
+ /**
39
+ * Lazy load registry from JSON file
40
+ */
41
+ getRegistry() {
42
+ if (this._registry === null) {
43
+ this._registry = this.loadRegistry();
44
+ }
45
+ return this._registry;
46
+ }
47
+ /**
48
+ * Load registry from bundled JSON file
49
+ * Uses fail-fast approach - throws RegistryError for any loading issues
50
+ */
51
+ loadRegistry() {
52
+ let jsonPath;
53
+ try {
54
+ jsonPath = resolveBundledScript("agents/agent-registry.json");
55
+ } catch (_error) {
56
+ throw RegistryError.registryNotFound(
57
+ "agents/agent-registry.json (bundle resolution failed)"
58
+ );
59
+ }
60
+ if (!existsSync(jsonPath)) {
61
+ throw RegistryError.registryNotFound(jsonPath);
62
+ }
63
+ try {
64
+ const jsonData = readFileSync(jsonPath, "utf-8");
65
+ const rawRegistry = JSON.parse(jsonData);
66
+ return RegistrySchema.parse(rawRegistry);
67
+ } catch (error) {
68
+ throw RegistryError.registryParseError(
69
+ jsonPath,
70
+ error instanceof Error ? error.message : String(error)
71
+ );
72
+ }
73
+ }
74
+ /**
75
+ * Check if agent exists in registry
76
+ */
77
+ hasAgent(name) {
78
+ const registry = this.getRegistry();
79
+ return name in registry.agents;
80
+ }
81
+ /**
82
+ * Get available agents with their metadata from registry
83
+ */
84
+ getAvailableAgents() {
85
+ const registry = this.getRegistry();
86
+ return registry.agents;
87
+ }
88
+ /**
89
+ * Resolve main config file for installed agent
90
+ * Handles both directory agents (with main field) and single-file agents
91
+ */
92
+ resolveMainConfig(agentDir, agentName) {
93
+ const registry = this.getRegistry();
94
+ const agentData = registry.agents[agentName];
95
+ if (!agentData) {
96
+ const available = Object.keys(registry.agents);
97
+ throw RegistryError.agentNotFound(agentName, available);
98
+ }
99
+ if (agentData.source.endsWith("/")) {
100
+ if (!agentData.main) {
101
+ throw RegistryError.agentInvalidEntry(
102
+ agentName,
103
+ "directory entry missing main field"
104
+ );
105
+ }
106
+ const mainConfigPath = path.join(agentDir, agentData.main);
107
+ if (!existsSync(mainConfigPath)) {
108
+ throw RegistryError.mainConfigMissing(agentName, mainConfigPath);
109
+ }
110
+ return mainConfigPath;
111
+ } else {
112
+ const filename = path.basename(agentData.source);
113
+ const configPath = path.join(agentDir, filename);
114
+ if (!existsSync(configPath)) {
115
+ throw RegistryError.configNotFound(configPath);
116
+ }
117
+ return configPath;
118
+ }
119
+ }
120
+ /**
121
+ * Install agent atomically using temp + rename pattern
122
+ * @param agentName Name of the agent to install
123
+ * @param injectPreferences Whether to inject global preferences into installed agent (default: true)
124
+ */
125
+ async installAgent(agentName, injectPreferences = true) {
126
+ logger.info(`Installing agent: ${agentName}`);
127
+ const registry = this.getRegistry();
128
+ const agentData = registry.agents[agentName];
129
+ if (!agentData) {
130
+ const available = Object.keys(registry.agents);
131
+ throw RegistryError.agentNotFound(agentName, available);
132
+ }
133
+ const globalAgentsDir = getDextoGlobalPath("agents");
134
+ const targetDir = path.join(globalAgentsDir, agentName);
135
+ if (existsSync(targetDir)) {
136
+ logger.info(`Agent '${agentName}' already installed`);
137
+ return this.resolveMainConfig(targetDir, agentName);
138
+ }
139
+ await fs.mkdir(globalAgentsDir, { recursive: true });
140
+ const sourcePath = resolveBundledScript(`agents/${agentData.source}`);
141
+ const tempDir = `${targetDir}.tmp.${Date.now()}`;
142
+ try {
143
+ if (agentData.source.endsWith("/")) {
144
+ await copyDirectory(sourcePath, tempDir);
145
+ } else {
146
+ await fs.mkdir(tempDir, { recursive: true });
147
+ const targetFile = path.join(tempDir, path.basename(sourcePath));
148
+ await fs.copyFile(sourcePath, targetFile);
149
+ }
150
+ const mainConfigPath = this.resolveMainConfig(tempDir, agentName);
151
+ if (!existsSync(mainConfigPath)) {
152
+ throw RegistryError.installationValidationFailed(agentName, mainConfigPath);
153
+ }
154
+ await fs.rename(tempDir, targetDir);
155
+ logger.info(`\u2713 Installed agent '${agentName}' to ${targetDir}`);
156
+ if (injectPreferences) {
157
+ try {
158
+ const preferences = await loadGlobalPreferences();
159
+ await writePreferencesToAgent(targetDir, preferences);
160
+ logger.info(`\u2713 Applied global preferences to installed agent '${agentName}'`);
161
+ } catch (error) {
162
+ logger.warn(
163
+ `Failed to inject preferences to '${agentName}': ${error instanceof Error ? error.message : String(error)}`
164
+ );
165
+ console.log(
166
+ `\u26A0\uFE0F Warning: Could not apply preferences to '${agentName}' - agent will use bundled settings`
167
+ );
168
+ }
169
+ } else {
170
+ logger.info(
171
+ `Skipped preference injection for '${agentName}' (injectPreferences=false)`
172
+ );
173
+ }
174
+ return this.resolveMainConfig(targetDir, agentName);
175
+ } catch (error) {
176
+ try {
177
+ if (existsSync(tempDir)) {
178
+ await fs.rm(tempDir, { recursive: true, force: true });
179
+ }
180
+ } catch (cleanupError) {
181
+ logger.error(
182
+ `Failed to clean up temp directory: ${cleanupError}. Skipping cleanup...`
183
+ );
184
+ }
185
+ throw RegistryError.installationFailed(
186
+ agentName,
187
+ error instanceof Error ? error.message : String(error)
188
+ );
189
+ }
190
+ }
191
+ /**
192
+ * Resolve a registry agent name to a config path
193
+ * NOTE: Only handles registry names, not file paths (routing done in loadAgentConfig)
194
+ * Handles installing agent if needed
195
+ * @param agentName Name of the agent to resolve
196
+ * @param autoInstall Whether to automatically install missing agents from registry (default: true)
197
+ * @param injectPreferences Whether to inject preferences during auto-installation (default: true)
198
+ */
199
+ async resolveAgent(agentName, autoInstall = true, injectPreferences = true) {
200
+ logger.debug(`Resolving registry agent: ${agentName}`);
201
+ const globalAgentsDir = getDextoGlobalPath("agents");
202
+ const installedPath = path.join(globalAgentsDir, agentName);
203
+ if (existsSync(installedPath)) {
204
+ const mainConfig = this.resolveMainConfig(installedPath, agentName);
205
+ logger.debug(`Resolved installed agent '${agentName}' to: ${mainConfig}`);
206
+ return mainConfig;
207
+ }
208
+ logger.debug(`Agent '${agentName}' not found in installed path: ${installedPath}`);
209
+ if (this.hasAgent(agentName)) {
210
+ if (autoInstall) {
211
+ logger.info(`Installing agent '${agentName}' from registry...`);
212
+ return await this.installAgent(agentName, injectPreferences);
213
+ } else {
214
+ const registry2 = this.getRegistry();
215
+ const available2 = Object.keys(registry2.agents);
216
+ throw RegistryError.agentNotInstalledAutoInstallDisabled(agentName, available2);
217
+ }
218
+ }
219
+ const registry = this.getRegistry();
220
+ const available = Object.keys(registry.agents);
221
+ throw RegistryError.agentNotFound(agentName, available);
222
+ }
223
+ /**
224
+ * Get list of currently installed agents
225
+ */
226
+ async getInstalledAgents() {
227
+ const globalAgentsDir = getDextoGlobalPath("agents");
228
+ if (!existsSync(globalAgentsDir)) {
229
+ return [];
230
+ }
231
+ try {
232
+ const entries = await fs.readdir(globalAgentsDir, { withFileTypes: true });
233
+ return entries.filter((entry) => entry.isDirectory()).map((entry) => entry.name).filter((name) => !name.startsWith(".tmp") && !name.includes(".tmp."));
234
+ } catch (error) {
235
+ logger.error(`Failed to read installed agents directory: ${error}`);
236
+ return [];
237
+ }
238
+ }
239
+ /**
240
+ * Check if an agent is safe to uninstall (not the default-agent which is critical)
241
+ */
242
+ isAgentSafeToUninstall(agentName) {
243
+ return agentName !== "default-agent";
244
+ }
245
+ /**
246
+ * Uninstall an agent by removing its directory
247
+ * @param agentName Name of the agent to uninstall
248
+ * @param force Whether to force uninstall even if agent is protected (default: false)
249
+ */
250
+ async uninstallAgent(agentName, force = false) {
251
+ const globalAgentsDir = getDextoGlobalPath("agents");
252
+ const agentDir = path.join(globalAgentsDir, agentName);
253
+ logger.info(`Uninstalling agent: ${agentName} from ${agentDir}`);
254
+ if (!existsSync(agentDir)) {
255
+ throw RegistryError.agentNotInstalled(agentName);
256
+ }
257
+ if (!force && !this.isAgentSafeToUninstall(agentName)) {
258
+ throw RegistryError.agentProtected(agentName);
259
+ }
260
+ try {
261
+ await fs.rm(agentDir, { recursive: true, force: true });
262
+ logger.info(`\u2713 Removed agent '${agentName}' from ${agentDir}`);
263
+ } catch (error) {
264
+ throw RegistryError.uninstallationFailed(
265
+ agentName,
266
+ error instanceof Error ? error.message : String(error)
267
+ );
268
+ }
269
+ }
270
+ };
271
+ function getAgentRegistry() {
272
+ if (cachedRegistry === null) {
273
+ cachedRegistry = new LocalAgentRegistry();
274
+ }
275
+ return cachedRegistry;
276
+ }
277
+
278
+ export {
279
+ LocalAgentRegistry,
280
+ getAgentRegistry
281
+ };