lua-cli 2.5.8 → 3.0.0-alpha.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.
Files changed (98) hide show
  1. package/dist/api/job.api.service.d.ts +210 -0
  2. package/dist/api/job.api.service.js +200 -0
  3. package/dist/api/lazy-instances.d.ts +24 -0
  4. package/dist/api/lazy-instances.js +48 -0
  5. package/dist/api/postprocessor.api.service.d.ts +98 -0
  6. package/dist/api/postprocessor.api.service.js +76 -0
  7. package/dist/api/preprocessor.api.service.d.ts +98 -0
  8. package/dist/api/preprocessor.api.service.js +76 -0
  9. package/dist/api/user.data.api.service.d.ts +13 -0
  10. package/dist/api/user.data.api.service.js +20 -0
  11. package/dist/api/webhook.api.service.d.ts +151 -0
  12. package/dist/api/webhook.api.service.js +134 -0
  13. package/dist/api-exports.d.ts +156 -41
  14. package/dist/api-exports.js +182 -21
  15. package/dist/cli/command-definitions.js +75 -5
  16. package/dist/commands/compile.js +124 -5
  17. package/dist/commands/index.d.ts +4 -0
  18. package/dist/commands/index.js +4 -0
  19. package/dist/commands/init.js +53 -7
  20. package/dist/commands/jobs.d.ts +20 -0
  21. package/dist/commands/jobs.js +533 -0
  22. package/dist/commands/logs.js +2 -5
  23. package/dist/commands/postprocessors.d.ts +8 -0
  24. package/dist/commands/postprocessors.js +431 -0
  25. package/dist/commands/preprocessors.d.ts +8 -0
  26. package/dist/commands/preprocessors.js +431 -0
  27. package/dist/commands/push.js +684 -5
  28. package/dist/commands/test.d.ts +9 -18
  29. package/dist/commands/test.js +558 -82
  30. package/dist/commands/webhooks.d.ts +18 -0
  31. package/dist/commands/webhooks.js +424 -0
  32. package/dist/common/job.instance.d.ts +77 -0
  33. package/dist/common/job.instance.js +108 -0
  34. package/dist/common/user.instance.d.ts +1 -0
  35. package/dist/common/user.instance.js +9 -0
  36. package/dist/config/constants.d.ts +2 -2
  37. package/dist/config/constants.js +4 -4
  38. package/dist/interfaces/agent.d.ts +2 -1
  39. package/dist/interfaces/chat.d.ts +22 -0
  40. package/dist/interfaces/index.d.ts +10 -0
  41. package/dist/interfaces/index.js +7 -0
  42. package/dist/interfaces/jobs.d.ts +172 -0
  43. package/dist/interfaces/jobs.js +5 -0
  44. package/dist/interfaces/postprocessors.d.ts +35 -0
  45. package/dist/interfaces/postprocessors.js +4 -0
  46. package/dist/interfaces/preprocessors.d.ts +35 -0
  47. package/dist/interfaces/preprocessors.js +4 -0
  48. package/dist/interfaces/webhooks.d.ts +104 -0
  49. package/dist/interfaces/webhooks.js +5 -0
  50. package/dist/types/api-contracts.d.ts +5 -0
  51. package/dist/types/compile.types.d.ts +49 -0
  52. package/dist/types/index.d.ts +1 -1
  53. package/dist/types/index.js +1 -1
  54. package/dist/types/skill.d.ts +502 -0
  55. package/dist/types/skill.js +477 -0
  56. package/dist/utils/agent-management.d.ts +25 -0
  57. package/dist/utils/agent-management.js +67 -0
  58. package/dist/utils/bundling.d.ts +31 -1
  59. package/dist/utils/bundling.js +653 -10
  60. package/dist/utils/compile.d.ts +63 -0
  61. package/dist/utils/compile.js +691 -36
  62. package/dist/utils/deployment.d.ts +2 -1
  63. package/dist/utils/deployment.js +16 -2
  64. package/dist/utils/init-agent.d.ts +3 -1
  65. package/dist/utils/init-agent.js +6 -4
  66. package/dist/utils/init-prompts.d.ts +2 -1
  67. package/dist/utils/init-prompts.js +14 -9
  68. package/dist/utils/job-management.d.ts +24 -0
  69. package/dist/utils/job-management.js +264 -0
  70. package/dist/utils/postprocessor-management.d.ts +9 -0
  71. package/dist/utils/postprocessor-management.js +118 -0
  72. package/dist/utils/preprocessor-management.d.ts +9 -0
  73. package/dist/utils/preprocessor-management.js +118 -0
  74. package/dist/utils/sandbox.d.ts +61 -1
  75. package/dist/utils/sandbox.js +283 -72
  76. package/dist/utils/tool-detection.d.ts +3 -2
  77. package/dist/utils/tool-detection.js +18 -4
  78. package/dist/utils/webhook-management.d.ts +24 -0
  79. package/dist/utils/webhook-management.js +256 -0
  80. package/package.json +1 -1
  81. package/template/AGENT_CONFIGURATION.md +251 -0
  82. package/template/COMPLEX_JOB_EXAMPLES.md +795 -0
  83. package/template/DYNAMIC_JOB_CREATION.md +371 -0
  84. package/template/README.md +30 -2
  85. package/template/WEBHOOKS_JOBS_QUICKSTART.md +318 -0
  86. package/template/WEBHOOK_JOB_EXAMPLES.md +817 -0
  87. package/template/src/index-agent-example.ts +201 -0
  88. package/template/src/index.ts +39 -0
  89. package/template/src/jobs/AbandonedBasketProcessorJob.ts +139 -0
  90. package/template/src/jobs/DailyCleanupJob.ts +100 -0
  91. package/template/src/jobs/DataMigrationJob.ts +133 -0
  92. package/template/src/jobs/HealthCheckJob.ts +87 -0
  93. package/template/src/postprocessors/ResponseFormatter.ts +151 -0
  94. package/template/src/preprocessors/MessageFilter.ts +91 -0
  95. package/template/src/tools/GameScoreTrackerTool.ts +356 -0
  96. package/template/src/tools/SmartBasketTool.ts +188 -0
  97. package/template/src/webhooks/PaymentWebhook.ts +113 -0
  98. package/template/src/webhooks/UserEventWebhook.ts +77 -0
