@botpress/adk 1.19.0-beta.12 → 1.19.0-beta.13
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/agent0/index.js +16 -7
- package/dist/agent0/index.js.map +5 -5
- package/dist/agent0/runtime/client.d.ts +2 -0
- package/dist/agent0/runtime/client.d.ts.map +1 -1
- package/dist/agent0/runtime/engine.d.ts +2 -1
- package/dist/agent0/runtime/engine.d.ts.map +1 -1
- package/dist/agent0/runtime/process.d.ts +1 -0
- package/dist/agent0/runtime/process.d.ts.map +1 -1
- package/dist/assets/manager.d.ts +3 -0
- package/dist/assets/manager.d.ts.map +1 -1
- package/dist/auth/credentials.d.ts +1 -1
- package/dist/dependencies/index.js +134 -258
- package/dist/dependencies/index.js.map +8 -9
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +459 -573
- package/dist/index.js.map +13 -14
- package/dist/integrations/hub-cache.d.ts +0 -58
- package/dist/integrations/hub-cache.d.ts.map +1 -1
- package/dist/integrations/index.d.ts +0 -1
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/manager.d.ts.map +1 -1
- package/dist/knowledge/manager.d.ts +3 -0
- package/dist/knowledge/manager.d.ts.map +1 -1
- package/dist/plugins/manager.d.ts.map +1 -1
- package/dist/preflight/checker.d.ts +6 -1
- package/dist/preflight/checker.d.ts.map +1 -1
- package/dist/tables/table-manager.d.ts +3 -0
- package/dist/tables/table-manager.d.ts.map +1 -1
- package/dist/workspace/workspace-cache.d.ts +2 -1
- package/dist/workspace/workspace-cache.d.ts.map +1 -1
- package/package.json +2 -2
|
@@ -944,7 +944,7 @@ class CredentialsManager {
|
|
|
944
944
|
await this.writeCredentials(store);
|
|
945
945
|
}
|
|
946
946
|
async getActiveCredentials() {
|
|
947
|
-
const profileName = this.profileOverride
|
|
947
|
+
const profileName = this.profileOverride;
|
|
948
948
|
const credentials = await this.getCredentials(profileName);
|
|
949
949
|
if (!credentials) {
|
|
950
950
|
const displayName = profileName || "default";
|
|
@@ -976,7 +976,7 @@ class CredentialsManager {
|
|
|
976
976
|
});
|
|
977
977
|
const agentApiUrl = agentInfo.apiUrl;
|
|
978
978
|
let baseCredentials;
|
|
979
|
-
const hasExplicitProfile = !!
|
|
979
|
+
const hasExplicitProfile = !!this.profileOverride;
|
|
980
980
|
if (hasExplicitProfile) {
|
|
981
981
|
baseCredentials = await this.getActiveCredentials();
|
|
982
982
|
} else {
|
|
@@ -1766,6 +1766,8 @@ function normalize(value) {
|
|
|
1766
1766
|
var init_search_ranking = () => {};
|
|
1767
1767
|
|
|
1768
1768
|
// src/integrations/manager.ts
|
|
1769
|
+
import { Client as Client3 } from "@botpress/client";
|
|
1770
|
+
|
|
1769
1771
|
class IntegrationManager {
|
|
1770
1772
|
cache;
|
|
1771
1773
|
options;
|
|
@@ -1776,15 +1778,33 @@ class IntegrationManager {
|
|
|
1776
1778
|
}
|
|
1777
1779
|
async getClient() {
|
|
1778
1780
|
if (!this.client) {
|
|
1779
|
-
this.
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1781
|
+
const hasProjectScope = !!(this.options.project || this.options.workspaceId);
|
|
1782
|
+
if (hasProjectScope) {
|
|
1783
|
+
this.client = await getProjectClient({
|
|
1784
|
+
project: this.options.project,
|
|
1785
|
+
credentials: this.options.credentials,
|
|
1786
|
+
apiUrl: this.options.apiUrl,
|
|
1787
|
+
workspaceId: this.options.workspaceId,
|
|
1788
|
+
headers: {
|
|
1789
|
+
"x-multiple-integrations": "true"
|
|
1790
|
+
}
|
|
1791
|
+
});
|
|
1792
|
+
} else if (this.options.credentials) {
|
|
1793
|
+
this.client = new Client3({
|
|
1794
|
+
token: this.options.credentials.token,
|
|
1795
|
+
apiUrl: this.options.apiUrl || this.options.credentials.apiUrl,
|
|
1796
|
+
...this.options.credentials.workspaceId ? { workspaceId: this.options.credentials.workspaceId } : {},
|
|
1797
|
+
headers: {
|
|
1798
|
+
"x-multiple-integrations": "true"
|
|
1799
|
+
}
|
|
1800
|
+
});
|
|
1801
|
+
} else {
|
|
1802
|
+
this.client = await getProjectClient({
|
|
1803
|
+
headers: {
|
|
1804
|
+
"x-multiple-integrations": "true"
|
|
1805
|
+
}
|
|
1806
|
+
});
|
|
1807
|
+
}
|
|
1788
1808
|
}
|
|
1789
1809
|
return this.client;
|
|
1790
1810
|
}
|
|
@@ -2157,11 +2177,13 @@ class AssetsManager {
|
|
|
2157
2177
|
assetsPath;
|
|
2158
2178
|
client;
|
|
2159
2179
|
botId;
|
|
2180
|
+
credentials;
|
|
2160
2181
|
cacheManager;
|
|
2161
2182
|
constructor(options) {
|
|
2162
2183
|
this.projectPath = options.projectPath;
|
|
2163
2184
|
this.assetsPath = path8.join(this.projectPath, "assets");
|
|
2164
2185
|
this.botId = options.botId;
|
|
2186
|
+
this.credentials = options.credentials;
|
|
2165
2187
|
this.cacheManager = new AssetsCacheManager(this.projectPath);
|
|
2166
2188
|
}
|
|
2167
2189
|
async getClient() {
|
|
@@ -2176,6 +2198,7 @@ class AssetsManager {
|
|
|
2176
2198
|
}
|
|
2177
2199
|
this.client = await getProjectClient({
|
|
2178
2200
|
project: { path: this.projectPath },
|
|
2201
|
+
credentials: this.credentials,
|
|
2179
2202
|
botId: this.botId,
|
|
2180
2203
|
headers: {
|
|
2181
2204
|
"x-multiple-integrations": "true"
|
|
@@ -2633,171 +2656,6 @@ class IntegrationCache {
|
|
|
2633
2656
|
}
|
|
2634
2657
|
var init_cache2 = () => {};
|
|
2635
2658
|
|
|
2636
|
-
// src/integrations/hub-cache.ts
|
|
2637
|
-
import { Client as Client3 } from "@botpress/client";
|
|
2638
|
-
import * as fs10 from "fs/promises";
|
|
2639
|
-
import * as path10 from "path";
|
|
2640
|
-
import * as os6 from "os";
|
|
2641
|
-
var HubCache;
|
|
2642
|
-
var init_hub_cache = __esm(() => {
|
|
2643
|
-
init_src();
|
|
2644
|
-
init_auth();
|
|
2645
|
-
HubCache = class HubCache {
|
|
2646
|
-
static CACHE_FILE = "botpress-hub-cache.json";
|
|
2647
|
-
static CACHE_DIR = path10.join(os6.homedir(), ".adk", "cache");
|
|
2648
|
-
static CACHE_PATH = path10.join(HubCache.CACHE_DIR, HubCache.CACHE_FILE);
|
|
2649
|
-
static CACHE_DURATION = 30 * 60 * 1000;
|
|
2650
|
-
client;
|
|
2651
|
-
constructor() {}
|
|
2652
|
-
async getClient() {
|
|
2653
|
-
if (!this.client) {
|
|
2654
|
-
const credentials = await auth.getActiveCredentials();
|
|
2655
|
-
if (!credentials.workspaceId) {
|
|
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
|
-
});
|
|
2662
|
-
}
|
|
2663
|
-
this.client = new Client3({
|
|
2664
|
-
token: credentials.token,
|
|
2665
|
-
apiUrl: credentials.apiUrl,
|
|
2666
|
-
workspaceId: credentials.workspaceId,
|
|
2667
|
-
headers: {
|
|
2668
|
-
"x-multiple-integrations": "true"
|
|
2669
|
-
}
|
|
2670
|
-
});
|
|
2671
|
-
}
|
|
2672
|
-
return this.client;
|
|
2673
|
-
}
|
|
2674
|
-
async ensureCacheDir() {
|
|
2675
|
-
try {
|
|
2676
|
-
await fs10.mkdir(HubCache.CACHE_DIR, { recursive: true });
|
|
2677
|
-
} catch {}
|
|
2678
|
-
}
|
|
2679
|
-
async loadCache() {
|
|
2680
|
-
try {
|
|
2681
|
-
const data = await fs10.readFile(HubCache.CACHE_PATH, "utf-8");
|
|
2682
|
-
return JSON.parse(data);
|
|
2683
|
-
} catch {
|
|
2684
|
-
return null;
|
|
2685
|
-
}
|
|
2686
|
-
}
|
|
2687
|
-
async saveCache(data) {
|
|
2688
|
-
await this.ensureCacheDir();
|
|
2689
|
-
await fs10.writeFile(HubCache.CACHE_PATH, JSON.stringify(data, null, 2));
|
|
2690
|
-
}
|
|
2691
|
-
async needsRefresh() {
|
|
2692
|
-
const cache2 = await this.loadCache();
|
|
2693
|
-
if (!cache2)
|
|
2694
|
-
return true;
|
|
2695
|
-
const lastUpdated = new Date(cache2.lastUpdated);
|
|
2696
|
-
const now = new Date;
|
|
2697
|
-
const diff = now.getTime() - lastUpdated.getTime();
|
|
2698
|
-
return diff > HubCache.CACHE_DURATION;
|
|
2699
|
-
}
|
|
2700
|
-
async refresh(force = false) {
|
|
2701
|
-
if (!force && !await this.needsRefresh()) {
|
|
2702
|
-
return;
|
|
2703
|
-
}
|
|
2704
|
-
const client = await this.getClient();
|
|
2705
|
-
const cache2 = await this.loadCache();
|
|
2706
|
-
const latestByName = new Map;
|
|
2707
|
-
if (cache2) {
|
|
2708
|
-
for (const entry of cache2.integrations) {
|
|
2709
|
-
latestByName.set(entry.name, entry);
|
|
2710
|
-
}
|
|
2711
|
-
}
|
|
2712
|
-
try {
|
|
2713
|
-
for await (const integration of client.list.publicIntegrations({
|
|
2714
|
-
sortBy: "updatedAt",
|
|
2715
|
-
direction: "desc"
|
|
2716
|
-
})) {
|
|
2717
|
-
const existing = latestByName.get(integration.name);
|
|
2718
|
-
if (existing && integration.id === existing.id && integration.updatedAt === existing.updatedAt) {
|
|
2719
|
-
break;
|
|
2720
|
-
}
|
|
2721
|
-
if (!existing || integration.version.localeCompare(existing.version, undefined, {
|
|
2722
|
-
numeric: true
|
|
2723
|
-
}) > 0) {
|
|
2724
|
-
latestByName.set(integration.name, {
|
|
2725
|
-
id: integration.id,
|
|
2726
|
-
name: integration.name,
|
|
2727
|
-
version: integration.version,
|
|
2728
|
-
updatedAt: integration.updatedAt,
|
|
2729
|
-
createdAt: integration.createdAt,
|
|
2730
|
-
title: integration.title,
|
|
2731
|
-
description: integration.description,
|
|
2732
|
-
iconUrl: integration.iconUrl,
|
|
2733
|
-
public: integration.public,
|
|
2734
|
-
visibility: integration.visibility,
|
|
2735
|
-
ownerWorkspace: integration.ownerWorkspace ? {
|
|
2736
|
-
id: integration.ownerWorkspace.id,
|
|
2737
|
-
name: integration.ownerWorkspace.name
|
|
2738
|
-
} : undefined,
|
|
2739
|
-
verificationStatus: integration.verificationStatus
|
|
2740
|
-
});
|
|
2741
|
-
}
|
|
2742
|
-
}
|
|
2743
|
-
const integrations = Array.from(latestByName.values()).sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
2744
|
-
const newCache = {
|
|
2745
|
-
lastUpdated: new Date().toISOString(),
|
|
2746
|
-
integrations
|
|
2747
|
-
};
|
|
2748
|
-
await this.saveCache(newCache);
|
|
2749
|
-
} catch (error) {
|
|
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
|
-
});
|
|
2756
|
-
}
|
|
2757
|
-
}
|
|
2758
|
-
async getAllIntegrations() {
|
|
2759
|
-
await this.refresh();
|
|
2760
|
-
const cache2 = await this.loadCache();
|
|
2761
|
-
return cache2?.integrations || [];
|
|
2762
|
-
}
|
|
2763
|
-
async searchIntegrations(query) {
|
|
2764
|
-
const integrations = await this.getAllIntegrations();
|
|
2765
|
-
const lowerQuery = query.toLowerCase();
|
|
2766
|
-
return integrations.filter((integration) => integration.name.toLowerCase().includes(lowerQuery) || integration.title?.toLowerCase().includes(lowerQuery) || integration.description?.toLowerCase().includes(lowerQuery));
|
|
2767
|
-
}
|
|
2768
|
-
async getIntegrationByName(name) {
|
|
2769
|
-
const integrations = await this.getAllIntegrations();
|
|
2770
|
-
return integrations.find((i) => i.name === name) || null;
|
|
2771
|
-
}
|
|
2772
|
-
async getIntegrationVersions(name) {
|
|
2773
|
-
const integration = await this.getIntegrationByName(name);
|
|
2774
|
-
return integration ? [integration.version] : [];
|
|
2775
|
-
}
|
|
2776
|
-
async getStats() {
|
|
2777
|
-
const cache2 = await this.loadCache();
|
|
2778
|
-
try {
|
|
2779
|
-
const stats = await fs10.stat(HubCache.CACHE_PATH);
|
|
2780
|
-
return {
|
|
2781
|
-
lastUpdated: cache2 ? new Date(cache2.lastUpdated) : null,
|
|
2782
|
-
integrationCount: cache2?.integrations.length || 0,
|
|
2783
|
-
cacheSize: stats.size
|
|
2784
|
-
};
|
|
2785
|
-
} catch {
|
|
2786
|
-
return {
|
|
2787
|
-
lastUpdated: null,
|
|
2788
|
-
integrationCount: 0,
|
|
2789
|
-
cacheSize: 0
|
|
2790
|
-
};
|
|
2791
|
-
}
|
|
2792
|
-
}
|
|
2793
|
-
async clear() {
|
|
2794
|
-
try {
|
|
2795
|
-
await fs10.unlink(HubCache.CACHE_PATH);
|
|
2796
|
-
} catch {}
|
|
2797
|
-
}
|
|
2798
|
-
};
|
|
2799
|
-
});
|
|
2800
|
-
|
|
2801
2659
|
// src/integrations/config-utils.ts
|
|
2802
2660
|
function mergeIntegrationConfig(current, desired) {
|
|
2803
2661
|
if (desired === undefined) {
|
|
@@ -2896,14 +2754,13 @@ var init_integrations = __esm(() => {
|
|
|
2896
2754
|
init_dependencies_parser();
|
|
2897
2755
|
init_cache2();
|
|
2898
2756
|
init_enhanced_cache();
|
|
2899
|
-
init_hub_cache();
|
|
2900
2757
|
init_config_utils();
|
|
2901
2758
|
});
|
|
2902
2759
|
|
|
2903
2760
|
// src/interfaces/enhanced-cache.ts
|
|
2904
|
-
import
|
|
2905
|
-
import
|
|
2906
|
-
import
|
|
2761
|
+
import fs10 from "fs/promises";
|
|
2762
|
+
import path10 from "path";
|
|
2763
|
+
import os6 from "os";
|
|
2907
2764
|
|
|
2908
2765
|
class EnhancedInterfaceCache {
|
|
2909
2766
|
cacheDir;
|
|
@@ -2912,21 +2769,21 @@ class EnhancedInterfaceCache {
|
|
|
2912
2769
|
noCache;
|
|
2913
2770
|
constructor(noCache = false) {
|
|
2914
2771
|
this.noCache = noCache;
|
|
2915
|
-
this.cacheDir =
|
|
2916
|
-
this.resolutionsDir =
|
|
2917
|
-
this.definitionsDir =
|
|
2772
|
+
this.cacheDir = path10.join(os6.homedir(), ".adk", "cache", "interfaces");
|
|
2773
|
+
this.resolutionsDir = path10.join(this.cacheDir, "resolutions");
|
|
2774
|
+
this.definitionsDir = path10.join(this.cacheDir, "definitions");
|
|
2918
2775
|
}
|
|
2919
2776
|
async ensureCacheDirs() {
|
|
2920
|
-
await
|
|
2921
|
-
await
|
|
2777
|
+
await fs10.mkdir(this.resolutionsDir, { recursive: true });
|
|
2778
|
+
await fs10.mkdir(this.definitionsDir, { recursive: true });
|
|
2922
2779
|
}
|
|
2923
2780
|
async getResolution(name, version, workspace) {
|
|
2924
2781
|
if (this.noCache)
|
|
2925
2782
|
return null;
|
|
2926
2783
|
try {
|
|
2927
2784
|
const key = this.getResolutionKey(name, version, workspace);
|
|
2928
|
-
const cachePath =
|
|
2929
|
-
const data = await
|
|
2785
|
+
const cachePath = path10.join(this.resolutionsDir, `${key}.json`);
|
|
2786
|
+
const data = await fs10.readFile(cachePath, "utf-8");
|
|
2930
2787
|
const resolution = JSON.parse(data);
|
|
2931
2788
|
const cachedAt = new Date(resolution.cachedAt);
|
|
2932
2789
|
const ageMinutes = (Date.now() - cachedAt.getTime()) / (1000 * 60);
|
|
@@ -2940,21 +2797,21 @@ class EnhancedInterfaceCache {
|
|
|
2940
2797
|
async setResolution(name, version, workspace, interfaceId, updatedAt) {
|
|
2941
2798
|
await this.ensureCacheDirs();
|
|
2942
2799
|
const key = this.getResolutionKey(name, version, workspace);
|
|
2943
|
-
const cachePath =
|
|
2800
|
+
const cachePath = path10.join(this.resolutionsDir, `${key}.json`);
|
|
2944
2801
|
const resolution = {
|
|
2945
2802
|
interfaceId,
|
|
2946
2803
|
updatedAt,
|
|
2947
2804
|
cachedAt: new Date().toISOString()
|
|
2948
2805
|
};
|
|
2949
|
-
await
|
|
2806
|
+
await fs10.writeFile(cachePath, JSON.stringify(resolution));
|
|
2950
2807
|
}
|
|
2951
2808
|
async getDefinition(interfaceId, updatedAt) {
|
|
2952
2809
|
if (this.noCache)
|
|
2953
2810
|
return null;
|
|
2954
2811
|
try {
|
|
2955
2812
|
const key = this.getDefinitionKey(interfaceId, updatedAt);
|
|
2956
|
-
const cachePath =
|
|
2957
|
-
const data = await
|
|
2813
|
+
const cachePath = path10.join(this.definitionsDir, `${key}.json`);
|
|
2814
|
+
const data = await fs10.readFile(cachePath, "utf-8");
|
|
2958
2815
|
const cached = JSON.parse(data);
|
|
2959
2816
|
return cached.definition;
|
|
2960
2817
|
} catch {
|
|
@@ -2964,28 +2821,28 @@ class EnhancedInterfaceCache {
|
|
|
2964
2821
|
async setDefinition(interfaceId, updatedAt, definition) {
|
|
2965
2822
|
await this.ensureCacheDirs();
|
|
2966
2823
|
const key = this.getDefinitionKey(interfaceId, updatedAt);
|
|
2967
|
-
const cachePath =
|
|
2824
|
+
const cachePath = path10.join(this.definitionsDir, `${key}.json`);
|
|
2968
2825
|
const cached = {
|
|
2969
2826
|
definition,
|
|
2970
2827
|
cachedAt: new Date().toISOString()
|
|
2971
2828
|
};
|
|
2972
|
-
await
|
|
2829
|
+
await fs10.writeFile(cachePath, JSON.stringify(cached));
|
|
2973
2830
|
}
|
|
2974
2831
|
async clear() {
|
|
2975
2832
|
try {
|
|
2976
|
-
const resolutionFiles = await
|
|
2977
|
-
await Promise.all(resolutionFiles.map((f) =>
|
|
2978
|
-
const definitionFiles = await
|
|
2979
|
-
await Promise.all(definitionFiles.map((f) =>
|
|
2833
|
+
const resolutionFiles = await fs10.readdir(this.resolutionsDir);
|
|
2834
|
+
await Promise.all(resolutionFiles.map((f) => fs10.unlink(path10.join(this.resolutionsDir, f))));
|
|
2835
|
+
const definitionFiles = await fs10.readdir(this.definitionsDir);
|
|
2836
|
+
await Promise.all(definitionFiles.map((f) => fs10.unlink(path10.join(this.definitionsDir, f))));
|
|
2980
2837
|
} catch {}
|
|
2981
2838
|
}
|
|
2982
2839
|
async getStats() {
|
|
2983
2840
|
const getDirectoryStats = async (dir) => {
|
|
2984
2841
|
try {
|
|
2985
|
-
const files = await
|
|
2842
|
+
const files = await fs10.readdir(dir);
|
|
2986
2843
|
let totalSize = 0;
|
|
2987
2844
|
for (const file of files) {
|
|
2988
|
-
const stats = await
|
|
2845
|
+
const stats = await fs10.stat(path10.join(dir, file));
|
|
2989
2846
|
totalSize += stats.size;
|
|
2990
2847
|
}
|
|
2991
2848
|
return { count: files.length, sizeBytes: totalSize };
|
|
@@ -3382,7 +3239,7 @@ var init_component_files = __esm(() => {
|
|
|
3382
3239
|
// src/agent-project/component-source-resolver.ts
|
|
3383
3240
|
import { Project, SyntaxKind } from "ts-morph";
|
|
3384
3241
|
import { readFileSync } from "fs";
|
|
3385
|
-
import * as
|
|
3242
|
+
import * as path11 from "path";
|
|
3386
3243
|
function resolveComponentSources(absolutePath) {
|
|
3387
3244
|
const project = new Project({ useInMemoryFileSystem: false, skipAddingFilesFromTsConfig: true });
|
|
3388
3245
|
const sourceFile = project.createSourceFile(absolutePath, readFileSync(absolutePath, "utf-8"), { overwrite: true });
|
|
@@ -3395,12 +3252,12 @@ function resolveComponentSources(absolutePath) {
|
|
|
3395
3252
|
}
|
|
3396
3253
|
function collectBpTsxImports(sourceFile, absolutePath) {
|
|
3397
3254
|
const imports = new Map;
|
|
3398
|
-
const dir =
|
|
3255
|
+
const dir = path11.dirname(absolutePath);
|
|
3399
3256
|
for (const decl of sourceFile.getImportDeclarations()) {
|
|
3400
3257
|
const specifier = decl.getModuleSpecifierValue();
|
|
3401
3258
|
if (!specifier.endsWith(BP_TSX_SUFFIX))
|
|
3402
3259
|
continue;
|
|
3403
|
-
const resolved =
|
|
3260
|
+
const resolved = path11.resolve(dir, specifier);
|
|
3404
3261
|
const defaultImport = decl.getDefaultImport();
|
|
3405
3262
|
if (defaultImport) {
|
|
3406
3263
|
imports.set(defaultImport.getText(), resolved);
|
|
@@ -3526,8 +3383,8 @@ import { BuiltInActions, BuiltInWorkflows, Errors as Errors2, Primitives as Prim
|
|
|
3526
3383
|
import { Autonomous } from "@botpress/runtime";
|
|
3527
3384
|
import createDebug from "debug";
|
|
3528
3385
|
import { createRequire as createRequire2 } from "module";
|
|
3529
|
-
import
|
|
3530
|
-
import
|
|
3386
|
+
import fs11 from "fs/promises";
|
|
3387
|
+
import path12 from "path";
|
|
3531
3388
|
function getToolDefinition(value) {
|
|
3532
3389
|
if (typeof value !== "object" || value === null) {
|
|
3533
3390
|
return;
|
|
@@ -3586,7 +3443,7 @@ var init_agent_project = __esm(() => {
|
|
|
3586
3443
|
_tools = [];
|
|
3587
3444
|
constructor(projectPath, options = {}) {
|
|
3588
3445
|
this._options = options;
|
|
3589
|
-
this._path =
|
|
3446
|
+
this._path = path12.resolve(projectPath);
|
|
3590
3447
|
this._integrationManager = new IntegrationManager({
|
|
3591
3448
|
noCache: options.noCache
|
|
3592
3449
|
});
|
|
@@ -3598,7 +3455,7 @@ var init_agent_project = __esm(() => {
|
|
|
3598
3455
|
});
|
|
3599
3456
|
}
|
|
3600
3457
|
static async load(projectPath, options = {}) {
|
|
3601
|
-
const resolvedPath =
|
|
3458
|
+
const resolvedPath = path12.resolve(projectPath);
|
|
3602
3459
|
if (!options.noCache) {
|
|
3603
3460
|
const cached = AgentProject._projectCache.get(resolvedPath);
|
|
3604
3461
|
if (cached) {
|
|
@@ -3616,7 +3473,7 @@ var init_agent_project = __esm(() => {
|
|
|
3616
3473
|
AgentProject._projectCache.clear();
|
|
3617
3474
|
}
|
|
3618
3475
|
static clearCacheForPath(projectPath) {
|
|
3619
|
-
const resolvedPath =
|
|
3476
|
+
const resolvedPath = path12.resolve(projectPath);
|
|
3620
3477
|
AgentProject._projectCache.delete(resolvedPath);
|
|
3621
3478
|
}
|
|
3622
3479
|
get path() {
|
|
@@ -3732,17 +3589,17 @@ var init_agent_project = __esm(() => {
|
|
|
3732
3589
|
const warnings = [];
|
|
3733
3590
|
const info = [];
|
|
3734
3591
|
try {
|
|
3735
|
-
await
|
|
3592
|
+
await fs11.access(this._path);
|
|
3736
3593
|
const requiredFiles = ["agent.config.ts"];
|
|
3737
3594
|
for (const file of requiredFiles) {
|
|
3738
3595
|
try {
|
|
3739
|
-
await
|
|
3596
|
+
await fs11.access(path12.join(this._path, file));
|
|
3740
3597
|
} catch {
|
|
3741
3598
|
errors.push(ValidationErrors.requiredFileMissing(file));
|
|
3742
3599
|
}
|
|
3743
3600
|
}
|
|
3744
3601
|
try {
|
|
3745
|
-
await
|
|
3602
|
+
await fs11.access(path12.join(this._path, "agent.json"));
|
|
3746
3603
|
} catch {
|
|
3747
3604
|
info.push({
|
|
3748
3605
|
$type: "ValidationError",
|
|
@@ -3756,7 +3613,7 @@ var init_agent_project = __esm(() => {
|
|
|
3756
3613
|
const expectedDirs = ["actions", "workflows", "conversations", "assets"];
|
|
3757
3614
|
for (const dir of expectedDirs) {
|
|
3758
3615
|
try {
|
|
3759
|
-
const stats = await
|
|
3616
|
+
const stats = await fs11.stat(path12.join(this._path, dir));
|
|
3760
3617
|
if (!stats.isDirectory()) {
|
|
3761
3618
|
warnings.push(ValidationErrors.invalidStructure(dir, "directory"));
|
|
3762
3619
|
}
|
|
@@ -3840,9 +3697,9 @@ var init_agent_project = __esm(() => {
|
|
|
3840
3697
|
}
|
|
3841
3698
|
async createAgentInfo(info) {
|
|
3842
3699
|
const { devId, ...agentJsonInfo } = info;
|
|
3843
|
-
const agentPath =
|
|
3700
|
+
const agentPath = path12.join(this._path, "agent.json");
|
|
3844
3701
|
const agentContent = stringifyWithOrder(agentJsonInfo, agentInfoKeyOrder);
|
|
3845
|
-
await
|
|
3702
|
+
await fs11.writeFile(agentPath, agentContent);
|
|
3846
3703
|
this._agentInfo = info;
|
|
3847
3704
|
if (devId) {
|
|
3848
3705
|
await this.createAgentLocalInfo({ devId });
|
|
@@ -3859,24 +3716,24 @@ var init_agent_project = __esm(() => {
|
|
|
3859
3716
|
const { devId, ...agentJsonUpdates } = updates;
|
|
3860
3717
|
const updatedInfo = { ...this._agentInfo, ...agentJsonUpdates };
|
|
3861
3718
|
const { devId: _devId, ...agentJsonData } = updatedInfo;
|
|
3862
|
-
const agentPath =
|
|
3719
|
+
const agentPath = path12.join(this._path, "agent.json");
|
|
3863
3720
|
const agentContent = stringifyWithOrder(agentJsonData, agentInfoKeyOrder);
|
|
3864
|
-
await
|
|
3721
|
+
await fs11.writeFile(agentPath, agentContent);
|
|
3865
3722
|
this._agentInfo = updatedInfo;
|
|
3866
3723
|
if (devId !== undefined) {
|
|
3867
3724
|
await this.updateAgentLocalInfo({ devId });
|
|
3868
3725
|
}
|
|
3869
3726
|
}
|
|
3870
3727
|
async createAgentLocalInfo(info) {
|
|
3871
|
-
const localPath =
|
|
3728
|
+
const localPath = path12.join(this._path, "agent.local.json");
|
|
3872
3729
|
let existing = {};
|
|
3873
3730
|
try {
|
|
3874
|
-
const content2 = await
|
|
3731
|
+
const content2 = await fs11.readFile(localPath, "utf-8");
|
|
3875
3732
|
existing = JSON.parse(content2);
|
|
3876
3733
|
} catch {}
|
|
3877
3734
|
const merged = { ...existing, ...info };
|
|
3878
3735
|
const content = stringifyWithOrder(merged, agentLocalInfoKeyOrder);
|
|
3879
|
-
await
|
|
3736
|
+
await fs11.writeFile(localPath, content);
|
|
3880
3737
|
if (this._agentInfo) {
|
|
3881
3738
|
if (merged.botId)
|
|
3882
3739
|
this._agentInfo.botId = merged.botId;
|
|
@@ -3896,10 +3753,10 @@ var init_agent_project = __esm(() => {
|
|
|
3896
3753
|
}
|
|
3897
3754
|
}
|
|
3898
3755
|
async updateAgentLocalInfo(updates) {
|
|
3899
|
-
const localPath =
|
|
3756
|
+
const localPath = path12.join(this._path, "agent.local.json");
|
|
3900
3757
|
let existing = {};
|
|
3901
3758
|
try {
|
|
3902
|
-
const content = await
|
|
3759
|
+
const content = await fs11.readFile(localPath, "utf-8");
|
|
3903
3760
|
existing = JSON.parse(content);
|
|
3904
3761
|
} catch {}
|
|
3905
3762
|
const updated = { ...existing, ...updates };
|
|
@@ -3910,21 +3767,21 @@ var init_agent_project = __esm(() => {
|
|
|
3910
3767
|
}
|
|
3911
3768
|
if (Object.keys(updated).length === 0) {
|
|
3912
3769
|
try {
|
|
3913
|
-
await
|
|
3770
|
+
await fs11.unlink(localPath);
|
|
3914
3771
|
} catch {}
|
|
3915
3772
|
} else {
|
|
3916
3773
|
const content = stringifyWithOrder(updated, agentLocalInfoKeyOrder);
|
|
3917
|
-
await
|
|
3774
|
+
await fs11.writeFile(localPath, content);
|
|
3918
3775
|
}
|
|
3919
3776
|
if (this._agentInfo) {
|
|
3920
|
-
const agentJsonPath =
|
|
3777
|
+
const agentJsonPath = path12.join(this._path, "agent.json");
|
|
3921
3778
|
let base = {
|
|
3922
3779
|
botId: this._agentInfo.botId,
|
|
3923
3780
|
workspaceId: this._agentInfo.workspaceId,
|
|
3924
3781
|
apiUrl: this._agentInfo.apiUrl
|
|
3925
3782
|
};
|
|
3926
3783
|
try {
|
|
3927
|
-
const agentJsonContent = await
|
|
3784
|
+
const agentJsonContent = await fs11.readFile(agentJsonPath, "utf-8");
|
|
3928
3785
|
const parsed = JSON.parse(agentJsonContent);
|
|
3929
3786
|
base = {
|
|
3930
3787
|
botId: parsed.botId ?? this._agentInfo.botId,
|
|
@@ -3956,10 +3813,10 @@ var init_agent_project = __esm(() => {
|
|
|
3956
3813
|
this._integrations = [];
|
|
3957
3814
|
this._interfaces = [];
|
|
3958
3815
|
try {
|
|
3959
|
-
const configPath =
|
|
3816
|
+
const configPath = path12.join(this._path, "agent.config.ts");
|
|
3960
3817
|
debug("loading agent.config.ts from %s", configPath);
|
|
3961
|
-
const projectRequire = createRequire2(
|
|
3962
|
-
debug("created projectRequire from %s",
|
|
3818
|
+
const projectRequire = createRequire2(path12.join(this._path, "package.json"));
|
|
3819
|
+
debug("created projectRequire from %s", path12.join(this._path, "package.json"));
|
|
3963
3820
|
try {
|
|
3964
3821
|
const resolvedPath = projectRequire.resolve(configPath);
|
|
3965
3822
|
debug("resolved config path: %s", resolvedPath);
|
|
@@ -4156,8 +4013,8 @@ ${err.stack?.split(`
|
|
|
4156
4013
|
}
|
|
4157
4014
|
}
|
|
4158
4015
|
isBarrelReexport(existing, newPath, newExport, newDefinition) {
|
|
4159
|
-
const isNewBarrel = /^index\.[tj]s$/i.test(
|
|
4160
|
-
const isExistingBarrel = /^index\.[tj]s$/i.test(
|
|
4016
|
+
const isNewBarrel = /^index\.[tj]s$/i.test(path12.basename(newPath));
|
|
4017
|
+
const isExistingBarrel = /^index\.[tj]s$/i.test(path12.basename(existing.path));
|
|
4161
4018
|
if (!isNewBarrel && !isExistingBarrel) {
|
|
4162
4019
|
return false;
|
|
4163
4020
|
}
|
|
@@ -4169,16 +4026,16 @@ ${err.stack?.split(`
|
|
|
4169
4026
|
return true;
|
|
4170
4027
|
}
|
|
4171
4028
|
isToolBarrelReexport(existingPath, newPath) {
|
|
4172
|
-
const isNewBarrel = /^index\.[tj]s$/i.test(
|
|
4173
|
-
const isExistingBarrel = /^index\.[tj]s$/i.test(
|
|
4029
|
+
const isNewBarrel = /^index\.[tj]s$/i.test(path12.basename(newPath));
|
|
4030
|
+
const isExistingBarrel = /^index\.[tj]s$/i.test(path12.basename(existingPath));
|
|
4174
4031
|
if (!isNewBarrel && !isExistingBarrel) {
|
|
4175
4032
|
return false;
|
|
4176
4033
|
}
|
|
4177
4034
|
return true;
|
|
4178
4035
|
}
|
|
4179
4036
|
shouldPreferToolDefinition(existingPath, newPath) {
|
|
4180
|
-
const isNewBarrel = /^index\.[tj]s$/i.test(
|
|
4181
|
-
const isExistingBarrel = /^index\.[tj]s$/i.test(
|
|
4037
|
+
const isNewBarrel = /^index\.[tj]s$/i.test(path12.basename(newPath));
|
|
4038
|
+
const isExistingBarrel = /^index\.[tj]s$/i.test(path12.basename(existingPath));
|
|
4182
4039
|
return isExistingBarrel && !isNewBarrel;
|
|
4183
4040
|
}
|
|
4184
4041
|
getChannelsList(channelSpec) {
|
|
@@ -4194,8 +4051,8 @@ ${err.stack?.split(`
|
|
|
4194
4051
|
if (this._options.adkCommand) {
|
|
4195
4052
|
setAdkCommand(this._options.adkCommand);
|
|
4196
4053
|
}
|
|
4197
|
-
const src =
|
|
4198
|
-
if (!await
|
|
4054
|
+
const src = path12.join(this._path, "src");
|
|
4055
|
+
if (!await fs11.stat(src).catch(() => false)) {
|
|
4199
4056
|
this._errors.push({
|
|
4200
4057
|
$type: "ValidationError",
|
|
4201
4058
|
code: "INVALID_STRUCTURE" /* INVALID_STRUCTURE */,
|
|
@@ -4204,14 +4061,14 @@ ${err.stack?.split(`
|
|
|
4204
4061
|
});
|
|
4205
4062
|
return;
|
|
4206
4063
|
}
|
|
4207
|
-
const allFiles = await
|
|
4064
|
+
const allFiles = await fs11.readdir(src, {
|
|
4208
4065
|
withFileTypes: true,
|
|
4209
4066
|
recursive: true
|
|
4210
4067
|
});
|
|
4211
4068
|
for (const file of allFiles.filter((x) => x.isFile())) {
|
|
4212
4069
|
const filename = file.name;
|
|
4213
|
-
const absolutePath =
|
|
4214
|
-
const relPath =
|
|
4070
|
+
const absolutePath = path12.join(file.parentPath, file.name);
|
|
4071
|
+
const relPath = path12.relative(this.path, absolutePath);
|
|
4215
4072
|
if (filename.toLowerCase().endsWith(".d.ts")) {
|
|
4216
4073
|
continue;
|
|
4217
4074
|
}
|
|
@@ -4498,7 +4355,7 @@ ${err.stack?.split(`
|
|
|
4498
4355
|
});
|
|
4499
4356
|
|
|
4500
4357
|
// src/generators/utils.ts
|
|
4501
|
-
import
|
|
4358
|
+
import path13 from "path";
|
|
4502
4359
|
async function getFormat() {
|
|
4503
4360
|
if (!_formatLoaded) {
|
|
4504
4361
|
_formatLoaded = true;
|
|
@@ -4546,9 +4403,9 @@ var _format = null, _formatLoaded = false, formatCode = async (code, filepath) =
|
|
|
4546
4403
|
`));
|
|
4547
4404
|
return code;
|
|
4548
4405
|
}
|
|
4549
|
-
}, ADK_VERSION = "1.19.0-beta.
|
|
4550
|
-
const fromDir =
|
|
4551
|
-
const relative2 =
|
|
4406
|
+
}, ADK_VERSION = "1.19.0-beta.13", relative = (from, to) => {
|
|
4407
|
+
const fromDir = path13.dirname(from);
|
|
4408
|
+
const relative2 = path13.relative(fromDir, to);
|
|
4552
4409
|
return relative2.startsWith(".") ? relative2 : `./${relative2}`;
|
|
4553
4410
|
};
|
|
4554
4411
|
var init_utils = () => {};
|
|
@@ -4765,6 +4622,7 @@ class IntegrationRegistry {
|
|
|
4765
4622
|
// src/plugins/manager.ts
|
|
4766
4623
|
init_src();
|
|
4767
4624
|
init_auth();
|
|
4625
|
+
import { Client as Client4 } from "@botpress/client";
|
|
4768
4626
|
|
|
4769
4627
|
// src/plugins/enhanced-cache.ts
|
|
4770
4628
|
import fs6 from "fs/promises";
|
|
@@ -4897,15 +4755,33 @@ class PluginManager {
|
|
|
4897
4755
|
}
|
|
4898
4756
|
async getClient() {
|
|
4899
4757
|
if (!this.client) {
|
|
4900
|
-
this.
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
4904
|
-
|
|
4905
|
-
|
|
4906
|
-
|
|
4907
|
-
|
|
4908
|
-
|
|
4758
|
+
const hasProjectScope = !!(this.options.project || this.options.workspaceId);
|
|
4759
|
+
if (hasProjectScope) {
|
|
4760
|
+
this.client = await getProjectClient({
|
|
4761
|
+
project: this.options.project,
|
|
4762
|
+
credentials: this.options.credentials,
|
|
4763
|
+
apiUrl: this.options.apiUrl,
|
|
4764
|
+
workspaceId: this.options.workspaceId,
|
|
4765
|
+
headers: {
|
|
4766
|
+
"x-multiple-integrations": "true"
|
|
4767
|
+
}
|
|
4768
|
+
});
|
|
4769
|
+
} else if (this.options.credentials) {
|
|
4770
|
+
this.client = new Client4({
|
|
4771
|
+
token: this.options.credentials.token,
|
|
4772
|
+
apiUrl: this.options.apiUrl || this.options.credentials.apiUrl,
|
|
4773
|
+
...this.options.credentials.workspaceId ? { workspaceId: this.options.credentials.workspaceId } : {},
|
|
4774
|
+
headers: {
|
|
4775
|
+
"x-multiple-integrations": "true"
|
|
4776
|
+
}
|
|
4777
|
+
});
|
|
4778
|
+
} else {
|
|
4779
|
+
this.client = await getProjectClient({
|
|
4780
|
+
headers: {
|
|
4781
|
+
"x-multiple-integrations": "true"
|
|
4782
|
+
}
|
|
4783
|
+
});
|
|
4784
|
+
}
|
|
4909
4785
|
}
|
|
4910
4786
|
return this.client;
|
|
4911
4787
|
}
|
|
@@ -5735,8 +5611,8 @@ class InterfaceRegistry {
|
|
|
5735
5611
|
}
|
|
5736
5612
|
// src/dependencies/migration.ts
|
|
5737
5613
|
init_lock_file();
|
|
5738
|
-
import * as
|
|
5739
|
-
import * as
|
|
5614
|
+
import * as fs12 from "fs/promises";
|
|
5615
|
+
import * as path15 from "path";
|
|
5740
5616
|
import { Project as Project3, SyntaxKind as SyntaxKind3 } from "ts-morph";
|
|
5741
5617
|
|
|
5742
5618
|
// src/agent-project/config-writer.ts
|
|
@@ -5744,12 +5620,12 @@ init_utils();
|
|
|
5744
5620
|
init_src();
|
|
5745
5621
|
import { Project as Project2, SyntaxKind as SyntaxKind2 } from "ts-morph";
|
|
5746
5622
|
import { readFileSync as readFileSync2 } from "fs";
|
|
5747
|
-
import * as
|
|
5623
|
+
import * as path14 from "path";
|
|
5748
5624
|
|
|
5749
5625
|
class ConfigWriter {
|
|
5750
5626
|
configPath;
|
|
5751
5627
|
constructor(projectPath) {
|
|
5752
|
-
this.configPath =
|
|
5628
|
+
this.configPath = path14.join(projectPath, "agent.config.ts");
|
|
5753
5629
|
}
|
|
5754
5630
|
loadConfig() {
|
|
5755
5631
|
const project = new Project2;
|
|
@@ -6158,9 +6034,9 @@ async function migrateFromConfig(opts) {
|
|
|
6158
6034
|
return result;
|
|
6159
6035
|
}
|
|
6160
6036
|
async function readAliasesFromConfig(projectPath) {
|
|
6161
|
-
const configPath =
|
|
6037
|
+
const configPath = path15.join(projectPath, "agent.config.ts");
|
|
6162
6038
|
try {
|
|
6163
|
-
await
|
|
6039
|
+
await fs12.access(configPath);
|
|
6164
6040
|
} catch {
|
|
6165
6041
|
return { integrations: {}, plugins: {} };
|
|
6166
6042
|
}
|
|
@@ -6230,4 +6106,4 @@ export {
|
|
|
6230
6106
|
DEPENDENCY_ERROR_CODES
|
|
6231
6107
|
};
|
|
6232
6108
|
|
|
6233
|
-
//# debugId=
|
|
6109
|
+
//# debugId=955ACBEC7AB99F3F64756E2164756E21
|