@thinksoftai/cli 1.5.0 → 1.6.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/index.js CHANGED
@@ -2,7 +2,7 @@
2
2
  "use strict";
3
3
  /**
4
4
  * ThinkSoft CLI
5
- * Deploy apps to ThinkSoft platform
5
+ * Create & Deploy apps to ThinkSoft platform
6
6
  */
7
7
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
8
  if (k2 === undefined) k2 = k;
@@ -52,11 +52,17 @@ const deploy_1 = require("./commands/deploy");
52
52
  const open_1 = require("./commands/open");
53
53
  const dev_1 = require("./commands/dev");
54
54
  const frontend_1 = require("./commands/frontend");
55
+ const agents_1 = require("./commands/agents");
56
+ const schema = __importStar(require("./commands/schema"));
57
+ const records = __importStar(require("./commands/records"));
58
+ const rules = __importStar(require("./commands/rules"));
59
+ const chat_1 = require("./commands/chat");
60
+ const studio_1 = require("./commands/studio");
55
61
  const program = new commander_1.Command();
56
62
  program
57
63
  .name('thinksoft')
58
- .description('ThinkSoft CLI - Deploy apps to ThinkSoft platform')
59
- .version('1.5.0');
64
+ .description('ThinkSoft CLI - Create & Deploy apps to ThinkSoft platform')
65
+ .version('1.6.1');
60
66
  // Login command
61
67
  program
62
68
  .command('login')
@@ -84,7 +90,7 @@ program
84
90
  program
85
91
  .command('create <description>')
86
92
  .description('Create a new app with AI')
87
- .option('-t, --type <type>', 'App type: workapp or storeapp', 'workapp')
93
+ .option('-t, --type <type>', 'App type: work_management or store', 'work_management')
88
94
  .action(create_1.create);
89
95
  // Init command
90
96
  program
@@ -123,6 +129,214 @@ program
123
129
  .option('-a, --app <appId>', 'App ID to scaffold for')
124
130
  .option('-i, --init', 'Initialize new frontend with AI suggestions')
125
131
  .action(frontend_1.frontend);
