@roarkanalytics/cli 0.67.1 → 0.68.0

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 (51) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/README.md +22 -0
  3. package/completions.js +3 -3
  4. package/npm-shrinkwrap.json +2 -2
  5. package/package.json +1 -1
  6. package/runtime/commands/config-as-code.js +5 -23
  7. package/runtime/commands/get-started.d.ts +34 -0
  8. package/runtime/commands/get-started.js +350 -0
  9. package/runtime/config-bundle.d.ts +10 -0
  10. package/runtime/config-bundle.js +14 -3
  11. package/runtime/config-changes.d.ts +15 -0
  12. package/runtime/config-changes.js +32 -0
  13. package/runtime/get-started/account.d.ts +18 -0
  14. package/runtime/get-started/account.js +35 -0
  15. package/runtime/get-started/agent.d.ts +17 -0
  16. package/runtime/get-started/agent.js +116 -0
  17. package/runtime/get-started/answers.d.ts +15 -0
  18. package/runtime/get-started/answers.js +42 -0
  19. package/runtime/get-started/apply.d.ts +35 -0
  20. package/runtime/get-started/apply.js +54 -0
  21. package/runtime/get-started/existing.d.ts +15 -0
  22. package/runtime/get-started/existing.js +47 -0
  23. package/runtime/get-started/ladder.d.ts +37 -0
  24. package/runtime/get-started/ladder.js +69 -0
  25. package/runtime/get-started/module.d.ts +20 -0
  26. package/runtime/get-started/module.js +159 -0
  27. package/runtime/get-started/placeholder.d.ts +9 -0
  28. package/runtime/get-started/placeholder.js +36 -0
  29. package/runtime/get-started/prompt.d.ts +32 -0
  30. package/runtime/get-started/prompt.js +132 -0
  31. package/runtime/get-started/resources.d.ts +106 -0
  32. package/runtime/get-started/resources.js +184 -0
  33. package/runtime/get-started/run.d.ts +42 -0
  34. package/runtime/get-started/run.js +101 -0
  35. package/runtime/get-started/scaffold-only.d.ts +19 -0
  36. package/runtime/get-started/scaffold-only.js +43 -0
  37. package/runtime/get-started/scaffold.d.ts +15 -0
  38. package/runtime/get-started/scaffold.js +35 -0
  39. package/runtime/get-started/starter-metrics.d.ts +33 -0
  40. package/runtime/get-started/starter-metrics.js +104 -0
  41. package/runtime/get-started/steps.d.ts +33 -0
  42. package/runtime/get-started/steps.js +112 -0
  43. package/runtime/get-started/target.d.ts +47 -0
  44. package/runtime/get-started/target.js +81 -0
  45. package/runtime/get-started/types.d.ts +18 -0
  46. package/runtime/get-started/types.js +8 -0
  47. package/runtime/get-started/watch.d.ts +57 -0
  48. package/runtime/get-started/watch.js +103 -0
  49. package/runtime/program.js +5 -0
  50. package/version.d.ts +1 -1
  51. package/version.js +1 -1
