@abyss-project/runtime 3.12.0 → 3.13.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 (69) hide show
  1. package/.eslintrc.js +32 -32
  2. package/.prettierrc +5 -5
  3. package/README.md +88 -88
  4. package/dist/definition/definition.schema.js +6 -0
  5. package/dist/definition/definition.schema.js.map +1 -1
  6. package/dist/definition/definition.types.d.ts +11 -0
  7. package/dist/definition/definition.types.js +6 -1
  8. package/dist/definition/definition.types.js.map +1 -1
  9. package/dist/discord/discord.types.d.ts +2 -34
  10. package/dist/discord/discord.types.js +1 -9
  11. package/dist/discord/discord.types.js.map +1 -1
  12. package/dist/engine/engine-source.js +1 -1
  13. package/dist/errors/runtime-error-code.enum.d.ts +1 -0
  14. package/dist/errors/runtime-error-code.enum.js +1 -0
  15. package/dist/errors/runtime-error-code.enum.js.map +1 -1
  16. package/dist/runner-protocol/evaluation.types.d.ts +1 -0
  17. package/dist/steps/global-references.js +7 -0
  18. package/dist/steps/global-references.js.map +1 -1
  19. package/dist/steps/step-fields.js +10 -0
  20. package/dist/steps/step-fields.js.map +1 -1
  21. package/jest.config.ts +11 -11
  22. package/package.json +1 -1
  23. package/scripts/build-engine.cjs +70 -70
  24. package/src/__tests__/engine-bundle.test.ts +121 -121
  25. package/src/__tests__/surface.test.ts +81 -88
  26. package/src/access/__tests__/host-match.test.ts +24 -24
  27. package/src/access/access.types.ts +25 -25
  28. package/src/access/host-match.ts +13 -13
  29. package/src/cost/__tests__/execution-cost.test.ts +249 -249
  30. package/src/cost/execution-cost.ts +203 -203
  31. package/src/definition/__tests__/code-step.test.ts +56 -0
  32. package/src/definition/__tests__/validate-definition.test.ts +354 -354
  33. package/src/definition/definition.limits.ts +9 -9
  34. package/src/definition/definition.schema.ts +7 -0
  35. package/src/definition/definition.types.ts +21 -1
  36. package/src/definition/validate-definition.ts +206 -206
  37. package/src/definition/walk-steps.ts +44 -44
  38. package/src/discord/__tests__/discord-event-input.test.ts +90 -108
  39. package/src/discord/discord.types.ts +696 -738
  40. package/src/engine/__tests__/run-in-isolate.test.ts +519 -519
  41. package/src/engine/engine-entry.ts +3 -3
  42. package/src/engine/engine-global.ts +2 -2
  43. package/src/engine/run-in-isolate.ts +462 -462
  44. package/src/errors/runtime-error-code.enum.ts +5 -0
  45. package/src/index.ts +32 -32
  46. package/src/interpreter/__tests__/interpreter.test.ts +854 -854
  47. package/src/interpreter/__tests__/log-respond-resume.test.ts +271 -271
  48. package/src/interpreter/interpreter-error.ts +12 -12
  49. package/src/interpreter/interpreter.ts +483 -483
  50. package/src/interpreter/interpreter.types.ts +204 -204
  51. package/src/interpreter/sequence-path.ts +67 -67
  52. package/src/interpreter/test-host.ts +85 -85
  53. package/src/runner-protocol/__tests__/file-payload.test.ts +26 -26
  54. package/src/runner-protocol/evaluation.types.ts +2 -0
  55. package/src/runner-protocol/execution-protocol.types.ts +297 -297
  56. package/src/schedule/schedule.types.ts +100 -100
  57. package/src/server/__tests__/code-runner-session.test.ts +311 -311
  58. package/src/server/code-runner-error.ts +12 -12
  59. package/src/server/code-runner-session.ts +310 -310
  60. package/src/server/index.ts +11 -11
  61. package/src/steps/__tests__/global-references.test.ts +140 -124
  62. package/src/steps/__tests__/step-fields.test.ts +58 -0
  63. package/src/steps/execute-step.ts +186 -186
  64. package/src/steps/global-references.ts +56 -48
  65. package/src/steps/step-access.ts +56 -56
  66. package/src/steps/step-fields.ts +10 -0
  67. package/src/steps/value-source.ts +69 -69
  68. package/tsconfig.check.json +15 -15
  69. package/tsconfig.json +35 -35
