@positronic/cli 0.0.75 → 0.0.77

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 (144) hide show
  1. package/dist/src/cli.js +210 -41
  2. package/dist/src/commands/brain.js +7 -13
  3. package/dist/src/commands/schedule.js +3 -2
  4. package/dist/src/commands/{secret.js → secrets.js} +13 -13
  5. package/dist/src/components/brain-history.js +8 -8
  6. package/dist/src/components/brain-kill.js +4 -2
  7. package/dist/src/components/brain-list.js +104 -17
  8. package/dist/src/components/brain-rerun.js +21 -30
  9. package/dist/src/components/brain-run.js +10 -6
  10. package/dist/src/components/brain-show.js +90 -3
  11. package/dist/src/components/brain-top.js +3 -17
  12. package/dist/src/components/event-detail.js +66 -0
  13. package/dist/src/components/events-view.js +12 -0
  14. package/dist/src/components/page-delete.js +2 -0
  15. package/dist/src/components/pages-list.js +7 -7
  16. package/dist/src/components/project-add.js +1 -1
  17. package/dist/src/components/project-list.js +2 -2
  18. package/dist/src/components/project-remove.js +1 -1
  19. package/dist/src/components/project-show.js +1 -1
  20. package/dist/src/components/resource-clear.js +1 -1
  21. package/dist/src/components/resource-delete.js +5 -2
  22. package/dist/src/components/resource-list.js +2 -2
  23. package/dist/src/components/resource-sync.js +5 -5
  24. package/dist/src/components/resource-upload.js +1 -1
  25. package/dist/src/components/schedule-create.js +37 -5
  26. package/dist/src/components/schedule-delete.js +4 -2
  27. package/dist/src/components/schedule-list.js +14 -14
  28. package/dist/src/components/schedule-runs.js +7 -7
  29. package/dist/src/components/{secret-bulk.js → secrets-bulk.js} +2 -2
  30. package/dist/src/components/{secret-create.js → secrets-create.js} +3 -3
  31. package/dist/src/components/{secret-delete.js → secrets-delete.js} +1 -1
  32. package/dist/src/components/{secret-list.js → secrets-list.js} +4 -4
  33. package/dist/src/components/store-explorer.js +3 -14
  34. package/dist/src/components/top-navigator.js +3 -17
  35. package/dist/src/components/users-keys-list.js +4 -4
  36. package/dist/src/components/users-keys-remove.js +1 -1
  37. package/dist/src/components/users-list.js +2 -2
  38. package/dist/src/components/watch.js +50 -33
  39. package/dist/src/components/whoami.js +1 -1
  40. package/dist/src/hooks/useAlternateScreen.js +18 -0
  41. package/dist/src/hooks/useApi.js +1 -1
  42. package/dist/types/cli.d.ts.map +1 -1
  43. package/dist/types/commands/brain.d.ts +5 -6
  44. package/dist/types/commands/brain.d.ts.map +1 -1
  45. package/dist/types/commands/helpers.d.ts.map +1 -1
  46. package/dist/types/commands/pages.d.ts +1 -1
  47. package/dist/types/commands/pages.d.ts.map +1 -1
  48. package/dist/types/commands/project-config-manager.d.ts.map +1 -1
  49. package/dist/types/commands/schedule.d.ts +3 -2
  50. package/dist/types/commands/schedule.d.ts.map +1 -1
  51. package/dist/types/commands/{secret.d.ts → secrets.d.ts} +2 -2
  52. package/dist/types/commands/secrets.d.ts.map +1 -0
  53. package/dist/types/commands/server.d.ts.map +1 -1
  54. package/dist/types/commands/users.d.ts +2 -2
  55. package/dist/types/commands/users.d.ts.map +1 -1
  56. package/dist/types/components/auth-login.d.ts +1 -1
  57. package/dist/types/components/auth-login.d.ts.map +1 -1
  58. package/dist/types/components/auth-logout.d.ts +1 -1
  59. package/dist/types/components/auth-logout.d.ts.map +1 -1
  60. package/dist/types/components/brain-history.d.ts.map +1 -1
  61. package/dist/types/components/brain-kill.d.ts.map +1 -1
  62. package/dist/types/components/brain-list.d.ts.map +1 -1
  63. package/dist/types/components/brain-rerun.d.ts +3 -5
  64. package/dist/types/components/brain-rerun.d.ts.map +1 -1
  65. package/dist/types/components/brain-resolver.d.ts.map +1 -1
  66. package/dist/types/components/brain-run.d.ts +2 -1
  67. package/dist/types/components/brain-run.d.ts.map +1 -1
  68. package/dist/types/components/brain-show.d.ts +5 -0
  69. package/dist/types/components/brain-show.d.ts.map +1 -1
  70. package/dist/types/components/brain-top-table.d.ts.map +1 -1
  71. package/dist/types/components/brain-top.d.ts.map +1 -1
  72. package/dist/types/components/brain-watch.d.ts +1 -1
  73. package/dist/types/components/brain-watch.d.ts.map +1 -1
  74. package/dist/types/components/error.d.ts.map +1 -1
  75. package/dist/types/components/event-detail.d.ts +1 -1
  76. package/dist/types/components/event-detail.d.ts.map +1 -1
  77. package/dist/types/components/events-view.d.ts.map +1 -1
  78. package/dist/types/components/page-delete.d.ts.map +1 -1
  79. package/dist/types/components/pages-list.d.ts.map +1 -1
  80. package/dist/types/components/project-add.d.ts.map +1 -1
  81. package/dist/types/components/project-auth-setup.d.ts +1 -1
  82. package/dist/types/components/project-auth-setup.d.ts.map +1 -1
  83. package/dist/types/components/project-create.d.ts.map +1 -1
  84. package/dist/types/components/project-list.d.ts.map +1 -1
  85. package/dist/types/components/project-remove.d.ts.map +1 -1
  86. package/dist/types/components/project-select.d.ts.map +1 -1
  87. package/dist/types/components/project-show.d.ts.map +1 -1
  88. package/dist/types/components/resource-clear.d.ts.map +1 -1
  89. package/dist/types/components/resource-delete.d.ts +1 -1
  90. package/dist/types/components/resource-delete.d.ts.map +1 -1
  91. package/dist/types/components/resource-list.d.ts.map +1 -1
  92. package/dist/types/components/resource-sync.d.ts +1 -1
  93. package/dist/types/components/resource-sync.d.ts.map +1 -1
  94. package/dist/types/components/resource-types.d.ts.map +1 -1
  95. package/dist/types/components/resource-upload.d.ts +1 -1
  96. package/dist/types/components/resource-upload.d.ts.map +1 -1
  97. package/dist/types/components/run-show.d.ts.map +1 -1
  98. package/dist/types/components/schedule-create.d.ts +2 -1
  99. package/dist/types/components/schedule-create.d.ts.map +1 -1
  100. package/dist/types/components/schedule-delete.d.ts.map +1 -1
  101. package/dist/types/components/schedule-list.d.ts.map +1 -1
  102. package/dist/types/components/schedule-runs.d.ts +1 -1
  103. package/dist/types/components/schedule-runs.d.ts.map +1 -1
  104. package/dist/types/components/secrets-bulk.d.ts +7 -0
  105. package/dist/types/components/secrets-bulk.d.ts.map +1 -0
  106. package/dist/types/components/secrets-create.d.ts +7 -0
  107. package/dist/types/components/secrets-create.d.ts.map +1 -0
  108. package/dist/types/components/secrets-delete.d.ts +6 -0
  109. package/dist/types/components/secrets-delete.d.ts.map +1 -0
  110. package/dist/types/components/secrets-list.d.ts +2 -0
  111. package/dist/types/components/secrets-list.d.ts.map +1 -0
  112. package/dist/types/components/select-list.d.ts.map +1 -1
  113. package/dist/types/components/state-view.d.ts.map +1 -1
  114. package/dist/types/components/store-explorer.d.ts.map +1 -1
  115. package/dist/types/components/top-navigator.d.ts.map +1 -1
  116. package/dist/types/components/users-create.d.ts.map +1 -1
  117. package/dist/types/components/users-delete.d.ts.map +1 -1
  118. package/dist/types/components/users-keys-add.d.ts +1 -1
  119. package/dist/types/components/users-keys-add.d.ts.map +1 -1
  120. package/dist/types/components/users-keys-list.d.ts.map +1 -1
  121. package/dist/types/components/users-keys-remove.d.ts +1 -1
  122. package/dist/types/components/users-keys-remove.d.ts.map +1 -1
  123. package/dist/types/components/users-list.d.ts.map +1 -1
  124. package/dist/types/components/watch-machine.d.ts.map +1 -1
  125. package/dist/types/components/watch-resolver.d.ts +1 -1
  126. package/dist/types/components/watch-resolver.d.ts.map +1 -1
  127. package/dist/types/components/watch.d.ts +1 -1
  128. package/dist/types/components/watch.d.ts.map +1 -1
  129. package/dist/types/components/whoami.d.ts.map +1 -1
  130. package/dist/types/hooks/useAlternateScreen.d.ts +2 -0
  131. package/dist/types/hooks/useAlternateScreen.d.ts.map +1 -0
  132. package/dist/types/hooks/useApi.d.ts.map +1 -1
  133. package/dist/types/lib/jwt-auth.d.ts.map +1 -1
  134. package/dist/types/lib/ssh-key-utils.d.ts.map +1 -1
  135. package/package.json +4 -4
  136. package/dist/types/commands/secret.d.ts.map +0 -1
  137. package/dist/types/components/secret-bulk.d.ts +0 -7
  138. package/dist/types/components/secret-bulk.d.ts.map +0 -1
  139. package/dist/types/components/secret-create.d.ts +0 -7
  140. package/dist/types/components/secret-create.d.ts.map +0 -1
  141. package/dist/types/components/secret-delete.d.ts +0 -6
  142. package/dist/types/components/secret-delete.d.ts.map +0 -1
  143. package/dist/types/components/secret-list.d.ts +0 -2
  144. package/dist/types/components/secret-list.d.ts.map +0 -1
