@openscout/protocol 0.2.40 → 0.2.42

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
@@ -13,3 +13,4 @@ export * from "./scout-dispatch.js";
13
13
  export * from "./deliveries.js";
14
14
  export * from "./transports.js";
15
15
  export * from "./events.js";
16
+ export * from "./thread-events.js";
package/dist/index.js CHANGED
@@ -13,3 +13,4 @@ export * from "./scout-dispatch.js";
13
13
  export * from "./deliveries.js";
14
14
  export * from "./transports.js";
15
15
  export * from "./events.js";
16
+ export * from "./thread-events.js";
@@ -0,0 +1,144 @@
1
+ import type { CollaborationEvent, CollaborationRecord } from "./collaboration.js";
2
+ import type { MetadataMap, ScoutId } from "./common.js";
3
+ import type { ConversationDefinition } from "./conversations.js";
4
+ import type { FlightRecord } from "./invocations.js";
5
+ import type { MessageClass, MessageRecord } from "./messages.js";
6
+ export type ThreadEventKind = "message.posted" | "flight.updated" | "collaboration.upserted" | "collaboration.event.appended" | "attention.requested" | "watch.reset_required";
7
+ export type ThreadWatchMode = "summary" | "shared";
8
+ export type ThreadNotificationTier = "interrupt" | "badge" | "silent";
9
+ export type ThreadNotificationReason = "mention" | "thread_reply" | "next_move" | "flight_completed" | "flight_failed";
10
+ export interface ThreadEventNotification {
11
+ tier: ThreadNotificationTier;
12
+ targetActorIds?: ScoutId[];
13
+ reason?: ThreadNotificationReason;
14
+ summary: string;
15
+ }
16
+ export interface ThreadMessageSummary {
17
+ id: ScoutId;
18
+ actorId: ScoutId;
19
+ class: MessageClass;
20
+ replyToMessageId?: ScoutId;
21
+ threadConversationId?: ScoutId;
22
+ mentionActorIds: ScoutId[];
23
+ createdAt: number;
24
+ summary: string;
25
+ }
26
+ export interface ThreadFlightSummary {
27
+ id: ScoutId;
28
+ invocationId: ScoutId;
29
+ requesterId: ScoutId;
30
+ targetAgentId: ScoutId;
31
+ state: FlightRecord["state"];
32
+ summary?: string;
33
+ error?: string;
34
+ startedAt?: number;
35
+ completedAt?: number;
36
+ }
37
+ export interface ThreadCollaborationSummary {
38
+ id: ScoutId;
39
+ kind: CollaborationRecord["kind"];
40
+ state: string;
41
+ acceptanceState: CollaborationRecord["acceptanceState"];
42
+ title: string;
43
+ summary?: string;
44
+ ownerId?: ScoutId;
45
+ nextMoveOwnerId?: ScoutId;
46
+ updatedAt: number;
47
+ }
48
+ export interface ThreadCollaborationEventSummary {
49
+ id: ScoutId;
50
+ recordId: ScoutId;
51
+ recordKind: CollaborationEvent["recordKind"];
52
+ kind: CollaborationEvent["kind"];
53
+ actorId: ScoutId;
54
+ at: number;
55
+ summary?: string;
56
+ }
57
+ export type ThreadMessagePayload = {
58
+ message: MessageRecord | ThreadMessageSummary;
59
+ };
60
+ export type ThreadFlightPayload = {
61
+ flight: FlightRecord | ThreadFlightSummary;
62
+ };
63
+ export type ThreadCollaborationPayload = {
64
+ record: CollaborationRecord | ThreadCollaborationSummary;
65
+ };
66
+ export type ThreadCollaborationEventPayload = {
67
+ event: CollaborationEvent | ThreadCollaborationEventSummary;
68
+ };
69
+ export type ThreadAttentionPayload = {
70
+ summary: string;
71
+ metadata?: MetadataMap;
72
+ };
73
+ export type ThreadResetRequiredPayload = {
74
+ reason: "cursor_out_of_range" | "lease_expired";
75
+ latestSeq: number;
76
+ };
77
+ export type ThreadEventPayload = ThreadMessagePayload | ThreadFlightPayload | ThreadCollaborationPayload | ThreadCollaborationEventPayload | ThreadAttentionPayload | ThreadResetRequiredPayload;
78
+ export interface ThreadEventEnvelope {
79
+ id: ScoutId;
80
+ conversationId: ScoutId;
81
+ authorityNodeId: ScoutId;
82
+ seq: number;
83
+ kind: ThreadEventKind;
84
+ actorId?: ScoutId;
85
+ ts: number;
86
+ payload: ThreadEventPayload;
87
+ notification?: ThreadEventNotification;
88
+ }
89
+ export interface ThreadWatchOpenRequest {
90
+ conversationId: ScoutId;
91
+ watcherNodeId: ScoutId;
92
+ watcherId: ScoutId;
93
+ afterSeq?: number;
94
+ leaseMs?: number;
95
+ }
96
+ export interface ThreadWatchOpenResponse {
97
+ watchId: ScoutId;
98
+ conversationId: ScoutId;
99
+ authorityNodeId: ScoutId;
100
+ acceptedAfterSeq: number;
101
+ latestSeq: number;
102
+ leaseExpiresAt: number;
103
+ mode: ThreadWatchMode;
104
+ }
105
+ export interface ThreadWatchRenewRequest {
106
+ watchId: ScoutId;
107
+ leaseMs?: number;
108
+ }
109
+ export interface ThreadWatchRenewResponse {
110
+ watchId: ScoutId;
111
+ leaseExpiresAt: number;
112
+ }
113
+ export interface ThreadWatchCloseRequest {
114
+ watchId: ScoutId;
115
+ reason?: string;
116
+ }
117
+ export interface ThreadEventsReplayRequest {
118
+ conversationId: ScoutId;
119
+ afterSeq: number;
120
+ limit?: number;
121
+ }
122
+ export interface ThreadSnapshotRequest {
123
+ conversationId: ScoutId;
124
+ }
125
+ export type ThreadSnapshotMessage = MessageRecord | ThreadMessageSummary;
126
+ export type ThreadSnapshotCollaboration = CollaborationRecord | ThreadCollaborationSummary;
127
+ export type ThreadSnapshotFlight = FlightRecord | ThreadFlightSummary;
128
+ export interface ThreadSnapshot {
129
+ conversation: ConversationDefinition;
130
+ latestSeq: number;
131
+ messages?: ThreadSnapshotMessage[];
132
+ collaboration?: ThreadSnapshotCollaboration[];
133
+ activeFlights?: ThreadSnapshotFlight[];
134
+ }
135
+ export interface LocalThreadCursor {
136
+ conversationId: ScoutId;
137
+ authorityNodeId: ScoutId;
138
+ lastAppliedSeq: number;
139
+ updatedAt: number;
140
+ }
141
+ export interface ThreadWatchError {
142
+ code: "no_responder" | "forbidden" | "unknown_conversation" | "lease_expired" | "cursor_out_of_range" | "invalid_request" | "internal";
143
+ message: string;
144
+ }
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openscout/protocol",
3
- "version": "0.2.40",
3
+ "version": "0.2.42",
4
4
  "description": "Typed protocol for the OpenScout local control plane",
