@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.
- package/.eslintrc.js +32 -0
- package/.prettierrc +5 -0
- package/README.md +28 -3
- package/dist/access/access.types.d.ts +14 -0
- package/dist/access/access.types.js +9 -0
- package/dist/access/access.types.js.map +1 -0
- package/dist/access/host-match.d.ts +1 -0
- package/dist/access/host-match.js +14 -0
- package/dist/access/host-match.js.map +1 -0
- package/dist/cost/execution-cost.d.ts +45 -0
- package/dist/cost/execution-cost.js +114 -0
- package/dist/cost/execution-cost.js.map +1 -0
- package/dist/definition/definition.limits.d.ts +4 -0
- package/dist/definition/definition.limits.js +8 -0
- package/dist/definition/definition.limits.js.map +1 -0
- package/dist/definition/definition.schema.d.ts +8 -0
- package/dist/definition/definition.schema.js +123 -0
- package/dist/definition/definition.schema.js.map +1 -0
- package/dist/definition/definition.types.d.ts +117 -0
- package/dist/definition/definition.types.js +37 -0
- package/dist/definition/definition.types.js.map +1 -0
- package/dist/definition/validate-definition.d.ts +9 -0
- package/dist/definition/validate-definition.js +163 -0
- package/dist/definition/validate-definition.js.map +1 -0
- package/dist/definition/walk-steps.d.ts +5 -0
- package/dist/definition/walk-steps.js +31 -0
- package/dist/definition/walk-steps.js.map +1 -0
- package/dist/engine/engine-entry.d.ts +1 -0
- package/dist/engine/engine-entry.js +6 -0
- package/dist/engine/engine-entry.js.map +1 -0
- package/dist/engine/engine-global.d.ts +1 -0
- package/dist/engine/engine-global.js +5 -0
- package/dist/engine/engine-global.js.map +1 -0
- package/dist/engine/engine-source.d.ts +2 -0
- package/dist/engine/engine-source.js +3 -0
- package/dist/engine/run-in-isolate.d.ts +34 -0
- package/dist/engine/run-in-isolate.js +267 -0
- package/dist/engine/run-in-isolate.js.map +1 -0
- package/dist/errors/runtime-error-code.enum.d.ts +18 -0
- package/dist/errors/runtime-error-code.enum.js +19 -0
- package/dist/errors/runtime-error-code.enum.js.map +1 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.js +47 -0
- package/dist/index.js.map +1 -0
- package/dist/interpreter/interpreter-error.d.ts +5 -0
- package/dist/interpreter/interpreter-error.js +12 -0
- package/dist/interpreter/interpreter-error.js.map +1 -0
- package/dist/interpreter/interpreter.d.ts +30 -0
- package/dist/interpreter/interpreter.js +313 -0
- package/dist/interpreter/interpreter.js.map +1 -0
- package/dist/interpreter/interpreter.types.d.ts +152 -0
- package/dist/interpreter/interpreter.types.js +31 -0
- package/dist/interpreter/interpreter.types.js.map +1 -0
- package/dist/interpreter/sequence-path.d.ts +6 -0
- package/dist/interpreter/sequence-path.js +53 -0
- package/dist/interpreter/sequence-path.js.map +1 -0
- package/dist/interpreter/test-host.d.ts +18 -0
- package/dist/interpreter/test-host.js +43 -0
- package/dist/interpreter/test-host.js.map +1 -0
- package/dist/runner-protocol/evaluation.types.d.ts +20 -0
- package/dist/runner-protocol/evaluation.types.js +10 -0
- package/dist/runner-protocol/evaluation.types.js.map +1 -0
- package/dist/runner-protocol/execution-protocol.types.d.ts +132 -0
- package/dist/runner-protocol/execution-protocol.types.js +48 -0
- package/dist/runner-protocol/execution-protocol.types.js.map +1 -0
- package/dist/server/code-runner-error.d.ts +5 -0
- package/dist/server/code-runner-error.js +12 -0
- package/dist/server/code-runner-error.js.map +1 -0
- package/dist/server/code-runner-session.d.ts +28 -0
- package/dist/server/code-runner-session.js +208 -0
- package/dist/server/code-runner-session.js.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +10 -0
- package/dist/server/index.js.map +1 -0
- package/dist/steps/execute-step.d.ts +50 -0
- package/dist/steps/execute-step.js +136 -0
- package/dist/steps/execute-step.js.map +1 -0
- package/dist/steps/global-references.d.ts +2 -0
- package/dist/steps/global-references.js +28 -0
- package/dist/steps/global-references.js.map +1 -0
- package/dist/steps/step-access.d.ts +8 -0
- package/dist/steps/step-access.js +39 -0
- package/dist/steps/step-access.js.map +1 -0
- package/dist/steps/step-fields.d.ts +5 -0
- package/dist/steps/step-fields.js +68 -0
- package/dist/steps/step-fields.js.map +1 -0
- package/dist/steps/value-source.d.ts +6 -0
- package/dist/steps/value-source.js +58 -0
- package/dist/steps/value-source.js.map +1 -0
- package/jest.config.ts +11 -0
- package/package.json +68 -3
- package/scripts/build-engine.cjs +70 -0
- package/src/__tests__/engine-bundle.test.ts +121 -0
- package/src/__tests__/surface.test.ts +53 -0
- package/src/access/__tests__/host-match.test.ts +24 -0
- package/src/access/access.types.ts +25 -0
- package/src/access/host-match.ts +13 -0
- package/src/cost/__tests__/execution-cost.test.ts +200 -0
- package/src/cost/execution-cost.ts +192 -0
- package/src/definition/__tests__/validate-definition.test.ts +354 -0
- package/src/definition/definition.limits.ts +9 -0
- package/src/definition/definition.schema.ts +172 -0
- package/src/definition/definition.types.ts +171 -0
- package/src/definition/validate-definition.ts +206 -0
- package/src/definition/walk-steps.ts +44 -0
- package/src/engine/__tests__/run-in-isolate.test.ts +468 -0
- package/src/engine/engine-entry.ts +3 -0
- package/src/engine/engine-global.ts +2 -0
- package/src/engine/run-in-isolate.ts +404 -0
- package/src/errors/runtime-error-code.enum.ts +37 -0
- package/src/index.ts +30 -0
- package/src/interpreter/__tests__/interpreter.test.ts +854 -0
- package/src/interpreter/__tests__/log-respond-resume.test.ts +223 -0
- package/src/interpreter/interpreter-error.ts +12 -0
- package/src/interpreter/interpreter.ts +461 -0
- package/src/interpreter/interpreter.types.ts +192 -0
- package/src/interpreter/sequence-path.ts +67 -0
- package/src/interpreter/test-host.ts +85 -0
- package/src/runner-protocol/evaluation.types.ts +21 -0
- package/src/runner-protocol/execution-protocol.types.ts +221 -0
- package/src/server/__tests__/code-runner-session.test.ts +311 -0
- package/src/server/code-runner-error.ts +12 -0
- package/src/server/code-runner-session.ts +310 -0
- package/src/server/index.ts +11 -0
- package/src/steps/__tests__/global-references.test.ts +113 -0
- package/src/steps/execute-step.ts +186 -0
- package/src/steps/global-references.ts +48 -0
- package/src/steps/step-access.ts +56 -0
- package/src/steps/step-fields.ts +87 -0
- package/src/steps/value-source.ts +69 -0
- package/tsconfig.check.json +15 -0
- package/tsconfig.json +35 -0
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { AccessGrant } from '../access/access.types';
|
|
2
|
+
import type { HostActionCatalog, HttpMethod, LogLevel, StopStatus } from '../definition/definition.types';
|
|
3
|
+
import type { RuntimeErrorDetail } from '../errors/runtime-error-code.enum';
|
|
4
|
+
import type { EvaluationItem, EvaluationResult } from '../runner-protocol/evaluation.types';
|
|
5
|
+
export declare const CURRENT_STATE_VERSION = 1;
|
|
6
|
+
export declare enum RunStatus {
|
|
7
|
+
WAITING = "WAITING",
|
|
8
|
+
SUCCEEDED = "SUCCEEDED",
|
|
9
|
+
FAILED = "FAILED"
|
|
10
|
+
}
|
|
11
|
+
export interface RunBudget {
|
|
12
|
+
maxSteps: number;
|
|
13
|
+
maxEffects: number;
|
|
14
|
+
maxWaitMs: number;
|
|
15
|
+
}
|
|
16
|
+
export interface RunOptions {
|
|
17
|
+
catalog: HostActionCatalog;
|
|
18
|
+
grants: AccessGrant[];
|
|
19
|
+
budget: RunBudget;
|
|
20
|
+
}
|
|
21
|
+
export interface EvaluationContext {
|
|
22
|
+
input: unknown;
|
|
23
|
+
steps: Record<string, {
|
|
24
|
+
output: unknown;
|
|
25
|
+
}>;
|
|
26
|
+
vars: Record<string, unknown>;
|
|
27
|
+
}
|
|
28
|
+
export declare enum EffectType {
|
|
29
|
+
EVALUATE = "EVALUATE",
|
|
30
|
+
HTTP = "HTTP",
|
|
31
|
+
HOST = "HOST",
|
|
32
|
+
WAIT = "WAIT",
|
|
33
|
+
LOG = "LOG",
|
|
34
|
+
RESPOND = "RESPOND"
|
|
35
|
+
}
|
|
36
|
+
export interface EvaluateEffect {
|
|
37
|
+
type: EffectType.EVALUATE;
|
|
38
|
+
stepId: string;
|
|
39
|
+
items: EvaluationItem[];
|
|
40
|
+
context: EvaluationContext;
|
|
41
|
+
}
|
|
42
|
+
export interface HttpRequest {
|
|
43
|
+
method: HttpMethod;
|
|
44
|
+
url: string;
|
|
45
|
+
headers: Record<string, string>;
|
|
46
|
+
body?: unknown;
|
|
47
|
+
timeoutMs?: number;
|
|
48
|
+
}
|
|
49
|
+
export interface HttpEffect {
|
|
50
|
+
type: EffectType.HTTP;
|
|
51
|
+
stepId: string;
|
|
52
|
+
request: HttpRequest;
|
|
53
|
+
}
|
|
54
|
+
export interface HostEffect {
|
|
55
|
+
type: EffectType.HOST;
|
|
56
|
+
stepId: string;
|
|
57
|
+
action: string;
|
|
58
|
+
input: Record<string, unknown>;
|
|
59
|
+
}
|
|
60
|
+
export interface WaitEffect {
|
|
61
|
+
type: EffectType.WAIT;
|
|
62
|
+
stepId: string;
|
|
63
|
+
durationMs?: number;
|
|
64
|
+
until?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface LogEffect {
|
|
67
|
+
type: EffectType.LOG;
|
|
68
|
+
stepId: string;
|
|
69
|
+
level: LogLevel;
|
|
70
|
+
message: string;
|
|
71
|
+
data?: unknown;
|
|
72
|
+
}
|
|
73
|
+
export interface HttpResponseToSend {
|
|
74
|
+
status: number;
|
|
75
|
+
headers: Record<string, string>;
|
|
76
|
+
body?: unknown;
|
|
77
|
+
}
|
|
78
|
+
export interface RespondEffect {
|
|
79
|
+
type: EffectType.RESPOND;
|
|
80
|
+
stepId: string;
|
|
81
|
+
response: HttpResponseToSend;
|
|
82
|
+
}
|
|
83
|
+
export type Effect = EvaluateEffect | HttpEffect | HostEffect | WaitEffect | LogEffect | RespondEffect;
|
|
84
|
+
export declare enum RunEventType {
|
|
85
|
+
EVALUATED = "EVALUATED",
|
|
86
|
+
HTTP_COMPLETED = "HTTP_COMPLETED",
|
|
87
|
+
HOST_COMPLETED = "HOST_COMPLETED",
|
|
88
|
+
WAIT_ELAPSED = "WAIT_ELAPSED",
|
|
89
|
+
LOG_WRITTEN = "LOG_WRITTEN",
|
|
90
|
+
RESPONSE_SENT = "RESPONSE_SENT",
|
|
91
|
+
RESUMED = "RESUMED",
|
|
92
|
+
EFFECT_FAILED = "EFFECT_FAILED"
|
|
93
|
+
}
|
|
94
|
+
export interface HttpResponse {
|
|
95
|
+
status: number;
|
|
96
|
+
headers: Record<string, string>;
|
|
97
|
+
body: unknown;
|
|
98
|
+
}
|
|
99
|
+
export type RunEvent = {
|
|
100
|
+
type: RunEventType.EVALUATED;
|
|
101
|
+
results: EvaluationResult[];
|
|
102
|
+
} | {
|
|
103
|
+
type: RunEventType.HTTP_COMPLETED;
|
|
104
|
+
response: HttpResponse;
|
|
105
|
+
} | {
|
|
106
|
+
type: RunEventType.HOST_COMPLETED;
|
|
107
|
+
output: unknown;
|
|
108
|
+
} | {
|
|
109
|
+
type: RunEventType.WAIT_ELAPSED;
|
|
110
|
+
} | {
|
|
111
|
+
type: RunEventType.LOG_WRITTEN;
|
|
112
|
+
} | {
|
|
113
|
+
type: RunEventType.RESPONSE_SENT;
|
|
114
|
+
} | {
|
|
115
|
+
type: RunEventType.RESUMED;
|
|
116
|
+
output: unknown;
|
|
117
|
+
} | {
|
|
118
|
+
type: RunEventType.EFFECT_FAILED;
|
|
119
|
+
error: RuntimeErrorDetail;
|
|
120
|
+
};
|
|
121
|
+
export interface Frame {
|
|
122
|
+
sequencePath: string;
|
|
123
|
+
index: number;
|
|
124
|
+
}
|
|
125
|
+
export interface RunState {
|
|
126
|
+
stateVersion: number;
|
|
127
|
+
formatVersion: number;
|
|
128
|
+
status: RunStatus;
|
|
129
|
+
input: unknown;
|
|
130
|
+
stack: Frame[];
|
|
131
|
+
outputs: Record<string, {
|
|
132
|
+
output: unknown;
|
|
133
|
+
}>;
|
|
134
|
+
vars: Record<string, unknown>;
|
|
135
|
+
pending: Effect | null;
|
|
136
|
+
counters: {
|
|
137
|
+
steps: number;
|
|
138
|
+
effects: number;
|
|
139
|
+
};
|
|
140
|
+
outcome?: {
|
|
141
|
+
status: StopStatus;
|
|
142
|
+
output?: unknown;
|
|
143
|
+
error?: RuntimeErrorDetail & {
|
|
144
|
+
stepId?: string;
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
export interface StepResult {
|
|
149
|
+
state: RunState;
|
|
150
|
+
effects: Effect[];
|
|
151
|
+
status: RunStatus;
|
|
152
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RunEventType = exports.EffectType = exports.RunStatus = exports.CURRENT_STATE_VERSION = void 0;
|
|
4
|
+
exports.CURRENT_STATE_VERSION = 1;
|
|
5
|
+
var RunStatus;
|
|
6
|
+
(function (RunStatus) {
|
|
7
|
+
RunStatus["WAITING"] = "WAITING";
|
|
8
|
+
RunStatus["SUCCEEDED"] = "SUCCEEDED";
|
|
9
|
+
RunStatus["FAILED"] = "FAILED";
|
|
10
|
+
})(RunStatus || (exports.RunStatus = RunStatus = {}));
|
|
11
|
+
var EffectType;
|
|
12
|
+
(function (EffectType) {
|
|
13
|
+
EffectType["EVALUATE"] = "EVALUATE";
|
|
14
|
+
EffectType["HTTP"] = "HTTP";
|
|
15
|
+
EffectType["HOST"] = "HOST";
|
|
16
|
+
EffectType["WAIT"] = "WAIT";
|
|
17
|
+
EffectType["LOG"] = "LOG";
|
|
18
|
+
EffectType["RESPOND"] = "RESPOND";
|
|
19
|
+
})(EffectType || (exports.EffectType = EffectType = {}));
|
|
20
|
+
var RunEventType;
|
|
21
|
+
(function (RunEventType) {
|
|
22
|
+
RunEventType["EVALUATED"] = "EVALUATED";
|
|
23
|
+
RunEventType["HTTP_COMPLETED"] = "HTTP_COMPLETED";
|
|
24
|
+
RunEventType["HOST_COMPLETED"] = "HOST_COMPLETED";
|
|
25
|
+
RunEventType["WAIT_ELAPSED"] = "WAIT_ELAPSED";
|
|
26
|
+
RunEventType["LOG_WRITTEN"] = "LOG_WRITTEN";
|
|
27
|
+
RunEventType["RESPONSE_SENT"] = "RESPONSE_SENT";
|
|
28
|
+
RunEventType["RESUMED"] = "RESUMED";
|
|
29
|
+
RunEventType["EFFECT_FAILED"] = "EFFECT_FAILED";
|
|
30
|
+
})(RunEventType || (exports.RunEventType = RunEventType = {}));
|
|
31
|
+
//# sourceMappingURL=interpreter.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interpreter.types.js","sourceRoot":"","sources":["../../src/interpreter/interpreter.types.ts"],"names":[],"mappings":";;;AAca,QAAA,qBAAqB,GAAG,CAAC,CAAC;AAEvC,IAAY,SAKX;AALD,WAAY,SAAS;IAEnB,gCAAmB,CAAA;IACnB,oCAAuB,CAAA;IACvB,8BAAiB,CAAA;AACnB,CAAC,EALW,SAAS,yBAAT,SAAS,QAKpB;AAuBD,IAAY,UAOX;AAPD,WAAY,UAAU;IACpB,mCAAqB,CAAA;IACrB,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,2BAAa,CAAA;IACb,yBAAW,CAAA;IACX,iCAAmB,CAAA;AACrB,CAAC,EAPW,UAAU,0BAAV,UAAU,QAOrB;AAyED,IAAY,YAaX;AAbD,WAAY,YAAY;IACtB,uCAAuB,CAAA;IACvB,iDAAiC,CAAA;IACjC,iDAAiC,CAAA;IACjC,6CAA6B,CAAA;IAC7B,2CAA2B,CAAA;IAC3B,+CAA+B,CAAA;IAK/B,mCAAmB,CAAA;IACnB,+CAA+B,CAAA;AACjC,CAAC,EAbW,YAAY,4BAAZ,YAAY,QAavB"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { RuntimeDefinition, Step } from '../definition/definition.types';
|
|
2
|
+
import type { Frame } from './interpreter.types';
|
|
3
|
+
export declare const resolveSequence: (definition: RuntimeDefinition, path: string) => Step[];
|
|
4
|
+
export declare const resolveStep: (definition: RuntimeDefinition, frame: Frame) => Step;
|
|
5
|
+
export declare const branchPath: (frame: Frame, branch: string) => string;
|
|
6
|
+
export declare const ROOT_SEQUENCE_PATH = "steps";
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ROOT_SEQUENCE_PATH = exports.branchPath = exports.resolveStep = exports.resolveSequence = void 0;
|
|
4
|
+
const runtime_error_code_enum_1 = require("../errors/runtime-error-code.enum");
|
|
5
|
+
const definition_types_1 = require("../definition/definition.types");
|
|
6
|
+
const interpreter_error_1 = require("./interpreter-error");
|
|
7
|
+
const ROOT = 'steps';
|
|
8
|
+
const SEGMENT = /\[(\d+)\]\.(?:(then|else|default)|cases\[(\d+)\]\.steps)/y;
|
|
9
|
+
const corrupted = (path) => new interpreter_error_1.InterpreterError(runtime_error_code_enum_1.RuntimeErrorCode.INVALID_REQUEST, `Run state points outside the definition: ${path}`);
|
|
10
|
+
const branchOf = (step, name, caseIndex) => {
|
|
11
|
+
if (step.type === definition_types_1.StepType.CONDITION) {
|
|
12
|
+
return name === 'then' ? step.then : name === 'else' ? step.else : undefined;
|
|
13
|
+
}
|
|
14
|
+
if (step.type === definition_types_1.StepType.SWITCH) {
|
|
15
|
+
return name === 'default'
|
|
16
|
+
? step.default
|
|
17
|
+
: caseIndex === undefined
|
|
18
|
+
? undefined
|
|
19
|
+
: step.cases[Number(caseIndex)]?.steps;
|
|
20
|
+
}
|
|
21
|
+
return undefined;
|
|
22
|
+
};
|
|
23
|
+
const resolveSequence = (definition, path) => {
|
|
24
|
+
if (!path.startsWith(ROOT)) {
|
|
25
|
+
throw corrupted(path);
|
|
26
|
+
}
|
|
27
|
+
let sequence = definition.steps;
|
|
28
|
+
let position = ROOT.length;
|
|
29
|
+
while (position < path.length) {
|
|
30
|
+
SEGMENT.lastIndex = position;
|
|
31
|
+
const match = SEGMENT.exec(path);
|
|
32
|
+
const next = match ? branchOf(sequence[Number(match[1])], match[2], match[3]) : undefined;
|
|
33
|
+
if (!match || !next) {
|
|
34
|
+
throw corrupted(path);
|
|
35
|
+
}
|
|
36
|
+
sequence = next;
|
|
37
|
+
position = SEGMENT.lastIndex;
|
|
38
|
+
}
|
|
39
|
+
return sequence;
|
|
40
|
+
};
|
|
41
|
+
exports.resolveSequence = resolveSequence;
|
|
42
|
+
const resolveStep = (definition, frame) => {
|
|
43
|
+
const step = (0, exports.resolveSequence)(definition, frame.sequencePath)[frame.index];
|
|
44
|
+
if (!step) {
|
|
45
|
+
throw corrupted(frame.sequencePath);
|
|
46
|
+
}
|
|
47
|
+
return step;
|
|
48
|
+
};
|
|
49
|
+
exports.resolveStep = resolveStep;
|
|
50
|
+
const branchPath = (frame, branch) => `${frame.sequencePath}[${frame.index}].${branch}`;
|
|
51
|
+
exports.branchPath = branchPath;
|
|
52
|
+
exports.ROOT_SEQUENCE_PATH = ROOT;
|
|
53
|
+
//# sourceMappingURL=sequence-path.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sequence-path.js","sourceRoot":"","sources":["../../src/interpreter/sequence-path.ts"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RuntimeDefinition } from '../definition/definition.types';
|
|
2
|
+
import type { Effect, EvaluateEffect, HostEffect, HttpEffect, HttpResponse, LogEffect, RespondEffect, RunOptions, RunState, WaitEffect } from './interpreter.types';
|
|
3
|
+
import type { EvaluationResult } from '../runner-protocol/evaluation.types';
|
|
4
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
5
|
+
export interface TestHostHandlers {
|
|
6
|
+
evaluate: (effect: EvaluateEffect) => MaybePromise<EvaluationResult[]>;
|
|
7
|
+
http?: (effect: HttpEffect) => MaybePromise<HttpResponse>;
|
|
8
|
+
host?: (effect: HostEffect) => MaybePromise<unknown>;
|
|
9
|
+
wait?: (effect: WaitEffect) => MaybePromise<void>;
|
|
10
|
+
log?: (effect: LogEffect) => MaybePromise<void>;
|
|
11
|
+
respond?: (effect: RespondEffect) => MaybePromise<void>;
|
|
12
|
+
}
|
|
13
|
+
export interface TestRunResult {
|
|
14
|
+
state: RunState;
|
|
15
|
+
effects: Effect[];
|
|
16
|
+
}
|
|
17
|
+
export declare const runToCompletion: (definition: RuntimeDefinition, input: unknown, options: RunOptions, handlers: TestHostHandlers) => Promise<TestRunResult>;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.runToCompletion = void 0;
|
|
4
|
+
const interpreter_1 = require("./interpreter");
|
|
5
|
+
const interpreter_types_1 = require("./interpreter.types");
|
|
6
|
+
const DEFAULT_HTTP_RESPONSE = { status: 200, headers: {}, body: null };
|
|
7
|
+
const answer = async (effect, handlers) => {
|
|
8
|
+
switch (effect.type) {
|
|
9
|
+
case interpreter_types_1.EffectType.EVALUATE:
|
|
10
|
+
return { type: interpreter_types_1.RunEventType.EVALUATED, results: await handlers.evaluate(effect) };
|
|
11
|
+
case interpreter_types_1.EffectType.HTTP:
|
|
12
|
+
return {
|
|
13
|
+
type: interpreter_types_1.RunEventType.HTTP_COMPLETED,
|
|
14
|
+
response: handlers.http ? await handlers.http(effect) : DEFAULT_HTTP_RESPONSE,
|
|
15
|
+
};
|
|
16
|
+
case interpreter_types_1.EffectType.HOST:
|
|
17
|
+
return {
|
|
18
|
+
type: interpreter_types_1.RunEventType.HOST_COMPLETED,
|
|
19
|
+
output: handlers.host ? await handlers.host(effect) : null,
|
|
20
|
+
};
|
|
21
|
+
case interpreter_types_1.EffectType.WAIT:
|
|
22
|
+
await handlers.wait?.(effect);
|
|
23
|
+
return { type: interpreter_types_1.RunEventType.WAIT_ELAPSED };
|
|
24
|
+
case interpreter_types_1.EffectType.LOG:
|
|
25
|
+
await handlers.log?.(effect);
|
|
26
|
+
return { type: interpreter_types_1.RunEventType.LOG_WRITTEN };
|
|
27
|
+
case interpreter_types_1.EffectType.RESPOND:
|
|
28
|
+
await handlers.respond?.(effect);
|
|
29
|
+
return { type: interpreter_types_1.RunEventType.RESPONSE_SENT };
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const runToCompletion = async (definition, input, options, handlers) => {
|
|
33
|
+
const effects = [];
|
|
34
|
+
let result = (0, interpreter_1.start)(definition, input, options);
|
|
35
|
+
while (result.effects.length > 0) {
|
|
36
|
+
const [effect] = result.effects;
|
|
37
|
+
effects.push(effect);
|
|
38
|
+
result = (0, interpreter_1.step)(definition, result.state, await answer(effect, handlers), options);
|
|
39
|
+
}
|
|
40
|
+
return { state: result.state, effects };
|
|
41
|
+
};
|
|
42
|
+
exports.runToCompletion = runToCompletion;
|
|
43
|
+
//# sourceMappingURL=test-host.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-host.js","sourceRoot":"","sources":["../../src/interpreter/test-host.ts"],"names":[],"mappings":";;;AACA,+CAA4C;AAC5C,2DAA+D;AAuC/D,MAAM,qBAAqB,GAAiB,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;AAErF,MAAM,MAAM,GAAG,KAAK,EAAE,MAAc,EAAE,QAA0B,EAAqB,EAAE;IACrF,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACpB,KAAK,8BAAU,CAAC,QAAQ;YACtB,OAAO,EAAE,IAAI,EAAE,gCAAY,CAAC,SAAS,EAAE,OAAO,EAAE,MAAM,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;QACpF,KAAK,8BAAU,CAAC,IAAI;YAClB,OAAO;gBACL,IAAI,EAAE,gCAAY,CAAC,cAAc;gBACjC,QAAQ,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,qBAAqB;aAC9E,CAAC;QACJ,KAAK,8BAAU,CAAC,IAAI;YAClB,OAAO;gBACL,IAAI,EAAE,gCAAY,CAAC,cAAc;gBACjC,MAAM,EAAE,QAAQ,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI;aAC3D,CAAC;QACJ,KAAK,8BAAU,CAAC,IAAI;YAClB,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,CAAC;YAC9B,OAAO,EAAE,IAAI,EAAE,gCAAY,CAAC,YAAY,EAAE,CAAC;QAC7C,KAAK,8BAAU,CAAC,GAAG;YACjB,MAAM,QAAQ,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;YAC7B,OAAO,EAAE,IAAI,EAAE,gCAAY,CAAC,WAAW,EAAE,CAAC;QAC5C,KAAK,8BAAU,CAAC,OAAO;YACrB,MAAM,QAAQ,CAAC,OAAO,EAAE,CAAC,MAAM,CAAC,CAAC;YACjC,OAAO,EAAE,IAAI,EAAE,gCAAY,CAAC,aAAa,EAAE,CAAC;IAChD,CAAC;AACH,CAAC,CAAC;AAGK,MAAM,eAAe,GAAG,KAAK,EAClC,UAA6B,EAC7B,KAAc,EACd,OAAmB,EACnB,QAA0B,EACF,EAAE;IAC1B,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,IAAI,MAAM,GAAe,IAAA,mBAAK,EAAC,UAAU,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;IAC3D,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjC,MAAM,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,OAAO,CAAC;QAChC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACrB,MAAM,GAAG,IAAA,kBAAI,EAAC,UAAU,EAAE,MAAM,CAAC,KAAK,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;IACnF,CAAC;IACD,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC;AAC1C,CAAC,CAAC;AAdW,QAAA,eAAe,mBAc1B"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { RuntimeErrorDetail } from '../errors/runtime-error-code.enum';
|
|
2
|
+
export declare enum EvaluationKind {
|
|
3
|
+
EXPRESSION = "EXPRESSION",
|
|
4
|
+
TEMPLATE = "TEMPLATE",
|
|
5
|
+
CODE = "CODE"
|
|
6
|
+
}
|
|
7
|
+
export interface EvaluationItem {
|
|
8
|
+
id: string;
|
|
9
|
+
kind: EvaluationKind;
|
|
10
|
+
source: string;
|
|
11
|
+
}
|
|
12
|
+
export type EvaluationResult = {
|
|
13
|
+
id: string;
|
|
14
|
+
ok: true;
|
|
15
|
+
value: unknown;
|
|
16
|
+
} | {
|
|
17
|
+
id: string;
|
|
18
|
+
ok: false;
|
|
19
|
+
error: RuntimeErrorDetail;
|
|
20
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EvaluationKind = void 0;
|
|
4
|
+
var EvaluationKind;
|
|
5
|
+
(function (EvaluationKind) {
|
|
6
|
+
EvaluationKind["EXPRESSION"] = "EXPRESSION";
|
|
7
|
+
EvaluationKind["TEMPLATE"] = "TEMPLATE";
|
|
8
|
+
EvaluationKind["CODE"] = "CODE";
|
|
9
|
+
})(EvaluationKind || (exports.EvaluationKind = EvaluationKind = {}));
|
|
10
|
+
//# sourceMappingURL=evaluation.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"evaluation.types.js","sourceRoot":"","sources":["../../src/runner-protocol/evaluation.types.ts"],"names":[],"mappings":";;;AAEA,IAAY,cAOX;AAPD,WAAY,cAAc;IAExB,2CAAyB,CAAA;IAEzB,uCAAqB,CAAA;IAErB,+BAAa,CAAA;AACf,CAAC,EAPW,cAAc,8BAAd,cAAc,QAOzB"}
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { RuntimeErrorCode } from '../errors/runtime-error-code.enum';
|
|
2
|
+
import type { RuntimeDefinition } from '../definition/definition.types';
|
|
3
|
+
import type { RunState } from '../interpreter/interpreter.types';
|
|
4
|
+
export declare const EXECUTION_PROTOCOL = "abyss-runtime.v2";
|
|
5
|
+
export declare const MAX_CALL_PAYLOAD_BYTES = 1048576;
|
|
6
|
+
export declare const MAX_PROGRESS_OUTPUT_CHARS = 4096;
|
|
7
|
+
export declare enum CoreCapability {
|
|
8
|
+
HTTP_FETCH = "http.fetch",
|
|
9
|
+
WAIT = "wait",
|
|
10
|
+
LOG_WRITE = "log.write",
|
|
11
|
+
HTTP_RESPOND = "http.respond"
|
|
12
|
+
}
|
|
13
|
+
export declare enum ExecutionMessageType {
|
|
14
|
+
EXECUTE = "execute",
|
|
15
|
+
CALL = "call",
|
|
16
|
+
CALL_RESULT = "callResult",
|
|
17
|
+
PROGRESS = "progress",
|
|
18
|
+
FINISHED = "finished",
|
|
19
|
+
REJECTED = "rejected"
|
|
20
|
+
}
|
|
21
|
+
export type JSONValue = string | number | boolean | null | JSONValue[] | {
|
|
22
|
+
[key: string]: JSONValue;
|
|
23
|
+
};
|
|
24
|
+
export declare const RESERVED_GLOBAL_NAMES: readonly string[];
|
|
25
|
+
export interface ExecutionLimits {
|
|
26
|
+
memoryMb: number;
|
|
27
|
+
cpuTimeMs: number;
|
|
28
|
+
wallTimeMs: number;
|
|
29
|
+
guaranteedCpu: boolean;
|
|
30
|
+
}
|
|
31
|
+
export interface ExecutionBudget {
|
|
32
|
+
maxSteps: number;
|
|
33
|
+
maxEffects: number;
|
|
34
|
+
}
|
|
35
|
+
export interface ExecuteMessage {
|
|
36
|
+
type: ExecutionMessageType.EXECUTE;
|
|
37
|
+
executionId: string;
|
|
38
|
+
definition: RuntimeDefinition;
|
|
39
|
+
input: unknown;
|
|
40
|
+
state?: RunState;
|
|
41
|
+
resumeInput?: unknown;
|
|
42
|
+
capabilities: string[];
|
|
43
|
+
limits: ExecutionLimits;
|
|
44
|
+
budget: ExecutionBudget;
|
|
45
|
+
suspendWaitAboveMs?: number;
|
|
46
|
+
globals?: Record<string, JSONValue>;
|
|
47
|
+
}
|
|
48
|
+
export interface ExecutionCallMessage {
|
|
49
|
+
type: ExecutionMessageType.CALL;
|
|
50
|
+
callId: string;
|
|
51
|
+
stepId: string;
|
|
52
|
+
capability: string;
|
|
53
|
+
args: unknown;
|
|
54
|
+
}
|
|
55
|
+
export interface CallError {
|
|
56
|
+
code?: RuntimeErrorCode;
|
|
57
|
+
message: string;
|
|
58
|
+
}
|
|
59
|
+
export type ExecutionCallResultMessage = {
|
|
60
|
+
type: ExecutionMessageType.CALL_RESULT;
|
|
61
|
+
callId: string;
|
|
62
|
+
ok: true;
|
|
63
|
+
value: unknown;
|
|
64
|
+
} | {
|
|
65
|
+
type: ExecutionMessageType.CALL_RESULT;
|
|
66
|
+
callId: string;
|
|
67
|
+
ok: true;
|
|
68
|
+
suspend: true;
|
|
69
|
+
} | {
|
|
70
|
+
type: ExecutionMessageType.CALL_RESULT;
|
|
71
|
+
callId: string;
|
|
72
|
+
ok: false;
|
|
73
|
+
error: CallError;
|
|
74
|
+
};
|
|
75
|
+
export interface StepMetrics {
|
|
76
|
+
cpuMs: number;
|
|
77
|
+
heapPeakBytes: number;
|
|
78
|
+
wallMs: number;
|
|
79
|
+
}
|
|
80
|
+
export interface ExecutionMetrics {
|
|
81
|
+
queueMs: number;
|
|
82
|
+
wallMs: number;
|
|
83
|
+
cpuMs: number;
|
|
84
|
+
heapPeakBytes: number;
|
|
85
|
+
memoryLimitBytes: number;
|
|
86
|
+
}
|
|
87
|
+
export declare enum StepPhase {
|
|
88
|
+
STARTED = "started",
|
|
89
|
+
FINISHED = "finished"
|
|
90
|
+
}
|
|
91
|
+
export declare enum StepStatus {
|
|
92
|
+
SUCCEEDED = "SUCCEEDED",
|
|
93
|
+
FAILED = "FAILED",
|
|
94
|
+
SUSPENDED = "SUSPENDED"
|
|
95
|
+
}
|
|
96
|
+
export interface ProgressMessage {
|
|
97
|
+
type: ExecutionMessageType.PROGRESS;
|
|
98
|
+
stepId: string;
|
|
99
|
+
phase: StepPhase;
|
|
100
|
+
status?: StepStatus;
|
|
101
|
+
durationMs?: number;
|
|
102
|
+
metrics?: StepMetrics;
|
|
103
|
+
output?: unknown;
|
|
104
|
+
outputTruncated?: boolean;
|
|
105
|
+
errorCode?: RuntimeErrorCode;
|
|
106
|
+
}
|
|
107
|
+
export declare enum ExecutionStatus {
|
|
108
|
+
SUCCEEDED = "SUCCEEDED",
|
|
109
|
+
FAILED = "FAILED",
|
|
110
|
+
SUSPENDED = "SUSPENDED"
|
|
111
|
+
}
|
|
112
|
+
export interface ExecutionOutcome {
|
|
113
|
+
status: ExecutionStatus;
|
|
114
|
+
output?: unknown;
|
|
115
|
+
errorCode?: RuntimeErrorCode;
|
|
116
|
+
errorMessage?: string;
|
|
117
|
+
stepId?: string;
|
|
118
|
+
state?: RunState;
|
|
119
|
+
}
|
|
120
|
+
export interface FinishedMessage {
|
|
121
|
+
type: ExecutionMessageType.FINISHED;
|
|
122
|
+
outcome: ExecutionOutcome;
|
|
123
|
+
metrics: ExecutionMetrics;
|
|
124
|
+
}
|
|
125
|
+
export type ExecutionRejectionCode = RuntimeErrorCode.RUNNER_SATURATED | RuntimeErrorCode.INVALID_REQUEST | RuntimeErrorCode.STATE_VERSION_UNSUPPORTED;
|
|
126
|
+
export interface ExecutionRejectedMessage {
|
|
127
|
+
type: ExecutionMessageType.REJECTED;
|
|
128
|
+
code: ExecutionRejectionCode;
|
|
129
|
+
message: string;
|
|
130
|
+
}
|
|
131
|
+
export type ExecutionHostMessage = ExecuteMessage | ExecutionCallResultMessage;
|
|
132
|
+
export type ExecutionRunnerMessage = ExecutionCallMessage | ProgressMessage | FinishedMessage | ExecutionRejectedMessage;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ExecutionStatus = exports.StepStatus = exports.StepPhase = exports.RESERVED_GLOBAL_NAMES = exports.ExecutionMessageType = exports.CoreCapability = exports.MAX_PROGRESS_OUTPUT_CHARS = exports.MAX_CALL_PAYLOAD_BYTES = exports.EXECUTION_PROTOCOL = void 0;
|
|
4
|
+
exports.EXECUTION_PROTOCOL = 'abyss-runtime.v2';
|
|
5
|
+
exports.MAX_CALL_PAYLOAD_BYTES = 1_048_576;
|
|
6
|
+
exports.MAX_PROGRESS_OUTPUT_CHARS = 4_096;
|
|
7
|
+
var CoreCapability;
|
|
8
|
+
(function (CoreCapability) {
|
|
9
|
+
CoreCapability["HTTP_FETCH"] = "http.fetch";
|
|
10
|
+
CoreCapability["WAIT"] = "wait";
|
|
11
|
+
CoreCapability["LOG_WRITE"] = "log.write";
|
|
12
|
+
CoreCapability["HTTP_RESPOND"] = "http.respond";
|
|
13
|
+
})(CoreCapability || (exports.CoreCapability = CoreCapability = {}));
|
|
14
|
+
var ExecutionMessageType;
|
|
15
|
+
(function (ExecutionMessageType) {
|
|
16
|
+
ExecutionMessageType["EXECUTE"] = "execute";
|
|
17
|
+
ExecutionMessageType["CALL"] = "call";
|
|
18
|
+
ExecutionMessageType["CALL_RESULT"] = "callResult";
|
|
19
|
+
ExecutionMessageType["PROGRESS"] = "progress";
|
|
20
|
+
ExecutionMessageType["FINISHED"] = "finished";
|
|
21
|
+
ExecutionMessageType["REJECTED"] = "rejected";
|
|
22
|
+
})(ExecutionMessageType || (exports.ExecutionMessageType = ExecutionMessageType = {}));
|
|
23
|
+
exports.RESERVED_GLOBAL_NAMES = [
|
|
24
|
+
'input',
|
|
25
|
+
'steps',
|
|
26
|
+
'vars',
|
|
27
|
+
'fetch',
|
|
28
|
+
'abyss',
|
|
29
|
+
'console',
|
|
30
|
+
];
|
|
31
|
+
var StepPhase;
|
|
32
|
+
(function (StepPhase) {
|
|
33
|
+
StepPhase["STARTED"] = "started";
|
|
34
|
+
StepPhase["FINISHED"] = "finished";
|
|
35
|
+
})(StepPhase || (exports.StepPhase = StepPhase = {}));
|
|
36
|
+
var StepStatus;
|
|
37
|
+
(function (StepStatus) {
|
|
38
|
+
StepStatus["SUCCEEDED"] = "SUCCEEDED";
|
|
39
|
+
StepStatus["FAILED"] = "FAILED";
|
|
40
|
+
StepStatus["SUSPENDED"] = "SUSPENDED";
|
|
41
|
+
})(StepStatus || (exports.StepStatus = StepStatus = {}));
|
|
42
|
+
var ExecutionStatus;
|
|
43
|
+
(function (ExecutionStatus) {
|
|
44
|
+
ExecutionStatus["SUCCEEDED"] = "SUCCEEDED";
|
|
45
|
+
ExecutionStatus["FAILED"] = "FAILED";
|
|
46
|
+
ExecutionStatus["SUSPENDED"] = "SUSPENDED";
|
|
47
|
+
})(ExecutionStatus || (exports.ExecutionStatus = ExecutionStatus = {}));
|
|
48
|
+
//# sourceMappingURL=execution-protocol.types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"execution-protocol.types.js","sourceRoot":"","sources":["../../src/runner-protocol/execution-protocol.types.ts"],"names":[],"mappings":";;;AAQa,QAAA,kBAAkB,GAAG,kBAAkB,CAAC;AAGxC,QAAA,sBAAsB,GAAG,SAAS,CAAC;AAGnC,QAAA,yBAAyB,GAAG,KAAK,CAAC;AAM/C,IAAY,cASX;AATD,WAAY,cAAc;IAExB,2CAAyB,CAAA;IAEzB,+BAAa,CAAA;IAEb,yCAAuB,CAAA;IAEvB,+CAA6B,CAAA;AAC/B,CAAC,EATW,cAAc,8BAAd,cAAc,QASzB;AAED,IAAY,oBAOX;AAPD,WAAY,oBAAoB;IAC9B,2CAAmB,CAAA;IACnB,qCAAa,CAAA;IACb,kDAA0B,CAAA;IAC1B,6CAAqB,CAAA;IACrB,6CAAqB,CAAA;IACrB,6CAAqB,CAAA;AACvB,CAAC,EAPW,oBAAoB,oCAApB,oBAAoB,QAO/B;AAcY,QAAA,qBAAqB,GAAsB;IACtD,OAAO;IACP,OAAO;IACP,MAAM;IACN,OAAO;IACP,OAAO;IACP,SAAS;CACV,CAAC;AAqFF,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,gCAAmB,CAAA;IACnB,kCAAqB,CAAA;AACvB,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB;AAED,IAAY,UAKX;AALD,WAAY,UAAU;IACpB,qCAAuB,CAAA;IACvB,+BAAiB,CAAA;IAEjB,qCAAuB,CAAA;AACzB,CAAC,EALW,UAAU,0BAAV,UAAU,QAKrB;AAuBD,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,0CAAuB,CAAA;IACvB,oCAAiB,CAAA;IACjB,0CAAuB,CAAA;AACzB,CAAC,EAJW,eAAe,+BAAf,eAAe,QAI1B"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CodeRunnerError = void 0;
|
|
4
|
+
class CodeRunnerError extends Error {
|
|
5
|
+
constructor(code, message) {
|
|
6
|
+
super(message);
|
|
7
|
+
this.name = 'CodeRunnerError';
|
|
8
|
+
this.code = code;
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
exports.CodeRunnerError = CodeRunnerError;
|
|
12
|
+
//# sourceMappingURL=code-runner-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"code-runner-error.js","sourceRoot":"","sources":["../../src/server/code-runner-error.ts"],"names":[],"mappings":";;;AAGA,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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RuntimeErrorCode } from '../errors/runtime-error-code.enum';
|
|
2
|
+
import type { ExecuteMessage, FinishedMessage, ProgressMessage } from '../runner-protocol/execution-protocol.types';
|
|
3
|
+
export interface CodeRunnerSessionOptions {
|
|
4
|
+
url: string;
|
|
5
|
+
token: string;
|
|
6
|
+
connectTimeoutMs: number;
|
|
7
|
+
wallTimeGraceMs: number;
|
|
8
|
+
}
|
|
9
|
+
export interface CapabilityContext {
|
|
10
|
+
stepId: string;
|
|
11
|
+
}
|
|
12
|
+
export type CapabilityHandlers = Record<string, (args: unknown, context: CapabilityContext) => Promise<unknown>>;
|
|
13
|
+
export declare const SUSPEND_EXECUTION: unique symbol;
|
|
14
|
+
export declare class CapabilityError extends Error {
|
|
15
|
+
readonly code: RuntimeErrorCode;
|
|
16
|
+
constructor(code: RuntimeErrorCode, message: string);
|
|
17
|
+
}
|
|
18
|
+
export type ExecutionRequest = Omit<ExecuteMessage, 'type' | 'capabilities'>;
|
|
19
|
+
export interface ExecuteOptions {
|
|
20
|
+
onProgress?: (progress: Omit<ProgressMessage, 'type'>) => void;
|
|
21
|
+
signal?: AbortSignal;
|
|
22
|
+
}
|
|
23
|
+
export type ExecutionResult = Omit<FinishedMessage, 'type'>;
|
|
24
|
+
export declare class CodeRunnerSession {
|
|
25
|
+
private readonly options;
|
|
26
|
+
constructor(options: CodeRunnerSessionOptions);
|
|
27
|
+
execute(request: ExecutionRequest, handlers: CapabilityHandlers, executeOptions?: ExecuteOptions): Promise<ExecutionResult>;
|
|
28
|
+
}
|