@@ -2,7 +2,7 @@
2
2
  * Command Definitions
3
3
  * Centralized command structure for the CLI
4
4
  */
5
- import { configureCommand, initCommand, destroyCommand, apiKeyCommand, compileCommand, testCommand, pushCommand, deployCommand, chatCommand, chatClearCommand, envCommand, personaCommand, productionCommand, resourcesCommand, adminCommand, docsCommand, channelsCommand, logsCommand, completionCommand, skillsCommand, featuresCommand } from "../commands/index.js";
5
+ import { configureCommand, initCommand, destroyCommand, apiKeyCommand, compileCommand, testCommand, pushCommand, deployCommand, chatCommand, chatClearCommand, envCommand, personaCommand, productionCommand, resourcesCommand, adminCommand, docsCommand, channelsCommand, logsCommand, completionCommand, skillsCommand, webhooksCommand, jobsCommand, featuresCommand, preprocessorsCommand, postprocessorsCommand } from "../commands/index.js";
6
6
  /**
7
7
  * Sets up authentication-related commands.
8
8
  *
@@ -53,20 +53,32 @@ export function setupSkillCommands(program) {
53
53
  .description("šŸ“¦ Compile skill to deployable format")
54
54
  .action(compileCommand);
55
55
  program
56
- .command("test")
57
- .description("🧪 Test skill tools interactively")
56
+ .command("test [type]")
57
+ .description("🧪 Test skills, webhooks, or jobs interactively")
58
+ .addHelpText('after', `
59
+ Arguments:
60
+ type Optional: 'skill', 'webhook', or 'job' (prompts if not provided)
61
+
62
+ Examples:
63
+ $ lua test Interactive selection
64
+ $ lua test skill Test a skill/tool directly
65
+ $ lua test webhook Test a webhook with query/headers/body
66
+ $ lua test job Test a job by executing it
67
+ `)
58
68
  .action(testCommand);
59
69
  // Deployment Commands
60
70
  program
61
71
  .command("push [type]")
62
- .description("ā˜ļø Push skill or persona version to server")
72
+ .description("ā˜ļø Push skill, webhook, job, or persona version to server")
63
73
  .addHelpText('after', `
64
74
  Arguments:
65
- type Optional: 'skill' or 'persona' (prompts if not provided)
75
+ type Optional: 'skill', 'webhook', 'job', or 'persona' (prompts if not provided)
66
76
 
67
77
  Examples:
68
78
  $ lua push Interactive selection
69
79
  $ lua push skill Push a skill directly
80
+ $ lua push webhook Push a webhook directly
81
+ $ lua push job Push a job directly
70
82
  $ lua push persona Push a persona directly
71
83
  `)
72
84
  .action(pushCommand);
@@ -160,6 +172,34 @@ Examples:
160
172
  $ lua skills production Manage production skills directly
161
173
  `)
162
174
  .action(skillsCommand);
175
+ program
176
+ .command("webhooks [env]")
177
+ .description("šŸŖ Manage and view webhooks")
178
+ .addHelpText('after', `
179
+ Arguments:
180
+ env Optional: 'sandbox', 'staging', or 'production' (prompts if not provided)
181
+
182
+ Examples:
183
+ $ lua webhooks Interactive selection
184
+ $ lua webhooks sandbox View sandbox webhooks directly
185
+ $ lua webhooks staging View staging webhooks (alias for sandbox)
186
+ $ lua webhooks production Manage production webhooks directly
187
+ `)
188
+ .action(webhooksCommand);
189
+ program
190
+ .command("jobs [env]")
191
+ .description("ā° Manage and view scheduled jobs")
192
+ .addHelpText('after', `
193
+ Arguments:
194
+ env Optional: 'sandbox', 'staging', or 'production' (prompts if not provided)
195
+
196
+ Examples:
197
+ $ lua jobs Interactive selection
198
+ $ lua jobs sandbox View sandbox jobs directly
199
+ $ lua jobs staging View staging jobs (alias for sandbox)
200
+ $ lua jobs production Manage production jobs (pause/resume/trigger)
201
+ `)
202
+ .action(jobsCommand);
163
203
  program
164
204
  .command("features")
165
205
  .description("šŸŽÆ Manage agent features (tickets, RAG, etc.)")
@@ -174,6 +214,36 @@ Examples:
174
214
  $ lua features View and manage all agent features
175
215
  `)
176
216
  .action(featuresCommand);
217
+ program
218
+ .command("preprocessors")
219
+ .description("šŸ“„ Manage message preprocessors")
220
+ .addHelpText('after', `
221
+ Features:
222
+ • View deployed preprocessors
223
+ • View preprocessor versions
224
+ • Deploy versions to production
225
+ • Activate/deactivate preprocessors
226
+ • Delete preprocessors
227
+
228
+ Examples:
229
+ $ lua preprocessors Manage production preprocessors
230
+ `)
231
+ .action(preprocessorsCommand);
232
+ program
233
+ .command("postprocessors")
234
+ .description("šŸ“¤ Manage response postprocessors")
235
+ .addHelpText('after', `
236
+ Features:
237
+ • View deployed postprocessors
238
+ • View postprocessor versions
239
+ • Deploy versions to production
240
+ • Activate/deactivate postprocessors
241
+ • Delete postprocessors
242
+
243
+ Examples:
244
+ $ lua postprocessors Manage production postprocessors
245
+ `)
246
+ .action(postprocessorsCommand);
177
247
  program
178
248
  .command("completion [shell]")
179
249
  .description("šŸŽÆ Generate shell completion script")
@@ -6,13 +6,18 @@ import fs from "fs";
6
6
  import path from "path";
7
7
  import { Project } from "ts-morph";
8
8
  import { withErrorHandling, writeProgress, writeSuccess } from "../utils/cli.js";
9
- import { findIndexFile } from '../utils/compile.js';
9
+ import { findIndexFile, extractWebhooksMetadata, extractJobsMetadata, extractPreProcessorsMetadata, extractPostProcessorsMetadata } from '../utils/compile.js';
10
10
  import { detectTools } from '../utils/tool-detection.js';
11
- import { bundleTool, bundleMainIndex, extractExecuteCode } from '../utils/bundling.js';
11
+ import { bundleTool, bundleMainIndex, extractExecuteCode, bundleWebhook, bundleJob, bundlePreProcessor, bundlePostProcessor } from '../utils/bundling.js';
12
12
  import { createDeploymentData, createLegacyDeploymentData } from '../utils/deployment.js';
13
13
  import { syncYamlWithDeployJson, syncServerSkillsWithYaml } from '../utils/skill-management.js';
14
+ import { ensureWebhooksExistInYaml, syncServerWebhooksWithYaml } from '../utils/webhook-management.js';
15
+ import { ensureJobsExistInYaml, syncServerJobsWithYaml } from '../utils/job-management.js';
16
+ import { ensurePreProcessorsExistInYaml, syncServerPreProcessorsWithYaml } from '../utils/preprocessor-management.js';
17
+ import { ensurePostProcessorsExistInYaml, syncServerPostProcessorsWithYaml } from '../utils/postprocessor-management.js';
14
18
  import { readSkillConfig } from '../utils/files.js';
15
19
  import { COMPILE_DIRS, COMPILE_FILES } from '../config/compile.constants.js';
20
+ import { syncAgentPersonaWithYaml } from '../utils/agent-management.js';
16
21
  /**
17
22
  * Main compile command - orchestrates the entire skill compilation process.
18
23
  *
@@ -49,7 +54,28 @@ export async function compileCommand() {
49
54
  const indexPath = findIndexFile();
50
55
  const project = createTypeScriptProject();
51
56
  const indexFile = project.addSourceFileAtPath(indexPath);
52
- const tools = await detectTools(indexFile, project);
57
+ // Step 2a: Check for LuaAgent (unified agent configuration)
58
+ writeProgress("šŸ” Checking for LuaAgent configuration...");
59
+ const { extractLuaAgentMetadata, resolveLuaAgentReferences, getSkillFilePaths } = await import('../utils/compile.js');
60
+ const agentMetadata = extractLuaAgentMetadata(indexFile);
61
+ let skillFilePaths = [];
62
+ let resolvedAgentData = null;
63
+ if (agentMetadata) {
64
+ writeProgress(`✨ Found LuaAgent: ${agentMetadata.name}`);
65
+ writeProgress(` Using new unified agent configuration approach`);
66
+ // Sync persona and welcome message with YAML
67
+ await syncAgentPersonaWithYaml(agentMetadata);
68
+ // Resolve references to get actual metadata for all components
69
+ resolvedAgentData = resolveLuaAgentReferences(agentMetadata, indexFile, project);
70
+ // Get file paths where skills are defined so we can scan them for tools
71
+ skillFilePaths = getSkillFilePaths(agentMetadata, indexFile);
72
+ writeProgress(`šŸ“¦ Agent contains: ${resolvedAgentData.skills.length} skill(s), ${resolvedAgentData.webhooks.length} webhook(s), ${resolvedAgentData.jobs.length} job(s), ${resolvedAgentData.preProcessors.length} preprocessor(s), ${resolvedAgentData.postProcessors.length} postprocessor(s)`);
73
+ }
74
+ else {
75
+ writeProgress(`ā„¹ļø No LuaAgent found, using legacy detection for individual components`);
76
+ }
77
+ // Step 2b: Detect tools from index file and skill files
78
+ const tools = await detectTools(indexFile, project, skillFilePaths);
53
79
  writeProgress(`šŸ“¦ Found ${tools.length} tools to bundle...`);
54
80
  // Step 3: Bundle each tool and extract metadata
55
81
  for (const tool of tools) {
@@ -60,7 +86,7 @@ export async function compileCommand() {
60
86
  await bundleMainIndex(indexPath, distDir);
61
87
  // Step 5: Create deployment data in both formats
62
88
  await createDeploymentData(tools, distDir);
63
- await createLegacyDeploymentData(tools, luaDir, indexFile);
89
+ await createLegacyDeploymentData(tools, luaDir, indexFile, resolvedAgentData);
64
90
  // Step 6: Sync YAML with deploy.json
65
91
  writeProgress("šŸ”„ Syncing YAML with deploy.json...");
66
92
  const deployJsonPath = path.join(luaDir, COMPILE_FILES.DEPLOY_JSON);
@@ -70,7 +96,100 @@ export async function compileCommand() {
70
96
  writeProgress("šŸ”„ Syncing server with YAML...");
71
97
  const updatedConfig = readSkillConfig(); // Re-read config after YAML sync
72
98
  await syncServerSkillsWithYaml(updatedConfig);
73
- writeSuccess(`āœ… Skill compiled successfully - ${tools.length} tools bundled`);
99
+ // Step 8: Detect and process webhooks
100
+ writeProgress("šŸ” Detecting webhooks...");
101
+ // Use resolved agent webhooks if available, otherwise scan index file
102
+ let webhooksMetadata = resolvedAgentData?.webhooks || extractWebhooksMetadata(indexFile);
103
+ let bundledWebhooks = [];
104
+ if (webhooksMetadata.length > 0) {
105
+ writeProgress(`šŸ“¦ Found ${webhooksMetadata.length} webhook(s)...`);
106
+ // Bundle each webhook (extract execute function and schemas)
107
+ for (const webhook of webhooksMetadata) {
108
+ const bundled = await bundleWebhook(webhook, indexFile, distDir, project);
109
+ bundledWebhooks.push(bundled);
110
+ }
111
+ // Ensure webhooks exist in YAML with valid IDs
112
+ const configForWebhooks = readSkillConfig(); // Re-read for webhooks
113
+ await ensureWebhooksExistInYaml(webhooksMetadata, configForWebhooks);
114
+ // Sync server webhooks with YAML
115
+ writeProgress("šŸ”„ Syncing server webhooks with YAML...");
116
+ const webhookConfig = readSkillConfig(); // Re-read after webhook updates
117
+ await syncServerWebhooksWithYaml(webhookConfig);
118
+ // Write bundled webhooks to file for reference
119
+ fs.writeFileSync(path.join(distDir, 'webhooks.json'), JSON.stringify(bundledWebhooks, null, 2));
120
+ }
121
+ // Step 9: Detect and process jobs
122
+ writeProgress("šŸ” Detecting jobs...");
123
+ // Use resolved agent jobs if available, otherwise scan index file
124
+ let jobsMetadata = resolvedAgentData?.jobs || extractJobsMetadata(indexFile);
125
+ let bundledJobs = [];
126
+ if (jobsMetadata.length > 0) {
127
+ writeProgress(`šŸ“¦ Found ${jobsMetadata.length} job(s)...`);
128
+ // Bundle each job (extract execute function)
129
+ for (const job of jobsMetadata) {
130
+ const bundled = await bundleJob(job, indexFile, distDir, project);
131
+ bundledJobs.push(bundled);
132
+ }
133
+ // Ensure jobs exist in YAML with valid IDs
134
+ const configForJobs = readSkillConfig(); // Re-read for jobs
135
+ await ensureJobsExistInYaml(jobsMetadata, configForJobs);
136
+ // Sync server jobs with YAML
137
+ writeProgress("šŸ”„ Syncing server jobs with YAML...");
138
+ const jobConfig = readSkillConfig(); // Re-read after job updates
139
+ await syncServerJobsWithYaml(jobConfig);
140
+ // Write bundled jobs to file for reference
141
+ fs.writeFileSync(path.join(distDir, 'jobs.json'), JSON.stringify(bundledJobs, null, 2));
142
+ }
143
+ // Step 10: Detect and process preprocessors
144
+ writeProgress("šŸ” Detecting preprocessors...");
145
+ // Use resolved agent preprocessors if available, otherwise scan index file
146
+ let preprocessorsMetadata = resolvedAgentData?.preProcessors || extractPreProcessorsMetadata(indexFile);
147
+ let bundledPreProcessors = [];
148
+ if (preprocessorsMetadata.length > 0) {
149
+ writeProgress(`šŸ“¦ Found ${preprocessorsMetadata.length} preprocessor(s)...`);
150
+ for (const preprocessor of preprocessorsMetadata) {
151
+ const bundled = await bundlePreProcessor(preprocessor, indexFile, distDir, project);
152
+ bundledPreProcessors.push(bundled);
153
+ }
154
+ // Ensure preprocessors exist in YAML with valid IDs
155
+ const configForPreProcessors = readSkillConfig();
156
+ await ensurePreProcessorsExistInYaml(preprocessorsMetadata, configForPreProcessors);
157
+ // Sync server preprocessors with YAML
158
+ writeProgress("šŸ”„ Syncing server preprocessors with YAML...");
159
+ const preprocessorConfig = readSkillConfig();
160
+ await syncServerPreProcessorsWithYaml(preprocessorConfig);
161
+ fs.writeFileSync(path.join(distDir, 'preprocessors.json'), JSON.stringify(bundledPreProcessors, null, 2));
162
+ }
163
+ // Step 11: Detect and process postprocessors
164
+ writeProgress("šŸ” Detecting postprocessors...");
165
+ // Use resolved agent postprocessors if available, otherwise scan index file
166
+ let postprocessorsMetadata = resolvedAgentData?.postProcessors || extractPostProcessorsMetadata(indexFile);
167
+ let bundledPostProcessors = [];
168
+ if (postprocessorsMetadata.length > 0) {
169
+ writeProgress(`šŸ“¦ Found ${postprocessorsMetadata.length} postprocessor(s)...`);
170
+ for (const postprocessor of postprocessorsMetadata) {
171
+ const bundled = await bundlePostProcessor(postprocessor, indexFile, distDir, project);
172
+ bundledPostProcessors.push(bundled);
173
+ }
174
+ // Ensure postprocessors exist in YAML with valid IDs
175
+ const configForPostProcessors = readSkillConfig();
176
+ await ensurePostProcessorsExistInYaml(postprocessorsMetadata, configForPostProcessors);
177
+ // Sync server postprocessors with YAML
178
+ writeProgress("šŸ”„ Syncing server postprocessors with YAML...");
179
+ const postprocessorConfig = readSkillConfig();
180
+ await syncServerPostProcessorsWithYaml(postprocessorConfig);
181
+ fs.writeFileSync(path.join(distDir, 'postprocessors.json'), JSON.stringify(bundledPostProcessors, null, 2));
182
+ }
183
+ const summaryParts = [`${tools.length} tools bundled`];
184
+ if (webhooksMetadata.length > 0)
185
+ summaryParts.push(`${webhooksMetadata.length} webhook(s) registered`);
186
+ if (jobsMetadata.length > 0)
187
+ summaryParts.push(`${jobsMetadata.length} job(s) registered`);
188
+ if (preprocessorsMetadata.length > 0)
189
+ summaryParts.push(`${preprocessorsMetadata.length} preprocessor(s) registered`);
190
+ if (postprocessorsMetadata.length > 0)
191
+ summaryParts.push(`${postprocessorsMetadata.length} postprocessor(s) registered`);
192
+ writeSuccess(`āœ… Skill compiled successfully - ${summaryParts.join(', ')}`);
74
193
  }, "compilation");
75
194
  }
76
195
  /**
@@ -19,4 +19,8 @@ export { channelsCommand } from "./channels.js";
19
19
  export { logsCommand } from "./logs.js";
20
20
  export { completionCommand } from "./completion.js";
21
21
  export { skillsCommand } from "./skills.js";
22
+ export { webhooksCommand } from "./webhooks.js";
23
+ export { jobsCommand } from "./jobs.js";
22
24
  export { featuresCommand } from "./features.js";
25
+ export { preprocessorsCommand } from "./preprocessors.js";
26
+ export { postprocessorsCommand } from "./postprocessors.js";
@@ -19,4 +19,8 @@ export { channelsCommand } from "./channels.js";
19
19
  export { logsCommand } from "./logs.js";
20
20
  export { completionCommand } from "./completion.js";
21
21
  export { skillsCommand } from "./skills.js";
22
+ export { webhooksCommand } from "./webhooks.js";
23
+ export { jobsCommand } from "./jobs.js";
22
24
  export { featuresCommand } from "./features.js";
25
+ export { preprocessorsCommand } from "./preprocessors.js";
26
+ export { postprocessorsCommand } from "./postprocessors.js";
@@ -119,7 +119,7 @@ export async function initCommand() {
119
119
  }
120
120
  else {
121
121
  // Step 4b: Create new agent
122
- const result = await createNewAgentFlow(apiKey);
122
+ const result = await createNewAgentFlow(apiKey, userData);
123
123
  selectedAgent = result.agent;
124
124
  selectedOrg = result.org;
125
125
  persona = result.persona;
@@ -172,14 +172,59 @@ async function selectExistingAgent(userData, apiKey) {
172
172
  * Handles the flow for creating a new agent.
173
173
  *
174
174
  * @param apiKey - User's API key
175
+ * @param userData - User data containing organizations
175
176
  * @returns Created agent, organization, and optional persona/welcome message
176
177
  */