5
5
  "type": "module",
6
6
  "exports": {
package/src/index.ts CHANGED
@@ -13,3 +13,4 @@ export * from "./scout-dispatch.js";
13
13
  export * from "./deliveries.js";
14
14
  export * from "./transports.js";
15
15
  export * from "./events.js";
16
+ export * from "./thread-events.js";
@@ -0,0 +1,196 @@
1
+ import type { CollaborationEvent, CollaborationRecord } from "./collaboration.js";
2
+ import type { MetadataMap, ScoutId } from "./common.js";
3
+ import type { ConversationDefinition } from "./conversations.js";
4
+ import type { FlightRecord } from "./invocations.js";
5
+ import type { MessageClass, MessageRecord } from "./messages.js";
6
+
7
+ export type ThreadEventKind =
8
+ | "message.posted"
9
+ | "flight.updated"
10
+ | "collaboration.upserted"
11
+ | "collaboration.event.appended"
12
+ | "attention.requested"
13
+ | "watch.reset_required";
14
+
15
+ export type ThreadWatchMode = "summary" | "shared";
16
+
17
+ export type ThreadNotificationTier = "interrupt" | "badge" | "silent";
18
+
19
+ export type ThreadNotificationReason =
20
+ | "mention"
21
+ | "thread_reply"
22
+ | "next_move"
23
+ | "flight_completed"
24
+ | "flight_failed";
25
+
26
+ export interface ThreadEventNotification {
27
+ tier: ThreadNotificationTier;
28
+ targetActorIds?: ScoutId[];
29
+ reason?: ThreadNotificationReason;
30
+ summary: string;
31
+ }
32
+
33
+ export interface ThreadMessageSummary {
34
+ id: ScoutId;
35
+ actorId: ScoutId;
36
+ class: MessageClass;
37
+ replyToMessageId?: ScoutId;
38
+ threadConversationId?: ScoutId;
39
+ mentionActorIds: ScoutId[];
40
+ createdAt: number;
41
+ summary: string;
42
+ }
43
+
44
+ export interface ThreadFlightSummary {
45
+ id: ScoutId;
46
+ invocationId: ScoutId;
47
+ requesterId: ScoutId;
48
+ targetAgentId: ScoutId;
49
+ state: FlightRecord["state"];
50
+ summary?: string;
51
+ error?: string;
52
+ startedAt?: number;
53
+ completedAt?: number;
54
+ }
55
+
56
+ export interface ThreadCollaborationSummary {
57
+ id: ScoutId;
58
+ kind: CollaborationRecord["kind"];
59
+ state: string;
60
+ acceptanceState: CollaborationRecord["acceptanceState"];
61
+ title: string;
62
+ summary?: string;
63
+ ownerId?: ScoutId;
64
+ nextMoveOwnerId?: ScoutId;
65
+ updatedAt: number;
66
+ }
67
+
68
+ export interface ThreadCollaborationEventSummary {
69
+ id: ScoutId;
70
+ recordId: ScoutId;
71
+ recordKind: CollaborationEvent["recordKind"];
72
+ kind: CollaborationEvent["kind"];
73
+ actorId: ScoutId;
74
+ at: number;
75
+ summary?: string;
76
+ }
77
+
78
+ export type ThreadMessagePayload = {
79
+ message: MessageRecord | ThreadMessageSummary;
80
+ };
81
+
82
+ export type ThreadFlightPayload = {
83
+ flight: FlightRecord | ThreadFlightSummary;
84
+ };
85
+
86
+ export type ThreadCollaborationPayload = {
87
+ record: CollaborationRecord | ThreadCollaborationSummary;
88
+ };
89
+
90
+ export type ThreadCollaborationEventPayload = {
91
+ event: CollaborationEvent | ThreadCollaborationEventSummary;
92
+ };
93
+
94
+ export type ThreadAttentionPayload = {
95
+ summary: string;
96
+ metadata?: MetadataMap;
97
+ };
98
+
99
+ export type ThreadResetRequiredPayload = {
100
+ reason: "cursor_out_of_range" | "lease_expired";
101
+ latestSeq: number;
102
+ };
103
+
104
+ export type ThreadEventPayload =
105
+ | ThreadMessagePayload
106
+ | ThreadFlightPayload
107
+ | ThreadCollaborationPayload
108
+ | ThreadCollaborationEventPayload
109
+ | ThreadAttentionPayload
110
+ | ThreadResetRequiredPayload;
111
+
112
+ export interface ThreadEventEnvelope {
113
+ id: ScoutId;
114
+ conversationId: ScoutId;
115
+ authorityNodeId: ScoutId;
116
+ seq: number;
117
+ kind: ThreadEventKind;
118
+ actorId?: ScoutId;
119
+ ts: number;
120
+ payload: ThreadEventPayload;
121
+ notification?: ThreadEventNotification;
122
+ }
123
+
124
+ export interface ThreadWatchOpenRequest {
125
+ conversationId: ScoutId;
126
+ watcherNodeId: ScoutId;
127
+ watcherId: ScoutId;
128
+ afterSeq?: number;
129
+ leaseMs?: number;
130
+ }
131
+
132
+ export interface ThreadWatchOpenResponse {
133
+ watchId: ScoutId;
134
+ conversationId: ScoutId;
135
+ authorityNodeId: ScoutId;
136
+ acceptedAfterSeq: number;
137
+ latestSeq: number;
138
+ leaseExpiresAt: number;
139
+ mode: ThreadWatchMode;
140
+ }
141
+
142
+ export interface ThreadWatchRenewRequest {
143
+ watchId: ScoutId;
144
+ leaseMs?: number;
145
+ }
146
+
147
+ export interface ThreadWatchRenewResponse {
148
+ watchId: ScoutId;
149
+ leaseExpiresAt: number;
150
+ }
151
+
152
+ export interface ThreadWatchCloseRequest {
153
+ watchId: ScoutId;
154
+ reason?: string;
155
+ }
156
+
157
+ export interface ThreadEventsReplayRequest {
158
+ conversationId: ScoutId;
159
+ afterSeq: number;
160
+ limit?: number;
161
+ }
162
+
163
+ export interface ThreadSnapshotRequest {
164
+ conversationId: ScoutId;
165
+ }
166
+
167
+ export type ThreadSnapshotMessage = MessageRecord | ThreadMessageSummary;
168
+ export type ThreadSnapshotCollaboration = CollaborationRecord | ThreadCollaborationSummary;
169
+ export type ThreadSnapshotFlight = FlightRecord | ThreadFlightSummary;
170
+
171
+ export interface ThreadSnapshot {
172
+ conversation: ConversationDefinition;
173
+ latestSeq: number;
174
+ messages?: ThreadSnapshotMessage[];
175
+ collaboration?: ThreadSnapshotCollaboration[];
176
+ activeFlights?: ThreadSnapshotFlight[];
177
+ }
178
+
179
+ export interface LocalThreadCursor {
180
+ conversationId: ScoutId;
181
+ authorityNodeId: ScoutId;
182
+ lastAppliedSeq: number;
183
+ updatedAt: number;
184
+ }
185
+
186
+ export interface ThreadWatchError {
187
+ code:
188
+ | "no_responder"
189
+ | "forbidden"
190
+ | "unknown_conversation"
191
+ | "lease_expired"
192
+ | "cursor_out_of_range"
193
+ | "invalid_request"
194
+ | "internal";
195
+ message: string;
196
+ }