package/dist/src/cli.js CHANGED
@@ -35,6 +35,19 @@ function _async_to_generator(fn) {
35
35
  });
36
36
  };
37
37
  }
38
+ function _define_property(obj, key, value) {
39
+ if (key in obj) {
40
+ Object.defineProperty(obj, key, {
41
+ value: value,
42
+ enumerable: true,
43
+ configurable: true,
44
+ writable: true
45
+ });
46
+ } else {
47
+ obj[key] = value;
48
+ }
49
+ return obj;
50
+ }
38
51
  function _instanceof(left, right) {
39
52
  if (right != null && typeof Symbol !== "undefined" && right[Symbol.hasInstance]) {
40
53
  return !!right[Symbol.hasInstance](left);
@@ -48,6 +61,45 @@ function _iterable_to_array(iter) {
48
61
  function _non_iterable_rest() {
49
62
  throw new TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
50
63
  }
64
+ function _object_spread(target) {
65
+ for(var i = 1; i < arguments.length; i++){
66
+ var source = arguments[i] != null ? arguments[i] : {};
67
+ var ownKeys = Object.keys(source);
68
+ if (typeof Object.getOwnPropertySymbols === "function") {
69
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
70
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
71
+ }));
72
+ }
73
+ ownKeys.forEach(function(key) {
74
+ _define_property(target, key, source[key]);
75
+ });
76
+ }
77
+ return target;
78
+ }
79
+ function ownKeys(object, enumerableOnly) {
80
+ var keys = Object.keys(object);
81
+ if (Object.getOwnPropertySymbols) {
82
+ var symbols = Object.getOwnPropertySymbols(object);
83
+ if (enumerableOnly) {
84
+ symbols = symbols.filter(function(sym) {
85
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
86
+ });
87
+ }
88
+ keys.push.apply(keys, symbols);
89
+ }
90
+ return keys;
91
+ }
92
+ function _object_spread_props(target, source) {
93
+ source = source != null ? source : {};
94
+ if (Object.getOwnPropertyDescriptors) {
95
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
96
+ } else {
97
+ ownKeys(Object(source)).forEach(function(key) {
98
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
99
+ });
100
+ }
101
+ return target;
102
+ }
51
103
  function _to_array(arr) {
52
104
  return _array_with_holes(arr) || _iterable_to_array(arr) || _unsupported_iterable_to_array(arr) || _non_iterable_rest();
53
105
  }