@@ -0,0 +1,103 @@
1
+ "use strict";
2
+ /**
3
+ * Watching the first run finish.
4
+ *
5
+ * A simulated call takes a minute or two, and the one thing someone wants from their first run is
6
+ * the verdict, so the command waits for it rather than printing a job id and leaving. It is a
7
+ * plain poll of `GET /v1/simulation/plan/job/{id}`: no websocket, no spinner, one line per status
8
+ * change so a pipe or a CI log stays readable.
9
+ *
10
+ * Waiting is bounded. Timing out is reported as "still running, here is how to check", never as a
11
+ * failure: the run is perfectly fine, it is this command's patience that ran out.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.sleep = exports.verdictStyle = exports.verdictLine = exports.watchJob = exports.progressLine = exports.TERMINAL_STATUSES = void 0;
15
+ /** Statuses a run never leaves. Anything else is still in flight. */
16
+ exports.TERMINAL_STATUSES = new Set([
17
+ 'COMPLETED',
18
+ 'FAILED',
19
+ 'TIMED_OUT',
20
+ 'CANCELLED',
21
+ ]);
22
+ /** How many polls in a row may fail before the wait is given up on. */
23
+ const ERROR_TOLERANCE = 3;
24
+ /** Stands in for a run we never managed to read, so the caller still has something to print. */
25
+ const UNREADABLE = { status: 'UNKNOWN' };
26
+ const progressLine = (snapshot) => {
27
+ const jobs = snapshot.simulationJobs ?? [];
28
+ if (jobs.length === 0)
29
+ return snapshot.status;
30
+ const done = jobs.filter((job) => exports.TERMINAL_STATUSES.has(job.status)).length;
31
+ return `${snapshot.status} ${done}/${jobs.length} calls finished`;
32
+ };
33
+ exports.progressLine = progressLine;
34
+ const watchJob = async (options) => {
35
+ const started = options.now();
36
+ let last;
37
+ let latest;
38
+ let failures = 0;
39
+ for (;;) {
40
+ // A poll that throws must not take the command down with it. The run has already started by
41
+ // the time we are here, so an exception would lose the job id and the "check it later" line
42
+ // over one network blip. A few in a row is a different matter: then we stop waiting and say so.
43
+ let snapshot;
44
+ try {
45
+ snapshot = await options.getJob(options.jobId);
46
+ failures = 0;
47
+ }
48
+ catch {
49
+ failures += 1;
50
+ if (failures >= ERROR_TOLERANCE)
51
+ return { snapshot: latest ?? UNREADABLE, outcome: 'unreachable' };
52
+ }
53
+ if (snapshot !== undefined) {
54
+ latest = snapshot;
55
+ const line = (0, exports.progressLine)(snapshot);
56
+ if (line !== last) {
57
+ options.onProgress(line);
58
+ last = line;
59
+ }
60
+ if (exports.TERMINAL_STATUSES.has(snapshot.status))
61
+ return { snapshot, outcome: 'settled' };
62
+ }
63
+ if (options.now() - started >= options.timeoutMs) {
64
+ return { snapshot: latest ?? UNREADABLE, outcome: 'timeout' };
65
+ }
66
+ await options.sleep(options.pollMs);
67
+ }
68
+ };
69
+ exports.watchJob = watchJob;
70
+ /**
71
+ * The headline.
72
+ *
73
+ * Two different absences of a verdict, and conflating them is a lie either way. A COMPLETED run
74
+ * with no verdict carried no pass/fail criterion, so there was nothing to judge. A run that ended
75
+ * FAILED, TIMED_OUT or CANCELLED also has no verdict, but there "no pass/fail criteria on this
76
+ * run" would read as reassurance about a run that fell over.
77
+ */
78
+ const verdictLine = (snapshot) => {
79
+ if (snapshot.status !== 'COMPLETED') {
80
+ return `The run ended ${snapshot.status}, so nothing was graded.`;
81
+ }
82
+ const verdict = snapshot.verdict;
83
+ if (verdict === undefined || verdict === null) {
84
+ return 'No pass/fail criteria on this run, so there is no verdict. The metric values are on the run.';
85
+ }
86
+ const score = typeof verdict.score === 'number' ? `, score ${Math.round(verdict.score)}/100` : '';
87
+ return verdict.passed ? `Passed${score}` : `Failed${score}`;
88
+ };
89
+ exports.verdictLine = verdictLine;
90
+ /** Green for a pass, red for a failed check or a run that fell over, yellow for nothing judged. */
91
+ const verdictStyle = (snapshot) => {
92
+ if (snapshot.status !== 'COMPLETED')
93
+ return 'red';
94
+ const passed = snapshot.verdict?.passed;
95
+ if (passed === undefined)
96
+ return 'yellow';
97
+ return passed ? 'green' : 'red';
98
+ };
99
+ exports.verdictStyle = verdictStyle;
100
+ const sleep = (ms) => new Promise((resolve) => {
101
+ setTimeout(resolve, ms);
102
+ });
103
+ exports.sleep = sleep;
@@ -16,6 +16,7 @@ const api_1 = require("./commands/api");
16
16
  const auth_1 = require("./commands/auth");
17
17
  const config_as_code_1 = require("./commands/config-as-code");
18
18
  const config_1 = require("./commands/config");
19
+ const get_started_1 = require("./commands/get-started");
19
20
  const completion_1 = require("./commands/completion");
20
21
  const confirm_1 = require("./confirm");
21
22
  const config_2 = require("./config");
@@ -308,12 +309,16 @@ const createProgram = (options) => {
308
309
  continue;
309
310
  addApiCommand(root, options, definition);
310
311
  }
312
+ (0, get_started_1.registerGetStartedCommand)(root, options.binaryName, clientFor, exports.resolveOutput);
311
313
  (0, auth_1.registerAuthCommands)(root, options.binaryName, clientFor);
312
314
  (0, config_as_code_1.registerConfigAsCodeCommands)(root, options.binaryName, clientFor, exports.resolveOutput);
313
315
  (0, config_1.registerConfigCommands)(root, options.binaryName);
314
316
  (0, api_1.registerApiCommand)(root, options.binaryName, clientFor, exports.resolveOutput);
315
317
  (0, completion_1.registerCompletionCommand)(root, options.binaryName, options.completions);
316
318
  root.addHelpText('after', [
319
+ '',
320
+ 'New here?',
321
+ ` ${options.binaryName} get-started an agent, a caller, a scenario, metrics, and a graded run`,
317
322
  '',
318
323
  'Environment:',
319
324
  ' ROARK_API_BEARER_TOKEN bearer token used when --token is not given',
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "0.67.1";
1
+ export declare const version = "0.68.0";
package/version.js CHANGED
@@ -10,4 +10,4 @@ exports.version = void 0;
10
10
  //
11
11
  // Do not edit: an edit here is overwritten, and the published number is whatever
12
12
  // package.json says.
13
- exports.version = '0.67.1'; // x-release-please-version
13
+ exports.version = '0.68.0'; // x-release-please-version