@blokjs/runner 0.4.0 → 0.6.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 (163) hide show
  1. package/dist/Blok.js +32 -3
  2. package/dist/Blok.js.map +1 -1
  3. package/dist/Configuration.d.ts +41 -5
  4. package/dist/Configuration.js +215 -92
  5. package/dist/Configuration.js.map +1 -1
  6. package/dist/ForEachNode.d.ts +59 -0
  7. package/dist/ForEachNode.js +522 -0
  8. package/dist/ForEachNode.js.map +1 -0
  9. package/dist/LoopMaxIterationsError.d.ts +11 -0
  10. package/dist/LoopMaxIterationsError.js +18 -0
  11. package/dist/LoopMaxIterationsError.js.map +1 -0
  12. package/dist/LoopNode.d.ts +36 -0
  13. package/dist/LoopNode.js +182 -0
  14. package/dist/LoopNode.js.map +1 -0
  15. package/dist/Runner.d.ts +11 -1
  16. package/dist/Runner.js +9 -2
  17. package/dist/Runner.js.map +1 -1
  18. package/dist/RunnerSteps.js +419 -112
  19. package/dist/RunnerSteps.js.map +1 -1
  20. package/dist/RuntimeAdapterNode.d.ts +2 -1
  21. package/dist/RuntimeAdapterNode.js +2 -2
  22. package/dist/RuntimeAdapterNode.js.map +1 -1
  23. package/dist/RuntimeRegistry.d.ts +23 -2
  24. package/dist/RuntimeRegistry.js +31 -2
  25. package/dist/RuntimeRegistry.js.map +1 -1
  26. package/dist/SubworkflowNode.d.ts +106 -0
  27. package/dist/SubworkflowNode.js +261 -3
  28. package/dist/SubworkflowNode.js.map +1 -1
  29. package/dist/SwitchNode.d.ts +37 -0
  30. package/dist/SwitchNode.js +153 -0
  31. package/dist/SwitchNode.js.map +1 -0
  32. package/dist/TriggerBase.d.ts +50 -0
  33. package/dist/TriggerBase.js +262 -4
  34. package/dist/TriggerBase.js.map +1 -1
  35. package/dist/TryCatchNode.d.ts +32 -0
  36. package/dist/TryCatchNode.js +207 -0
  37. package/dist/TryCatchNode.js.map +1 -0
  38. package/dist/adapters/grpc/GrpcCodec.js +2 -2
  39. package/dist/adapters/grpc/GrpcRuntimeAdapter.d.ts +6 -4
  40. package/dist/adapters/grpc/GrpcRuntimeAdapter.js +6 -4
  41. package/dist/adapters/grpc/GrpcRuntimeAdapter.js.map +1 -1
  42. package/dist/adapters/grpc/types.d.ts +7 -5
  43. package/dist/adapters/grpc/types.js.map +1 -1
  44. package/dist/adapters/transport.d.ts +12 -41
  45. package/dist/adapters/transport.js +21 -70
  46. package/dist/adapters/transport.js.map +1 -1
  47. package/dist/cache/NodeResultCache.js +7 -0
  48. package/dist/cache/NodeResultCache.js.map +1 -1
  49. package/dist/concurrency/NatsKvConcurrencyBackend.js +18 -5
  50. package/dist/concurrency/NatsKvConcurrencyBackend.js.map +1 -1
  51. package/dist/concurrency/RedisConcurrencyBackend.d.ts +64 -0
  52. package/dist/concurrency/RedisConcurrencyBackend.js +374 -0
  53. package/dist/concurrency/RedisConcurrencyBackend.js.map +1 -0
  54. package/dist/concurrency/createConcurrencyBackend.d.ts +1 -0
  55. package/dist/concurrency/createConcurrencyBackend.js +5 -1
  56. package/dist/concurrency/createConcurrencyBackend.js.map +1 -1
  57. package/dist/defineNode.d.ts +8 -0
  58. package/dist/defineNode.js +25 -5
  59. package/dist/defineNode.js.map +1 -1
  60. package/dist/graphql/GraphQLSchemaGenerator.js +1 -1
  61. package/dist/graphql/GraphQLSchemaGenerator.js.map +1 -1
  62. package/dist/index.d.ts +10 -6
  63. package/dist/index.js +13 -9
  64. package/dist/index.js.map +1 -1
  65. package/dist/marketplace/RuntimeCatalog.d.ts +6 -0
  66. package/dist/marketplace/RuntimeCatalog.js.map +1 -1
  67. package/dist/marketplace/RuntimeDiscovery.d.ts +2 -2
  68. package/dist/marketplace/RuntimeDiscovery.js +18 -6
  69. package/dist/marketplace/RuntimeDiscovery.js.map +1 -1
  70. package/dist/monitoring/ConcurrencyMetrics.d.ts +26 -0
  71. package/dist/monitoring/ConcurrencyMetrics.js +36 -4
  72. package/dist/monitoring/ConcurrencyMetrics.js.map +1 -1
  73. package/dist/monitoring/ForEachWaitMetrics.d.ts +22 -0
  74. package/dist/monitoring/ForEachWaitMetrics.js +36 -0
  75. package/dist/monitoring/ForEachWaitMetrics.js.map +1 -0
  76. package/dist/openapi/OpenAPIGenerator.js +7 -2
  77. package/dist/openapi/OpenAPIGenerator.js.map +1 -1
  78. package/dist/runtime/PrimitiveStack.d.ts +64 -0
  79. package/dist/runtime/PrimitiveStack.js +92 -0
  80. package/dist/runtime/PrimitiveStack.js.map +1 -0
  81. package/dist/scheduling/DebounceBackend.d.ts +108 -0
  82. package/dist/scheduling/DebounceBackend.js +23 -0
  83. package/dist/scheduling/DebounceBackend.js.map +1 -0
  84. package/dist/scheduling/DebounceCoordinator.d.ts +65 -12
  85. package/dist/scheduling/DebounceCoordinator.js +234 -13
  86. package/dist/scheduling/DebounceCoordinator.js.map +1 -1
  87. package/dist/scheduling/DeferredRunScheduler.d.ts +28 -0
  88. package/dist/scheduling/DeferredRunScheduler.js +105 -3
  89. package/dist/scheduling/DeferredRunScheduler.js.map +1 -1
  90. package/dist/scheduling/NatsKvDebounceBackend.d.ts +53 -0
  91. package/dist/scheduling/NatsKvDebounceBackend.js +334 -0
  92. package/dist/scheduling/NatsKvDebounceBackend.js.map +1 -0
  93. package/dist/scheduling/RedisDebounceBackend.d.ts +49 -0
  94. package/dist/scheduling/RedisDebounceBackend.js +356 -0
  95. package/dist/scheduling/RedisDebounceBackend.js.map +1 -0
  96. package/dist/scheduling/createDebounceBackend.d.ts +25 -0
  97. package/dist/scheduling/createDebounceBackend.js +39 -0
  98. package/dist/scheduling/createDebounceBackend.js.map +1 -0
  99. package/dist/security/AuditLogger.js +1 -1
  100. package/dist/security/AuditLogger.js.map +1 -1
  101. package/dist/security/AuthMiddleware.d.ts +19 -20
  102. package/dist/security/AuthMiddleware.js +35 -20
  103. package/dist/security/AuthMiddleware.js.map +1 -1
  104. package/dist/security/OAuthProvider.js +2 -2
  105. package/dist/security/OAuthProvider.js.map +1 -1
  106. package/dist/security/SecretManager.js +14 -13
  107. package/dist/security/SecretManager.js.map +1 -1
  108. package/dist/security/index.d.ts +3 -1
  109. package/dist/security/index.js +3 -1
  110. package/dist/security/index.js.map +1 -1
  111. package/dist/testing/TestHarness.d.ts +27 -12
  112. package/dist/testing/TestHarness.js +19 -3
  113. package/dist/testing/TestHarness.js.map +1 -1
  114. package/dist/testing/WorkflowTestRunner.js +0 -7
  115. package/dist/testing/WorkflowTestRunner.js.map +1 -1
  116. package/dist/tracing/InMemoryRunStore.d.ts +14 -1
  117. package/dist/tracing/InMemoryRunStore.js +95 -6
  118. package/dist/tracing/InMemoryRunStore.js.map +1 -1
  119. package/dist/tracing/PostgresRunStore.d.ts +28 -2
  120. package/dist/tracing/PostgresRunStore.js +276 -3
  121. package/dist/tracing/PostgresRunStore.js.map +1 -1
  122. package/dist/tracing/RoutingDiagnostics.d.ts +55 -0
  123. package/dist/tracing/RoutingDiagnostics.js +50 -0
  124. package/dist/tracing/RoutingDiagnostics.js.map +1 -0
  125. package/dist/tracing/RunStore.d.ts +82 -1
  126. package/dist/tracing/RunTracker.d.ts +7 -1
  127. package/dist/tracing/RunTracker.js +23 -0
  128. package/dist/tracing/RunTracker.js.map +1 -1
  129. package/dist/tracing/SqliteRunStore.d.ts +57 -2
  130. package/dist/tracing/SqliteRunStore.js +408 -48
  131. package/dist/tracing/SqliteRunStore.js.map +1 -1
  132. package/dist/tracing/TraceRouter.js +380 -18
  133. package/dist/tracing/TraceRouter.js.map +1 -1
  134. package/dist/tracing/createStore.js +14 -3
  135. package/dist/tracing/createStore.js.map +1 -1
  136. package/dist/tracing/metadataFilter.d.ts +63 -0
  137. package/dist/tracing/metadataFilter.js +224 -0
  138. package/dist/tracing/metadataFilter.js.map +1 -0
  139. package/dist/tracing/types.d.ts +331 -7
  140. package/dist/utils/envAllowlist.d.ts +35 -0
  141. package/dist/utils/envAllowlist.js +113 -0
  142. package/dist/utils/envAllowlist.js.map +1 -0
  143. package/dist/version/RuntimeVersionValidator.d.ts +38 -0
  144. package/dist/version/RuntimeVersionValidator.js +121 -0
  145. package/dist/version/RuntimeVersionValidator.js.map +1 -0
  146. package/dist/visualization/WorkflowVisualizer.js +4 -4
  147. package/dist/visualization/WorkflowVisualizer.js.map +1 -1
  148. package/dist/workflow/PersistenceHelper.d.ts +18 -10
  149. package/dist/workflow/PersistenceHelper.js +35 -9
  150. package/dist/workflow/PersistenceHelper.js.map +1 -1
  151. package/dist/workflow/WorkflowNormalizer.d.ts +19 -1
  152. package/dist/workflow/WorkflowNormalizer.js +469 -19
  153. package/dist/workflow/WorkflowNormalizer.js.map +1 -1
  154. package/dist/workflow/WorkflowRegistry.d.ts +122 -0
  155. package/dist/workflow/WorkflowRegistry.js +121 -0
  156. package/dist/workflow/WorkflowRegistry.js.map +1 -1
  157. package/dist/workflow/sampleBody.d.ts +54 -0
  158. package/dist/workflow/sampleBody.js +320 -0
  159. package/dist/workflow/sampleBody.js.map +1 -0
  160. package/package.json +3 -8
  161. package/dist/adapters/HttpRuntimeAdapter.d.ts +0 -79
  162. package/dist/adapters/HttpRuntimeAdapter.js +0 -233
  163. package/dist/adapters/HttpRuntimeAdapter.js.map +0 -1
