@botpress/adk-cli 1.5.10 → 1.5.12

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 (2) hide show
  1. package/dist/cli.js +102 -71
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -314312,7 +314312,7 @@ var import_const, import_const2, __create4, __defProp6, __getOwnPropDesc3, __get
314312
314312
  Object.assign(wf3, response.workflow);
314313
314313
  }
314314
314314
  return response;
314315
- }, DEFAULT_MAX_ATTEMPTS = 5, MIN_STEP_REMAINING_TIME_MS = 1e4, storage2, step = async (name2, run, options = {}) => {
314315
+ }, import_ms22, DEFAULT_MAX_ATTEMPTS = 5, MIN_STEP_REMAINING_TIME_MS = 1e4, storage2, step = async (name2, run, options = {}) => {
314316
314316
  return _step(name2, run, options);
314317
314317
  }, workflowStepContextSchema, workflowExecutionContextSchema, StepSymbol, BaseWorkflowInstance, Definitions, TableSource, nameStartChar = ":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD", nameChar, nameRegexp, regexName, isName = function(string) {
314318
314318
  const match22 = regexName.exec(string);
@@ -315684,7 +315684,7 @@ var init_internal = __esm(() => {
315684
315684
  });
315685
315685
  init_define_PACKAGE_VERSIONS = __esm2({
315686
315686
  "<define:__PACKAGE_VERSIONS__>"() {
315687
- define_PACKAGE_VERSIONS_default = { runtime: "1.3.10", adk: "not-installed", sdk: "4.17.0", llmz: "0.0.26", zai: "2.1.16", cognitive: "0.1.47" };
315687
+ define_PACKAGE_VERSIONS_default = { runtime: "1.3.12", adk: "not-installed", sdk: "4.17.0", llmz: "0.0.26", zai: "2.1.16", cognitive: "0.1.47" };
315688
315688
  }
315689
315689
  });
315690
315690
  init_globalThis = __esm2({
@@ -338765,41 +338765,41 @@ function print() { __p += __j.call(arguments, '') }
338765
338765
  return;
338766
338766
  }
338767
338767
  }
338768
- function fmtShort(ms22) {
338769
- var msAbs = Math.abs(ms22);
338768
+ function fmtShort(ms32) {
338769
+ var msAbs = Math.abs(ms32);
338770
338770
  if (msAbs >= d3) {
338771
- return Math.round(ms22 / d3) + "d";
338771
+ return Math.round(ms32 / d3) + "d";
338772
338772
  }
338773
338773
  if (msAbs >= h3) {
338774
- return Math.round(ms22 / h3) + "h";
338774
+ return Math.round(ms32 / h3) + "h";
338775
338775
  }
338776
338776
  if (msAbs >= m2) {
338777
- return Math.round(ms22 / m2) + "m";
338777
+ return Math.round(ms32 / m2) + "m";
338778
338778
  }
338779
338779
  if (msAbs >= s2) {
338780
- return Math.round(ms22 / s2) + "s";
338780
+ return Math.round(ms32 / s2) + "s";
338781
338781
  }
338782
- return ms22 + "ms";
338782
+ return ms32 + "ms";
338783
338783
  }
338784
- function fmtLong(ms22) {
338785
- var msAbs = Math.abs(ms22);
338784
+ function fmtLong(ms32) {
338785
+ var msAbs = Math.abs(ms32);
338786
338786
  if (msAbs >= d3) {
338787
- return plural(ms22, msAbs, d3, "day");
338787
+ return plural(ms32, msAbs, d3, "day");
338788
338788
  }
338789
338789
  if (msAbs >= h3) {
338790
- return plural(ms22, msAbs, h3, "hour");
338790
+ return plural(ms32, msAbs, h3, "hour");
338791
338791
  }
338792
338792
  if (msAbs >= m2) {
338793
- return plural(ms22, msAbs, m2, "minute");
338793
+ return plural(ms32, msAbs, m2, "minute");
338794
338794
  }
338795
338795
  if (msAbs >= s2) {
338796
- return plural(ms22, msAbs, s2, "second");
338796
+ return plural(ms32, msAbs, s2, "second");
338797
338797
  }
338798
- return ms22 + " ms";
338798
+ return ms32 + " ms";
338799
338799
  }
338800
- function plural(ms22, msAbs, n3, name2) {
338800
+ function plural(ms32, msAbs, n3, name2) {
338801
338801
  var isPlural = msAbs >= n3 * 1.5;
338802
- return Math.round(ms22 / n3) + " " + name2 + (isPlural ? "s" : "");
338802
+ return Math.round(ms32 / n3) + " " + name2 + (isPlural ? "s" : "");
338803
338803
  }
338804
338804
  }
338805
338805
  });
@@ -338842,8 +338842,8 @@ function print() { __p += __j.call(arguments, '') }
338842
338842
  }
