@abyss-project/runtime 0.0.0-stage → 2.0.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 (132) hide show
  1. package/.eslintrc.js +32 -0
  2. package/.prettierrc +5 -0
  3. package/README.md +28 -3
  4. package/dist/access/access.types.d.ts +14 -0
  5. package/dist/access/access.types.js +9 -0
  6. package/dist/access/access.types.js.map +1 -0
  7. package/dist/access/host-match.d.ts +1 -0
  8. package/dist/access/host-match.js +14 -0
  9. package/dist/access/host-match.js.map +1 -0
  10. package/dist/cost/execution-cost.d.ts +45 -0
  11. package/dist/cost/execution-cost.js +114 -0
  12. package/dist/cost/execution-cost.js.map +1 -0
  13. package/dist/definition/definition.limits.d.ts +4 -0
  14. package/dist/definition/definition.limits.js +8 -0
  15. package/dist/definition/definition.limits.js.map +1 -0
  16. package/dist/definition/definition.schema.d.ts +8 -0
  17. package/dist/definition/definition.schema.js +123 -0
  18. package/dist/definition/definition.schema.js.map +1 -0
  19. package/dist/definition/definition.types.d.ts +117 -0
  20. package/dist/definition/definition.types.js +37 -0
  21. package/dist/definition/definition.types.js.map +1 -0
  22. package/dist/definition/validate-definition.d.ts +9 -0
  23. package/dist/definition/validate-definition.js +163 -0
  24. package/dist/definition/validate-definition.js.map +1 -0
  25. package/dist/definition/walk-steps.d.ts +5 -0
  26. package/dist/definition/walk-steps.js +31 -0
  27. package/dist/definition/walk-steps.js.map +1 -0
  28. package/dist/engine/engine-entry.d.ts +1 -0
  29. package/dist/engine/engine-entry.js +6 -0
  30. package/dist/engine/engine-entry.js.map +1 -0
  31. package/dist/engine/engine-global.d.ts +1 -0
  32. package/dist/engine/engine-global.js +5 -0
  33. package/dist/engine/engine-global.js.map +1 -0
  34. package/dist/engine/engine-source.d.ts +2 -0
  35. package/dist/engine/engine-source.js +3 -0
  36. package/dist/engine/run-in-isolate.d.ts +34 -0
  37. package/dist/engine/run-in-isolate.js +267 -0
  38. package/dist/engine/run-in-isolate.js.map +1 -0
  39. package/dist/errors/runtime-error-code.enum.d.ts +18 -0
  40. package/dist/errors/runtime-error-code.enum.js +19 -0
  41. package/dist/errors/runtime-error-code.enum.js.map +1 -0
  42. package/dist/index.d.ts +21 -0
  43. package/dist/index.js +47 -0
  44. package/dist/index.js.map +1 -0
  45. package/dist/interpreter/interpreter-error.d.ts +5 -0
  46. package/dist/interpreter/interpreter-error.js +12 -0
  47. package/dist/interpreter/interpreter-error.js.map +1 -0
  48. package/dist/interpreter/interpreter.d.ts +30 -0
  49. package/dist/interpreter/interpreter.js +313 -0
  50. package/dist/interpreter/interpreter.js.map +1 -0
  51. package/dist/interpreter/interpreter.types.d.ts +152 -0
  52. package/dist/interpreter/interpreter.types.js +31 -0
  53. package/dist/interpreter/interpreter.types.js.map +1 -0
  54. package/dist/interpreter/sequence-path.d.ts +6 -0
  55. package/dist/interpreter/sequence-path.js +53 -0
  56. package/dist/interpreter/sequence-path.js.map +1 -0
  57. package/dist/interpreter/test-host.d.ts +18 -0
  58. package/dist/interpreter/test-host.js +43 -0
  59. package/dist/interpreter/test-host.js.map +1 -0
  60. package/dist/runner-protocol/evaluation.types.d.ts +20 -0
  61. package/dist/runner-protocol/evaluation.types.js +10 -0
  62. package/dist/runner-protocol/evaluation.types.js.map +1 -0
  63. package/dist/runner-protocol/execution-protocol.types.d.ts +132 -0
  64. package/dist/runner-protocol/execution-protocol.types.js +48 -0
  65. package/dist/runner-protocol/execution-protocol.types.js.map +1 -0
  66. package/dist/server/code-runner-error.d.ts +5 -0
  67. package/dist/server/code-runner-error.js +12 -0
  68. package/dist/server/code-runner-error.js.map +1 -0
  69. package/dist/server/code-runner-session.d.ts +28 -0
  70. package/dist/server/code-runner-session.js +208 -0
  71. package/dist/server/code-runner-session.js.map +1 -0
  72. package/dist/server/index.d.ts +3 -0
  73. package/dist/server/index.js +10 -0
  74. package/dist/server/index.js.map +1 -0
  75. package/dist/steps/execute-step.d.ts +50 -0
  76. package/dist/steps/execute-step.js +136 -0
  77. package/dist/steps/execute-step.js.map +1 -0
  78. package/dist/steps/global-references.d.ts +2 -0
  79. package/dist/steps/global-references.js +28 -0
  80. package/dist/steps/global-references.js.map +1 -0
  81. package/dist/steps/step-access.d.ts +8 -0
  82. package/dist/steps/step-access.js +39 -0
  83. package/dist/steps/step-access.js.map +1 -0
  84. package/dist/steps/step-fields.d.ts +5 -0
  85. package/dist/steps/step-fields.js +68 -0
  86. package/dist/steps/step-fields.js.map +1 -0
  87. package/dist/steps/value-source.d.ts +6 -0
  88. package/dist/steps/value-source.js +58 -0
  89. package/dist/steps/value-source.js.map +1 -0
  90. package/jest.config.ts +11 -0
  91. package/package.json +68 -3
  92. package/scripts/build-engine.cjs +70 -0
  93. package/src/__tests__/engine-bundle.test.ts +121 -0
  94. package/src/__tests__/surface.test.ts +53 -0
  95. package/src/access/__tests__/host-match.test.ts +24 -0
  96. package/src/access/access.types.ts +25 -0
  97. package/src/access/host-match.ts +13 -0
  98. package/src/cost/__tests__/execution-cost.test.ts +200 -0
  99. package/src/cost/execution-cost.ts +192 -0
  100. package/src/definition/__tests__/validate-definition.test.ts +354 -0
  101. package/src/definition/definition.limits.ts +9 -0
  102. package/src/definition/definition.schema.ts +172 -0
  103. package/src/definition/definition.types.ts +171 -0
  104. package/src/definition/validate-definition.ts +206 -0
  105. package/src/definition/walk-steps.ts +44 -0
  106. package/src/engine/__tests__/run-in-isolate.test.ts +468 -0
  107. package/src/engine/engine-entry.ts +3 -0
  108. package/src/engine/engine-global.ts +2 -0
  109. package/src/engine/run-in-isolate.ts +404 -0
  110. package/src/errors/runtime-error-code.enum.ts +37 -0
  111. package/src/index.ts +30 -0
  112. package/src/interpreter/__tests__/interpreter.test.ts +854 -0
  113. package/src/interpreter/__tests__/log-respond-resume.test.ts +223 -0
  114. package/src/interpreter/interpreter-error.ts +12 -0
  115. package/src/interpreter/interpreter.ts +461 -0
  116. package/src/interpreter/interpreter.types.ts +192 -0
  117. package/src/interpreter/sequence-path.ts +67 -0
  118. package/src/interpreter/test-host.ts +85 -0
  119. package/src/runner-protocol/evaluation.types.ts +21 -0
  120. package/src/runner-protocol/execution-protocol.types.ts +221 -0
  121. package/src/server/__tests__/code-runner-session.test.ts +311 -0
  122. package/src/server/code-runner-error.ts +12 -0
  123. package/src/server/code-runner-session.ts +310 -0
  124. package/src/server/index.ts +11 -0
  125. package/src/steps/__tests__/global-references.test.ts +113 -0
  126. package/src/steps/execute-step.ts +186 -0
  127. package/src/steps/global-references.ts +48 -0
  128. package/src/steps/step-access.ts +56 -0
  129. package/src/steps/step-fields.ts +87 -0
  130. package/src/steps/value-source.ts +69 -0
  131. package/tsconfig.check.json +15 -0
  132. package/tsconfig.json +35 -0
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CodeRunnerSession = exports.CapabilityError = exports.SUSPEND_EXECUTION = void 0;
4
+ const ws_1 = require("ws");
5
+ const runtime_error_code_enum_1 = require("../errors/runtime-error-code.enum");
6
+ const execution_protocol_types_1 = require("../runner-protocol/execution-protocol.types");
7
+ const code_runner_error_1 = require("./code-runner-error");
8
+ exports.SUSPEND_EXECUTION = Symbol('abyss-runtime.suspend-execution');
9
+ class CapabilityError extends Error {
10
+ constructor(code, message) {
11
+ super(message);
12
+ this.name = 'CapabilityError';
13
+ this.code = code;
14
+ }
15
+ }
16
+ exports.CapabilityError = CapabilityError;
17
+ const REJECTION_CODES = new Set([
18
+ runtime_error_code_enum_1.RuntimeErrorCode.RUNNER_SATURATED,
19
+ runtime_error_code_enum_1.RuntimeErrorCode.INVALID_REQUEST,
20
+ runtime_error_code_enum_1.RuntimeErrorCode.STATE_VERSION_UNSUPPORTED,
21
+ ]);
22
+ const EXECUTION_STATUSES = new Set(Object.values(execution_protocol_types_1.ExecutionStatus));
23
+ const STEP_PHASES = new Set(Object.values(execution_protocol_types_1.StepPhase));
24
+ const isRecord = (value) => typeof value === 'object' && value !== null && !Array.isArray(value);
25
+ const malformed = (type) => new Error(`Code runner sent a malformed "${type}" message`);
26
+ const parseRunnerMessage = (raw) => {
27
+ let parsed;
28
+ try {
29
+ parsed = JSON.parse(raw.toString());
30
+ }
31
+ catch {
32
+ throw new Error('Code runner sent a message that is not valid JSON');
33
+ }
34
+ if (!isRecord(parsed)) {
35
+ throw new Error('Code runner sent a message that is not an object');
36
+ }
37
+ switch (parsed.type) {
38
+ case execution_protocol_types_1.ExecutionMessageType.CALL:
39
+ if (typeof parsed.callId !== 'string' ||
40
+ typeof parsed.stepId !== 'string' ||
41
+ typeof parsed.capability !== 'string') {
42
+ throw malformed(parsed.type);
43
+ }
44
+ return parsed;
45
+ case execution_protocol_types_1.ExecutionMessageType.PROGRESS:
46
+ if (typeof parsed.stepId !== 'string' || !STEP_PHASES.has(parsed.phase)) {
47
+ throw malformed(parsed.type);
48
+ }
49
+ return parsed;
50
+ case execution_protocol_types_1.ExecutionMessageType.FINISHED:
51
+ if (!isRecord(parsed.outcome) ||
52
+ !EXECUTION_STATUSES.has(parsed.outcome.status) ||
53
+ !isRecord(parsed.metrics)) {
54
+ throw malformed(parsed.type);
55
+ }
56
+ return parsed;
57
+ case execution_protocol_types_1.ExecutionMessageType.REJECTED:
58
+ if (!REJECTION_CODES.has(parsed.code) || typeof parsed.message !== 'string') {
59
+ throw malformed(parsed.type);
60
+ }
61
+ return parsed;
62
+ default:
63
+ throw new Error('Code runner sent a message of unknown type');
64
+ }
65
+ };
66
+ const errorMessage = (error) => error instanceof Error ? error.message : String(error);
67
+ const callErrorOf = (error) => error instanceof CapabilityError
68
+ ? { code: error.code, message: error.message }
69
+ : { message: errorMessage(error) };
70
+ const abortReason = (signal) => signal.reason ?? new Error('The execution was aborted');
71
+ class CodeRunnerSession {
72
+ constructor(options) {
73
+ this.options = options;
74
+ }
75
+ execute(request, handlers, executeOptions = {}) {
76
+ const { url, token, connectTimeoutMs, wallTimeGraceMs } = this.options;
77
+ const { onProgress, signal } = executeOptions;
78
+ if (signal?.aborted) {
79
+ return Promise.reject(abortReason(signal));
80
+ }
81
+ return new Promise((resolve, reject) => {
82
+ let settled = false;
83
+ let wallTimer;
84
+ const ws = new ws_1.WebSocket(url, execution_protocol_types_1.EXECUTION_PROTOCOL, {
85
+ headers: { Authorization: `Bearer ${token}` },
86
+ handshakeTimeout: connectTimeoutMs,
87
+ });
88
+ const onAbort = () => finish(() => reject(abortReason(signal)));
89
+ function finish(outcome) {
90
+ if (settled) {
91
+ return;
92
+ }
93
+ settled = true;
94
+ clearTimeout(connectTimer);
95
+ clearTimeout(wallTimer);
96
+ signal?.removeEventListener('abort', onAbort);
97
+ if (ws.readyState === ws_1.WebSocket.OPEN) {
98
+ ws.close();
99
+ }
100
+ else {
101
+ ws.terminate();
102
+ }
103
+ outcome();
104
+ }
105
+ const fail = (code, message) => finish(() => reject(new code_runner_error_1.CodeRunnerError(code, message)));
106
+ const unavailable = (message) => fail(runtime_error_code_enum_1.RuntimeErrorCode.RUNNER_UNAVAILABLE, message);
107
+ const connectTimer = setTimeout(() => unavailable(`Code runner did not accept the connection within ${connectTimeoutMs} ms`), connectTimeoutMs);
108
+ signal?.addEventListener('abort', onAbort, { once: true });
109
+ const send = (message) => {
110
+ if (!settled && ws.readyState === ws_1.WebSocket.OPEN) {
111
+ ws.send(JSON.stringify(message));
112
+ }
113
+ };
114
+ const serveCall = async (call) => {
115
+ const handler = Object.prototype.hasOwnProperty.call(handlers, call.capability)
116
+ ? handlers[call.capability]
117
+ : undefined;
118
+ if (!handler) {
119
+ send({
120
+ type: execution_protocol_types_1.ExecutionMessageType.CALL_RESULT,
121
+ callId: call.callId,
122
+ ok: false,
123
+ error: {
124
+ code: runtime_error_code_enum_1.RuntimeErrorCode.ACCESS_DENIED,
125
+ message: `Capability "${call.capability}" is not granted to the execution`,
126
+ },
127
+ });
128
+ return;
129
+ }
130
+ try {
131
+ const value = await handler(call.args, { stepId: call.stepId });
132
+ send(value === exports.SUSPEND_EXECUTION
133
+ ? {
134
+ type: execution_protocol_types_1.ExecutionMessageType.CALL_RESULT,
135
+ callId: call.callId,
136
+ ok: true,
137
+ suspend: true,
138
+ }
139
+ : { type: execution_protocol_types_1.ExecutionMessageType.CALL_RESULT, callId: call.callId, ok: true, value });
140
+ }
141
+ catch (error) {
142
+ send({
143
+ type: execution_protocol_types_1.ExecutionMessageType.CALL_RESULT,
144
+ callId: call.callId,
145
+ ok: false,
146
+ error: callErrorOf(error),
147
+ });
148
+ }
149
+ };
150
+ ws.on('unexpected-response', (_request, response) => {
151
+ const status = response.statusCode;
152
+ unavailable(status === 401
153
+ ? 'Code runner refused the token (401 Unauthorized)'
154
+ : `Code runner refused the connection (HTTP ${status})`);
155
+ });
156
+ ws.on('error', (error) => unavailable(`Code runner unreachable: ${error.message}`));
157
+ ws.on('close', () => unavailable('Code runner connection closed before the end'));
158
+ ws.on('open', () => {
159
+ clearTimeout(connectTimer);
160
+ const wallLimitMs = request.limits.wallTimeMs + wallTimeGraceMs;
161
+ wallTimer = setTimeout(() => fail(runtime_error_code_enum_1.RuntimeErrorCode.TIMEOUT, `Execution did not finish within ${wallLimitMs} ms`), wallLimitMs);
162
+ send({
163
+ ...request,
164
+ type: execution_protocol_types_1.ExecutionMessageType.EXECUTE,
165
+ capabilities: Object.keys(handlers),
166
+ });
167
+ });
168
+ ws.on('message', (raw) => {
169
+ if (settled) {
170
+ return;
171
+ }
172
+ let message;
173
+ try {
174
+ message = parseRunnerMessage(raw);
175
+ }
176
+ catch (error) {
177
+ unavailable(errorMessage(error));
178
+ return;
179
+ }
180
+ switch (message.type) {
181
+ case execution_protocol_types_1.ExecutionMessageType.CALL:
182
+ void serveCall(message);
183
+ break;
184
+ case execution_protocol_types_1.ExecutionMessageType.PROGRESS: {
185
+ if (!onProgress) {
186
+ break;
187
+ }
188
+ try {
189
+ onProgress(message);
190
+ }
191
+ catch (error) {
192
+ finish(() => reject(error));
193
+ }
194
+ break;
195
+ }
196
+ case execution_protocol_types_1.ExecutionMessageType.FINISHED:
197
+ finish(() => resolve({ outcome: message.outcome, metrics: message.metrics }));
198
+ break;
199
+ case execution_protocol_types_1.ExecutionMessageType.REJECTED:
200
+ fail(message.code, message.message);
201
+ break;
202
+ }
203
+ });
204
+ });
205
+ }
206
+ }
207
+ exports.CodeRunnerSession = CodeRunnerSession;
208
+ //# sourceMappingURL=code-runner-session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"code-runner-session.js","sourceRoot":"","sources":["../../src/server/code-runner-session.ts"],"names":[],"mappings":";;;AAAA,2BAA+B;AAE/B,+EAAqE;AACrE,0FAKqD;AAWrD,2DAAsD;AAiCzC,QAAA,iBAAiB,GAAkB,MAAM,CAAC,iCAAiC,CAAC,CAAC;AAG1F,MAAa,eAAgB,SAAQ,KAAK;IAGxC,YAAY,IAAsB,EAAE,OAAe;QACjD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AARD,0CAQC;AAaD,MAAM,eAAe,GAAG,IAAI,GAAG,CAAS;IACtC,0CAAgB,CAAC,gBAAgB;IACjC,0CAAgB,CAAC,eAAe;IAChC,0CAAgB,CAAC,yBAAyB;CAC3C,CAAC,CAAC;AACH,MAAM,kBAAkB,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC,MAAM,CAAC,0CAAe,CAAC,CAAC,CAAC;AAC3E,MAAM,WAAW,GAAG,IAAI,GAAG,CAAS,MAAM,CAAC,MAAM,CAAC,oCAAS,CAAC,CAAC,CAAC;AAE9D,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAoC,EAAE,CACpE,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAEvE,MAAM,SAAS,GAAG,CAAC,IAAY,EAAS,EAAE,CACxC,IAAI,KAAK,CAAC,iCAAiC,IAAI,WAAW,CAAC,CAAC;AA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C,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;wBAC9E,MAAM;oBACR,KAAK,+CAAoB,CAAC,QAAQ;wBAChC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC;wBACpC,MAAM;gBACV,CAAC;YACH,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF;AAhKD,8CAgKC"}
@@ -0,0 +1,3 @@
1
+ export { CodeRunnerError } from './code-runner-error';
2
+ export { CapabilityError, CodeRunnerSession, SUSPEND_EXECUTION } from './code-runner-session';
3
+ export type { CapabilityContext, CapabilityHandlers, CodeRunnerSessionOptions, ExecuteOptions, ExecutionRequest, ExecutionResult, } from './code-runner-session';
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SUSPEND_EXECUTION = exports.CodeRunnerSession = exports.CapabilityError = exports.CodeRunnerError = void 0;
4
+ var code_runner_error_1 = require("./code-runner-error");
5
+ Object.defineProperty(exports, "CodeRunnerError", { enumerable: true, get: function () { return code_runner_error_1.CodeRunnerError; } });
6
+ var code_runner_session_1 = require("./code-runner-session");
7
+ Object.defineProperty(exports, "CapabilityError", { enumerable: true, get: function () { return code_runner_session_1.CapabilityError; } });
8
+ Object.defineProperty(exports, "CodeRunnerSession", { enumerable: true, get: function () { return code_runner_session_1.CodeRunnerSession; } });
9
+ Object.defineProperty(exports, "SUSPEND_EXECUTION", { enumerable: true, get: function () { return code_runner_session_1.SUSPEND_EXECUTION; } });
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":";;;AACA,yDAAsD;AAA7C,oHAAA,eAAe,OAAA;AACxB,6DAA8F;AAArF,sHAAA,eAAe,OAAA;AAAE,wHAAA,iBAAiB,OAAA;AAAE,wHAAA,iBAAiB,OAAA"}
@@ -0,0 +1,50 @@
1
+ import type { RuntimeErrorDetail } from '../errors/runtime-error-code.enum';
2
+ import type { LogLevel, Step, StopStatus } from '../definition/definition.types';
3
+ import type { HttpRequest, HttpResponseToSend } from '../interpreter/interpreter.types';
4
+ import type { ResolvedFields } from './step-fields';
5
+ export declare enum StepActionKind {
6
+ DONE = "DONE",
7
+ STOP = "STOP",
8
+ WAIT = "WAIT",
9
+ HTTP = "HTTP",
10
+ HOST = "HOST",
11
+ LOG = "LOG",
12
+ RESPOND = "RESPOND",
13
+ FAIL = "FAIL"
14
+ }
15
+ export type StepAction = {
16
+ kind: StepActionKind.DONE;
17
+ output: unknown;
18
+ variable?: {
19
+ name: string;
20
+ value: unknown;
21
+ };
22
+ branch?: string;
23
+ } | {
24
+ kind: StepActionKind.STOP;
25
+ status: StopStatus;
26
+ output: unknown;
27
+ } | {
28
+ kind: StepActionKind.WAIT;
29
+ durationMs?: number;
30
+ until?: string;
31
+ } | {
32
+ kind: StepActionKind.HTTP;
33
+ request: HttpRequest;
34
+ } | {
35
+ kind: StepActionKind.HOST;
36
+ action: string;
37
+ input: Record<string, unknown>;
38
+ } | {
39
+ kind: StepActionKind.LOG;
40
+ level: LogLevel;
41
+ message: string;
42
+ data?: unknown;
43
+ } | {
44
+ kind: StepActionKind.RESPOND;
45
+ response: HttpResponseToSend;
46
+ } | {
47
+ kind: StepActionKind.FAIL;
48
+ error: RuntimeErrorDetail;
49
+ };
50
+ export declare const executeStep: (step: Step, fields: ResolvedFields) => StepAction;
@@ -0,0 +1,136 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.executeStep = exports.StepActionKind = void 0;
4
+ const runtime_error_code_enum_1 = require("../errors/runtime-error-code.enum");
5
+ const definition_limits_1 = require("../definition/definition.limits");
6
+ const definition_types_1 = require("../definition/definition.types");
7
+ const value_source_1 = require("./value-source");
8
+ var StepActionKind;
9
+ (function (StepActionKind) {
10
+ StepActionKind["DONE"] = "DONE";
11
+ StepActionKind["STOP"] = "STOP";
12
+ StepActionKind["WAIT"] = "WAIT";
13
+ StepActionKind["HTTP"] = "HTTP";
14
+ StepActionKind["HOST"] = "HOST";
15
+ StepActionKind["LOG"] = "LOG";
16
+ StepActionKind["RESPOND"] = "RESPOND";
17
+ StepActionKind["FAIL"] = "FAIL";
18
+ })(StepActionKind || (exports.StepActionKind = StepActionKind = {}));
19
+ const fail = (message) => ({
20
+ kind: StepActionKind.FAIL,
21
+ error: { code: runtime_error_code_enum_1.RuntimeErrorCode.EXPRESSION_ERROR, message },
22
+ });
23
+ const headerValue = (value) => typeof value === 'string' ? value : JSON.stringify(value) ?? '';
24
+ const resolvedRecord = (base, keys, fields) => Object.fromEntries(keys.map((key) => [key, fields.get((0, value_source_1.propertyPath)(base, key))]));
25
+ const executeWait = (step, fields) => {
26
+ if (step.durationMs !== undefined) {
27
+ const durationMs = fields.get('durationMs');
28
+ if (typeof durationMs !== 'number' || !Number.isInteger(durationMs) || durationMs < 0) {
29
+ return fail('Wait duration must resolve to a non-negative integer number of milliseconds');
30
+ }
31
+ return { kind: StepActionKind.WAIT, durationMs };
32
+ }
33
+ const until = fields.get('until');
34
+ if (typeof until !== 'string' || Number.isNaN(Date.parse(until))) {
35
+ return fail('Wait date must resolve to an ISO 8601 date');
36
+ }
37
+ return { kind: StepActionKind.WAIT, until };
38
+ };
39
+ const executeLog = (step, fields) => {
40
+ const message = fields.get('message');
41
+ const action = {
42
+ kind: StepActionKind.LOG,
43
+ level: step.level,
44
+ message: typeof message === 'string' ? message : JSON.stringify(message) ?? '',
45
+ };
46
+ if (step.data !== undefined) {
47
+ action.data = fields.get('data');
48
+ }
49
+ return action;
50
+ };
51
+ const executeRespond = (step, fields) => {
52
+ const status = fields.get('status');
53
+ if (typeof status !== 'number' ||
54
+ !Number.isInteger(status) ||
55
+ status < definition_limits_1.MIN_RESPONSE_STATUS ||
56
+ status > definition_limits_1.MAX_RESPONSE_STATUS) {
57
+ return fail(`Response status must resolve to an integer from ${definition_limits_1.MIN_RESPONSE_STATUS} to ${definition_limits_1.MAX_RESPONSE_STATUS}`);
58
+ }
59
+ const headers = resolvedRecord('headers', Object.keys(step.headers ?? {}), fields);
60
+ const response = {
61
+ status,
62
+ headers: Object.fromEntries(Object.entries(headers).map(([key, value]) => [key, headerValue(value)])),
63
+ };
64
+ if (step.body !== undefined) {
65
+ response.body = fields.get('body');
66
+ }
67
+ return { kind: StepActionKind.RESPOND, response };
68
+ };
69
+ const executeStep = (step, fields) => {
70
+ switch (step.type) {
71
+ case definition_types_1.StepType.CONDITION: {
72
+ if (fields.get('if')) {
73
+ return { kind: StepActionKind.DONE, output: 'then', branch: 'then' };
74
+ }
75
+ return step.else
76
+ ? { kind: StepActionKind.DONE, output: 'else', branch: 'else' }
77
+ : { kind: StepActionKind.DONE, output: 'else' };
78
+ }
79
+ case definition_types_1.StepType.SWITCH: {
80
+ const value = fields.get('value');
81
+ const index = step.cases.findIndex((_, caseIndex) => fields.get(`cases[${caseIndex}].match`) === value);
82
+ if (index >= 0) {
83
+ const branch = `cases[${index}].steps`;
84
+ return { kind: StepActionKind.DONE, output: `cases[${index}]`, branch };
85
+ }
86
+ return step.default
87
+ ? { kind: StepActionKind.DONE, output: 'default', branch: 'default' }
88
+ : { kind: StepActionKind.DONE, output: null };
89
+ }
90
+ case definition_types_1.StepType.WAIT:
91
+ return executeWait(step, fields);
92
+ case definition_types_1.StepType.SET: {
93
+ const value = fields.get('value');
94
+ return {
95
+ kind: StepActionKind.DONE,
96
+ output: value,
97
+ variable: { name: step.variable, value },
98
+ };
99
+ }
100
+ case definition_types_1.StepType.CODE:
101
+ return { kind: StepActionKind.DONE, output: fields.get('source') };
102
+ case definition_types_1.StepType.HTTP: {
103
+ const url = fields.get('url');
104
+ if (typeof url !== 'string') {
105
+ return fail('HTTP url must resolve to a string');
106
+ }
107
+ const headers = resolvedRecord('headers', Object.keys(step.headers ?? {}), fields);
108
+ const request = {
109
+ method: step.method,
110
+ url,
111
+ headers: Object.fromEntries(Object.entries(headers).map(([key, value]) => [key, headerValue(value)])),
112
+ };
113
+ if (step.body !== undefined) {
114
+ request.body = fields.get('body');
115
+ }
116
+ if (step.timeoutMs !== undefined) {
117
+ request.timeoutMs = step.timeoutMs;
118
+ }
119
+ return { kind: StepActionKind.HTTP, request };
120
+ }
121
+ case definition_types_1.StepType.HOST:
122
+ return {
123
+ kind: StepActionKind.HOST,
124
+ action: step.action,
125
+ input: resolvedRecord('input', Object.keys(step.input), fields),
126
+ };
127
+ case definition_types_1.StepType.LOG:
128
+ return executeLog(step, fields);
129
+ case definition_types_1.StepType.RESPOND:
130
+ return executeRespond(step, fields);
131
+ case definition_types_1.StepType.STOP:
132
+ return { kind: StepActionKind.STOP, status: step.status, output: fields.get('output') };
133
+ }
134
+ };
135
+ exports.executeStep = executeStep;
136
+ //# sourceMappingURL=execute-step.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"execute-step.js","sourceRoot":"","sources":["../../src/steps/execute-step.ts"],"names":[],"mappings":";;;AAAA,+EAAqE;AAErE,uEAA2F;AAC3F,qEAA0D;AAU1D,iDAA8C;AAG9C,IAAY,cAUX;AAVD,WAAY,cAAc;IAExB,+BAAa,CAAA;IACb,+BAAa,CAAA;IACb,+BAAa,CAAA;IACb,+BAAa,CAAA;IACb,+BAAa,CAAA;IACb,6BAAW,CAAA;IACX,qCAAmB,CAAA;IACnB,+BAAa,CAAA;AACf,CAAC,EAVW,cAAc,8BAAd,cAAc,QAUzB;AAkBD,MAAM,IAAI,GAAG,CAAC,OAAe,EAAc,EAAE,CAAC,CAAC;IAC7C,IAAI,EAAE,cAAc,CAAC,IAAI;IACzB,KAAK,EAAE,EAAE,IAAI,EAAE,0CAAgB,CAAC,gBAAgB,EAAE,OAAO,EAAE;CAC5D,CAAC,CAAC;AAEH,MAAM,WAAW,GAAG,CAAC,KAAc,EAAU,EAAE,CAC7C,OAAO,KAAK,KAAK,QAAQ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W,QAAA,WAAW,eAqEtB"}
@@ -0,0 +1,2 @@
1
+ import type { RuntimeDefinition } from '../definition/definition.types';
2
+ export declare const collectGlobalReferences: (definition: Pick<RuntimeDefinition, "steps">, globalName: string) => string[];
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.collectGlobalReferences = void 0;
4
+ const evaluation_types_1 = require("../runner-protocol/evaluation.types");
5
+ const walk_steps_1 = require("../definition/walk-steps");
6
+ const step_fields_1 = require("./step-fields");
7
+ const PLACEHOLDER = /\{\{([\s\S]*?)\}\}/g;
8
+ const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
9
+ const codeOf = (kind, source) => kind === evaluation_types_1.EvaluationKind.TEMPLATE
10
+ ? [...source.matchAll(PLACEHOLDER)].map((match) => match[1])
11
+ : [source];
12
+ const collectGlobalReferences = (definition, globalName) => {
13
+ const name = escapeRegExp(globalName);
14
+ const access = new RegExp(`(?<![\\w$.])${name}\\s*(?:\\??\\.\\s*([A-Za-z_$][\\w$]*)|\\[\\s*(['"])([A-Za-z_$][\\w$]*)\\2\\s*\\])`, 'g');
15
+ const found = new Set();
16
+ (0, walk_steps_1.walkSteps)(definition.steps, (step) => {
17
+ for (const item of (0, step_fields_1.collectStepItems)(step)) {
18
+ for (const code of codeOf(item.kind, item.source)) {
19
+ for (const match of code.matchAll(access)) {
20
+ found.add(match[1] ?? match[3]);
21
+ }
22
+ }
23
+ }
24
+ });
25
+ return [...found];
26
+ };
27
+ exports.collectGlobalReferences = collectGlobalReferences;
28
+ //# sourceMappingURL=global-references.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"global-references.js","sourceRoot":"","sources":["../../src/steps/global-references.ts"],"names":[],"mappings":";;;AAAA,0EAAqE;AAErE,yDAAqD;AACrD,+CAAiD;AAEjD,MAAM,WAAW,GAAG,qBAAqB,CAAC;AAE1C,MAAM,YAAY,GAAG,CAAC,IAAY,EAAU,EA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aration } from '../access/access.types';
2
+ export declare enum AccessVerdict {
3
+ ALLOWED = "ALLOWED",
4
+ NOT_DECLARED = "NOT_DECLARED",
5
+ NOT_GRANTED = "NOT_GRANTED"
6
+ }
7
+ export declare const checkHttpAccess: (url: string, declared: AccessDeclaration[], granted: AccessDeclaration[]) => AccessVerdict;
8
+ export declare const checkHostActionAccess: (action: string, declared: AccessDeclaration[], granted: AccessDeclaration[]) => AccessVerdict;
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkHostActionAccess = exports.checkHttpAccess = exports.AccessVerdict = void 0;
4
+ const access_types_1 = require("../access/access.types");
5
+ const host_match_1 = require("../access/host-match");
6
+ var AccessVerdict;
7
+ (function (AccessVerdict) {
8
+ AccessVerdict["ALLOWED"] = "ALLOWED";
9
+ AccessVerdict["NOT_DECLARED"] = "NOT_DECLARED";
10
+ AccessVerdict["NOT_GRANTED"] = "NOT_GRANTED";
11
+ })(AccessVerdict || (exports.AccessVerdict = AccessVerdict = {}));
12
+ const coversHost = (accesses, host) => accesses.some((access) => access.kind === access_types_1.AccessKind.HTTP && access.hosts.some((pattern) => (0, host_match_1.hostMatches)(host, pattern)));
13
+ const coversAction = (accesses, action) => accesses.some((access) => access.kind === access_types_1.AccessKind.HOST_ACTION && access.action === action);
14
+ const verdict = (declared, granted) => {
15
+ if (!declared) {
16
+ return AccessVerdict.NOT_DECLARED;
17
+ }
18
+ return granted ? AccessVerdict.ALLOWED : AccessVerdict.NOT_GRANTED;
19
+ };
20
+ const hostOf = (url) => {
21
+ try {
22
+ const parsed = new URL(url);
23
+ return parsed.protocol === 'http:' || parsed.protocol === 'https:' ? parsed.hostname : null;
24
+ }
25
+ catch {
26
+ return null;
27
+ }
28
+ };
29
+ const checkHttpAccess = (url, declared, granted) => {
30
+ const host = hostOf(url);
31
+ if (host === null) {
32
+ return AccessVerdict.NOT_DECLARED;
33
+ }
34
+ return verdict(coversHost(declared, host), coversHost(granted, host));
35
+ };
36
+ exports.checkHttpAccess = checkHttpAccess;
37
+ const checkHostActionAccess = (action, declared, granted) => verdict(coversAction(declared, action), coversAction(granted, action));
38
+ exports.checkHostActionAccess = checkHostActionAccess;
39
+ //# sourceMappingURL=step-access.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-access.js","sourceRoot":"","sources":["../../src/steps/step-access.ts"],"names":[],"mappings":";;;AAAA,yDAAoD;AAEpD,qDAAmD;AAEnD,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,8CAA6B,CAAA;IAC7B,4CAA2B,CAAA;AAC7B,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB;AAED,MAAM,UAAU,GAAG,CAAC,QAA6B,EAAE,IAAY,EAAW,EAAE,CAC1E,QAAQ,CAAC,IAAI,CACX,CAAC,MAAM,EAAE,EAAE,CACT,MAAM,CAAC,IAAI,KAAK,yBAAU,CAAC,IAAI,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAA,wBAAW,EAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAChG,CAAC;AAEJ,MAAM,YAAY,GAAG,CAAC,QAA6B,EAAE,MAAc,EAAW,EAAE,CAC9E,QAAQ,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,KAAK,yBAAU,CAAC,WAAW,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC,CAAC;AAEhG,MAAM,OAAO,GAAG,CAAC,QAAiB,EAAE,OAAgB,EAAiB,EAAE;IACrE,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,aAAa,CAAC,YAAY,CAAC;IACpC,CAAC;IACD,OAAO,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,aAAa,CAAC,WAAW,CAAC;AACrE,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,CAAC,GAAW,EAAiB,EAAE;IAC5C,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;QAC5B,OAAO,MAAM,CAAC,QAAQ,KAAK,OAAO,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9F,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC,CAAC;AAMK,MAAM,eAAe,GAAG,CAC7B,GAAW,EACX,QAA6B,EAC7B,OAA4B,EACb,EAAE;IACjB,MAAM,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC;IACzB,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;QAClB,OAAO,aAAa,CAAC,YAAY,CAAC;IACpC,CAAC;IACD,OAAO,OAAO,CAAC,UAAU,CAAC,QAAQ,EAAE,IAAI,CAAC,EAAE,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;AACxE,CAAC,CAAC;AAVW,QAAA,eAAe,mBAU1B;AAEK,MAAM,qBAAqB,GAAG,CACnC,MAAc,EACd,QAA6B,EAC7B,OAA4B,EACb,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,EAAE,YAAY,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC;AAJ9E,QAAA,qBAAqB,yBAIyD"}
@@ -0,0 +1,5 @@
1
+ import type { EvaluationItem } from '../runner-protocol/evaluation.types';
2
+ import type { Step } from '../definition/definition.types';
3
+ export type ResolvedFields = ReadonlyMap<string, unknown>;
4
+ export declare const collectStepItems: (step: Step) => EvaluationItem[];
5
+ export declare const resolveStepFields: (step: Step, results: ReadonlyMap<string, unknown>) => ResolvedFields;
@@ -0,0 +1,68 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.resolveStepFields = exports.collectStepItems = void 0;
4
+ const evaluation_types_1 = require("../runner-protocol/evaluation.types");
5
+ const definition_types_1 = require("../definition/definition.types");
6
+ const value_source_1 = require("./value-source");
7
+ const recordFields = (base, record) => Object.entries(record ?? {}).map(([key, source]) => ({ path: (0, value_source_1.propertyPath)(base, key), source }));
8
+ const optionalField = (path, source) => source === undefined ? [] : [{ path, source }];
9
+ const stepFields = (step) => {
10
+ switch (step.type) {
11
+ case definition_types_1.StepType.CONDITION:
12
+ return [{ path: 'if', source: step.if }];
13
+ case definition_types_1.StepType.SWITCH:
14
+ return [
15
+ { path: 'value', source: step.value },
16
+ ...step.cases.map((switchCase, index) => ({
17
+ path: `cases[${index}].match`,
18
+ source: switchCase.match,
19
+ })),
20
+ ];
21
+ case definition_types_1.StepType.WAIT:
22
+ return [
23
+ ...optionalField('durationMs', step.durationMs),
24
+ ...optionalField('until', step.until),
25
+ ];
26
+ case definition_types_1.StepType.SET:
27
+ return [{ path: 'value', source: step.value }];
28
+ case definition_types_1.StepType.CODE:
29
+ return [];
30
+ case definition_types_1.StepType.HTTP:
31
+ return [
32
+ { path: 'url', source: step.url },
33
+ ...recordFields('headers', step.headers),
34
+ ...optionalField('body', step.body),
35
+ ];
36
+ case definition_types_1.StepType.HOST:
37
+ return recordFields('input', step.input);
38
+ case definition_types_1.StepType.LOG:
39
+ return [{ path: 'message', source: step.message }, ...optionalField('data', step.data)];
40
+ case definition_types_1.StepType.RESPOND:
41
+ return [
42
+ { path: 'status', source: step.status },
43
+ ...recordFields('headers', step.headers),
44
+ ...optionalField('body', step.body),
45
+ ];
46
+ case definition_types_1.StepType.STOP:
47
+ return optionalField('output', step.output);
48
+ }
49
+ };
50
+ const collectStepItems = (step) => {
51
+ if (step.type === definition_types_1.StepType.CODE) {
52
+ return [{ id: 'source', kind: evaluation_types_1.EvaluationKind.CODE, source: step.source }];
53
+ }
54
+ const items = [];
55
+ for (const field of stepFields(step)) {
56
+ (0, value_source_1.collectItems)(field.path, field.source, items);
57
+ }
58
+ return items;
59
+ };
60
+ exports.collectStepItems = collectStepItems;
61
+ const resolveStepFields = (step, results) => {
62
+ if (step.type === definition_types_1.StepType.CODE) {
63
+ return new Map([['source', results.get('source')]]);
64
+ }
65
+ return new Map(stepFields(step).map((field) => [field.path, (0, value_source_1.resolveValue)(field.path, field.source, results)]));
66
+ };
67
+ exports.resolveStepFields = resolveStepFields;
68
+ //# sourceMappingURL=step-fields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"step-fields.js","sourceRoot":"","sources":["../../src/steps/step-fields.ts"],"names":[],"mappings":";;;AAAA,0EAAqE;AAErE,qEAA0D;AAE1D,iDAA0E;AAU1E,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,MAA+C,EAAe,EAAE,CAClG,MAAM,CAAC,OAAO,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,IAAA,2BAAY,EAAC,IAAI,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC;AAEnG,MAAM,aAAa,GAAG,CAAC,IAAY,EAAE,MAA+B,EAAe,EAAE,CACnF,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;AAGjD,MAAM,UAAU,GAAG,CAAC,IAAU,EAAe,EAAE;IAC7C,QAAQ,IAAI,CAAC,IAAI,EAAE,CAAC;QAClB,KAAK,2BAAQ,CAAC,SAAS;YACrB,OAAO,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC;QAC3C,KAAK,2BAAQ,CAAC,MAAM;YAClB,OAAO;gBACL,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,EAAE;gBACrC,GA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CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAC/F,CAAC;AACJ,CAAC,CAAC;AAVW,QAAA,iBAAiB,qBAU5B"}
@@ -0,0 +1,6 @@
1
+ import type { EvaluationItem } from '../runner-protocol/evaluation.types';
2
+ import type { ExpressionValue, ValueSource } from '../definition/definition.types';
3
+ export declare const isExpressionValue: (value: ValueSource) => value is ExpressionValue;
4
+ export declare const propertyPath: (base: string, key: string) => string;
5
+ export declare const collectItems: (path: string, source: ValueSource, items: EvaluationItem[]) => void;
6
+ export declare const resolveValue: (path: string, source: ValueSource, results: ReadonlyMap<string, unknown>) => unknown;