@@ -1,108 +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
- 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
- [DiscordEventType.MESSAGE_POLL_VOTE_ADD]: {
34
- userId: 'u1',
35
- channelId: 'c1',
36
- messageId: 'm1',
37
- answerId: 2,
38
- },
39
- [DiscordEventType.MESSAGE_POLL_VOTE_REMOVE]: {
40
- userId: 'u1',
41
- channelId: 'c1',
42
- messageId: 'm1',
43
- answerId: 2,
44
- },
45
- };
46
-
47
- const inputOf = (type: DiscordEventType): DiscordEventInput => ({
48
- kind: 'DISCORD_EVENT',
49
- event: { id: 'e1', type, trigger: { id: 't1', name: 'welcome' } },
50
- guildId: 'g1',
51
- receivedAt: '2026-11-21T10:00:00.000Z',
52
- firedAt: '2026-11-21T10:00:01.000Z',
53
- attempt: 1,
54
- data: DATA_BY_TYPE[type],
55
- });
56
-
57
- describe('isDiscordEventInput', () => {
58
- it.each(Object.values(DiscordEventType))('is true for a %s input', (type) => {
59
- expect(isDiscordEventInput(inputOf(type))).toBe(true);
60
- });
61
-
62
- it('is true for a replay, which names the live run it replays', () => {
63
- expect(
64
- isDiscordEventInput({ ...inputOf(DiscordEventType.MESSAGE_POLL_VOTE_ADD), replayOf: 'r1' }),
65
- ).toBe(true);
66
- });
67
-
68
- it('is false for an interaction input', () => {
69
- expect(
70
- isDiscordEventInput({
71
- kind: 'COMMAND',
72
- command: { name: 'ping', options: {} },
73
- user: { id: 'u1', username: 'ann', globalName: null },
74
- locale: 'en-US',
75
- interaction: { id: 'i1', applicationId: 'a1', type: 2, data: null },
76
- }),
77
- ).toBe(false);
78
- });
79
-
80
- it('is false for a scheduled run input', () => {
81
- expect(
82
- isDiscordEventInput({
83
- kind: ScheduledRunKind.SCHEDULE,
84
- task: { id: 't1', name: 'daily' },
85
- scheduledFor: '2026-11-21T10:00:00.000Z',
86
- firedAt: '2026-11-21T10:00:01.000Z',
87
- attempt: 1,
88
- }),
89
- ).toBe(false);
90
- });
91
-
92
- it('is false for an unknown event type, a missing envelope field and non-objects', () => {
93
- expect(
94
- isDiscordEventInput({
95
- ...inputOf(DiscordEventType.MESSAGE_CREATE),
96
- event: { id: 'e1', type: 'X', trigger: { id: 't', name: 'n' } },
97
- }),
98
- ).toBe(false);
99
- expect(
100
- isDiscordEventInput({ ...inputOf(DiscordEventType.MESSAGE_CREATE), guildId: undefined }),
101
- ).toBe(false);
102
- expect(isDiscordEventInput({ ...inputOf(DiscordEventType.MESSAGE_CREATE), data: null })).toBe(
103
- false,
104
- );
105
- expect(isDiscordEventInput(null)).toBe(false);
106
- expect(isDiscordEventInput('DISCORD_EVENT')).toBe(false);
107
- });
108
- });
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
+ });