338843
338843
  const self2 = debug;
338844
338844
  const curr = Number(/* @__PURE__ */ new Date);
338845
- const ms22 = curr - (prevTime || curr);
338846
- self2.diff = ms22;
338845
+ const ms32 = curr - (prevTime || curr);
338846
+ self2.diff = ms32;
338847
338847
  self2.prev = prevTime;
338848
338848
  self2.curr = curr;
338849
338849
  prevTime = curr;
@@ -351164,6 +351164,7 @@ ${iteration.status.execution_error.stack}`;
351164
351164
  init_define_PACKAGE_VERSIONS();
351165
351165
  init_define_BUILD();
351166
351166
  init_define_PACKAGE_VERSIONS();
351167
+ import_ms22 = __toESM4(require_ms2(), 1);
351167
351168
  init_define_BUILD();
351168
351169
  init_define_PACKAGE_VERSIONS();
351169
351170
  init_define_BUILD();
@@ -351201,10 +351202,10 @@ ${iteration.status.execution_error.stack}`;
351201
351202
  workflowControlContext.abort();
351202
351203
  throw createStepSignal();
351203
351204
  };
351204
- step.sleep = async (name2, ms22) => {
351205
+ step.sleep = async (name2, ms32) => {
351205
351206
  await _step(name2, async () => {
351206
351207
  const remainingTime = context.get("runtime").getRemainingExecutionTimeInMs();
351207
- if (remainingTime - MIN_STEP_REMAINING_TIME_MS <= ms22 || ms22 >= 1e4) {
351208
+ if (remainingTime - MIN_STEP_REMAINING_TIME_MS <= ms32 || ms32 >= 1e4) {
351208
351209
  const client = context.get("client");
351209
351210
  const workflowControlContext = context.get("workflowControlContext");
351210
351211
  await client.createEvent({
@@ -351212,7 +351213,7 @@ ${iteration.status.execution_error.stack}`;
351212
351213
  payload: {},
351213
351214
  workflowId: workflowControlContext.workflow.id,
351214
351215
  schedule: {
351215
- delay: ms22
351216
+ delay: ms32
351216
351217
  }
351217
351218
  });
351218
351219
  await updateWorkflow({
@@ -351221,15 +351222,15 @@ ${iteration.status.execution_error.stack}`;
351221
351222
  });
351222
351223
  workflowControlContext.abort();
351223
351224
  } else {
351224
- await new Promise((resolve) => void setTimeout(resolve, ms22));
351225
+ await new Promise((resolve) => void setTimeout(resolve, ms32));
351225
351226
  }
351226
351227
  }, {}, {
351227
351228
  stepType: "sleep"
351228
351229
  });
351229
351230
  };
351230
351231
  step.sleepUntil = async (name2, date) => {
351231
- const ms22 = Math.max(0, new Date(date).getTime() - Date.now() - MIN_STEP_REMAINING_TIME_MS);
351232
- await step.sleep(name2, ms22);
351232
+ const ms32 = Math.max(0, new Date(date).getTime() - Date.now() - MIN_STEP_REMAINING_TIME_MS);
351233
+ await step.sleep(name2, ms32);
351233
351234
  };
351234
351235
  step.waitForWorkflow = async (name2, workflowId) => {
351235
351236
  const workflowControlContext = context.get("workflowControlContext");
@@ -366417,14 +366418,14 @@ class ValidationErrors {
366417
366418
  context: { integration, version }
366418
366419
  };
366419
366420
  }
366420
- static unknownIntegration(integration, source) {
366421
+ static unknownIntegration(integration, source, detailedMessage) {
366421
366422
  return {
366422
366423
  $type: ValidationErrors.$type,
366423
366424
  code: "UNKNOWN_INTEGRATION",
366424
366425
  severity: "error",
366425
- message: `Unknown integration '${integration}' from source '${source}'`,
366426
+ message: detailedMessage || `Unknown integration '${integration}' from source '${source}'`,
366426
366427
  file: "dependencies.json",
366427
- hint: `Check if the integration name is correct or if it exists in ${source}`,
366428
+ hint: detailedMessage ? undefined : `Check if the integration name is correct or if it exists in ${source}`,
366428
366429
  context: { integration, source }
366429
366430
  };
366430
366431
  }
@@ -366691,7 +366692,8 @@ class IntegrationManager {
366691
366692
  if (error instanceof Error && error.message.includes("version")) {
366692
366693
  errors.push(ValidationErrors.integrationVersionError(integration.alias, error.message));
366693
366694
  } else {
366694
- errors.push(ValidationErrors.unknownIntegration(integration.alias, integration.ref.fullName));
366695
+ const errorMessage = error instanceof Error ? error.message : undefined;
366696
+ errors.push(ValidationErrors.unknownIntegration(integration.alias, integration.ref.fullName, errorMessage));
366695
366697
  }
366696
366698
  }
366697
366699
  });
@@ -366711,51 +366713,80 @@ class IntegrationManager {
366711
366713
  }
366712
366714
  }