132
+ // Agents command
133
+ program
134
+ .command('agents [appId]')
135
+ .description('List or add service agents for an app')
136
+ .option('-a, --add <description>', 'Add a new agent with description')
137
+ .action(agents_1.agents);
138
+ // ============================================
139
+ // Schema Commands (CRUD for tables & fields)
140
+ // ============================================
141
+ // Schema list (default)
142
+ program
143
+ .command('schema [appId]')
144
+ .description('List all tables in app schema')
145
+ .option('-t, --table <table>', 'Show details for specific table (legacy)')
146
+ .action((appId, options) => {
147
+ if (options.table) {
148
+ schema.show(options.table, appId);
149
+ }
150
+ else {
151
+ schema.list(appId);
152
+ }
153
+ });
154
+ // Schema show
155
+ program
156
+ .command('schema:show <table> [appId]')
157
+ .description('Show details for a specific table')
158
+ .action(schema.show);
159
+ // Schema create
160
+ program
161
+ .command('schema:create [appId]')
162
+ .description('Create a new table')
163
+ .option('-n, --name <name>', 'Table name')
164
+ .option('-s, --slug <slug>', 'Table slug')
165
+ .option('-i, --icon <icon>', 'Table icon (emoji)')
166
+ .option('-d, --description <desc>', 'Table description')
167
+ .option('-y, --yes', 'Skip confirmation prompts')
168
+ .action(schema.create);
169
+ // Schema update
170
+ program
171
+ .command('schema:update <table> [appId]')
172
+ .description('Update table metadata')
173
+ .option('-n, --name <name>', 'New table name')
174
+ .option('-i, --icon <icon>', 'New icon')
175
+ .option('-d, --description <desc>', 'New description')
176
+ .action(schema.update);
177
+ // Schema delete
178
+ program
179
+ .command('schema:delete <table> [appId]')
180
+ .description('Delete a table')
181
+ .option('-y, --yes', 'Skip confirmation prompt')
182
+ .action(schema.deleteTable);
183
+ // Schema add-field
184
+ program
185
+ .command('schema:add-field <table> [appId]')
186
+ .description('Add a field to a table')
187
+ .option('-n, --name <name>', 'Field name')
188
+ .option('-t, --type <type>', 'Field type (text, number, select, etc.)')
189
+ .option('-r, --required', 'Mark field as required')
190
+ .option('-o, --options <options>', 'Comma-separated options for select/multiselect')
191
+ .action(schema.addField);
192
+ // Schema update-field
193
+ program
194
+ .command('schema:update-field <table> <field> [appId]')
195
+ .description('Update a field in a table')
196
+ .option('-n, --name <name>', 'New field name')
197
+ .option('-t, --type <type>', 'New field type')
198
+ .option('-r, --required', 'Mark field as required')
199
+ .option('-o, --options <options>', 'Comma-separated options')
200
+ .action(schema.updateField);
201
+ // Schema remove-field
202
+ program
203
+ .command('schema:remove-field <table> <field> [appId]')
204
+ .description('Remove a field from a table')
205
+ .option('-y, --yes', 'Skip confirmation prompt')
206
+ .action(schema.removeField);
207
+ // ============================================
208
+ // Records Commands (CRUD for table data)
209
+ // ============================================
210
+ // Records list
211
+ program
212
+ .command('records <table> [appId]')
213
+ .description('List records from a table')
214
+ .option('-l, --limit <limit>', 'Maximum records to return')
215
+ .option('-o, --offset <offset>', 'Number of records to skip')
216
+ .option('-f, --filter <filter>', 'Filter expression')
217
+ .option('-s, --sort <sort>', 'Sort expression')
218
+ .option('--format <format>', 'Output format: json or table', 'table')
219
+ .action((table, appId, options) => records.list(table, appId, options));
220
+ // Records get
221
+ program
222
+ .command('records:get <table> <id> [appId]')
223
+ .description('Get a single record by ID')
224
+ .option('--format <format>', 'Output format: json or table', 'table')
225
+ .action(records.get);
226
+ // Records create
227
+ program
228
+ .command('records:create <table> [appId]')
229
+ .description('Create a new record')
230
+ .option('-d, --data <json>', 'JSON data for the record')
231
+ .action(records.create);
232
+ // Records update
233
+ program
234
+ .command('records:update <table> <id> [appId]')
235
+ .description('Update a record')
236
+ .option('-d, --data <json>', 'JSON data to update')
237
+ .action(records.update);
238
+ // Records delete
239
+ program
240
+ .command('records:delete <table> <id> [appId]')
241
+ .description('Delete a record')
242
+ .option('-y, --yes', 'Skip confirmation prompt')
243
+ .action(records.deleteRecord);
244
+ // ============================================
245
+ // Legacy Record Commands (backward compatibility)
246
+ // ============================================
247
+ // List records command (legacy)
248
+ program
249
+ .command('list [appId] [table]')
250
+ .description('List records from a table (legacy)')
251
+ .option('-l, --limit <limit>', 'Maximum records to return')
252
+ .option('-o, --offset <offset>', 'Number of records to skip')
253
+ .option('-f, --filter <filter>', 'Filter expression')
254
+ .option('-s, --sort <sort>', 'Sort expression')
255
+ .action(records.listRecords);
256
+ // Get record command (legacy)
257
+ program
258
+ .command('get [appId] [table] [id]')
259
+ .description('Get a single record by ID (legacy)')
260
+ .action(records.getRecord);
261
+ // Create record command (legacy)
262
+ program
263
+ .command('create-record [appId] [table]')
264
+ .description('Create a new record (legacy)')
265
+ .option('-d, --data <json>', 'JSON data for the record')
266
+ .action(records.createRecord);
267
+ // Update record command (legacy)
268
+ program
269
+ .command('update [appId] [table] [id]')
270
+ .description('Update a record (legacy)')
271
+ .option('-d, --data <json>', 'JSON data to update')
272
+ .action(records.updateRecord);
273
+ // Delete record command (legacy)
274
+ program
275
+ .command('delete [appId] [table] [id]')
276
+ .description('Delete a record (legacy)')
277
+ .option('-y, --yes', 'Skip confirmation prompt')
278
+ .action((appId, table, id, options) => {
279
+ records.deleteRecord(table, id, appId, options);
280
+ });
281
+ // ============================================
282
+ // Rules Commands (CRUD for agent business rules)
283
+ // ============================================
284
+ // Rules list
285
+ program
286
+ .command('rules <agentSlug> [appId]')
287
+ .description('List all rules for an agent')
288
+ .action(rules.list);
289
+ // Rules show
290
+ program
291
+ .command('rules:show <agentSlug> <ruleId> [appId]')
292
+ .description('Show details for a specific rule')
293
+ .action(rules.show);
294
+ // Rules create
295
+ program
296
+ .command('rules:create <agentSlug> [appId]')
297
+ .description('Create a new rule')
298
+ .option('-d, --data <json>', 'JSON data for the rule')
299
+ .action(rules.create);
300
+ // Rules update
301
+ program
302
+ .command('rules:update <agentSlug> <ruleId> [appId]')
303
+ .description('Update a rule')
304
+ .option('-d, --data <json>', 'JSON data to update')
305
+ .option('--enabled <bool>', 'Enable or disable rule')
306
+ .option('-p, --priority <number>', 'Set rule priority')
307
+ .action(rules.update);
308
+ // Rules delete
309
+ program
310
+ .command('rules:delete <agentSlug> <ruleId> [appId]')
311
+ .description('Delete a rule')
312
+ .option('-y, --yes', 'Skip confirmation prompt')
313
+ .action(rules.deleteRule);
314
+ // Rules enable
315
+ program
316
+ .command('rules:enable <agentSlug> <ruleId> [appId]')
317
+ .description('Enable a rule')
318
+ .action(rules.enable);
319
+ // Rules disable
320
+ program
321
+ .command('rules:disable <agentSlug> <ruleId> [appId]')
322
+ .description('Disable a rule')
323
+ .action(rules.disable);
324
+ // ============================================
325
+ // Chat & Studio Commands
326
+ // ============================================
327
+ // Chat command
328
+ program
329
+ .command('chat [appId] [agentSlug] [message]')
330
+ .description('Chat with a service agent')
331
+ .option('-i, --interactive', 'Start interactive chat mode')
332
+ .option('-s, --session <sessionId>', 'Continue existing session')
333
+ .action(chat_1.chat);
334
+ // Studio command (owner-only app customization)
335
+ program
336
+ .command('studio [appId] [message]')
337
+ .description('Customize app schema & agents with AI (owner only)')
338
+ .option('-i, --interactive', 'Start interactive studio mode')
339
+ .action(studio_1.studio);
126
340
  /**
127
341
  * Interactive Mode
128
342
  */
