@botpress/adk 1.2.3 → 1.2.5
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-project/agent-project.d.ts +6 -0
- package/dist/agent-project/agent-project.d.ts.map +1 -1
- package/dist/bot-generator/generator.d.ts +1 -0
- package/dist/bot-generator/generator.d.ts.map +1 -1
- package/dist/generators/conversation-types.d.ts +3 -0
- package/dist/generators/conversation-types.d.ts.map +1 -0
- package/dist/generators/event-types.d.ts.map +1 -1
- package/dist/generators/integration-action-types.d.ts.map +1 -1
- package/dist/generators/workflow-types.d.ts.map +1 -1
- package/dist/index.js +199 -116
- package/dist/index.js.map +9 -8
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -241,7 +241,7 @@ var exports_action_types = {};
|
|
|
241
241
|
__export(exports_action_types, {
|
|
242
242
|
generateActionTypes: () => generateActionTypes
|
|
243
243
|
});
|
|
244
|
-
import
|
|
244
|
+
import path27 from "path";
|
|
245
245
|
async function generateActionTypes(project) {
|
|
246
246
|
const actionDefs = [];
|
|
247
247
|
for (const action of project.actions) {
|
|
@@ -249,7 +249,7 @@ async function generateActionTypes(project) {
|
|
|
249
249
|
continue;
|
|
250
250
|
}
|
|
251
251
|
try {
|
|
252
|
-
const absolutePath =
|
|
252
|
+
const absolutePath = path27.join(project.path, action.path);
|
|
253
253
|
const actionModule = await import(`${absolutePath}?t=${Date.now()}`);
|
|
254
254
|
const actionInstance = actionModule[action.export] || actionModule.default;
|
|
255
255
|
if (actionInstance && actionInstance.input && actionInstance.output) {
|
|
@@ -294,7 +294,7 @@ ${actionDefs.join(`
|
|
|
294
294
|
};
|
|
295
295
|
}
|
|
296
296
|
`;
|
|
297
|
-
const actionTypesPath =
|
|
297
|
+
const actionTypesPath = path27.join(project.path, ".adk", "action-types.d.ts");
|
|
298
298
|
await createFile(actionTypesPath, await formatCode(content));
|
|
299
299
|
}
|
|
300
300
|
var init_action_types = __esm(() => {
|
|
@@ -307,7 +307,7 @@ var exports_integration_action_types = {};
|
|
|
307
307
|
__export(exports_integration_action_types, {
|
|
308
308
|
generateIntegrationActionTypes: () => generateIntegrationActionTypes
|
|
309
309
|
});
|
|
310
|
-
import
|
|
310
|
+
import path28 from "path";
|
|
311
311
|
async function generateIntegrationActionTypes(project) {
|
|
312
312
|
const content = `
|
|
313
313
|
////////////////////////////////////////////////////////
|
|
@@ -317,6 +317,8 @@ async function generateIntegrationActionTypes(project) {
|
|
|
317
317
|
// Generated at: ${new Date().toISOString()}
|
|
318
318
|
////////////////////////////////////////////////////////
|
|
319
319
|
|
|
320
|
+
type Integrations = import("@botpress/runtime/_types/integrations").Integrations;
|
|
321
|
+
|
|
320
322
|
declare module "@botpress/runtime/_types/integration-actions" {
|
|
321
323
|
|
|
322
324
|
export interface CallableAction<I, O> {
|
|
@@ -339,7 +341,7 @@ type IntegrationsMap<T> = {
|
|
|
339
341
|
export type IntegrationActions = IntegrationsMap<Integrations>;
|
|
340
342
|
}
|
|
341
343
|
`;
|
|
342
|
-
const integrationActionTypesPath =
|
|
344
|
+
const integrationActionTypesPath = path28.join(project.path, ".adk", "integration-action-types.d.ts");
|
|
343
345
|
await createFile(integrationActionTypesPath, await formatCode(content));
|
|
344
346
|
}
|
|
345
347
|
var init_integration_action_types = __esm(() => {
|
|
@@ -4136,6 +4138,15 @@ class AgentProject {
|
|
|
4136
4138
|
console.warn(`Failed to register data source workflows for ${kbPath}:`, error);
|
|
4137
4139
|
}
|
|
4138
4140
|
}
|
|
4141
|
+
getChannelsList(channelSpec) {
|
|
4142
|
+
if (channelSpec === "*") {
|
|
4143
|
+
return ["*"];
|
|
4144
|
+
} else if (Array.isArray(channelSpec)) {
|
|
4145
|
+
return channelSpec;
|
|
4146
|
+
} else {
|
|
4147
|
+
return [channelSpec];
|
|
4148
|
+
}
|
|
4149
|
+
}
|
|
4139
4150
|
async loadAgentPrimitives() {
|
|
4140
4151
|
if (this._options.adkCommand) {
|
|
4141
4152
|
setAdkCommand(this._options.adkCommand);
|
|
@@ -4201,13 +4212,17 @@ class AgentProject {
|
|
|
4201
4212
|
throw error;
|
|
4202
4213
|
}
|
|
4203
4214
|
if (Primitives2.Definitions.isConversationDefinition(definition)) {
|
|
4204
|
-
const
|
|
4205
|
-
|
|
4215
|
+
const overlapping = this._conversations.find((p) => {
|
|
4216
|
+
const existingChannels = this.getChannelsList(p.definition.channel);
|
|
4217
|
+
const newChannels = this.getChannelsList(definition.channel);
|
|
4218
|
+
return existingChannels.some((ch) => newChannels.includes(ch));
|
|
4219
|
+
});
|
|
4220
|
+
if (overlapping) {
|
|
4206
4221
|
this._warnings.push({
|
|
4207
4222
|
$type: "ValidationError",
|
|
4208
4223
|
code: "DUPLICATE_PRIMITIVE" /* DUPLICATE_PRIMITIVE */,
|
|
4209
4224
|
severity: "warning" /* WARNING */,
|
|
4210
|
-
message: `
|
|
4225
|
+
message: `Overlapping conversation channels found: ${filename} -> ${key} overlaps with ${overlapping.path} -> ${overlapping.export}`,
|
|
4211
4226
|
file: relPath
|
|
4212
4227
|
});
|
|
4213
4228
|
continue;
|
|
@@ -4961,7 +4976,7 @@ Description: ${tag?.description}`);
|
|
|
4961
4976
|
import dedent from "dedent";
|
|
4962
4977
|
import { existsSync as existsSync5 } from "fs";
|
|
4963
4978
|
import fs15 from "fs/promises";
|
|
4964
|
-
import
|
|
4979
|
+
import path29 from "path";
|
|
4965
4980
|
|
|
4966
4981
|
// src/generators/interface-types.ts
|
|
4967
4982
|
import { transforms as transforms2 } from "@botpress/sdk";
|
|
@@ -5297,7 +5312,6 @@ async function generateWorkflowTypes(project) {
|
|
|
5297
5312
|
const workflowModule = await import(`${workflowPath}?t=${Date.now()}`);
|
|
5298
5313
|
const workflowInstance = workflowModule[workflowRef.export] || workflowModule.default;
|
|
5299
5314
|
if (!workflowInstance) {
|
|
5300
|
-
console.warn(`No default export found in workflow file: ${workflowRef.path}`);
|
|
5301
5315
|
continue;
|
|
5302
5316
|
}
|
|
5303
5317
|
const inputType = workflowInstance.inputSchema ? workflowInstance.inputSchema.toTypescriptType?.() || "any" : "{}";
|
|
@@ -5342,10 +5356,78 @@ ${typeDefinitions || " // No workflows defined yet"}
|
|
|
5342
5356
|
await createFile(workflowTypesPath, await formatCode(content));
|
|
5343
5357
|
}
|
|
5344
5358
|
|
|
5345
|
-
// src/generators/
|
|
5359
|
+
// src/generators/conversation-types.ts
|
|
5346
5360
|
init_utils();
|
|
5347
5361
|
init_fs();
|
|
5348
5362
|
import path22 from "path";
|
|
5363
|
+
async function generateConversationTypes(project) {
|
|
5364
|
+
const conversationTypes = {};
|
|
5365
|
+
for (const conversationRef of project.conversations) {
|
|
5366
|
+
console.log(`[ConversationTypes] Processing conversation: ${conversationRef.export}`);
|
|
5367
|
+
try {
|
|
5368
|
+
const conversationPath = path22.join(project.path, conversationRef.path);
|
|
5369
|
+
const conversationModule = await import(`${conversationPath}?t=${Date.now()}`);
|
|
5370
|
+
const conversationInstance = conversationModule[conversationRef.export] || conversationModule.default;
|
|
5371
|
+
if (!conversationInstance) {
|
|
5372
|
+
continue;
|
|
5373
|
+
}
|
|
5374
|
+
const channel = conversationInstance.channel;
|
|
5375
|
+
const stateType = conversationInstance.schema ? conversationInstance.schema.toTypescriptType?.() || "any" : "{}";
|
|
5376
|
+
let channels;
|
|
5377
|
+
if (channel === "*") {
|
|
5378
|
+
channels = ["*"];
|
|
5379
|
+
} else if (Array.isArray(channel)) {
|
|
5380
|
+
channels = channel;
|
|
5381
|
+
} else {
|
|
5382
|
+
channels = [channel];
|
|
5383
|
+
}
|
|
5384
|
+
for (const ch of channels) {
|
|
5385
|
+
conversationTypes[ch] = {
|
|
5386
|
+
channel: ch,
|
|
5387
|
+
state: stateType
|
|
5388
|
+
};
|
|
5389
|
+
}
|
|
5390
|
+
} catch (error) {
|
|
5391
|
+
console.error(`Failed to process conversation ${conversationRef.export}:`, error);
|
|
5392
|
+
}
|
|
5393
|
+
}
|
|
5394
|
+
const channelDefinitions = Object.entries(conversationTypes).filter(([channel]) => channel !== "*").map(([channel, info]) => {
|
|
5395
|
+
const [integration, channelName] = channel.split(".");
|
|
5396
|
+
return ` "${channel}": {
|
|
5397
|
+
channel: "${channel}";
|
|
5398
|
+
integration: "${integration}";
|
|
5399
|
+
state: ${info.state};
|
|
5400
|
+
tags: Integrations["${integration}"]["channels"]["${channelName}"]["conversation"]["tags"];
|
|
5401
|
+
messageTags: Integrations["${integration}"]["channels"]["${channelName}"]["message"]["tags"];
|
|
5402
|
+
messages: Integrations["${integration}"]["channels"]["${channelName}"]["messages"];
|
|
5403
|
+
events: Integrations["${integration}"]["events"];
|
|
5404
|
+
};`;
|
|
5405
|
+
}).join(`
|
|
5406
|
+
`);
|
|
5407
|
+
const content = `
|
|
5408
|
+
////////////////////////////////////////////////////////
|
|
5409
|
+
// DO NOT EDIT THIS FILE DIRECTLY
|
|
5410
|
+
// This file is auto-generated from the Botpress ADK
|
|
5411
|
+
// ADK Version: ${ADK_VERSION}
|
|
5412
|
+
// Generated at: ${new Date().toISOString()}
|
|
5413
|
+
////////////////////////////////////////////////////////
|
|
5414
|
+
|
|
5415
|
+
type Integrations = import("@botpress/runtime/_types/integrations").Integrations;
|
|
5416
|
+
|
|
5417
|
+
declare module "@botpress/runtime/_types/conversations" {
|
|
5418
|
+
export type ConversationDefinitions = {
|
|
5419
|
+
${channelDefinitions || " // No conversations defined yet"}
|
|
5420
|
+
};
|
|
5421
|
+
}
|
|
5422
|
+
`;
|
|
5423
|
+
const conversationTypesPath = path22.join(project.path, ".adk", "conversation-types.d.ts");
|
|
5424
|
+
await createFile(conversationTypesPath, await formatCode(content));
|
|
5425
|
+
}
|
|
5426
|
+
|
|
5427
|
+
// src/generators/event-types.ts
|
|
5428
|
+
init_utils();
|
|
5429
|
+
init_fs();
|
|
5430
|
+
import path23 from "path";
|
|
5349
5431
|
async function generateEventTypes(project) {
|
|
5350
5432
|
const integrationEvents = [];
|
|
5351
5433
|
for (const int of project.integrations) {
|
|
@@ -5361,6 +5443,8 @@ async function generateEventTypes(project) {
|
|
|
5361
5443
|
// Generated at: ${new Date().toISOString()}
|
|
5362
5444
|
////////////////////////////////////////////////////////
|
|
5363
5445
|
|
|
5446
|
+
type Integrations = import("@botpress/runtime/_types/integrations").Integrations;
|
|
5447
|
+
|
|
5364
5448
|
declare module "@botpress/runtime/_types/events" {
|
|
5365
5449
|
/**
|
|
5366
5450
|
* Global Events type that includes all integration events.
|
|
@@ -5382,7 +5466,7 @@ ${integrationEvents.join(`
|
|
|
5382
5466
|
export type EventPayload<T extends EventName> = Events[T];
|
|
5383
5467
|
}
|
|
5384
5468
|
`;
|
|
5385
|
-
const eventTypesPath =
|
|
5469
|
+
const eventTypesPath = path23.join(project.path, ".adk", "event-types.d.ts");
|
|
5386
5470
|
await createFile(eventTypesPath, await formatCode(content));
|
|
5387
5471
|
}
|
|
5388
5472
|
|
|
@@ -5390,7 +5474,7 @@ ${integrationEvents.join(`
|
|
|
5390
5474
|
init_fs();
|
|
5391
5475
|
|
|
5392
5476
|
// src/bot-generator/dev-id-manager.ts
|
|
5393
|
-
import
|
|
5477
|
+
import path24 from "path";
|
|
5394
5478
|
import fs12 from "fs/promises";
|
|
5395
5479
|
import { existsSync as existsSync2 } from "fs";
|
|
5396
5480
|
import { Client as Client9 } from "@botpress/client";
|
|
@@ -5402,7 +5486,7 @@ class DevIdManager {
|
|
|
5402
5486
|
constructor(projectPath, botProjectPath) {
|
|
5403
5487
|
this.projectPath = projectPath;
|
|
5404
5488
|
this.botProjectPath = botProjectPath;
|
|
5405
|
-
this.projectCachePath =
|
|
5489
|
+
this.projectCachePath = path24.join(botProjectPath, ".botpress", "project.cache.json");
|
|
5406
5490
|
}
|
|
5407
5491
|
async getClient() {
|
|
5408
5492
|
if (!this.client) {
|
|
@@ -5436,7 +5520,7 @@ class DevIdManager {
|
|
|
5436
5520
|
}
|
|
5437
5521
|
async saveProjectCache(cache2) {
|
|
5438
5522
|
try {
|
|
5439
|
-
await fs12.mkdir(
|
|
5523
|
+
await fs12.mkdir(path24.dirname(this.projectCachePath), { recursive: true });
|
|
5440
5524
|
await fs12.writeFile(this.projectCachePath, JSON.stringify(cache2, null, 2));
|
|
5441
5525
|
} catch (error) {
|
|
5442
5526
|
console.error("Error saving project.cache.json:", error);
|
|
@@ -5490,7 +5574,7 @@ class DevIdManager {
|
|
|
5490
5574
|
}
|
|
5491
5575
|
|
|
5492
5576
|
// src/bot-generator/integration-sync.ts
|
|
5493
|
-
import
|
|
5577
|
+
import path25 from "path";
|
|
5494
5578
|
import fs13 from "fs/promises";
|
|
5495
5579
|
import { existsSync as existsSync3 } from "fs";
|
|
5496
5580
|
class IntegrationSync {
|
|
@@ -5500,7 +5584,7 @@ class IntegrationSync {
|
|
|
5500
5584
|
constructor(projectPath, botProjectPath) {
|
|
5501
5585
|
this.projectPath = projectPath;
|
|
5502
5586
|
this.botProjectPath = botProjectPath;
|
|
5503
|
-
this.bpModulesPath =
|
|
5587
|
+
this.bpModulesPath = path25.join(botProjectPath, "bp_modules");
|
|
5504
5588
|
}
|
|
5505
5589
|
async parseIntegrations() {
|
|
5506
5590
|
const project = await AgentProject.load(this.projectPath);
|
|
@@ -5531,12 +5615,12 @@ class IntegrationSync {
|
|
|
5531
5615
|
return integrations;
|
|
5532
5616
|
}
|
|
5533
5617
|
async isIntegrationSynced(integration) {
|
|
5534
|
-
const targetFolder =
|
|
5618
|
+
const targetFolder = path25.join(this.bpModulesPath, `integration_${integration.alias}`);
|
|
5535
5619
|
if (!existsSync3(targetFolder)) {
|
|
5536
5620
|
return false;
|
|
5537
5621
|
}
|
|
5538
5622
|
try {
|
|
5539
|
-
const indexPath =
|
|
5623
|
+
const indexPath = path25.join(targetFolder, "index.ts");
|
|
5540
5624
|
if (!existsSync3(indexPath)) {
|
|
5541
5625
|
return false;
|
|
5542
5626
|
}
|
|
@@ -5569,8 +5653,8 @@ class IntegrationSync {
|
|
|
5569
5653
|
}
|
|
5570
5654
|
async renameIntegrationFolder(integration) {
|
|
5571
5655
|
console.log(integration.name, integration.alias);
|
|
5572
|
-
const sourceFolder =
|
|
5573
|
-
const targetFolder =
|
|
5656
|
+
const sourceFolder = path25.join(this.bpModulesPath, integration.name.replace("/", "-"));
|
|
5657
|
+
const targetFolder = path25.join(this.bpModulesPath, `integration_${integration.alias}`);
|
|
5574
5658
|
if (!existsSync3(sourceFolder)) {
|
|
5575
5659
|
throw new Error(`Integration folder not found: ${sourceFolder}`);
|
|
5576
5660
|
}
|
|
@@ -5580,7 +5664,7 @@ class IntegrationSync {
|
|
|
5580
5664
|
await fs13.rename(sourceFolder, targetFolder);
|
|
5581
5665
|
}
|
|
5582
5666
|
async removeIntegrationFolder(alias) {
|
|
5583
|
-
const targetFolder =
|
|
5667
|
+
const targetFolder = path25.join(this.bpModulesPath, `integration_${alias}`);
|
|
5584
5668
|
if (existsSync3(targetFolder)) {
|
|
5585
5669
|
await fs13.rm(targetFolder, { recursive: true, force: true });
|
|
5586
5670
|
}
|
|
@@ -5614,7 +5698,7 @@ class IntegrationSync {
|
|
|
5614
5698
|
}
|
|
5615
5699
|
|
|
5616
5700
|
// src/bot-generator/interface-sync.ts
|
|
5617
|
-
import
|
|
5701
|
+
import path26 from "path";
|
|
5618
5702
|
import fs14 from "fs/promises";
|
|
5619
5703
|
import { existsSync as existsSync4 } from "fs";
|
|
5620
5704
|
import { spawn } from "child_process";
|
|
@@ -5625,7 +5709,7 @@ class InterfaceSync {
|
|
|
5625
5709
|
constructor(projectPath, botProjectPath) {
|
|
5626
5710
|
this.projectPath = projectPath;
|
|
5627
5711
|
this.botProjectPath = botProjectPath;
|
|
5628
|
-
this.bpModulesPath =
|
|
5712
|
+
this.bpModulesPath = path26.join(botProjectPath, "bp_modules");
|
|
5629
5713
|
}
|
|
5630
5714
|
async parseInterfaces() {
|
|
5631
5715
|
const interfaces = [];
|
|
@@ -5643,12 +5727,12 @@ class InterfaceSync {
|
|
|
5643
5727
|
return interfaces;
|
|
5644
5728
|
}
|
|
5645
5729
|
async isInterfaceSynced(interfaceInfo) {
|
|
5646
|
-
const targetFolder =
|
|
5730
|
+
const targetFolder = path26.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
|
|
5647
5731
|
if (!existsSync4(targetFolder)) {
|
|
5648
5732
|
return false;
|
|
5649
5733
|
}
|
|
5650
5734
|
try {
|
|
5651
|
-
const indexPath =
|
|
5735
|
+
const indexPath = path26.join(targetFolder, "index.ts");
|
|
5652
5736
|
if (!existsSync4(indexPath)) {
|
|
5653
5737
|
return false;
|
|
5654
5738
|
}
|
|
@@ -5711,8 +5795,8 @@ class InterfaceSync {
|
|
|
5711
5795
|
});
|
|
5712
5796
|
}
|
|
5713
5797
|
async renameInterfaceFolder(interfaceInfo) {
|
|
5714
|
-
const sourceFolder =
|
|
5715
|
-
const targetFolder =
|
|
5798
|
+
const sourceFolder = path26.join(this.bpModulesPath, interfaceInfo.name);
|
|
5799
|
+
const targetFolder = path26.join(this.bpModulesPath, `interface_${pascalCase(interfaceInfo.alias)}`);
|
|
5716
5800
|
if (!existsSync4(sourceFolder)) {
|
|
5717
5801
|
throw new Error(`Interface folder not found: ${sourceFolder}`);
|
|
5718
5802
|
}
|
|
@@ -5722,7 +5806,7 @@ class InterfaceSync {
|
|
|
5722
5806
|
await fs14.rename(sourceFolder, targetFolder);
|
|
5723
5807
|
}
|
|
5724
5808
|
async removeInterfaceFolder(alias) {
|
|
5725
|
-
const targetFolder =
|
|
5809
|
+
const targetFolder = path26.join(this.bpModulesPath, `interface_${pascalCase(alias)}`);
|
|
5726
5810
|
if (existsSync4(targetFolder)) {
|
|
5727
5811
|
await fs14.rm(targetFolder, { recursive: true, force: true });
|
|
5728
5812
|
}
|
|
@@ -5770,8 +5854,8 @@ class BotGenerator {
|
|
|
5770
5854
|
projectPath;
|
|
5771
5855
|
outputPath;
|
|
5772
5856
|
constructor(options) {
|
|
5773
|
-
this.projectPath =
|
|
5774
|
-
this.outputPath =
|
|
5857
|
+
this.projectPath = path29.resolve(options.projectPath);
|
|
5858
|
+
this.outputPath = path29.resolve(options.outputPath || path29.join(this.projectPath, ".adk"));
|
|
5775
5859
|
}
|
|
5776
5860
|
async listFilesRecursive(rootDir) {
|
|
5777
5861
|
try {
|
|
@@ -5781,8 +5865,8 @@ class BotGenerator {
|
|
|
5781
5865
|
const walk = async (dir, relativeBase) => {
|
|
5782
5866
|
const entries = await fs15.readdir(dir, { withFileTypes: true });
|
|
5783
5867
|
for (const entry of entries) {
|
|
5784
|
-
const abs =
|
|
5785
|
-
const rel =
|
|
5868
|
+
const abs = path29.join(dir, entry.name);
|
|
5869
|
+
const rel = path29.join(relativeBase, entry.name);
|
|
5786
5870
|
if (entry.isDirectory()) {
|
|
5787
5871
|
await walk(abs, rel);
|
|
5788
5872
|
} else {
|
|
@@ -5803,7 +5887,7 @@ class BotGenerator {
|
|
|
5803
5887
|
const entries = await fs15.readdir(dir, { withFileTypes: true });
|
|
5804
5888
|
for (const entry of entries) {
|
|
5805
5889
|
if (entry.isDirectory()) {
|
|
5806
|
-
const subdir =
|
|
5890
|
+
const subdir = path29.join(dir, entry.name);
|
|
5807
5891
|
await removeIfEmpty(subdir);
|
|
5808
5892
|
}
|
|
5809
5893
|
}
|
|
@@ -5828,6 +5912,7 @@ class BotGenerator {
|
|
|
5828
5912
|
await this.generateTriggerTypes();
|
|
5829
5913
|
await this.generateStateTypes();
|
|
5830
5914
|
await this.generateWorkflowTypes();
|
|
5915
|
+
await this.generateConversationTypes();
|
|
5831
5916
|
await this.generateActionTypes();
|
|
5832
5917
|
await this.generateEventTypes();
|
|
5833
5918
|
await this.generateIntegrationActionTypes();
|
|
@@ -5842,19 +5927,18 @@ class BotGenerator {
|
|
|
5842
5927
|
const project = await AgentProject.load(this.projectPath);
|
|
5843
5928
|
const manager2 = new IntegrationManager;
|
|
5844
5929
|
const integrations = await manager2.loadIntegrations(project.dependencies || {});
|
|
5845
|
-
const integrationsDir =
|
|
5930
|
+
const integrationsDir = path29.join(this.projectPath, ".adk", "integrations");
|
|
5846
5931
|
const existingIntegrationFiles = await this.listFilesRecursive(integrationsDir);
|
|
5847
|
-
let imports = new Set;
|
|
5848
5932
|
let aliases = new Set;
|
|
5849
5933
|
let files = new Set;
|
|
5850
5934
|
for (const integration of integrations.integrations) {
|
|
5851
5935
|
if (integration.enabled && integration.definition) {
|
|
5852
5936
|
const types6 = await generateIntegrationTypes(integration);
|
|
5853
|
-
|
|
5854
|
-
aliases.add(`"${integration.alias}": ${types6.names.typings.index}`);
|
|
5937
|
+
const importPath = `./${path29.join("integrations", types6.names.paths.index)}`;
|
|
5938
|
+
aliases.add(`"${integration.alias}": import("${importPath}").${types6.names.typings.index}`);
|
|
5855
5939
|
for (const [filePath, content] of Object.entries(types6.files)) {
|
|
5856
|
-
const fullPath =
|
|
5857
|
-
const dir =
|
|
5940
|
+
const fullPath = path29.join(this.projectPath, ".adk", "integrations", filePath);
|
|
5941
|
+
const dir = path29.dirname(fullPath);
|
|
5858
5942
|
await fs15.mkdir(dir, { recursive: true });
|
|
5859
5943
|
await createFile(fullPath, content);
|
|
5860
5944
|
files.add(filePath);
|
|
@@ -5868,20 +5952,17 @@ class BotGenerator {
|
|
|
5868
5952
|
// File: integrations.ts
|
|
5869
5953
|
////////////////////////////////////////////////////////
|
|
5870
5954
|
|
|
5871
|
-
|
|
5872
|
-
`)}
|
|
5873
|
-
|
|
5874
|
-
declare global {
|
|
5955
|
+
declare module "@botpress/runtime/_types/integrations" {
|
|
5875
5956
|
export type Integrations = {
|
|
5876
5957
|
${Array.from(aliases).join(`, `)}
|
|
5877
5958
|
};
|
|
5878
5959
|
}
|
|
5879
5960
|
`;
|
|
5880
|
-
await createFile(
|
|
5961
|
+
await createFile(path29.join(this.projectPath, ".adk", "integrations.d.ts"), await formatCode(types5));
|
|
5881
5962
|
const staleIntegrationFiles = existingIntegrationFiles.filter((f) => !files.has(f));
|
|
5882
5963
|
if (staleIntegrationFiles.length > 0) {
|
|
5883
5964
|
for (const rel of staleIntegrationFiles) {
|
|
5884
|
-
const abs =
|
|
5965
|
+
const abs = path29.join(integrationsDir, rel);
|
|
5885
5966
|
try {
|
|
5886
5967
|
await fs15.rm(abs, { force: true });
|
|
5887
5968
|
} catch {}
|
|
@@ -5909,6 +5990,10 @@ class BotGenerator {
|
|
|
5909
5990
|
const project = await AgentProject.load(this.projectPath);
|
|
5910
5991
|
await generateWorkflowTypes(project);
|
|
5911
5992
|
}
|
|
5993
|
+
async generateConversationTypes() {
|
|
5994
|
+
const project = await AgentProject.load(this.projectPath);
|
|
5995
|
+
await generateConversationTypes(project);
|
|
5996
|
+
}
|
|
5912
5997
|
async generateActionTypes() {
|
|
5913
5998
|
const project = await AgentProject.load(this.projectPath);
|
|
5914
5999
|
const { generateActionTypes: generateActionTypes2 } = await Promise.resolve().then(() => (init_action_types(), exports_action_types));
|
|
@@ -5921,10 +6006,22 @@ class BotGenerator {
|
|
|
5921
6006
|
}
|
|
5922
6007
|
async generateRuntimeTypes() {
|
|
5923
6008
|
const project = await AgentProject.load(this.projectPath);
|
|
6009
|
+
const manager2 = new IntegrationManager;
|
|
6010
|
+
const integrations = await manager2.loadIntegrations(project.dependencies || {});
|
|
6011
|
+
const channels = [];
|
|
6012
|
+
for (const integration of integrations.integrations) {
|
|
6013
|
+
if (integration.enabled && integration.definition) {
|
|
6014
|
+
const alias = integration.alias;
|
|
6015
|
+
for (const channelName of Object.keys(integration.definition.channels || {})) {
|
|
6016
|
+
channels.push(`"${alias}.${channelName}"`);
|
|
6017
|
+
}
|
|
6018
|
+
}
|
|
6019
|
+
}
|
|
6020
|
+
const channelsType = channels.length > 0 ? channels.join(" | ") : "never";
|
|
5924
6021
|
let botStateType = "{}";
|
|
5925
6022
|
let userStateType = "{}";
|
|
5926
6023
|
try {
|
|
5927
|
-
const configPath =
|
|
6024
|
+
const configPath = path29.join(project.path, "agent.config.ts");
|
|
5928
6025
|
const configModule = await import(`${configPath}?t=${Date.now()}`);
|
|
5929
6026
|
const config = configModule.default;
|
|
5930
6027
|
if (config?.bot?.state) {
|
|
@@ -5950,38 +6047,23 @@ class BotGenerator {
|
|
|
5950
6047
|
// Generated at: ${new Date().toISOString()}
|
|
5951
6048
|
////////////////////////////////////////////////////////
|
|
5952
6049
|
|
|
5953
|
-
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
export type Channels = {
|
|
5957
|
-
[K in keyof Integrations]: {
|
|
5958
|
-
[C in keyof Integrations[K]["channels"]]: C extends string
|
|
5959
|
-
? \`\${K}.\${C}\`
|
|
5960
|
-
: never;
|
|
5961
|
-
}[keyof Integrations[K]["channels"]];
|
|
5962
|
-
}[keyof Integrations];
|
|
5963
|
-
|
|
5964
|
-
export class Conversation<
|
|
5965
|
-
T extends Channels = Channels,
|
|
5966
|
-
Schema extends ZuiType = ZuiType,
|
|
5967
|
-
> extends Primitives.BaseConversation<Integrations, T, Schema> {}
|
|
5968
|
-
|
|
6050
|
+
declare module "@botpress/runtime/_types/channels" {
|
|
6051
|
+
export type Channels = ${channelsType};
|
|
6052
|
+
export type ChannelSpec = Channels | readonly Channels[] | '*';
|
|
5969
6053
|
}
|
|
5970
6054
|
|
|
5971
6055
|
declare module "@botpress/runtime/_types/state" {
|
|
5972
6056
|
export type BotState = ${botStateType};
|
|
5973
6057
|
export type UserState = ${userStateType};
|
|
5974
6058
|
}
|
|
5975
|
-
|
|
5976
|
-
export {};
|
|
5977
6059
|
`;
|
|
5978
|
-
await createFile(
|
|
6060
|
+
await createFile(path29.join(this.projectPath, ".adk", "runtime.d.ts"), await formatCode(types5));
|
|
5979
6061
|
}
|
|
5980
6062
|
async generateInterfacesTypes() {
|
|
5981
6063
|
const project = await AgentProject.load(this.projectPath);
|
|
5982
6064
|
const integrationManager = new IntegrationManager;
|
|
5983
6065
|
const manager2 = new InterfaceManager;
|
|
5984
|
-
const interfacesDir =
|
|
6066
|
+
const interfacesDir = path29.join(this.projectPath, ".adk", "interfaces");
|
|
5985
6067
|
const existingInterfaceFiles = await this.listFilesRecursive(interfacesDir);
|
|
5986
6068
|
const interfaces = await manager2.loadInterfaces(project.dependencies || {}).then((result) => result.interfaces.filter((int) => int.definition).map((x) => x.definition));
|
|
5987
6069
|
const integrations = await integrationManager.loadIntegrations(project.dependencies || {}).then((result) => result.integrations.filter((int) => int.enabled && int.definition).map((x) => x.definition));
|
|
@@ -5990,11 +6072,11 @@ export {};
|
|
|
5990
6072
|
let files = new Set;
|
|
5991
6073
|
for (const int of interfaces) {
|
|
5992
6074
|
const types6 = await generateInterfaceTypes(int, integrations);
|
|
5993
|
-
imports.add(`import { ${types6.names.typings.index} } from "./${
|
|
6075
|
+
imports.add(`import { ${types6.names.typings.index} } from "./${path29.join("interfaces", types6.names.paths.index)}";`);
|
|
5994
6076
|
aliases.add(`"${types6.names.name}": ${types6.names.typings.index}`);
|
|
5995
6077
|
for (const [filePath, content] of Object.entries(types6.files)) {
|
|
5996
|
-
const fullPath =
|
|
5997
|
-
const dir =
|
|
6078
|
+
const fullPath = path29.join(this.projectPath, ".adk", "interfaces", filePath);
|
|
6079
|
+
const dir = path29.dirname(fullPath);
|
|
5998
6080
|
await fs15.mkdir(dir, { recursive: true });
|
|
5999
6081
|
await createFile(fullPath, content);
|
|
6000
6082
|
files.add(filePath);
|
|
@@ -6031,12 +6113,12 @@ export {};
|
|
|
6031
6113
|
`)}
|
|
6032
6114
|
};
|
|
6033
6115
|
`;
|
|
6034
|
-
await createFile(
|
|
6035
|
-
await createFile(
|
|
6116
|
+
await createFile(path29.join(this.projectPath, ".adk", "interfaces.d.ts"), await formatCode(types5));
|
|
6117
|
+
await createFile(path29.join(this.projectPath, ".adk", "interfaces.ts"), await formatCode(consts));
|
|
6036
6118
|
const staleInterfaceFiles = existingInterfaceFiles.filter((f) => !files.has(f));
|
|
6037
6119
|
if (staleInterfaceFiles.length > 0) {
|
|
6038
6120
|
for (const rel of staleInterfaceFiles) {
|
|
6039
|
-
const abs =
|
|
6121
|
+
const abs = path29.join(interfacesDir, rel);
|
|
6040
6122
|
try {
|
|
6041
6123
|
await fs15.rm(abs, { force: true });
|
|
6042
6124
|
} catch {}
|
|
@@ -6065,7 +6147,7 @@ export {};
|
|
|
6065
6147
|
`) : ""}
|
|
6066
6148
|
} as Record<string, IntegrationPackage>;
|
|
6067
6149
|
`;
|
|
6068
|
-
await createFile(
|
|
6150
|
+
await createFile(path29.join(this.outputPath, "src", "integrations.ts"), content);
|
|
6069
6151
|
}
|
|
6070
6152
|
async generateInterfacesDefinition() {
|
|
6071
6153
|
const interfaces = BUILTIN_INTERFACES;
|
|
@@ -6088,7 +6170,7 @@ export {};
|
|
|
6088
6170
|
`) : ""}
|
|
6089
6171
|
} as Record<string, InterfacePackage>;
|
|
6090
6172
|
`;
|
|
6091
|
-
await createFile(
|
|
6173
|
+
await createFile(path29.join(this.outputPath, "src", "interfaces.ts"), await formatCode(content));
|
|
6092
6174
|
}
|
|
6093
6175
|
async generateBotDefinition() {
|
|
6094
6176
|
const project = await AgentProject.load(this.projectPath);
|
|
@@ -6122,7 +6204,7 @@ export {};
|
|
|
6122
6204
|
if (isBuiltinWorkflow2(workflow.definition.name)) {
|
|
6123
6205
|
continue;
|
|
6124
6206
|
}
|
|
6125
|
-
const workflowPath =
|
|
6207
|
+
const workflowPath = path29.join(project.path, workflow.path);
|
|
6126
6208
|
const workflowModule = await import(`${workflowPath}?t=${Date.now()}`);
|
|
6127
6209
|
const workflowInstance = workflowModule.default || workflowModule[workflow.export];
|
|
6128
6210
|
if (workflowInstance) {
|
|
@@ -6181,6 +6263,7 @@ export {};
|
|
|
6181
6263
|
const content = dedent`
|
|
6182
6264
|
import { BotDefinition, z } from "@botpress/sdk";
|
|
6183
6265
|
import {
|
|
6266
|
+
BUILT_IN_STATES,
|
|
6184
6267
|
TranscriptSchema,
|
|
6185
6268
|
TrackedStateSchema,
|
|
6186
6269
|
WorkflowCallbackEvent,
|
|
@@ -6274,7 +6357,7 @@ export {};
|
|
|
6274
6357
|
* This is defined by the users at build-time when they define conversations.
|
|
6275
6358
|
* Because each conversation can have its own state schema, we use \`z.any()\`
|
|
6276
6359
|
*/
|
|
6277
|
-
|
|
6360
|
+
[BUILT_IN_STATES.conversation]: {
|
|
6278
6361
|
type: "conversation",
|
|
6279
6362
|
schema: TrackedStateSchema,
|
|
6280
6363
|
},
|
|
@@ -6282,7 +6365,7 @@ export {};
|
|
|
6282
6365
|
/**
|
|
6283
6366
|
* Bot-wide global state that persists across all conversations
|
|
6284
6367
|
*/
|
|
6285
|
-
|
|
6368
|
+
[BUILT_IN_STATES.bot]: {
|
|
6286
6369
|
type: "bot",
|
|
6287
6370
|
schema: TrackedStateSchema,
|
|
6288
6371
|
},
|
|
@@ -6290,7 +6373,7 @@ export {};
|
|
|
6290
6373
|
/**
|
|
6291
6374
|
* User-specific state that persists across conversations for each user
|
|
6292
6375
|
*/
|
|
6293
|
-
|
|
6376
|
+
[BUILT_IN_STATES.user]: {
|
|
6294
6377
|
type: "user",
|
|
6295
6378
|
schema: TrackedStateSchema,
|
|
6296
6379
|
},
|
|
@@ -6298,7 +6381,7 @@ export {};
|
|
|
6298
6381
|
/**
|
|
6299
6382
|
* Workflow-specific state that persists across workflow executions
|
|
6300
6383
|
*/
|
|
6301
|
-
workflowState: {
|
|
6384
|
+
[BUILT_IN_STATES.workflowState]: {
|
|
6302
6385
|
type: "workflow",
|
|
6303
6386
|
schema: TrackedStateSchema,
|
|
6304
6387
|
},
|
|
@@ -6306,7 +6389,7 @@ export {};
|
|
|
6306
6389
|
/**
|
|
6307
6390
|
* Workflow cached steps executions
|
|
6308
6391
|
*/
|
|
6309
|
-
workflowSteps: {
|
|
6392
|
+
[BUILT_IN_STATES.workflowSteps]: {
|
|
6310
6393
|
type: "workflow",
|
|
6311
6394
|
schema: TrackedStateSchema,
|
|
6312
6395
|
},
|
|
@@ -6320,7 +6403,7 @@ export {};
|
|
|
6320
6403
|
|
|
6321
6404
|
export default bot;
|
|
6322
6405
|
`;
|
|
6323
|
-
await createFile(
|
|
6406
|
+
await createFile(path29.join(this.outputPath, "bot.definition.ts"), await formatCode(content));
|
|
6324
6407
|
}
|
|
6325
6408
|
async generateBotIndex() {
|
|
6326
6409
|
const project = await AgentProject.load(this.projectPath);
|
|
@@ -6348,22 +6431,22 @@ export {};
|
|
|
6348
6431
|
|
|
6349
6432
|
if (isWorkerMode() && isMainThread) {
|
|
6350
6433
|
// Branch 1: Main thread in worker mode - initialize parent with pool
|
|
6351
|
-
console.log("[Main] Initializing parent worker with pool...");
|
|
6434
|
+
if (process.env.BP_DEBUG) console.log("[Main] Initializing parent worker with pool...");
|
|
6352
6435
|
initializeParentWorker(bot);
|
|
6353
6436
|
} else if (isWorkerMode() && process.env.IS_DEV_WORKER === "true") {
|
|
6354
6437
|
// Branch 2: Worker thread - run child worker
|
|
6355
|
-
console.log("[Worker] Initializing child worker...");
|
|
6438
|
+
if (process.env.BP_DEBUG) console.log("[Worker] Initializing child worker...");
|
|
6356
6439
|
runWorker(bot);
|
|
6357
6440
|
setupAdkRuntime(bot);
|
|
6358
6441
|
} else {
|
|
6359
6442
|
// Branch 3: Worker mode disabled - single-thread mode
|
|
6360
|
-
console.log("[Bot] Running in single-thread mode");
|
|
6443
|
+
if (process.env.BP_DEBUG) console.log("[Bot] Running in single-thread mode");
|
|
6361
6444
|
setupAdkRuntime(bot);
|
|
6362
6445
|
}
|
|
6363
6446
|
|
|
6364
6447
|
export default bot
|
|
6365
6448
|
`;
|
|
6366
|
-
await createFile(
|
|
6449
|
+
await createFile(path29.join(this.outputPath, "src", "index.ts"), await formatCode(content));
|
|
6367
6450
|
}
|
|
6368
6451
|
async generatePackageJson(project) {
|
|
6369
6452
|
const packageJson = {
|
|
@@ -6382,7 +6465,7 @@ export {};
|
|
|
6382
6465
|
typescript: "^5.6.3"
|
|
6383
6466
|
}
|
|
6384
6467
|
};
|
|
6385
|
-
await createFile(
|
|
6468
|
+
await createFile(path29.join(this.outputPath, "package.json"), JSON.stringify(packageJson, null, 2));
|
|
6386
6469
|
}
|
|
6387
6470
|
async generateTsConfig() {
|
|
6388
6471
|
const tsConfig = {
|
|
@@ -6419,7 +6502,7 @@ export {};
|
|
|
6419
6502
|
"./*.json"
|
|
6420
6503
|
]
|
|
6421
6504
|
};
|
|
6422
|
-
await createFile(
|
|
6505
|
+
await createFile(path29.join(this.outputPath, "tsconfig.json"), JSON.stringify(tsConfig, null, 2));
|
|
6423
6506
|
}
|
|
6424
6507
|
async generateGlobalTypes() {
|
|
6425
6508
|
const content = dedent`
|
|
@@ -6442,11 +6525,11 @@ export {};
|
|
|
6442
6525
|
|
|
6443
6526
|
export {};
|
|
6444
6527
|
`;
|
|
6445
|
-
await createFile(
|
|
6528
|
+
await createFile(path29.join(this.outputPath, "global.d.ts"), await formatCode(content));
|
|
6446
6529
|
}
|
|
6447
6530
|
async copyAssets() {
|
|
6448
|
-
const assetsPath =
|
|
6449
|
-
const targetPath =
|
|
6531
|
+
const assetsPath = path29.join(this.projectPath, "assets");
|
|
6532
|
+
const targetPath = path29.join(this.outputPath, "assets");
|
|
6450
6533
|
if (existsSync5(assetsPath)) {
|
|
6451
6534
|
await fs15.mkdir(targetPath, { recursive: true });
|
|
6452
6535
|
await this.copyDirectory(assetsPath, targetPath);
|
|
@@ -6455,8 +6538,8 @@ export {};
|
|
|
6455
6538
|
async copyDirectory(src, dest) {
|
|
6456
6539
|
const entries = await fs15.readdir(src, { withFileTypes: true });
|
|
6457
6540
|
for (const entry of entries) {
|
|
6458
|
-
const srcPath =
|
|
6459
|
-
const destPath =
|
|
6541
|
+
const srcPath = path29.join(src, entry.name);
|
|
6542
|
+
const destPath = path29.join(dest, entry.name);
|
|
6460
6543
|
if (entry.isDirectory()) {
|
|
6461
6544
|
await fs15.mkdir(destPath, { recursive: true });
|
|
6462
6545
|
await this.copyDirectory(srcPath, destPath);
|
|
@@ -6468,16 +6551,16 @@ export {};
|
|
|
6468
6551
|
async generateAdkRuntime() {
|
|
6469
6552
|
const project = new AgentProject(this.projectPath);
|
|
6470
6553
|
await project.reload();
|
|
6471
|
-
const srcDir =
|
|
6554
|
+
const srcDir = path29.join(this.outputPath, "src");
|
|
6472
6555
|
{
|
|
6473
|
-
const dest =
|
|
6556
|
+
const dest = path29.join(srcDir, "conversations.ts");
|
|
6474
6557
|
const imports = new Map;
|
|
6475
6558
|
const exports = new Set;
|
|
6476
6559
|
let index = 1;
|
|
6477
6560
|
for (const conversation of project.conversations) {
|
|
6478
6561
|
if (!imports.has(conversation.path)) {
|
|
6479
6562
|
const name = `conversations_${index++}`;
|
|
6480
|
-
const importPath =
|
|
6563
|
+
const importPath = path29.relative(path29.dirname(dest), path29.join(project.path, conversation.path)).replace(/\.ts$/, "");
|
|
6481
6564
|
imports.set(conversation.path, {
|
|
6482
6565
|
name,
|
|
6483
6566
|
statement: `import * as ${name} from "${importPath}";`
|
|
@@ -6503,14 +6586,14 @@ export {};
|
|
|
6503
6586
|
await createFile(dest, await formatCode(content2));
|
|
6504
6587
|
}
|
|
6505
6588
|
{
|
|
6506
|
-
const dest =
|
|
6589
|
+
const dest = path29.join(srcDir, "knowledge.ts");
|
|
6507
6590
|
const imports = new Map;
|
|
6508
6591
|
const exports = new Set;
|
|
6509
6592
|
let index = 1;
|
|
6510
6593
|
for (const knowledge of project.knowledge) {
|
|
6511
6594
|
if (!imports.has(knowledge.path)) {
|
|
6512
6595
|
const name = `knowledge_${index++}`;
|
|
6513
|
-
const importPath =
|
|
6596
|
+
const importPath = path29.relative(path29.dirname(dest), path29.join(project.path, knowledge.path)).replace(/\.ts$/, "");
|
|
6514
6597
|
imports.set(knowledge.path, {
|
|
6515
6598
|
name,
|
|
6516
6599
|
statement: `import * as ${name} from "${importPath}";`
|
|
@@ -6536,7 +6619,7 @@ export {};
|
|
|
6536
6619
|
await createFile(dest, await formatCode(content2));
|
|
6537
6620
|
}
|
|
6538
6621
|
{
|
|
6539
|
-
const dest =
|
|
6622
|
+
const dest = path29.join(srcDir, "triggers.ts");
|
|
6540
6623
|
const { transforms: transforms4 } = await import("@botpress/sdk");
|
|
6541
6624
|
const imports = new Map;
|
|
6542
6625
|
const exports = new Set;
|
|
@@ -6545,7 +6628,7 @@ export {};
|
|
|
6545
6628
|
for (const trigger of project.triggers) {
|
|
6546
6629
|
if (!imports.has(trigger.path)) {
|
|
6547
6630
|
const name = `triggers_${index++}`;
|
|
6548
|
-
const importPath =
|
|
6631
|
+
const importPath = path29.relative(path29.dirname(dest), path29.join(project.path, trigger.path)).replace(/\.ts$/, "");
|
|
6549
6632
|
imports.set(trigger.path, {
|
|
6550
6633
|
name,
|
|
6551
6634
|
statement: `import * as ${name} from "${importPath}";`
|
|
@@ -6555,7 +6638,7 @@ export {};
|
|
|
6555
6638
|
}
|
|
6556
6639
|
for (const trigger of project.triggers) {
|
|
6557
6640
|
try {
|
|
6558
|
-
const absolutePath =
|
|
6641
|
+
const absolutePath = path29.join(project.path, trigger.path);
|
|
6559
6642
|
const triggerModule = await import(`${absolutePath}?t=${Date.now()}`);
|
|
6560
6643
|
const triggerInstance = triggerModule[trigger.export] || triggerModule.default;
|
|
6561
6644
|
if (triggerInstance && triggerInstance.payload) {
|
|
@@ -6598,7 +6681,7 @@ export {};
|
|
|
6598
6681
|
await createFile(dest, await formatCode(content2));
|
|
6599
6682
|
}
|
|
6600
6683
|
{
|
|
6601
|
-
const dest =
|
|
6684
|
+
const dest = path29.join(srcDir, "workflows.ts");
|
|
6602
6685
|
const imports = new Map;
|
|
6603
6686
|
const exports = new Set;
|
|
6604
6687
|
let index = 1;
|
|
@@ -6608,7 +6691,7 @@ export {};
|
|
|
6608
6691
|
}
|
|
6609
6692
|
if (!imports.has(workflow.path)) {
|
|
6610
6693
|
const name = `workflows_${index++}`;
|
|
6611
|
-
const importPath =
|
|
6694
|
+
const importPath = path29.relative(path29.dirname(dest), path29.join(project.path, workflow.path)).replace(/\.ts$/, "");
|
|
6612
6695
|
const statement = `import * as ${name} from "${importPath}";`;
|
|
6613
6696
|
imports.set(workflow.path, {
|
|
6614
6697
|
name,
|
|
@@ -6642,14 +6725,14 @@ export {};
|
|
|
6642
6725
|
await createFile(dest, await formatCode(content2));
|
|
6643
6726
|
}
|
|
6644
6727
|
{
|
|
6645
|
-
const dest =
|
|
6728
|
+
const dest = path29.join(srcDir, "actions.ts");
|
|
6646
6729
|
const imports = new Map;
|
|
6647
6730
|
const exports = new Set;
|
|
6648
6731
|
let index = 1;
|
|
6649
6732
|
for (const action of project.actions) {
|
|
6650
6733
|
if (!imports.has(action.path)) {
|
|
6651
6734
|
const name = `actions_${index++}`;
|
|
6652
|
-
const importPath =
|
|
6735
|
+
const importPath = path29.relative(path29.dirname(dest), path29.join(project.path, action.path)).replace(/\.ts$/, "");
|
|
6653
6736
|
imports.set(action.path, {
|
|
6654
6737
|
name,
|
|
6655
6738
|
statement: `import * as ${name} from "${importPath}";`
|
|
@@ -6675,14 +6758,14 @@ export {};
|
|
|
6675
6758
|
await createFile(dest, await formatCode(content2));
|
|
6676
6759
|
}
|
|
6677
6760
|
{
|
|
6678
|
-
const dest =
|
|
6761
|
+
const dest = path29.join(srcDir, "tables.ts");
|
|
6679
6762
|
const imports = new Map;
|
|
6680
6763
|
const exports = new Set;
|
|
6681
6764
|
let index = 1;
|
|
6682
6765
|
for (const table of project.tables) {
|
|
6683
6766
|
if (!imports.has(table.path)) {
|
|
6684
6767
|
const name = `tables_${index++}`;
|
|
6685
|
-
const importPath =
|
|
6768
|
+
const importPath = path29.relative(path29.dirname(dest), path29.join(project.path, table.path)).replace(/\.ts$/, "");
|
|
6686
6769
|
imports.set(table.path, {
|
|
6687
6770
|
name,
|
|
6688
6771
|
statement: `import * as ${name} from "${importPath}";`
|
|
@@ -6708,8 +6791,8 @@ export {};
|
|
|
6708
6791
|
await createFile(dest, await formatCode(content2));
|
|
6709
6792
|
}
|
|
6710
6793
|
{
|
|
6711
|
-
const dest =
|
|
6712
|
-
const importPath =
|
|
6794
|
+
const dest = path29.join(srcDir, "config.ts");
|
|
6795
|
+
const importPath = path29.relative(path29.dirname(dest), path29.join(project.path, "agent.config.ts")).replace(/\.ts$/, "");
|
|
6713
6796
|
const content2 = `
|
|
6714
6797
|
////////////////////////////////////////////////////////
|
|
6715
6798
|
// DO NOT EDIT THIS FILE DIRECTLY
|
|
@@ -6774,13 +6857,13 @@ export {};
|
|
|
6774
6857
|
handlers.workflow.setup(bot);
|
|
6775
6858
|
}
|
|
6776
6859
|
`;
|
|
6777
|
-
await createFile(
|
|
6860
|
+
await createFile(path29.join(this.outputPath, "src", "adk-runtime.ts"), await formatCode(content));
|
|
6778
6861
|
}
|
|
6779
6862
|
async copyAssetsRuntime() {
|
|
6780
|
-
const assetsRuntimePath =
|
|
6863
|
+
const assetsRuntimePath = path29.join(this.projectPath, ".adk", "assets-runtime.ts");
|
|
6781
6864
|
if (existsSync5(assetsRuntimePath)) {
|
|
6782
6865
|
const content = await fs15.readFile(assetsRuntimePath, "utf-8");
|
|
6783
|
-
await createFile(
|
|
6866
|
+
await createFile(path29.join(this.outputPath, "src", "assets-runtime.ts"), await formatCode(content));
|
|
6784
6867
|
}
|
|
6785
6868
|
}
|
|
6786
6869
|
}
|
|
@@ -6789,9 +6872,9 @@ async function generateBotProject(options) {
|
|
|
6789
6872
|
await generator.generate();
|
|
6790
6873
|
await generator.generateAdkRuntime();
|
|
6791
6874
|
await generator.copyAssetsRuntime();
|
|
6792
|
-
const devIdManager = new DevIdManager(options.projectPath, options.outputPath ||
|
|
6875
|
+
const devIdManager = new DevIdManager(options.projectPath, options.outputPath || path29.join(options.projectPath, ".adk", "bot"));
|
|
6793
6876
|
await devIdManager.restoreDevId();
|
|
6794
|
-
const integrationSync = new IntegrationSync(options.projectPath, options.outputPath ||
|
|
6877
|
+
const integrationSync = new IntegrationSync(options.projectPath, options.outputPath || path29.join(options.projectPath, ".adk", "bot"));
|
|
6795
6878
|
const integrationSyncResult = await integrationSync.syncIntegrations();
|
|
6796
6879
|
if (integrationSyncResult.errors.length > 0) {
|
|
6797
6880
|
console.warn(`⚠️ Some integrations failed to sync:`);
|
|
@@ -6799,7 +6882,7 @@ async function generateBotProject(options) {
|
|
|
6799
6882
|
console.warn(` - ${alias}: ${error}`);
|
|
6800
6883
|
});
|
|
6801
6884
|
}
|
|
6802
|
-
const interfaceSync = new InterfaceSync(options.projectPath, options.outputPath ||
|
|
6885
|
+
const interfaceSync = new InterfaceSync(options.projectPath, options.outputPath || path29.join(options.projectPath, ".adk", "bot"));
|
|
6803
6886
|
const interfaceSyncResult = await interfaceSync.syncInterfaces();
|
|
6804
6887
|
if (interfaceSyncResult.errors.length > 0) {
|
|
6805
6888
|
console.warn(`⚠️ Some interfaces failed to sync:`);
|
|
@@ -7194,5 +7277,5 @@ export {
|
|
|
7194
7277
|
AgentProject
|
|
7195
7278
|
};
|
|
7196
7279
|
|
|
7197
|
-
//# debugId=
|
|
7280
|
+
//# debugId=457481A453B1622564756E2164756E21
|
|
7198
7281
|
//# sourceMappingURL=index.js.map
|