@@ -0,0 +1,182 @@
1
+ /**
2
+ * LoopNode — v0.5 primitive. While-loop with hard maxIterations safety
3
+ * cap. Runs a sub-pipeline as long as the `while` condition evaluates
4
+ * truthy against the live ctx. Each iteration carries forward state
5
+ * mutations (sequential by definition) so condition variables can
6
+ * advance between iterations.
7
+ *
8
+ * The runtime config is read from `ctx.config[this.name]`:
9
+ * {
10
+ * while: string, // JS expression evaluated against ctx
11
+ * maxIterations: number, // hard safety cap; throws LoopMaxIterationsError on hit
12
+ * steps: NodeBase[], // pre-resolved by Configuration's isFlowWithProperties path
13
+ * }
14
+ *
15
+ * The loop counter is exposed as `ctx.state[<stepId>Index]` (0-based)
16
+ * so the `while` expression can reference it. Each iteration's final
17
+ * step output is the loop step's overall data (the last iteration's
18
+ * `ctx.response.data`).
19
+ */
20
+ import _ from "lodash";
21
+ import { LoopMaxIterationsError } from "./LoopMaxIterationsError";
22
+ import RunnerNode from "./RunnerNode";
23
+ import { consumeRehydratedCursor, popPrimitiveFrame, pushPrimitiveFrame, readRehydratedCursor, } from "./runtime/PrimitiveStack";
24
+ import { applyStepOutput } from "./workflow/PersistenceHelper";
25
+ const DEFAULT_MAX_ITERATIONS = 1000;
26
+ export class LoopNode extends RunnerNode {
27
+ /**
28
+ * v0.6 marker — RunnerSteps stamps `_blokActivePrimitiveNodeRunId`
29
+ * on ctx around `step.process()` calls when this flag is true so a
30
+ * nested wait fired inside an iteration body knows which NodeRun to
31
+ * write its `iteration_context` cursor to. Mirrors ForEachNode's
32
+ * marker (Phase 2). Static `true` (vs an instance method) avoids
33
+ * importing LoopNode inside RunnerSteps, which would create a
34
+ * circular dependency.
35
+ */
36
+ isPrimitiveIterator = true;
37
+ async run(ctx) {
38
+ this.contentType = "application/json";
39
+ const response = { success: true, data: null, error: null };
40
+ const opts = (ctx.config?.[this.name] ?? {});
41
+ const whileExpr = typeof opts.while === "string" ? opts.while : "false";
42
+ const envCap = process.env.BLOK_LOOP_MAX_ITERATIONS
43
+ ? Number.parseInt(process.env.BLOK_LOOP_MAX_ITERATIONS, 10)
44
+ : undefined;
45
+ const maxIterations = typeof opts.maxIterations === "number" && opts.maxIterations > 0
46
+ ? opts.maxIterations
47
+ : envCap && envCap > 0
48
+ ? envCap
49
+ : DEFAULT_MAX_ITERATIONS;
50
+ const steps = (opts.steps ?? []);
51
+ if (steps.length === 0) {
52
+ return response;
53
+ }
54
+ // v0.6 — read the resume hint. Phase 4 — cursors are keyed by
55
+ // NodeRun id in the rehydrated map so a loop nested inside
56
+ // another primitive (or vice versa) finds its OWN cursor.
57
+ // Falls back to the legacy single-slot field for back-compat.
58
+ const ctxAny = ctx;
59
+ const myNodeRunId = ctxAny._traceNodeId;
60
+ // Phase 4 — lookup by step NAME (stable across re-entries).
61
+ let resume = readRehydratedCursor(ctx, this.name);
62
+ if (resume) {
63
+ consumeRehydratedCursor(ctx, this.name);
64
+ }
65
+ if (resume === undefined) {
66
+ const legacyResume = ctxAny._blokIterationResume;
67
+ if (legacyResume !== undefined) {
68
+ resume = legacyResume;
69
+ ctxAny._blokIterationResume = undefined;
70
+ }
71
+ }
72
+ const { default: Runner } = await import("./Runner");
73
+ const counterKey = `${this.name}Index`;
74
+ const state = (ctx.state ?? {});
75
+ let iteration = resume?.iteration ?? 0;
76
+ let lastData = null;
77
+ // v0.6 Phase 4 — push a primitive frame for THIS loop so a
78
+ // nested wait persists THIS loop's iteration cursor to THIS
79
+ // loop's NodeRun (and outer primitives' cursors to THEIRS).
80
+ // Loop returns the LAST iteration's output, so `completedResults`
81
+ // is always `[]` — preserved at schema level for parity with
82
+ // forEach.
83
+ const initialCursor = {
84
+ mode: "sequential",
85
+ iteration: 0,
86
+ innerStepIndex: 0,
87
+ completedResults: [],
88
+ };
89
+ const frame = myNodeRunId
90
+ ? { nodeRunId: myNodeRunId, cursor: initialCursor }
91
+ : undefined;
92
+ if (frame)
93
+ pushPrimitiveFrame(ctx, frame);
94
+ try {
95
+ while (true) {
96
+ state[counterKey] = iteration;
97
+ // v0.6 Phase 3 — on the first iteration after a wait-resume,
98
+ // skip the while-condition check. The condition was already
99
+ // TRUE when the wait fired (otherwise iter N wouldn't have
100
+ // started), and we've committed to finishing iter N's body
101
+ // — re-evaluating now would compare against post-iter-N
102
+ // state (e.g. a counter advanced by the pre-wait steps) and
103
+ // could falsely terminate the loop. Subsequent iterations
104
+ // re-check normally.
105
+ const isFirstIterationAfterResume = resume !== undefined && iteration === resume.iteration;
106
+ if (!isFirstIterationAfterResume) {
107
+ // Re-clone config each iteration so mapper-resolved
108
+ // values from prior iterations don't bleed into the
109
+ // next condition eval.
110
+ const evalCtx = { ...ctx, config: _.cloneDeep(ctx.config) };
111
+ const shouldContinue = this.evaluateCondition(whileExpr, evalCtx);
112
+ if (!shouldContinue)
113
+ break;
114
+ }
115
+ if (iteration >= maxIterations) {
116
+ throw new LoopMaxIterationsError(this.name, maxIterations, iteration);
117
+ }
118
+ // v0.6 Phase 4 — update the frame cursor before launching
119
+ // the iteration body. The wait-throw site walks the stack
120
+ // and writes the cursor; the TOP frame is THIS loop's,
121
+ // so we need `iteration` to point at the in-flight pass.
122
+ if (frame) {
123
+ frame.cursor.iteration = iteration;
124
+ }
125
+ const childCtx = this.cloneCtxForIteration(ctx);
126
+ // v0.5.3 — stash iteration index on the per-iteration
127
+ // child ctx so RunnerSteps propagates it to
128
+ // NodeRun.iterationIndex (Studio groups inner steps under
129
+ // "iteration N" headers).
130
+ childCtx._blokIterationIndex = iteration;
131
+ // v0.6 Phase 3 — pass the inner-step resume cursor on the
132
+ // child ctx for the first iteration after resume.
133
+ // Phase 4 — propagate the index-0 case so the deep
134
+ // runSteps' wait re-entry detection sees innerResumeIndex
135
+ // defined even when the wait is at body[0].
136
+ if (isFirstIterationAfterResume && resume !== undefined) {
137
+ childCtx._blokInnerResumeIndex = resume.innerStepIndex;
138
+ }
139
+ const runner = new Runner(steps);
140
+ // `deep: true` — inner pipelines must not inherit the
141
+ // outer run's `lastCompletedStepIndex` cursor.
142
+ await runner.run(childCtx, { deep: true, stepName: this.name });
143
+ // Carry state forward into the parent ctx so subsequent
144
+ // iterations see updates.
145
+ const childState = (childCtx.state ?? {});
146
+ for (const [k, v] of Object.entries(childState)) {
147
+ state[k] = v;
148
+ }
149
+ lastData = childCtx.response;
150
+ iteration++;
151
+ }
152
+ response.data = lastData;
153
+ // Persist to ctx.state[this.name] (see ForEachNode comment).
154
+ applyStepOutput(ctx, this, { data: lastData });
155
+ return response;
156
+ }
157
+ finally {
158
+ // v0.6 Phase 4 — always pop so sibling loops / outer
159
+ // runSteps see a clean stack, including on wait re-throw.
160
+ if (frame)
161
+ popPrimitiveFrame(ctx);
162
+ }
163
+ }
164
+ evaluateCondition(expr, ctx) {
165
+ const data = (ctx.response?.data ?? ctx.request?.body ?? {});
166
+ const vars = (ctx.vars ?? {});
167
+ const fn = new Function("ctx", "data", "vars", `"use strict";return (${expr});`);
168
+ return fn(ctx, data, vars);
169
+ }
170
+ cloneCtxForIteration(ctx) {
171
+ // State is shared by reference (mutations carry forward — that's
172
+ // the loop semantic). Config is deep-cloned so mapper resolutions
173
+ // don't bleed across iterations.
174
+ const config = _.cloneDeep(ctx.config);
175
+ return {
176
+ ...ctx,
177
+ config,
178
+ response: { data: null, success: true, error: null, contentType: "application/json" },
179
+ };
180
+ }
181
+ }
182
+ //# sourceMappingURL=LoopNode.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"LoopNode.js","sourceRoot":"","sources":["../src/LoopNode.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAGH,OAAO,CAAC,MAAM,QAAQ,CAAC;AACvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,UAAU,MAAM,cAAc,CAAC;AACtC,OAAO,EAEN,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,oBAAoB,GACpB,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAqC/D,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAEpC,MAAM,OAAO,QAAS,SAAQ,UAAU;IACvC;;;;;;;;OAQG;IACa,mBAAmB,GAAG,IAAI,CAAC;IAE3C,KAAK,CAAC,GAAG,CAAC,GAAY;QACrB,IAAI,CAAC,WAAW,GAAG,kBAAkB,CAAC;QACtC,MAAM,QAAQ,GAAoB,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC;QAE7E,MAAM,IAAI,GAAG,CAAE,GAAG,CAAC,MAA8C,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAa,CAAC;QAClG,MAAM,SAAS,GAAG,OAAO,IAAI,CAAC,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,IA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AE,kBAAkB,EAAE;SAC1E,CAAC;IACd,CAAC;CACD"}
package/dist/Runner.d.ts CHANGED
@@ -19,7 +19,17 @@ export default class Runner extends RunnerSteps {
19
19
  * Executes the series of BlokService steps with the given context.
20
20
  *
21
21
  * @param ctx - The context to be passed through the steps.
22
+ * @param options - Optional execution options:
23
+ * - `deep`: if true, treats this as a nested flow run — disables
24
+ * top-level concerns like the wait/resume cursor
25
+ * (`lastCompletedStepIndex`) and parent-run trace updates so
26
+ * inner pipelines (forEach, loop, switch, tryCatch) don't
27
+ * accidentally inherit the outer run's cursor and skip ahead.
28
+ * - `stepName`: parent step's id, surfaced in nested-runner log lines.
22
29
  * @returns A promise that resolves to the final context after all steps have been executed.
23
30
  */
24
- run(ctx: Context): Promise<Context>;
31
+ run(ctx: Context, options?: {
32
+ deep?: boolean;
33
+ stepName?: string;
34
+ }): Promise<Context>;
25
35
  }
