@botpress/adk 1.19.0-beta.7 → 2.0.0-alpha.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 (233) hide show
  1. package/dist/agent-init/agent-project-generator.d.ts +5 -1
  2. package/dist/agent-init/agent-project-generator.d.ts.map +1 -1
  3. package/dist/agent-project/agent-project.d.ts +3 -3
  4. package/dist/agent-project/agent-project.d.ts.map +1 -1
  5. package/dist/agent-project/agent-resolver.d.ts.map +1 -1
  6. package/dist/agent-project/config-writer.d.ts +1 -1
  7. package/dist/agent-project/config-writer.d.ts.map +1 -1
  8. package/dist/agent-project/dependencies-parser.d.ts.map +1 -1
  9. package/dist/agent-project/dependency-state-to-dependencies.d.ts +11 -0
  10. package/dist/agent-project/dependency-state-to-dependencies.d.ts.map +1 -0
  11. package/dist/agent-project/file-watcher.d.ts.map +1 -1
  12. package/dist/agent-project/types.d.ts +9 -4
  13. package/dist/agent-project/types.d.ts.map +1 -1
  14. package/dist/agent0/capabilities/commands/adk-build.md +6 -5
  15. package/dist/agent0/capabilities/commands/adk-debug.md +1 -1
  16. package/dist/agent0/capabilities/commands/adk-dev-console.md +1 -1
  17. package/dist/agent0/capabilities/commands/adk-document.md +10 -2
  18. package/dist/agent0/capabilities/commands/adk-eval.md +1 -1
  19. package/dist/agent0/capabilities/commands/adk-explain.md +2 -2
  20. package/dist/agent0/capabilities/commands/adk-init.md +2 -2
  21. package/dist/agent0/capabilities/commands/adk-ship.md +1 -1
  22. package/dist/agent0/capabilities/commands/adk-test.md +3 -3
  23. package/dist/agent0/capabilities/commands/adk-validate.md +3 -3
  24. package/dist/agent0/capabilities/skills/adk/SKILL.md +21 -21
  25. package/dist/agent0/capabilities/skills/adk/references/actions.md +245 -239
  26. package/dist/agent0/capabilities/skills/adk/references/advanced-patterns.md +185 -218
  27. package/dist/agent0/capabilities/skills/adk/references/agent-config.md +74 -71
  28. package/dist/agent0/capabilities/skills/adk/references/assets.md +45 -48
  29. package/dist/agent0/capabilities/skills/adk/references/autonomous-execution.md +40 -46
  30. package/dist/agent0/capabilities/skills/adk/references/cli.md +17 -7
  31. package/dist/agent0/capabilities/skills/adk/references/context-api.md +98 -94
  32. package/dist/agent0/capabilities/skills/adk/references/conversation-lifecycle.md +65 -62
  33. package/dist/agent0/capabilities/skills/adk/references/conversations.md +395 -385
  34. package/dist/agent0/capabilities/skills/adk/references/custom-components.md +1 -1
  35. package/dist/agent0/capabilities/skills/adk/references/desk.md +236 -234
  36. package/dist/agent0/capabilities/skills/adk/references/explain-config.md +54 -37
  37. package/dist/agent0/capabilities/skills/adk/references/files.md +301 -306
  38. package/dist/agent0/capabilities/skills/adk/references/integration-actions.md +211 -214
  39. package/dist/agent0/capabilities/skills/adk/references/integrations.md +33 -31
  40. package/dist/agent0/capabilities/skills/adk/references/interfaces.md +13 -12
  41. package/dist/agent0/capabilities/skills/adk/references/knowledge-bases.md +98 -111
  42. package/dist/agent0/capabilities/skills/adk/references/mcp-server.md +6 -0
  43. package/dist/agent0/capabilities/skills/adk/references/messages.md +280 -256
  44. package/dist/agent0/capabilities/skills/adk/references/model-configuration.md +52 -49
  45. package/dist/agent0/capabilities/skills/adk/references/patterns-mistakes.md +102 -101
  46. package/dist/agent0/capabilities/skills/adk/references/plugins.md +15 -15
  47. package/dist/agent0/capabilities/skills/adk/references/tables.md +204 -210
  48. package/dist/agent0/capabilities/skills/adk/references/tags.md +141 -143
  49. package/dist/agent0/capabilities/skills/adk/references/tools.md +191 -199
  50. package/dist/agent0/capabilities/skills/adk/references/triggers.md +331 -336
  51. package/dist/agent0/capabilities/skills/adk/references/workflow-steps.md +132 -96
  52. package/dist/agent0/capabilities/skills/adk/references/workflows.md +479 -464
  53. package/dist/agent0/capabilities/skills/adk/references/zai-agent-reference.md +127 -129
  54. package/dist/agent0/capabilities/skills/adk/references/zai-complete-guide.md +255 -276
  55. package/dist/agent0/capabilities/skills/adk-debugger/SKILL.md +21 -17
  56. package/dist/agent0/capabilities/skills/adk-debugger/references/common-failures.md +25 -25
  57. package/dist/agent0/capabilities/skills/adk-debugger/references/conversation-analysis.md +49 -41
  58. package/dist/agent0/capabilities/skills/adk-debugger/references/debug-workflow.md +20 -14
  59. package/dist/agent0/capabilities/skills/adk-debugger/references/llm-debugging.md +13 -13
  60. package/dist/agent0/capabilities/skills/adk-debugger/references/trace-summarization.md +18 -18
  61. package/dist/agent0/capabilities/skills/adk-debugger/references/traces-and-logs.md +67 -67
  62. package/dist/agent0/capabilities/skills/adk-dev-console/SKILL.md +36 -36
  63. package/dist/agent0/capabilities/skills/adk-dev-console/references/agent-steps.md +14 -6
  64. package/dist/agent0/capabilities/skills/adk-dev-console/references/multi-agent-dashboard.md +13 -13
  65. package/dist/agent0/capabilities/skills/adk-dev-console/references/pages.md +18 -0
  66. package/dist/agent0/capabilities/skills/adk-docs/SKILL.md +13 -13
  67. package/dist/agent0/capabilities/skills/adk-docs/references/doc-standards.md +15 -0
  68. package/dist/agent0/capabilities/skills/adk-evals/SKILL.md +29 -23
  69. package/dist/agent0/capabilities/skills/adk-evals/references/eval-format.md +31 -23
  70. package/dist/agent0/capabilities/skills/adk-evals/references/test-patterns.md +25 -36
  71. package/dist/agent0/capabilities/skills/adk-evals/references/testing-workflow.md +6 -4
  72. package/dist/agent0/config/schema.d.ts.map +1 -1
  73. package/dist/agent0/config/store.d.ts +8 -3
  74. package/dist/agent0/config/store.d.ts.map +1 -1
  75. package/dist/agent0/index.js +214 -59
  76. package/dist/agent0/index.js.map +17 -15
  77. package/dist/agent0/providers/catalog.d.ts.map +1 -1
  78. package/dist/agent0/providers/registry.d.ts.map +1 -1
  79. package/dist/agent0/providers/source.d.ts +8 -3
  80. package/dist/agent0/providers/source.d.ts.map +1 -1
  81. package/dist/agent0/runtime/client.d.ts +4 -3
  82. package/dist/agent0/runtime/client.d.ts.map +1 -1
  83. package/dist/agent0/runtime/engine.d.ts +7 -1
  84. package/dist/agent0/runtime/engine.d.ts.map +1 -1
  85. package/dist/agent0/runtime/manager.d.ts +2 -3
  86. package/dist/agent0/runtime/manager.d.ts.map +1 -1
  87. package/dist/agent0/runtime/process.d.ts +10 -0
  88. package/dist/agent0/runtime/process.d.ts.map +1 -1
  89. package/dist/assets/manager.d.ts +3 -0
  90. package/dist/assets/manager.d.ts.map +1 -1
  91. package/dist/auth/credentials.d.ts +1 -1
  92. package/dist/auth/credentials.d.ts.map +1 -1
  93. package/dist/auth/index.d.ts.map +1 -1
  94. package/dist/auth/service.d.ts.map +1 -1
  95. package/dist/bot-generator/generator.d.ts +22 -0
  96. package/dist/bot-generator/generator.d.ts.map +1 -1
  97. package/dist/bot-generator/integration-sync.d.ts +2 -0
  98. package/dist/bot-generator/integration-sync.d.ts.map +1 -1
  99. package/dist/bot-generator/interface-sync.d.ts +2 -0
  100. package/dist/bot-generator/interface-sync.d.ts.map +1 -1
  101. package/dist/bot-generator/plugin-sync.d.ts +2 -0
  102. package/dist/bot-generator/plugin-sync.d.ts.map +1 -1
  103. package/dist/cognitive/models.d.ts.map +1 -1
  104. package/dist/commands/base-command.d.ts +1 -0
  105. package/dist/commands/base-command.d.ts.map +1 -1
  106. package/dist/commands/bp-cli.d.ts.map +1 -1
  107. package/dist/commands/bp-cli.js +147 -0
  108. package/dist/commands/bp-cli.js.map +12 -0
  109. package/dist/commands/bp-dev-command.d.ts +3 -1
  110. package/dist/commands/bp-dev-command.d.ts.map +1 -1
  111. package/dist/commands/bp-dev-stderr.d.ts +9 -0
  112. package/dist/commands/bp-dev-stderr.d.ts.map +1 -1
  113. package/dist/commands/bp-dev-worker-env.d.ts +7 -0
  114. package/dist/commands/bp-dev-worker-env.d.ts.map +1 -0
  115. package/dist/commands/index.d.ts +1 -0
  116. package/dist/commands/index.d.ts.map +1 -1
  117. package/dist/config/manager.d.ts.map +1 -1
  118. package/dist/dependencies/catalog/catalog-service.d.ts +53 -0
  119. package/dist/dependencies/catalog/catalog-service.d.ts.map +1 -0
  120. package/dist/dependencies/catalog/client-factory.d.ts +33 -0
  121. package/dist/dependencies/catalog/client-factory.d.ts.map +1 -0
  122. package/dist/dependencies/catalog/integration-source.d.ts +34 -0
  123. package/dist/dependencies/catalog/integration-source.d.ts.map +1 -0
  124. package/dist/dependencies/catalog/interface-source.d.ts +23 -0
  125. package/dist/dependencies/catalog/interface-source.d.ts.map +1 -0
  126. package/dist/dependencies/catalog/plugin-source.d.ts +49 -0
  127. package/dist/dependencies/catalog/plugin-source.d.ts.map +1 -0
  128. package/dist/dependencies/catalog/resolution-cache.d.ts +76 -0
  129. package/dist/dependencies/catalog/resolution-cache.d.ts.map +1 -0
  130. package/dist/dependencies/dependency-manager.d.ts +31 -16
  131. package/dist/dependencies/dependency-manager.d.ts.map +1 -1
  132. package/dist/dependencies/errors.d.ts +9 -6
  133. package/dist/dependencies/errors.d.ts.map +1 -1
  134. package/dist/dependencies/index.d.ts +5 -4
  135. package/dist/dependencies/index.d.ts.map +1 -1
  136. package/dist/dependencies/index.js +2309 -1697
  137. package/dist/dependencies/index.js.map +41 -32
  138. package/dist/dependencies/legacy-lock-file.d.ts +15 -0
  139. package/dist/dependencies/legacy-lock-file.d.ts.map +1 -0
  140. package/dist/dependencies/migration.d.ts +19 -0
  141. package/dist/dependencies/migration.d.ts.map +1 -1
  142. package/dist/dependencies/resolvers/integration-resolver.d.ts +4 -3
  143. package/dist/dependencies/resolvers/integration-resolver.d.ts.map +1 -1
  144. package/dist/dependencies/resolvers/plugin-resolver.d.ts +4 -4
  145. package/dist/dependencies/resolvers/plugin-resolver.d.ts.map +1 -1
  146. package/dist/dependencies/snapshot-store.d.ts +59 -0
  147. package/dist/dependencies/snapshot-store.d.ts.map +1 -0
  148. package/dist/dependencies/status-resolver.d.ts +36 -0
  149. package/dist/dependencies/status-resolver.d.ts.map +1 -0
  150. package/dist/dependencies/status.d.ts +214 -0
  151. package/dist/dependencies/status.d.ts.map +1 -0
  152. package/dist/dependencies/types.d.ts +388 -37
  153. package/dist/dependencies/types.d.ts.map +1 -1
  154. package/dist/file-watcher/watcher.d.ts +21 -5
  155. package/dist/file-watcher/watcher.d.ts.map +1 -1
  156. package/dist/generators/action-types.d.ts.map +1 -1
  157. package/dist/generators/client-wrapper.d.ts.map +1 -1
  158. package/dist/index.d.ts +5 -5
  159. package/dist/index.d.ts.map +1 -1
  160. package/dist/index.js +3643 -2345
  161. package/dist/index.js.map +68 -58
  162. package/dist/integrations/config-utils.d.ts +11 -7
  163. package/dist/integrations/config-utils.d.ts.map +1 -1
  164. package/dist/integrations/hub-cache.d.ts +0 -58
  165. package/dist/integrations/hub-cache.d.ts.map +1 -1
  166. package/dist/integrations/index.d.ts +1 -3
  167. package/dist/integrations/index.d.ts.map +1 -1
  168. package/dist/integrations/manager.d.ts +19 -53
  169. package/dist/integrations/manager.d.ts.map +1 -1
  170. package/dist/interfaces/enhanced-cache.d.ts +7 -7
  171. package/dist/interfaces/enhanced-cache.d.ts.map +1 -1
  172. package/dist/interfaces/manager.d.ts +11 -17
  173. package/dist/interfaces/manager.d.ts.map +1 -1
  174. package/dist/interfaces/parser.d.ts.map +1 -1
  175. package/dist/knowledge/manager.d.ts +3 -0
  176. package/dist/knowledge/manager.d.ts.map +1 -1
  177. package/dist/plugins/index.d.ts +0 -1
  178. package/dist/plugins/index.d.ts.map +1 -1
  179. package/dist/plugins/manager.d.ts +16 -48
  180. package/dist/plugins/manager.d.ts.map +1 -1
  181. package/dist/preflight/checker.d.ts +6 -1
  182. package/dist/preflight/checker.d.ts.map +1 -1
  183. package/dist/preflight/dependency-gate.d.ts +37 -0
  184. package/dist/preflight/dependency-gate.d.ts.map +1 -0
  185. package/dist/preflight/index.d.ts +2 -1
  186. package/dist/preflight/index.d.ts.map +1 -1
  187. package/dist/preflight/types.d.ts +18 -0
  188. package/dist/preflight/types.d.ts.map +1 -1
  189. package/dist/runner/script-runner.d.ts.map +1 -1
  190. package/dist/secrets/manager.d.ts.map +1 -1
  191. package/dist/tables/table-manager.d.ts +3 -0
  192. package/dist/tables/table-manager.d.ts.map +1 -1
  193. package/dist/templates/README.md +23 -13
  194. package/dist/templates/blank/agent.config.ts +3 -3
  195. package/dist/templates/blank/src/triggers/index.ts +1 -1
  196. package/dist/templates/botpress-desk/evals/index.eval.ts +1 -1
  197. package/dist/templates/botpress-desk/src/triggers/index.ts +1 -1
  198. package/dist/templates/crm-enrichment/README.md +3 -3
  199. package/dist/templates/crm-enrichment/agent.config.ts +2 -2
  200. package/dist/templates/crm-enrichment/src/conversations/index.ts +1 -1
  201. package/dist/templates/hello-world/agent.config.ts +3 -3
  202. package/dist/templates/hello-world/src/triggers/index.ts +1 -1
  203. package/dist/templates/knowledge-assistant/src/triggers/index.ts +1 -1
  204. package/dist/templates/template.config.json +3 -3
  205. package/dist/test-utils/mock-module.d.ts +29 -0
  206. package/dist/test-utils/mock-module.d.ts.map +1 -0
  207. package/dist/utils/ids.d.ts +10 -0
  208. package/dist/utils/ids.d.ts.map +1 -1
  209. package/dist/utils/require-chat.d.ts.map +1 -1
  210. package/dist/utils/source-map-optimizer.d.ts +10 -11
  211. package/dist/utils/source-map-optimizer.d.ts.map +1 -1
  212. package/dist/workspace/workspace-cache.d.ts +2 -1
  213. package/dist/workspace/workspace-cache.d.ts.map +1 -1
  214. package/package.json +8 -4
  215. package/dist/agent-project/lock-to-dependencies.d.ts +0 -11
  216. package/dist/agent-project/lock-to-dependencies.d.ts.map +0 -1
  217. package/dist/dependencies/lock-file.d.ts +0 -15
  218. package/dist/dependencies/lock-file.d.ts.map +0 -1
  219. package/dist/integrations/enhanced-cache.d.ts +0 -53
  220. package/dist/integrations/enhanced-cache.d.ts.map +0 -1
  221. package/dist/plugins/enhanced-cache.d.ts +0 -53
  222. package/dist/plugins/enhanced-cache.d.ts.map +0 -1
  223. package/dist/templates/blank/package.json +0 -17
  224. package/dist/templates/blank/tsconfig.json +0 -25
  225. package/dist/templates/botpress-desk/package.json +0 -17
  226. package/dist/templates/crm-enrichment/package.json +0 -18
  227. package/dist/templates/crm-enrichment/tsconfig.json +0 -25
  228. package/dist/templates/hello-world/package.json +0 -18
  229. package/dist/templates/hello-world/tsconfig.json +0 -25
  230. package/dist/templates/knowledge-assistant/package.json +0 -18
  231. package/dist/templates/knowledge-assistant/tsconfig.json +0 -25
  232. package/dist/templates/slack-triage/package.json +0 -18
  233. package/dist/templates/slack-triage/tsconfig.json +0 -25