177
- async function createNewAgentFlow(apiKey) {
178
+ async function createNewAgentFlow(apiKey, userData) {
178
179
  // Fetch and select agent type
179
180
  const agentTypes = await fetchAgentTypes(apiKey);
180
181
  const selectedAgentType = selectBaseAgentType(agentTypes);
182
+ // Ask about organization selection FIRST
183
+ const { orgChoice } = await inquirer.prompt([
184
+ {
185
+ type: 'list',
186
+ name: 'orgChoice',
187
+ message: 'Organization:',
188
+ choices: [
189
+ { name: 'šŸ¢ Use existing organization', value: 'existing' },
190
+ { name: 'āž• Create new organization', value: 'create' }
191
+ ]
192
+ }
193
+ ]);
194
+ let orgId;
195
+ let orgName;
196
+ let usingExistingOrg = false;
197
+ if (orgChoice === 'existing') {
198
+ // Select from existing organizations
199
+ const orgs = userData.admin?.orgs || [];
200
+ if (orgs.length === 0) {
201
+ writeInfo("\nāš ļø No existing organizations found. Creating new organization instead.\n");
202
+ }
203
+ else {
204
+ const selectedOrg = await promptOrganizationSelection(orgs);
205
+ orgId = selectedOrg.id;
206
+ usingExistingOrg = true;
207
+ }
208
+ }
209
+ if (!orgId) {
210
+ // Create new organization - ask for org name
211
+ const { organizationName } = await inquirer.prompt([
212
+ {
213
+ type: 'input',
214
+ name: 'organizationName',
215
+ message: 'Organization name:',
216
+ validate: (input) => {
217
+ if (!input || input.trim() === '') {
218
+ return 'Organization name is required';
219
+ }
220
+ return true;
221
+ }
222
+ }
223
+ ]);
224
+ orgName = organizationName.trim();
225
+ }
181
226
  // Collect required metadata
182
- let linesToClear = 1;
227
+ let linesToClear = 2; // orgChoice + (org selection OR org name)
183
228
  const metadata = selectedAgentType.requiredSubAgentMetadata?.length
184
229
  ? await promptMetadataCollection(selectedAgentType.requiredSubAgentMetadata)
185
230
  : {};
@@ -190,12 +235,13 @@ async function createNewAgentFlow(apiKey) {
190
235
  : {};
191
236
  linesToClear += availableFeatures.length;
192
237
  // Collect business configuration
193
- const businessConfig = await promptBusinessConfiguration();
194
- linesToClear += 5; // businessName, agentName, businessType, brandPersonality, brandTraits
238
+ // If using existing org, don't ask for business name (use org name)
239
+ const businessConfig = await promptBusinessConfiguration(usingExistingOrg);
240
+ linesToClear += usingExistingOrg ? 4 : 5; // Skip businessName prompt if using existing org
195
241
  // Clear all prompts
196
242
  clearLinesIfNeeded(linesToClear);
197
243
  // Create the agent
198
- const result = await createNewAgent(apiKey, selectedAgentType, businessConfig, metadata, features);
244
+ const result = await createNewAgent(apiKey, selectedAgentType, businessConfig, metadata, features, orgId, orgName);
199
245
  return result;
200
246
  }
201
247
  /**
@@ -232,7 +278,7 @@ async function handleAgentSwitch(userData, apiKey, existingYaml) {
232
278
  }
233
279
  else {
234
280
  // Create new agent
235
- const result = await createNewAgentFlow(apiKey);
281
+ const result = await createNewAgentFlow(apiKey, userData);
236
282
  selectedAgent = result.agent;
237
283
  selectedOrg = result.org;
238
284
  persona = result.persona;
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Jobs Command
3
+ * Manages agent scheduled jobs for sandbox and production environments
4
+ */
5
+ /**
6
+ * Main jobs command - manages agent jobs
7
+ *
8
+ * Features:
9
+ * - View deployed jobs
10
+ * - View job versions
11
+ * - Deploy job versions to production
12
+ * - Activate/deactivate, pause/resume jobs
13
+ * - Trigger jobs manually
14
+ * - View execution history
15
+ *
16
+ * Note: For local testing, use `lua test job`
17
+ *
18
+ * @returns Promise that resolves when command completes
19
+ */
20
+ export declare function jobsCommand(): Promise<void>;