package/dist/Runner.js CHANGED
@@ -23,10 +23,17 @@ export default class Runner extends RunnerSteps {
23
23
  * Executes the series of BlokService steps with the given context.
24
24
  *
25
25
  * @param ctx - The context to be passed through the steps.
26
+ * @param options - Optional execution options:
27
+ * - `deep`: if true, treats this as a nested flow run — disables
28
+ * top-level concerns like the wait/resume cursor
29
+ * (`lastCompletedStepIndex`) and parent-run trace updates so
30
+ * inner pipelines (forEach, loop, switch, tryCatch) don't
31
+ * accidentally inherit the outer run's cursor and skip ahead.
32
+ * - `stepName`: parent step's id, surfaced in nested-runner log lines.
26
33
  * @returns A promise that resolves to the final context after all steps have been executed.
27
34
  */
28
- async run(ctx) {
29
- return await this.runSteps(ctx, this.steps);
35
+ async run(ctx, options) {
36
+ return await this.runSteps(ctx, this.steps, options?.deep ?? false, options?.stepName ?? "");
30
37
  }
31
38
  }
32
39
  //# sourceMappingURL=Runner.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Runner.js","sourceRoot":"","sources":["../src/Runner.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,WAAW;IACtC,KAAK,CAAa;IAE1B;;;;OAIG;IACH,YAAY,QAAoB,EAAE;QACjC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,YAAY;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG,CAAC,GAAY;QACrB,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC;CACD"}
1
+ {"version":3,"file":"Runner.js","sourceRoot":"","sources":["../src/Runner.ts"],"names":[],"mappings":"AACA,OAAO,WAAW,MAAM,eAAe,CAAC;AAExC;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,WAAW;IACtC,KAAK,CAAa;IAE1B;;;;OAIG;IACH,YAAY,QAAoB,EAAE;QACjC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,YAAY;QACX,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC1B,CAAC;IAED;;;;;;;;;;;;OAYG;IACH,KAAK,CAAC,GAAG,CAAC,GAAY,EAAE,OAA+C;QACtE,OAAO,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,IAAI,IAAI,KAAK,EAAE,OAAO,EAAE,QAAQ,IAAI,EAAE,CAAC,CAAC;IAC9F,CAAC;CACD"}