@positronic/cli 0.0.74 → 0.0.76

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 (146) 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 +4 -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 +89 -2
  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-auth-setup.js +5 -2
  18. package/dist/src/components/project-create.js +8 -2
  19. package/dist/src/components/project-list.js +2 -2
  20. package/dist/src/components/project-remove.js +1 -1
  21. package/dist/src/components/project-show.js +1 -1
  22. package/dist/src/components/resource-clear.js +1 -1
  23. package/dist/src/components/resource-delete.js +5 -2
  24. package/dist/src/components/resource-list.js +2 -2
  25. package/dist/src/components/resource-sync.js +5 -5
  26. package/dist/src/components/resource-upload.js +1 -1
  27. package/dist/src/components/schedule-create.js +43 -5
  28. package/dist/src/components/schedule-delete.js +4 -2
  29. package/dist/src/components/schedule-list.js +14 -14
  30. package/dist/src/components/schedule-runs.js +7 -7
  31. package/dist/src/components/{secret-bulk.js → secrets-bulk.js} +2 -2
  32. package/dist/src/components/{secret-create.js → secrets-create.js} +3 -3
  33. package/dist/src/components/{secret-delete.js → secrets-delete.js} +1 -1
  34. package/dist/src/components/{secret-list.js → secrets-list.js} +4 -4
  35. package/dist/src/components/store-explorer.js +4 -17
  36. package/dist/src/components/top-navigator.js +3 -17
  37. package/dist/src/components/users-keys-list.js +4 -4
  38. package/dist/src/components/users-keys-remove.js +1 -1
  39. package/dist/src/components/users-list.js +2 -2
  40. package/dist/src/components/watch.js +50 -33
  41. package/dist/src/components/whoami.js +1 -1
  42. package/dist/src/hooks/useAlternateScreen.js +18 -0
  43. package/dist/src/hooks/useApi.js +1 -1
  44. package/dist/types/cli.d.ts.map +1 -1
  45. package/dist/types/commands/brain.d.ts +5 -6
  46. package/dist/types/commands/brain.d.ts.map +1 -1
  47. package/dist/types/commands/helpers.d.ts.map +1 -1
  48. package/dist/types/commands/pages.d.ts +1 -1
  49. package/dist/types/commands/pages.d.ts.map +1 -1
  50. package/dist/types/commands/project-config-manager.d.ts.map +1 -1
  51. package/dist/types/commands/schedule.d.ts +4 -2
  52. package/dist/types/commands/schedule.d.ts.map +1 -1
  53. package/dist/types/commands/{secret.d.ts → secrets.d.ts} +2 -2
  54. package/dist/types/commands/secrets.d.ts.map +1 -0
  55. package/dist/types/commands/server.d.ts.map +1 -1
  56. package/dist/types/commands/users.d.ts +2 -2
  57. package/dist/types/commands/users.d.ts.map +1 -1
  58. package/dist/types/components/auth-login.d.ts +1 -1
  59. package/dist/types/components/auth-login.d.ts.map +1 -1
  60. package/dist/types/components/auth-logout.d.ts +1 -1
  61. package/dist/types/components/auth-logout.d.ts.map +1 -1
  62. package/dist/types/components/brain-history.d.ts.map +1 -1
  63. package/dist/types/components/brain-kill.d.ts.map +1 -1
  64. package/dist/types/components/brain-list.d.ts.map +1 -1
  65. package/dist/types/components/brain-rerun.d.ts +3 -5
  66. package/dist/types/components/brain-rerun.d.ts.map +1 -1
  67. package/dist/types/components/brain-resolver.d.ts.map +1 -1
  68. package/dist/types/components/brain-run.d.ts +2 -1
  69. package/dist/types/components/brain-run.d.ts.map +1 -1
  70. package/dist/types/components/brain-show.d.ts +5 -0
  71. package/dist/types/components/brain-show.d.ts.map +1 -1
  72. package/dist/types/components/brain-top-table.d.ts.map +1 -1
  73. package/dist/types/components/brain-top.d.ts.map +1 -1
  74. package/dist/types/components/brain-watch.d.ts +1 -1
  75. package/dist/types/components/brain-watch.d.ts.map +1 -1
  76. package/dist/types/components/error.d.ts.map +1 -1
  77. package/dist/types/components/event-detail.d.ts +1 -1
  78. package/dist/types/components/event-detail.d.ts.map +1 -1
  79. package/dist/types/components/events-view.d.ts.map +1 -1
  80. package/dist/types/components/page-delete.d.ts.map +1 -1
  81. package/dist/types/components/pages-list.d.ts.map +1 -1
  82. package/dist/types/components/project-add.d.ts.map +1 -1
  83. package/dist/types/components/project-auth-setup.d.ts +1 -1
  84. package/dist/types/components/project-auth-setup.d.ts.map +1 -1
  85. package/dist/types/components/project-create.d.ts.map +1 -1
  86. package/dist/types/components/project-list.d.ts.map +1 -1
  87. package/dist/types/components/project-remove.d.ts.map +1 -1
  88. package/dist/types/components/project-select.d.ts.map +1 -1
  89. package/dist/types/components/project-show.d.ts.map +1 -1
  90. package/dist/types/components/resource-clear.d.ts.map +1 -1
  91. package/dist/types/components/resource-delete.d.ts +1 -1
  92. package/dist/types/components/resource-delete.d.ts.map +1 -1
  93. package/dist/types/components/resource-list.d.ts.map +1 -1
  94. package/dist/types/components/resource-sync.d.ts +1 -1
  95. package/dist/types/components/resource-sync.d.ts.map +1 -1
  96. package/dist/types/components/resource-types.d.ts.map +1 -1
  97. package/dist/types/components/resource-upload.d.ts +1 -1
  98. package/dist/types/components/resource-upload.d.ts.map +1 -1
  99. package/dist/types/components/run-show.d.ts.map +1 -1
  100. package/dist/types/components/schedule-create.d.ts +3 -1
  101. package/dist/types/components/schedule-create.d.ts.map +1 -1
  102. package/dist/types/components/schedule-delete.d.ts.map +1 -1
  103. package/dist/types/components/schedule-list.d.ts.map +1 -1
  104. package/dist/types/components/schedule-runs.d.ts +1 -1
  105. package/dist/types/components/schedule-runs.d.ts.map +1 -1
  106. package/dist/types/components/secrets-bulk.d.ts +7 -0
  107. package/dist/types/components/secrets-bulk.d.ts.map +1 -0
  108. package/dist/types/components/secrets-create.d.ts +7 -0
  109. package/dist/types/components/secrets-create.d.ts.map +1 -0
  110. package/dist/types/components/secrets-delete.d.ts +6 -0
  111. package/dist/types/components/secrets-delete.d.ts.map +1 -0
  112. package/dist/types/components/secrets-list.d.ts +2 -0
  113. package/dist/types/components/secrets-list.d.ts.map +1 -0
  114. package/dist/types/components/select-list.d.ts.map +1 -1
  115. package/dist/types/components/state-view.d.ts.map +1 -1
  116. package/dist/types/components/store-explorer.d.ts.map +1 -1
  117. package/dist/types/components/top-navigator.d.ts.map +1 -1
  118. package/dist/types/components/users-create.d.ts.map +1 -1
  119. package/dist/types/components/users-delete.d.ts.map +1 -1
  120. package/dist/types/components/users-keys-add.d.ts +1 -1
  121. package/dist/types/components/users-keys-add.d.ts.map +1 -1
  122. package/dist/types/components/users-keys-list.d.ts.map +1 -1
  123. package/dist/types/components/users-keys-remove.d.ts +1 -1
  124. package/dist/types/components/users-keys-remove.d.ts.map +1 -1
  125. package/dist/types/components/users-list.d.ts.map +1 -1
  126. package/dist/types/components/watch-machine.d.ts.map +1 -1
  127. package/dist/types/components/watch-resolver.d.ts +1 -1
  128. package/dist/types/components/watch-resolver.d.ts.map +1 -1
  129. package/dist/types/components/watch.d.ts +1 -1
  130. package/dist/types/components/watch.d.ts.map +1 -1
  131. package/dist/types/components/whoami.d.ts.map +1 -1
  132. package/dist/types/hooks/useAlternateScreen.d.ts +2 -0
  133. package/dist/types/hooks/useAlternateScreen.d.ts.map +1 -0
  134. package/dist/types/hooks/useApi.d.ts.map +1 -1
  135. package/dist/types/lib/jwt-auth.d.ts.map +1 -1
  136. package/dist/types/lib/ssh-key-utils.d.ts.map +1 -1
  137. package/package.json +4 -4
  138. package/dist/types/commands/secret.d.ts.map +0 -1
  139. package/dist/types/components/secret-bulk.d.ts +0 -7
  140. package/dist/types/components/secret-bulk.d.ts.map +0 -1
  141. package/dist/types/components/secret-create.d.ts +0 -7
  142. package/dist/types/components/secret-create.d.ts.map +0 -1
  143. package/dist/types/components/secret-delete.d.ts +0 -6
  144. package/dist/types/components/secret-delete.d.ts.map +0 -1
  145. package/dist/types/components/secret-list.d.ts +0 -2
  146. 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,16 @@ 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('rerun <run-id>', 'Rerun an existing brain run from a specific step\n', function(yargsRerun) {
501
+ return yargsRerun.positional('run-id', {
502
+ describe: 'ID of the brain run to rerun',
411
503
  type: 'string',
412
504
  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
505
  }).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');
506
+ describe: 'Step number to start execution from (1-indexed)',
507
+ type: 'number',
508
+ demandOption: true
509
+ }).alias('starts-at', 's').example('$0 rerun abc123 --starts-at=3', 'Rerun from step 3');
423
510
  }, function(argv) {
424
511
  var element = brainCommand.rerun(argv);
425
512
  render(element);
@@ -444,9 +531,36 @@ export function buildCli(options) {
444
531
  alias: 'o',
445
532
  string: true,
446
533
  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');
534
+ }).option('state', {
535
+ describe: 'Initial state values (key=value format, with type coercion)',
536
+ type: 'array',
537
+ alias: 's',
538
+ string: true,
539
+ coerce: parseStateValues
540
+ }).option('state-json', {
541
+ describe: 'Initial state as a JSON string',
542
+ type: 'string'
543
+ }).check(function(argv) {
544
+ if (argv.state && argv.stateJson) {
545
+ throw new Error('Cannot use both --state/-s and --state-json at the same time.');
546
+ }
547
+ return true;
548
+ }).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
549
  }, function(argv) {
449
- var element = brainCommand.run(argv);
550
+ var initialState;
551
+ if (argv.stateJson) {
552
+ try {
553
+ initialState = JSON.parse(argv.stateJson);
554
+ } catch (e) {
555
+ console.error("Invalid JSON for --state-json: ".concat(argv.stateJson));
556
+ process.exit(1);
557
+ }
558
+ } else if (argv.state) {
559
+ initialState = argv.state;
560
+ }
561
+ var element = brainCommand.run(_object_spread_props(_object_spread({}, argv), {
562
+ initialState: initialState
563
+ }));
450
564
  render(element);
451
565
  });