366713
366715
  const client = await this.getClient();
366714
- let integrationResponse;
366715
- let versionError = null;
366716
+ const integration = await this._findPrivateOrPublicIntegration(client, ref);
366717
+ if (!integration) {
366718
+ throw await this._buildIntegrationNotFoundError(client, ref);
366719
+ }
366720
+ await this.cache.setResolution(ref.name, ref.version, ref.workspace, integration.id, integration.updatedAt);
366721
+ const definition = integration;
366722
+ await this.cache.setDefinition(integration.id, integration.updatedAt, definition);
366723
+ return definition;
366724
+ }
366725
+ async _findPrivateOrPublicIntegration(client, ref) {
366726
+ const privateIntegration = await this._findPrivateIntegration(client, ref);
366727
+ if (privateIntegration) {
366728
+ return privateIntegration;
366729
+ }
366730
+ const publicIntegration = await this._findPublicIntegration(client, ref);
366731
+ if (publicIntegration) {
366732
+ return publicIntegration;
366733
+ }
366734
+ return;
366735
+ }
366736
+ async _findPrivateIntegration(client, ref) {
366716
366737
  try {
366717
- integrationResponse = await client.getIntegrationByName({
366738
+ const version = ref.workspace && ref.version !== "latest" ? "latest" : ref.version;
366739
+ const response = await client.getIntegrationByName({
366740
+ name: ref.fullName,
366741
+ version
366742
+ });
366743
+ return response.integration;
366744
+ } catch (error) {
366745
+ if (this._isResourceNotFoundError(error)) {
366746
+ return;
366747
+ }
366748
+ throw error;
366749
+ }
366750
+ }
366751
+ async _findPublicIntegration(client, ref) {
366752
+ try {
366753
+ const response = await client.getPublicIntegration({
366718
366754
  name: ref.fullName,
366719
366755
  version: ref.version
366720
366756
  });
366721
- } catch (privateError) {
366722
- try {
366723
- integrationResponse = await client.getPublicIntegration({
366724
- name: ref.name,
366725
- version: ref.version
366726
- });
366727
- } catch (publicError) {
366728
- versionError = publicError;
366757
+ return response.integration;
366758
+ } catch (error) {
366759
+ if (this._isResourceNotFoundError(error)) {
366760
+ return;
366729
366761
  }
366762
+ throw error;
366730
366763
  }
366731
- if (!integrationResponse && versionError) {
366732
- let latestVersion = null;
366733
- try {
366734
- const latestResponse = await client.getIntegrationByName({
366735
- name: ref.fullName,
366736
- version: "latest"
366737
- });
366738
- latestVersion = latestResponse.integration.version;
366739
- } catch {
366740
- try {
366741
- const latestResponse = await client.getPublicIntegration({
366742
- name: ref.fullName,
366743
- version: "latest"
366744
- });
366745
- latestVersion = latestResponse.integration.version;
366746
- } catch {
366747
- const location2 = ref.workspace ? `workspace "${ref.workspace}"` : "the official Botpress hub";
366748
- throw new Error(`Integration "${ref.name}" does not exist in ${location2}`);
366749
- }
366764
+ }
366765
+ _isResourceNotFoundError(error) {
366766
+ if (error && typeof error === "object" && "type" in error) {
366767
+ return error.type === "ResourceNotFound";
366768
+ }
366769
+ return false;
366770
+ }
366771
+ async _buildIntegrationNotFoundError(client, ref) {
366772
+ if (!ref.workspace) {
366773
+ return new Error(`Integration "${ref.name}" not found in the official Botpress hub`);
366774
+ }
366775
+ let currentWorkspaceHandle;
366776
+ try {
366777
+ const credentials = this.options.credentials || await auth.getActiveCredentials();
366778
+ const workspaceId = this.options.workspaceId || credentials.workspaceId;
366779
+ if (workspaceId) {
366780
+ const currentWorkspace = await client.getWorkspace({ id: workspaceId });
366781
+ currentWorkspaceHandle = currentWorkspace?.handle;
366750
366782
  }
366751
- const location = ref.workspace ? `workspace "${ref.workspace}"` : "Botpress";
366752
- throw new Error(`Integration "${ref.name}" version "${ref.version}" not found in ${location}. Latest available version is "${latestVersion}"`);
366783
+ } catch {
366784
+ return new Error(`Integration "${ref.name}" not found in workspace "${ref.workspace}"`);
366753
366785
  }
366754
- const integration = integrationResponse.integration;
366755
- await this.cache.setResolution(ref.name, ref.version, ref.workspace, integration.id, integration.updatedAt);
366756
- const definition = integration;
366757
- await this.cache.setDefinition(integration.id, integration.updatedAt, definition);
366758
- return definition;
366786
+ if (currentWorkspaceHandle === ref.workspace) {
366787
+ return new Error(`Integration "${ref.name}" not found in workspace "${ref.workspace}". Are you sure you published the integration? Run 'adk deploy' to publish it to your workspace.`);
366788
+ }
366789
+ return new Error(`Integration "${ref.name}" not found in workspace "${ref.workspace}". This integration may be private. Private integrations can only be installed in the same workspace. If you want to share this integration with other workspaces, deploy it with --visibility="unlisted" or --visibility="public".`);
366759
366790
  }
366760
366791
  validateIntegration(integration) {
366761
366792
  const errors = [];
@@ -367778,7 +367809,7 @@ class AgentProjectGenerator {
367778
367809
  deploy: "adk deploy"
367779
367810
  },
367780
367811
  dependencies: {
367781
- "@botpress/runtime": "^1.3.10"
367812
+ "@botpress/runtime": "^1.3.12"
367782
367813
  },
367783
367814
  devDependencies: {
367784
367815
  typescript: "^5.0.0"
@@ -377019,7 +377050,7 @@ var init_Separator = __esm(async () => {
377019
377050
  var require_package3 = __commonJS((exports, module) => {
377020
377051
  module.exports = {
377021
377052
  name: "@botpress/adk",
377022
- version: "1.3.10",
377053
+ version: "1.3.12",
377023
377054
  description: "Core ADK library for building AI agents on Botpress",
377024
377055
  type: "module",
377025
377056
  main: "dist/index.js",
@@ -380244,7 +380275,7 @@ function checkRuntimeVersion(agentRoot) {
380244
380275
  `));
380245
380276
  }
380246
380277
  }
380247
- var semver, EXPECTED_RUNTIME_VERSION = "1.3.10";
380278
+ var semver, EXPECTED_RUNTIME_VERSION = "1.3.12";
380248
380279
  var init_runtime_version_check = __esm(() => {
380249
380280
  init_source();
380250
380281
  semver = __toESM(require_semver3(), 1);
@@ -395785,7 +395816,7 @@ function formatHelp(cmd, version) {
395785
395816
  // src/cli.ts
395786
395817
  var __filename2 = fileURLToPath9(import.meta.url);
395787
395818
  var __dirname5 = dirname3(__filename2);
395788
- var CLI_VERSION = "1.5.10";
395819
+ var CLI_VERSION = "1.5.12";
395789
395820
  program.name("adk").description("Botpress Agent Development Kit (ADK) - CLI for building AI agents").version(CLI_VERSION).option("--no-cache", "Disable caching for integration lookups").configureHelp({
395790
395821
  formatHelp: () => formatHelp(program, CLI_VERSION)
395791
395822
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@botpress/adk-cli",
3
- "version": "1.5.10",
3
+ "version": "1.5.12",
4
4
  "description": "Command-line interface for the Botpress Agent Development Kit (ADK)",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",