lua-cli 3.5.0-alpha.3 → 3.5.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/README.md +137 -689
- package/dist/api/agent.api.service.d.ts +1 -8
- package/dist/api/agent.api.service.js +1 -11
- package/dist/api/agent.api.service.js.map +1 -1
- package/dist/api/auth.api.service.d.ts +1 -1
- package/dist/api/auth.api.service.js +1 -1
- package/dist/api/auth.api.service.js.map +1 -1
- package/dist/api/backup.api.service.d.ts +80 -0
- package/dist/api/backup.api.service.js +101 -0
- package/dist/api/backup.api.service.js.map +1 -0
- package/dist/api/basket.api.service.d.ts +4 -5
- package/dist/api/basket.api.service.js +13 -18
- package/dist/api/basket.api.service.js.map +1 -1
- package/dist/api/cdn.api.service.d.ts +2 -0
- package/dist/api/cdn.api.service.js +2 -0
- package/dist/api/cdn.api.service.js.map +1 -1
- package/dist/api/chat.api.service.d.ts +10 -2
- package/dist/api/chat.api.service.js +21 -2
- package/dist/api/chat.api.service.js.map +1 -1
- package/dist/api/credentials.js +5 -8
- package/dist/api/credentials.js.map +1 -1
- package/dist/api/custom.data.api.service.d.ts +3 -3
- package/dist/api/custom.data.api.service.js +9 -10
- package/dist/api/custom.data.api.service.js.map +1 -1
- package/dist/api/developer.api.service.d.ts +1 -1
- package/dist/api/developer.api.service.js +1 -1
- package/dist/api/developer.api.service.js.map +1 -1
- package/dist/api/http.client.js.map +1 -0
- package/dist/api/job.api.service.d.ts +2 -2
- package/dist/api/job.api.service.js +2 -2
- package/dist/api/job.api.service.js.map +1 -1
- package/dist/api/logs.api.service.d.ts +1 -1
- package/dist/api/logs.api.service.js +1 -1
- package/dist/api/logs.api.service.js.map +1 -1
- package/dist/api/marketplace.api.service.d.ts +6 -6
- package/dist/api/marketplace.api.service.js.map +1 -1
- package/dist/api/order.api.service.d.ts +3 -4
- package/dist/api/order.api.service.js +8 -10
- package/dist/api/order.api.service.js.map +1 -1
- package/dist/api/persona.api.service.d.ts +1 -1
- package/dist/api/persona.api.service.js +1 -1
- package/dist/api/persona.api.service.js.map +1 -1
- package/dist/api/postprocessor.api.service.d.ts +1 -1
- package/dist/api/postprocessor.api.service.js +1 -1
- package/dist/api/postprocessor.api.service.js.map +1 -1
- package/dist/api/preprocessor.api.service.d.ts +1 -1
- package/dist/api/preprocessor.api.service.js +1 -1
- package/dist/api/preprocessor.api.service.js.map +1 -1
- package/dist/api/products.api.service.d.ts +4 -4
- package/dist/api/products.api.service.js +6 -6
- package/dist/api/products.api.service.js.map +1 -1
- package/dist/api/resource.api.service.d.ts +76 -0
- package/dist/api/resource.api.service.js +74 -0
- package/dist/api/resource.api.service.js.map +1 -0
- package/dist/api/skills.api.service.d.ts +7 -15
- package/dist/api/skills.api.service.js +1 -1
- package/dist/api/skills.api.service.js.map +1 -1
- package/dist/api/tool.api.service.d.ts +1 -1
- package/dist/api/tool.api.service.js +1 -1
- package/dist/api/tool.api.service.js.map +1 -1
- package/dist/api/unifiedto.api.service.d.ts +1 -1
- package/dist/api/unifiedto.api.service.js +1 -1
- package/dist/api/unifiedto.api.service.js.map +1 -1
- package/dist/api/user.data.api.service.d.ts +7 -8
- package/dist/api/user.data.api.service.js +2 -3
- package/dist/api/user.data.api.service.js.map +1 -1
- package/dist/api/webhook.api.service.d.ts +1 -1
- package/dist/api/webhook.api.service.js +1 -1
- package/dist/api/webhook.api.service.js.map +1 -1
- package/dist/api/whatsapp-templates.api.service.d.ts +1 -1
- package/dist/api/whatsapp-templates.api.service.js +1 -1
- package/dist/api/whatsapp-templates.api.service.js.map +1 -1
- package/dist/api-exports.d.ts +14 -12
- package/dist/api-exports.js +8 -8
- package/dist/api-exports.js.map +1 -1
- package/dist/cli/command-definitions.js +32 -17
- package/dist/cli/command-definitions.js.map +1 -1
- package/dist/commands/admin.js +3 -24
- package/dist/commands/admin.js.map +1 -1
- package/dist/commands/agents.d.ts +8 -7
- package/dist/commands/agents.js +63 -21
- package/dist/commands/agents.js.map +1 -1
- package/dist/commands/channels.js +11 -23
- package/dist/commands/channels.js.map +1 -1
- package/dist/commands/chat.js +33 -47
- package/dist/commands/chat.js.map +1 -1
- package/dist/commands/chatClear.js +11 -41
- package/dist/commands/chatClear.js.map +1 -1
- package/dist/commands/compile.d.ts +26 -23
- package/dist/commands/compile.js +98 -403
- package/dist/commands/compile.js.map +1 -1
- package/dist/commands/completion.js +1 -1
- package/dist/commands/completion.js.map +1 -1
- package/dist/commands/deploy.js +55 -25
- package/dist/commands/deploy.js.map +1 -1
- package/dist/commands/dev.js +29 -45
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/env.js +12 -25
- package/dist/commands/env.js.map +1 -1
- package/dist/commands/evals.js +3 -20
- package/dist/commands/evals.js.map +1 -1
- package/dist/commands/features.js +10 -23
- package/dist/commands/features.js.map +1 -1
- package/dist/commands/index.d.ts +1 -0
- package/dist/commands/index.js +1 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/init.d.ts +1 -0
- package/dist/commands/init.js +135 -19
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/integrations.js +26 -37
- package/dist/commands/integrations.js.map +1 -1
- package/dist/commands/jobs.js +32 -56
- package/dist/commands/jobs.js.map +1 -1
- package/dist/commands/logs.js +9 -20
- package/dist/commands/logs.js.map +1 -1
- package/dist/commands/marketplace.js +34 -52
- package/dist/commands/marketplace.js.map +1 -1
- package/dist/commands/mcp.js +10 -23
- package/dist/commands/mcp.js.map +1 -1
- package/dist/commands/persona.js +43 -74
- package/dist/commands/persona.js.map +1 -1
- package/dist/commands/postprocessors.js +15 -28
- package/dist/commands/postprocessors.js.map +1 -1
- package/dist/commands/preprocessors.js +15 -28
- package/dist/commands/preprocessors.js.map +1 -1
- package/dist/commands/production.js +30 -63
- package/dist/commands/production.js.map +1 -1
- package/dist/commands/push.js +294 -1241
- package/dist/commands/push.js.map +1 -1
- package/dist/commands/pushBackup.d.ts +22 -0
- package/dist/commands/pushBackup.js +133 -0
- package/dist/commands/pushBackup.js.map +1 -0
- package/dist/commands/resources.js +29 -72
- package/dist/commands/resources.js.map +1 -1
- package/dist/commands/skills.d.ts +1 -1
- package/dist/commands/skills.js +58 -70
- package/dist/commands/skills.js.map +1 -1
- package/dist/commands/sync.d.ts +1 -3
- package/dist/commands/sync.js +12 -24
- package/dist/commands/sync.js.map +1 -1
- package/dist/commands/test.js +135 -104
- package/dist/commands/test.js.map +1 -1
- package/dist/commands/webhooks.js +15 -28
- package/dist/commands/webhooks.js.map +1 -1
- package/dist/compiler/agent-traverser.d.ts +104 -0
- package/dist/compiler/agent-traverser.js +311 -0
- package/dist/compiler/agent-traverser.js.map +1 -0
- package/dist/compiler/bundler.d.ts +42 -0
- package/dist/compiler/bundler.js +187 -0
- package/dist/compiler/bundler.js.map +1 -0
- package/dist/compiler/compiler.d.ts +177 -0
- package/dist/compiler/compiler.js +580 -0
- package/dist/compiler/compiler.js.map +1 -0
- package/dist/compiler/index.d.ts +36 -0
- package/dist/compiler/index.js +42 -0
- package/dist/compiler/index.js.map +1 -0
- package/dist/compiler/plugins/base.d.ts +264 -0
- package/dist/compiler/plugins/base.js +307 -0
- package/dist/compiler/plugins/base.js.map +1 -0
- package/dist/compiler/plugins/job.plugin.d.ts +33 -0
- package/dist/compiler/plugins/job.plugin.js +143 -0
- package/dist/compiler/plugins/job.plugin.js.map +1 -0
- package/dist/compiler/plugins/mcp-server.plugin.d.ts +50 -0
- package/dist/compiler/plugins/mcp-server.plugin.js +186 -0
- package/dist/compiler/plugins/mcp-server.plugin.js.map +1 -0
- package/dist/compiler/plugins/postprocessor.plugin.d.ts +20 -0
- package/dist/compiler/plugins/postprocessor.plugin.js +39 -0
- package/dist/compiler/plugins/postprocessor.plugin.js.map +1 -0
- package/dist/compiler/plugins/preprocessor.plugin.d.ts +20 -0
- package/dist/compiler/plugins/preprocessor.plugin.js +48 -0
- package/dist/compiler/plugins/preprocessor.plugin.js.map +1 -0
- package/dist/compiler/plugins/processor-base.d.ts +16 -0
- package/dist/compiler/plugins/processor-base.js +34 -0
- package/dist/compiler/plugins/processor-base.js.map +1 -0
- package/dist/compiler/plugins/registry.d.ts +61 -0
- package/dist/compiler/plugins/registry.js +107 -0
- package/dist/compiler/plugins/registry.js.map +1 -0
- package/dist/compiler/plugins/skill.plugin.d.ts +71 -0
- package/dist/compiler/plugins/skill.plugin.js +243 -0
- package/dist/compiler/plugins/skill.plugin.js.map +1 -0
- package/dist/compiler/plugins/tool.plugin.d.ts +67 -0
- package/dist/compiler/plugins/tool.plugin.js +279 -0
- package/dist/compiler/plugins/tool.plugin.js.map +1 -0
- package/dist/compiler/plugins/webhook.plugin.d.ts +37 -0
- package/dist/compiler/plugins/webhook.plugin.js +127 -0
- package/dist/compiler/plugins/webhook.plugin.js.map +1 -0
- package/dist/compiler/source-writer.d.ts +98 -0
- package/dist/compiler/source-writer.js +223 -0
- package/dist/compiler/source-writer.js.map +1 -0
- package/dist/compiler/types.d.ts +289 -0
- package/dist/compiler/types.js +20 -0
- package/dist/compiler/types.js.map +1 -0
- package/dist/compiler/utils/ast-helpers.d.ts +57 -0
- package/dist/compiler/utils/ast-helpers.js +164 -0
- package/dist/compiler/utils/ast-helpers.js.map +1 -0
- package/dist/compiler/utils/common.d.ts +23 -0
- package/dist/compiler/utils/common.js +66 -0
- package/dist/compiler/utils/common.js.map +1 -0
- package/dist/compiler/utils/file-discovery.d.ts +34 -0
- package/dist/compiler/utils/file-discovery.js +68 -0
- package/dist/compiler/utils/file-discovery.js.map +1 -0
- package/dist/compiler/utils/path-resolver.d.ts +25 -0
- package/dist/compiler/utils/path-resolver.js +66 -0
- package/dist/compiler/utils/path-resolver.js.map +1 -0
- package/dist/compiler/utils/schema-converter.d.ts +26 -0
- package/dist/compiler/utils/schema-converter.js +94 -0
- package/dist/compiler/utils/schema-converter.js.map +1 -0
- package/dist/config/compile.constants.d.ts +2 -22
- package/dist/config/compile.constants.js +2 -49
- package/dist/config/compile.constants.js.map +1 -1
- package/dist/config/constants.d.ts +18 -2
- package/dist/config/constants.js +28 -8
- package/dist/config/constants.js.map +1 -1
- package/dist/config/dev.constants.d.ts +0 -10
- package/dist/config/dev.constants.js +0 -10
- package/dist/config/dev.constants.js.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/instances/basket.instance.js.map +1 -0
- package/dist/instances/data.entry.instance.js.map +1 -0
- package/dist/instances/job.instance.js.map +1 -0
- package/dist/instances/order.instance.js.map +1 -0
- package/dist/instances/product.instance.js.map +1 -0
- package/dist/instances/product.pagination.instance.js.map +1 -0
- package/dist/instances/product.search.instance.js.map +1 -0
- package/dist/instances/user.instance.js.map +1 -0
- package/dist/interfaces/admin.d.ts +0 -38
- package/dist/interfaces/backup.d.ts +125 -0
- package/dist/interfaces/backup.js +8 -0
- package/dist/interfaces/backup.js.map +1 -0
- package/dist/interfaces/baskets.d.ts +0 -56
- package/dist/interfaces/common.d.ts +1 -0
- package/dist/interfaces/deploy.d.ts +0 -15
- package/dist/interfaces/index.d.ts +1 -1
- package/dist/interfaces/marketplace.d.ts +51 -0
- package/dist/interfaces/marketplace.js +1 -1
- package/dist/interfaces/marketplace.js.map +1 -1
- package/dist/interfaces/message.d.ts +0 -3
- package/dist/interfaces/orders.d.ts +0 -24
- package/dist/interfaces/postprocessors.d.ts +0 -18
- package/dist/interfaces/preprocessors.d.ts +0 -18
- package/dist/interfaces/skills.d.ts +61 -0
- package/dist/interfaces/user.d.ts +25 -0
- package/dist/interfaces/webhooks.d.ts +0 -9
- package/dist/primitives/base.handler.d.ts +106 -0
- package/dist/primitives/base.handler.js +370 -0
- package/dist/primitives/base.handler.js.map +1 -0
- package/dist/primitives/index.d.ts +47 -0
- package/dist/primitives/index.js +78 -0
- package/dist/primitives/index.js.map +1 -0
- package/dist/primitives/job.handler.d.ts +52 -0
- package/dist/primitives/job.handler.js +118 -0
- package/dist/primitives/job.handler.js.map +1 -0
- package/dist/primitives/mcp-server.handler.d.ts +54 -0
- package/dist/primitives/mcp-server.handler.js +91 -0
- package/dist/primitives/mcp-server.handler.js.map +1 -0
- package/dist/primitives/postprocessor.handler.d.ts +49 -0
- package/dist/primitives/postprocessor.handler.js +81 -0
- package/dist/primitives/postprocessor.handler.js.map +1 -0
- package/dist/primitives/preprocessor.handler.d.ts +54 -0
- package/dist/primitives/preprocessor.handler.js +95 -0
- package/dist/primitives/preprocessor.handler.js.map +1 -0
- package/dist/primitives/skill.handler.d.ts +44 -0
- package/dist/primitives/skill.handler.js +192 -0
- package/dist/primitives/skill.handler.js.map +1 -0
- package/dist/primitives/types.d.ts +72 -0
- package/dist/primitives/types.js +17 -0
- package/dist/primitives/types.js.map +1 -0
- package/dist/primitives/webhook.handler.d.ts +50 -0
- package/dist/primitives/webhook.handler.js +96 -0
- package/dist/primitives/webhook.handler.js.map +1 -0
- package/dist/services/auth.js +1 -2
- package/dist/services/auth.js.map +1 -1
- package/dist/services/sandbox.service.d.ts +103 -0
- package/dist/services/sandbox.service.js +479 -0
- package/dist/services/sandbox.service.js.map +1 -0
- package/dist/types/api-contracts.d.ts +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/index.js.map +1 -1
- package/dist/types/skill.d.ts +8 -2
- package/dist/types/skill.js +8 -0
- package/dist/types/skill.js.map +1 -1
- package/dist/types/yaml.types.d.ts +69 -0
- package/dist/types/yaml.types.js +6 -0
- package/dist/types/yaml.types.js.map +1 -0
- package/dist/utils/artifact-loader.d.ts +108 -0
- package/dist/utils/artifact-loader.js +188 -0
- package/dist/utils/artifact-loader.js.map +1 -0
- package/dist/utils/backup-helpers.d.ts +122 -0
- package/dist/utils/backup-helpers.js +274 -0
- package/dist/utils/backup-helpers.js.map +1 -0
- package/dist/utils/cli.d.ts +8 -0
- package/dist/utils/cli.js +19 -2
- package/dist/utils/cli.js.map +1 -1
- package/dist/utils/command-utils.d.ts +42 -0
- package/dist/utils/command-utils.js +83 -0
- package/dist/utils/command-utils.js.map +1 -0
- package/dist/utils/deploy-helpers.d.ts +0 -29
- package/dist/utils/deploy-helpers.js +0 -70
- package/dist/utils/deploy-helpers.js.map +1 -1
- package/dist/utils/dev-api.d.ts +3 -99
- package/dist/utils/dev-api.js +3 -430
- package/dist/utils/dev-api.js.map +1 -1
- package/dist/utils/dev-server.d.ts +3 -1
- package/dist/utils/dev-server.js +69 -145
- package/dist/utils/dev-server.js.map +1 -1
- package/dist/utils/dev-watcher.d.ts +0 -1
- package/dist/utils/dev-watcher.js +23 -8
- package/dist/utils/dev-watcher.js.map +1 -1
- package/dist/utils/env-loader.utils.d.ts +10 -1
- package/dist/utils/env-loader.utils.js +39 -31
- package/dist/utils/env-loader.utils.js.map +1 -1
- package/dist/utils/files.d.ts +47 -3
- package/dist/utils/files.js +98 -40
- package/dist/utils/files.js.map +1 -1
- package/dist/utils/init-agent.js +1 -2
- package/dist/utils/init-agent.js.map +1 -1
- package/dist/utils/init-helpers.d.ts +2 -10
- package/dist/utils/init-helpers.js +9 -17
- package/dist/utils/init-helpers.js.map +1 -1
- package/dist/utils/init-prompts.d.ts +0 -8
- package/dist/utils/init-prompts.js +0 -22
- package/dist/utils/init-prompts.js.map +1 -1
- package/dist/utils/prompt-handler.d.ts +3 -0
- package/dist/utils/prompt-handler.js +13 -0
- package/dist/utils/prompt-handler.js.map +1 -1
- package/dist/utils/sandbox-storage.d.ts +6 -5
- package/dist/utils/sandbox-storage.js +12 -12
- package/dist/utils/sandbox-storage.js.map +1 -1
- package/dist/utils/sandbox.d.ts +7 -30
- package/dist/utils/sandbox.js +247 -223
- package/dist/utils/sandbox.js.map +1 -1
- package/dist/utils/semver.d.ts +12 -0
- package/dist/utils/semver.js +23 -0
- package/dist/utils/semver.js.map +1 -1
- package/dist/utils/sync-display.d.ts +9 -0
- package/dist/utils/sync-display.js +67 -0
- package/dist/utils/sync-display.js.map +1 -0
- package/dist/utils/sync-fetch.d.ts +23 -0
- package/dist/utils/sync-fetch.js +64 -0
- package/dist/utils/sync-fetch.js.map +1 -0
- package/dist/utils/sync-helpers.d.ts +4 -59
- package/dist/utils/sync-helpers.js +4 -206
- package/dist/utils/sync-helpers.js.map +1 -1
- package/dist/web/app.css +912 -186
- package/dist/web/app.js +46 -46
- package/docs/API_INDEX.md +100 -0
- package/docs/API_REFERENCE.md +773 -0
- package/docs/CLI_REFERENCE.md +924 -0
- package/docs/GETTING_STARTED.md +862 -0
- package/docs/README.md +270 -0
- package/docs/api/AI.md +882 -0
- package/docs/api/Baskets.md +511 -0
- package/docs/api/CDN.md +524 -0
- package/docs/api/Data.md +446 -0
- package/docs/api/Jobs.md +524 -0
- package/docs/api/LuaAgent.md +454 -0
- package/docs/api/LuaJob.md +604 -0
- package/docs/api/LuaSkill.md +396 -0
- package/docs/api/LuaTool.md +521 -0
- package/docs/api/LuaWebhook.md +601 -0
- package/docs/api/Orders.md +514 -0
- package/docs/api/PostProcessor.md +565 -0
- package/docs/api/PreProcessor.md +630 -0
- package/docs/api/Products.md +507 -0
- package/docs/api/Templates.md +662 -0
- package/docs/api/User.md +567 -0
- package/docs/archive/DEVELOPMENT_GUIDE_V1.md +1294 -0
- package/docs/compiler-v2/ASSESSMENT.md +205 -0
- package/docs/compiler-v2/TEST_PLAN.md +306 -0
- package/package.json +3 -7
- package/template/tsconfig.json +1 -1
- package/dist/common/basket.instance.js.map +0 -1
- package/dist/common/data.entry.instance.js.map +0 -1
- package/dist/common/http.client.js.map +0 -1
- package/dist/common/job.instance.js.map +0 -1
- package/dist/common/order.instance.js.map +0 -1
- package/dist/common/product.instance.js.map +0 -1
- package/dist/common/product.pagination.instance.js.map +0 -1
- package/dist/common/product.search.instance.js.map +0 -1
- package/dist/common/user.instance.js.map +0 -1
- package/dist/config/auth.constants.d.ts +0 -11
- package/dist/config/auth.constants.js +0 -12
- package/dist/config/auth.constants.js.map +0 -1
- package/dist/config/init.constants.d.ts +0 -15
- package/dist/config/init.constants.js +0 -20
- package/dist/config/init.constants.js.map +0 -1
- package/dist/interfaces/compile.d.ts +0 -12
- package/dist/interfaces/compile.js +0 -5
- package/dist/interfaces/compile.js.map +0 -1
- package/dist/types/compile.types.d.ts +0 -131
- package/dist/types/compile.types.js +0 -6
- package/dist/types/compile.types.js.map +0 -1
- package/dist/utils/agent-code-utils.d.ts +0 -25
- package/dist/utils/agent-code-utils.js +0 -107
- package/dist/utils/agent-code-utils.js.map +0 -1
- package/dist/utils/bundling.d.ts +0 -89
- package/dist/utils/bundling.js +0 -1068
- package/dist/utils/bundling.js.map +0 -1
- package/dist/utils/compile.d.ts +0 -116
- package/dist/utils/compile.js +0 -1062
- package/dist/utils/compile.js.map +0 -1
- package/dist/utils/deploy-api.d.ts +0 -26
- package/dist/utils/deploy-api.js +0 -54
- package/dist/utils/deploy-api.js.map +0 -1
- package/dist/utils/deployment.d.ts +0 -26
- package/dist/utils/deployment.js +0 -218
- package/dist/utils/deployment.js.map +0 -1
- package/dist/utils/dev-helpers.d.ts +0 -47
- package/dist/utils/dev-helpers.js +0 -82
- package/dist/utils/dev-helpers.js.map +0 -1
- package/dist/utils/job-management.d.ts +0 -27
- package/dist/utils/job-management.js +0 -248
- package/dist/utils/job-management.js.map +0 -1
- package/dist/utils/mcp-server-management.d.ts +0 -26
- package/dist/utils/mcp-server-management.js +0 -197
- package/dist/utils/mcp-server-management.js.map +0 -1
- package/dist/utils/postprocessor-management.d.ts +0 -9
- package/dist/utils/postprocessor-management.js +0 -117
- package/dist/utils/postprocessor-management.js.map +0 -1
- package/dist/utils/pre-bundle-jobs.d.ts +0 -27
- package/dist/utils/pre-bundle-jobs.js +0 -189
- package/dist/utils/pre-bundle-jobs.js.map +0 -1
- package/dist/utils/preprocessor-management.d.ts +0 -9
- package/dist/utils/preprocessor-management.js +0 -117
- package/dist/utils/preprocessor-management.js.map +0 -1
- package/dist/utils/push-api.d.ts +0 -15
- package/dist/utils/push-api.js +0 -49
- package/dist/utils/push-api.js.map +0 -1
- package/dist/utils/push-helpers.d.ts +0 -82
- package/dist/utils/push-helpers.js +0 -246
- package/dist/utils/push-helpers.js.map +0 -1
- package/dist/utils/skill-management.d.ts +0 -39
- package/dist/utils/skill-management.js +0 -299
- package/dist/utils/skill-management.js.map +0 -1
- package/dist/utils/test-helpers.d.ts +0 -33
- package/dist/utils/test-helpers.js +0 -84
- package/dist/utils/test-helpers.js.map +0 -1
- package/dist/utils/test-prompts.d.ts +0 -23
- package/dist/utils/test-prompts.js +0 -187
- package/dist/utils/test-prompts.js.map +0 -1
- package/dist/utils/tool-detection.d.ts +0 -19
- package/dist/utils/tool-detection.js +0 -125
- package/dist/utils/tool-detection.js.map +0 -1
- package/dist/utils/webhook-management.d.ts +0 -27
- package/dist/utils/webhook-management.js +0 -241
- package/dist/utils/webhook-management.js.map +0 -1
- /package/dist/{common → api}/http.client.d.ts +0 -0
- /package/dist/{common → api}/http.client.js +0 -0
- /package/dist/{common → instances}/basket.instance.d.ts +0 -0
- /package/dist/{common → instances}/basket.instance.js +0 -0
- /package/dist/{common → instances}/data.entry.instance.d.ts +0 -0
- /package/dist/{common → instances}/data.entry.instance.js +0 -0
- /package/dist/{common → instances}/job.instance.d.ts +0 -0
- /package/dist/{common → instances}/job.instance.js +0 -0
- /package/dist/{common → instances}/order.instance.d.ts +0 -0
- /package/dist/{common → instances}/order.instance.js +0 -0
- /package/dist/{common → instances}/product.instance.d.ts +0 -0
- /package/dist/{common → instances}/product.instance.js +0 -0
- /package/dist/{common → instances}/product.pagination.instance.d.ts +0 -0
- /package/dist/{common → instances}/product.pagination.instance.js +0 -0
- /package/dist/{common → instances}/product.search.instance.d.ts +0 -0
- /package/dist/{common → instances}/product.search.instance.js +0 -0
- /package/dist/{common → instances}/user.instance.d.ts +0 -0
- /package/dist/{common → instances}/user.instance.js +0 -0
package/docs/api/AI.md
ADDED
|
@@ -0,0 +1,882 @@
|
|
|
1
|
+
# AI API
|
|
2
|
+
|
|
3
|
+
The AI API allows your tools to generate AI responses with custom context. Use this to add AI capabilities to your tools, such as text generation, content analysis, recommendations, and more.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { AI } from 'lua-cli';
|
|
9
|
+
// or
|
|
10
|
+
import { AI } from 'lua-cli/skill';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Overview
|
|
14
|
+
|
|
15
|
+
The AI API enables:
|
|
16
|
+
- Generate text with custom prompts and context
|
|
17
|
+
- Analyze images with AI
|
|
18
|
+
- Process documents with AI
|
|
19
|
+
- Create AI-powered features in your tools
|
|
20
|
+
- Use different personas for different tasks
|
|
21
|
+
- Multi-modal inputs (text, images, files)
|
|
22
|
+
|
|
23
|
+
## Methods
|
|
24
|
+
|
|
25
|
+
### `AI.generate(context, messages, agentId?)`
|
|
26
|
+
|
|
27
|
+
Generates an AI response with custom runtime context.
|
|
28
|
+
|
|
29
|
+
**Parameters:**
|
|
30
|
+
- `context` (string) - Runtime context/instructions for the AI
|
|
31
|
+
- `messages` (ChatMessage[]) - Array of messages to process
|
|
32
|
+
- `agentId` (string, optional) - Agent ID to use (defaults to 'luaAgent')
|
|
33
|
+
|
|
34
|
+
**Returns:** `Promise<string>` - AI-generated text response
|
|
35
|
+
|
|
36
|
+
**Example:**
|
|
37
|
+
```typescript
|
|
38
|
+
const response = await AI.generate(
|
|
39
|
+
'You are a helpful sales assistant.',
|
|
40
|
+
[{ type: 'text', text: 'What products do you recommend?' }]
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
console.log(response);
|
|
44
|
+
// "I recommend starting with our best-sellers..."
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Message Types
|
|
48
|
+
|
|
49
|
+
### Text Message
|
|
50
|
+
|
|
51
|
+
```typescript
|
|
52
|
+
{
|
|
53
|
+
type: 'text',
|
|
54
|
+
text: string
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### Image Message
|
|
59
|
+
|
|
60
|
+
```typescript
|
|
61
|
+
{
|
|
62
|
+
type: 'image',
|
|
63
|
+
url: string
|
|
64
|
+
}
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### File Message
|
|
68
|
+
|
|
69
|
+
```typescript
|
|
70
|
+
{
|
|
71
|
+
type: 'file',
|
|
72
|
+
url: string,
|
|
73
|
+
mimeType?: string
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Complete Examples
|
|
78
|
+
|
|
79
|
+
### Product Description Generator
|
|
80
|
+
|
|
81
|
+
```typescript
|
|
82
|
+
import { LuaTool, AI, Products } from 'lua-cli/skill';
|
|
83
|
+
import { z } from 'zod';
|
|
84
|
+
|
|
85
|
+
export default class GenerateDescriptionTool implements LuaTool {
|
|
86
|
+
name = 'generate_product_description';
|
|
87
|
+
description = 'Generate compelling product descriptions using AI';
|
|
88
|
+
|
|
89
|
+
inputSchema = z.object({
|
|
90
|
+
productId: z.string(),
|
|
91
|
+
style: z.enum(['casual', 'professional', 'luxury']).optional()
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
95
|
+
// Get product details
|
|
96
|
+
const product = await Products.getById(input.productId);
|
|
97
|
+
|
|
98
|
+
if (!product) {
|
|
99
|
+
return { success: false, error: 'Product not found' };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Generate description with AI
|
|
103
|
+
const style = input.style || 'professional';
|
|
104
|
+
const context = `You are a ${style} copywriter for an e-commerce store.
|
|
105
|
+
Create an engaging product description that highlights benefits and features.
|
|
106
|
+
Keep it concise but compelling (2-3 sentences).`;
|
|
107
|
+
|
|
108
|
+
const description = await AI.generate(
|
|
109
|
+
context,
|
|
110
|
+
[{
|
|
111
|
+
type: 'text',
|
|
112
|
+
text: `Write a product description for: ${product.name}, Price: $${product.price}`
|
|
113
|
+
}]
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
// Update product with new description
|
|
117
|
+
await product.update({ description });
|
|
118
|
+
|
|
119
|
+
return {
|
|
120
|
+
success: true,
|
|
121
|
+
productId: input.productId,
|
|
122
|
+
description
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Image Analysis Tool
|
|
129
|
+
|
|
130
|
+
```typescript
|
|
131
|
+
import { LuaTool, AI } from 'lua-cli/skill';
|
|
132
|
+
import { z } from 'zod';
|
|
133
|
+
|
|
134
|
+
export default class AnalyzeImageTool implements LuaTool {
|
|
135
|
+
name = 'analyze_image';
|
|
136
|
+
description = 'Analyze images using AI vision';
|
|
137
|
+
|
|
138
|
+
inputSchema = z.object({
|
|
139
|
+
imageUrl: z.string().url(),
|
|
140
|
+
question: z.string().optional()
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
144
|
+
const context = `You are an image analysis expert.
|
|
145
|
+
Describe what you see in detail, including:
|
|
146
|
+
- Main subjects and objects
|
|
147
|
+
- Colors and composition
|
|
148
|
+
- Mood and atmosphere
|
|
149
|
+
- Any text or branding visible`;
|
|
150
|
+
|
|
151
|
+
const messages = [
|
|
152
|
+
{
|
|
153
|
+
type: 'text' as const,
|
|
154
|
+
text: input.question || 'Describe this image in detail'
|
|
155
|
+
},
|
|
156
|
+
{
|
|
157
|
+
type: 'image' as const,
|
|
158
|
+
url: input.imageUrl
|
|
159
|
+
}
|
|
160
|
+
];
|
|
161
|
+
|
|
162
|
+
const analysis = await AI.generate(context, messages);
|
|
163
|
+
|
|
164
|
+
return {
|
|
165
|
+
success: true,
|
|
166
|
+
imageUrl: input.imageUrl,
|
|
167
|
+
analysis
|
|
168
|
+
};
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Content Summarizer
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
import { LuaTool, AI } from 'lua-cli/skill';
|
|
177
|
+
import { z } from 'zod';
|
|
178
|
+
|
|
179
|
+
export default class SummarizeTool implements LuaTool {
|
|
180
|
+
name = 'summarize_content';
|
|
181
|
+
description = 'Summarize long text content';
|
|
182
|
+
|
|
183
|
+
inputSchema = z.object({
|
|
184
|
+
content: z.string(),
|
|
185
|
+
maxLength: z.enum(['brief', 'medium', 'detailed']).optional()
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
189
|
+
const lengthInstructions = {
|
|
190
|
+
brief: 'in 1-2 sentences',
|
|
191
|
+
medium: 'in 1 paragraph',
|
|
192
|
+
detailed: 'in 2-3 paragraphs with key points'
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
const length = input.maxLength || 'medium';
|
|
196
|
+
|
|
197
|
+
const context = `You are a professional content summarizer.
|
|
198
|
+
Create a clear, accurate summary ${lengthInstructions[length]}.
|
|
199
|
+
Focus on main ideas and key takeaways.`;
|
|
200
|
+
|
|
201
|
+
const summary = await AI.generate(
|
|
202
|
+
context,
|
|
203
|
+
[{
|
|
204
|
+
type: 'text',
|
|
205
|
+
text: `Summarize this content:\n\n${input.content}`
|
|
206
|
+
}]
|
|
207
|
+
);
|
|
208
|
+
|
|
209
|
+
return {
|
|
210
|
+
success: true,
|
|
211
|
+
originalLength: input.content.length,
|
|
212
|
+
summary,
|
|
213
|
+
summaryLength: summary.length
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
### Smart Recommendation Engine
|
|
220
|
+
|
|
221
|
+
```typescript
|
|
222
|
+
import { LuaTool, AI, User, Products } from 'lua-cli/skill';
|
|
223
|
+
import { z } from 'zod';
|
|
224
|
+
|
|
225
|
+
export default class RecommendProductsTool implements LuaTool {
|
|
226
|
+
name = 'get_ai_recommendations';
|
|
227
|
+
description = 'Get AI-powered product recommendations based on user preferences';
|
|
228
|
+
|
|
229
|
+
inputSchema = z.object({
|
|
230
|
+
userQuery: z.string().optional()
|
|
231
|
+
});
|
|
232
|
+
|
|
233
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
234
|
+
// Get user data and product catalog
|
|
235
|
+
const user = await User.get();
|
|
236
|
+
const products = await Products.get(1, 50);
|
|
237
|
+
|
|
238
|
+
// Build context with product data
|
|
239
|
+
const productList = products.map(p =>
|
|
240
|
+
`- ${p.name}: $${p.price} (${p.category})`
|
|
241
|
+
).join('\n');
|
|
242
|
+
|
|
243
|
+
const context = `You are a personal shopping assistant.
|
|
244
|
+
|
|
245
|
+
Available products:
|
|
246
|
+
${productList}
|
|
247
|
+
|
|
248
|
+
User preferences: ${JSON.stringify(user.data.preferences || {})}
|
|
249
|
+
|
|
250
|
+
Task: Recommend 3-5 products that best match the user's needs.
|
|
251
|
+
Format: Return product names with brief explanations.`;
|
|
252
|
+
|
|
253
|
+
const query = input.userQuery || 'What products would you recommend for me?';
|
|
254
|
+
|
|
255
|
+
const recommendations = await AI.generate(
|
|
256
|
+
context,
|
|
257
|
+
[{ type: 'text', text: query }]
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
return {
|
|
261
|
+
success: true,
|
|
262
|
+
recommendations,
|
|
263
|
+
basedOn: {
|
|
264
|
+
userPreferences: user.data.preferences,
|
|
265
|
+
availableProducts: products.length,
|
|
266
|
+
query
|
|
267
|
+
}
|
|
268
|
+
};
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### Content Moderator
|
|
274
|
+
|
|
275
|
+
```typescript
|
|
276
|
+
import { LuaTool, AI } from 'lua-cli/skill';
|
|
277
|
+
import { z } from 'zod';
|
|
278
|
+
|
|
279
|
+
export default class ModerateContentTool implements LuaTool {
|
|
280
|
+
name = 'moderate_content';
|
|
281
|
+
description = 'Check if content is appropriate and safe';
|
|
282
|
+
|
|
283
|
+
inputSchema = z.object({
|
|
284
|
+
content: z.string()
|
|
285
|
+
});
|
|
286
|
+
|
|
287
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
288
|
+
const context = `You are a content moderation expert.
|
|
289
|
+
|
|
290
|
+
Analyze the following content for:
|
|
291
|
+
- Inappropriate language
|
|
292
|
+
- Harmful content
|
|
293
|
+
- Spam or advertising
|
|
294
|
+
- Personal information exposure
|
|
295
|
+
|
|
296
|
+
Respond with JSON in this exact format:
|
|
297
|
+
{
|
|
298
|
+
"safe": true/false,
|
|
299
|
+
"reason": "explanation",
|
|
300
|
+
"category": "appropriate/profanity/spam/harmful/pii",
|
|
301
|
+
"confidence": 0.95
|
|
302
|
+
}`;
|
|
303
|
+
|
|
304
|
+
const analysis = await AI.generate(
|
|
305
|
+
context,
|
|
306
|
+
[{
|
|
307
|
+
type: 'text',
|
|
308
|
+
text: `Analyze this content:\n\n"${input.content}"`
|
|
309
|
+
}]
|
|
310
|
+
);
|
|
311
|
+
|
|
312
|
+
try {
|
|
313
|
+
const result = JSON.parse(analysis);
|
|
314
|
+
return {
|
|
315
|
+
success: true,
|
|
316
|
+
...result,
|
|
317
|
+
originalContent: input.content
|
|
318
|
+
};
|
|
319
|
+
} catch {
|
|
320
|
+
// If AI didn't return valid JSON, parse manually
|
|
321
|
+
const safe = !analysis.toLowerCase().includes('inappropriate');
|
|
322
|
+
return {
|
|
323
|
+
success: true,
|
|
324
|
+
safe,
|
|
325
|
+
reason: analysis,
|
|
326
|
+
category: 'unknown',
|
|
327
|
+
confidence: 0.5
|
|
328
|
+
};
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
### Translation Tool
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
import { LuaTool, AI } from 'lua-cli/skill';
|
|
338
|
+
import { z } from 'zod';
|
|
339
|
+
|
|
340
|
+
export default class TranslateTool implements LuaTool {
|
|
341
|
+
name = 'translate_text';
|
|
342
|
+
description = 'Translate text to different languages';
|
|
343
|
+
|
|
344
|
+
inputSchema = z.object({
|
|
345
|
+
text: z.string(),
|
|
346
|
+
targetLanguage: z.string(),
|
|
347
|
+
sourceLanguage: z.string().optional()
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
351
|
+
const sourceLang = input.sourceLanguage || 'auto-detect';
|
|
352
|
+
|
|
353
|
+
const context = `You are a professional translator.
|
|
354
|
+
Translate the text accurately while preserving:
|
|
355
|
+
- Tone and style
|
|
356
|
+
- Cultural context
|
|
357
|
+
- Idiomatic expressions (adapt appropriately)
|
|
358
|
+
|
|
359
|
+
Source language: ${sourceLang}
|
|
360
|
+
Target language: ${input.targetLanguage}
|
|
361
|
+
|
|
362
|
+
Return ONLY the translated text, nothing else.`;
|
|
363
|
+
|
|
364
|
+
const translation = await AI.generate(
|
|
365
|
+
context,
|
|
366
|
+
[{
|
|
367
|
+
type: 'text',
|
|
368
|
+
text: input.text
|
|
369
|
+
}]
|
|
370
|
+
);
|
|
371
|
+
|
|
372
|
+
return {
|
|
373
|
+
success: true,
|
|
374
|
+
original: input.text,
|
|
375
|
+
translation,
|
|
376
|
+
from: sourceLang,
|
|
377
|
+
to: input.targetLanguage
|
|
378
|
+
};
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### Document Q&A Tool
|
|
384
|
+
|
|
385
|
+
```typescript
|
|
386
|
+
import { LuaTool, AI } from 'lua-cli/skill';
|
|
387
|
+
import { z } from 'zod';
|
|
388
|
+
|
|
389
|
+
export default class DocumentQATool implements LuaTool {
|
|
390
|
+
name = 'ask_about_document';
|
|
391
|
+
description = 'Ask questions about a document using AI';
|
|
392
|
+
|
|
393
|
+
inputSchema = z.object({
|
|
394
|
+
documentUrl: z.string().url(),
|
|
395
|
+
question: z.string()
|
|
396
|
+
});
|
|
397
|
+
|
|
398
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
399
|
+
const context = `You are a document analysis assistant.
|
|
400
|
+
|
|
401
|
+
Read the document carefully and answer the user's question based on the content.
|
|
402
|
+
|
|
403
|
+
Guidelines:
|
|
404
|
+
- Only use information from the document
|
|
405
|
+
- If the answer isn't in the document, say so
|
|
406
|
+
- Cite specific parts when possible
|
|
407
|
+
- Be accurate and precise`;
|
|
408
|
+
|
|
409
|
+
const answer = await AI.generate(
|
|
410
|
+
context,
|
|
411
|
+
[
|
|
412
|
+
{ type: 'file', url: input.documentUrl },
|
|
413
|
+
{ type: 'text', text: input.question }
|
|
414
|
+
]
|
|
415
|
+
);
|
|
416
|
+
|
|
417
|
+
return {
|
|
418
|
+
success: true,
|
|
419
|
+
question: input.question,
|
|
420
|
+
answer,
|
|
421
|
+
documentUrl: input.documentUrl
|
|
422
|
+
};
|
|
423
|
+
}
|
|
424
|
+
}
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### Sentiment Analysis
|
|
428
|
+
|
|
429
|
+
```typescript
|
|
430
|
+
import { LuaTool, AI } from 'lua-cli/skill';
|
|
431
|
+
import { z } from 'zod';
|
|
432
|
+
|
|
433
|
+
export default class SentimentAnalysisTool implements LuaTool {
|
|
434
|
+
name = 'analyze_sentiment';
|
|
435
|
+
description = 'Analyze the sentiment of text';
|
|
436
|
+
|
|
437
|
+
inputSchema = z.object({
|
|
438
|
+
text: z.string()
|
|
439
|
+
});
|
|
440
|
+
|
|
441
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
442
|
+
const context = `You are a sentiment analysis expert.
|
|
443
|
+
|
|
444
|
+
Analyze the sentiment of the text and respond with JSON:
|
|
445
|
+
{
|
|
446
|
+
"sentiment": "positive|negative|neutral",
|
|
447
|
+
"score": 0.0 to 1.0,
|
|
448
|
+
"emotions": ["happy", "excited", "satisfied"],
|
|
449
|
+
"summary": "brief explanation"
|
|
450
|
+
}`;
|
|
451
|
+
|
|
452
|
+
const analysis = await AI.generate(
|
|
453
|
+
context,
|
|
454
|
+
[{
|
|
455
|
+
type: 'text',
|
|
456
|
+
text: `Analyze the sentiment:\n\n"${input.text}"`
|
|
457
|
+
}]
|
|
458
|
+
);
|
|
459
|
+
|
|
460
|
+
try {
|
|
461
|
+
const result = JSON.parse(analysis);
|
|
462
|
+
return {
|
|
463
|
+
success: true,
|
|
464
|
+
...result,
|
|
465
|
+
originalText: input.text
|
|
466
|
+
};
|
|
467
|
+
} catch {
|
|
468
|
+
return {
|
|
469
|
+
success: false,
|
|
470
|
+
error: 'Failed to parse AI response',
|
|
471
|
+
rawResponse: analysis
|
|
472
|
+
};
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
```
|
|
477
|
+
|
|
478
|
+
### Creative Writing Assistant
|
|
479
|
+
|
|
480
|
+
```typescript
|
|
481
|
+
import { LuaTool, AI } from 'lua-cli/skill';
|
|
482
|
+
import { z } from 'zod';
|
|
483
|
+
|
|
484
|
+
export default class CreativeWritingTool implements LuaTool {
|
|
485
|
+
name = 'write_creative_content';
|
|
486
|
+
description = 'Generate creative content (stories, poems, descriptions)';
|
|
487
|
+
|
|
488
|
+
inputSchema = z.object({
|
|
489
|
+
type: z.enum(['story', 'poem', 'description', 'dialogue']),
|
|
490
|
+
prompt: z.string(),
|
|
491
|
+
style: z.string().optional(),
|
|
492
|
+
length: z.enum(['short', 'medium', 'long']).optional()
|
|
493
|
+
});
|
|
494
|
+
|
|
495
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
496
|
+
const lengthGuide = {
|
|
497
|
+
short: '1-2 paragraphs',
|
|
498
|
+
medium: '3-5 paragraphs',
|
|
499
|
+
long: '6-10 paragraphs'
|
|
500
|
+
};
|
|
501
|
+
|
|
502
|
+
const length = lengthGuide[input.length || 'medium'];
|
|
503
|
+
const style = input.style || 'engaging and creative';
|
|
504
|
+
|
|
505
|
+
const contexts = {
|
|
506
|
+
story: `You are a creative fiction writer. Write ${length} of an ${style} story based on the prompt.`,
|
|
507
|
+
poem: `You are a poet. Write a ${style} poem based on the theme.`,
|
|
508
|
+
description: `You are a descriptive writer. Create a vivid ${length} description.`,
|
|
509
|
+
dialogue: `You are a screenwriter. Write ${length} of natural, ${style} dialogue.`
|
|
510
|
+
};
|
|
511
|
+
|
|
512
|
+
const content = await AI.generate(
|
|
513
|
+
contexts[input.type],
|
|
514
|
+
[{
|
|
515
|
+
type: 'text',
|
|
516
|
+
text: input.prompt
|
|
517
|
+
}]
|
|
518
|
+
);
|
|
519
|
+
|
|
520
|
+
return {
|
|
521
|
+
success: true,
|
|
522
|
+
type: input.type,
|
|
523
|
+
content,
|
|
524
|
+
wordCount: content.split(/\s+/).length
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
```
|
|
529
|
+
|
|
530
|
+
### Email Draft Generator
|
|
531
|
+
|
|
532
|
+
```typescript
|
|
533
|
+
import { LuaTool, AI, User } from 'lua-cli/skill';
|
|
534
|
+
import { z } from 'zod';
|
|
535
|
+
|
|
536
|
+
export default class DraftEmailTool implements LuaTool {
|
|
537
|
+
name = 'draft_email';
|
|
538
|
+
description = 'Generate professional email drafts';
|
|
539
|
+
|
|
540
|
+
inputSchema = z.object({
|
|
541
|
+
purpose: z.string().describe('What the email is about'),
|
|
542
|
+
recipient: z.string().describe('Who it\'s addressed to'),
|
|
543
|
+
tone: z.enum(['formal', 'friendly', 'urgent']).optional(),
|
|
544
|
+
includeSignature: z.boolean().optional()
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
548
|
+
const tone = input.tone || 'friendly';
|
|
549
|
+
const user = await User.get();
|
|
550
|
+
|
|
551
|
+
const context = `You are a professional email writer.
|
|
552
|
+
|
|
553
|
+
Write a ${tone} email for the following purpose: ${input.purpose}
|
|
554
|
+
|
|
555
|
+
Recipient: ${input.recipient}
|
|
556
|
+
Sender: ${user.data.name || 'User'}
|
|
557
|
+
|
|
558
|
+
Format:
|
|
559
|
+
- Subject line
|
|
560
|
+
- Greeting
|
|
561
|
+
- Body (2-4 paragraphs)
|
|
562
|
+
- Closing${input.includeSignature ? '\n- Signature' : ''}
|
|
563
|
+
|
|
564
|
+
Be clear, concise, and ${tone}.`;
|
|
565
|
+
|
|
566
|
+
const email = await AI.generate(
|
|
567
|
+
context,
|
|
568
|
+
[{
|
|
569
|
+
type: 'text',
|
|
570
|
+
text: 'Generate the email'
|
|
571
|
+
}]
|
|
572
|
+
);
|
|
573
|
+
|
|
574
|
+
return {
|
|
575
|
+
success: true,
|
|
576
|
+
email,
|
|
577
|
+
metadata: {
|
|
578
|
+
tone,
|
|
579
|
+
recipient: input.recipient,
|
|
580
|
+
purpose: input.purpose
|
|
581
|
+
}
|
|
582
|
+
};
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
### Code Explainer
|
|
588
|
+
|
|
589
|
+
```typescript
|
|
590
|
+
import { LuaTool, AI } from 'lua-cli/skill';
|
|
591
|
+
import { z } from 'zod';
|
|
592
|
+
|
|
593
|
+
export default class ExplainCodeTool implements LuaTool {
|
|
594
|
+
name = 'explain_code';
|
|
595
|
+
description = 'Explain code snippets in plain language';
|
|
596
|
+
|
|
597
|
+
inputSchema = z.object({
|
|
598
|
+
code: z.string(),
|
|
599
|
+
language: z.string().optional(),
|
|
600
|
+
level: z.enum(['beginner', 'intermediate', 'expert']).optional()
|
|
601
|
+
});
|
|
602
|
+
|
|
603
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
604
|
+
const level = input.level || 'intermediate';
|
|
605
|
+
const language = input.language || 'auto-detect';
|
|
606
|
+
|
|
607
|
+
const context = `You are a programming instructor explaining code to ${level}-level developers.
|
|
608
|
+
|
|
609
|
+
Language: ${language}
|
|
610
|
+
|
|
611
|
+
Explain:
|
|
612
|
+
1. What the code does (high-level)
|
|
613
|
+
2. How it works (step-by-step)
|
|
614
|
+
3. Key concepts used
|
|
615
|
+
4. Potential improvements or issues
|
|
616
|
+
|
|
617
|
+
Use clear, simple language. Include examples if helpful.`;
|
|
618
|
+
|
|
619
|
+
const explanation = await AI.generate(
|
|
620
|
+
context,
|
|
621
|
+
[{
|
|
622
|
+
type: 'text',
|
|
623
|
+
text: `Explain this code:\n\n\`\`\`${language}\n${input.code}\n\`\`\``
|
|
624
|
+
}]
|
|
625
|
+
);
|
|
626
|
+
|
|
627
|
+
return {
|
|
628
|
+
success: true,
|
|
629
|
+
code: input.code,
|
|
630
|
+
explanation,
|
|
631
|
+
level,
|
|
632
|
+
language
|
|
633
|
+
};
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
```
|
|
637
|
+
|
|
638
|
+
### Multi-Agent Specialist
|
|
639
|
+
|
|
640
|
+
```typescript
|
|
641
|
+
import { LuaTool, AI } from 'lua-cli/skill';
|
|
642
|
+
import { z } from 'zod';
|
|
643
|
+
|
|
644
|
+
export default class GetExpertOpinionTool implements LuaTool {
|
|
645
|
+
name = 'get_expert_opinion';
|
|
646
|
+
description = 'Get expert opinions from specialized AI personas';
|
|
647
|
+
|
|
648
|
+
inputSchema = z.object({
|
|
649
|
+
expertType: z.enum(['lawyer', 'doctor', 'financial', 'technical']),
|
|
650
|
+
question: z.string()
|
|
651
|
+
});
|
|
652
|
+
|
|
653
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
654
|
+
const expertContexts = {
|
|
655
|
+
lawyer: `You are a legal expert providing general legal information.
|
|
656
|
+
Important: This is not legal advice. Recommend consulting a licensed attorney for specific cases.`,
|
|
657
|
+
|
|
658
|
+
doctor: `You are a medical professional providing general health information.
|
|
659
|
+
Important: This is not medical advice. Recommend seeing a healthcare provider for diagnosis/treatment.`,
|
|
660
|
+
|
|
661
|
+
financial: `You are a financial advisor providing general financial guidance.
|
|
662
|
+
Important: This is not financial advice. Recommend consulting a certified financial planner.`,
|
|
663
|
+
|
|
664
|
+
technical: `You are a technical expert with deep knowledge of software, hardware, and technology.
|
|
665
|
+
Provide detailed, accurate technical information.`
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
const opinion = await AI.generate(
|
|
669
|
+
expertContexts[input.expertType],
|
|
670
|
+
[{
|
|
671
|
+
type: 'text',
|
|
672
|
+
text: input.question
|
|
673
|
+
}]
|
|
674
|
+
);
|
|
675
|
+
|
|
676
|
+
return {
|
|
677
|
+
success: true,
|
|
678
|
+
expertType: input.expertType,
|
|
679
|
+
question: input.question,
|
|
680
|
+
opinion,
|
|
681
|
+
disclaimer: 'This is general information only. Consult a licensed professional for specific advice.'
|
|
682
|
+
};
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
```
|
|
686
|
+
|
|
687
|
+
### Conversational Context Builder
|
|
688
|
+
|
|
689
|
+
```typescript
|
|
690
|
+
import { LuaTool, AI, User } from 'lua-cli/skill';
|
|
691
|
+
import { z } from 'zod';
|
|
692
|
+
|
|
693
|
+
export default class ChatWithContextTool implements LuaTool {
|
|
694
|
+
name = 'chat_with_history';
|
|
695
|
+
description = 'Generate AI response with conversation history';
|
|
696
|
+
|
|
697
|
+
inputSchema = z.object({
|
|
698
|
+
newMessage: z.string()
|
|
699
|
+
});
|
|
700
|
+
|
|
701
|
+
async execute(input: z.infer<typeof this.inputSchema>) {
|
|
702
|
+
// Get chat history
|
|
703
|
+
const history = await User.getChatHistory();
|
|
704
|
+
|
|
705
|
+
// Build conversation context
|
|
706
|
+
const conversationContext = history
|
|
707
|
+
.slice(-10) // Last 10 messages
|
|
708
|
+
.map(msg => `${msg.role}: ${msg.content[0]?.text}`)
|
|
709
|
+
.join('\n');
|
|
710
|
+
|
|
711
|
+
const context = `You are continuing a conversation.
|
|
712
|
+
|
|
713
|
+
Previous conversation:
|
|
714
|
+
${conversationContext}
|
|
715
|
+
|
|
716
|
+
Maintain conversation continuity and reference previous topics when relevant.`;
|
|
717
|
+
|
|
718
|
+
const response = await AI.generate(
|
|
719
|
+
context,
|
|
720
|
+
[{
|
|
721
|
+
type: 'text',
|
|
722
|
+
text: input.newMessage
|
|
723
|
+
}]
|
|
724
|
+
);
|
|
725
|
+
|
|
726
|
+
return {
|
|
727
|
+
success: true,
|
|
728
|
+
response,
|
|
729
|
+
contextUsed: history.length
|
|
730
|
+
};
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
```
|
|
734
|
+
|
|
735
|
+
## Using Different Agents
|
|
736
|
+
|
|
737
|
+
```typescript
|
|
738
|
+
// Use a specialized agent for specific tasks
|
|
739
|
+
const technicalResponse = await AI.generate(
|
|
740
|
+
'You are a technical support specialist.',
|
|
741
|
+
[{ type: 'text', text: 'How do I fix error code 500?' }],
|
|
742
|
+
'technical-support-agent-id'
|
|
743
|
+
);
|
|
744
|
+
|
|
745
|
+
const salesResponse = await AI.generate(
|
|
746
|
+
'You are a sales expert.',
|
|
747
|
+
[{ type: 'text', text: 'What are the benefits of product X?' }],
|
|
748
|
+
'sales-agent-id'
|
|
749
|
+
);
|
|
750
|
+
```
|
|
751
|
+
|
|
752
|
+
## Best Practices
|
|
753
|
+
|
|
754
|
+
### ✅ DO
|
|
755
|
+
|
|
756
|
+
- Provide clear, specific context
|
|
757
|
+
- Include relevant data in the context
|
|
758
|
+
- Use appropriate message types (text, image, file)
|
|
759
|
+
- Handle AI responses that may vary
|
|
760
|
+
- Include error handling
|
|
761
|
+
- Set expectations in context (format, length, style)
|
|
762
|
+
|
|
763
|
+
### ❌ DON'T
|
|
764
|
+
|
|
765
|
+
- Don't expect exact JSON without clear instructions
|
|
766
|
+
- Don't use AI for simple logic (if/else, calculations)
|
|
767
|
+
- Don't expose sensitive data in context
|
|
768
|
+
- Don't make critical decisions purely on AI output
|
|
769
|
+
- Don't forget to validate/sanitize AI responses
|
|
770
|
+
|
|
771
|
+
## Context Writing Tips
|
|
772
|
+
|
|
773
|
+
### Clear Instructions
|
|
774
|
+
|
|
775
|
+
```typescript
|
|
776
|
+
// ✅ Good - Specific and clear
|
|
777
|
+
const context = `You are a product reviewer.
|
|
778
|
+
Rate products on:
|
|
779
|
+
1. Quality (1-10)
|
|
780
|
+
2. Value (1-10)
|
|
781
|
+
3. Features (1-10)
|
|
782
|
+
|
|
783
|
+
Return ONLY a JSON object with these ratings.`;
|
|
784
|
+
|
|
785
|
+
// ❌ Bad - Vague
|
|
786
|
+
const context = `Review this product`;
|
|
787
|
+
```
|
|
788
|
+
|
|
789
|
+
### Structured Output
|
|
790
|
+
|
|
791
|
+
```typescript
|
|
792
|
+
// ✅ Good - Request specific format
|
|
793
|
+
const context = `Analyze the text and return JSON:
|
|
794
|
+
{
|
|
795
|
+
"summary": "brief summary",
|
|
796
|
+
"keyPoints": ["point 1", "point 2"],
|
|
797
|
+
"sentiment": "positive|negative|neutral"
|
|
798
|
+
}`;
|
|
799
|
+
|
|
800
|
+
// ❌ Bad - Free-form output
|
|
801
|
+
const context = `Analyze the text`;
|
|
802
|
+
```
|
|
803
|
+
|
|
804
|
+
### Example-Driven
|
|
805
|
+
|
|
806
|
+
```typescript
|
|
807
|
+
// ✅ Good - Include examples
|
|
808
|
+
const context = `Extract product names from text.
|
|
809
|
+
|
|
810
|
+
Examples:
|
|
811
|
+
"I want to buy an iPhone" → ["iPhone"]
|
|
812
|
+
"Looking for Nike shoes and Adidas jacket" → ["Nike shoes", "Adidas jacket"]
|
|
813
|
+
|
|
814
|
+
Return array of product names only.`;
|
|
815
|
+
```
|
|
816
|
+
|
|
817
|
+
## Error Handling
|
|
818
|
+
|
|
819
|
+
```typescript
|
|
820
|
+
try {
|
|
821
|
+
const response = await AI.generate(context, messages);
|
|
822
|
+
|
|
823
|
+
// Validate response
|
|
824
|
+
if (!response || response.trim().length === 0) {
|
|
825
|
+
return {
|
|
826
|
+
success: false,
|
|
827
|
+
error: 'AI returned empty response'
|
|
828
|
+
};
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
return {
|
|
832
|
+
success: true,
|
|
833
|
+
response
|
|
834
|
+
};
|
|
835
|
+
} catch (error) {
|
|
836
|
+
return {
|
|
837
|
+
success: false,
|
|
838
|
+
error: error instanceof Error ? error.message : 'AI generation failed'
|
|
839
|
+
};
|
|
840
|
+
}
|
|
841
|
+
```
|
|
842
|
+
|
|
843
|
+
## Performance Considerations
|
|
844
|
+
|
|
845
|
+
- AI generation takes 1-5 seconds typically
|
|
846
|
+
- Longer/more complex requests take more time
|
|
847
|
+
- Image analysis is slower than text
|
|
848
|
+
- Consider using typing indicators in chat
|
|
849
|
+
- Cache common AI responses when possible
|
|
850
|
+
|
|
851
|
+
## Limitations
|
|
852
|
+
|
|
853
|
+
- Maximum context length varies by model
|
|
854
|
+
- Image size limits apply
|
|
855
|
+
- File types supported: PDF, images, text
|
|
856
|
+
- Response may vary between calls (non-deterministic)
|
|
857
|
+
- Some content may be filtered for safety
|
|
858
|
+
|
|
859
|
+
## Common Use Cases
|
|
860
|
+
|
|
861
|
+
| Use Case | Example |
|
|
862
|
+
|----------|---------|
|
|
863
|
+
| Content generation | Product descriptions, email drafts, social media posts |
|
|
864
|
+
| Analysis | Sentiment analysis, image recognition, document review |
|
|
865
|
+
| Translation | Multi-language support |
|
|
866
|
+
| Summarization | Long documents, articles, conversations |
|
|
867
|
+
| Recommendations | Product suggestions, content curation |
|
|
868
|
+
| Moderation | Content filtering, safety checks |
|
|
869
|
+
| Q&A | Document queries, knowledge retrieval |
|
|
870
|
+
|
|
871
|
+
## Related APIs
|
|
872
|
+
|
|
873
|
+
- [User API](./User.md) - Get user context for personalization
|
|
874
|
+
- [Data API](./Data.md) - Store AI-generated content
|
|
875
|
+
- [Jobs API](./Jobs.md) - Schedule AI tasks
|
|
876
|
+
|
|
877
|
+
## See Also
|
|
878
|
+
|
|
879
|
+
- [AI Integration Patterns](../guides/AIPatterns.md)
|
|
880
|
+
- [Multi-Modal Examples](../guides/MultiModalAI.md)
|
|
881
|
+
- [Context Engineering Guide](../guides/ContextEngineering.md)
|
|
882
|
+
|