@@ -138,18 +352,61 @@ function showBanner() {
138
352
  }
139
353
  function showHelp() {
140
354
  console.log();
141
- console.log(chalk_1.default.cyan.bold('Available Commands:'));
355
+ console.log(chalk_1.default.cyan.bold('Authentication:'));
142
356
  console.log();
143
357
  console.log(chalk_1.default.yellow(' login') + chalk_1.default.gray(' [--token <token>]') + chalk_1.default.white(' Authenticate with ThinkSoft'));
144
358
  console.log(chalk_1.default.yellow(' logout') + chalk_1.default.white(' Clear stored credentials'));
145
359
  console.log(chalk_1.default.yellow(' whoami') + chalk_1.default.white(' Show current logged in user'));
360
+ console.log();
361
+ console.log(chalk_1.default.cyan.bold('App Management:'));
362
+ console.log();
146
363
  console.log(chalk_1.default.yellow(' apps') + chalk_1.default.white(' List your apps'));
147
364
  console.log(chalk_1.default.yellow(' create') + chalk_1.default.gray(' "<description>"') + chalk_1.default.white(' Create a new app with AI'));
148
365
  console.log(chalk_1.default.yellow(' init') + chalk_1.default.gray(' [--app <appId>]') + chalk_1.default.white(' Initialize project config'));
149
366
  console.log(chalk_1.default.yellow(' deploy') + chalk_1.default.gray(' [--app <appId>]') + chalk_1.default.white(' Deploy frontend to ThinkSoft'));
150
367
  console.log(chalk_1.default.yellow(' open') + chalk_1.default.gray(' [appId] [--admin]') + chalk_1.default.white(' Open app in browser'));
151
- console.log(chalk_1.default.yellow(' dev') + chalk_1.default.gray(' [--app <appId>] [--init]') + chalk_1.default.white(' AI-assisted frontend development'));
152
- console.log(chalk_1.default.yellow(' frontend') + chalk_1.default.gray(' [--app <appId>] [--init]') + chalk_1.default.white(' Scaffold for external AI tools'));
368
+ console.log(chalk_1.default.yellow(' dev') + chalk_1.default.gray(' [--app <appId>]') + chalk_1.default.white(' AI-assisted development'));
369
+ console.log(chalk_1.default.yellow(' agents') + chalk_1.default.gray(' [appId]') + chalk_1.default.white(' List or add service agents'));
370
+ console.log();
371
+ console.log(chalk_1.default.cyan.bold('Schema Commands:'));
372
+ console.log();
373
+ console.log(chalk_1.default.yellow(' schema') + chalk_1.default.gray(' [appId]') + chalk_1.default.white(' List all tables'));
374
+ console.log(chalk_1.default.yellow(' schema:show') + chalk_1.default.gray(' <table>') + chalk_1.default.white(' Show table details'));
375
+ console.log(chalk_1.default.yellow(' schema:create') + chalk_1.default.white(' Create a new table'));
376
+ console.log(chalk_1.default.yellow(' schema:update') + chalk_1.default.gray(' <table>') + chalk_1.default.white(' Update table metadata'));
377
+ console.log(chalk_1.default.yellow(' schema:delete') + chalk_1.default.gray(' <table>') + chalk_1.default.white(' Delete a table'));
378
+ console.log(chalk_1.default.yellow(' schema:add-field') + chalk_1.default.gray(' <table>') + chalk_1.default.white(' Add a field to table'));
379
+ console.log(chalk_1.default.yellow(' schema:update-field') + chalk_1.default.gray(' <t> <f>') + chalk_1.default.white(' Update a field'));
380
+ console.log(chalk_1.default.yellow(' schema:remove-field') + chalk_1.default.gray(' <t> <f>') + chalk_1.default.white(' Remove a field'));
381
+ console.log();
382
+ console.log(chalk_1.default.cyan.bold('Records Commands:'));
383
+ console.log();
384
+ console.log(chalk_1.default.yellow(' records') + chalk_1.default.gray(' <table>') + chalk_1.default.white(' List records from table'));
385
+ console.log(chalk_1.default.yellow(' records:get') + chalk_1.default.gray(' <table> <id>') + chalk_1.default.white(' Get a record by ID'));
386
+ console.log(chalk_1.default.yellow(' records:create') + chalk_1.default.gray(' <table>') + chalk_1.default.white(' Create a new record'));
387
+ console.log(chalk_1.default.yellow(' records:update') + chalk_1.default.gray(' <t> <id>') + chalk_1.default.white(' Update a record'));
388
+ console.log(chalk_1.default.yellow(' records:delete') + chalk_1.default.gray(' <t> <id>') + chalk_1.default.white(' Delete a record'));
389
+ console.log();
390
+ console.log(chalk_1.default.cyan.bold('Rules Commands:'));
391
+ console.log();
392
+ console.log(chalk_1.default.yellow(' rules') + chalk_1.default.gray(' <agent>') + chalk_1.default.white(' List rules for agent'));
393
+ console.log(chalk_1.default.yellow(' rules:show') + chalk_1.default.gray(' <agent> <id>') + chalk_1.default.white(' Show rule details'));
394
+ console.log(chalk_1.default.yellow(' rules:create') + chalk_1.default.gray(' <agent>') + chalk_1.default.white(' Create a new rule'));
395
+ console.log(chalk_1.default.yellow(' rules:update') + chalk_1.default.gray(' <a> <id>') + chalk_1.default.white(' Update a rule'));
396
+ console.log(chalk_1.default.yellow(' rules:delete') + chalk_1.default.gray(' <a> <id>') + chalk_1.default.white(' Delete a rule'));
397
+ console.log(chalk_1.default.yellow(' rules:enable') + chalk_1.default.gray(' <a> <id>') + chalk_1.default.white(' Enable a rule'));
398
+ console.log(chalk_1.default.yellow(' rules:disable') + chalk_1.default.gray(' <a> <id>') + chalk_1.default.white(' Disable a rule'));
399
+ console.log();
400
+ console.log(chalk_1.default.cyan.bold('Agent Chat:'));
401
+ console.log();
402
+ console.log(chalk_1.default.yellow(' chat') + chalk_1.default.gray(' <appId> <agent> "msg"') + chalk_1.default.white(' Send message to agent'));
403
+ console.log(chalk_1.default.yellow(' chat') + chalk_1.default.gray(' <appId> <agent> -i') + chalk_1.default.white(' Interactive chat mode'));
404
+ console.log();
405
+ console.log(chalk_1.default.cyan.bold('App Studio (Owner Only):'));
406
+ console.log();
407
+ console.log(chalk_1.default.yellow(' studio') + chalk_1.default.gray(' <appId> "msg"') + chalk_1.default.white(' Customize schema/agents with AI'));
408
+ console.log(chalk_1.default.yellow(' studio') + chalk_1.default.gray(' <appId> -i') + chalk_1.default.white(' Interactive studio mode'));
409
+ console.log();
153
410
  console.log(chalk_1.default.yellow(' help') + chalk_1.default.white(' Show this help message'));
154
411
  console.log(chalk_1.default.yellow(' quit') + chalk_1.default.white(' / ') + chalk_1.default.yellow('exit') + chalk_1.default.white(' Exit the CLI'));
155
412
  console.log();
@@ -272,12 +529,290 @@ async function executeCommand(input) {
272
529
  const frontendInitFlag = args.includes('--init') || args.includes('-i');
273
530
  await (0, frontend_1.frontend)({ app: frontendApp, init: frontendInitFlag });
274
531
  break;
532
+ case 'agents':
533
+ const agentsAppId = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
534
+ const addFlag = args.indexOf('--add');
535
+ const addShort = args.indexOf('-a');
536
+ const addIndex = addFlag !== -1 ? addFlag : addShort;
537
+ const addDescription = addIndex !== -1 ? args.slice(addIndex + 1).join(' ') : undefined;
538
+ await (0, agents_1.agents)(agentsAppId, { add: addDescription });
539
+ break;
540
+ // Schema commands
541
+ case 'schema':
542
+ const schemaAppId = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
543
+ const tableFlag = args.indexOf('--table');
544
+ const tableShort = args.indexOf('-t');
545
+ const tableIndex = tableFlag !== -1 ? tableFlag : tableShort;
546
+ const schemaTable = tableIndex !== -1 ? args[tableIndex + 1] : undefined;
547
+ if (schemaTable) {
548
+ await schema.show(schemaTable, schemaAppId);
549
+ }
550
+ else {
551
+ await schema.list(schemaAppId);
552
+ }
553
+ break;
554
+ case 'schema:show':
555
+ const showTable = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
556
+ const showAppId = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
557
+ await schema.show(showTable, showAppId);
558
+ break;
559
+ case 'schema:create':
560
+ const createSchemaAppId = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
561
+ const createNameFlag = args.indexOf('--name') !== -1 ? args[args.indexOf('--name') + 1] : undefined;
562
+ const createSlugFlag = args.indexOf('--slug') !== -1 ? args[args.indexOf('--slug') + 1] : undefined;
563
+ const createIconFlag = args.indexOf('--icon') !== -1 ? args[args.indexOf('--icon') + 1] : undefined;
564
+ const createDescFlag = args.indexOf('--description') !== -1 ? args[args.indexOf('--description') + 1] : undefined;
565
+ const createYesFlag = args.includes('--yes') || args.includes('-y');
566
+ await schema.create(createSchemaAppId, {
567
+ name: createNameFlag,
568
+ slug: createSlugFlag,
569
+ icon: createIconFlag,
570
+ description: createDescFlag,
571
+ yes: createYesFlag
572
+ });
573
+ break;
574
+ case 'schema:update':
575
+ const updateSchemaTable = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
576
+ const updateSchemaAppId = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
577
+ const updateNameFlag = args.indexOf('--name') !== -1 ? args[args.indexOf('--name') + 1] : undefined;
578
+ const updateIconFlag = args.indexOf('--icon') !== -1 ? args[args.indexOf('--icon') + 1] : undefined;
579
+ const updateDescFlag = args.indexOf('--description') !== -1 ? args[args.indexOf('--description') + 1] : undefined;
580
+ await schema.update(updateSchemaTable, updateSchemaAppId, {
581
+ name: updateNameFlag,
582
+ icon: updateIconFlag,
583
+ description: updateDescFlag
584
+ });
585
+ break;
586
+ case 'schema:delete':
587
+ const deleteSchemaTable = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
588
+ const deleteSchemaAppId = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
589
+ const deleteYesFlag = args.includes('--yes') || args.includes('-y');
590
+ await schema.deleteTable(deleteSchemaTable, deleteSchemaAppId, { yes: deleteYesFlag });
591
+ break;
592
+ case 'schema:add-field':
593
+ const addFieldTable = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
594
+ const addFieldAppId = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
595
+ const addFieldNameFlag = args.indexOf('--name') !== -1 ? args[args.indexOf('--name') + 1] : undefined;
596
+ const addFieldTypeFlag = args.indexOf('--type') !== -1 ? args[args.indexOf('--type') + 1] : undefined;
597
+ const addFieldRequiredFlag = args.includes('--required') || args.includes('-r');
598
+ const addFieldOptionsFlag = args.indexOf('--options') !== -1 ? args[args.indexOf('--options') + 1] : undefined;
599
+ await schema.addField(addFieldTable, addFieldAppId, {
600
+ name: addFieldNameFlag,
601
+ type: addFieldTypeFlag,
602
+ required: addFieldRequiredFlag,
603
+ options: addFieldOptionsFlag
604
+ });
605
+ break;
606
+ case 'schema:update-field':
607
+ const updateFieldTable = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
608
+ const updateFieldName = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
609
+ const updateFieldAppId = args[3] && !args[3].startsWith('-') ? args[3] : undefined;
610
+ const updateFieldNewNameFlag = args.indexOf('--name') !== -1 ? args[args.indexOf('--name') + 1] : undefined;
611
+ const updateFieldTypeFlag = args.indexOf('--type') !== -1 ? args[args.indexOf('--type') + 1] : undefined;
612
+ const updateFieldRequiredFlag = args.includes('--required') || args.includes('-r');
613
+ const updateFieldOptionsFlag = args.indexOf('--options') !== -1 ? args[args.indexOf('--options') + 1] : undefined;
614
+ await schema.updateField(updateFieldTable, updateFieldName, updateFieldAppId, {
615
+ name: updateFieldNewNameFlag,
616
+ type: updateFieldTypeFlag,
617
+ required: updateFieldRequiredFlag,
618
+ options: updateFieldOptionsFlag
619
+ });
620
+ break;
621
+ case 'schema:remove-field':
622
+ const removeFieldTable = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
623
+ const removeFieldName = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
624
+ const removeFieldAppId = args[3] && !args[3].startsWith('-') ? args[3] : undefined;
625
+ const removeFieldYesFlag = args.includes('--yes') || args.includes('-y');
626
+ await schema.removeField(removeFieldTable, removeFieldName, removeFieldAppId, { yes: removeFieldYesFlag });
627
+ break;
628
+ // Records commands
629
+ case 'records':
630
+ const recordsTable = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
631
+ const recordsAppId = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
632
+ const recordsLimitFlag = args.indexOf('--limit') !== -1 ? args[args.indexOf('--limit') + 1] : undefined;
633
+ const recordsOffsetFlag = args.indexOf('--offset') !== -1 ? args[args.indexOf('--offset') + 1] : undefined;
634
+ const recordsFilterFlag = args.indexOf('--filter') !== -1 ? args[args.indexOf('--filter') + 1] : undefined;
635
+ const recordsSortFlag = args.indexOf('--sort') !== -1 ? args[args.indexOf('--sort') + 1] : undefined;
636
+ await records.list(recordsTable, recordsAppId, {
637
+ limit: recordsLimitFlag,
638
+ offset: recordsOffsetFlag,
639
+ filter: recordsFilterFlag,
640
+ sort: recordsSortFlag
641
+ });
642
+ break;
643
+ case 'records:get':
644
+ const getRecordTable = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
645
+ const getRecordId = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
646
+ const getRecordAppId = args[3] && !args[3].startsWith('-') ? args[3] : undefined;
647
+ await records.get(getRecordTable, getRecordId, getRecordAppId);
648
+ break;
649
+ case 'records:create':
650
+ const createRecordTable = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
651
+ const createRecordAppId = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
652
+ const createRecordDataFlag = args.indexOf('--data') !== -1 ? args.slice(args.indexOf('--data') + 1).join(' ') : undefined;
653
+ await records.create(createRecordTable, createRecordAppId, { data: createRecordDataFlag });
654
+ break;
655
+ case 'records:update':
656
+ const updateRecordTable = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
657
+ const updateRecordId = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
658
+ const updateRecordAppId = args[3] && !args[3].startsWith('-') ? args[3] : undefined;
659
+ const updateRecordDataFlag = args.indexOf('--data') !== -1 ? args.slice(args.indexOf('--data') + 1).join(' ') : undefined;
660
+ await records.update(updateRecordTable, updateRecordId, updateRecordAppId, { data: updateRecordDataFlag });
661
+ break;
662
+ case 'records:delete':
663
+ const deleteRecordTable = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
664
+ const deleteRecordId = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
665
+ const deleteRecordAppId = args[3] && !args[3].startsWith('-') ? args[3] : undefined;
666
+ const deleteRecordYesFlag = args.includes('--yes') || args.includes('-y');
667
+ await records.deleteRecord(deleteRecordTable, deleteRecordId, deleteRecordAppId, { yes: deleteRecordYesFlag });
668
+ break;
669
+ // Rules commands
670
+ case 'rules':
671
+ const rulesAgentSlug = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
672
+ const rulesAppId = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
673
+ await rules.list(rulesAgentSlug, rulesAppId);
674
+ break;
675
+ case 'rules:show':
676
+ const showRuleAgentSlug = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
677
+ const showRuleId = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
678
+ const showRuleAppId = args[3] && !args[3].startsWith('-') ? args[3] : undefined;
679
+ await rules.show(showRuleAgentSlug, showRuleId, showRuleAppId);
680
+ break;
681
+ case 'rules:create':
682
+ const createRuleAgentSlug = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
683
+ const createRuleAppId = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
684
+ const createRuleDataFlag = args.indexOf('--data') !== -1 ? args.slice(args.indexOf('--data') + 1).join(' ') : undefined;
685
+ await rules.create(createRuleAgentSlug, createRuleAppId, { data: createRuleDataFlag });
686
+ break;
687
+ case 'rules:update':
688
+ const updateRuleAgentSlug = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
689
+ const updateRuleId = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
690
+ const updateRuleAppId = args[3] && !args[3].startsWith('-') ? args[3] : undefined;
691
+ const updateRuleDataFlag = args.indexOf('--data') !== -1 ? args.slice(args.indexOf('--data') + 1).join(' ') : undefined;
692
+ const updateRulePriorityFlag = args.indexOf('--priority') !== -1 ? args[args.indexOf('--priority') + 1] : undefined;
693
+ const updateRuleEnabledFlag = args.indexOf('--enabled') !== -1 ? args[args.indexOf('--enabled') + 1] === 'true' : undefined;
694
+ await rules.update(updateRuleAgentSlug, updateRuleId, updateRuleAppId, {
695
+ data: updateRuleDataFlag,
696
+ priority: updateRulePriorityFlag,
697
+ enabled: updateRuleEnabledFlag
698
+ });
699
+ break;
700
+ case 'rules:delete':
701
+ const deleteRuleAgentSlug = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
702
+ const deleteRuleId = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
703
+ const deleteRuleAppId = args[3] && !args[3].startsWith('-') ? args[3] : undefined;
704
+ const deleteRuleYesFlag = args.includes('--yes') || args.includes('-y');
705
+ await rules.deleteRule(deleteRuleAgentSlug, deleteRuleId, deleteRuleAppId, { yes: deleteRuleYesFlag });
706
+ break;
707
+ case 'rules:enable':
708
+ const enableRuleAgentSlug = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
709
+ const enableRuleId = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
710
+ const enableRuleAppId = args[3] && !args[3].startsWith('-') ? args[3] : undefined;
711
+ await rules.enable(enableRuleAgentSlug, enableRuleId, enableRuleAppId);
712
+ break;
713
+ case 'rules:disable':
714
+ const disableRuleAgentSlug = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
715
+ const disableRuleId = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
716
+ const disableRuleAppId = args[3] && !args[3].startsWith('-') ? args[3] : undefined;
717
+ await rules.disable(disableRuleAgentSlug, disableRuleId, disableRuleAppId);
718
+ break;
719
+ // Legacy record commands
720
+ case 'list':
721
+ const listAppId = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
722
+ const listTable = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
723
+ const limitFlagLegacy = args.indexOf('--limit');
724
+ const limitShortLegacy = args.indexOf('-l');
725
+ const limitIndexLegacy = limitFlagLegacy !== -1 ? limitFlagLegacy : limitShortLegacy;
726
+ const limitVal = limitIndexLegacy !== -1 ? args[limitIndexLegacy + 1] : undefined;
727
+ const offsetFlagLegacy = args.indexOf('--offset');
728
+ const offsetShortLegacy = args.indexOf('-o');
729
+ const offsetIndexLegacy = offsetFlagLegacy !== -1 ? offsetFlagLegacy : offsetShortLegacy;
730
+ const offsetVal = offsetIndexLegacy !== -1 ? args[offsetIndexLegacy + 1] : undefined;
731
+ const filterFlagLegacy = args.indexOf('--filter');
732
+ const filterShortLegacy = args.indexOf('-f');
733
+ const filterIndexLegacy = filterFlagLegacy !== -1 ? filterFlagLegacy : filterShortLegacy;
734
+ const filterVal = filterIndexLegacy !== -1 ? args[filterIndexLegacy + 1] : undefined;
735
+ const sortFlagLegacy = args.indexOf('--sort');
736
+ const sortShortFlagLegacy = args.indexOf('-s');
737
+ const sortIndexLegacy = sortFlagLegacy !== -1 ? sortFlagLegacy : sortShortFlagLegacy;
738
+ const sortVal = sortIndexLegacy !== -1 ? args[sortIndexLegacy + 1] : undefined;
739
+ await records.listRecords(listAppId, listTable, { limit: limitVal, offset: offsetVal, filter: filterVal, sort: sortVal });
740
+ break;
741
+ case 'get':
742
+ const getAppId = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
743
+ const getTable = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
744
+ const getId = args[3] && !args[3].startsWith('-') ? args[3] : undefined;
745
+ await records.getRecord(getAppId, getTable, getId);
746
+ break;
747
+ case 'create-record':
748
+ const createAppId = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
749
+ const createTable = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
750
+ const createDataFlag = args.indexOf('--data');
751
+ const createDataShort = args.indexOf('-d');
752
+ const createDataIndex = createDataFlag !== -1 ? createDataFlag : createDataShort;
753
+ const createData = createDataIndex !== -1 ? args.slice(createDataIndex + 1).join(' ') : undefined;
754
+ await records.createRecord(createAppId, createTable, { data: createData });
755
+ break;
756
+ case 'update':
757
+ const updateAppId = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
758
+ const updateTable = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
759
+ const updateId = args[3] && !args[3].startsWith('-') ? args[3] : undefined;
760
+ const updateDataFlag = args.indexOf('--data');
761
+ const updateDataShort = args.indexOf('-d');
762
+ const updateDataIndex = updateDataFlag !== -1 ? updateDataFlag : updateDataShort;
763
+ const updateData = updateDataIndex !== -1 ? args.slice(updateDataIndex + 1).join(' ') : undefined;
764
+ await records.updateRecord(updateAppId, updateTable, updateId, { data: updateData });
765
+ break;
766
+ case 'delete':
767
+ const deleteAppId = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
768
+ const deleteTable = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
769
+ const deleteId = args[3] && !args[3].startsWith('-') ? args[3] : undefined;
770
+ const deleteLegacyYesFlag = args.includes('--yes') || args.includes('-y');
771
+ await records.deleteRecord(deleteTable, deleteId, deleteAppId, { yes: deleteLegacyYesFlag });
772
+ break;
773
+ case 'chat':
774
+ const chatAppId = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
775
+ const chatAgentSlug = args[2] && !args[2].startsWith('-') ? args[2] : undefined;
776
+ const chatInteractive = args.includes('--interactive') || args.includes('-i');
777
+ const sessionFlag = args.indexOf('--session');
778
+ const sessionShort = args.indexOf('-s');
779
+ const sessionIndex = sessionFlag !== -1 ? sessionFlag : sessionShort;
780
+ const chatSession = sessionIndex !== -1 ? args[sessionIndex + 1] : undefined;
781
+ // Get message - everything after agentSlug that's not a flag
782
+ let chatMessage;
783
+ if (!chatInteractive && args.length > 3) {
784
+ const msgParts = [];
785
+ for (let i = 3; i < args.length; i++) {
786
+ if (args[i].startsWith('-'))
787
+ break;
788
+ msgParts.push(args[i]);
789
+ }
790
+ chatMessage = msgParts.join(' ') || undefined;
791
+ }
792
+ await (0, chat_1.chat)(chatAppId, chatAgentSlug, chatMessage, { interactive: chatInteractive, session: chatSession });
793
+ break;
794
+ case 'studio':
795
+ const studioAppId = args[1] && !args[1].startsWith('-') ? args[1] : undefined;
796
+ const studioInteractive = args.includes('--interactive') || args.includes('-i');
797
+ // Get message - everything after appId that's not a flag
798
+ let studioMessage;
799
+ if (!studioInteractive && args.length > 2) {
800
+ const msgParts = [];
801
+ for (let i = 2; i < args.length; i++) {
802
+ if (args[i].startsWith('-'))
803
+ break;
804
+ msgParts.push(args[i]);
805
+ }
806
+ studioMessage = msgParts.join(' ') || undefined;
807
+ }
808
+ await (0, studio_1.studio)(studioAppId, studioMessage, { interactive: studioInteractive });
809
+ break;
275
810
  case 'help':
276
811
  showHelp();
277
812
  break;
278
813
  case 'quit':
279
814
  case 'exit':
280
- console.log(chalk_1.default.cyan('\nGoodbye! 👋\n'));
815
+ console.log(chalk_1.default.cyan('\nGoodbye!\n'));
281
816
  return false;
282
817
  case 'clear':
283
818
  console.clear();