@@ -158,7 +210,7 @@ import { ServerCommand } from './commands/server.js';
158
210
  import { BrainCommand } from './commands/brain.js';
159
211
  import { ResourcesCommand } from './commands/resources.js';
160
212
  import { ScheduleCommand } from './commands/schedule.js';
161
- import { SecretCommand } from './commands/secret.js';
213
+ import { SecretsCommand } from './commands/secrets.js';
162
214
  import { PagesCommand } from './commands/pages.js';
163
215
  import { UsersCommand } from './commands/users.js';
164
216
  import { AuthCommand } from './commands/auth.js';
@@ -197,6 +249,46 @@ function parseKeyValueOptions(opts) {
197
249
  }
198
250
  return parsed;
199
251
  }
252
+ // Helper function to parse key=value state values with type coercion
253
+ function parseStateValues(opts) {
254
+ if (!opts || opts.length === 0) return undefined;
255
+ var parsed = {};
256
+ var _iteratorNormalCompletion = true, _didIteratorError = false, _iteratorError = undefined;
257
+ try {
258
+ for(var _iterator = opts[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true){
259
+ var opt = _step.value;
260
+ var _opt_split = _to_array(opt.split('=')), key = _opt_split[0], valueParts = _opt_split.slice(1);
261
+ var raw = valueParts.join('=');
262
+ if (!key || raw === undefined || raw === '') {
263
+ throw new Error('Invalid state format: "'.concat(opt, '". State values must be in key=value format.'));
264
+ }
265
+ // Type coercion
266
+ if (raw === 'true') {
267
+ parsed[key] = true;
268
+ } else if (raw === 'false') {
269
+ parsed[key] = false;
270
+ } else if (raw !== '' && !isNaN(Number(raw))) {
271
+ parsed[key] = Number(raw);
272
+ } else {
273
+ parsed[key] = raw;
274
+ }
275
+ }
276
+ } catch (err) {
277
+ _didIteratorError = true;
278
+ _iteratorError = err;
279
+ } finally{
280
+ try {
281
+ if (!_iteratorNormalCompletion && _iterator.return != null) {
282
+ _iterator.return();
283
+ }
284
+ } finally{
285
+ if (_didIteratorError) {
286
+ throw _iteratorError;
287
+ }
288
+ }
289
+ }
290
+ return parsed;
291
+ }
200
292
  export function buildCli(options) {
201
293
  var _options_argv = options.argv, argv = _options_argv === void 0 ? hideBin(process.argv) : _options_argv, server = options.server, _options_exitProcess = options.exitProcess, exitProcess = _options_exitProcess === void 0 ? false : _options_exitProcess, render = options.render, projectRootPath = options.projectRootPath;
202
294
  var isLocalDevMode = server !== undefined;
@@ -216,7 +308,7 @@ export function buildCli(options) {
216
308
  var projectCommand = new ProjectCommand();
217
309
  var brainCommand = new BrainCommand();
218
310
  var scheduleCommand = new ScheduleCommand();
219
- var secretCommand = new SecretCommand();
311
+ var secretsCommand = new SecretsCommand();
220
312
  var pagesCommand = new PagesCommand();
221
313
  var usersCommand = new UsersCommand();
222
314
  // Main CLI definition
@@ -405,21 +497,19 @@ export function buildCli(options) {
405
497
  render(element);
406
498
  });
407
499
  // --- Rerun Brain Command ---
408
- cli = cli.command('rerun <brain> [run-id]', 'Rerun an existing brain run\n', function(yargsRerun) {
409
- return yargsRerun.positional('brain', {
410
- describe: 'Brain identifier (title, filename, or search term)',
500
+ cli = cli.command([
501
+ 'rerun <run-id>',
502
+ 'rr <run-id>'
503
+ ], 'Rerun an existing brain run from a specific step\n', function(yargsRerun) {
504
+ return yargsRerun.positional('run-id', {
505
+ describe: 'ID of the brain run to rerun',
411
506
  type: 'string',
412
507
  demandOption: true
413
- }).positional('run-id', {
414
- describe: 'ID of the brain run to rerun (defaults to the most recent run)',
415
- type: 'string'
416
508
  }).option('starts-at', {
417
- describe: 'Step number to start execution from',
418
- type: 'number'
419
- }).alias('starts-at', 's').option('stops-after', {
420
- describe: 'Step number to stop execution after',
421
- type: 'number'
422
- }).alias('stops-after', 'e').example('$0 rerun my-brain', 'Rerun the most recent execution of my-brain').example('$0 rerun my-brain abc123', 'Rerun a specific brain run').example('$0 rerun my-brain --starts-at=3', 'Rerun from step 3').example('$0 rerun my-brain --stops-after=5', 'Rerun and stop after step 5').example('$0 rerun my-brain --starts-at=3 --stops-after=5', 'Rerun steps 3 through 5');
509
+ describe: 'Step number to start execution from (1-indexed)',
510
+ type: 'number',
511
+ demandOption: true
512
+ }).alias('starts-at', 's').example('$0 rerun abc123 --starts-at=3', 'Rerun from step 3');
423
513
  }, function(argv) {
424
514
  var element = brainCommand.rerun(argv);
425
515
  render(element);
@@ -444,9 +534,36 @@ export function buildCli(options) {
444
534
  alias: 'o',
445
535
  string: true,
446
536
  coerce: parseKeyValueOptions
447
- }).example('$0 run my-brain', 'Run a brain by filename').example('$0 run "Email Digest"', 'Run a brain by title').example('$0 run email', 'Fuzzy search for brains matching "email"').example('$0 run my-brain --watch', 'Run a brain and watch its execution').example('$0 run my-brain -o channel=#general -o debug=true', 'Run a brain with options');
537
+ }).option('state', {
538
+ describe: 'Initial state values (key=value format, with type coercion)',
539
+ type: 'array',
540
+ alias: 's',
541
+ string: true,
542
+ coerce: parseStateValues
543
+ }).option('state-json', {
544
+ describe: 'Initial state as a JSON string',
545
+ type: 'string'
546
+ }).check(function(argv) {
547
+ if (argv.state && argv.stateJson) {
548
+ throw new Error('Cannot use both --state/-s and --state-json at the same time.');
549
+ }
550
+ return true;
551
+ }).example('$0 run my-brain', 'Run a brain by filename').example('$0 run "Email Digest"', 'Run a brain by title').example('$0 run email', 'Fuzzy search for brains matching "email"').example('$0 run my-brain --watch', 'Run a brain and watch its execution').example('$0 run my-brain -o channel=#general -o debug=true', 'Run a brain with options').example('$0 run my-brain -s count=0 -s name=sean', 'Run a brain with initial state').example('$0 run my-brain --state-json \'{"items": [], "config": {"debug": true}}\'', 'Run a brain with initial state from JSON');
448
552
  }, function(argv) {
449
- var element = brainCommand.run(argv);
553
+ var initialState;
554
+ if (argv.stateJson) {
555
+ try {
556
+ initialState = JSON.parse(argv.stateJson);
557
+ } catch (e) {
558
+ console.error("Invalid JSON for --state-json: ".concat(argv.stateJson));
559
+ process.exit(1);
560
+ }
561
+ } else if (argv.state) {
562
+ initialState = argv.state;
563
+ }
564
+ var element = brainCommand.run(_object_spread_props(_object_spread({}, argv), {
565
+ initialState: initialState
566
+ }));
450
567
  render(element);
451
568
  });
452
569
  // --- Watch Brain Run Command ---
@@ -514,21 +631,19 @@ export function buildCli(options) {
514
631
  }, function(argv) {
515
632
  var element = brainCommand.show(argv);
516
633
  render(element);
517
- }).command('rerun <brain> [run-id]', 'Rerun an existing brain run\n', function(yargsRerun) {
518
- return yargsRerun.positional('brain', {
519
- describe: 'Brain identifier (title, filename, or search term)',
634
+ }).command([
635
+ 'rerun <run-id>',
636
+ 'rr <run-id>'
637
+ ], 'Rerun an existing brain run from a specific step\n', function(yargsRerun) {
638
+ return yargsRerun.positional('run-id', {
639
+ describe: 'ID of the brain run to rerun',
520
640
  type: 'string',
521
641
  demandOption: true
522
- }).positional('run-id', {
523
- describe: 'ID of the brain run to rerun (defaults to the most recent run)',
524
- type: 'string'
525
642
  }).option('starts-at', {
526
- describe: 'Step number to start execution from',
527
- type: 'number'
528
- }).alias('starts-at', 's').option('stops-after', {
529
- describe: 'Step number to stop execution after',
530
- type: 'number'
531
- }).alias('stops-after', 'e').example('$0 brain rerun my-brain', 'Rerun the most recent execution of my-brain').example('$0 brain rerun my-brain abc123', 'Rerun a specific brain run').example('$0 brain rerun my-brain --starts-at=3', 'Rerun from step 3').example('$0 brain rerun my-brain --stops-after=5', 'Rerun and stop after step 5').example('$0 brain rerun my-brain --starts-at=3 --stops-after=5', 'Rerun steps 3 through 5');
643
+ describe: 'Step number to start execution from (1-indexed)',
644
+ type: 'number',
645
+ demandOption: true
646
+ }).alias('starts-at', 's').example('$0 brain rerun abc123 --starts-at=3', 'Rerun from step 3');
532
647
  }, function(argv) {
533
648
  var element = brainCommand.rerun(argv);
534
649
  render(element);
@@ -548,9 +663,36 @@ export function buildCli(options) {
548
663
  alias: 'o',
549
664
  string: true,
550
665
  coerce: parseKeyValueOptions
551
- }).example('$0 brain run my-brain', 'Run a brain by filename').example('$0 brain run "Email Digest"', 'Run a brain by title').example('$0 brain run email', 'Fuzzy search for brains matching "email"').example('$0 brain run my-brain --watch', 'Run a brain and watch its execution').example('$0 brain run my-brain -o channel=#general -o debug=true', 'Run a brain with options');
666
+ }).option('state', {
667
+ describe: 'Initial state values (key=value format, with type coercion)',
668
+ type: 'array',
669
+ alias: 's',
670
+ string: true,
671
+ coerce: parseStateValues
672
+ }).option('state-json', {
673
+ describe: 'Initial state as a JSON string',
674
+ type: 'string'
675
+ }).check(function(argv) {
676
+ if (argv.state && argv.stateJson) {
677
+ throw new Error('Cannot use both --state/-s and --state-json at the same time.');
678
+ }
679
+ return true;
680
+ }).example('$0 brain run my-brain', 'Run a brain by filename').example('$0 brain run "Email Digest"', 'Run a brain by title').example('$0 brain run email', 'Fuzzy search for brains matching "email"').example('$0 brain run my-brain --watch', 'Run a brain and watch its execution').example('$0 brain run my-brain -o channel=#general -o debug=true', 'Run a brain with options').example('$0 brain run my-brain -s count=0 -s name=sean', 'Run a brain with initial state');
552
681
  }, function(argv) {
553
- var element = brainCommand.run(argv);
682
+ var initialState;
683
+ if (argv.stateJson) {
684
+ try {
685
+ initialState = JSON.parse(argv.stateJson);
686
+ } catch (e) {
687
+ console.error("Invalid JSON for --state-json: ".concat(argv.stateJson));
688
+ process.exit(1);
689
+ }
690
+ } else if (argv.state) {
691
+ initialState = argv.state;
692
+ }
693
+ var element = brainCommand.run(_object_spread_props(_object_spread({}, argv), {
694
+ initialState: initialState
695
+ }));
554
696
  render(element);
555
697
  }).command('watch <identifier>', 'Watch a brain run by brain name or run ID\n', function(yargsWatch) {
556
698
  return yargsWatch.positional('identifier', {
@@ -787,9 +929,36 @@ export function buildCli(options) {
787
929
  alias: 'o',
788
930
  string: true,
789
931
  coerce: parseKeyValueOptions
790
- }).example('$0 schedule create my-brain "0 3 * * *"', 'Run my-brain daily at 3am').example('$0 schedule c my-brain "0 3 * * *"', 'Run my-brain daily at 3am (shorthand)').example('$0 schedule create data-sync "*/30 * * * *"', 'Run data-sync every 30 minutes').example('$0 schedule create weekly-report "0 9 * * 1"', 'Run weekly-report every Monday at 9am').example('$0 schedule create my-brain "0 8 * * 1" -o notify=sean,jim', 'Run with options passed to the brain');
932
+ }).option('state', {
933
+ describe: 'Initial state values for each run (key=value format, with type coercion)',
934
+ type: 'array',
935
+ alias: 's',
936
+ string: true,
937
+ coerce: parseStateValues
938
+ }).option('state-json', {
939
+ describe: 'Initial state as a JSON string',
940
+ type: 'string'
941
+ }).check(function(argv) {
942
+ if (argv.state && argv.stateJson) {
943
+ throw new Error('Cannot use both --state/-s and --state-json at the same time.');
944
+ }
945
+ return true;
946
+ }).example('$0 schedule create my-brain "0 3 * * *"', 'Run my-brain daily at 3am').example('$0 schedule c my-brain "0 3 * * *"', 'Run my-brain daily at 3am (shorthand)').example('$0 schedule create data-sync "*/30 * * * *"', 'Run data-sync every 30 minutes').example('$0 schedule create weekly-report "0 9 * * 1"', 'Run weekly-report every Monday at 9am').example('$0 schedule create my-brain "0 8 * * 1" -o notify=sean,jim', 'Run with options passed to the brain').example('$0 schedule create my-brain "0 3 * * *" -s environment=staging', 'Run with initial state');
791
947
  }, function(argv) {
792
- var element = scheduleCommand.create(argv);
948
+ var initialState;
949
+ if (argv.stateJson) {
950
+ try {
951
+ initialState = JSON.parse(argv.stateJson);
952
+ } catch (e) {
953
+ console.error("Invalid JSON for --state-json: ".concat(argv.stateJson));
954
+ process.exit(1);
955
+ }
956
+ } else if (argv.state) {
957
+ initialState = argv.state;
958
+ }
959
+ var element = scheduleCommand.create(_object_spread_props(_object_spread({}, argv), {
960
+ initialState: initialState
961
+ }));
793
962
  render(element);
794
963
  }).command('timezone [timezone]', 'Get or set the project timezone for schedules\n', function(yargsTimezone) {
795
964
  return yargsTimezone.positional('timezone', {
@@ -846,10 +1015,10 @@ export function buildCli(options) {
846
1015
  }).demandCommand(1, 'You need to specify a subcommand');
847
1016
  return yargsPages;
848
1017
  });
849
- // --- Secret Management Commands ---
850
- cli = cli.command('secret', 'Manage secrets for your brains\n', function(yargsSecret) {
1018
+ // --- Secrets Management Commands ---
1019
+ cli = cli.command('secrets', 'Manage secrets for your brains\n', function(yargsSecret) {
851
1020
  yargsSecret.command('list', 'List all secrets\n', {}, function() {
852
- var element = secretCommand.list();
1021
+ var element = secretsCommand.list();
853
1022
  render(element);
854
1023
  }).command('create <name>', 'Create a new secret\n', function(yargsCreate) {
855
1024
  return yargsCreate.positional('name', {
@@ -859,26 +1028,26 @@ export function buildCli(options) {
859
1028
  }).option('value', {
860
1029
  describe: 'Secret value (omit for secure input)',
861
1030
  type: 'string'
862
- }).example('$0 secret create ANTHROPIC_API_KEY', 'Create a secret with secure input').example('$0 secret create DATABASE_URL --value "postgres://..."', 'Create a secret with direct value (not recommended)');
1031
+ }).example('$0 secrets create ANTHROPIC_API_KEY', 'Create a secret with secure input').example('$0 secrets create DATABASE_URL --value "postgres://..."', 'Create a secret with direct value (not recommended)');
863
1032
  }, function(argv) {
864
- var element = secretCommand.create(argv);
1033
+ var element = secretsCommand.create(argv);
865
1034
  render(element);
866
1035
  }).command('delete <name>', 'Delete a secret\n', function(yargsDelete) {
867
1036
  return yargsDelete.positional('name', {
868
1037
  describe: 'Name of the secret to delete',
869
1038
  type: 'string',
870
1039
  demandOption: true
871
- }).example('$0 secret delete ANTHROPIC_API_KEY', 'Delete a secret');
1040
+ }).example('$0 secrets delete ANTHROPIC_API_KEY', 'Delete a secret');
872
1041
  }, function(argv) {
873
- var element = secretCommand.delete(argv);
1042
+ var element = secretsCommand.delete(argv);
874
1043
  render(element);
875
1044
  }).command('bulk [file]', 'Bulk upload secrets from a .env file\n', function(yargsBulk) {
876
1045
  return yargsBulk.positional('file', {
877
1046
  describe: 'Path to the .env file (defaults to .env in project root)',
878
1047
  type: 'string'
879
- }).example('$0 secret bulk', 'Upload secrets from .env file in project root').example('$0 secret bulk .env.production', 'Upload secrets from a specific .env file');
1048
+ }).example('$0 secrets bulk', 'Upload secrets from .env file in project root').example('$0 secrets bulk .env.production', 'Upload secrets from a specific .env file');
880
1049
  }, function(argv) {
881
- var element = secretCommand.bulk(argv);
1050
+ var element = secretsCommand.bulk(argv);
882
1051
  render(element);
883
1052
  }).demandCommand(1, 'You need to specify a subcommand');
