@taico/events 0.0.3 → 0.2.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/dist/index.d.ts +2 -0
- package/dist/index.js +2 -0
- package/dist/types/execution-events.d.ts +111 -0
- package/dist/types/execution-events.js +31 -0
- package/dist/types/thread-events.d.ts +24 -7
- package/dist/types/thread-events.js +1 -0
- package/dist/types/worker-events.d.ts +112 -0
- package/dist/types/worker-events.js +25 -0
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -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
|
+
}
|
|
@@ -20,6 +20,7 @@ export declare const ThreadWireEvents: {
|
|
|
20
20
|
readonly THREAD_TITLE_UPDATED: "thread.title.updated";
|
|
21
21
|
readonly MESSAGE_CREATED: "thread.message.created";
|
|
22
22
|
readonly AGENT_ACTIVITY: "thread.agent.activity";
|
|
23
|
+
readonly AGENT_RESPONSE_DELTA: "thread.agent.response.delta";
|
|
23
24
|
};
|
|
24
25
|
export type ThreadWireEventName = (typeof ThreadWireEvents)[keyof typeof ThreadWireEvents];
|
|
25
26
|
/**
|
|
@@ -28,7 +29,14 @@ export type ThreadWireEventName = (typeof ThreadWireEvents)[keyof typeof ThreadW
|
|
|
28
29
|
export interface TaskSummaryWirePayload {
|
|
29
30
|
id: string;
|
|
30
31
|
name: string;
|
|
32
|
+
description: string;
|
|
31
33
|
status: 'NOT_STARTED' | 'IN_PROGRESS' | 'FOR_REVIEW' | 'DONE';
|
|
34
|
+
assigneeActor: Actor | null;
|
|
35
|
+
createdByActor: Actor;
|
|
36
|
+
tags: TagWirePayload[];
|
|
37
|
+
commentCount: number;
|
|
38
|
+
inputRequests: unknown[];
|
|
39
|
+
updatedAt: string;
|
|
32
40
|
}
|
|
33
41
|
/**
|
|
34
42
|
* Context block summary structure as sent over the wire
|
|
@@ -56,16 +64,13 @@ export interface Actor {
|
|
|
56
64
|
export interface ThreadWirePayload {
|
|
57
65
|
id: string;
|
|
58
66
|
title: string;
|
|
59
|
-
|
|
67
|
+
chatSessionId: string | null;
|
|
60
68
|
createdByActor: Actor;
|
|
61
69
|
parentTaskId: string | null;
|
|
62
|
-
|
|
63
|
-
stateBlockId: string;
|
|
64
|
-
stateBlock: ContextBlockSummaryWirePayload;
|
|
70
|
+
stateContextBlockId: string;
|
|
65
71
|
tags: TagWirePayload[];
|
|
66
72
|
tasks: TaskSummaryWirePayload[];
|
|
67
|
-
|
|
68
|
-
participantActorIds: string[];
|
|
73
|
+
referencedContextBlocks: ContextBlockSummaryWirePayload[];
|
|
69
74
|
participants: Actor[];
|
|
70
75
|
rowVersion: number;
|
|
71
76
|
createdAt: string;
|
|
@@ -141,7 +146,19 @@ export interface AgentActivityWireEvent {
|
|
|
141
146
|
};
|
|
142
147
|
actor: MinimalEventActor;
|
|
143
148
|
}
|
|
149
|
+
/**
|
|
150
|
+
* Agent response delta event
|
|
151
|
+
* Emitted when assistant streaming text chunks are received.
|
|
152
|
+
*/
|
|
153
|
+
export interface AgentResponseDeltaWireEvent {
|
|
154
|
+
payload: {
|
|
155
|
+
threadId: string;
|
|
156
|
+
streamId: string;
|
|
157
|
+
delta: string;
|
|
158
|
+
};
|
|
159
|
+
actor: MinimalEventActor;
|
|
160
|
+
}
|
|
144
161
|
/**
|
|
145
162
|
* Union type of all thread wire events
|
|
146
163
|
*/
|
|
147
|
-
export type ThreadWireEvent = ThreadCreatedWireEvent | ThreadUpdatedWireEvent | ThreadDeletedWireEvent | ThreadTitleUpdatedWireEvent | MessageCreatedWireEvent | AgentActivityWireEvent;
|
|
164
|
+
export type ThreadWireEvent = ThreadCreatedWireEvent | ThreadUpdatedWireEvent | ThreadDeletedWireEvent | ThreadTitleUpdatedWireEvent | MessageCreatedWireEvent | AgentActivityWireEvent | AgentResponseDeltaWireEvent;
|
|
@@ -19,6 +19,7 @@ export const ThreadWireEvents = {
|
|
|
19
19
|
THREAD_TITLE_UPDATED: 'thread.title.updated',
|
|
20
20
|
MESSAGE_CREATED: 'thread.message.created',
|
|
21
21
|
AGENT_ACTIVITY: 'thread.agent.activity',
|
|
22
|
+
AGENT_RESPONSE_DELTA: 'thread.agent.response.delta',
|
|
22
23
|
};
|
|
23
24
|
export var ActorType;
|
|
24
25
|
(function (ActorType) {
|
|
@@ -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
|
+
};
|