@botpress/adk 1.19.0-beta.7 → 1.19.0-beta.9
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.
- package/dist/agent-init/agent-project-generator.d.ts.map +1 -1
- package/dist/agent-project/agent-project.d.ts.map +1 -1
- package/dist/agent-project/config-writer.d.ts.map +1 -1
- package/dist/agent-project/dependencies-parser.d.ts.map +1 -1
- package/dist/agent-project/file-watcher.d.ts.map +1 -1
- package/dist/agent0/config/schema.d.ts.map +1 -1
- package/dist/agent0/config/store.d.ts +8 -3
- package/dist/agent0/config/store.d.ts.map +1 -1
- package/dist/agent0/index.js +174 -41
- package/dist/agent0/index.js.map +15 -13
- package/dist/agent0/providers/catalog.d.ts.map +1 -1
- package/dist/agent0/providers/registry.d.ts.map +1 -1
- package/dist/agent0/providers/source.d.ts +8 -3
- package/dist/agent0/providers/source.d.ts.map +1 -1
- package/dist/agent0/runtime/client.d.ts +2 -3
- package/dist/agent0/runtime/client.d.ts.map +1 -1
- package/dist/agent0/runtime/engine.d.ts +5 -0
- package/dist/agent0/runtime/engine.d.ts.map +1 -1
- package/dist/agent0/runtime/manager.d.ts +2 -3
- package/dist/agent0/runtime/manager.d.ts.map +1 -1
- package/dist/agent0/runtime/process.d.ts +9 -0
- package/dist/agent0/runtime/process.d.ts.map +1 -1
- package/dist/assets/manager.d.ts.map +1 -1
- package/dist/auth/credentials.d.ts.map +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/service.d.ts.map +1 -1
- package/dist/bot-generator/generator.d.ts.map +1 -1
- package/dist/bot-generator/integration-sync.d.ts +2 -0
- package/dist/bot-generator/integration-sync.d.ts.map +1 -1
- package/dist/bot-generator/interface-sync.d.ts +2 -0
- package/dist/bot-generator/interface-sync.d.ts.map +1 -1
- package/dist/bot-generator/plugin-sync.d.ts +2 -0
- package/dist/bot-generator/plugin-sync.d.ts.map +1 -1
- package/dist/cognitive/models.d.ts.map +1 -1
- package/dist/commands/bp-cli.d.ts.map +1 -1
- package/dist/commands/bp-cli.js +147 -0
- package/dist/commands/bp-cli.js.map +12 -0
- package/dist/commands/bp-dev-command.d.ts +2 -0
- package/dist/commands/bp-dev-command.d.ts.map +1 -1
- package/dist/commands/bp-dev-worker-env.d.ts +7 -0
- package/dist/commands/bp-dev-worker-env.d.ts.map +1 -0
- package/dist/config/manager.d.ts.map +1 -1
- package/dist/dependencies/dependency-manager.d.ts.map +1 -1
- package/dist/dependencies/errors.d.ts +7 -4
- package/dist/dependencies/errors.d.ts.map +1 -1
- package/dist/dependencies/index.js +255 -62
- package/dist/dependencies/index.js.map +23 -21
- package/dist/dependencies/types.d.ts +12 -12
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +807 -417
- package/dist/index.js.map +40 -37
- package/dist/integrations/hub-cache.d.ts.map +1 -1
- package/dist/integrations/manager.d.ts.map +1 -1
- package/dist/interfaces/manager.d.ts.map +1 -1
- package/dist/interfaces/parser.d.ts.map +1 -1
- package/dist/knowledge/manager.d.ts.map +1 -1
- package/dist/plugins/manager.d.ts.map +1 -1
- package/dist/runner/script-runner.d.ts.map +1 -1
- package/dist/secrets/manager.d.ts.map +1 -1
- package/dist/tables/table-manager.d.ts.map +1 -1
- package/dist/test-utils/mock-module.d.ts +29 -0
- package/dist/test-utils/mock-module.d.ts.map +1 -0
- package/dist/utils/require-chat.d.ts.map +1 -1
- package/dist/utils/source-map-optimizer.d.ts +10 -11
- package/dist/utils/source-map-optimizer.d.ts.map +1 -1
- package/package.json +7 -3
|
@@ -75,9 +75,46 @@ var init_types = __esm(() => {
|
|
|
75
75
|
});
|
|
76
76
|
});
|
|
77
77
|
|
|
78
|
+
// ../analytics/src/errors.ts
|
|
79
|
+
function isAdkError(error) {
|
|
80
|
+
if (error instanceof AdkError)
|
|
81
|
+
return true;
|
|
82
|
+
if (!(error instanceof Error))
|
|
83
|
+
return false;
|
|
84
|
+
return error.constructor?.__IS_ADK_BASE_ERROR === true;
|
|
85
|
+
}
|
|
86
|
+
var AdkError;
|
|
87
|
+
var init_errors = __esm(() => {
|
|
88
|
+
AdkError = class AdkError extends Error {
|
|
89
|
+
static __IS_ADK_BASE_ERROR = true;
|
|
90
|
+
code;
|
|
91
|
+
expected;
|
|
92
|
+
details;
|
|
93
|
+
suggestion;
|
|
94
|
+
constructor(opts) {
|
|
95
|
+
super(opts.message, opts.cause !== undefined ? { cause: opts.cause } : undefined);
|
|
96
|
+
this.name = this.constructor.name;
|
|
97
|
+
this.code = opts.code;
|
|
98
|
+
this.expected = opts.expected ?? false;
|
|
99
|
+
if (opts.details !== undefined) {
|
|
100
|
+
this.details = opts.details;
|
|
101
|
+
}
|
|
102
|
+
if (opts.suggestion !== undefined) {
|
|
103
|
+
this.suggestion = opts.suggestion;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
});
|
|
108
|
+
|
|
109
|
+
// ../analytics/src/index.ts
|
|
110
|
+
var init_src = __esm(() => {
|
|
111
|
+
init_errors();
|
|
112
|
+
});
|
|
113
|
+
|
|
78
114
|
// src/dependencies/errors.ts
|
|
79
115
|
var DEPENDENCY_ERROR_CODES, DependencyError, DEPENDENCY_WARNING_CODES;
|
|
80
|
-
var
|
|
116
|
+
var init_errors2 = __esm(() => {
|
|
117
|
+
init_src();
|
|
81
118
|
DEPENDENCY_ERROR_CODES = [
|
|
82
119
|
"AUTH_REQUIRED",
|
|
83
120
|
"INTEGRATION_NOT_FOUND",
|
|
@@ -98,16 +135,9 @@ var init_errors = __esm(() => {
|
|
|
98
135
|
"BUILTIN_INTERFACE_IMMUTABLE",
|
|
99
136
|
"PROD_CONFIRMATION_REQUIRED"
|
|
100
137
|
];
|
|
101
|
-
DependencyError = class DependencyError extends
|
|
102
|
-
code;
|
|
103
|
-
details;
|
|
104
|
-
suggestion;
|
|
138
|
+
DependencyError = class DependencyError extends AdkError {
|
|
105
139
|
constructor(opts) {
|
|
106
|
-
super(opts
|
|
107
|
-
this.name = "DependencyError";
|
|
108
|
-
this.code = opts.code;
|
|
109
|
-
this.details = opts.details;
|
|
110
|
-
this.suggestion = opts.suggestion;
|
|
140
|
+
super({ ...opts, expected: true });
|
|
111
141
|
}
|
|
112
142
|
};
|
|
113
143
|
DEPENDENCY_WARNING_CODES = [
|
|
@@ -196,7 +226,7 @@ class LockFile {
|
|
|
196
226
|
}
|
|
197
227
|
var init_lock_file = __esm(() => {
|
|
198
228
|
init_types();
|
|
199
|
-
|
|
229
|
+
init_errors2();
|
|
200
230
|
});
|
|
201
231
|
|
|
202
232
|
// src/agent-project/types.ts
|
|
@@ -880,7 +910,11 @@ class CredentialsManager {
|
|
|
880
910
|
async setCurrentProfile(profileName) {
|
|
881
911
|
const store = await this.readCredentials();
|
|
882
912
|
if (!store.profiles[profileName]) {
|
|
883
|
-
throw new
|
|
913
|
+
throw new AdkError({
|
|
914
|
+
code: "PROFILE_NOT_FOUND",
|
|
915
|
+
message: `Profile '${profileName}' not found`,
|
|
916
|
+
expected: true
|
|
917
|
+
});
|
|
884
918
|
}
|
|
885
919
|
if (!store.profileMetadata) {
|
|
886
920
|
store.profileMetadata = {};
|
|
@@ -895,7 +929,11 @@ class CredentialsManager {
|
|
|
895
929
|
async deleteProfile(profileName) {
|
|
896
930
|
const store = await this.readCredentials();
|
|
897
931
|
if (!store.profiles[profileName]) {
|
|
898
|
-
throw new
|
|
932
|
+
throw new AdkError({
|
|
933
|
+
code: "PROFILE_NOT_FOUND",
|
|
934
|
+
message: `Profile '${profileName}' not found`,
|
|
935
|
+
expected: true
|
|
936
|
+
});
|
|
899
937
|
}
|
|
900
938
|
delete store.profiles[profileName];
|
|
901
939
|
delete store.profileMetadata?.[profileName];
|
|
@@ -910,7 +948,12 @@ class CredentialsManager {
|
|
|
910
948
|
const credentials = await this.getCredentials(profileName);
|
|
911
949
|
if (!credentials) {
|
|
912
950
|
const displayName = profileName || "default";
|
|
913
|
-
throw new
|
|
951
|
+
throw new AdkError({
|
|
952
|
+
code: "NOT_AUTHENTICATED",
|
|
953
|
+
message: `No credentials found for profile '${displayName}'. ` + `Please run 'adk login' to authenticate.`,
|
|
954
|
+
expected: true,
|
|
955
|
+
suggestion: "Run 'adk login' to authenticate."
|
|
956
|
+
});
|
|
914
957
|
}
|
|
915
958
|
return credentials;
|
|
916
959
|
}
|
|
@@ -945,7 +988,12 @@ class CredentialsManager {
|
|
|
945
988
|
const profileName = store.currentProfile || "default";
|
|
946
989
|
const activeCredentials = store.profiles[profileName];
|
|
947
990
|
if (!activeCredentials) {
|
|
948
|
-
throw new
|
|
991
|
+
throw new AdkError({
|
|
992
|
+
code: "NOT_AUTHENTICATED",
|
|
993
|
+
message: `No credentials found for profile '${profileName}'. ` + `Please run 'adk login' to authenticate.`,
|
|
994
|
+
expected: true,
|
|
995
|
+
suggestion: "Run 'adk login' to authenticate."
|
|
996
|
+
});
|
|
949
997
|
}
|
|
950
998
|
baseCredentials = activeCredentials;
|
|
951
999
|
}
|
|
@@ -959,6 +1007,7 @@ class CredentialsManager {
|
|
|
959
1007
|
}
|
|
960
1008
|
}
|
|
961
1009
|
var init_credentials = __esm(() => {
|
|
1010
|
+
init_src();
|
|
962
1011
|
init_agent_resolver();
|
|
963
1012
|
});
|
|
964
1013
|
|
|
@@ -972,7 +1021,11 @@ class AuthService {
|
|
|
972
1021
|
}
|
|
973
1022
|
async validateToken(token) {
|
|
974
1023
|
if (!token || !token.startsWith("bp_")) {
|
|
975
|
-
throw new
|
|
1024
|
+
throw new AdkError({
|
|
1025
|
+
code: "INVALID_TOKEN_FORMAT",
|
|
1026
|
+
message: 'Invalid token format. Token should start with "bp_"',
|
|
1027
|
+
expected: true
|
|
1028
|
+
});
|
|
976
1029
|
}
|
|
977
1030
|
try {
|
|
978
1031
|
const client = new Client({
|
|
@@ -996,10 +1049,20 @@ class AuthService {
|
|
|
996
1049
|
} catch (error) {
|
|
997
1050
|
if (error instanceof Error) {
|
|
998
1051
|
if (error.message.includes("401") || error.message.includes("Unauthorized")) {
|
|
999
|
-
throw new
|
|
1052
|
+
throw new AdkError({
|
|
1053
|
+
code: "AUTH_FAILED",
|
|
1054
|
+
message: "Invalid token. Please check your API token and try again.",
|
|
1055
|
+
expected: true,
|
|
1056
|
+
cause: error
|
|
1057
|
+
});
|
|
1000
1058
|
}
|
|
1001
1059
|
if (error.message.includes("Network") || error.message.includes("ENOTFOUND")) {
|
|
1002
|
-
throw new
|
|
1060
|
+
throw new AdkError({
|
|
1061
|
+
code: "NETWORK_ERROR",
|
|
1062
|
+
message: `Unable to connect to ${this.apiUrl}. Please check your internet connection and API URL.`,
|
|
1063
|
+
expected: true,
|
|
1064
|
+
cause: error
|
|
1065
|
+
});
|
|
1003
1066
|
}
|
|
1004
1067
|
}
|
|
1005
1068
|
throw error;
|
|
@@ -1014,7 +1077,9 @@ class AuthService {
|
|
|
1014
1077
|
}
|
|
1015
1078
|
}
|
|
1016
1079
|
}
|
|
1017
|
-
var init_service = () => {
|
|
1080
|
+
var init_service = __esm(() => {
|
|
1081
|
+
init_src();
|
|
1082
|
+
});
|
|
1018
1083
|
|
|
1019
1084
|
// src/auth/bp-cli-import.ts
|
|
1020
1085
|
import fs4 from "fs/promises";
|
|
@@ -1195,7 +1260,12 @@ async function resolveProjectCredentials(options = {}) {
|
|
|
1195
1260
|
async function resolveWorkspaceCredentials(options = {}) {
|
|
1196
1261
|
const credentials = await resolveProjectCredentials(options);
|
|
1197
1262
|
if (!credentials.workspaceId) {
|
|
1198
|
-
throw new
|
|
1263
|
+
throw new AdkError({
|
|
1264
|
+
code: "WORKSPACE_ID_MISSING",
|
|
1265
|
+
message: 'No workspace ID found. Please login again with "adk login" or link your agent first.',
|
|
1266
|
+
expected: true,
|
|
1267
|
+
suggestion: 'Login again with "adk login" or link your agent first.'
|
|
1268
|
+
});
|
|
1199
1269
|
}
|
|
1200
1270
|
return {
|
|
1201
1271
|
...credentials,
|
|
@@ -1205,7 +1275,12 @@ async function resolveWorkspaceCredentials(options = {}) {
|
|
|
1205
1275
|
async function resolveBotCredentials(options = {}) {
|
|
1206
1276
|
const credentials = await resolveWorkspaceCredentials(options);
|
|
1207
1277
|
if (!credentials.botId) {
|
|
1208
|
-
throw new
|
|
1278
|
+
throw new AdkError({
|
|
1279
|
+
code: "BOT_ID_MISSING",
|
|
1280
|
+
message: "No bot ID found. Please link your agent first.",
|
|
1281
|
+
expected: true,
|
|
1282
|
+
suggestion: "Link your agent first."
|
|
1283
|
+
});
|
|
1209
1284
|
}
|
|
1210
1285
|
return {
|
|
1211
1286
|
...credentials,
|
|
@@ -1269,6 +1344,7 @@ var auth, projectClientCache, MAX_PROJECT_CLIENT_CACHE_ENTRIES = 32, stableStrin
|
|
|
1269
1344
|
return `{${Object.keys(record).sort().map((key) => `${JSON.stringify(key)}:${stableStringify(record[key])}`).join(",")}}`;
|
|
1270
1345
|
};
|
|
1271
1346
|
var init_auth = __esm(() => {
|
|
1347
|
+
init_src();
|
|
1272
1348
|
init_credentials();
|
|
1273
1349
|
init_service();
|
|
1274
1350
|
init_agent_resolver();
|
|
@@ -1327,7 +1403,7 @@ class EnhancedIntegrationCache {
|
|
|
1327
1403
|
updatedAt,
|
|
1328
1404
|
cachedAt: new Date().toISOString()
|
|
1329
1405
|
};
|
|
1330
|
-
await fs5.writeFile(cachePath, JSON.stringify(resolution
|
|
1406
|
+
await fs5.writeFile(cachePath, JSON.stringify(resolution));
|
|
1331
1407
|
}
|
|
1332
1408
|
async getDefinition(integrationId, updatedAt) {
|
|
1333
1409
|
if (this.noCache) {
|
|
@@ -1351,7 +1427,7 @@ class EnhancedIntegrationCache {
|
|
|
1351
1427
|
definition,
|
|
1352
1428
|
cachedAt: new Date().toISOString()
|
|
1353
1429
|
};
|
|
1354
|
-
await fs5.writeFile(cachePath, JSON.stringify(cached
|
|
1430
|
+
await fs5.writeFile(cachePath, JSON.stringify(cached));
|
|
1355
1431
|
}
|
|
1356
1432
|
async clear() {
|
|
1357
1433
|
try {
|
|
@@ -1406,7 +1482,11 @@ class IntegrationParser {
|
|
|
1406
1482
|
static parseIntegrationRef(versionString) {
|
|
1407
1483
|
const result = integrationRefSchema.safeParse(versionString);
|
|
1408
1484
|
if (!result.success) {
|
|
1409
|
-
throw new
|
|
1485
|
+
throw new AdkError({
|
|
1486
|
+
code: "INVALID_VERSION_FORMAT",
|
|
1487
|
+
expected: true,
|
|
1488
|
+
message: result.error.errors[0]?.message || "Invalid integration version format"
|
|
1489
|
+
});
|
|
1410
1490
|
}
|
|
1411
1491
|
return result.data;
|
|
1412
1492
|
}
|
|
@@ -1483,7 +1563,11 @@ class PluginParser {
|
|
|
1483
1563
|
static parsePluginRef(versionString) {
|
|
1484
1564
|
const result = pluginRefSchema.safeParse(versionString);
|
|
1485
1565
|
if (!result.success) {
|
|
1486
|
-
throw new
|
|
1566
|
+
throw new AdkError({
|
|
1567
|
+
code: "INVALID_VERSION_FORMAT",
|
|
1568
|
+
expected: true,
|
|
1569
|
+
message: result.error.errors[0]?.message || "Invalid plugin version format"
|
|
1570
|
+
});
|
|
1487
1571
|
}
|
|
1488
1572
|
return result.data;
|
|
1489
1573
|
}
|
|
@@ -1570,6 +1654,7 @@ class PluginParser {
|
|
|
1570
1654
|
}
|
|
1571
1655
|
var INTEGRATION_ALIAS_MIN_LENGTH = 2, INTEGRATION_ALIAS_MAX_LENGTH = 100, INTEGRATION_ALIAS_REGEX, integrationRefSchema, versionSchema, PLUGIN_ALIAS_MIN_LENGTH = 2, PLUGIN_ALIAS_MAX_LENGTH = 100, PLUGIN_ALIAS_REGEX, pluginRefSchema;
|
|
1572
1656
|
var init_dependencies_parser = __esm(() => {
|
|
1657
|
+
init_src();
|
|
1573
1658
|
init_validation_errors();
|
|
1574
1659
|
INTEGRATION_ALIAS_REGEX = /^(?:[a-z][a-z0-9_-]*\/)?[a-z][a-z0-9_-]*$/;
|
|
1575
1660
|
integrationRefSchema = z3.string().transform((val, ctx) => {
|
|
@@ -1866,11 +1951,19 @@ class IntegrationManager {
|
|
|
1866
1951
|
const latestExists = await this._findPrivateOrPublicIntegration(client, { ...ref, version: "latest" });
|
|
1867
1952
|
if (latestExists) {
|
|
1868
1953
|
const scope = ref.workspace ? `workspace "${ref.workspace}"` : "the official Botpress hub";
|
|
1869
|
-
return new
|
|
1954
|
+
return new AdkError({
|
|
1955
|
+
code: "INTEGRATION_NOT_FOUND",
|
|
1956
|
+
message: `Integration "${ref.name}" version "${ref.version}" not found in ${scope} ` + `(latest is ${latestExists.version}). Run 'adk info ${ref.fullName}' to see available versions.`,
|
|
1957
|
+
expected: true
|
|
1958
|
+
});
|
|
1870
1959
|
}
|
|
1871
1960
|
}
|
|
1872
1961
|
if (!ref.workspace) {
|
|
1873
|
-
return new
|
|
1962
|
+
return new AdkError({
|
|
1963
|
+
code: "INTEGRATION_NOT_FOUND",
|
|
1964
|
+
message: `Integration "${ref.name}" not found in the official Botpress hub`,
|
|
1965
|
+
expected: true
|
|
1966
|
+
});
|
|
1874
1967
|
}
|
|
1875
1968
|
let currentWorkspaceHandle;
|
|
1876
1969
|
let workspaceId;
|
|
@@ -1887,12 +1980,25 @@ class IntegrationManager {
|
|
|
1887
1980
|
currentWorkspaceHandle = currentWorkspace?.handle;
|
|
1888
1981
|
}
|
|
1889
1982
|
} catch {
|
|
1890
|
-
return new
|
|
1983
|
+
return new AdkError({
|
|
1984
|
+
code: "INTEGRATION_NOT_FOUND",
|
|
1985
|
+
message: `Integration "${ref.name}" not found in workspace "${ref.workspace}"`,
|
|
1986
|
+
expected: true
|
|
1987
|
+
});
|
|
1891
1988
|
}
|
|
1892
1989
|
if (currentWorkspaceHandle === ref.workspace) {
|
|
1893
|
-
return new
|
|
1990
|
+
return new AdkError({
|
|
1991
|
+
code: "INTEGRATION_NOT_FOUND",
|
|
1992
|
+
message: `Integration "${ref.name}" not found in workspace "${ref.workspace}" (workspaceId: ${workspaceId}). ` + `Are you sure you published the integration? ` + `Run 'adk deploy' to publish it to your workspace.`,
|
|
1993
|
+
expected: true,
|
|
1994
|
+
suggestion: "Are you sure you published the integration? Run 'adk deploy' to publish it to your workspace."
|
|
1995
|
+
});
|
|
1894
1996
|
}
|
|
1895
|
-
return new
|
|
1997
|
+
return new AdkError({
|
|
1998
|
+
code: "INTEGRATION_NOT_FOUND",
|
|
1999
|
+
message: `Integration "${ref.name}" not found in workspace "${ref.workspace}" (current workspaceId: ${workspaceId}). ` + `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".`,
|
|
2000
|
+
expected: true
|
|
2001
|
+
});
|
|
1896
2002
|
}
|
|
1897
2003
|
validateIntegration(integration) {
|
|
1898
2004
|
const errors = [];
|
|
@@ -1951,6 +2057,7 @@ function toHubCacheEntry(integration) {
|
|
|
1951
2057
|
};
|
|
1952
2058
|
}
|
|
1953
2059
|
var init_manager = __esm(() => {
|
|
2060
|
+
init_src();
|
|
1954
2061
|
init_auth();
|
|
1955
2062
|
init_enhanced_cache();
|
|
1956
2063
|
init_dependencies_parser();
|
|
@@ -2060,7 +2167,12 @@ class AssetsManager {
|
|
|
2060
2167
|
async getClient() {
|
|
2061
2168
|
if (!this.client) {
|
|
2062
2169
|
if (!this.botId) {
|
|
2063
|
-
throw new
|
|
2170
|
+
throw new AdkError({
|
|
2171
|
+
code: "BOT_ID_REQUIRED",
|
|
2172
|
+
message: "Bot ID is required for asset operations. Please deploy your agent first or create agent.json with botId and workspaceId.",
|
|
2173
|
+
expected: true,
|
|
2174
|
+
suggestion: "Deploy your agent first or create agent.json with botId and workspaceId."
|
|
2175
|
+
});
|
|
2064
2176
|
}
|
|
2065
2177
|
this.client = await getProjectClient({
|
|
2066
2178
|
project: { path: this.projectPath },
|
|
@@ -2074,7 +2186,12 @@ class AssetsManager {
|
|
|
2074
2186
|
}
|
|
2075
2187
|
assertBotId(operation) {
|
|
2076
2188
|
if (!this.botId) {
|
|
2077
|
-
throw new
|
|
2189
|
+
throw new AdkError({
|
|
2190
|
+
code: "BOT_ID_REQUIRED",
|
|
2191
|
+
message: `Operation "${operation}" requires a bot ID. ` + "Please deploy your agent first or create agent.json with botId and workspaceId.",
|
|
2192
|
+
expected: true,
|
|
2193
|
+
suggestion: "Deploy your agent first or create agent.json with botId and workspaceId."
|
|
2194
|
+
});
|
|
2078
2195
|
}
|
|
2079
2196
|
}
|
|
2080
2197
|
async hasAssetsDirectory() {
|
|
@@ -2140,7 +2257,12 @@ class AssetsManager {
|
|
|
2140
2257
|
url: file.url || ""
|
|
2141
2258
|
}));
|
|
2142
2259
|
} catch (error) {
|
|
2143
|
-
throw new
|
|
2260
|
+
throw new AdkError({
|
|
2261
|
+
code: "ASSET_FETCH_FAILED",
|
|
2262
|
+
message: `Failed to fetch remote assets: ${error}`,
|
|
2263
|
+
expected: true,
|
|
2264
|
+
cause: error
|
|
2265
|
+
});
|
|
2144
2266
|
}
|
|
2145
2267
|
}
|
|
2146
2268
|
async createSyncPlan() {
|
|
@@ -2399,6 +2521,7 @@ declare global {
|
|
|
2399
2521
|
}
|
|
2400
2522
|
}
|
|
2401
2523
|
var init_manager2 = __esm(() => {
|
|
2524
|
+
init_src();
|
|
2402
2525
|
init_auth();
|
|
2403
2526
|
init_types3();
|
|
2404
2527
|
init_cache();
|
|
@@ -2517,6 +2640,7 @@ import * as path10 from "path";
|
|
|
2517
2640
|
import * as os6 from "os";
|
|
2518
2641
|
var HubCache;
|
|
2519
2642
|
var init_hub_cache = __esm(() => {
|
|
2643
|
+
init_src();
|
|
2520
2644
|
init_auth();
|
|
2521
2645
|
HubCache = class HubCache {
|
|
2522
2646
|
static CACHE_FILE = "botpress-hub-cache.json";
|
|
@@ -2529,7 +2653,12 @@ var init_hub_cache = __esm(() => {
|
|
|
2529
2653
|
if (!this.client) {
|
|
2530
2654
|
const credentials = await auth.getActiveCredentials();
|
|
2531
2655
|
if (!credentials.workspaceId) {
|
|
2532
|
-
throw new
|
|
2656
|
+
throw new AdkError({
|
|
2657
|
+
code: "WORKSPACE_ID_MISSING",
|
|
2658
|
+
message: 'No workspace ID found in current profile. Please login again with "adk login"',
|
|
2659
|
+
expected: true,
|
|
2660
|
+
suggestion: 'Please login again with "adk login".'
|
|
2661
|
+
});
|
|
2533
2662
|
}
|
|
2534
2663
|
this.client = new Client3({
|
|
2535
2664
|
token: credentials.token,
|
|
@@ -2618,7 +2747,12 @@ var init_hub_cache = __esm(() => {
|
|
|
2618
2747
|
};
|
|
2619
2748
|
await this.saveCache(newCache);
|
|
2620
2749
|
} catch (error) {
|
|
2621
|
-
throw new
|
|
2750
|
+
throw new AdkError({
|
|
2751
|
+
code: "HUB_CACHE_REFRESH_FAILED",
|
|
2752
|
+
message: `Failed to refresh hub cache: ${error instanceof Error ? error.message : String(error)}`,
|
|
2753
|
+
expected: true,
|
|
2754
|
+
cause: error
|
|
2755
|
+
});
|
|
2622
2756
|
}
|
|
2623
2757
|
}
|
|
2624
2758
|
async getAllIntegrations() {
|
|
@@ -2812,7 +2946,7 @@ class EnhancedInterfaceCache {
|
|
|
2812
2946
|
updatedAt,
|
|
2813
2947
|
cachedAt: new Date().toISOString()
|
|
2814
2948
|
};
|
|
2815
|
-
await fs11.writeFile(cachePath, JSON.stringify(resolution
|
|
2949
|
+
await fs11.writeFile(cachePath, JSON.stringify(resolution));
|
|
2816
2950
|
}
|
|
2817
2951
|
async getDefinition(interfaceId, updatedAt) {
|
|
2818
2952
|
if (this.noCache)
|
|
@@ -2835,7 +2969,7 @@ class EnhancedInterfaceCache {
|
|
|
2835
2969
|
definition,
|
|
2836
2970
|
cachedAt: new Date().toISOString()
|
|
2837
2971
|
};
|
|
2838
|
-
await fs11.writeFile(cachePath, JSON.stringify(cached
|
|
2972
|
+
await fs11.writeFile(cachePath, JSON.stringify(cached));
|
|
2839
2973
|
}
|
|
2840
2974
|
async clear() {
|
|
2841
2975
|
try {
|
|
@@ -2882,7 +3016,11 @@ class InterfaceParser {
|
|
|
2882
3016
|
static parseInterfaceRef(versionString) {
|
|
2883
3017
|
const match = versionString.match(/^(?:([^/]+)\/)?([^@]+)@(.+)$/);
|
|
2884
3018
|
if (!match) {
|
|
2885
|
-
throw new
|
|
3019
|
+
throw new AdkError({
|
|
3020
|
+
code: "INVALID_VERSION_FORMAT",
|
|
3021
|
+
message: `Invalid interface version format: ${versionString}. Expected format: 'name@version' or 'workspace/name@version'`,
|
|
3022
|
+
expected: true
|
|
3023
|
+
});
|
|
2886
3024
|
}
|
|
2887
3025
|
const [, workspace, name, version] = match;
|
|
2888
3026
|
return {
|
|
@@ -2916,6 +3054,7 @@ class InterfaceParser {
|
|
|
2916
3054
|
}
|
|
2917
3055
|
}
|
|
2918
3056
|
var init_parser = __esm(() => {
|
|
3057
|
+
init_src();
|
|
2919
3058
|
init_validation_errors();
|
|
2920
3059
|
init_constants();
|
|
2921
3060
|
});
|
|
@@ -3014,11 +3153,19 @@ class InterfaceManager {
|
|
|
3014
3153
|
latestVersion = latestPublic.interface.version;
|
|
3015
3154
|
} catch {
|
|
3016
3155
|
const location2 = ref.workspace ? `workspace "${ref.workspace}"` : "the official Botpress hub";
|
|
3017
|
-
throw new
|
|
3156
|
+
throw new AdkError({
|
|
3157
|
+
code: "INTERFACE_NOT_FOUND",
|
|
3158
|
+
message: `Interface "${ref.name}" does not exist in ${location2}`,
|
|
3159
|
+
expected: true
|
|
3160
|
+
});
|
|
3018
3161
|
}
|
|
3019
3162
|
}
|
|
3020
3163
|
const location = ref.workspace ? `workspace "${ref.workspace}"` : "Botpress";
|
|
3021
|
-
throw new
|
|
3164
|
+
throw new AdkError({
|
|
3165
|
+
code: "INTERFACE_VERSION_NOT_FOUND",
|
|
3166
|
+
message: `Interface "${ref.name}" version "${ref.version}" not found in ${location}. Latest available version is "${latestVersion}"`,
|
|
3167
|
+
expected: true
|
|
3168
|
+
});
|
|
3022
3169
|
}
|
|
3023
3170
|
const intf = interfaceResponse.interface;
|
|
3024
3171
|
await this.cache.setResolution(ref.name, ref.version, ref.workspace, intf.id, intf.updatedAt);
|
|
@@ -3028,7 +3175,11 @@ class InterfaceManager {
|
|
|
3028
3175
|
async getByDependencyString(dep) {
|
|
3029
3176
|
const match = dep.match(/^(?:([^/]+)\/)?([^@]+)@(.+)$/);
|
|
3030
3177
|
if (!match) {
|
|
3031
|
-
throw new
|
|
3178
|
+
throw new AdkError({
|
|
3179
|
+
code: "INVALID_VERSION_FORMAT",
|
|
3180
|
+
message: `Invalid interface dependency string: ${dep}. Expected 'name@version' or 'workspace/name@version'`,
|
|
3181
|
+
expected: true
|
|
3182
|
+
});
|
|
3032
3183
|
}
|
|
3033
3184
|
const [, workspace, name, version] = match;
|
|
3034
3185
|
return this.fetchInterface({
|
|
@@ -3059,6 +3210,7 @@ class InterfaceManager {
|
|
|
3059
3210
|
}
|
|
3060
3211
|
}
|
|
3061
3212
|
var init_manager3 = __esm(() => {
|
|
3213
|
+
init_src();
|
|
3062
3214
|
init_auth();
|
|
3063
3215
|
init_enhanced_cache2();
|
|
3064
3216
|
init_parser();
|
|
@@ -3393,6 +3545,7 @@ function getToolDefinition(value) {
|
|
|
3393
3545
|
}
|
|
3394
3546
|
var debug, AgentProject;
|
|
3395
3547
|
var init_agent_project = __esm(() => {
|
|
3548
|
+
init_src();
|
|
3396
3549
|
init_assets();
|
|
3397
3550
|
init_integrations();
|
|
3398
3551
|
init_interfaces();
|
|
@@ -3540,7 +3693,12 @@ var init_agent_project = __esm(() => {
|
|
|
3540
3693
|
this._warnings = validation.warnings;
|
|
3541
3694
|
if (!validation.valid) {
|
|
3542
3695
|
this._state = "error" /* Error */;
|
|
3543
|
-
throw new
|
|
3696
|
+
throw new AdkError({
|
|
3697
|
+
code: "PROJECT_VALIDATION_FAILED",
|
|
3698
|
+
expected: true,
|
|
3699
|
+
message: `Project validation failed: ${validation.errors[0]?.message}`,
|
|
3700
|
+
details: { errors: validation.errors }
|
|
3701
|
+
});
|
|
3544
3702
|
}
|
|
3545
3703
|
await this.loadAgentInfo();
|
|
3546
3704
|
this._integrationManager = new IntegrationManager({
|
|
@@ -3627,19 +3785,19 @@ var init_agent_project = __esm(() => {
|
|
|
3627
3785
|
}
|
|
3628
3786
|
get integrations() {
|
|
3629
3787
|
if (!this._integrations) {
|
|
3630
|
-
throw new
|
|
3788
|
+
throw new AdkError({ code: "PROJECT_NOT_LOADED", expected: false, message: "Integrations not loaded" });
|
|
3631
3789
|
}
|
|
3632
3790
|
return this._integrations;
|
|
3633
3791
|
}
|
|
3634
3792
|
get interfaces() {
|
|
3635
3793
|
if (!this._interfaces) {
|
|
3636
|
-
throw new
|
|
3794
|
+
throw new AdkError({ code: "PROJECT_NOT_LOADED", expected: false, message: "Interfaces not loaded" });
|
|
3637
3795
|
}
|
|
3638
3796
|
return this._interfaces;
|
|
3639
3797
|
}
|
|
3640
3798
|
async getIntegrations() {
|
|
3641
3799
|
if (!this._dependencies || !this._integrations) {
|
|
3642
|
-
throw new
|
|
3800
|
+
throw new AdkError({ code: "PROJECT_NOT_LOADED", expected: false, message: "Project not loaded" });
|
|
3643
3801
|
}
|
|
3644
3802
|
return this._integrations.map((parsed) => ({
|
|
3645
3803
|
name: parsed.alias,
|
|
@@ -3653,14 +3811,22 @@ var init_agent_project = __esm(() => {
|
|
|
3653
3811
|
}
|
|
3654
3812
|
async createAssetSyncPlan() {
|
|
3655
3813
|
if (this._state !== "ready" /* Ready */) {
|
|
3656
|
-
throw new
|
|
3814
|
+
throw new AdkError({
|
|
3815
|
+
code: "PROJECT_NOT_READY",
|
|
3816
|
+
expected: false,
|
|
3817
|
+
message: "Project must be in Ready state to create asset sync plan"
|
|
3818
|
+
});
|
|
3657
3819
|
}
|
|
3658
3820
|
this.requiresAgentInfo("create asset sync plan");
|
|
3659
3821
|
return await this._assetsManager.createSyncPlan();
|
|
3660
3822
|
}
|
|
3661
3823
|
async syncAssets(options) {
|
|
3662
3824
|
if (this._state !== "ready" /* Ready */) {
|
|
3663
|
-
throw new
|
|
3825
|
+
throw new AdkError({
|
|
3826
|
+
code: "PROJECT_NOT_READY",
|
|
3827
|
+
expected: false,
|
|
3828
|
+
message: "Project must be in Ready state to sync assets"
|
|
3829
|
+
});
|
|
3664
3830
|
}
|
|
3665
3831
|
this.requiresAgentInfo("sync assets");
|
|
3666
3832
|
const plan = await this._assetsManager.createSyncPlan();
|
|
@@ -3684,7 +3850,11 @@ var init_agent_project = __esm(() => {
|
|
|
3684
3850
|
}
|
|
3685
3851
|
async updateAgentInfo(updates) {
|
|
3686
3852
|
if (!this._agentInfo) {
|
|
3687
|
-
throw new
|
|
3853
|
+
throw new AdkError({
|
|
3854
|
+
code: "AGENT_INFO_MISSING",
|
|
3855
|
+
expected: false,
|
|
3856
|
+
message: "No agent.json found. Use createAgentInfo() first."
|
|
3857
|
+
});
|
|
3688
3858
|
}
|
|
3689
3859
|
const { devId, ...agentJsonUpdates } = updates;
|
|
3690
3860
|
const updatedInfo = { ...this._agentInfo, ...agentJsonUpdates };
|
|
@@ -3773,7 +3943,12 @@ var init_agent_project = __esm(() => {
|
|
|
3773
3943
|
}
|
|
3774
3944
|
requiresAgentInfo(operation) {
|
|
3775
3945
|
if (!this._agentInfo?.botId) {
|
|
3776
|
-
throw new
|
|
3946
|
+
throw new AdkError({
|
|
3947
|
+
code: "BOT_ID_REQUIRED",
|
|
3948
|
+
expected: true,
|
|
3949
|
+
message: `Operation "${operation}" requires a bot ID. ` + "Please create agent.json with botId and workspaceId after deploying your agent.",
|
|
3950
|
+
suggestion: "Create agent.json with botId and workspaceId after deploying your agent."
|
|
3951
|
+
});
|
|
3777
3952
|
}
|
|
3778
3953
|
}
|
|
3779
3954
|
async loadConfig() {
|
|
@@ -4371,7 +4546,7 @@ var _format = null, _formatLoaded = false, formatCode = async (code, filepath) =
|
|
|
4371
4546
|
`));
|
|
4372
4547
|
return code;
|
|
4373
4548
|
}
|
|
4374
|
-
}, ADK_VERSION = "1.19.0-beta.
|
|
4549
|
+
}, ADK_VERSION = "1.19.0-beta.9", relative = (from, to) => {
|
|
4375
4550
|
const fromDir = path14.dirname(from);
|
|
4376
4551
|
const relative2 = path14.relative(fromDir, to);
|
|
4377
4552
|
return relative2.startsWith(".") ? relative2 : `./${relative2}`;
|
|
@@ -4424,10 +4599,10 @@ function generateFriendlyAlias(cloudName, cloudAlias, used) {
|
|
|
4424
4599
|
}
|
|
4425
4600
|
|
|
4426
4601
|
// src/dependencies/dependency-manager.ts
|
|
4427
|
-
|
|
4602
|
+
init_errors2();
|
|
4428
4603
|
|
|
4429
4604
|
// src/dependencies/resolvers/integration-resolver.ts
|
|
4430
|
-
|
|
4605
|
+
init_errors2();
|
|
4431
4606
|
|
|
4432
4607
|
class IntegrationResolver {
|
|
4433
4608
|
registry;
|
|
@@ -4473,7 +4648,7 @@ class IntegrationResolver {
|
|
|
4473
4648
|
}
|
|
4474
4649
|
|
|
4475
4650
|
// src/dependencies/resolvers/plugin-resolver.ts
|
|
4476
|
-
|
|
4651
|
+
init_errors2();
|
|
4477
4652
|
|
|
4478
4653
|
class PluginResolver {
|
|
4479
4654
|
registry;
|
|
@@ -4588,6 +4763,7 @@ class IntegrationRegistry {
|
|
|
4588
4763
|
}
|
|
4589
4764
|
|
|
4590
4765
|
// src/plugins/manager.ts
|
|
4766
|
+
init_src();
|
|
4591
4767
|
init_auth();
|
|
4592
4768
|
|
|
4593
4769
|
// src/plugins/enhanced-cache.ts
|
|
@@ -4639,7 +4815,7 @@ class EnhancedPluginCache {
|
|
|
4639
4815
|
updatedAt,
|
|
4640
4816
|
cachedAt: new Date().toISOString()
|
|
4641
4817
|
};
|
|
4642
|
-
await fs6.writeFile(cachePath, JSON.stringify(resolution
|
|
4818
|
+
await fs6.writeFile(cachePath, JSON.stringify(resolution));
|
|
4643
4819
|
}
|
|
4644
4820
|
async getDefinition(pluginId, updatedAt) {
|
|
4645
4821
|
if (this.noCache) {
|
|
@@ -4663,7 +4839,7 @@ class EnhancedPluginCache {
|
|
|
4663
4839
|
definition,
|
|
4664
4840
|
cachedAt: new Date().toISOString()
|
|
4665
4841
|
};
|
|
4666
|
-
await fs6.writeFile(cachePath, JSON.stringify(cached
|
|
4842
|
+
await fs6.writeFile(cachePath, JSON.stringify(cached));
|
|
4667
4843
|
}
|
|
4668
4844
|
async clear() {
|
|
4669
4845
|
try {
|
|
@@ -4767,7 +4943,11 @@ class PluginManager {
|
|
|
4767
4943
|
const client = await this.getClient();
|
|
4768
4944
|
const plugin = await this._findPublicPlugin(client, ref);
|
|
4769
4945
|
if (!plugin) {
|
|
4770
|
-
throw new
|
|
4946
|
+
throw new AdkError({
|
|
4947
|
+
code: "PLUGIN_NOT_FOUND",
|
|
4948
|
+
expected: true,
|
|
4949
|
+
message: `Plugin "${ref.name}" not found on the Botpress Hub`
|
|
4950
|
+
});
|
|
4771
4951
|
}
|
|
4772
4952
|
await this.cache.setResolution(ref.name, ref.version, plugin.id, plugin.updatedAt);
|
|
4773
4953
|
await this.cache.setDefinition(plugin.id, plugin.updatedAt, plugin);
|
|
@@ -5528,7 +5708,7 @@ function extractMissingRequiredFields(err) {
|
|
|
5528
5708
|
|
|
5529
5709
|
// src/dependencies/index.ts
|
|
5530
5710
|
init_lock_file();
|
|
5531
|
-
|
|
5711
|
+
init_errors2();
|
|
5532
5712
|
|
|
5533
5713
|
// src/dependencies/registry/interface-registry.ts
|
|
5534
5714
|
init_constants();
|
|
@@ -5553,6 +5733,7 @@ import { Project as Project3, SyntaxKind as SyntaxKind3 } from "ts-morph";
|
|
|
5553
5733
|
|
|
5554
5734
|
// src/agent-project/config-writer.ts
|
|
5555
5735
|
init_utils();
|
|
5736
|
+
init_src();
|
|
5556
5737
|
import { Project as Project2, SyntaxKind as SyntaxKind2 } from "ts-morph";
|
|
5557
5738
|
import { readFileSync as readFileSync2 } from "fs";
|
|
5558
5739
|
import * as path15 from "path";
|
|
@@ -5571,11 +5752,19 @@ class ConfigWriter {
|
|
|
5571
5752
|
return call.getExpression().getText() === "defineConfig";
|
|
5572
5753
|
});
|
|
5573
5754
|
if (!defineConfigCall) {
|
|
5574
|
-
throw new
|
|
5755
|
+
throw new AdkError({
|
|
5756
|
+
code: "CONFIG_AST_INVALID",
|
|
5757
|
+
expected: true,
|
|
5758
|
+
message: "Could not find defineConfig() call in agent.config.ts"
|
|
5759
|
+
});
|
|
5575
5760
|
}
|
|
5576
5761
|
const configArg = defineConfigCall.getArguments()[0];
|
|
5577
5762
|
if (!configArg || !configArg.isKind(SyntaxKind2.ObjectLiteralExpression)) {
|
|
5578
|
-
throw new
|
|
5763
|
+
throw new AdkError({
|
|
5764
|
+
code: "CONFIG_AST_INVALID",
|
|
5765
|
+
expected: true,
|
|
5766
|
+
message: "defineConfig() must have an object literal as its first argument"
|
|
5767
|
+
});
|
|
5579
5768
|
}
|
|
5580
5769
|
return { sourceFile, configObject: configArg };
|
|
5581
5770
|
}
|
|
@@ -5663,7 +5852,11 @@ class ConfigWriter {
|
|
|
5663
5852
|
}
|
|
5664
5853
|
const defaultModelsObject = defaultModelsProperty.getInitializerIfKind(SyntaxKind2.ObjectLiteralExpression);
|
|
5665
5854
|
if (!defaultModelsObject) {
|
|
5666
|
-
throw new
|
|
5855
|
+
throw new AdkError({
|
|
5856
|
+
code: "CONFIG_AST_INVALID",
|
|
5857
|
+
expected: true,
|
|
5858
|
+
message: "defaultModels must be an object literal in agent.config.ts"
|
|
5859
|
+
});
|
|
5667
5860
|
}
|
|
5668
5861
|
for (const [key, value] of requestedEntries) {
|
|
5669
5862
|
const existingProperty = defaultModelsObject.getProperty(key);
|
|
@@ -5852,7 +6045,7 @@ class ConfigWriter {
|
|
|
5852
6045
|
}
|
|
5853
6046
|
|
|
5854
6047
|
// src/dependencies/migration.ts
|
|
5855
|
-
|
|
6048
|
+
init_errors2();
|
|
5856
6049
|
init_agent_project();
|
|
5857
6050
|
async function migrateFromConfig(opts) {
|
|
5858
6051
|
const result = {
|
|
@@ -6029,4 +6222,4 @@ export {
|
|
|
6029
6222
|
DEPENDENCY_ERROR_CODES
|
|
6030
6223
|
};
|
|
6031
6224
|
|
|
6032
|
-
//# debugId=
|
|
6225
|
+
//# debugId=737A4C5C47E4F6F964756E2164756E21
|