@@ -46,6 +46,42 @@ var __export = (target, all) => {
46
46
  var __esm = (fn, res) => () => (fn && (res = fn(fn = 0)), res);
47
47
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
48
48
 
49
+ // ../analytics/src/errors.ts
50
+ function isAdkError(error) {
51
+ if (error instanceof AdkError)
52
+ return true;
53
+ if (!(error instanceof Error))
54
+ return false;
55
+ return error.constructor?.__IS_ADK_BASE_ERROR === true;
56
+ }
57
+ var AdkError;
58
+ var init_errors = __esm(() => {
59
+ AdkError = class AdkError extends Error {
60
+ static __IS_ADK_BASE_ERROR = true;
61
+ code;
62
+ expected;
63
+ details;
64
+ suggestion;
65
+ constructor(opts) {
66
+ super(opts.message, opts.cause !== undefined ? { cause: opts.cause } : undefined);
67
+ this.name = this.constructor.name;
68
+ this.code = opts.code;
69
+ this.expected = opts.expected ?? false;
70
+ if (opts.details !== undefined) {
71
+ this.details = opts.details;
72
+ }
73
+ if (opts.suggestion !== undefined) {
74
+ this.suggestion = opts.suggestion;
75
+ }
76
+ }
77
+ };
78
+ });
79
+
80
+ // ../analytics/src/index.ts
81
+ var init_src = __esm(() => {
82
+ init_errors();
83
+ });
84
+
49
85
  // src/agent0/types.ts
50
86
  var AGENT0_CONFIG_SCHEMA_VERSION = 1;
51
87
  var AGENT0_SESSION_MODES = ["default", "guided"];
@@ -102,7 +138,7 @@ Schemas use \`z\` from @botpress/sdk (a Zod fork) — never import Zod directly.
102
138
  - Nothing happens → check \`adk logs error --format json\` for silent failures, then check if the handler is registered
103
139
  - When in doubt → start with \`adk check --format json\`, then \`adk logs error --format json\`, then traces
104
140
 
105
- **Integrations.** First check if the integration already exists with \`adk list\`. Only search the hub (\`adk search <query>\`) when adding a new integration. Get details with \`adk info <name>\` to understand actions, events, channels, and config requirements. Add it with \`adk add <name>\` after the developer confirms.
141
+ **Integrations.** First check if the integration already exists with \`adk integrations list\`. Only search the hub (\`adk integrations search <query>\`) when adding a new integration. Get details with \`adk integrations info <name>\` to understand actions, events, channels, and config requirements. Add it with \`adk integrations add <name>\` after the developer confirms.
106
142
 
107
143
  **Test iteratively.** To send messages, use \`adk chat --single "<message>" --format json\`. Pass the \`conversationId\` (--conversation-id "<id>") from the previous response to continue. Only test against the local dev bot.
108
144
 
@@ -250,7 +286,7 @@ Your shell is already set to the agent project root. Run all commands directly
250
286
  Before planning or writing, inspect enough local context:
251
287
  - Run \`adk status --format json\` if available to learn project state.
252
288
  - Read \`agent.config.ts\`.
253
- - Run \`adk list --format json\` before deciding integrations.
289
+ - Run \`adk integrations list --format json\` before deciding integrations.
254
290
  - Glob \`src/\` and skim existing primitives if the project is not empty.
255
291
  - For conversation changes, read every \`src/conversations/*.ts\` file and check channel overlap. Extend an existing overlapping handler; only create a new conversation file when channels are disjoint or the developer explicitly asks.
256
292
 
@@ -258,7 +294,7 @@ Never read or display \`.env\` files or credentials. If a secret/config value is
258
294
 
259
295
  ## Building Rules
260
296
 
261
- - Use \`adk info <integration> --format json\` before adding an integration when possible. Pin the version when you know it.
297
+ - Use \`adk integrations info <integration> --format json\` before adding an integration when possible. Pin the version when you know it.
262
298
  - Write files in dependency order: tables/knowledge first, actions/tools next, workflows next, conversations/triggers last.
263
299
  - Add seed/demo data only when useful and clearly placeholder.
264
300
  - Use static imports. Avoid dynamic imports except for documented ADK-safe cases.
@@ -498,6 +534,7 @@ async function ensureAgent0ProjectDirs(projectPath, options = {}) {
498
534
  return paths;
499
535
  }
500
536
  // src/agent0/config/schema.ts
537
+ init_src();
501
538
  import { z } from "@botpress/sdk";
502
539
  var agent0ProviderAuthSchema = z.object({
503
540
  type: z.literal("api_key"),
@@ -543,7 +580,11 @@ function parseAgent0Config(value) {
543
580
  const config = agent0ConfigSchema.parse(value);
544
581
  for (const [key, connection] of Object.entries(config.providers)) {
545
582
  if (key !== connection.providerId) {
546
- throw new Error(`Provider connection key "${key}" does not match providerId "${connection.providerId}"`);
583
+ throw new AdkError({
584
+ code: "AGENT0_CONFIG_KEY_MISMATCH",
585
+ message: `Provider connection key "${key}" does not match providerId "${connection.providerId}"`,
586
+ expected: false
587
+ });
547
588
  }
548
589
  }
549
590
  return config;
@@ -577,14 +618,12 @@ function hasAgent0ProviderAuth(connection) {
577
618
  return Boolean(connection?.auth?.apiKey);
578
619
  }
579
620
  // src/agent0/config/store.ts
621
+ init_src();
580
622
  import { readFile, rename, writeFile, chmod as chmod2 } from "node:fs/promises";
581
623
  import { dirname as dirname2 } from "node:path";
582
- class Agent0ConfigError extends Error {
583
- cause;
584
- constructor(message, cause) {
585
- super(message);
586
- this.cause = cause;
587
- this.name = "Agent0ConfigError";
624
+ class Agent0ConfigError extends AdkError {
625
+ constructor(message, cause, code = "AGENT0_CONFIG_INVALID") {
626
+ super({ code, message, expected: true, cause });
588
627
  }
589
628
  }
590
629
 
@@ -603,7 +642,7 @@ class Agent0ConfigStore {
603
642
  } catch (error) {
604
643
  if (isFileNotFoundError(error))
605
644
  return createDefaultAgent0Config(this.now());
606
- throw new Agent0ConfigError(`Failed to read Agent(0) config at ${this.configPath}`, error);
645
+ throw new Agent0ConfigError(`Failed to read Agent(0) config at ${this.configPath}`, error, "AGENT0_CONFIG_READ_FAILED");
607
646
  }
608
647
  try {
609
648
  return parseAgent0Config(JSON.parse(content));
@@ -649,6 +688,7 @@ function isFileNotFoundError(error) {
649
688
  return typeof error === "object" && error !== null && "code" in error && error.code === "ENOENT";
650
689
  }
651
690
  // src/agent0/providers/catalog.ts
691
+ init_src();
652
692
  var apiKey = (apiKeyLabel = "API key", baseURL) => ({
653
693
  type: "api_key",
654
694
  apiKeyLabel,
@@ -885,12 +925,20 @@ function getAgent0ProviderCatalogEntry(providerId) {
885
925
  function requireAgent0ProviderCatalogEntry(providerId) {
886
926
  const entry = getAgent0ProviderCatalogEntry(providerId);
887
927
  if (!entry)
888
- throw new Error(`Unknown Agent(0) provider: ${providerId}`);
928
+ throw new AdkError({
929
+ code: "AGENT0_PROVIDER_UNKNOWN",
930
+ message: `Unknown Agent(0) provider: ${providerId}`,
931
+ expected: false
932
+ });
889
933
  return entry;
890
934
  }
891
935
  function toAgent0AvailableModel(entry, model) {
892
936
  if (model.providerId !== entry.id) {
893
- throw new Error(`Agent(0) model ${model.modelId} belongs to ${model.providerId}, not ${entry.id}`);
937
+ throw new AdkError({
938
+ code: "AGENT0_MODEL_MISMATCH",
939
+ message: `Agent(0) model ${model.modelId} belongs to ${model.providerId}, not ${entry.id}`,
940
+ expected: false
941
+ });
894
942
  }
895
943
  return {
896
944
  id: `${entry.id}/${model.modelId}`,
@@ -905,6 +953,12 @@ function toAgent0AvailableModel(entry, model) {
905
953
  tags: model.tags ? [...model.tags] : undefined
906
954
  };
907
955
  }
956
+ // src/agent0/providers/registry.ts
957
+ init_src();
958
+
959
+ // src/agent0/providers/source.ts
960
+ init_src();
961
+
908
962
  // src/cognitive/models.ts
909
963
  import { z as z2 } from "@botpress/sdk";
910
964
  var DEFAULT_BOTPRESS_API_URL = "https://api.botpress.cloud";
@@ -962,12 +1016,9 @@ var DEFAULT_MODELS_DEV_API_URL = "https://models.dev/api.json";
962
1016
  var DEFAULT_CACHE_TTL_MS = 5 * 60 * 1000;
963
1017
  var DEFAULT_MODELS_DEV_FETCH_TIMEOUT_MS = 1e4;
964
1018
 
965
- class Agent0ProviderCatalogSourceError extends Error {
966
- cause;
1019
+ class Agent0ProviderCatalogSourceError extends AdkError {
967
1020
  constructor(message, cause) {
968
- super(message);
969
- this.cause = cause;
970
- this.name = "Agent0ProviderCatalogSourceError";
1021
+ super({ code: "AGENT0_PROVIDER_CATALOG_UNAVAILABLE", message, expected: true, cause });
971
1022
  }
972
1023
  }
973
1024
 
@@ -1295,7 +1346,11 @@ class Agent0ProviderRegistry {
1295
1346
  async putProviderAuth(providerId, input) {
1296
1347
  const entry = requireAgent0ProviderCatalogEntry(providerId);
1297
1348
  if (entry.auth.type !== "api_key") {
1298
- throw new Error(`Agent(0) provider ${providerId} does not support API-key authentication`);
1349
+ throw new AdkError({
1350
+ code: "AGENT0_PROVIDER_KEY_UNSUPPORTED",
1351
+ message: `Agent(0) provider ${providerId} does not support API-key authentication`,
1352
+ expected: true
1353
+ });
1299
1354
  }
1300
1355
  const now = this.now().toISOString();
1301
1356
  const config = await this.store.update((draft) => {
@@ -1332,11 +1387,20 @@ class Agent0ProviderRegistry {
1332
1387
  async setProviderEnabled(providerId, enabled) {
1333
1388
  const entry = requireAgent0ProviderCatalogEntry(providerId);
1334
1389
  if (enabled && entry.status !== "available") {
1335
- throw new Error(`Agent(0) provider ${providerId} is not available yet`);
1390
+ throw new AdkError({
1391
+ code: "AGENT0_PROVIDER_UNAVAILABLE",
1392
+ message: `Agent(0) provider ${providerId} is not available yet`,
1393
+ expected: true
1394
+ });
1336
1395
  }
1337
1396
  const current = await this.store.read();
1338
1397
  if (enabled && entry.auth.type === "api_key" && !hasAgent0ProviderAuth(current.providers[providerId])) {
1339
- throw new Error(`Agent(0) provider ${providerId} must be connected before it can be enabled`);
1398
+ throw new AdkError({
1399
+ code: "AGENT0_PROVIDER_NOT_CONNECTED",
1400
+ message: `Agent(0) provider ${providerId} must be connected before it can be enabled`,
1401
+ expected: true,
1402
+ suggestion: `Connect the ${providerId} provider before enabling it.`
1403
+ });
1340
1404
  }
1341
1405
  const now = this.now().toISOString();
1342
1406
  const config = await this.store.update((draft) => {
@@ -1421,7 +1485,11 @@ function countModelsByProvider(models) {
1421
1485
  }
1422
1486
  return counts;
1423
1487
  }
1488
+ // src/agent0/runtime/client.ts
1489
+ init_src();
1490
+
1424
1491
  // src/agent0/runtime/process.ts
1492
+ init_src();
1425
1493
  import { execFileSync, spawn } from "node:child_process";
1426
1494
  import { randomUUID } from "node:crypto";
1427
1495
  import { chmodSync, copyFileSync, createWriteStream, existsSync as existsSync3, mkdirSync, renameSync, rmSync } from "node:fs";
@@ -1430,6 +1498,10 @@ import { arch, homedir as homedir2, platform as platform2, tmpdir } from "node:o
1430
1498
  import { delimiter, dirname as dirname3, join as join4, resolve as resolve2 } from "node:path";
1431
1499
  import { pipeline } from "node:stream/promises";
1432
1500
 
1501
+ // src/agent0/runtime/engine.ts
1502
+ init_src();
1503
+ import { createHash as createHash2 } from "node:crypto";
1504
+
1433
1505
  // src/agent0/runtime/permissions.ts
1434
1506
  var AGENT0_BUILT_IN_MCP_PERMISSION = "adk_*";
1435
1507
  var AGENT0_HIDDEN_OPENCODE_SKILL = "customize-opencode";
@@ -1601,7 +1673,8 @@ function buildAgent0CognitiveProvider(options) {
1601
1673
  {
1602
1674
  id: model.modelId,
1603
1675
  name: model.name,
1604
- ...renderCognitiveModelCostAndLimits(model)
1676
+ ...renderCognitiveModelCostAndLimits(model),
1677
+ ...renderCognitiveModelModalities(model)
1605
1678
  }
1606
1679
  ]));
1607
1680
  return {
@@ -1611,14 +1684,15 @@ function buildAgent0CognitiveProvider(options) {
1611
1684
  models
1612
1685
  };
1613
1686
  }
1614
- function buildAgent0OpenCodeEnv(paths2, config, authContent = {}) {
1687
+ function buildAgent0OpenCodeEnv(paths2, configOrContent, authContent = {}) {
1688
+ const configContent = typeof configOrContent === "string" ? configOrContent : JSON.stringify(configOrContent);
1615
1689
  return {
1616
1690
  XDG_CONFIG_HOME: paths2.xdgConfigHome,
1617
1691
  XDG_DATA_HOME: paths2.xdgDataHome,
1618
1692
  XDG_CACHE_HOME: paths2.xdgCacheHome,
1619
1693
  XDG_STATE_HOME: paths2.xdgStateHome,
1620
1694
  OPENCODE_CONFIG_DIR: paths2.engineConfigDir,
1621
- OPENCODE_CONFIG_CONTENT: JSON.stringify(config),
1695
+ OPENCODE_CONFIG_CONTENT: configContent,
1622
1696
  OPENCODE_AUTH_CONTENT: JSON.stringify(authContent),
1623
1697
  OPENCODE_TEST_HOME: paths2.fakeHomeDir,
1624
1698
  OPENCODE_PURE: "1",
@@ -1635,11 +1709,13 @@ function buildAgent0OpenCodeEnv(paths2, config, authContent = {}) {
1635
1709
  }
1636
1710
  function renderAgent0OpenCodeRuntime(options) {
1637
1711
  const config = buildAgent0OpenCodeConfig(options);
1712
+ const configContent = JSON.stringify(config);
1638
1713
  const authContent = options.agent0Config ? buildAgent0OpenCodeAuthContent(options.agent0Config) : {};
1639
1714
  return {
1640
1715
  config,
1641
1716
  authContent,
1642
- env: buildAgent0OpenCodeEnv(options.paths, config, authContent)
1717
+ renderedOpenCodeConfigHash: sha256(configContent),
1718
+ env: buildAgent0OpenCodeEnv(options.paths, configContent, authContent)
1643
1719
  };
1644
1720
  }
1645
1721
  async function prepareAgent0OpenCodeRuntime(options) {
@@ -1652,12 +1728,20 @@ function getAgent0OpenCodeAuthenticatedProviders(config) {
1652
1728
  return [];
1653
1729
  const entry = getAgent0ProviderCatalogEntry(connection.providerId);
1654
1730
  if (!entry)
1655
- throw new Error(`Unknown Agent(0) provider: ${connection.providerId}`);
1731
+ throw new AdkError({
1732
+ code: "AGENT0_PROVIDER_UNKNOWN",
1733
+ message: `Unknown Agent(0) provider: ${connection.providerId}`,
1734
+ expected: false
1735
+ });
1656
1736
  if (entry.firstParty || entry.auth.type !== "api_key")
1657
1737
  return [];
1658
1738
  const providerId = entry.modelSource?.type === "models.dev" ? entry.modelSource.providerId ?? entry.id : undefined;
1659
1739
  if (!providerId)
1660
- throw new Error(`Agent(0) provider ${connection.providerId} has no OpenCode provider source`);
1740
+ throw new AdkError({
1741
+ code: "AGENT0_PROVIDER_SOURCE_MISSING",
1742
+ message: `Agent(0) provider ${connection.providerId} has no OpenCode provider source`,
1743
+ expected: false
1744
+ });
1661
1745
  return [[providerId, { ...connection, auth: connection.auth }]];
1662
1746
  });
1663
1747
  }
@@ -1676,6 +1760,20 @@ function renderCognitiveModelCostAndLimits(model) {
1676
1760
  }
1677
1761
  };
1678
1762
  }
1763
+ function sha256(content) {
1764
+ return createHash2("sha256").update(content).digest("hex");
1765
+ }
1766
+ function renderCognitiveModelModalities(model) {
1767
+ if (!model.tags?.includes("vision"))
1768
+ return {};
1769
+ return {
1770
+ attachment: true,
1771
+ modalities: {
1772
+ input: ["text", "image"],
1773
+ output: ["text"]
1774
+ }
1775
+ };
1776
+ }
1679
1777
 
1680
1778
  // src/agent0/runtime/process.ts
1681
1779
  var DEFAULT_STARTUP_TIMEOUT_MS = 15000;
@@ -1710,6 +1808,25 @@ var PROVIDER_AUTH_ENV_KEYS = new Set([
1710
1808
  "TOGETHERAI_API_KEY",
1711
1809
  "XAI_API_KEY"
1712
1810
  ]);
1811
+
1812
+ class Agent0OpenCodeStartupTimeoutError extends AdkError {
1813
+ timeoutMs;
1814
+ startupOutput;
1815
+ constructor(timeoutMs, options = {}) {
1816
+ super({
1817
+ code: "AGENT0_OPENCODE_STARTUP_TIMEOUT",
1818
+ message: `Agent(0) private OpenCode runtime did not start within ${timeoutMs}ms` + (options.startupOutput ? `
1819
+ ${options.startupOutput}` : ""),
1820
+ expected: true,
1821
+ details: { timeoutMs },
1822
+ cause: options.cause
1823
+ });
1824
+ this.timeoutMs = timeoutMs;
1825
+ if (options.startupOutput !== undefined) {
1826
+ this.startupOutput = options.startupOutput;
1827
+ }
1828
+ }
1829
+ }
1713
1830
  function sanitizeAgent0OpenCodeBaseEnv(env) {
1714
1831
  return Object.fromEntries(Object.entries(env).filter(([key]) => !shouldStripEnv(key)));
1715
1832
  }
@@ -1753,7 +1870,11 @@ function getCachedAgent0OpenCodeBinary(options) {
1753
1870
  async function downloadAgent0OpenCodeBinary(options) {
1754
1871
  const version = options.version ?? OPENCODE_VERSION;
1755
1872
  if (version === "0.0.0") {
1756
- throw new Error("Unable to resolve pinned opencode-ai version");
1873
+ throw new AdkError({
1874
+ code: "AGENT0_OPENCODE_VERSION_UNRESOLVED",
1875
+ message: "Unable to resolve pinned opencode-ai version",
1876
+ expected: false
1877
+ });
1757
1878
  }
1758
1879
  const { name, binary } = getAgent0OpenCodePlatformPackage();
1759
1880
  const tarballUrl = `https://registry.npmjs.org/${name}/-/${name}-${version}.tgz`;
@@ -1767,7 +1888,11 @@ async function downloadAgent0OpenCodeBinary(options) {
1767
1888
  const tarPath = join4(tmpDirPath, "opencode.tgz");
1768
1889
  const response = await fetchImpl(tarballUrl);
1769
1890
  if (!response.ok || !response.body) {
1770
- throw new Error(`Failed to download ${tarballUrl}: ${response.status} ${response.statusText}`);
1891
+ throw new AdkError({
1892
+ code: "AGENT0_OPENCODE_DOWNLOAD_FAILED",
1893
+ message: `Failed to download ${tarballUrl}: ${response.status} ${response.statusText}`,
1894
+ expected: true
1895
+ });
1771
1896
  }
1772
1897
  await pipeline(response.body, createWriteStream(tarPath));
1773
1898
  const extractDir = join4(tmpDirPath, "extracted");
@@ -1775,7 +1900,11 @@ async function downloadAgent0OpenCodeBinary(options) {
1775
1900
  execFileSync("tar", ["xzf", tarPath, "-C", extractDir, `package/bin/${binary}`]);
1776
1901
  const extractedBinary = join4(extractDir, "package", "bin", binary);
1777
1902
  if (!existsSync3(extractedBinary)) {
1778
- throw new Error(`Binary not found at expected path package/bin/${binary} in ${name}@${version} tarball`);
1903
+ throw new AdkError({
1904
+ code: "AGENT0_OPENCODE_DOWNLOAD_FAILED",
1905
+ message: `Binary not found at expected path package/bin/${binary} in ${name}@${version} tarball`,
1906
+ expected: true
1907
+ });
1779
1908
  }
1780
1909
  const destBinary = join4(cacheDir, binary);
1781
1910
  const tmpBinary = `${destBinary}.tmp`;
@@ -1833,6 +1962,7 @@ async function startAgent0OpenCodeProcess(options) {
1833
1962
  return {
1834
1963
  baseURL,
1835
1964
  authHeaders: buildAgent0OpenCodeAuthHeaders(serverAuth),
1965
+ renderedOpenCodeConfigHash: runtime.renderedOpenCodeConfigHash,
1836
1966
  pid: child.pid,
1837
1967
  stop: () => stopAgent0OpenCodeProcess(child)
1838
1968
  };
@@ -1865,7 +1995,7 @@ async function waitForOpenCodeServer(child, options) {
1865
1995
  return new Promise((resolveReady, rejectReady) => {
1866
1996
  let settled = false;
1867
1997
  const timeout = setTimeout(() => {
1868
- finish(new Error(`Agent(0) private OpenCode runtime did not start within ${options.timeoutMs}ms`));
1998
+ finish(new Agent0OpenCodeStartupTimeoutError(options.timeoutMs));
1869
1999
  }, options.timeoutMs);
1870
2000
  const finish = (error, url) => {
1871
2001
  if (settled)
@@ -1913,23 +2043,32 @@ function appendStartupOutput(error, chunks) {
1913
2043
  const output = chunks.join("").trim();
1914
2044
  if (!output)
1915
2045
  return error;
1916
- return new Error(`${error.message}
2046
+ if (error instanceof Agent0OpenCodeStartupTimeoutError) {
2047
+ return new Agent0OpenCodeStartupTimeoutError(error.timeoutMs, {
2048
+ cause: error.cause,
2049
+ startupOutput: output
2050
+ });
2051
+ }
2052
+ const wrapped = new Error(`${error.message}
1917
2053
  ${output}`);
2054
+ wrapped.cause = error;
2055
+ return wrapped;
1918
2056
  }
1919
2057
  function prependPath(dir, currentPath) {
1920
2058
  return currentPath ? `${dir}${delimiter}${currentPath}` : dir;
1921
2059
  }
1922
2060
 
1923
2061
  // src/agent0/runtime/client.ts
1924
- class Agent0RuntimeClientError extends Error {
1925
- cause;
1926
- code;
2062
+ class Agent0RuntimeClientError extends AdkError {
1927
2063
  status;
1928
2064
  constructor(code, message, options = {}) {
1929
- super(message);
1930
- this.name = "Agent0RuntimeClientError";
1931
- this.code = code;
1932
- this.cause = options.cause;
2065
+ super({
2066
+ code,
2067
+ message,
2068
+ expected: code === "ENGINE_UNAVAILABLE",
2069
+ cause: options.cause,
2070
+ details: options.status !== undefined ? { status: options.status } : undefined
2071
+ });
1933
2072
  this.status = options.status;
1934
2073
  }
1935
2074
  }
@@ -1952,7 +2091,7 @@ function createAgent0RuntimeClient(options) {
1952
2091
  path: "/path",
1953
2092
  searchParams: { directory: options.projectPath }
1954
2093
  });
1955
- return normalizeAgent0RuntimeStatus(pathInfo, options.projectPath);
2094
+ return normalizeAgent0RuntimeStatus(pathInfo, options.projectPath, options.engine.renderedOpenCodeConfigHash);
1956
2095
  },
1957
2096
  async listSessions() {
1958
2097
  const sessions = await fetchAgent0OpenCodeJson({
@@ -1996,15 +2135,23 @@ function createAgent0RuntimeClient(options) {
1996
2135
  };
1997
2136
  },
1998
2137
  async sendMessage(sessionId, input) {
1999
- const message = await fetchAgent0OpenCodeJson({
2000
- engine: options.engine,
2001
- fetch: fetchImpl,
2002
- path: `/session/${encodeURIComponent(sessionId)}/message`,
2003
- method: "POST",
2004
- searchParams: { directory: options.projectPath },
2005
- body: toOpenCodePromptInput(input)
2006
- });
2007
- return normalizeAgent0Message(message);
2138
+ const send = async () => {
2139
+ const message2 = await fetchAgent0OpenCodeJson({
2140
+ engine: options.engine,
2141
+ fetch: fetchImpl,
2142
+ path: `/session/${encodeURIComponent(sessionId)}/message`,
2143
+ method: "POST",
2144
+ searchParams: { directory: options.projectPath },
2145
+ body: toOpenCodePromptInput(input)
2146
+ });
2147
+ return normalizeAgent0Message(message2);
2148
+ };
2149
+ let message = await send();
2150
+ for (let retry = 0;retry < EMPTY_COMPLETION_MAX_RETRIES && input.generateReply !== false && isEmptyCompletion(message); retry++) {
2151
+ await new Promise((resolve3) => setTimeout(resolve3, EMPTY_COMPLETION_RETRY_DELAY_MS));
2152
+ message = await send();
2153
+ }
2154
+ return message;
2008
2155
  },
2009
2156
  async abortSession(sessionId) {
2010
2157
  const result = await fetchAgent0OpenCodeJson({
@@ -2519,6 +2666,11 @@ function normalizeAgent0MessageInfo(info) {
2519
2666
  ...isRecord2(info.error) ? { error: { message: normalizeErrorMessage(info.error) } } : {}
2520
2667
  };
2521
2668
  }
2669
+ var EMPTY_COMPLETION_MAX_RETRIES = 1;
2670
+ var EMPTY_COMPLETION_RETRY_DELAY_MS = 500;
2671
+ function isEmptyCompletion(message) {
2672
+ return message.role === "assistant" && message.completed && message.error === undefined && message.parts.length === 0 && (message.usage?.outputTokens ?? 0) === 0;
2673
+ }
2522
2674
  function normalizeAgent0Message(value) {
2523
2675
  if (!isRecord2(value) || !isRecord2(value.info) || !Array.isArray(value.parts)) {
2524
2676
  throw new Agent0RuntimeClientError("ENGINE_INVALID_RESPONSE", "Agent(0) private runtime returned an invalid message response");
@@ -2928,28 +3080,30 @@ function toOpenCodeCreateSessionInput(input) {
2928
3080
  }
2929
3081
  };
2930
3082
  }
2931
- function normalizeAgent0RuntimeStatus(value, projectPath) {
3083
+ function normalizeAgent0RuntimeStatus(value, projectPath, renderedOpenCodeConfigHash) {
2932
3084
  if (!isRecord2(value) || typeof value.directory !== "string" || typeof value.worktree !== "string") {
2933
3085
  throw new Agent0RuntimeClientError("ENGINE_INVALID_RESPONSE", "Agent(0) private runtime returned an invalid path response");
2934
3086
  }
2935
3087
  return {
2936
3088
  state: "running",
2937
3089
  projectPath,
2938
- worktreePath: value.worktree
3090
+ worktreePath: value.worktree,
3091
+ ...renderedOpenCodeConfigHash === undefined ? {} : { renderedOpenCodeConfigHash }
2939
3092
  };
2940
3093
  }
2941
3094
  function isRecord2(value) {
2942
3095
  return typeof value === "object" && value !== null && !Array.isArray(value);
2943
3096
  }
2944
3097
  // src/agent0/runtime/manager.ts
2945
- class Agent0RuntimeManagerError extends Error {
2946
- code;
2947
- cause;
3098
+ init_src();
3099
+ class Agent0RuntimeManagerError extends AdkError {
2948
3100
  constructor(code, message, options = {}) {
2949
- super(message);
2950
- this.name = "Agent0RuntimeManagerError";
2951
- this.code = code;
2952
- this.cause = options.cause;
3101
+ super({
3102
+ code,
3103
+ message,
3104
+ expected: code === "RUNTIME_NOT_RUNNING",
3105
+ cause: options.cause
3106
+ });
2953
3107
  }
2954
3108
  }
2955
3109
 
@@ -3225,6 +3379,7 @@ export {
3225
3379
  Agent0RuntimeClientError,
3226
3380
  Agent0ProviderRegistry,
3227
3381
  Agent0ProviderCatalogSourceError,
3382
+ Agent0OpenCodeStartupTimeoutError,
3228
3383
  Agent0ModelsDevCatalogSource,
3229
3384
  Agent0ConfigStore,
3230
3385
  Agent0ConfigError,
@@ -3245,4 +3400,4 @@ export {
3245
3400
  AGENT0_BUILT_IN_MCP_PERMISSION
3246
3401
  };
3247
3402
 
3248
- //# debugId=5A9AB7B1FC2F63C264756E2164756E21
3403
+ //# debugId=D54D2C6D79749EC864756E2164756E21