@taico/events 0.1.0 → 0.2.6

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/dist/index.d.ts CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from './types/task-events.js';
2
2
  export * from './types/thread-events.js';
3
+ export * from './types/worker-events.js';
4
+ export * from './types/execution-events.js';
package/dist/index.js CHANGED
@@ -1,2 +1,4 @@
1
1
  export * from './types/task-events.js';
2
2
  export * from './types/thread-events.js';
3
+ export * from './types/worker-events.js';
4
+ export * from './types/execution-events.js';
@@ -0,0 +1,111 @@
1
+ /**
2
+ * Execution Wire Event Types for WebSocket Communication
3
+ *
4
+ * These types define the structure of events sent between backend and frontend
5
+ * via WebSocket for the Executions domain. They serve as a contract between the
6
+ * backend gateway and frontend consumers.
7
+ *
8
+ * Import these types in both backend (for emission) and frontend (for reception)
9
+ * to ensure type safety across the wire protocol.
10
+ */
11
+ import type { MinimalEventActor } from './task-events.js';
12
+ /**
13
+ * Wire event names for Executions domain
14
+ * These are the stable, external event identifiers sent over the wire protocol.
15
+ */
16
+ export declare const ExecutionWireEvents: {
17
+ readonly EXECUTION_CREATED: "execution.created";
18
+ readonly EXECUTION_UPDATED: "execution.updated";
19
+ readonly EXECUTION_DELETED: "execution.deleted";
20
+ readonly EXECUTION_ACTIVITY: "execution.activity";
21
+ readonly EXECUTION_ACTIVITY_POST: "execution.activity.post";
22
+ readonly EXECUTION_HEARTBEAT_POST: "execution.heartbeat.post";
23
+ };
24
+ export type ExecutionWireEventName = (typeof ExecutionWireEvents)[keyof typeof ExecutionWireEvents];
25
+ /**
26
+ * Execution structure as sent over the wire
27
+ * Matches ExecutionResponseDto from backend
28
+ */
29
+ export interface ExecutionWirePayload {
30
+ id: string;
31
+ taskId: string;
32
+ taskName: string | null;
33
+ agentActorId: string;
34
+ agentSlug: string | null;
35
+ agentName: string | null;
36
+ status: 'READY' | 'CLAIMED' | 'RUNNING' | 'COMPLETED' | 'FAILED' | 'CANCELLED' | 'EXPIRED';
37
+ requestedAt: string;
38
+ claimedAt: string | null;
39
+ startedAt: string | null;
40
+ finishedAt: string | null;
41
+ workerSessionId: string | null;
42
+ leaseExpiresAt: string | null;
43
+ stopRequestedAt: string | null;
44
+ failureReason: string | null;
45
+ triggerReason: string | null;
46
+ rowVersion: number;
47
+ createdAt: string;
48
+ updatedAt: string;
49
+ }
50
+ /**
51
+ * Execution created event
52
+ * Emitted when a new execution is created
53
+ */
54
+ export interface ExecutionCreatedWireEvent {
55
+ payload: ExecutionWirePayload;
56
+ actor: MinimalEventActor;
57
+ }
58
+ /**
59
+ * Execution updated event
60
+ * Emitted when an execution is updated
61
+ */
62
+ export interface ExecutionUpdatedWireEvent {
63
+ payload: ExecutionWirePayload;
64
+ actor: MinimalEventActor;
65
+ }
66
+ /**
67
+ * Execution deleted event
68
+ * Emitted when an execution is deleted
69
+ */
70
+ export interface ExecutionDeletedWireEvent {
71
+ payload: {
72
+ executionId: string;
73
+ };
74
+ actor: MinimalEventActor;
75
+ }
76
+ export interface ExecutionActivityPayload {
77
+ executionId: string;
78
+ taskId: string;
79
+ agentActorId: string;
80
+ kind: string;
81
+ message?: string;
82
+ ts: number;
83
+ runnerSessionId?: string | null;
84
+ }
85
+ export interface PostExecutionActivityPayload {
86
+ executionId: string;
87
+ kind?: string;
88
+ message?: string;
89
+ ts?: number;
90
+ runnerSessionId?: string | null;
91
+ }
92
+ export interface PostExecutionHeartbeatPayload {
93
+ executionId: string;
94
+ }
95
+ /**
96
+ * Execution activity event
97
+ * Emitted for real-time activity updates from workers/runners
98
+ */
99
+ export interface ExecutionActivityWireEvent {
100
+ payload: ExecutionActivityPayload;
101
+ actor: MinimalEventActor;
102
+ }
103
+ /**
104
+ * Union type of all execution wire events
105
+ */
106
+ export type ExecutionWireEvent = ExecutionCreatedWireEvent | ExecutionUpdatedWireEvent | ExecutionDeletedWireEvent | ExecutionActivityWireEvent;
107
+ /**
108
+ * Type guards for event identification
109
+ */
110
+ export declare function isExecutionCreatedEvent(event: ExecutionWireEvent): event is ExecutionCreatedWireEvent;
111
+ export declare function isExecutionDeletedEvent(event: ExecutionWireEvent): event is ExecutionDeletedWireEvent;
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Execution Wire Event Types for WebSocket Communication
3
+ *
4
+ * These types define the structure of events sent between backend and frontend
5
+ * via WebSocket for the Executions domain. They serve as a contract between the
6
+ * backend gateway and frontend consumers.
7
+ *
8
+ * Import these types in both backend (for emission) and frontend (for reception)
9
+ * to ensure type safety across the wire protocol.
10
+ */
11
+ /**
12
+ * Wire event names for Executions domain
13
+ * These are the stable, external event identifiers sent over the wire protocol.
14
+ */
15
+ export const ExecutionWireEvents = {
16
+ EXECUTION_CREATED: 'execution.created',
17
+ EXECUTION_UPDATED: 'execution.updated',
18
+ EXECUTION_DELETED: 'execution.deleted',
19
+ EXECUTION_ACTIVITY: 'execution.activity',
20
+ EXECUTION_ACTIVITY_POST: 'execution.activity.post',
21
+ EXECUTION_HEARTBEAT_POST: 'execution.heartbeat.post',
22
+ };
23
+ /**
24
+ * Type guards for event identification
25
+ */
26
+ export function isExecutionCreatedEvent(event) {
27
+ return 'payload' in event && 'id' in event.payload && 'taskId' in event.payload;
28
+ }
29
+ export function isExecutionDeletedEvent(event) {
30
+ return 'payload' in event && 'executionId' in event.payload;
31
+ }
@@ -0,0 +1,112 @@
1
+ /**
2
+ * Worker Wire Event Types for WebSocket Communication
3
+ *
4
+ * These types define the structure of events sent between backend and workers
5
+ * via WebSocket for the Workers domain. They serve as a contract between the
6
+ * backend gateway and worker clients.
7
+ *
8
+ * Import these types in both backend (for emission/reception) and worker (for emission/reception)
9
+ * to ensure type safety across the wire protocol.
10
+ */
11
+ /**
12
+ * Wire event names for Workers domain
13
+ * These are the stable, external event identifiers sent over the wire protocol.
14
+ */
15
+ export declare const WorkerWireEvents: {
16
+ readonly WORKER_HELLO: "worker.hello";
17
+ readonly WORKER_HEARTBEAT: "worker.heartbeat";
18
+ readonly RUN_STARTED: "run.started";
19
+ readonly RUN_COMPLETED: "run.completed";
20
+ readonly RUN_FAILED: "run.failed";
21
+ readonly RUN_ASSIGNED: "run.assigned";
22
+ readonly STOP_REQUESTED: "stop.requested";
23
+ };
24
+ export type WorkerWireEventName = (typeof WorkerWireEvents)[keyof typeof WorkerWireEvents];
25
+ /**
26
+ * Worker hello message payload
27
+ * Sent by worker on connection to register itself with metadata
28
+ */
29
+ export interface WorkerHelloPayload {
30
+ hostname?: string;
31
+ pid?: number;
32
+ version?: string;
33
+ capabilities?: string[];
34
+ }
35
+ /**
36
+ * Worker heartbeat message payload
37
+ * Sent periodically by worker to indicate it's still alive
38
+ */
39
+ export interface WorkerHeartbeatPayload {
40
+ sessionId: string;
41
+ timestamp: number;
42
+ }
43
+ /**
44
+ * Run started message payload
45
+ * Sent by worker when it begins executing a task
46
+ */
47
+ export interface RunStartedPayload {
48
+ executionId: string;
49
+ sessionId: string;
50
+ startedAt: string;
51
+ }
52
+ /**
53
+ * Run completed message payload
54
+ * Sent by worker when task execution finishes successfully
55
+ */
56
+ export interface RunCompletedPayload {
57
+ executionId: string;
58
+ sessionId: string;
59
+ completedAt: string;
60
+ }
61
+ /**
62
+ * Run failed message payload
63
+ * Sent by worker when task execution fails
64
+ */
65
+ export interface RunFailedPayload {
66
+ executionId: string;
67
+ sessionId: string;
68
+ failedAt: string;
69
+ reason?: string;
70
+ }
71
+ /**
72
+ * Run assigned wire event
73
+ * Sent by backend to worker when a task execution is assigned
74
+ */
75
+ export interface RunAssignedWireEvent {
76
+ executionId: string;
77
+ taskId: string;
78
+ agentActorId: string;
79
+ triggerReason?: string;
80
+ }
81
+ /**
82
+ * Stop requested wire event
83
+ * Sent by backend to worker to request stopping a running execution
84
+ */
85
+ export interface StopRequestedWireEvent {
86
+ executionId: string;
87
+ taskId: string;
88
+ reason?: string;
89
+ }
90
+ /**
91
+ * Worker hello wire event
92
+ * Response sent by backend after successful registration
93
+ */
94
+ export interface WorkerHelloResponse {
95
+ sessionId: string;
96
+ serverTime: number;
97
+ }
98
+ /**
99
+ * Worker heartbeat wire event
100
+ * Response sent by backend after processing heartbeat
101
+ */
102
+ export interface WorkerHeartbeatResponse {
103
+ ok: boolean;
104
+ serverTime: number;
105
+ }
106
+ /**
107
+ * Generic acknowledgment for run lifecycle events
108
+ */
109
+ export interface RunLifecycleAck {
110
+ ok: boolean;
111
+ executionId: string;
112
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Worker Wire Event Types for WebSocket Communication
3
+ *
4
+ * These types define the structure of events sent between backend and workers
5
+ * via WebSocket for the Workers domain. They serve as a contract between the
6
+ * backend gateway and worker clients.
7
+ *
8
+ * Import these types in both backend (for emission/reception) and worker (for emission/reception)
9
+ * to ensure type safety across the wire protocol.
10
+ */
11
+ /**
12
+ * Wire event names for Workers domain
13
+ * These are the stable, external event identifiers sent over the wire protocol.
14
+ */
15
+ export const WorkerWireEvents = {
16
+ // Worker -> Backend
17
+ WORKER_HELLO: 'worker.hello',
18
+ WORKER_HEARTBEAT: 'worker.heartbeat',
19
+ RUN_STARTED: 'run.started',
20
+ RUN_COMPLETED: 'run.completed',
21
+ RUN_FAILED: 'run.failed',
22
+ // Backend -> Worker
23
+ RUN_ASSIGNED: 'run.assigned',
24
+ STOP_REQUESTED: 'stop.requested',
25
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@taico/events",
3
- "version": "0.1.0",
3
+ "version": "0.2.6",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "license": "MIT",