452
566
  // --- Watch Brain Run Command ---
@@ -514,21 +628,16 @@ export function buildCli(options) {
514
628
  }, function(argv) {
515
629
  var element = brainCommand.show(argv);
516
630
  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)',
631
+ }).command('rerun <run-id>', 'Rerun an existing brain run from a specific step\n', function(yargsRerun) {
632
+ return yargsRerun.positional('run-id', {
633
+ describe: 'ID of the brain run to rerun',
520
634
  type: 'string',
521
635
  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
636
  }).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');
637
+ describe: 'Step number to start execution from (1-indexed)',
638
+ type: 'number',
639
+ demandOption: true
640
+ }).alias('starts-at', 's').example('$0 brain rerun abc123 --starts-at=3', 'Rerun from step 3');
532
641
  }, function(argv) {
533
642
  var element = brainCommand.rerun(argv);
534
643
  render(element);
@@ -548,9 +657,36 @@ export function buildCli(options) {
548
657
  alias: 'o',
549
658
  string: true,
550
659
  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');
660
+ }).option('state', {
661
+ describe: 'Initial state values (key=value format, with type coercion)',
662
+ type: 'array',
663
+ alias: 's',
664
+ string: true,
665
+ coerce: parseStateValues
666
+ }).option('state-json', {
667
+ describe: 'Initial state as a JSON string',
668
+ type: 'string'
669
+ }).check(function(argv) {
670
+ if (argv.state && argv.stateJson) {
671
+ throw new Error('Cannot use both --state/-s and --state-json at the same time.');
672
+ }
673
+ return true;
674
+ }).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
675
  }, function(argv) {
553
- var element = brainCommand.run(argv);
676
+ var initialState;
677
+ if (argv.stateJson) {
678
+ try {
679
+ initialState = JSON.parse(argv.stateJson);
680
+ } catch (e) {
681
+ console.error("Invalid JSON for --state-json: ".concat(argv.stateJson));
682
+ process.exit(1);
683
+ }
684
+ } else if (argv.state) {
685
+ initialState = argv.state;
686
+ }
687
+ var element = brainCommand.run(_object_spread_props(_object_spread({}, argv), {
688
+ initialState: initialState
689
+ }));
554
690
  render(element);
555
691
  }).command('watch <identifier>', 'Watch a brain run by brain name or run ID\n', function(yargsWatch) {
556
692
  return yargsWatch.positional('identifier', {
@@ -781,9 +917,42 @@ export function buildCli(options) {
781
917
  describe: 'Cron expression for the schedule (e.g., "0 3 * * *" for daily at 3am)',
782
918
  type: 'string',
783
919
  demandOption: true
784
- }).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');
920
+ }).option('options', {
921
+ describe: 'Options to pass to the brain on each run (key=value format)',
922
+ type: 'array',
923
+ alias: 'o',
924
+ string: true,
925
+ coerce: parseKeyValueOptions
926
+ }).option('state', {
927
+ describe: 'Initial state values for each run (key=value format, with type coercion)',
928
+ type: 'array',
929
+ alias: 's',
930
+ string: true,
931
+ coerce: parseStateValues
932
+ }).option('state-json', {
933
+ describe: 'Initial state as a JSON string',
934
+ type: 'string'
935
+ }).check(function(argv) {
936
+ if (argv.state && argv.stateJson) {
937
+ throw new Error('Cannot use both --state/-s and --state-json at the same time.');
938
+ }
939
+ return true;
940
+ }).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');
785
941
  }, function(argv) {
786
- var element = scheduleCommand.create(argv);
942
+ var initialState;
943
+ if (argv.stateJson) {
944
+ try {
945
+ initialState = JSON.parse(argv.stateJson);
946
+ } catch (e) {
947
+ console.error("Invalid JSON for --state-json: ".concat(argv.stateJson));
948
+ process.exit(1);
949
+ }
950
+ } else if (argv.state) {
951
+ initialState = argv.state;
952
+ }
953
+ var element = scheduleCommand.create(_object_spread_props(_object_spread({}, argv), {
954
+ initialState: initialState
955
+ }));
787
956
  render(element);
788
957
  }).command('timezone [timezone]', 'Get or set the project timezone for schedules\n', function(yargsTimezone) {
789
958
  return yargsTimezone.positional('timezone', {
@@ -840,10 +1009,10 @@ export function buildCli(options) {
840
1009
  }).demandCommand(1, 'You need to specify a subcommand');
841
1010
  return yargsPages;
842
1011
  });
843
- // --- Secret Management Commands ---
844
- cli = cli.command('secret', 'Manage secrets for your brains\n', function(yargsSecret) {
1012
+ // --- Secrets Management Commands ---
1013
+ cli = cli.command('secrets', 'Manage secrets for your brains\n', function(yargsSecret) {
845
1014
  yargsSecret.command('list', 'List all secrets\n', {}, function() {
846
- var element = secretCommand.list();
1015
+ var element = secretsCommand.list();
847
1016
  render(element);
848
1017
  }).command('create <name>', 'Create a new secret\n', function(yargsCreate) {
849
1018
  return yargsCreate.positional('name', {
@@ -853,26 +1022,26 @@ export function buildCli(options) {
853
1022
  }).option('value', {
854
1023
  describe: 'Secret value (omit for secure input)',
855
1024
  type: 'string'
856
- }).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)');
1025
+ }).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)');
857
1026
  }, function(argv) {
858
- var element = secretCommand.create(argv);
1027
+ var element = secretsCommand.create(argv);
859
1028
  render(element);
860
1029
  }).command('delete <name>', 'Delete a secret\n', function(yargsDelete) {
861
1030
  return yargsDelete.positional('name', {
862
1031
  describe: 'Name of the secret to delete',
863
1032
  type: 'string',
864
1033
  demandOption: true
865
- }).example('$0 secret delete ANTHROPIC_API_KEY', 'Delete a secret');
1034
+ }).example('$0 secrets delete ANTHROPIC_API_KEY', 'Delete a secret');
866
1035
  }, function(argv) {
867
- var element = secretCommand.delete(argv);
1036
+ var element = secretsCommand.delete(argv);
868
1037
  render(element);
869
1038
  }).command('bulk [file]', 'Bulk upload secrets from a .env file\n', function(yargsBulk) {
870
1039
  return yargsBulk.positional('file', {
871
1040
  describe: 'Path to the .env file (defaults to .env in project root)',
872
1041
  type: 'string'
873
- }).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');
1042
+ }).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');
874
1043
  }, function(argv) {
875
- var element = secretCommand.bulk(argv);
1044
+ var element = secretsCommand.bulk(argv);
876
1045
  render(element);
877
1046
  }).demandCommand(1, 'You need to specify a subcommand');
878
1047
  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,13 +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;
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
- cronExpression: cronExpression
42
+ cronExpression: cronExpression,
43
+ options: options,
44
+ initialState: initialState
43
45
  });
44
46
  }
45
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,