@abyss-project/runtime 3.8.0 → 3.10.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 -32
- package/dist/cost/execution-cost.d.ts +6 -0
- package/dist/cost/execution-cost.js +27 -12
- package/dist/cost/execution-cost.js.map +1 -1
- package/dist/discord/discord.types.d.ts +44 -2
- package/dist/discord/discord.types.js +12 -1
- package/dist/discord/discord.types.js.map +1 -1
- package/dist/engine/engine-source.js +1 -1
- package/dist/runner-protocol/execution-protocol.types.d.ts +3 -0
- package/dist/runner-protocol/execution-protocol.types.js +5 -1
- package/dist/runner-protocol/execution-protocol.types.js.map +1 -1
- package/jest.config.ts +11 -11
- package/package.json +1 -1
- package/scripts/build-engine.cjs +70 -70
- package/src/__tests__/engine-bundle.test.ts +121 -121
- package/src/access/__tests__/host-match.test.ts +24 -24
- package/src/access/access.types.ts +25 -25
- package/src/access/host-match.ts +13 -13
- package/src/cost/__tests__/execution-cost.test.ts +249 -196
- package/src/cost/execution-cost.ts +203 -186
- package/src/definition/__tests__/validate-definition.test.ts +354 -354
- package/src/definition/definition.limits.ts +9 -9
- package/src/definition/definition.schema.ts +172 -172
- package/src/definition/definition.types.ts +171 -171
- package/src/definition/validate-definition.ts +206 -206
- package/src/definition/walk-steps.ts +44 -44
- package/src/discord/__tests__/discord-event-input.test.ts +90 -89
- package/src/discord/discord.types.ts +56 -1
- package/src/engine/engine-entry.ts +3 -3
- package/src/engine/engine-global.ts +2 -2
- package/src/errors/runtime-error-code.enum.ts +37 -37
- package/src/index.ts +32 -32
- package/src/interpreter/__tests__/interpreter.test.ts +854 -854
- package/src/interpreter/__tests__/log-respond-resume.test.ts +271 -271
- package/src/interpreter/interpreter-error.ts +12 -12
- package/src/interpreter/interpreter.ts +483 -483
- package/src/interpreter/interpreter.types.ts +204 -204
- package/src/interpreter/sequence-path.ts +67 -67
- package/src/interpreter/test-host.ts +85 -85
- package/src/runner-protocol/__tests__/file-payload.test.ts +26 -0
- package/src/runner-protocol/evaluation.types.ts +21 -21
- package/src/runner-protocol/execution-protocol.types.ts +20 -0
- package/src/schedule/schedule.types.ts +100 -100
- package/src/server/__tests__/code-runner-session.test.ts +311 -311
- package/src/server/code-runner-error.ts +12 -12
- package/src/server/code-runner-session.ts +310 -310
- package/src/server/index.ts +11 -11
- package/src/steps/__tests__/global-references.test.ts +133 -133
- package/src/steps/execute-step.ts +186 -186
- package/src/steps/global-references.ts +48 -48
- package/src/steps/step-access.ts +56 -56
- package/src/steps/step-fields.ts +87 -87
- package/src/steps/value-source.ts +69 -69
- package/tsconfig.check.json +15 -15
- package/tsconfig.json +35 -35
|
@@ -1,89 +1,90 @@
|
|
|
1
|
-
import { DiscordEventInput, DiscordEventType, isDiscordEventInput } from '../discord.types';
|
|
2
|
-
import { ScheduledRunKind } from '../../schedule/schedule.types';
|
|
3
|
-
|
|
4
|
-
const DATA_BY_TYPE: Record<DiscordEventType, DiscordEventInput['data']> = {
|
|
5
|
-
[DiscordEventType.GUILD_MEMBER_ADD]: {
|
|
6
|
-
user: { id: 'u1', username: 'ann', globalName: null, bot: false, avatar: null },
|
|
7
|
-
roles: [],
|
|
8
|
-
joinedAt: '2026-11-21T10:00:00.000Z',
|
|
9
|
-
pending: false,
|
|
10
|
-
},
|
|
11
|
-
[DiscordEventType.GUILD_MEMBER_REMOVE]: {
|
|
12
|
-
user: { id: 'u1', username: 'ann', globalName: 'Ann', bot: false },
|
|
13
|
-
},
|
|
14
|
-
[DiscordEventType.MESSAGE_CREATE]: {
|
|
15
|
-
id: 'm1',
|
|
16
|
-
channelId: 'c1',
|
|
17
|
-
author: { id: 'u1', username: 'ann', globalName: null, bot: false },
|
|
18
|
-
member: { roles: ['r1'], nick: null },
|
|
19
|
-
mentions: [],
|
|
20
|
-
referencedMessageId: null,
|
|
21
|
-
attachmentCount: 0,
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
expect(isDiscordEventInput(
|
|
88
|
-
|
|
89
|
-
});
|
|
1
|
+
import { DiscordEventInput, DiscordEventType, isDiscordEventInput } from '../discord.types';
|
|
2
|
+
import { ScheduledRunKind } from '../../schedule/schedule.types';
|
|
3
|
+
|
|
4
|
+
const DATA_BY_TYPE: Record<DiscordEventType, DiscordEventInput['data']> = {
|
|
5
|
+
[DiscordEventType.GUILD_MEMBER_ADD]: {
|
|
6
|
+
user: { id: 'u1', username: 'ann', globalName: null, bot: false, avatar: null },
|
|
7
|
+
roles: [],
|
|
8
|
+
joinedAt: '2026-11-21T10:00:00.000Z',
|
|
9
|
+
pending: false,
|
|
10
|
+
},
|
|
11
|
+
[DiscordEventType.GUILD_MEMBER_REMOVE]: {
|
|
12
|
+
user: { id: 'u1', username: 'ann', globalName: 'Ann', bot: false },
|
|
13
|
+
},
|
|
14
|
+
[DiscordEventType.MESSAGE_CREATE]: {
|
|
15
|
+
id: 'm1',
|
|
16
|
+
channelId: 'c1',
|
|
17
|
+
author: { id: 'u1', username: 'ann', globalName: null, bot: false },
|
|
18
|
+
member: { roles: ['r1'], nick: null },
|
|
19
|
+
mentions: [],
|
|
20
|
+
referencedMessageId: null,
|
|
21
|
+
attachmentCount: 0,
|
|
22
|
+
attachments: [],
|
|
23
|
+
createdAt: '2026-11-21T10:00:00.000Z',
|
|
24
|
+
},
|
|
25
|
+
[DiscordEventType.MESSAGE_REACTION_ADD]: {
|
|
26
|
+
userId: 'u1',
|
|
27
|
+
channelId: 'c1',
|
|
28
|
+
messageId: 'm1',
|
|
29
|
+
messageAuthorId: 'u2',
|
|
30
|
+
member: { roles: [] },
|
|
31
|
+
emoji: { id: null, name: '👍', animated: false },
|
|
32
|
+
},
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const inputOf = (type: DiscordEventType): DiscordEventInput => ({
|
|
36
|
+
kind: 'DISCORD_EVENT',
|
|
37
|
+
event: { id: 'e1', type, trigger: { id: 't1', name: 'welcome' } },
|
|
38
|
+
guildId: 'g1',
|
|
39
|
+
receivedAt: '2026-11-21T10:00:00.000Z',
|
|
40
|
+
firedAt: '2026-11-21T10:00:01.000Z',
|
|
41
|
+
attempt: 1,
|
|
42
|
+
data: DATA_BY_TYPE[type],
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
describe('isDiscordEventInput', () => {
|
|
46
|
+
it.each(Object.values(DiscordEventType))('is true for a %s input', (type) => {
|
|
47
|
+
expect(isDiscordEventInput(inputOf(type))).toBe(true);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('is false for an interaction input', () => {
|
|
51
|
+
expect(
|
|
52
|
+
isDiscordEventInput({
|
|
53
|
+
kind: 'COMMAND',
|
|
54
|
+
command: { name: 'ping', options: {} },
|
|
55
|
+
user: { id: 'u1', username: 'ann', globalName: null },
|
|
56
|
+
locale: 'en-US',
|
|
57
|
+
interaction: { id: 'i1', applicationId: 'a1', type: 2, data: null },
|
|
58
|
+
}),
|
|
59
|
+
).toBe(false);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('is false for a scheduled run input', () => {
|
|
63
|
+
expect(
|
|
64
|
+
isDiscordEventInput({
|
|
65
|
+
kind: ScheduledRunKind.SCHEDULE,
|
|
66
|
+
task: { id: 't1', name: 'daily' },
|
|
67
|
+
scheduledFor: '2026-11-21T10:00:00.000Z',
|
|
68
|
+
firedAt: '2026-11-21T10:00:01.000Z',
|
|
69
|
+
attempt: 1,
|
|
70
|
+
}),
|
|
71
|
+
).toBe(false);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('is false for an unknown event type, a missing envelope field and non-objects', () => {
|
|
75
|
+
expect(
|
|
76
|
+
isDiscordEventInput({
|
|
77
|
+
...inputOf(DiscordEventType.MESSAGE_CREATE),
|
|
78
|
+
event: { id: 'e1', type: 'X', trigger: { id: 't', name: 'n' } },
|
|
79
|
+
}),
|
|
80
|
+
).toBe(false);
|
|
81
|
+
expect(
|
|
82
|
+
isDiscordEventInput({ ...inputOf(DiscordEventType.MESSAGE_CREATE), guildId: undefined }),
|
|
83
|
+
).toBe(false);
|
|
84
|
+
expect(isDiscordEventInput({ ...inputOf(DiscordEventType.MESSAGE_CREATE), data: null })).toBe(
|
|
85
|
+
false,
|
|
86
|
+
);
|
|
87
|
+
expect(isDiscordEventInput(null)).toBe(false);
|
|
88
|
+
expect(isDiscordEventInput('DISCORD_EVENT')).toBe(false);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
@@ -64,7 +64,22 @@ export enum DiscordCapability {
|
|
|
64
64
|
CREATE_THREAD = 'discord.createThread',
|
|
65
65
|
/** Ends a poll of the bot before its time. Arguments: `DiscordEndPollArgs`. */
|
|
66
66
|
END_POLL = 'discord.endPoll',
|
|
67
|
-
|
|
67
|
+
/** Answers an autocomplete interaction with choices. Arguments: `DiscordAutocompleteArgs`. */
|
|
68
|
+
AUTOCOMPLETE = 'discord.autocomplete',
|
|
69
|
+
/** Downloads an attachment of the interaction or event. Arguments: `DiscordReadAttachmentArgs`; result: `DiscordReadAttachmentResult`. */
|
|
70
|
+
READ_ATTACHMENT = 'discord.readAttachment',
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Choices an autocomplete answer carries at most (Discord's limit). */
|
|
74
|
+
export const DISCORD_AUTOCOMPLETE_MAX_CHOICES = 25;
|
|
75
|
+
/** Files a message carries at most (Discord's limit). */
|
|
76
|
+
export const DISCORD_MESSAGE_MAX_FILES = 10;
|
|
77
|
+
/** Total size of the files of a message, in bytes. */
|
|
78
|
+
export const DISCORD_MESSAGE_MAX_FILES_BYTES = 10 * 1024 * 1024;
|
|
79
|
+
/** Upper bound of `budget.maxFilePayloadBytes`: the largest payload a file call may carry. */
|
|
80
|
+
export const REFLEX_ATTACHMENT_MAX_BYTES_BOUND = 8 * 1024 * 1024;
|
|
81
|
+
/** Default size an attachment read may reach when the Service sets no limit. */
|
|
82
|
+
export const REFLEX_ATTACHMENT_DEFAULT_MAX_BYTES = 2 * 1024 * 1024;
|
|
68
83
|
|
|
69
84
|
/**
|
|
70
85
|
* Bounds the host applies to the arguments of `abyss.discord.*` before any call to Discord: a call
|
|
@@ -103,6 +118,8 @@ export const DISCORD_CAPABILITY_LIMITS = {
|
|
|
103
118
|
export enum DiscordErrorCode {
|
|
104
119
|
/** `showModal` after the interaction was acknowledged (more than 2.5 s after it arrived). */
|
|
105
120
|
MODAL_TOO_LATE = 'MODAL_TOO_LATE',
|
|
121
|
+
/** `autocomplete` called after the autocomplete answer was sent, or a second time. */
|
|
122
|
+
INTERACTION_ALREADY_ANSWERED = 'INTERACTION_ALREADY_ANSWERED',
|
|
106
123
|
/** The bot's token is refused (circuit breaker open): no call was made to Discord. */
|
|
107
124
|
DISCORD_TOKEN_INVALID = 'DISCORD_TOKEN_INVALID',
|
|
108
125
|
/** Discord answered 403. */
|
|
@@ -165,8 +182,16 @@ export interface DiscordPoll {
|
|
|
165
182
|
allowMultiselect?: boolean;
|
|
166
183
|
}
|
|
167
184
|
|
|
185
|
+
/** A file of a message: its content inline (base64) or an attachment of the interaction to forward. */
|
|
186
|
+
export type DiscordMessageFile = { name: string; description?: string } & (
|
|
187
|
+
| { contentBase64: string }
|
|
188
|
+
| { attachmentId: string }
|
|
189
|
+
);
|
|
190
|
+
|
|
168
191
|
export interface DiscordMessage {
|
|
169
192
|
content?: string;
|
|
193
|
+
/** At most `DISCORD_MESSAGE_MAX_FILES` files, `DISCORD_MESSAGE_MAX_FILES_BYTES` in total. */
|
|
194
|
+
files?: DiscordMessageFile[];
|
|
170
195
|
embeds?: DiscordJsonObject[];
|
|
171
196
|
components?: DiscordJsonObject[];
|
|
172
197
|
/** Only the reply to an interaction can be ephemeral. */
|
|
@@ -357,6 +382,29 @@ export interface DiscordCreateThreadArgs extends DiscordAuditReason {
|
|
|
357
382
|
autoArchiveMinutes?: number;
|
|
358
383
|
}
|
|
359
384
|
|
|
385
|
+
export interface DiscordAutocompleteChoice {
|
|
386
|
+
name: string;
|
|
387
|
+
value: string | number;
|
|
388
|
+
nameLocalizations?: Record<string, string>;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/** At most `DISCORD_AUTOCOMPLETE_MAX_CHOICES` choices. */
|
|
392
|
+
export interface DiscordAutocompleteArgs {
|
|
393
|
+
choices: DiscordAutocompleteChoice[];
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
export interface DiscordReadAttachmentArgs {
|
|
397
|
+
attachmentId: string;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export interface DiscordReadAttachmentResult {
|
|
401
|
+
filename: string;
|
|
402
|
+
contentType: string | null;
|
|
403
|
+
/** Bytes. */
|
|
404
|
+
size: number;
|
|
405
|
+
contentBase64: string;
|
|
406
|
+
}
|
|
407
|
+
|
|
360
408
|
export interface DiscordEndPollArgs {
|
|
361
409
|
channelId: string;
|
|
362
410
|
messageId: string;
|
|
@@ -455,6 +503,7 @@ export interface DiscordGuild {
|
|
|
455
503
|
/** The kind of interaction a function was started by. */
|
|
456
504
|
export enum DiscordInteractionKind {
|
|
457
505
|
COMMAND = 'COMMAND',
|
|
506
|
+
AUTOCOMPLETE = 'AUTOCOMPLETE',
|
|
458
507
|
COMPONENT = 'COMPONENT',
|
|
459
508
|
MODAL = 'MODAL',
|
|
460
509
|
}
|
|
@@ -464,6 +513,7 @@ export enum DiscordInteractionType {
|
|
|
464
513
|
PING = 1,
|
|
465
514
|
APPLICATION_COMMAND = 2,
|
|
466
515
|
MESSAGE_COMPONENT = 3,
|
|
516
|
+
APPLICATION_COMMAND_AUTOCOMPLETE = 4,
|
|
467
517
|
MODAL_SUBMIT = 5,
|
|
468
518
|
}
|
|
469
519
|
|
|
@@ -474,6 +524,7 @@ export enum DiscordCallbackType {
|
|
|
474
524
|
DEFERRED_CHANNEL_MESSAGE_WITH_SOURCE = 5,
|
|
475
525
|
DEFERRED_UPDATE_MESSAGE = 6,
|
|
476
526
|
UPDATE_MESSAGE = 7,
|
|
527
|
+
APPLICATION_COMMAND_AUTOCOMPLETE_RESULT = 8,
|
|
477
528
|
MODAL = 9,
|
|
478
529
|
}
|
|
479
530
|
|
|
@@ -524,6 +575,8 @@ export interface DiscordInteractionInput {
|
|
|
524
575
|
name: string;
|
|
525
576
|
options: Record<string, string | number | boolean>;
|
|
526
577
|
resolved?: DiscordResolved;
|
|
578
|
+
/** The option being typed; present only for an AUTOCOMPLETE interaction. */
|
|
579
|
+
focused?: { name: string; value: string };
|
|
527
580
|
};
|
|
528
581
|
/** `values` of a select menu; `resolved` details them for a user, role, channel or mentionable menu. */
|
|
529
582
|
component?: { customId: string; values?: string[]; resolved?: DiscordResolved };
|
|
@@ -576,6 +629,8 @@ export interface DiscordMessageCreateData {
|
|
|
576
629
|
mentions: string[];
|
|
577
630
|
referencedMessageId: string | null;
|
|
578
631
|
attachmentCount: number;
|
|
632
|
+
/** The files of the message, with the ids `discord.readAttachment` takes. */
|
|
633
|
+
attachments: DiscordAttachment[];
|
|
579
634
|
/** ISO 8601. */
|
|
580
635
|
createdAt: string;
|
|
581
636
|
/** Present only when the trigger asks for the content (`includeContent`). */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
// Entry of the isolate bundle built by `scripts/build-engine.cjs` (IIFE): evaluating the script
|
|
2
|
-
// defines the global `ENGINE_GLOBAL_NAME` holding exactly these exports.
|
|
3
|
-
export { runInIsolate } from './run-in-isolate';
|
|
1
|
+
// Entry of the isolate bundle built by `scripts/build-engine.cjs` (IIFE): evaluating the script
|
|
2
|
+
// defines the global `ENGINE_GLOBAL_NAME` holding exactly these exports.
|
|
3
|
+
export { runInIsolate } from './run-in-isolate';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** Global the engine script defines when evaluated: `{ runInIsolate }`. */
|
|
2
|
-
export const ENGINE_GLOBAL_NAME = 'AbyssRuntimeEngine';
|
|
1
|
+
/** Global the engine script defines when evaluated: `{ runInIsolate }`. */
|
|
2
|
+
export const ENGINE_GLOBAL_NAME = 'AbyssRuntimeEngine';
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Every failure a run, an evaluation or the code runner can report. The same codes travel in
|
|
3
|
-
* the interpreter's events, in the runner protocol and in the errors thrown by the Node client,
|
|
4
|
-
* so a caller maps one list to its own failure codes.
|
|
5
|
-
*/
|
|
6
|
-
export enum RuntimeErrorCode {
|
|
7
|
-
/** An expression or a template threw or did not parse. */
|
|
8
|
-
EXPRESSION_ERROR = 'EXPRESSION_ERROR',
|
|
9
|
-
/** A `code` item threw or did not parse. */
|
|
10
|
-
CODE_ERROR = 'CODE_ERROR',
|
|
11
|
-
/** The execution exceeded its wall-clock or CPU time limit. */
|
|
12
|
-
TIMEOUT = 'TIMEOUT',
|
|
13
|
-
/** The execution exceeded the memory limit of its isolate. */
|
|
14
|
-
MEMORY_LIMIT = 'MEMORY_LIMIT',
|
|
15
|
-
/** An effect is not covered by both the definition's declarations and the run's grants. */
|
|
16
|
-
ACCESS_DENIED = 'ACCESS_DENIED',
|
|
17
|
-
/** The run exceeded its step or effect budget. */
|
|
18
|
-
BUDGET_EXCEEDED = 'BUDGET_EXCEEDED',
|
|
19
|
-
/** A host action failed, or its resolved input does not match the action's schema. */
|
|
20
|
-
HOST_ERROR = 'HOST_ERROR',
|
|
21
|
-
/** The host could not perform an HTTP effect (network, SSRF guard, timeout). */
|
|
22
|
-
HTTP_ERROR = 'HTTP_ERROR',
|
|
23
|
-
/** The code runner could not be reached, or the connection dropped mid-execution. */
|
|
24
|
-
RUNNER_UNAVAILABLE = 'RUNNER_UNAVAILABLE',
|
|
25
|
-
/** The code runner refused the execution: its queue is full or the wait timed out. */
|
|
26
|
-
RUNNER_SATURATED = 'RUNNER_SATURATED',
|
|
27
|
-
/** A message or a definition does not match the contract. */
|
|
28
|
-
INVALID_REQUEST = 'INVALID_REQUEST',
|
|
29
|
-
/** A run state to resume carries a `stateVersion` this core cannot read. */
|
|
30
|
-
STATE_VERSION_UNSUPPORTED = 'STATE_VERSION_UNSUPPORTED',
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface RuntimeErrorDetail {
|
|
34
|
-
code: RuntimeErrorCode;
|
|
35
|
-
/** Human-readable cause. Never contains the client's code, context or values. */
|
|
36
|
-
message: string;
|
|
37
|
-
}
|
|
1
|
+
/**
|
|
2
|
+
* Every failure a run, an evaluation or the code runner can report. The same codes travel in
|
|
3
|
+
* the interpreter's events, in the runner protocol and in the errors thrown by the Node client,
|
|
4
|
+
* so a caller maps one list to its own failure codes.
|
|
5
|
+
*/
|
|
6
|
+
export enum RuntimeErrorCode {
|
|
7
|
+
/** An expression or a template threw or did not parse. */
|
|
8
|
+
EXPRESSION_ERROR = 'EXPRESSION_ERROR',
|
|
9
|
+
/** A `code` item threw or did not parse. */
|
|
10
|
+
CODE_ERROR = 'CODE_ERROR',
|
|
11
|
+
/** The execution exceeded its wall-clock or CPU time limit. */
|
|
12
|
+
TIMEOUT = 'TIMEOUT',
|
|
13
|
+
/** The execution exceeded the memory limit of its isolate. */
|
|
14
|
+
MEMORY_LIMIT = 'MEMORY_LIMIT',
|
|
15
|
+
/** An effect is not covered by both the definition's declarations and the run's grants. */
|
|
16
|
+
ACCESS_DENIED = 'ACCESS_DENIED',
|
|
17
|
+
/** The run exceeded its step or effect budget. */
|
|
18
|
+
BUDGET_EXCEEDED = 'BUDGET_EXCEEDED',
|
|
19
|
+
/** A host action failed, or its resolved input does not match the action's schema. */
|
|
20
|
+
HOST_ERROR = 'HOST_ERROR',
|
|
21
|
+
/** The host could not perform an HTTP effect (network, SSRF guard, timeout). */
|
|
22
|
+
HTTP_ERROR = 'HTTP_ERROR',
|
|
23
|
+
/** The code runner could not be reached, or the connection dropped mid-execution. */
|
|
24
|
+
RUNNER_UNAVAILABLE = 'RUNNER_UNAVAILABLE',
|
|
25
|
+
/** The code runner refused the execution: its queue is full or the wait timed out. */
|
|
26
|
+
RUNNER_SATURATED = 'RUNNER_SATURATED',
|
|
27
|
+
/** A message or a definition does not match the contract. */
|
|
28
|
+
INVALID_REQUEST = 'INVALID_REQUEST',
|
|
29
|
+
/** A run state to resume carries a `stateVersion` this core cannot read. */
|
|
30
|
+
STATE_VERSION_UNSUPPORTED = 'STATE_VERSION_UNSUPPORTED',
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface RuntimeErrorDetail {
|
|
34
|
+
code: RuntimeErrorCode;
|
|
35
|
+
/** Human-readable cause. Never contains the client's code, context or values. */
|
|
36
|
+
message: string;
|
|
37
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
// Package root: browser-compatible. No Node import (`fs`, `net`, `http`, `ws`...) here nor in what
|
|
2
|
-
// this root re-exports; everything touching the network or the system lives under `src/server`
|
|
3
|
-
// (entry point `@abyss-project/runtime/server`).
|
|
4
|
-
export * from './errors/runtime-error-code.enum';
|
|
5
|
-
export * from './access/access.types';
|
|
6
|
-
export { hostMatches } from './access/host-match';
|
|
7
|
-
export * from './definition/definition.types';
|
|
8
|
-
export { validateDefinition } from './definition/validate-definition';
|
|
9
|
-
export type { ValidationResult } from './definition/validate-definition';
|
|
10
|
-
export { MAX_WAIT_DURATION_MS } from './definition/definition.limits';
|
|
11
|
-
export { walkSteps } from './definition/walk-steps';
|
|
12
|
-
export type { StepVisitor } from './definition/walk-steps';
|
|
13
|
-
export * from './interpreter/interpreter.types';
|
|
14
|
-
export { start, step } from './interpreter/interpreter';
|
|
15
|
-
export { InterpreterError } from './interpreter/interpreter-error';
|
|
16
|
-
export { runToCompletion } from './interpreter/test-host';
|
|
17
|
-
export type { TestHostHandlers, TestRunResult } from './interpreter/test-host';
|
|
18
|
-
export * from './discord/discord.types';
|
|
19
|
-
export * from './schedule/schedule.types';
|
|
20
|
-
export * from './runner-protocol/evaluation.types';
|
|
21
|
-
export * from './runner-protocol/execution-protocol.types';
|
|
22
|
-
export { runInIsolate, EngineResultKind } from './engine/run-in-isolate';
|
|
23
|
-
export type {
|
|
24
|
-
EngineHost,
|
|
25
|
-
EngineProgress,
|
|
26
|
-
EngineRequest,
|
|
27
|
-
EngineResult,
|
|
28
|
-
HostCallAnswer,
|
|
29
|
-
} from './engine/run-in-isolate';
|
|
30
|
-
export { ENGINE_GLOBAL_NAME } from './engine/engine-global';
|
|
31
|
-
export { collectGlobalReferences } from './steps/global-references';
|
|
32
|
-
export * from './cost/execution-cost';
|
|
1
|
+
// Package root: browser-compatible. No Node import (`fs`, `net`, `http`, `ws`...) here nor in what
|
|
2
|
+
// this root re-exports; everything touching the network or the system lives under `src/server`
|
|
3
|
+
// (entry point `@abyss-project/runtime/server`).
|
|
4
|
+
export * from './errors/runtime-error-code.enum';
|
|
5
|
+
export * from './access/access.types';
|
|
6
|
+
export { hostMatches } from './access/host-match';
|
|
7
|
+
export * from './definition/definition.types';
|
|
8
|
+
export { validateDefinition } from './definition/validate-definition';
|
|
9
|
+
export type { ValidationResult } from './definition/validate-definition';
|
|
10
|
+
export { MAX_WAIT_DURATION_MS } from './definition/definition.limits';
|
|
11
|
+
export { walkSteps } from './definition/walk-steps';
|
|
12
|
+
export type { StepVisitor } from './definition/walk-steps';
|
|
13
|
+
export * from './interpreter/interpreter.types';
|
|
14
|
+
export { start, step } from './interpreter/interpreter';
|
|
15
|
+
export { InterpreterError } from './interpreter/interpreter-error';
|
|
16
|
+
export { runToCompletion } from './interpreter/test-host';
|
|
17
|
+
export type { TestHostHandlers, TestRunResult } from './interpreter/test-host';
|
|
18
|
+
export * from './discord/discord.types';
|
|
19
|
+
export * from './schedule/schedule.types';
|
|
20
|
+
export * from './runner-protocol/evaluation.types';
|
|
21
|
+
export * from './runner-protocol/execution-protocol.types';
|
|
22
|
+
export { runInIsolate, EngineResultKind } from './engine/run-in-isolate';
|
|
23
|
+
export type {
|
|
24
|
+
EngineHost,
|
|
25
|
+
EngineProgress,
|
|
26
|
+
EngineRequest,
|
|
27
|
+
EngineResult,
|
|
28
|
+
HostCallAnswer,
|
|
29
|
+
} from './engine/run-in-isolate';
|
|
30
|
+
export { ENGINE_GLOBAL_NAME } from './engine/engine-global';
|
|
31
|
+
export { collectGlobalReferences } from './steps/global-references';
|
|
32
|
+
export * from './cost/execution-cost';
|