@botpress/adk 2.0.4 → 3.0.0-beta.1
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 +5 -0
- package/dist/agent-project/agent-project.d.ts.map +1 -1
- package/dist/agent-project/agent-resolver.d.ts.map +1 -1
- package/dist/agent-project/types.d.ts +8 -88
- package/dist/agent-project/types.d.ts.map +1 -1
- package/dist/agent0/config/schema.d.ts +8 -130
- package/dist/agent0/config/schema.d.ts.map +1 -1
- package/dist/agent0/index.js +280 -63
- package/dist/agent0/index.js.map +17 -14
- package/dist/agent0/providers/source.d.ts.map +1 -1
- package/dist/agent0/runtime/client.d.ts +2 -1
- package/dist/agent0/runtime/client.d.ts.map +1 -1
- package/dist/agent0/runtime/engine.d.ts +2 -0
- package/dist/agent0/runtime/engine.d.ts.map +1 -1
- package/dist/agent0/runtime/manager.d.ts +2 -1
- package/dist/agent0/runtime/manager.d.ts.map +1 -1
- package/dist/agent0/types.d.ts +41 -1
- package/dist/agent0/types.d.ts.map +1 -1
- package/dist/auth/index.d.ts +1 -1
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/bot-generator/dev-id-manager.d.ts +6 -0
- package/dist/bot-generator/dev-id-manager.d.ts.map +1 -1
- package/dist/bot-generator/generator.d.ts +1 -1
- package/dist/bot-generator/generator.d.ts.map +1 -1
- package/dist/bot-generator/install-package.d.ts +22 -0
- package/dist/bot-generator/install-package.d.ts.map +1 -0
- package/dist/bot-generator/integration-sync.d.ts +6 -20
- package/dist/bot-generator/integration-sync.d.ts.map +1 -1
- package/dist/bot-generator/interface-sync.d.ts +6 -20
- package/dist/bot-generator/interface-sync.d.ts.map +1 -1
- package/dist/bot-generator/plugin-sync.d.ts +5 -20
- package/dist/bot-generator/plugin-sync.d.ts.map +1 -1
- package/dist/build/__fixtures__/generated-import-bot/bot.definition.d.ts +14 -0
- package/dist/build/__fixtures__/generated-import-bot/bot.definition.d.ts.map +1 -0
- package/dist/build/__fixtures__/generated-import-bot/src/index.d.ts +3 -0
- package/dist/build/__fixtures__/generated-import-bot/src/index.d.ts.map +1 -0
- package/dist/build/__fixtures__/minimal-bot/bot.definition.d.ts +26 -0
- package/dist/build/__fixtures__/minimal-bot/bot.definition.d.ts.map +1 -0
- package/dist/build/__fixtures__/minimal-bot/src/index.d.ts +6 -0
- package/dist/build/__fixtures__/minimal-bot/src/index.d.ts.map +1 -0
- package/dist/build/bot-builder.d.ts +48 -0
- package/dist/build/bot-builder.d.ts.map +1 -0
- package/dist/build/definition-inputs.d.ts +21 -0
- package/dist/build/definition-inputs.d.ts.map +1 -0
- package/dist/build/definition-loader.d.ts +14 -0
- package/dist/build/definition-loader.d.ts.map +1 -0
- package/dist/chat-bundle.cjs +23 -22
- package/dist/codegen/bot-implementation/bot-implementation.d.ts +9 -0
- package/dist/codegen/bot-implementation/bot-implementation.d.ts.map +1 -0
- package/dist/codegen/bot-implementation/bot-plugins/index.d.ts +8 -0
- package/dist/codegen/bot-implementation/bot-plugins/index.d.ts.map +1 -0
- package/dist/codegen/bot-implementation/bot-plugins/plugin-module.d.ts +14 -0
- package/dist/codegen/bot-implementation/bot-plugins/plugin-module.d.ts.map +1 -0
- package/dist/codegen/bot-implementation/bot-typings/actions-module.d.ts +22 -0
- package/dist/codegen/bot-implementation/bot-typings/actions-module.d.ts.map +1 -0
- package/dist/codegen/bot-implementation/bot-typings/events-module.d.ts +11 -0
- package/dist/codegen/bot-implementation/bot-typings/events-module.d.ts.map +1 -0
- package/dist/codegen/bot-implementation/bot-typings/index.d.ts +8 -0
- package/dist/codegen/bot-implementation/bot-typings/index.d.ts.map +1 -0
- package/dist/codegen/bot-implementation/bot-typings/states-module.d.ts +18 -0
- package/dist/codegen/bot-implementation/bot-typings/states-module.d.ts.map +1 -0
- package/dist/codegen/bot-implementation/bot-typings/tables-module.d.ts +11 -0
- package/dist/codegen/bot-implementation/bot-typings/tables-module.d.ts.map +1 -0
- package/dist/codegen/bot-implementation/bot-typings/workflows-module.d.ts +28 -0
- package/dist/codegen/bot-implementation/bot-typings/workflows-module.d.ts.map +1 -0
- package/dist/codegen/bot-implementation/index.d.ts +4 -0
- package/dist/codegen/bot-implementation/index.d.ts.map +1 -0
- package/dist/codegen/casing.d.ts +11 -0
- package/dist/codegen/casing.d.ts.map +1 -0
- package/dist/codegen/consts.d.ts +19 -0
- package/dist/codegen/consts.d.ts.map +1 -0
- package/dist/codegen/generators.d.ts +16 -0
- package/dist/codegen/generators.d.ts.map +1 -0
- package/dist/codegen/index.d.ts +9 -0
- package/dist/codegen/index.d.ts.map +1 -0
- package/dist/codegen/integration-implementation/index.d.ts +4 -0
- package/dist/codegen/integration-implementation/index.d.ts.map +1 -0
- package/dist/codegen/integration-implementation/integration-implementation.d.ts +8 -0
- package/dist/codegen/integration-implementation/integration-implementation.d.ts.map +1 -0
- package/dist/codegen/integration-implementation/integration-typings/actions-module.d.ts +22 -0
- package/dist/codegen/integration-implementation/integration-typings/actions-module.d.ts.map +1 -0
- package/dist/codegen/integration-implementation/integration-typings/channels-module.d.ts +6 -0
- package/dist/codegen/integration-implementation/integration-typings/channels-module.d.ts.map +1 -0
- package/dist/codegen/integration-implementation/integration-typings/configuration-module.d.ts +8 -0
- package/dist/codegen/integration-implementation/integration-typings/configuration-module.d.ts.map +1 -0
- package/dist/codegen/integration-implementation/integration-typings/configurations-module.d.ts +11 -0
- package/dist/codegen/integration-implementation/integration-typings/configurations-module.d.ts.map +1 -0
- package/dist/codegen/integration-implementation/integration-typings/entities-module.d.ts +11 -0
- package/dist/codegen/integration-implementation/integration-typings/entities-module.d.ts.map +1 -0
- package/dist/codegen/integration-implementation/integration-typings/events-module.d.ts +11 -0
- package/dist/codegen/integration-implementation/integration-typings/events-module.d.ts.map +1 -0
- package/dist/codegen/integration-implementation/integration-typings/index.d.ts +9 -0
- package/dist/codegen/integration-implementation/integration-typings/index.d.ts.map +1 -0
- package/dist/codegen/integration-implementation/integration-typings/states-module.d.ts +18 -0
- package/dist/codegen/integration-implementation/integration-typings/states-module.d.ts.map +1 -0
- package/dist/codegen/integration-package/index.d.ts +3 -0
- package/dist/codegen/integration-package/index.d.ts.map +1 -0
- package/dist/codegen/integration-package/integration-package-definition/actions-module.d.ts +22 -0
- package/dist/codegen/integration-package/integration-package-definition/actions-module.d.ts.map +1 -0
- package/dist/codegen/integration-package/integration-package-definition/channels-module.d.ts +6 -0
- package/dist/codegen/integration-package/integration-package-definition/channels-module.d.ts.map +1 -0
- package/dist/codegen/integration-package/integration-package-definition/configuration-module.d.ts +8 -0
- package/dist/codegen/integration-package/integration-package-definition/configuration-module.d.ts.map +1 -0
- package/dist/codegen/integration-package/integration-package-definition/configurations-module.d.ts +11 -0
- package/dist/codegen/integration-package/integration-package-definition/configurations-module.d.ts.map +1 -0
- package/dist/codegen/integration-package/integration-package-definition/entities-module.d.ts +11 -0
- package/dist/codegen/integration-package/integration-package-definition/entities-module.d.ts.map +1 -0
- package/dist/codegen/integration-package/integration-package-definition/events-module.d.ts +11 -0
- package/dist/codegen/integration-package/integration-package-definition/events-module.d.ts.map +1 -0
- package/dist/codegen/integration-package/integration-package-definition/index.d.ts +9 -0
- package/dist/codegen/integration-package/integration-package-definition/index.d.ts.map +1 -0
- package/dist/codegen/integration-package/integration-package-definition/interfaces-module.d.ts +11 -0
- package/dist/codegen/integration-package/integration-package-definition/interfaces-module.d.ts.map +1 -0
- package/dist/codegen/integration-package/integration-package-definition/states-module.d.ts +11 -0
- package/dist/codegen/integration-package/integration-package-definition/states-module.d.ts.map +1 -0
- package/dist/codegen/integration-package/integration-package-definition/typings.d.ts +11 -0
- package/dist/codegen/integration-package/integration-package-definition/typings.d.ts.map +1 -0
- package/dist/codegen/interface-implementation/index.d.ts +5 -0
- package/dist/codegen/interface-implementation/index.d.ts.map +1 -0
- package/dist/codegen/interface-implementation/integration-typings/actions-module.d.ts +22 -0
- package/dist/codegen/interface-implementation/integration-typings/actions-module.d.ts.map +1 -0
- package/dist/codegen/interface-implementation/integration-typings/channels-module.d.ts +6 -0
- package/dist/codegen/interface-implementation/integration-typings/channels-module.d.ts.map +1 -0
- package/dist/codegen/interface-implementation/integration-typings/entities-module.d.ts +11 -0
- package/dist/codegen/interface-implementation/integration-typings/entities-module.d.ts.map +1 -0
- package/dist/codegen/interface-implementation/integration-typings/events-module.d.ts +11 -0
- package/dist/codegen/interface-implementation/integration-typings/events-module.d.ts.map +1 -0
- package/dist/codegen/interface-implementation/integration-typings/index.d.ts +9 -0
- package/dist/codegen/interface-implementation/integration-typings/index.d.ts.map +1 -0
- package/dist/codegen/interface-package/index.d.ts +3 -0
- package/dist/codegen/interface-package/index.d.ts.map +1 -0
- package/dist/codegen/interface-package/interface-package-definition/actions-module.d.ts +22 -0
- package/dist/codegen/interface-package/interface-package-definition/actions-module.d.ts.map +1 -0
- package/dist/codegen/interface-package/interface-package-definition/channels-module.d.ts +6 -0
- package/dist/codegen/interface-package/interface-package-definition/channels-module.d.ts.map +1 -0
- package/dist/codegen/interface-package/interface-package-definition/entities-module.d.ts +11 -0
- package/dist/codegen/interface-package/interface-package-definition/entities-module.d.ts.map +1 -0
- package/dist/codegen/interface-package/interface-package-definition/events-module.d.ts +11 -0
- package/dist/codegen/interface-package/interface-package-definition/events-module.d.ts.map +1 -0
- package/dist/codegen/interface-package/interface-package-definition/index.d.ts +9 -0
- package/dist/codegen/interface-package/interface-package-definition/index.d.ts.map +1 -0
- package/dist/codegen/interface-package/interface-package-definition/typings.d.ts +8 -0
- package/dist/codegen/interface-package/interface-package-definition/typings.d.ts.map +1 -0
- package/dist/codegen/module.d.ts +54 -0
- package/dist/codegen/module.d.ts.map +1 -0
- package/dist/codegen/paths.d.ts +8 -0
- package/dist/codegen/paths.d.ts.map +1 -0
- package/dist/codegen/plugin-implementation/index.d.ts +4 -0
- package/dist/codegen/plugin-implementation/index.d.ts.map +1 -0
- package/dist/codegen/plugin-implementation/plugin-implementation.d.ts +8 -0
- package/dist/codegen/plugin-implementation/plugin-implementation.d.ts.map +1 -0
- package/dist/codegen/plugin-implementation/plugin-typings/actions-module.d.ts +22 -0
- package/dist/codegen/plugin-implementation/plugin-typings/actions-module.d.ts.map +1 -0
- package/dist/codegen/plugin-implementation/plugin-typings/configuration-module.d.ts +8 -0
- package/dist/codegen/plugin-implementation/plugin-typings/configuration-module.d.ts.map +1 -0
- package/dist/codegen/plugin-implementation/plugin-typings/conversation-module.d.ts +8 -0
- package/dist/codegen/plugin-implementation/plugin-typings/conversation-module.d.ts.map +1 -0
- package/dist/codegen/plugin-implementation/plugin-typings/events-module.d.ts +11 -0
- package/dist/codegen/plugin-implementation/plugin-typings/events-module.d.ts.map +1 -0
- package/dist/codegen/plugin-implementation/plugin-typings/index.d.ts +9 -0
- package/dist/codegen/plugin-implementation/plugin-typings/index.d.ts.map +1 -0
- package/dist/codegen/plugin-implementation/plugin-typings/message-module.d.ts +8 -0
- package/dist/codegen/plugin-implementation/plugin-typings/message-module.d.ts.map +1 -0
- package/dist/codegen/plugin-implementation/plugin-typings/states-module.d.ts +18 -0
- package/dist/codegen/plugin-implementation/plugin-typings/states-module.d.ts.map +1 -0
- package/dist/codegen/plugin-implementation/plugin-typings/tables-module.d.ts +11 -0
- package/dist/codegen/plugin-implementation/plugin-typings/tables-module.d.ts.map +1 -0
- package/dist/codegen/plugin-implementation/plugin-typings/user-module.d.ts +8 -0
- package/dist/codegen/plugin-implementation/plugin-typings/user-module.d.ts.map +1 -0
- package/dist/codegen/plugin-implementation/plugin-typings/workflows-module.d.ts +28 -0
- package/dist/codegen/plugin-implementation/plugin-typings/workflows-module.d.ts.map +1 -0
- package/dist/codegen/plugin-package/index.d.ts +3 -0
- package/dist/codegen/plugin-package/index.d.ts.map +1 -0
- package/dist/codegen/plugin-package/plugin-package-definition/actions-module.d.ts +22 -0
- package/dist/codegen/plugin-package/plugin-package-definition/actions-module.d.ts.map +1 -0
- package/dist/codegen/plugin-package/plugin-package-definition/configuration-module.d.ts +8 -0
- package/dist/codegen/plugin-package/plugin-package-definition/configuration-module.d.ts.map +1 -0
- package/dist/codegen/plugin-package/plugin-package-definition/events-module.d.ts +11 -0
- package/dist/codegen/plugin-package/plugin-package-definition/events-module.d.ts.map +1 -0
- package/dist/codegen/plugin-package/plugin-package-definition/index.d.ts +9 -0
- package/dist/codegen/plugin-package/plugin-package-definition/index.d.ts.map +1 -0
- package/dist/codegen/plugin-package/plugin-package-definition/interfaces-module.d.ts +8 -0
- package/dist/codegen/plugin-package/plugin-package-definition/interfaces-module.d.ts.map +1 -0
- package/dist/codegen/plugin-package/plugin-package-definition/recurring-events-module.d.ts +6 -0
- package/dist/codegen/plugin-package/plugin-package-definition/recurring-events-module.d.ts.map +1 -0
- package/dist/codegen/plugin-package/plugin-package-definition/states-module.d.ts +11 -0
- package/dist/codegen/plugin-package/plugin-package-definition/states-module.d.ts.map +1 -0
- package/dist/codegen/plugin-package/plugin-package-definition/typings.d.ts +8 -0
- package/dist/codegen/plugin-package/plugin-package-definition/typings.d.ts.map +1 -0
- package/dist/codegen/schema.d.ts +8 -0
- package/dist/codegen/schema.d.ts.map +1 -0
- package/dist/codegen/secret-module.d.ts +17 -0
- package/dist/codegen/secret-module.d.ts.map +1 -0
- package/dist/codegen/strings.d.ts +6 -0
- package/dist/codegen/strings.d.ts.map +1 -0
- package/dist/codegen/type-utils.d.ts +9 -0
- package/dist/codegen/type-utils.d.ts.map +1 -0
- package/dist/codegen/typings.d.ts +167 -0
- package/dist/codegen/typings.d.ts.map +1 -0
- package/dist/codegen/utils.d.ts +12 -0
- package/dist/codegen/utils.d.ts.map +1 -0
- package/dist/commands/base-command.d.ts.map +1 -1
- package/dist/commands/index.d.ts +1 -12
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/native-command.d.ts +39 -0
- package/dist/commands/native-command.d.ts.map +1 -0
- package/dist/constants.d.ts +1 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/dependencies/catalog/catalog-service.d.ts +2 -0
- package/dist/dependencies/catalog/catalog-service.d.ts.map +1 -1
- package/dist/dependencies/catalog/client-factory.d.ts +7 -10
- package/dist/dependencies/catalog/client-factory.d.ts.map +1 -1
- package/dist/dependencies/catalog/integration-source.d.ts +1 -0
- package/dist/dependencies/catalog/integration-source.d.ts.map +1 -1
- package/dist/dependencies/catalog/interface-source.d.ts +1 -0
- package/dist/dependencies/catalog/interface-source.d.ts.map +1 -1
- package/dist/dependencies/catalog/plugin-source.d.ts +7 -0
- package/dist/dependencies/catalog/plugin-source.d.ts.map +1 -1
- package/dist/dependencies/catalog/resolution-cache.d.ts +8 -6
- package/dist/dependencies/catalog/resolution-cache.d.ts.map +1 -1
- package/dist/dependencies/dependency-manager.d.ts +13 -0
- package/dist/dependencies/dependency-manager.d.ts.map +1 -1
- package/dist/dependencies/index.js +502 -267
- package/dist/dependencies/index.js.map +24 -24
- package/dist/dependencies/resolvers/plugin-resolver.d.ts.map +1 -1
- package/dist/dependencies/snapshot-store.d.ts.map +1 -1
- package/dist/dependencies/types.d.ts +23 -318
- package/dist/dependencies/types.d.ts.map +1 -1
- package/dist/deploy/attributes.d.ts +16 -0
- package/dist/deploy/attributes.d.ts.map +1 -0
- package/dist/deploy/bot-body.d.ts +26 -0
- package/dist/deploy/bot-body.d.ts.map +1 -0
- package/dist/deploy/errors.d.ts +9 -0
- package/dist/deploy/errors.d.ts.map +1 -0
- package/dist/deploy/integration-utils.d.ts +11 -0
- package/dist/deploy/integration-utils.d.ts.map +1 -0
- package/dist/deploy/records.d.ts +14 -0
- package/dist/deploy/records.d.ts.map +1 -0
- package/dist/deploy/schema-utils.d.ts +16 -0
- package/dist/deploy/schema-utils.d.ts.map +1 -0
- package/dist/deploy-manifest/index.d.ts +23 -491
- package/dist/deploy-manifest/index.d.ts.map +1 -1
- package/dist/file-watcher/watcher.d.ts +18 -4
- package/dist/file-watcher/watcher.d.ts.map +1 -1
- package/dist/generators/tests.d.ts.map +1 -1
- package/dist/index.d.ts +11 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +15846 -10935
- package/dist/index.js.map +128 -48
- package/dist/knowledge/manager.d.ts.map +1 -1
- package/dist/native-deploy/deploy-bot.d.ts +32 -0
- package/dist/native-deploy/deploy-bot.d.ts.map +1 -0
- package/dist/native-deploy/prepare-dependencies.d.ts +13 -0
- package/dist/native-deploy/prepare-dependencies.d.ts.map +1 -0
- package/dist/native-dev/dev-runtime.d.ts +159 -0
- package/dist/native-dev/dev-runtime.d.ts.map +1 -0
- package/dist/native-dev/event-emitter.d.ts +8 -0
- package/dist/native-dev/event-emitter.d.ts.map +1 -0
- package/dist/native-dev/tunnel.d.ts +56 -0
- package/dist/native-dev/tunnel.d.ts.map +1 -0
- package/dist/native-dev/worker/child-wrapper.d.ts +24 -0
- package/dist/native-dev/worker/child-wrapper.d.ts.map +1 -0
- package/dist/native-dev/worker/config.d.ts +21 -0
- package/dist/native-dev/worker/config.d.ts.map +1 -0
- package/dist/native-dev/worker/worker-state.d.ts +31 -0
- package/dist/native-dev/worker/worker-state.d.ts.map +1 -0
- package/dist/native-dev/worker/worker.d.ts +32 -0
- package/dist/native-dev/worker/worker.d.ts.map +1 -0
- package/dist/{commands/bp-dev-worker-env.d.ts → native-dev/worker-env.d.ts} +1 -1
- package/dist/native-dev/worker-env.d.ts.map +1 -0
- package/dist/plugins/manager.d.ts +6 -0
- package/dist/plugins/manager.d.ts.map +1 -1
- package/dist/preflight/checker.d.ts +1 -1
- package/dist/preflight/checker.d.ts.map +1 -1
- package/dist/preflight/types.d.ts +1 -1
- package/dist/preflight/types.d.ts.map +1 -1
- package/dist/runner/script-runner.d.ts +0 -4
- package/dist/runner/script-runner.d.ts.map +1 -1
- package/dist/secrets/index.d.ts +5 -2
- package/dist/secrets/index.d.ts.map +1 -1
- package/dist/secrets/local.d.ts +28 -0
- package/dist/secrets/local.d.ts.map +1 -0
- package/dist/secrets/remote.d.ts +22 -0
- package/dist/secrets/remote.d.ts.map +1 -0
- package/dist/secrets/status.d.ts +24 -0
- package/dist/secrets/status.d.ts.map +1 -0
- package/dist/secrets/validation.d.ts +11 -0
- package/dist/secrets/validation.d.ts.map +1 -0
- package/dist/templates/README.md +6 -1
- package/dist/templates/blank/README.md +5 -0
- package/dist/templates/botpress-desk/README.md +5 -0
- package/dist/templates/crm-enrichment/README.md +5 -0
- package/dist/templates/hello-world/README.md +5 -0
- package/dist/templates/knowledge-assistant/README.md +5 -0
- package/dist/templates/slack-triage/README.md +5 -0
- package/dist/utils/adk-ignore.d.ts +17 -0
- package/dist/utils/adk-ignore.d.ts.map +1 -0
- package/dist/utils/json-ordering.d.ts +1 -1
- package/dist/utils/json-ordering.d.ts.map +1 -1
- package/dist/utils/ref-parser.d.ts +17 -0
- package/dist/utils/ref-parser.d.ts.map +1 -0
- package/dist/utils/source-map-optimizer.d.ts +4 -4
- package/package.json +11 -12
- package/dist/auth/bp-cli-import.d.ts +0 -16
- package/dist/auth/bp-cli-import.d.ts.map +0 -1
- package/dist/commands/bp-add-command.d.ts +0 -19
- package/dist/commands/bp-add-command.d.ts.map +0 -1
- package/dist/commands/bp-build-command.d.ts +0 -14
- package/dist/commands/bp-build-command.d.ts.map +0 -1
- package/dist/commands/bp-chat-command.d.ts +0 -18
- package/dist/commands/bp-chat-command.d.ts.map +0 -1
- package/dist/commands/bp-cli.d.ts +0 -14
- package/dist/commands/bp-cli.d.ts.map +0 -1
- package/dist/commands/bp-cli.js +0 -147
- package/dist/commands/bp-cli.js.map +0 -12
- package/dist/commands/bp-deploy-command.d.ts +0 -21
- package/dist/commands/bp-deploy-command.d.ts.map +0 -1
- package/dist/commands/bp-dev-command.d.ts +0 -89
- package/dist/commands/bp-dev-command.d.ts.map +0 -1
- package/dist/commands/bp-dev-stderr.d.ts +0 -30
- package/dist/commands/bp-dev-stderr.d.ts.map +0 -1
- package/dist/commands/bp-dev-worker-env.d.ts.map +0 -1
- package/dist/secrets/manager.d.ts +0 -44
- package/dist/secrets/manager.d.ts.map +0 -1
|
@@ -72,20 +72,21 @@ var init_types = __esm(() => {
|
|
|
72
72
|
name: z.string(),
|
|
73
73
|
version: z.string(),
|
|
74
74
|
enabled: z.boolean(),
|
|
75
|
-
config: z.record(z.any()).default({}),
|
|
75
|
+
config: z.record(z.string(), z.any()).default({}),
|
|
76
76
|
configurationType: z.string().optional(),
|
|
77
77
|
missingFields: z.array(z.string()).optional(),
|
|
78
78
|
authorizationPending: z.boolean().optional()
|
|
79
79
|
});
|
|
80
80
|
pluginDependencyMappingSchema = z.object({
|
|
81
|
-
integrationAlias: z.string()
|
|
81
|
+
integrationAlias: z.string(),
|
|
82
|
+
integrationInterfaceAlias: z.string().optional()
|
|
82
83
|
});
|
|
83
84
|
pluginDependencyEntrySchema = z.object({
|
|
84
85
|
name: z.string(),
|
|
85
86
|
version: z.string(),
|
|
86
87
|
enabled: z.boolean().default(true),
|
|
87
|
-
config: z.record(z.any()).default({}),
|
|
88
|
-
dependencies: z.record(pluginDependencyMappingSchema).default({}),
|
|
88
|
+
config: z.record(z.string(), z.any()).default({}),
|
|
89
|
+
dependencies: z.record(z.string(), pluginDependencyMappingSchema).default({}),
|
|
89
90
|
missingFields: z.array(z.string()).optional()
|
|
90
91
|
});
|
|
91
92
|
integrationSnapshotEntrySchema = integrationDependencyEntrySchema.extend({
|
|
@@ -102,8 +103,8 @@ var init_types = __esm(() => {
|
|
|
102
103
|
$schema: z.string().optional(),
|
|
103
104
|
version: z.literal(1),
|
|
104
105
|
env: z.enum(["dev", "prod"]),
|
|
105
|
-
integrations: z.record(integrationDependencyEntrySchema).default({}),
|
|
106
|
-
plugins: z.record(pluginDependencyEntrySchema).default({})
|
|
106
|
+
integrations: z.record(z.string(), integrationDependencyEntrySchema).default({}),
|
|
107
|
+
plugins: z.record(z.string(), pluginDependencyEntrySchema).default({})
|
|
107
108
|
});
|
|
108
109
|
dependencySnapshotSchema = z.object({
|
|
109
110
|
$schema: z.string().optional(),
|
|
@@ -113,8 +114,8 @@ var init_types = __esm(() => {
|
|
|
113
114
|
fetchedAt: z.string(),
|
|
114
115
|
botUpdatedAt: z.string().optional(),
|
|
115
116
|
stale: z.boolean().optional(),
|
|
116
|
-
integrations: z.record(integrationSnapshotEntrySchema).default({}),
|
|
117
|
-
plugins: z.record(pluginSnapshotEntrySchema).default({})
|
|
117
|
+
integrations: z.record(z.string(), integrationSnapshotEntrySchema).default({}),
|
|
118
|
+
plugins: z.record(z.string(), pluginSnapshotEntrySchema).default({})
|
|
118
119
|
});
|
|
119
120
|
dependencyMigrationMarkerSchema = z.object({
|
|
120
121
|
version: z.literal(1),
|
|
@@ -131,6 +132,9 @@ function isAdkError(error) {
|
|
|
131
132
|
return false;
|
|
132
133
|
return error.constructor?.__IS_ADK_BASE_ERROR === true;
|
|
133
134
|
}
|
|
135
|
+
function isExpectedError(error) {
|
|
136
|
+
return isAdkError(error) && error.expected;
|
|
137
|
+
}
|
|
134
138
|
var AdkError;
|
|
135
139
|
var init_errors = __esm(() => {
|
|
136
140
|
AdkError = class AdkError extends Error {
|
|
@@ -143,7 +147,7 @@ var init_errors = __esm(() => {
|
|
|
143
147
|
super(opts.message, opts.cause !== undefined ? { cause: opts.cause } : undefined);
|
|
144
148
|
this.name = this.constructor.name;
|
|
145
149
|
this.code = opts.code;
|
|
146
|
-
this.expected = opts.expected ??
|
|
150
|
+
this.expected = opts.expected ?? true;
|
|
147
151
|
if (opts.details !== undefined) {
|
|
148
152
|
this.details = opts.details;
|
|
149
153
|
}
|
|
@@ -381,13 +385,13 @@ var init_types2 = __esm(() => {
|
|
|
381
385
|
version: z2.string(),
|
|
382
386
|
enabled: z2.boolean(),
|
|
383
387
|
configurationType: z2.string().optional(),
|
|
384
|
-
config: z2.record(z2.any()).optional()
|
|
388
|
+
config: z2.record(z2.string(), z2.any()).optional()
|
|
385
389
|
})
|
|
386
390
|
])).optional(),
|
|
387
391
|
plugins: z2.record(z2.object({
|
|
388
392
|
version: z2.string(),
|
|
389
|
-
config: z2.record(z2.any()).optional(),
|
|
390
|
-
dependencies: z2.record(pluginDependencyMappingSchema2).optional(),
|
|
393
|
+
config: z2.record(z2.string(), z2.any()).optional(),
|
|
394
|
+
dependencies: z2.record(z2.string(), pluginDependencyMappingSchema2).optional(),
|
|
391
395
|
missingFields: z2.array(z2.string()).optional()
|
|
392
396
|
})).optional()
|
|
393
397
|
});
|
|
@@ -400,7 +404,8 @@ var init_types2 = __esm(() => {
|
|
|
400
404
|
botId: z2.string().optional().describe("The bot ID (overrides agent.json for local development)"),
|
|
401
405
|
workspaceId: z2.string().optional().describe("The workspace ID (overrides agent.json for local development)"),
|
|
402
406
|
apiUrl: z2.string().optional().describe("The Botpress API URL (overrides agent.json for local development)"),
|
|
403
|
-
devId: z2.string().optional().describe("The development bot ID used during local development")
|
|
407
|
+
devId: z2.string().optional().describe("The development bot ID used during local development"),
|
|
408
|
+
tunnelId: z2.string().optional().describe("The dev tunnel ID, reused across local dev sessions")
|
|
404
409
|
});
|
|
405
410
|
((ValidationErrorCode2) => {
|
|
406
411
|
ValidationErrorCode2["DIRECTORY_NOT_FOUND"] = "DIRECTORY_NOT_FOUND";
|
|
@@ -1056,7 +1061,7 @@ var init_dependencies_parser = __esm(() => {
|
|
|
1056
1061
|
});
|
|
1057
1062
|
|
|
1058
1063
|
// src/constants.ts
|
|
1059
|
-
var DEFAULT_API_URL = "https://api.botpress.cloud", BUILTIN_INTERFACES, MAX_TABLE_COLUMNS = 20;
|
|
1064
|
+
var DEFAULT_API_URL = "https://api.botpress.cloud", BUILTIN_INTERFACES, MAX_TABLE_COLUMNS = 20, MAX_ACTION_DESCRIPTION_LENGTH = 256;
|
|
1060
1065
|
var init_constants = __esm(() => {
|
|
1061
1066
|
BUILTIN_INTERFACES = {
|
|
1062
1067
|
"typing-indicator": "typing-indicator@0.0.3",
|
|
@@ -1102,6 +1107,9 @@ function applyLocalOverrides(agentInfo, localInfo) {
|
|
|
1102
1107
|
if (localInfo.devId) {
|
|
1103
1108
|
agentInfo.devId = localInfo.devId;
|
|
1104
1109
|
}
|
|
1110
|
+
if (localInfo.tunnelId) {
|
|
1111
|
+
agentInfo.tunnelId = localInfo.tunnelId;
|
|
1112
|
+
}
|
|
1105
1113
|
}
|
|
1106
1114
|
async function resolveAgent(agentPath, options = {}) {
|
|
1107
1115
|
const { required = false, requireWorkspace = false, requireBot = false } = options;
|
|
@@ -1140,7 +1148,8 @@ async function resolveAgent(agentPath, options = {}) {
|
|
|
1140
1148
|
botId: localInfo.botId,
|
|
1141
1149
|
workspaceId: localInfo.workspaceId,
|
|
1142
1150
|
apiUrl: localInfo.apiUrl,
|
|
1143
|
-
devId: localInfo.devId
|
|
1151
|
+
devId: localInfo.devId,
|
|
1152
|
+
tunnelId: localInfo.tunnelId
|
|
1144
1153
|
};
|
|
1145
1154
|
} else if (required || requireWorkspace || requireBot) {
|
|
1146
1155
|
throw ValidationErrors.requiredFileMissing("agent.json or agent.local.json");
|
|
@@ -1170,10 +1179,6 @@ var init_agent_resolver = __esm(() => {
|
|
|
1170
1179
|
});
|
|
1171
1180
|
|
|
1172
1181
|
// src/auth/credentials.ts
|
|
1173
|
-
var exports_credentials = {};
|
|
1174
|
-
__export(exports_credentials, {
|
|
1175
|
-
CredentialsManager: () => CredentialsManager
|
|
1176
|
-
});
|
|
1177
1182
|
import fs2 from "fs/promises";
|
|
1178
1183
|
import path2 from "path";
|
|
1179
1184
|
import os from "os";
|
|
@@ -1450,67 +1455,6 @@ var init_service = __esm(() => {
|
|
|
1450
1455
|
init_src();
|
|
1451
1456
|
});
|
|
1452
1457
|
|
|
1453
|
-
// src/auth/bp-cli-import.ts
|
|
1454
|
-
import fs3 from "fs/promises";
|
|
1455
|
-
import path3 from "path";
|
|
1456
|
-
import os2 from "os";
|
|
1457
|
-
|
|
1458
|
-
class BpCliImporter {
|
|
1459
|
-
bpCachePath;
|
|
1460
|
-
constructor() {
|
|
1461
|
-
this.bpCachePath = path3.join(os2.homedir(), ".botpress", "global.cache.json");
|
|
1462
|
-
}
|
|
1463
|
-
async hasBpCliCredentials() {
|
|
1464
|
-
try {
|
|
1465
|
-
await fs3.access(this.bpCachePath);
|
|
1466
|
-
return true;
|
|
1467
|
-
} catch {
|
|
1468
|
-
return false;
|
|
1469
|
-
}
|
|
1470
|
-
}
|
|
1471
|
-
async getBpCliCredentials() {
|
|
1472
|
-
try {
|
|
1473
|
-
const data = await fs3.readFile(this.bpCachePath, "utf-8");
|
|
1474
|
-
const credentials = JSON.parse(data);
|
|
1475
|
-
if (!credentials.token || !credentials.workspaceId || !credentials.apiUrl) {
|
|
1476
|
-
return null;
|
|
1477
|
-
}
|
|
1478
|
-
return credentials;
|
|
1479
|
-
} catch {
|
|
1480
|
-
return null;
|
|
1481
|
-
}
|
|
1482
|
-
}
|
|
1483
|
-
async importFromBpCli(profileName = "default") {
|
|
1484
|
-
const bpCredentials = await this.getBpCliCredentials();
|
|
1485
|
-
if (!bpCredentials) {
|
|
1486
|
-
return false;
|
|
1487
|
-
}
|
|
1488
|
-
try {
|
|
1489
|
-
await auth.login(bpCredentials.token, {
|
|
1490
|
-
profile: profileName,
|
|
1491
|
-
apiUrl: bpCredentials.apiUrl
|
|
1492
|
-
});
|
|
1493
|
-
const credentialsManager = new (await Promise.resolve().then(() => (init_credentials(), exports_credentials))).CredentialsManager;
|
|
1494
|
-
const store = await credentialsManager["readCredentials"]();
|
|
1495
|
-
if (store.profiles[profileName]) {
|
|
1496
|
-
store.profiles[profileName].workspaceId = bpCredentials.workspaceId;
|
|
1497
|
-
if (bpCredentials.botId) {
|
|
1498
|
-
store.profiles[profileName].botId = bpCredentials.botId;
|
|
1499
|
-
}
|
|
1500
|
-
await credentialsManager["writeCredentials"](store);
|
|
1501
|
-
}
|
|
1502
|
-
return true;
|
|
1503
|
-
} catch {
|
|
1504
|
-
return false;
|
|
1505
|
-
}
|
|
1506
|
-
}
|
|
1507
|
-
}
|
|
1508
|
-
var bpCliImporter;
|
|
1509
|
-
var init_bp_cli_import = __esm(() => {
|
|
1510
|
-
init_auth();
|
|
1511
|
-
bpCliImporter = new BpCliImporter;
|
|
1512
|
-
});
|
|
1513
|
-
|
|
1514
1458
|
// src/auth/index.ts
|
|
1515
1459
|
import { Client as Client2 } from "@botpress/client";
|
|
1516
1460
|
|
|
@@ -1658,7 +1602,7 @@ async function resolveBotCredentials(options = {}) {
|
|
|
1658
1602
|
}
|
|
1659
1603
|
async function getProjectClient(options = {}) {
|
|
1660
1604
|
const credentials = await resolveWorkspaceCredentials(options);
|
|
1661
|
-
const botId = options.botId;
|
|
1605
|
+
const botId = options.botId ?? credentials.botId;
|
|
1662
1606
|
const headers = {
|
|
1663
1607
|
"x-multiple-integrations": "true",
|
|
1664
1608
|
...options.headers ?? {}
|
|
@@ -1670,7 +1614,8 @@ async function getProjectClient(options = {}) {
|
|
|
1670
1614
|
botId,
|
|
1671
1615
|
integrationId: options.integrationId,
|
|
1672
1616
|
integrationAlias: options.integrationAlias,
|
|
1673
|
-
headers
|
|
1617
|
+
headers,
|
|
1618
|
+
timeoutMs: options.timeoutMs
|
|
1674
1619
|
});
|
|
1675
1620
|
const cached = projectClientCache.get(cacheKey);
|
|
1676
1621
|
if (cached) {
|
|
@@ -1685,6 +1630,7 @@ async function getProjectClient(options = {}) {
|
|
|
1685
1630
|
...botId ? { botId } : {},
|
|
1686
1631
|
...options.integrationId ? { integrationId: options.integrationId } : {},
|
|
1687
1632
|
...options.integrationAlias ? { integrationAlias: options.integrationAlias } : {},
|
|
1633
|
+
...options.timeoutMs !== undefined ? { timeout: options.timeoutMs } : {},
|
|
1688
1634
|
headers
|
|
1689
1635
|
});
|
|
1690
1636
|
if (projectClientCache.size >= MAX_PROJECT_CLIENT_CACHE_ENTRIES) {
|
|
@@ -1718,7 +1664,6 @@ var init_auth = __esm(() => {
|
|
|
1718
1664
|
init_service();
|
|
1719
1665
|
init_agent_resolver();
|
|
1720
1666
|
init_credentials();
|
|
1721
|
-
init_bp_cli_import();
|
|
1722
1667
|
auth = new Auth;
|
|
1723
1668
|
projectClientCache = new Map;
|
|
1724
1669
|
});
|
|
@@ -1729,32 +1674,36 @@ import { Client as Client3 } from "@botpress/client";
|
|
|
1729
1674
|
class CatalogClientFactory {
|
|
1730
1675
|
options;
|
|
1731
1676
|
client;
|
|
1677
|
+
resolvedCredentials;
|
|
1732
1678
|
constructor(options = {}) {
|
|
1733
1679
|
this.options = options;
|
|
1734
1680
|
}
|
|
1681
|
+
async getCredentials() {
|
|
1682
|
+
if (this.resolvedCredentials)
|
|
1683
|
+
return this.resolvedCredentials;
|
|
1684
|
+
const { project, workspaceId, credentials, apiUrl } = this.options;
|
|
1685
|
+
this.resolvedCredentials = await resolveWorkspaceCredentials({
|
|
1686
|
+
project,
|
|
1687
|
+
credentials,
|
|
1688
|
+
apiUrl,
|
|
1689
|
+
workspaceId
|
|
1690
|
+
});
|
|
1691
|
+
return this.resolvedCredentials;
|
|
1692
|
+
}
|
|
1693
|
+
async getCacheScope() {
|
|
1694
|
+
const resolved = await this.getCredentials();
|
|
1695
|
+
return `${resolved.apiUrl.replace(/\/+$/, "")}|${resolved.workspaceId}`;
|
|
1696
|
+
}
|
|
1735
1697
|
async getClient() {
|
|
1736
1698
|
if (this.client)
|
|
1737
1699
|
return this.client;
|
|
1738
|
-
const
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
workspaceId,
|
|
1746
|
-
headers: { ...CATALOG_HEADERS }
|
|
1747
|
-
});
|
|
1748
|
-
} else if (credentials) {
|
|
1749
|
-
this.client = new Client3({
|
|
1750
|
-
token: credentials.token,
|
|
1751
|
-
apiUrl: apiUrl || credentials.apiUrl,
|
|
1752
|
-
...credentials.workspaceId ? { workspaceId: credentials.workspaceId } : {},
|
|
1753
|
-
headers: { ...CATALOG_HEADERS }
|
|
1754
|
-
});
|
|
1755
|
-
} else {
|
|
1756
|
-
this.client = await getProjectClient({ headers: { ...CATALOG_HEADERS } });
|
|
1757
|
-
}
|
|
1700
|
+
const resolved = await this.getCredentials();
|
|
1701
|
+
this.client = new Client3({
|
|
1702
|
+
token: resolved.token,
|
|
1703
|
+
apiUrl: resolved.apiUrl,
|
|
1704
|
+
workspaceId: resolved.workspaceId,
|
|
1705
|
+
headers: { ...CATALOG_HEADERS }
|
|
1706
|
+
});
|
|
1758
1707
|
return this.client;
|
|
1759
1708
|
}
|
|
1760
1709
|
}
|
|
@@ -1765,9 +1714,9 @@ var init_client_factory = __esm(() => {
|
|
|
1765
1714
|
});
|
|
1766
1715
|
|
|
1767
1716
|
// src/dependencies/catalog/resolution-cache.ts
|
|
1768
|
-
import
|
|
1769
|
-
import
|
|
1770
|
-
import
|
|
1717
|
+
import fs3 from "fs/promises";
|
|
1718
|
+
import path3 from "path";
|
|
1719
|
+
import os2 from "os";
|
|
1771
1720
|
|
|
1772
1721
|
class ResolutionCache {
|
|
1773
1722
|
cacheDir;
|
|
@@ -1778,23 +1727,23 @@ class ResolutionCache {
|
|
|
1778
1727
|
constructor(config, noCache = false) {
|
|
1779
1728
|
this.idField = config.idField;
|
|
1780
1729
|
this.noCache = noCache;
|
|
1781
|
-
const cacheRoot = config.cacheRoot ??
|
|
1782
|
-
this.cacheDir =
|
|
1783
|
-
this.resolutionsDir =
|
|
1784
|
-
this.definitionsDir =
|
|
1730
|
+
const cacheRoot = config.cacheRoot ?? path3.join(os2.homedir(), ".adk", "cache");
|
|
1731
|
+
this.cacheDir = path3.join(cacheRoot, config.cacheType);
|
|
1732
|
+
this.resolutionsDir = path3.join(this.cacheDir, "resolutions");
|
|
1733
|
+
this.definitionsDir = path3.join(this.cacheDir, "definitions");
|
|
1785
1734
|
}
|
|
1786
1735
|
async ensureCacheDirs() {
|
|
1787
|
-
await
|
|
1788
|
-
await
|
|
1736
|
+
await fs3.mkdir(this.resolutionsDir, { recursive: true });
|
|
1737
|
+
await fs3.mkdir(this.definitionsDir, { recursive: true });
|
|
1789
1738
|
}
|
|
1790
1739
|
async getResolution(name, version, workspace, options) {
|
|
1791
1740
|
if (this.noCache) {
|
|
1792
1741
|
return null;
|
|
1793
1742
|
}
|
|
1794
1743
|
try {
|
|
1795
|
-
const key = this.getResolutionKey(name, version, workspace);
|
|
1796
|
-
const cachePath =
|
|
1797
|
-
const data = await
|
|
1744
|
+
const key = this.getResolutionKey(name, version, workspace, options?.cacheScope);
|
|
1745
|
+
const cachePath = path3.join(this.resolutionsDir, `${key}.json`);
|
|
1746
|
+
const data = await fs3.readFile(cachePath, "utf-8");
|
|
1798
1747
|
const raw = JSON.parse(data);
|
|
1799
1748
|
if (!options?.allowStale) {
|
|
1800
1749
|
const cachedAt = new Date(raw.cachedAt);
|
|
@@ -1812,16 +1761,16 @@ class ResolutionCache {
|
|
|
1812
1761
|
return null;
|
|
1813
1762
|
}
|
|
1814
1763
|
}
|
|
1815
|
-
async setResolution(name, version, workspace, id, updatedAt) {
|
|
1764
|
+
async setResolution(name, version, workspace, id, updatedAt, cacheScope) {
|
|
1816
1765
|
await this.ensureCacheDirs();
|
|
1817
|
-
const key = this.getResolutionKey(name, version, workspace);
|
|
1818
|
-
const cachePath =
|
|
1766
|
+
const key = this.getResolutionKey(name, version, workspace, cacheScope);
|
|
1767
|
+
const cachePath = path3.join(this.resolutionsDir, `${key}.json`);
|
|
1819
1768
|
const resolution = {
|
|
1820
1769
|
[this.idField]: id,
|
|
1821
1770
|
updatedAt,
|
|
1822
1771
|
cachedAt: new Date().toISOString()
|
|
1823
1772
|
};
|
|
1824
|
-
await
|
|
1773
|
+
await fs3.writeFile(cachePath, JSON.stringify(resolution));
|
|
1825
1774
|
}
|
|
1826
1775
|
async getDefinition(id, updatedAt) {
|
|
1827
1776
|
if (this.noCache) {
|
|
@@ -1829,8 +1778,8 @@ class ResolutionCache {
|
|
|
1829
1778
|
}
|
|
1830
1779
|
try {
|
|
1831
1780
|
const key = this.getDefinitionKey(id, updatedAt);
|
|
1832
|
-
const cachePath =
|
|
1833
|
-
const data = await
|
|
1781
|
+
const cachePath = path3.join(this.definitionsDir, `${key}.json`);
|
|
1782
|
+
const data = await fs3.readFile(cachePath, "utf-8");
|
|
1834
1783
|
const cached = JSON.parse(data);
|
|
1835
1784
|
return cached.definition;
|
|
1836
1785
|
} catch {
|
|
@@ -1840,28 +1789,28 @@ class ResolutionCache {
|
|
|
1840
1789
|
async setDefinition(id, updatedAt, definition) {
|
|
1841
1790
|
await this.ensureCacheDirs();
|
|
1842
1791
|
const key = this.getDefinitionKey(id, updatedAt);
|
|
1843
|
-
const cachePath =
|
|
1792
|
+
const cachePath = path3.join(this.definitionsDir, `${key}.json`);
|
|
1844
1793
|
const cached = {
|
|
1845
1794
|
definition,
|
|
1846
1795
|
cachedAt: new Date().toISOString()
|
|
1847
1796
|
};
|
|
1848
|
-
await
|
|
1797
|
+
await fs3.writeFile(cachePath, JSON.stringify(cached));
|
|
1849
1798
|
}
|
|
1850
1799
|
async clear() {
|
|
1851
1800
|
try {
|
|
1852
|
-
const resolutionFiles = await
|
|
1853
|
-
await Promise.all(resolutionFiles.map((file) =>
|
|
1854
|
-
const definitionFiles = await
|
|
1855
|
-
await Promise.all(definitionFiles.map((file) =>
|
|
1801
|
+
const resolutionFiles = await fs3.readdir(this.resolutionsDir);
|
|
1802
|
+
await Promise.all(resolutionFiles.map((file) => fs3.unlink(path3.join(this.resolutionsDir, file))));
|
|
1803
|
+
const definitionFiles = await fs3.readdir(this.definitionsDir);
|
|
1804
|
+
await Promise.all(definitionFiles.map((file) => fs3.unlink(path3.join(this.definitionsDir, file))));
|
|
1856
1805
|
} catch {}
|
|
1857
1806
|
}
|
|
1858
1807
|
async getStats() {
|
|
1859
1808
|
const getDirectoryStats = async (dir) => {
|
|
1860
1809
|
try {
|
|
1861
|
-
const files = await
|
|
1810
|
+
const files = await fs3.readdir(dir);
|
|
1862
1811
|
let totalSize = 0;
|
|
1863
1812
|
for (const file of files) {
|
|
1864
|
-
const stats = await
|
|
1813
|
+
const stats = await fs3.stat(path3.join(dir, file));
|
|
1865
1814
|
totalSize += stats.size;
|
|
1866
1815
|
}
|
|
1867
1816
|
return { count: files.length, sizeBytes: totalSize };
|
|
@@ -1875,9 +1824,10 @@ class ResolutionCache {
|
|
|
1875
1824
|
]);
|
|
1876
1825
|
return { resolutions, definitions };
|
|
1877
1826
|
}
|
|
1878
|
-
getResolutionKey(name, version, workspace) {
|
|
1827
|
+
getResolutionKey(name, version, workspace, cacheScope) {
|
|
1828
|
+
const scopePrefix = cacheScope ? `${cacheScope}_` : "";
|
|
1879
1829
|
const prefix = workspace ? `${workspace}_` : "";
|
|
1880
|
-
const key = `${prefix}${name}_${version}`;
|
|
1830
|
+
const key = `${scopePrefix}${prefix}${name}_${version}`;
|
|
1881
1831
|
return key.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
1882
1832
|
}
|
|
1883
1833
|
getDefinitionKey(id, updatedAt) {
|
|
@@ -1897,7 +1847,8 @@ class CatalogService {
|
|
|
1897
1847
|
this.cache = new ResolutionCache(source.cacheConfig, noCache);
|
|
1898
1848
|
}
|
|
1899
1849
|
async getDefinition(ref) {
|
|
1900
|
-
const
|
|
1850
|
+
const cacheScope = await this.source.getCacheScope();
|
|
1851
|
+
const cachedResolution = await this.cache.getResolution(ref.name, ref.version, ref.workspace, { cacheScope });
|
|
1901
1852
|
if (cachedResolution) {
|
|
1902
1853
|
const cachedDefinition = await this.cache.getDefinition(cachedResolution.id, cachedResolution.updatedAt);
|
|
1903
1854
|
if (cachedDefinition) {
|
|
@@ -1906,12 +1857,12 @@ class CatalogService {
|
|
|
1906
1857
|
}
|
|
1907
1858
|
try {
|
|
1908
1859
|
const { id, updatedAt, definition } = await this.source.fetchByRef(ref);
|
|
1909
|
-
await this.cache.setResolution(ref.name, ref.version, ref.workspace, id, updatedAt);
|
|
1860
|
+
await this.cache.setResolution(ref.name, ref.version, ref.workspace, id, updatedAt, cacheScope);
|
|
1910
1861
|
await this.cache.setDefinition(id, updatedAt, definition);
|
|
1911
1862
|
return definition;
|
|
1912
1863
|
} catch (err) {
|
|
1913
1864
|
if (!(err instanceof AdkError && err.expected)) {
|
|
1914
|
-
const stale = await this.getStaleDefinition(ref);
|
|
1865
|
+
const stale = await this.getStaleDefinition(ref, cacheScope);
|
|
1915
1866
|
if (stale !== null) {
|
|
1916
1867
|
return stale;
|
|
1917
1868
|
}
|
|
@@ -1919,8 +1870,11 @@ class CatalogService {
|
|
|
1919
1870
|
throw err;
|
|
1920
1871
|
}
|
|
1921
1872
|
}
|
|
1922
|
-
async getStaleDefinition(ref) {
|
|
1923
|
-
const stale = await this.cache.getResolution(ref.name, ref.version, ref.workspace, {
|
|
1873
|
+
async getStaleDefinition(ref, cacheScope) {
|
|
1874
|
+
const stale = await this.cache.getResolution(ref.name, ref.version, ref.workspace, {
|
|
1875
|
+
allowStale: true,
|
|
1876
|
+
cacheScope
|
|
1877
|
+
});
|
|
1924
1878
|
if (!stale)
|
|
1925
1879
|
return null;
|
|
1926
1880
|
return this.cache.getDefinition(stale.id, stale.updatedAt);
|
|
@@ -2014,6 +1968,9 @@ class IntegrationCatalogSource {
|
|
|
2014
1968
|
constructor(clientFactory) {
|
|
2015
1969
|
this.clientFactory = clientFactory;
|
|
2016
1970
|
}
|
|
1971
|
+
async getCacheScope() {
|
|
1972
|
+
return this.clientFactory.getCacheScope();
|
|
1973
|
+
}
|
|
2017
1974
|
async fetchByRef(ref) {
|
|
2018
1975
|
const client = await this.clientFactory.getClient();
|
|
2019
1976
|
const integration = await this._findPrivateOrPublicIntegration(client, ref);
|
|
@@ -2311,8 +2268,8 @@ var init_types3 = () => {};
|
|
|
2311
2268
|
var defaultAdkFolder = ".adk";
|
|
2312
2269
|
|
|
2313
2270
|
// src/assets/cache.ts
|
|
2314
|
-
import
|
|
2315
|
-
import
|
|
2271
|
+
import fs4 from "fs/promises";
|
|
2272
|
+
import path4 from "path";
|
|
2316
2273
|
|
|
2317
2274
|
class AssetsCacheManager {
|
|
2318
2275
|
projectPath;
|
|
@@ -2320,14 +2277,14 @@ class AssetsCacheManager {
|
|
|
2320
2277
|
cache = null;
|
|
2321
2278
|
constructor(projectPath) {
|
|
2322
2279
|
this.projectPath = projectPath;
|
|
2323
|
-
this.cachePath =
|
|
2280
|
+
this.cachePath = path4.join(projectPath, defaultAdkFolder, "assets-cache.json");
|
|
2324
2281
|
}
|
|
2325
2282
|
async load() {
|
|
2326
2283
|
if (this.cache) {
|
|
2327
2284
|
return this.cache;
|
|
2328
2285
|
}
|
|
2329
2286
|
try {
|
|
2330
|
-
const content = await
|
|
2287
|
+
const content = await fs4.readFile(this.cachePath, "utf-8");
|
|
2331
2288
|
this.cache = JSON.parse(content);
|
|
2332
2289
|
return this.cache;
|
|
2333
2290
|
} catch {
|
|
@@ -2342,9 +2299,9 @@ class AssetsCacheManager {
|
|
|
2342
2299
|
if (!this.cache) {
|
|
2343
2300
|
return;
|
|
2344
2301
|
}
|
|
2345
|
-
const cacheDir =
|
|
2346
|
-
await
|
|
2347
|
-
await
|
|
2302
|
+
const cacheDir = path4.dirname(this.cachePath);
|
|
2303
|
+
await fs4.mkdir(cacheDir, { recursive: true });
|
|
2304
|
+
await fs4.writeFile(this.cachePath, JSON.stringify(this.cache, null, 2), "utf-8");
|
|
2348
2305
|
}
|
|
2349
2306
|
async getEntry(assetPath) {
|
|
2350
2307
|
const cache = await this.load();
|
|
@@ -2387,8 +2344,8 @@ class AssetsCacheManager {
|
|
|
2387
2344
|
var init_cache = () => {};
|
|
2388
2345
|
|
|
2389
2346
|
// src/assets/manager.ts
|
|
2390
|
-
import
|
|
2391
|
-
import
|
|
2347
|
+
import fs5 from "fs/promises";
|
|
2348
|
+
import path5 from "path";
|
|
2392
2349
|
import crypto from "crypto";
|
|
2393
2350
|
|
|
2394
2351
|
class AssetsManager {
|
|
@@ -2400,7 +2357,7 @@ class AssetsManager {
|
|
|
2400
2357
|
cacheManager;
|
|
2401
2358
|
constructor(options) {
|
|
2402
2359
|
this.projectPath = options.projectPath;
|
|
2403
|
-
this.assetsPath =
|
|
2360
|
+
this.assetsPath = path5.join(this.projectPath, "assets");
|
|
2404
2361
|
this.botId = options.botId;
|
|
2405
2362
|
this.credentials = options.credentials;
|
|
2406
2363
|
this.cacheManager = new AssetsCacheManager(this.projectPath);
|
|
@@ -2438,7 +2395,7 @@ class AssetsManager {
|
|
|
2438
2395
|
}
|
|
2439
2396
|
async hasAssetsDirectory() {
|
|
2440
2397
|
try {
|
|
2441
|
-
const stats = await
|
|
2398
|
+
const stats = await fs5.stat(this.assetsPath);
|
|
2442
2399
|
return stats.isDirectory();
|
|
2443
2400
|
} catch {
|
|
2444
2401
|
return false;
|
|
@@ -2452,16 +2409,16 @@ class AssetsManager {
|
|
|
2452
2409
|
const assets = [];
|
|
2453
2410
|
for (const filePath of files) {
|
|
2454
2411
|
try {
|
|
2455
|
-
const stats = await
|
|
2412
|
+
const stats = await fs5.stat(filePath);
|
|
2456
2413
|
if (stats.isFile()) {
|
|
2457
|
-
const relativePath =
|
|
2458
|
-
const content = await
|
|
2414
|
+
const relativePath = path5.relative(this.assetsPath, filePath);
|
|
2415
|
+
const content = await fs5.readFile(filePath);
|
|
2459
2416
|
const hash = this.calculateHash(content);
|
|
2460
2417
|
const mime = this.getMimeType(filePath);
|
|
2461
2418
|
assets.push({
|
|
2462
2419
|
relativePath,
|
|
2463
2420
|
absolutePath: filePath,
|
|
2464
|
-
name:
|
|
2421
|
+
name: path5.basename(filePath),
|
|
2465
2422
|
size: stats.size,
|
|
2466
2423
|
mime,
|
|
2467
2424
|
hash,
|
|
@@ -2489,7 +2446,7 @@ class AssetsManager {
|
|
|
2489
2446
|
});
|
|
2490
2447
|
return response.files.map((file) => ({
|
|
2491
2448
|
path: file.tags?.path || file.key,
|
|
2492
|
-
name:
|
|
2449
|
+
name: path5.basename(file.tags?.path || file.key),
|
|
2493
2450
|
size: file.size || 0,
|
|
2494
2451
|
mime: file.contentType,
|
|
2495
2452
|
hash: file.tags?.hash || "",
|
|
@@ -2627,7 +2584,7 @@ class AssetsManager {
|
|
|
2627
2584
|
};
|
|
2628
2585
|
}
|
|
2629
2586
|
async uploadAsset(client, localFile) {
|
|
2630
|
-
const content = await
|
|
2587
|
+
const content = await fs5.readFile(localFile.absolutePath);
|
|
2631
2588
|
await client.uploadFile({
|
|
2632
2589
|
key: localFile.relativePath,
|
|
2633
2590
|
content,
|
|
@@ -2720,10 +2677,10 @@ declare global {
|
|
|
2720
2677
|
return enrichedAssets;
|
|
2721
2678
|
}
|
|
2722
2679
|
async scanDirectory(dir, files = []) {
|
|
2723
|
-
const items = await
|
|
2680
|
+
const items = await fs5.readdir(dir);
|
|
2724
2681
|
for (const item of items) {
|
|
2725
|
-
const fullPath =
|
|
2726
|
-
const stats = await
|
|
2682
|
+
const fullPath = path5.join(dir, item);
|
|
2683
|
+
const stats = await fs5.stat(fullPath);
|
|
2727
2684
|
if (stats.isDirectory()) {
|
|
2728
2685
|
await this.scanDirectory(fullPath, files);
|
|
2729
2686
|
} else {
|
|
@@ -2736,7 +2693,7 @@ declare global {
|
|
|
2736
2693
|
return crypto.createHash("sha256").update(content).digest("hex");
|
|
2737
2694
|
}
|
|
2738
2695
|
getMimeType(filePath) {
|
|
2739
|
-
const ext =
|
|
2696
|
+
const ext = path5.extname(filePath).toLowerCase();
|
|
2740
2697
|
const mimeTypes = {
|
|
2741
2698
|
".png": "image/png",
|
|
2742
2699
|
".jpg": "image/jpeg",
|
|
@@ -2772,10 +2729,10 @@ var init_manager2 = __esm(() => {
|
|
|
2772
2729
|
// src/utils/fs.ts
|
|
2773
2730
|
import { mkdir, writeFile } from "fs/promises";
|
|
2774
2731
|
import { parse } from "path";
|
|
2775
|
-
var createFile = async (
|
|
2776
|
-
const file = parse(
|
|
2732
|
+
var createFile = async (path6, content) => {
|
|
2733
|
+
const file = parse(path6);
|
|
2777
2734
|
await mkdir(file.dir, { recursive: true });
|
|
2778
|
-
await writeFile(
|
|
2735
|
+
await writeFile(path6, content);
|
|
2779
2736
|
};
|
|
2780
2737
|
var init_fs = () => {};
|
|
2781
2738
|
|
|
@@ -2793,19 +2750,19 @@ var init_assets = __esm(() => {
|
|
|
2793
2750
|
});
|
|
2794
2751
|
|
|
2795
2752
|
// src/integrations/cache.ts
|
|
2796
|
-
import
|
|
2797
|
-
import
|
|
2798
|
-
import
|
|
2753
|
+
import fs6 from "fs/promises";
|
|
2754
|
+
import path6 from "path";
|
|
2755
|
+
import os3 from "os";
|
|
2799
2756
|
|
|
2800
2757
|
class IntegrationCache {
|
|
2801
2758
|
cacheDir;
|
|
2802
2759
|
integrationsDir;
|
|
2803
2760
|
constructor() {
|
|
2804
|
-
this.cacheDir =
|
|
2805
|
-
this.integrationsDir =
|
|
2761
|
+
this.cacheDir = path6.join(os3.homedir(), ".adk", "cache");
|
|
2762
|
+
this.integrationsDir = path6.join(this.cacheDir, "integrations");
|
|
2806
2763
|
}
|
|
2807
2764
|
async ensureCacheDir() {
|
|
2808
|
-
await
|
|
2765
|
+
await fs6.mkdir(this.integrationsDir, { recursive: true });
|
|
2809
2766
|
}
|
|
2810
2767
|
getCacheKey(integrationId, updatedAt) {
|
|
2811
2768
|
const sanitizedId = integrationId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
@@ -2815,8 +2772,8 @@ class IntegrationCache {
|
|
|
2815
2772
|
async get(integrationId, updatedAt) {
|
|
2816
2773
|
try {
|
|
2817
2774
|
const cacheKey = this.getCacheKey(integrationId, updatedAt);
|
|
2818
|
-
const cachePath =
|
|
2819
|
-
const data = await
|
|
2775
|
+
const cachePath = path6.join(this.integrationsDir, cacheKey);
|
|
2776
|
+
const data = await fs6.readFile(cachePath, "utf-8");
|
|
2820
2777
|
const cached = JSON.parse(data);
|
|
2821
2778
|
if (cached.expiresAt) {
|
|
2822
2779
|
const expiryDate = new Date(cached.expiresAt);
|
|
@@ -2833,7 +2790,7 @@ class IntegrationCache {
|
|
|
2833
2790
|
async set(integrationId, updatedAt, definition, ttlHours = 24 * 7) {
|
|
2834
2791
|
await this.ensureCacheDir();
|
|
2835
2792
|
const cacheKey = this.getCacheKey(integrationId, updatedAt);
|
|
2836
|
-
const cachePath =
|
|
2793
|
+
const cachePath = path6.join(this.integrationsDir, cacheKey);
|
|
2837
2794
|
const expiresAt = new Date;
|
|
2838
2795
|
expiresAt.setHours(expiresAt.getHours() + ttlHours);
|
|
2839
2796
|
const cacheEntry = {
|
|
@@ -2841,27 +2798,27 @@ class IntegrationCache {
|
|
|
2841
2798
|
cachedAt: new Date().toISOString(),
|
|
2842
2799
|
expiresAt: expiresAt.toISOString()
|
|
2843
2800
|
};
|
|
2844
|
-
await
|
|
2801
|
+
await fs6.writeFile(cachePath, JSON.stringify(cacheEntry, null, 2));
|
|
2845
2802
|
}
|
|
2846
2803
|
async remove(integrationId, updatedAt) {
|
|
2847
2804
|
try {
|
|
2848
2805
|
const cacheKey = this.getCacheKey(integrationId, updatedAt);
|
|
2849
|
-
const cachePath =
|
|
2850
|
-
await
|
|
2806
|
+
const cachePath = path6.join(this.integrationsDir, cacheKey);
|
|
2807
|
+
await fs6.unlink(cachePath);
|
|
2851
2808
|
} catch {}
|
|
2852
2809
|
}
|
|
2853
2810
|
async clear() {
|
|
2854
2811
|
try {
|
|
2855
|
-
const files = await
|
|
2856
|
-
await Promise.all(files.map((file) =>
|
|
2812
|
+
const files = await fs6.readdir(this.integrationsDir);
|
|
2813
|
+
await Promise.all(files.map((file) => fs6.unlink(path6.join(this.integrationsDir, file))));
|
|
2857
2814
|
} catch {}
|
|
2858
2815
|
}
|
|
2859
2816
|
async getStats() {
|
|
2860
2817
|
try {
|
|
2861
|
-
const files = await
|
|
2818
|
+
const files = await fs6.readdir(this.integrationsDir);
|
|
2862
2819
|
let totalSize = 0;
|
|
2863
2820
|
for (const file of files) {
|
|
2864
|
-
const stats = await
|
|
2821
|
+
const stats = await fs6.stat(path6.join(this.integrationsDir, file));
|
|
2865
2822
|
totalSize += stats.size;
|
|
2866
2823
|
}
|
|
2867
2824
|
return {
|
|
@@ -3033,6 +2990,9 @@ class InterfaceCatalogSource {
|
|
|
3033
2990
|
constructor(clientFactory) {
|
|
3034
2991
|
this.clientFactory = clientFactory;
|
|
3035
2992
|
}
|
|
2993
|
+
async getCacheScope() {
|
|
2994
|
+
return this.clientFactory.getCacheScope();
|
|
2995
|
+
}
|
|
3036
2996
|
async fetchByRef(ref) {
|
|
3037
2997
|
const client = await this.clientFactory.getClient();
|
|
3038
2998
|
let interfaceResponse;
|
|
@@ -3241,7 +3201,7 @@ function stringifyWithOrder(obj, keyOrder, space = 2) {
|
|
|
3241
3201
|
var agentInfoKeyOrder, agentLocalInfoKeyOrder, dependenciesKeyOrder, integrationKeyOrder;
|
|
3242
3202
|
var init_json_ordering = __esm(() => {
|
|
3243
3203
|
agentInfoKeyOrder = ["botId", "workspaceId", "apiUrl"];
|
|
3244
|
-
agentLocalInfoKeyOrder = ["botId", "workspaceId", "apiUrl", "devId"];
|
|
3204
|
+
agentLocalInfoKeyOrder = ["botId", "workspaceId", "apiUrl", "devId", "tunnelId"];
|
|
3245
3205
|
dependenciesKeyOrder = ["integrations"];
|
|
3246
3206
|
integrationKeyOrder = ["version", "enabled", "configurationType", "config"];
|
|
3247
3207
|
});
|
|
@@ -3350,7 +3310,7 @@ var init_component_files = __esm(() => {
|
|
|
3350
3310
|
// src/agent-project/component-source-resolver.ts
|
|
3351
3311
|
import { Project, SyntaxKind } from "ts-morph";
|
|
3352
3312
|
import { readFileSync } from "fs";
|
|
3353
|
-
import * as
|
|
3313
|
+
import * as path7 from "path";
|
|
3354
3314
|
function resolveComponentSources(absolutePath) {
|
|
3355
3315
|
const project = new Project({ useInMemoryFileSystem: false, skipAddingFilesFromTsConfig: true });
|
|
3356
3316
|
const sourceFile = project.createSourceFile(absolutePath, readFileSync(absolutePath, "utf-8"), { overwrite: true });
|
|
@@ -3363,12 +3323,12 @@ function resolveComponentSources(absolutePath) {
|
|
|
3363
3323
|
}
|
|
3364
3324
|
function collectBpTsxImports(sourceFile, absolutePath) {
|
|
3365
3325
|
const imports = new Map;
|
|
3366
|
-
const dir =
|
|
3326
|
+
const dir = path7.dirname(absolutePath);
|
|
3367
3327
|
for (const decl of sourceFile.getImportDeclarations()) {
|
|
3368
3328
|
const specifier = decl.getModuleSpecifierValue();
|
|
3369
3329
|
if (!specifier.endsWith(BP_TSX_SUFFIX))
|
|
3370
3330
|
continue;
|
|
3371
|
-
const resolved =
|
|
3331
|
+
const resolved = path7.resolve(dir, specifier);
|
|
3372
3332
|
const defaultImport = decl.getDefaultImport();
|
|
3373
3333
|
if (defaultImport) {
|
|
3374
3334
|
imports.set(defaultImport.getText(), resolved);
|
|
@@ -3495,25 +3455,25 @@ var init_alias_utils = __esm(() => {
|
|
|
3495
3455
|
});
|
|
3496
3456
|
|
|
3497
3457
|
// src/dependencies/snapshot-store.ts
|
|
3498
|
-
import * as
|
|
3499
|
-
import * as
|
|
3458
|
+
import * as fs7 from "fs/promises";
|
|
3459
|
+
import * as path8 from "path";
|
|
3500
3460
|
|
|
3501
3461
|
class DependencySnapshotStore {
|
|
3502
3462
|
projectPath;
|
|
3503
3463
|
dirPath;
|
|
3504
3464
|
constructor(opts) {
|
|
3505
3465
|
this.projectPath = opts.projectPath;
|
|
3506
|
-
this.dirPath =
|
|
3466
|
+
this.dirPath = path8.join(opts.projectPath, ".adk", "dependencies");
|
|
3507
3467
|
}
|
|
3508
3468
|
getSnapshotPath(env) {
|
|
3509
|
-
return
|
|
3469
|
+
return path8.join(this.dirPath, `${env}.json`);
|
|
3510
3470
|
}
|
|
3511
3471
|
getMigrationMarkerPath() {
|
|
3512
|
-
return
|
|
3472
|
+
return path8.join(this.dirPath, "migration.json");
|
|
3513
3473
|
}
|
|
3514
3474
|
async exists(env) {
|
|
3515
3475
|
try {
|
|
3516
|
-
await
|
|
3476
|
+
await fs7.access(this.getSnapshotPath(env));
|
|
3517
3477
|
return true;
|
|
3518
3478
|
} catch {
|
|
3519
3479
|
return false;
|
|
@@ -3523,9 +3483,10 @@ class DependencySnapshotStore {
|
|
|
3523
3483
|
const filePath = this.getSnapshotPath(env);
|
|
3524
3484
|
let raw;
|
|
3525
3485
|
try {
|
|
3526
|
-
raw = await
|
|
3486
|
+
raw = await fs7.readFile(filePath, "utf8");
|
|
3527
3487
|
} catch (err) {
|
|
3528
|
-
|
|
3488
|
+
const code = err.code;
|
|
3489
|
+
if (code === "ENOENT" || code === "ENOTDIR")
|
|
3529
3490
|
return null;
|
|
3530
3491
|
throw err;
|
|
3531
3492
|
}
|
|
@@ -3547,16 +3508,16 @@ class DependencySnapshotStore {
|
|
|
3547
3508
|
}
|
|
3548
3509
|
async write(snapshot) {
|
|
3549
3510
|
const validated = dependencySnapshotSchema.parse(snapshot);
|
|
3550
|
-
await
|
|
3511
|
+
await fs7.mkdir(this.dirPath, { recursive: true });
|
|
3551
3512
|
const filePath = this.getSnapshotPath(validated.env);
|
|
3552
3513
|
const tmp = `${filePath}.tmp-${process.pid}-${Date.now()}`;
|
|
3553
|
-
await
|
|
3514
|
+
await fs7.writeFile(tmp, JSON.stringify(sortKeysDeep(validated), null, 2) + `
|
|
3554
3515
|
`, "utf8");
|
|
3555
|
-
await
|
|
3516
|
+
await fs7.rename(tmp, filePath);
|
|
3556
3517
|
}
|
|
3557
3518
|
async delete(env) {
|
|
3558
3519
|
try {
|
|
3559
|
-
await
|
|
3520
|
+
await fs7.unlink(this.getSnapshotPath(env));
|
|
3560
3521
|
} catch (err) {
|
|
3561
3522
|
if (err.code !== "ENOENT")
|
|
3562
3523
|
throw err;
|
|
@@ -3564,7 +3525,7 @@ class DependencySnapshotStore {
|
|
|
3564
3525
|
}
|
|
3565
3526
|
async hasMigrationMarker() {
|
|
3566
3527
|
try {
|
|
3567
|
-
await
|
|
3528
|
+
await fs7.access(this.getMigrationMarkerPath());
|
|
3568
3529
|
return true;
|
|
3569
3530
|
} catch {
|
|
3570
3531
|
return false;
|
|
@@ -3572,12 +3533,12 @@ class DependencySnapshotStore {
|
|
|
3572
3533
|
}
|
|
3573
3534
|
async writeMigrationMarker(marker) {
|
|
3574
3535
|
const validated = dependencyMigrationMarkerSchema.parse(marker);
|
|
3575
|
-
await
|
|
3536
|
+
await fs7.mkdir(this.dirPath, { recursive: true });
|
|
3576
3537
|
const filePath = this.getMigrationMarkerPath();
|
|
3577
3538
|
const tmp = `${filePath}.tmp-${process.pid}-${Date.now()}`;
|
|
3578
|
-
await
|
|
3539
|
+
await fs7.writeFile(tmp, JSON.stringify(sortKeysDeep(validated), null, 2) + `
|
|
3579
3540
|
`, "utf8");
|
|
3580
|
-
await
|
|
3541
|
+
await fs7.rename(tmp, filePath);
|
|
3581
3542
|
}
|
|
3582
3543
|
async refreshFromCloud(opts) {
|
|
3583
3544
|
const previous = await this.readForRefresh(opts.env, opts.onWarning);
|
|
@@ -3710,7 +3671,10 @@ function dependencySnapshotFromBot(opts) {
|
|
|
3710
3671
|
const dependencies = {};
|
|
3711
3672
|
for (const [ifaceAlias, dep] of Object.entries(cloud.interfaces ?? {})) {
|
|
3712
3673
|
if (typeof dep.integrationAlias === "string") {
|
|
3713
|
-
dependencies[ifaceAlias] = {
|
|
3674
|
+
dependencies[ifaceAlias] = {
|
|
3675
|
+
integrationAlias: dep.integrationAlias,
|
|
3676
|
+
...typeof dep.integrationInterfaceAlias === "string" && dep.integrationInterfaceAlias ? { integrationInterfaceAlias: dep.integrationInterfaceAlias } : {}
|
|
3677
|
+
};
|
|
3714
3678
|
}
|
|
3715
3679
|
}
|
|
3716
3680
|
const alias = chooseCloudAlias({
|
|
@@ -3767,6 +3731,152 @@ var init_snapshot_store = __esm(() => {
|
|
|
3767
3731
|
init_types();
|
|
3768
3732
|
});
|
|
3769
3733
|
|
|
3734
|
+
// src/utils/adk-ignore.ts
|
|
3735
|
+
import { readFileSync as readFileSync2 } from "fs";
|
|
3736
|
+
import { readFile as readFile2 } from "fs/promises";
|
|
3737
|
+
import { join as join2 } from "path";
|
|
3738
|
+
async function loadAdkIgnoreMatcher(projectPath) {
|
|
3739
|
+
try {
|
|
3740
|
+
return parseAdkIgnore(await readFile2(join2(projectPath, ADK_IGNORE_FILE), "utf-8"));
|
|
3741
|
+
} catch {
|
|
3742
|
+
return EMPTY_MATCHER;
|
|
3743
|
+
}
|
|
3744
|
+
}
|
|
3745
|
+
function loadAdkIgnoreMatcherSync(projectPath) {
|
|
3746
|
+
try {
|
|
3747
|
+
return parseAdkIgnore(readFileSync2(join2(projectPath, ADK_IGNORE_FILE), "utf-8"));
|
|
3748
|
+
} catch {
|
|
3749
|
+
return EMPTY_MATCHER;
|
|
3750
|
+
}
|
|
3751
|
+
}
|
|
3752
|
+
function parseAdkIgnore(contents) {
|
|
3753
|
+
const rules = contents.split(/\r?\n/).map(parseIgnoreRule).filter((rule) => rule !== null);
|
|
3754
|
+
if (rules.length === 0) {
|
|
3755
|
+
return EMPTY_MATCHER;
|
|
3756
|
+
}
|
|
3757
|
+
return {
|
|
3758
|
+
hasRules: true,
|
|
3759
|
+
ignores: (relativePath) => {
|
|
3760
|
+
const normalized = normalizePath(relativePath);
|
|
3761
|
+
if (!normalized)
|
|
3762
|
+
return false;
|
|
3763
|
+
let ignored = false;
|
|
3764
|
+
for (const rule of rules) {
|
|
3765
|
+
if (matchesRule(rule, normalized)) {
|
|
3766
|
+
ignored = !rule.negated;
|
|
3767
|
+
}
|
|
3768
|
+
}
|
|
3769
|
+
return ignored;
|
|
3770
|
+
},
|
|
3771
|
+
canReincludeDescendant: (relativeDirectoryPath) => {
|
|
3772
|
+
const normalized = normalizePath(relativeDirectoryPath).replace(/\/+$/, "");
|
|
3773
|
+
if (!normalized)
|
|
3774
|
+
return false;
|
|
3775
|
+
return rules.some((rule) => {
|
|
3776
|
+
if (!rule.negated) {
|
|
3777
|
+
return false;
|
|
3778
|
+
}
|
|
3779
|
+
if (!rule.hasSlash || rule.literalPrefix === "") {
|
|
3780
|
+
return true;
|
|
3781
|
+
}
|
|
3782
|
+
return normalized.startsWith(rule.literalPrefix) || rule.literalPrefix.startsWith(`${normalized}/`);
|
|
3783
|
+
});
|
|
3784
|
+
}
|
|
3785
|
+
};
|
|
3786
|
+
}
|
|
3787
|
+
function parseIgnoreRule(rawLine) {
|
|
3788
|
+
let line = rawLine.trim();
|
|
3789
|
+
if (!line || line.startsWith("#")) {
|
|
3790
|
+
return null;
|
|
3791
|
+
}
|
|
3792
|
+
if (line.startsWith("\\#") || line.startsWith("\\!")) {
|
|
3793
|
+
line = line.slice(1);
|
|
3794
|
+
}
|
|
3795
|
+
let negated = false;
|
|
3796
|
+
if (line.startsWith("!")) {
|
|
3797
|
+
negated = true;
|
|
3798
|
+
line = line.slice(1).trim();
|
|
3799
|
+
if (!line)
|
|
3800
|
+
return null;
|
|
3801
|
+
}
|
|
3802
|
+
const { pattern: normalized, anchored } = normalizePattern(line);
|
|
3803
|
+
let pattern = normalized;
|
|
3804
|
+
if (!pattern)
|
|
3805
|
+
return null;
|
|
3806
|
+
while (pattern.endsWith("/")) {
|
|
3807
|
+
pattern = pattern.slice(0, -1);
|
|
3808
|
+
}
|
|
3809
|
+
if (!pattern)
|
|
3810
|
+
return null;
|
|
3811
|
+
const hasSlash = anchored || pattern.includes("/");
|
|
3812
|
+
const regexSource = globToRegexSource(pattern);
|
|
3813
|
+
return {
|
|
3814
|
+
negated,
|
|
3815
|
+
hasSlash,
|
|
3816
|
+
literalPrefix: getLiteralPrefix(pattern),
|
|
3817
|
+
fullPathRegex: new RegExp(`^${regexSource}(?:/.*)?$`),
|
|
3818
|
+
segmentRegex: new RegExp(`^${regexSource}$`)
|
|
3819
|
+
};
|
|
3820
|
+
}
|
|
3821
|
+
function matchesRule(rule, relativePath) {
|
|
3822
|
+
if (rule.hasSlash) {
|
|
3823
|
+
return rule.fullPathRegex.test(relativePath);
|
|
3824
|
+
}
|
|
3825
|
+
return relativePath.split("/").some((segment) => rule.segmentRegex.test(segment));
|
|
3826
|
+
}
|
|
3827
|
+
function normalizePath(value) {
|
|
3828
|
+
return value.replace(/\\/g, "/").replace(/^\.\/+/, "").replace(/^\/+/, "");
|
|
3829
|
+
}
|
|
3830
|
+
function normalizePattern(value) {
|
|
3831
|
+
const normalized = value.replace(/\\/g, "/").replace(/^\.\/+/, "");
|
|
3832
|
+
return {
|
|
3833
|
+
anchored: normalized.startsWith("/"),
|
|
3834
|
+
pattern: normalized.replace(/^\/+/, "")
|
|
3835
|
+
};
|
|
3836
|
+
}
|
|
3837
|
+
function globToRegexSource(pattern) {
|
|
3838
|
+
let out = "";
|
|
3839
|
+
for (let i = 0;i < pattern.length; i++) {
|
|
3840
|
+
const char = pattern[i];
|
|
3841
|
+
if (char === "*") {
|
|
3842
|
+
if (pattern[i + 1] === "*") {
|
|
3843
|
+
while (pattern[i + 1] === "*")
|
|
3844
|
+
i++;
|
|
3845
|
+
if (pattern[i + 1] === "/") {
|
|
3846
|
+
out += "(?:.*/)?";
|
|
3847
|
+
i++;
|
|
3848
|
+
} else {
|
|
3849
|
+
out += ".*";
|
|
3850
|
+
}
|
|
3851
|
+
} else {
|
|
3852
|
+
out += "[^/]*";
|
|
3853
|
+
}
|
|
3854
|
+
continue;
|
|
3855
|
+
}
|
|
3856
|
+
if (char === "?") {
|
|
3857
|
+
out += "[^/]";
|
|
3858
|
+
continue;
|
|
3859
|
+
}
|
|
3860
|
+
out += escapeRegex(char);
|
|
3861
|
+
}
|
|
3862
|
+
return out;
|
|
3863
|
+
}
|
|
3864
|
+
function getLiteralPrefix(pattern) {
|
|
3865
|
+
const globIndex = pattern.search(/[*?]/);
|
|
3866
|
+
return globIndex === -1 ? pattern : pattern.slice(0, globIndex);
|
|
3867
|
+
}
|
|
3868
|
+
function escapeRegex(value) {
|
|
3869
|
+
return value.replace(/[|\\{}()[\]^$+?.]/g, "\\$&");
|
|
3870
|
+
}
|
|
3871
|
+
var ADK_IGNORE_FILE = ".adkignore", EMPTY_MATCHER;
|
|
3872
|
+
var init_adk_ignore = __esm(() => {
|
|
3873
|
+
EMPTY_MATCHER = {
|
|
3874
|
+
hasRules: false,
|
|
3875
|
+
ignores: () => false,
|
|
3876
|
+
canReincludeDescendant: () => false
|
|
3877
|
+
};
|
|
3878
|
+
});
|
|
3879
|
+
|
|
3770
3880
|
// src/agent-project/dependency-state-to-dependencies.ts
|
|
3771
3881
|
function dependencyStateToDependencies(state) {
|
|
3772
3882
|
const integrations = {};
|
|
@@ -3795,8 +3905,8 @@ import { BuiltInActions, BuiltInWorkflows, Errors as Errors2, Primitives as Prim
|
|
|
3795
3905
|
import { Autonomous } from "@botpress/runtime";
|
|
3796
3906
|
import createDebug from "debug";
|
|
3797
3907
|
import { createRequire as createRequire2 } from "module";
|
|
3798
|
-
import
|
|
3799
|
-
import
|
|
3908
|
+
import fs8 from "fs/promises";
|
|
3909
|
+
import path9 from "path";
|
|
3800
3910
|
function getToolDefinition(value) {
|
|
3801
3911
|
if (typeof value !== "object" || value === null) {
|
|
3802
3912
|
return;
|
|
@@ -3828,6 +3938,7 @@ var init_agent_project = __esm(() => {
|
|
|
3828
3938
|
init_table_validation();
|
|
3829
3939
|
init_constants();
|
|
3830
3940
|
init_snapshot_store();
|
|
3941
|
+
init_adk_ignore();
|
|
3831
3942
|
debug = createDebug("adk:agent-project");
|
|
3832
3943
|
AgentProject = class AgentProject {
|
|
3833
3944
|
static _projectCache = new Map;
|
|
@@ -3855,7 +3966,7 @@ var init_agent_project = __esm(() => {
|
|
|
3855
3966
|
_tools = [];
|
|
3856
3967
|
constructor(projectPath, options = {}) {
|
|
3857
3968
|
this._options = options;
|
|
3858
|
-
this._path =
|
|
3969
|
+
this._path = path9.resolve(projectPath);
|
|
3859
3970
|
this._integrationManager = new IntegrationManager({
|
|
3860
3971
|
noCache: options.noCache
|
|
3861
3972
|
});
|
|
@@ -3867,7 +3978,7 @@ var init_agent_project = __esm(() => {
|
|
|
3867
3978
|
});
|
|
3868
3979
|
}
|
|
3869
3980
|
static async load(projectPath, options = {}) {
|
|
3870
|
-
const resolvedPath =
|
|
3981
|
+
const resolvedPath = path9.resolve(projectPath);
|
|
3871
3982
|
const cacheKey = AgentProject._getCacheKey(resolvedPath, options);
|
|
3872
3983
|
if (!options.noCache) {
|
|
3873
3984
|
const cached = AgentProject._projectCache.get(cacheKey);
|
|
@@ -3891,7 +4002,7 @@ var init_agent_project = __esm(() => {
|
|
|
3891
4002
|
AgentProject._projectCache.clear();
|
|
3892
4003
|
}
|
|
3893
4004
|
static clearCacheForPath(projectPath) {
|
|
3894
|
-
const resolvedPath =
|
|
4005
|
+
const resolvedPath = path9.resolve(projectPath);
|
|
3895
4006
|
const prefix = `${resolvedPath}\x00`;
|
|
3896
4007
|
for (const key of AgentProject._projectCache.keys()) {
|
|
3897
4008
|
if (key.startsWith(prefix)) {
|
|
@@ -4012,17 +4123,17 @@ var init_agent_project = __esm(() => {
|
|
|
4012
4123
|
const warnings = [];
|
|
4013
4124
|
const info = [];
|
|
4014
4125
|
try {
|
|
4015
|
-
await
|
|
4126
|
+
await fs8.access(this._path);
|
|
4016
4127
|
const requiredFiles = ["agent.config.ts"];
|
|
4017
4128
|
for (const file of requiredFiles) {
|
|
4018
4129
|
try {
|
|
4019
|
-
await
|
|
4130
|
+
await fs8.access(path9.join(this._path, file));
|
|
4020
4131
|
} catch {
|
|
4021
4132
|
errors.push(ValidationErrors.requiredFileMissing(file));
|
|
4022
4133
|
}
|
|
4023
4134
|
}
|
|
4024
4135
|
try {
|
|
4025
|
-
await
|
|
4136
|
+
await fs8.access(path9.join(this._path, "agent.json"));
|
|
4026
4137
|
} catch {
|
|
4027
4138
|
info.push({
|
|
4028
4139
|
$type: "ValidationError",
|
|
@@ -4036,7 +4147,7 @@ var init_agent_project = __esm(() => {
|
|
|
4036
4147
|
const expectedDirs = ["actions", "workflows", "conversations", "assets"];
|
|
4037
4148
|
for (const dir of expectedDirs) {
|
|
4038
4149
|
try {
|
|
4039
|
-
const stats = await
|
|
4150
|
+
const stats = await fs8.stat(path9.join(this._path, dir));
|
|
4040
4151
|
if (!stats.isDirectory()) {
|
|
4041
4152
|
warnings.push(ValidationErrors.invalidStructure(dir, "directory"));
|
|
4042
4153
|
}
|
|
@@ -4048,6 +4159,12 @@ var init_agent_project = __esm(() => {
|
|
|
4048
4159
|
for (const violation of findTableColumnViolations(this._tables)) {
|
|
4049
4160
|
errors.push(ValidationErrors.tableTooManyColumns(violation.name, violation.path, violation.columnCount, MAX_TABLE_COLUMNS));
|
|
4050
4161
|
}
|
|
4162
|
+
for (const action of this._actions) {
|
|
4163
|
+
const description = action.definition.description;
|
|
4164
|
+
if (description && description.length > MAX_ACTION_DESCRIPTION_LENGTH) {
|
|
4165
|
+
warnings.push(ValidationErrors.warning(`Action '${action.definition.name}' description is ${description.length} characters; ADK truncates it to ${MAX_ACTION_DESCRIPTION_LENGTH} at deploy (platform limit).`, action.path, `Shorten the description to ${MAX_ACTION_DESCRIPTION_LENGTH} characters or fewer to control what is kept.`));
|
|
4166
|
+
}
|
|
4167
|
+
}
|
|
4051
4168
|
const errorsBySeverity = {
|
|
4052
4169
|
errors: errors.filter((e) => e.severity === "error" /* ERROR */),
|
|
4053
4170
|
warnings: [...warnings, ...errors.filter((e) => e.severity === "warning" /* WARNING */)],
|
|
@@ -4124,9 +4241,9 @@ var init_agent_project = __esm(() => {
|
|
|
4124
4241
|
workspaceId: info.workspaceId,
|
|
4125
4242
|
apiUrl: info.apiUrl
|
|
4126
4243
|
};
|
|
4127
|
-
const agentPath =
|
|
4244
|
+
const agentPath = path9.join(this._path, "agent.json");
|
|
4128
4245
|
const agentContent = stringifyWithOrder(agentJsonData, agentInfoKeyOrder);
|
|
4129
|
-
await
|
|
4246
|
+
await fs8.writeFile(agentPath, agentContent);
|
|
4130
4247
|
this._agentInfo = agentJsonData;
|
|
4131
4248
|
}
|
|
4132
4249
|
async updateAgentInfo(updates) {
|
|
@@ -4148,21 +4265,21 @@ var init_agent_project = __esm(() => {
|
|
|
4148
4265
|
workspaceId: updatedInfo.workspaceId,
|
|
4149
4266
|
apiUrl: updatedInfo.apiUrl
|
|
4150
4267
|
};
|
|
4151
|
-
const agentPath =
|
|
4268
|
+
const agentPath = path9.join(this._path, "agent.json");
|
|
4152
4269
|
const agentContent = stringifyWithOrder(agentJsonData, agentInfoKeyOrder);
|
|
4153
|
-
await
|
|
4270
|
+
await fs8.writeFile(agentPath, agentContent);
|
|
4154
4271
|
this._agentInfo = updatedInfo;
|
|
4155
4272
|
}
|
|
4156
4273
|
async createAgentLocalInfo(info) {
|
|
4157
|
-
const localPath =
|
|
4274
|
+
const localPath = path9.join(this._path, "agent.local.json");
|
|
4158
4275
|
let existing = {};
|
|
4159
4276
|
try {
|
|
4160
|
-
const content2 = await
|
|
4277
|
+
const content2 = await fs8.readFile(localPath, "utf-8");
|
|
4161
4278
|
existing = JSON.parse(content2);
|
|
4162
4279
|
} catch {}
|
|
4163
4280
|
const merged = { ...existing, ...info };
|
|
4164
4281
|
const content = stringifyWithOrder(merged, agentLocalInfoKeyOrder);
|
|
4165
|
-
await
|
|
4282
|
+
await fs8.writeFile(localPath, content);
|
|
4166
4283
|
if (this._agentInfo) {
|
|
4167
4284
|
if (merged.botId)
|
|
4168
4285
|
this._agentInfo.botId = merged.botId;
|
|
@@ -4172,20 +4289,23 @@ var init_agent_project = __esm(() => {
|
|
|
4172
4289
|
this._agentInfo.apiUrl = merged.apiUrl;
|
|
4173
4290
|
if (merged.devId)
|
|
4174
4291
|
this._agentInfo.devId = merged.devId;
|
|
4292
|
+
if (merged.tunnelId)
|
|
4293
|
+
this._agentInfo.tunnelId = merged.tunnelId;
|
|
4175
4294
|
} else if (merged.botId && merged.workspaceId) {
|
|
4176
4295
|
this._agentInfo = {
|
|
4177
4296
|
botId: merged.botId,
|
|
4178
4297
|
workspaceId: merged.workspaceId,
|
|
4179
4298
|
apiUrl: merged.apiUrl,
|
|
4180
|
-
devId: merged.devId
|
|
4299
|
+
devId: merged.devId,
|
|
4300
|
+
tunnelId: merged.tunnelId
|
|
4181
4301
|
};
|
|
4182
4302
|
}
|
|
4183
4303
|
}
|
|
4184
4304
|
async updateAgentLocalInfo(updates) {
|
|
4185
|
-
const localPath =
|
|
4305
|
+
const localPath = path9.join(this._path, "agent.local.json");
|
|
4186
4306
|
let existing = {};
|
|
4187
4307
|
try {
|
|
4188
|
-
const content = await
|
|
4308
|
+
const content = await fs8.readFile(localPath, "utf-8");
|
|
4189
4309
|
existing = JSON.parse(content);
|
|
4190
4310
|
} catch {}
|
|
4191
4311
|
const updated = { ...existing, ...updates };
|
|
@@ -4196,21 +4316,21 @@ var init_agent_project = __esm(() => {
|
|
|
4196
4316
|
}
|
|
4197
4317
|
if (Object.keys(updated).length === 0) {
|
|
4198
4318
|
try {
|
|
4199
|
-
await
|
|
4319
|
+
await fs8.unlink(localPath);
|
|
4200
4320
|
} catch {}
|
|
4201
4321
|
} else {
|
|
4202
4322
|
const content = stringifyWithOrder(updated, agentLocalInfoKeyOrder);
|
|
4203
|
-
await
|
|
4323
|
+
await fs8.writeFile(localPath, content);
|
|
4204
4324
|
}
|
|
4205
4325
|
if (this._agentInfo) {
|
|
4206
|
-
const agentJsonPath =
|
|
4326
|
+
const agentJsonPath = path9.join(this._path, "agent.json");
|
|
4207
4327
|
let base = {
|
|
4208
4328
|
botId: this._agentInfo.botId,
|
|
4209
4329
|
workspaceId: this._agentInfo.workspaceId,
|
|
4210
4330
|
apiUrl: this._agentInfo.apiUrl
|
|
4211
4331
|
};
|
|
4212
4332
|
try {
|
|
4213
|
-
const agentJsonContent = await
|
|
4333
|
+
const agentJsonContent = await fs8.readFile(agentJsonPath, "utf-8");
|
|
4214
4334
|
const parsed = agentInfoSchema.parse(JSON.parse(agentJsonContent));
|
|
4215
4335
|
base = {
|
|
4216
4336
|
botId: parsed.botId,
|
|
@@ -4223,7 +4343,8 @@ var init_agent_project = __esm(() => {
|
|
|
4223
4343
|
botId: local.botId ?? base.botId,
|
|
4224
4344
|
workspaceId: local.workspaceId ?? base.workspaceId,
|
|
4225
4345
|
apiUrl: local.apiUrl ?? base.apiUrl,
|
|
4226
|
-
devId: local.devId
|
|
4346
|
+
devId: local.devId,
|
|
4347
|
+
tunnelId: local.tunnelId
|
|
4227
4348
|
};
|
|
4228
4349
|
}
|
|
4229
4350
|
}
|
|
@@ -4242,10 +4363,10 @@ var init_agent_project = __esm(() => {
|
|
|
4242
4363
|
this._integrations = [];
|
|
4243
4364
|
this._interfaces = [];
|
|
4244
4365
|
try {
|
|
4245
|
-
const configPath =
|
|
4366
|
+
const configPath = path9.join(this._path, "agent.config.ts");
|
|
4246
4367
|
debug("loading agent.config.ts from %s", configPath);
|
|
4247
|
-
const projectRequire = createRequire2(
|
|
4248
|
-
debug("created projectRequire from %s",
|
|
4368
|
+
const projectRequire = createRequire2(path9.join(this._path, "package.json"));
|
|
4369
|
+
debug("created projectRequire from %s", path9.join(this._path, "package.json"));
|
|
4249
4370
|
try {
|
|
4250
4371
|
const resolvedPath = projectRequire.resolve(configPath);
|
|
4251
4372
|
debug("resolved config path: %s", resolvedPath);
|
|
@@ -4292,7 +4413,6 @@ var init_agent_project = __esm(() => {
|
|
|
4292
4413
|
const dependencyEnv = this._options.adkCommand === "adk-deploy" ? "prod" : "dev";
|
|
4293
4414
|
const snapshotStore = new DependencySnapshotStore({ projectPath: this._path });
|
|
4294
4415
|
let snapshotBasedDependencies;
|
|
4295
|
-
let dependencySnapshotReadFailed = false;
|
|
4296
4416
|
try {
|
|
4297
4417
|
const snapshot = await snapshotStore.read(dependencyEnv);
|
|
4298
4418
|
const state = snapshot ?? { version: 1, env: dependencyEnv, integrations: {}, plugins: {} };
|
|
@@ -4308,7 +4428,6 @@ var init_agent_project = __esm(() => {
|
|
|
4308
4428
|
message: `Could not read .adk/dependencies/${dependencyEnv}.json: ${err.message}. Refresh dependencies from Cloud; agent.config.ts dependencies is not used when a snapshot exists but is invalid.`,
|
|
4309
4429
|
file: `.adk/dependencies/${dependencyEnv}.json`
|
|
4310
4430
|
});
|
|
4311
|
-
dependencySnapshotReadFailed = true;
|
|
4312
4431
|
}
|
|
4313
4432
|
if (snapshotBasedDependencies) {
|
|
4314
4433
|
this._dependencies = snapshotBasedDependencies;
|
|
@@ -4422,8 +4541,8 @@ ${err.stack?.split(`
|
|
|
4422
4541
|
}
|
|
4423
4542
|
}
|
|
4424
4543
|
isBarrelReexport(existing, newPath, newExport, newDefinition) {
|
|
4425
|
-
const isNewBarrel = /^index\.[tj]s$/i.test(
|
|
4426
|
-
const isExistingBarrel = /^index\.[tj]s$/i.test(
|
|
4544
|
+
const isNewBarrel = /^index\.[tj]s$/i.test(path9.basename(newPath));
|
|
4545
|
+
const isExistingBarrel = /^index\.[tj]s$/i.test(path9.basename(existing.path));
|
|
4427
4546
|
if (!isNewBarrel && !isExistingBarrel) {
|
|
4428
4547
|
return false;
|
|
4429
4548
|
}
|
|
@@ -4435,16 +4554,16 @@ ${err.stack?.split(`
|
|
|
4435
4554
|
return true;
|
|
4436
4555
|
}
|
|
4437
4556
|
isToolBarrelReexport(existingPath, newPath) {
|
|
4438
|
-
const isNewBarrel = /^index\.[tj]s$/i.test(
|
|
4439
|
-
const isExistingBarrel = /^index\.[tj]s$/i.test(
|
|
4557
|
+
const isNewBarrel = /^index\.[tj]s$/i.test(path9.basename(newPath));
|
|
4558
|
+
const isExistingBarrel = /^index\.[tj]s$/i.test(path9.basename(existingPath));
|
|
4440
4559
|
if (!isNewBarrel && !isExistingBarrel) {
|
|
4441
4560
|
return false;
|
|
4442
4561
|
}
|
|
4443
4562
|
return true;
|
|
4444
4563
|
}
|
|
4445
4564
|
shouldPreferToolDefinition(existingPath, newPath) {
|
|
4446
|
-
const isNewBarrel = /^index\.[tj]s$/i.test(
|
|
4447
|
-
const isExistingBarrel = /^index\.[tj]s$/i.test(
|
|
4565
|
+
const isNewBarrel = /^index\.[tj]s$/i.test(path9.basename(newPath));
|
|
4566
|
+
const isExistingBarrel = /^index\.[tj]s$/i.test(path9.basename(existingPath));
|
|
4448
4567
|
return isExistingBarrel && !isNewBarrel;
|
|
4449
4568
|
}
|
|
4450
4569
|
getChannelsList(channelSpec) {
|
|
@@ -4457,11 +4576,83 @@ ${err.stack?.split(`
|
|
|
4457
4576
|
}
|
|
4458
4577
|
}
|
|
4459
4578
|
async loadAgentPrimitives() {
|
|
4579
|
+
const before = this.snapshotPrimitiveState();
|
|
4580
|
+
await this.scanPrimitivesInto(path9.join(this._path, "src"), this._path);
|
|
4581
|
+
if (!this.scanRaisedLoadFailure(before.warnings)) {
|
|
4582
|
+
return;
|
|
4583
|
+
}
|
|
4584
|
+
const freshRoot = await this.makeFreshScanCopy().catch(() => null);
|
|
4585
|
+
if (!freshRoot) {
|
|
4586
|
+
return;
|
|
4587
|
+
}
|
|
4588
|
+
try {
|
|
4589
|
+
this.restorePrimitiveState(before);
|
|
4590
|
+
await this.scanPrimitivesInto(path9.join(freshRoot, "src"), freshRoot);
|
|
4591
|
+
for (const component of this._customComponents.slice(before.customComponents)) {
|
|
4592
|
+
if (component.source && component.source.startsWith(freshRoot)) {
|
|
4593
|
+
component.source = this._path + component.source.slice(freshRoot.length);
|
|
4594
|
+
}
|
|
4595
|
+
}
|
|
4596
|
+
} finally {
|
|
4597
|
+
await fs8.rm(freshRoot, { recursive: true, force: true }).catch(() => {});
|
|
4598
|
+
}
|
|
4599
|
+
}
|
|
4600
|
+
snapshotPrimitiveState() {
|
|
4601
|
+
return {
|
|
4602
|
+
conversations: this._conversations.length,
|
|
4603
|
+
knowledge: this._knowledge.length,
|
|
4604
|
+
triggers: this._triggers.length,
|
|
4605
|
+
workflows: this._workflows.length,
|
|
4606
|
+
actions: this._actions.length,
|
|
4607
|
+
tables: this._tables.length,
|
|
4608
|
+
customComponents: this._customComponents.length,
|
|
4609
|
+
tools: this._tools.length,
|
|
4610
|
+
warnings: this._warnings.length,
|
|
4611
|
+
errors: this._errors.length
|
|
4612
|
+
};
|
|
4613
|
+
}
|
|
4614
|
+
restorePrimitiveState(state) {
|
|
4615
|
+
this._conversations.length = state.conversations;
|
|
4616
|
+
this._knowledge.length = state.knowledge;
|
|
4617
|
+
this._triggers.length = state.triggers;
|
|
4618
|
+
this._workflows.length = state.workflows;
|
|
4619
|
+
this._actions.length = state.actions;
|
|
4620
|
+
this._tables.length = state.tables;
|
|
4621
|
+
this._customComponents.length = state.customComponents;
|
|
4622
|
+
this._tools.length = state.tools;
|
|
4623
|
+
this._warnings.length = state.warnings;
|
|
4624
|
+
this._errors.length = state.errors;
|
|
4625
|
+
}
|
|
4626
|
+
scanRaisedLoadFailure(warningsBefore) {
|
|
4627
|
+
return this._warnings.slice(warningsBefore).some((w) => w.code === "INVALID_PRIMITIVE_DEFINITION" /* INVALID_PRIMITIVE_DEFINITION */ || w.code === "IMPORT_ERROR" /* IMPORT_ERROR */);
|
|
4628
|
+
}
|
|
4629
|
+
async makeFreshScanCopy() {
|
|
4630
|
+
const realSrc = path9.join(this._path, "src");
|
|
4631
|
+
if (!await fs8.stat(realSrc).catch(() => false)) {
|
|
4632
|
+
return null;
|
|
4633
|
+
}
|
|
4634
|
+
const scanParent = path9.join(this._path, ".adk");
|
|
4635
|
+
await fs8.mkdir(scanParent, { recursive: true });
|
|
4636
|
+
const freshRoot = await fs8.mkdtemp(path9.join(scanParent, "scan-"));
|
|
4637
|
+
await fs8.cp(realSrc, path9.join(freshRoot, "src"), { recursive: true });
|
|
4638
|
+
const excluded = new Set(["src", "node_modules", ".adk", ".botpress", ".git", "dist"]);
|
|
4639
|
+
const entries = await fs8.readdir(this._path, { withFileTypes: true }).catch(() => []);
|
|
4640
|
+
for (const entry of entries) {
|
|
4641
|
+
if (excluded.has(entry.name)) {
|
|
4642
|
+
continue;
|
|
4643
|
+
}
|
|
4644
|
+
const target = path9.join(this._path, entry.name);
|
|
4645
|
+
const isDir = entry.isSymbolicLink() ? (await fs8.stat(target).catch(() => null))?.isDirectory() ?? false : entry.isDirectory();
|
|
4646
|
+
await fs8.symlink(target, path9.join(freshRoot, entry.name), isDir ? "junction" : "file").catch(() => {});
|
|
4647
|
+
}
|
|
4648
|
+
return freshRoot;
|
|
4649
|
+
}
|
|
4650
|
+
async scanPrimitivesInto(scanSrcDir, relBase) {
|
|
4460
4651
|
if (this._options.adkCommand) {
|
|
4461
4652
|
setAdkCommand(this._options.adkCommand);
|
|
4462
4653
|
}
|
|
4463
|
-
const src =
|
|
4464
|
-
if (!await
|
|
4654
|
+
const src = scanSrcDir;
|
|
4655
|
+
if (!await fs8.stat(src).catch(() => false)) {
|
|
4465
4656
|
this._errors.push({
|
|
4466
4657
|
$type: "ValidationError",
|
|
4467
4658
|
code: "INVALID_STRUCTURE" /* INVALID_STRUCTURE */,
|
|
@@ -4470,14 +4661,33 @@ ${err.stack?.split(`
|
|
|
4470
4661
|
});
|
|
4471
4662
|
return;
|
|
4472
4663
|
}
|
|
4473
|
-
const
|
|
4474
|
-
|
|
4475
|
-
|
|
4476
|
-
|
|
4477
|
-
|
|
4478
|
-
|
|
4479
|
-
|
|
4480
|
-
|
|
4664
|
+
const adkIgnore = await loadAdkIgnoreMatcher(this._path);
|
|
4665
|
+
const allFiles = [];
|
|
4666
|
+
const collectFiles = async (dir) => {
|
|
4667
|
+
const entries = await fs8.readdir(dir, { withFileTypes: true });
|
|
4668
|
+
for (const entry of entries) {
|
|
4669
|
+
const absolutePath = path9.join(dir, entry.name);
|
|
4670
|
+
const relPath = path9.relative(relBase, absolutePath);
|
|
4671
|
+
if (entry.isDirectory()) {
|
|
4672
|
+
if (adkIgnore.ignores(relPath) && !adkIgnore.canReincludeDescendant(relPath)) {
|
|
4673
|
+
continue;
|
|
4674
|
+
}
|
|
4675
|
+
await collectFiles(absolutePath);
|
|
4676
|
+
continue;
|
|
4677
|
+
}
|
|
4678
|
+
if (entry.isFile()) {
|
|
4679
|
+
allFiles.push({ absolutePath, filename: entry.name, isSymbolicLink: () => entry.isSymbolicLink() });
|
|
4680
|
+
}
|
|
4681
|
+
}
|
|
4682
|
+
};
|
|
4683
|
+
await collectFiles(src);
|
|
4684
|
+
for (const file of allFiles) {
|
|
4685
|
+
const filename = file.filename;
|
|
4686
|
+
const absolutePath = file.absolutePath;
|
|
4687
|
+
const relPath = path9.relative(relBase, absolutePath);
|
|
4688
|
+
if (adkIgnore.ignores(relPath)) {
|
|
4689
|
+
continue;
|
|
4690
|
+
}
|
|
4481
4691
|
if (filename.toLowerCase().endsWith(".d.ts")) {
|
|
4482
4692
|
continue;
|
|
4483
4693
|
}
|
|
@@ -4764,7 +4974,7 @@ ${err.stack?.split(`
|
|
|
4764
4974
|
});
|
|
4765
4975
|
|
|
4766
4976
|
// src/generators/utils.ts
|
|
4767
|
-
import
|
|
4977
|
+
import path12 from "path";
|
|
4768
4978
|
async function getFormat() {
|
|
4769
4979
|
if (!_formatLoaded) {
|
|
4770
4980
|
_formatLoaded = true;
|
|
@@ -4812,9 +5022,9 @@ var _format = null, _formatLoaded = false, formatCode = async (code, filepath) =
|
|
|
4812
5022
|
`));
|
|
4813
5023
|
return code;
|
|
4814
5024
|
}
|
|
4815
|
-
}, ADK_VERSION = "
|
|
4816
|
-
const fromDir =
|
|
4817
|
-
const relative2 =
|
|
5025
|
+
}, ADK_VERSION = "3.0.0-beta.1", relative = (from, to) => {
|
|
5026
|
+
const fromDir = path12.dirname(from);
|
|
5027
|
+
const relative2 = path12.relative(fromDir, to);
|
|
4818
5028
|
return relative2.startsWith(".") ? relative2 : `./${relative2}`;
|
|
4819
5029
|
};
|
|
4820
5030
|
var init_utils = () => {};
|
|
@@ -4917,7 +5127,10 @@ class PluginResolver {
|
|
|
4917
5127
|
const dependencies = {};
|
|
4918
5128
|
for (const [ifaceAlias, dep] of Object.entries(cloud.interfaces ?? {})) {
|
|
4919
5129
|
if (dep.integrationAlias) {
|
|
4920
|
-
dependencies[ifaceAlias] = {
|
|
5130
|
+
dependencies[ifaceAlias] = {
|
|
5131
|
+
integrationAlias: dep.integrationAlias,
|
|
5132
|
+
...dep.integrationInterfaceAlias && { integrationInterfaceAlias: dep.integrationInterfaceAlias }
|
|
5133
|
+
};
|
|
4921
5134
|
}
|
|
4922
5135
|
}
|
|
4923
5136
|
return {
|
|
@@ -5032,6 +5245,9 @@ class PluginCatalogSource {
|
|
|
5032
5245
|
constructor(clientFactory) {
|
|
5033
5246
|
this.clientFactory = clientFactory;
|
|
5034
5247
|
}
|
|
5248
|
+
async getCacheScope() {
|
|
5249
|
+
return this.clientFactory.getCacheScope();
|
|
5250
|
+
}
|
|
5035
5251
|
async fetchByRef(ref) {
|
|
5036
5252
|
const client = await this.clientFactory.getClient();
|
|
5037
5253
|
const plugin = await this._findPublicPlugin(client, ref);
|
|
@@ -5052,6 +5268,11 @@ class PluginCatalogSource {
|
|
|
5052
5268
|
}
|
|
5053
5269
|
return getSortedCatalogSearchResults(results, limit);
|
|
5054
5270
|
}
|
|
5271
|
+
async fetchCode(plugin) {
|
|
5272
|
+
const client = await this.clientFactory.getClient();
|
|
5273
|
+
const { code } = await client.getPublicPluginCode({ id: plugin.id, platform: "node" });
|
|
5274
|
+
return code;
|
|
5275
|
+
}
|
|
5055
5276
|
async listVersions(name) {
|
|
5056
5277
|
const client = await this.clientFactory.getClient();
|
|
5057
5278
|
const versions = new Set;
|
|
@@ -5121,6 +5342,9 @@ class PluginManager {
|
|
|
5121
5342
|
async fetchPlugin(ref) {
|
|
5122
5343
|
return this.service.getDefinition(ref);
|
|
5123
5344
|
}
|
|
5345
|
+
async fetchPluginCode(plugin) {
|
|
5346
|
+
return this.source.fetchCode(plugin);
|
|
5347
|
+
}
|
|
5124
5348
|
async searchPlugins(query, limit = 20) {
|
|
5125
5349
|
return this.source.search(query, limit);
|
|
5126
5350
|
}
|
|
@@ -5275,12 +5499,20 @@ class DependencyManager {
|
|
|
5275
5499
|
const out = [];
|
|
5276
5500
|
if (!type || type === "integration") {
|
|
5277
5501
|
for (const [alias, e] of Object.entries(data.integrations)) {
|
|
5278
|
-
out.push({ type: "integration", alias, name: e.name, version: e.version, enabled: e.enabled });
|
|
5502
|
+
out.push({ type: "integration", alias, name: e.name, version: e.version, enabled: e.enabled, config: e.config });
|
|
5279
5503
|
}
|
|
5280
5504
|
}
|
|
5281
5505
|
if (!type || type === "plugin") {
|
|
5282
5506
|
for (const [alias, e] of Object.entries(data.plugins)) {
|
|
5283
|
-
out.push({
|
|
5507
|
+
out.push({
|
|
5508
|
+
type: "plugin",
|
|
5509
|
+
alias,
|
|
5510
|
+
name: e.name,
|
|
5511
|
+
version: e.version,
|
|
5512
|
+
enabled: e.enabled,
|
|
5513
|
+
config: e.config,
|
|
5514
|
+
dependencies: e.dependencies
|
|
5515
|
+
});
|
|
5284
5516
|
}
|
|
5285
5517
|
}
|
|
5286
5518
|
return out;
|
|
@@ -5640,6 +5872,9 @@ class DependencyManager {
|
|
|
5640
5872
|
integrationRegistry: this.integrationRegistry
|
|
5641
5873
|
});
|
|
5642
5874
|
}
|
|
5875
|
+
async refresh() {
|
|
5876
|
+
await this.refreshSnapshotFromCloud();
|
|
5877
|
+
}
|
|
5643
5878
|
integrationEntriesMatch(a, b) {
|
|
5644
5879
|
return jsonEqual(stripSnapshotMetadata(a), stripSnapshotMetadata(b));
|
|
5645
5880
|
}
|
|
@@ -5937,7 +6172,7 @@ init_types();
|
|
|
5937
6172
|
|
|
5938
6173
|
// src/dependencies/status-resolver.ts
|
|
5939
6174
|
import { existsSync } from "fs";
|
|
5940
|
-
import * as
|
|
6175
|
+
import * as path10 from "path";
|
|
5941
6176
|
|
|
5942
6177
|
// src/utils/ids.ts
|
|
5943
6178
|
function getIntegrationAlias(integrationName) {
|
|
@@ -5955,7 +6190,7 @@ async function resolveDependencyStatuses(input) {
|
|
|
5955
6190
|
const out = [];
|
|
5956
6191
|
const integrationVerdicts = new Map;
|
|
5957
6192
|
for (const [alias, entry] of Object.entries(input.snapshot.integrations)) {
|
|
5958
|
-
const installed = input.bpModulesDir ? existsSync(
|
|
6193
|
+
const installed = input.bpModulesDir ? existsSync(path10.join(input.bpModulesDir, bpModuleDirName("integration", alias))) : true;
|
|
5959
6194
|
const spec = await tryGetSpec(input.integrationRegistry, entry.name, entry.version);
|
|
5960
6195
|
const verdict = spec ? computeIntegrationStatus({
|
|
5961
6196
|
installed,
|
|
@@ -5982,7 +6217,7 @@ async function resolveDependencyStatuses(input) {
|
|
|
5982
6217
|
});
|
|
5983
6218
|
}
|
|
5984
6219
|
for (const [alias, entry] of Object.entries(input.snapshot.plugins)) {
|
|
5985
|
-
const installed = input.bpModulesDir ? existsSync(
|
|
6220
|
+
const installed = input.bpModulesDir ? existsSync(path10.join(input.bpModulesDir, bpModuleDirName("plugin", alias))) : true;
|
|
5986
6221
|
const spec = await tryGetSpec(input.pluginRegistry, entry.name, entry.version);
|
|
5987
6222
|
const dependencyStatuses = mapPluginDependencyStatuses(entry.dependencies, (intAlias) => integrationVerdicts.get(intAlias));
|
|
5988
6223
|
let verdict;
|
|
@@ -6041,26 +6276,26 @@ class InterfaceRegistry {
|
|
|
6041
6276
|
init_snapshot_store();
|
|
6042
6277
|
|
|
6043
6278
|
// src/dependencies/migration.ts
|
|
6044
|
-
import * as
|
|
6045
|
-
import * as
|
|
6279
|
+
import * as fs10 from "fs/promises";
|
|
6280
|
+
import * as path14 from "path";
|
|
6046
6281
|
import { Project as Project3, SyntaxKind as SyntaxKind3 } from "ts-morph";
|
|
6047
6282
|
|
|
6048
6283
|
// src/dependencies/legacy-lock-file.ts
|
|
6049
6284
|
init_types();
|
|
6050
6285
|
init_errors2();
|
|
6051
|
-
import * as
|
|
6052
|
-
import * as
|
|
6286
|
+
import * as fs9 from "fs/promises";
|
|
6287
|
+
import * as path11 from "path";
|
|
6053
6288
|
|
|
6054
6289
|
class LegacyDependencyLockFile {
|
|
6055
6290
|
filePath;
|
|
6056
6291
|
env;
|
|
6057
6292
|
constructor(opts) {
|
|
6058
6293
|
this.env = opts.env;
|
|
6059
|
-
this.filePath =
|
|
6294
|
+
this.filePath = path11.join(opts.projectPath, `dependencies.${opts.env}.lock.json`);
|
|
6060
6295
|
}
|
|
6061
6296
|
async exists() {
|
|
6062
6297
|
try {
|
|
6063
|
-
await
|
|
6298
|
+
await fs9.access(this.filePath);
|
|
6064
6299
|
return true;
|
|
6065
6300
|
} catch {
|
|
6066
6301
|
return false;
|
|
@@ -6069,7 +6304,7 @@ class LegacyDependencyLockFile {
|
|
|
6069
6304
|
async read(options) {
|
|
6070
6305
|
let raw;
|
|
6071
6306
|
try {
|
|
6072
|
-
raw = await
|
|
6307
|
+
raw = await fs9.readFile(this.filePath, "utf8");
|
|
6073
6308
|
} catch (err) {
|
|
6074
6309
|
if (err.code === "ENOENT") {
|
|
6075
6310
|
return dependencyStateSchema.parse({ version: 1, env: this.env });
|
|
@@ -6091,7 +6326,7 @@ class LegacyDependencyLockFile {
|
|
|
6091
6326
|
}
|
|
6092
6327
|
async delete() {
|
|
6093
6328
|
try {
|
|
6094
|
-
await
|
|
6329
|
+
await fs9.unlink(this.filePath);
|
|
6095
6330
|
} catch (err) {
|
|
6096
6331
|
if (err.code !== "ENOENT")
|
|
6097
6332
|
throw err;
|
|
@@ -6103,17 +6338,17 @@ class LegacyDependencyLockFile {
|
|
|
6103
6338
|
init_utils();
|
|
6104
6339
|
init_src();
|
|
6105
6340
|
import { Project as Project2, SyntaxKind as SyntaxKind2 } from "ts-morph";
|
|
6106
|
-
import { readFileSync as
|
|
6107
|
-
import * as
|
|
6341
|
+
import { readFileSync as readFileSync3 } from "fs";
|
|
6342
|
+
import * as path13 from "path";
|
|
6108
6343
|
|
|
6109
6344
|
class ConfigWriter {
|
|
6110
6345
|
configPath;
|
|
6111
6346
|
constructor(projectPath) {
|
|
6112
|
-
this.configPath =
|
|
6347
|
+
this.configPath = path13.join(projectPath, "agent.config.ts");
|
|
6113
6348
|
}
|
|
6114
6349
|
loadConfig() {
|
|
6115
6350
|
const project = new Project2;
|
|
6116
|
-
const sourceFile = project.createSourceFile(this.configPath,
|
|
6351
|
+
const sourceFile = project.createSourceFile(this.configPath, readFileSync3(this.configPath, "utf-8"), {
|
|
6117
6352
|
overwrite: true
|
|
6118
6353
|
});
|
|
6119
6354
|
const defineConfigCall = sourceFile.getDescendantsOfKind(SyntaxKind2.CallExpression).find((call) => {
|
|
@@ -6571,10 +6806,10 @@ async function migrateFromConfig(opts) {
|
|
|
6571
6806
|
return new DependencyMigrationManager(opts).run();
|
|
6572
6807
|
}
|
|
6573
6808
|
async function readDependenciesFromConfig(projectPath) {
|
|
6574
|
-
const configPath =
|
|
6809
|
+
const configPath = path14.join(projectPath, "agent.config.ts");
|
|
6575
6810
|
const empty = { version: 1, env: "dev", integrations: {}, plugins: {} };
|
|
6576
6811
|
try {
|
|
6577
|
-
await
|
|
6812
|
+
await fs10.access(configPath);
|
|
6578
6813
|
} catch {
|
|
6579
6814
|
return empty;
|
|
6580
6815
|
}
|
|
@@ -6668,4 +6903,4 @@ export {
|
|
|
6668
6903
|
DEPENDENCY_ERROR_CODES
|
|
6669
6904
|
};
|
|
6670
6905
|
|
|
6671
|
-
//# debugId=
|
|
6906
|
+
//# debugId=B6D706E1E2DC882A64756E2164756E21
|