884
1053
  return yargsSecret;
@@ -86,28 +86,22 @@ export var BrainCommand = /*#__PURE__*/ function() {
86
86
  {
87
87
  key: "rerun",
88
88
  value: function rerun(param) {
89
- var brain = param.brain, runId = param.runId, startsAt = param.startsAt, stopsAfter = param.stopsAfter;
90
- return React.createElement(BrainResolver, {
91
- identifier: brain,
92
- children: function(resolvedBrainTitle) {
93
- return React.createElement(BrainRerun, {
94
- identifier: resolvedBrainTitle,
95
- runId: runId,
96
- startsAt: startsAt,
97
- stopsAfter: stopsAfter
98
- });
99
- }
89
+ var runId = param.runId, startsAt = param.startsAt;
90
+ return React.createElement(BrainRerun, {
91
+ runId: runId,
92
+ startsAt: startsAt
100
93
  });
101
94
  }
102
95
  },
103
96
  {
104
97
  key: "run",
105
98
  value: function run(param) {
106
- var brain = param.brain, watch = param.watch, options = param.options;
99
+ var brain = param.brain, watch = param.watch, options = param.options, initialState = param.initialState;
107
100
  return React.createElement(BrainRun, {
108
101
  identifier: brain,
109
102
  watch: watch,
110
- options: options
103
+ options: options,
104
+ initialState: initialState
111
105
  });
112
106
  }
113
107
  },
@@ -33,14 +33,15 @@ export var ScheduleCommand = /*#__PURE__*/ function() {
33
33
  {
34
34
  key: "create",
35
35
  value: function create(param) {
36
- var brain = param.brain, cronExpression = param.cronExpression, options = param.options;
36
+ var brain = param.brain, cronExpression = param.cronExpression, options = param.options, initialState = param.initialState;
37
37
  return React.createElement(BrainResolver, {
38
38
  identifier: brain,
39
39
  children: function(resolvedBrainTitle) {
40
40
  return React.createElement(ScheduleCreate, {
41
41
  identifier: resolvedBrainTitle,
42
42
  cronExpression: cronExpression,
43
- options: options
43
+ options: options,
44
+ initialState: initialState
44
45
  });
45
46
  }
46
47
  });
@@ -18,27 +18,27 @@ function _create_class(Constructor, protoProps, staticProps) {
18
18
  return Constructor;
19
19
  }
20
20
  import React from 'react';
21
- import { SecretCreate } from '../components/secret-create.js';
22
- import { SecretList } from '../components/secret-list.js';
23
- import { SecretDelete } from '../components/secret-delete.js';
24
- import { SecretBulk } from '../components/secret-bulk.js';
25
- export var SecretCommand = /*#__PURE__*/ function() {
21
+ import { SecretsCreate } from '../components/secrets-create.js';
22
+ import { SecretsList } from '../components/secrets-list.js';
23
+ import { SecretsDelete } from '../components/secrets-delete.js';
24
+ import { SecretsBulk } from '../components/secrets-bulk.js';
25
+ export var SecretsCommand = /*#__PURE__*/ function() {
26
26
  "use strict";
27
- function SecretCommand() {
28
- _class_call_check(this, SecretCommand);
27
+ function SecretsCommand() {
28
+ _class_call_check(this, SecretsCommand);
29
29
  }
30
- _create_class(SecretCommand, [
30
+ _create_class(SecretsCommand, [
31
31
  {
32
32
  key: "list",
33
33
  value: function list() {
34
- return React.createElement(SecretList);
34
+ return React.createElement(SecretsList);
35
35
  }
36
36
  },
37
37
  {
38
38
  key: "create",
39
39
  value: function create(param) {
40
40
  var name = param.name, value = param.value;
41
- return React.createElement(SecretCreate, {
41
+ return React.createElement(SecretsCreate, {
42
42
  name: name,
43
43
  value: value
44
44
  });
@@ -48,7 +48,7 @@ export var SecretCommand = /*#__PURE__*/ function() {
48
48
  key: "delete",
49
49
  value: function _delete(param) {
50
50
  var name = param.name;
51
- return React.createElement(SecretDelete, {
51
+ return React.createElement(SecretsDelete, {
52
52
  name: name
53
53
  });
54
54
  }
@@ -57,11 +57,11 @@ export var SecretCommand = /*#__PURE__*/ function() {
57
57
  key: "bulk",
58
58
  value: function bulk(param) {
59
59
  var file = param.file;
60
- return React.createElement(SecretBulk, {
60
+ return React.createElement(SecretsBulk, {
61
61
  file: file
62
62
  });
63
63
  }
64
64
  }
65
65
  ]);
66
- return SecretCommand;
66
+ return SecretsCommand;
67
67
  }();
@@ -119,19 +119,19 @@ export var BrainHistory = function(param) {
119
119
  }, /*#__PURE__*/ React.createElement(Box, null, /*#__PURE__*/ React.createElement(Text, {
120
120
  bold: true,
121
121
  color: "cyan"
122
- }, padRight(columns.runId.header, columns.runId.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
122
+ }, padRight(columns.runId.header, columns.runId.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
123
123
  bold: true,
124
124
  color: "cyan"
125
- }, padRight(columns.status.header, columns.status.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
125
+ }, padRight(columns.status.header, columns.status.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
126
126
  bold: true,
127
127
  color: "cyan"
128
- }, padRight(columns.type.header, columns.type.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
128
+ }, padRight(columns.type.header, columns.type.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
129
129
  bold: true,
130
130
  color: "cyan"
131
- }, padRight(columns.when.header, columns.when.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
131
+ }, padRight(columns.when.header, columns.when.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
132
132
  bold: true,
133
133
  color: "cyan"
134
- }, padRight(columns.duration.header, columns.duration.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
134
+ }, padRight(columns.duration.header, columns.duration.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
135
135
  bold: true,
136
136
  color: "cyan"
137
137
  }, padRight(columns.startedAt.header, columns.startedAt.width))), /*#__PURE__*/ React.createElement(Box, null, /*#__PURE__*/ React.createElement(Text, {
@@ -140,11 +140,11 @@ export var BrainHistory = function(param) {
140
140
  var duration = run.startedAt && run.completedAt ? formatDuration(run.startedAt, run.completedAt) : run.status === STATUS.RUNNING ? 'Running...' : 'N/A';
141
141
  return /*#__PURE__*/ React.createElement(Box, {
142
142
  key: run.brainRunId
143
- }, /*#__PURE__*/ React.createElement(Text, null, padRight(truncate(run.brainRunId, columns.runId.width), columns.runId.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
143
+ }, /*#__PURE__*/ React.createElement(Text, null, padRight(truncate(run.brainRunId, columns.runId.width), columns.runId.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
144
144
  color: getStatusColor(run.status)
145
- }, padRight(run.status, columns.status.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, null, padRight(run.type || 'N/A', columns.type.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
145
+ }, padRight(run.status, columns.status.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, null, padRight(run.type || 'N/A', columns.type.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
146
146
  dimColor: true
147
- }, padRight(formatRelativeTime(run.createdAt), columns.when.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, null, padRight(duration, columns.duration.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
147
+ }, padRight(formatRelativeTime(run.createdAt), columns.when.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, null, padRight(duration, columns.duration.width)), /*#__PURE__*/ React.createElement(Text, null, " "), /*#__PURE__*/ React.createElement(Text, {
148
148
  dimColor: true
149
149
  }, padRight(run.startedAt ? formatDate(run.startedAt) : 'N/A', columns.startedAt.width)));
150
150
  })));
@@ -76,9 +76,11 @@ export var BrainKill = function(param) {
76
76
  }
77
77
  return; // Stop processing after Enter
78
78
  } else if (char === '\u0003') {
79
+ // Ctrl+C
79
80
  exit();
80
81
  return;
81
82
  } else if (char === '\u007F' || char === '\b') {
83
+ // Backspace
82
84
  inputRef.current = inputRef.current.slice(0, -1);
83
85
  setInput(inputRef.current);
84
86
  } else {
@@ -150,7 +152,7 @@ export var BrainKill = function(param) {
150
152
  flexDirection: "column"
151
153
  }, /*#__PURE__*/ React.createElement(Text, {
152
154
  color: "yellow"
153
- }, "⚠️ Brain run is not active"), /*#__PURE__*/ React.createElement(Box, {
155
+ }, "⚠️ Brain run is not active"), /*#__PURE__*/ React.createElement(Box, {
154
156
  marginTop: 1,
155
157
  paddingLeft: 2
156
158
  }, /*#__PURE__*/ React.createElement(Text, null, "The brain run has already completed or was previously cancelled.")));
@@ -180,7 +182,7 @@ export var BrainKill = function(param) {
180
182
  }, /*#__PURE__*/ React.createElement(Text, {
181
183
  bold: true,
182
184
  color: "yellow"
183
- }, "⚠️ Warning: This will stop the running brain"), /*#__PURE__*/ React.createElement(Box, {
185
+ }, "⚠️ Warning: This will stop the running brain"), /*#__PURE__*/ React.createElement(Box, {
184
186
  marginTop: 1,
185
187
  marginBottom: 1,
186
188
  paddingLeft: 2,