@teodorruskvi/chat-core 0.1.45 → 0.1.47
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/features/conversation/hooks/useChatSession.d.ts +1 -0
- package/dist/features/conversation/hooks/useThreadHistoryState.d.ts +1 -0
- package/dist/features/streaming/contexts/types.d.ts +1 -0
- package/dist/index.esm.js +1529 -1387
- package/dist/index.esm.js.map +1 -1
- package/dist/index.umd.js +7 -7
- package/dist/index.umd.js.map +1 -1
- package/dist/lib/contracts.d.ts +4 -0
- package/dist/types/contracts/index.d.ts +1 -0
- package/dist/types/contracts/openapi.generated.d.ts +4037 -0
- package/dist/types/domain/chat.d.ts +9 -2
- package/dist/types/domain/streaming.d.ts +58 -10
- package/package.json +4 -1
|
@@ -55,9 +55,16 @@ export interface ChatMessage extends TemporalMetadata {
|
|
|
55
55
|
checkpointNs?: string | null;
|
|
56
56
|
toolStreaming?: boolean;
|
|
57
57
|
artifact?: any;
|
|
58
|
+
scope?: string;
|
|
59
|
+
origin?: string;
|
|
58
60
|
additionalKwargs?: Record<string, any>;
|
|
59
61
|
responseMetadata?: Record<string, any>;
|
|
60
62
|
}
|
|
63
|
+
export interface ChatPayload extends Record<string, any> {
|
|
64
|
+
creativityLevel: "low" | "medium" | "high" | null;
|
|
65
|
+
activeAgent?: string;
|
|
66
|
+
modelName?: string;
|
|
67
|
+
}
|
|
61
68
|
/**
|
|
62
69
|
* Feature-specific request/command types
|
|
63
70
|
*/
|
|
@@ -67,10 +74,10 @@ export interface ChatRequest {
|
|
|
67
74
|
checkpointId?: string;
|
|
68
75
|
checkpointNs?: string;
|
|
69
76
|
attachments?: File[];
|
|
70
|
-
payload?:
|
|
77
|
+
payload?: ChatPayload;
|
|
71
78
|
config?: Record<string, any>;
|
|
72
79
|
command?: GraphCommand;
|
|
73
|
-
edit
|
|
80
|
+
edit: boolean;
|
|
74
81
|
}
|
|
75
82
|
export interface GraphCommand {
|
|
76
83
|
kind: "resume" | "goto";
|
|
@@ -61,6 +61,7 @@ export type ActiveRunContext = {
|
|
|
61
61
|
export type StreamEventMeta = {
|
|
62
62
|
origin?: "agent" | "task";
|
|
63
63
|
scope?: string;
|
|
64
|
+
seq?: number;
|
|
64
65
|
};
|
|
65
66
|
export type StreamFinishInfo = {
|
|
66
67
|
lastSeq: number;
|
|
@@ -72,22 +73,38 @@ export type ToolEventIdentity = {
|
|
|
72
73
|
id?: string;
|
|
73
74
|
callId?: string;
|
|
74
75
|
};
|
|
76
|
+
/**
|
|
77
|
+
* Emitted when a tool begins execution.
|
|
78
|
+
*/
|
|
75
79
|
export type ToolStartEvent = {
|
|
76
80
|
type: "tool.start";
|
|
81
|
+
/** Arguments passed to the tool */
|
|
77
82
|
args: Record<string, unknown>;
|
|
83
|
+
/** Unique name of the tool */
|
|
78
84
|
name?: string;
|
|
85
|
+
/** Legacy tool identifier */
|
|
79
86
|
tool?: string;
|
|
80
87
|
seq?: number;
|
|
88
|
+
scope?: string;
|
|
89
|
+
origin?: "agent" | "task";
|
|
81
90
|
additionalKwargs?: Record<string, unknown>;
|
|
82
91
|
} & ToolEventIdentity;
|
|
92
|
+
/**
|
|
93
|
+
* Emitted when a tool finishes execution, providing the result.
|
|
94
|
+
*/
|
|
83
95
|
export type ToolEndEvent = {
|
|
84
96
|
type: "tool.end";
|
|
97
|
+
/** The final output/response from the tool */
|
|
85
98
|
content: string;
|
|
99
|
+
/** Optional structured data returned by the tool */
|
|
86
100
|
artifact?: unknown;
|
|
101
|
+
/** Error message if execution failed */
|
|
87
102
|
error?: string;
|
|
88
103
|
name?: string;
|
|
89
104
|
tool?: string;
|
|
90
105
|
seq?: number;
|
|
106
|
+
scope?: string;
|
|
107
|
+
origin?: "agent" | "task";
|
|
91
108
|
additionalKwargs?: Record<string, unknown>;
|
|
92
109
|
status?: "completed" | "failed";
|
|
93
110
|
} & ToolEventIdentity;
|
|
@@ -119,15 +136,45 @@ export type TaskStartEvent = {
|
|
|
119
136
|
subagentType?: string;
|
|
120
137
|
seq?: number;
|
|
121
138
|
} & StreamEventMeta;
|
|
122
|
-
export type
|
|
139
|
+
export type MessageStartEvent = {
|
|
140
|
+
type: "message.start";
|
|
141
|
+
role: "assistant";
|
|
142
|
+
id: string;
|
|
143
|
+
model?: string;
|
|
144
|
+
seq?: number;
|
|
145
|
+
};
|
|
146
|
+
export type MessageDeltaEvent = {
|
|
147
|
+
type: "message.delta";
|
|
148
|
+
delta: any[];
|
|
149
|
+
seq?: number;
|
|
150
|
+
};
|
|
151
|
+
export type MessageEndEvent = {
|
|
152
|
+
type: "message.end";
|
|
153
|
+
seq?: number;
|
|
154
|
+
};
|
|
155
|
+
export type MessageStreamEvent = MessageStartEvent | MessageDeltaEvent | MessageEndEvent | ToolProgressEvent | {
|
|
156
|
+
type: "messages/metadata";
|
|
157
|
+
metadata: MessagesMetadataMap;
|
|
158
|
+
seq?: number;
|
|
159
|
+
} | {
|
|
123
160
|
type: "messages/partial";
|
|
124
|
-
messages:
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
161
|
+
messages: PartialMessageChunk[];
|
|
162
|
+
seq?: number;
|
|
163
|
+
};
|
|
164
|
+
export type PartialMessageChunk = {
|
|
165
|
+
id: string;
|
|
166
|
+
type: string;
|
|
167
|
+
role?: string;
|
|
168
|
+
content: string | unknown[];
|
|
169
|
+
responseMetadata?: Record<string, unknown>;
|
|
170
|
+
seq?: number;
|
|
171
|
+
scope?: string;
|
|
172
|
+
origin?: "agent" | "task";
|
|
130
173
|
};
|
|
174
|
+
export type MessagesMetadataEntry = {
|
|
175
|
+
metadata?: Record<string, unknown>;
|
|
176
|
+
};
|
|
177
|
+
export type MessagesMetadataMap = Record<string, MessagesMetadataEntry>;
|
|
131
178
|
export type ThreadStreamEvent = {
|
|
132
179
|
type: "thread_info";
|
|
133
180
|
threadId: string;
|
|
@@ -183,9 +230,6 @@ export type SystemStreamEvent = {
|
|
|
183
230
|
type: "updates";
|
|
184
231
|
tools?: Record<string, unknown>;
|
|
185
232
|
[key: string]: unknown;
|
|
186
|
-
} | {
|
|
187
|
-
type: "values";
|
|
188
|
-
[key: string]: unknown;
|
|
189
233
|
} | {
|
|
190
234
|
type: "token";
|
|
191
235
|
token: string;
|
|
@@ -201,6 +245,10 @@ export type HeartbeatEvent = Extract<SystemStreamEvent, {
|
|
|
201
245
|
export type ValuesEvent = Extract<SystemStreamEvent, {
|
|
202
246
|
type: "values";
|
|
203
247
|
}>;
|
|
248
|
+
/**
|
|
249
|
+
* The primary union of all possible streaming events.
|
|
250
|
+
* Use the 'type' field to discriminate between different event payloads.
|
|
251
|
+
*/
|
|
204
252
|
export type StreamEvent = (MessageStreamEvent | ToolStreamEvent | ThreadStreamEvent | SystemStreamEvent | TaskStartEvent) & StreamEventMeta;
|
|
205
253
|
export interface StreamEventHandlers {
|
|
206
254
|
onConnectionError?: (error: string) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@teodorruskvi/chat-core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.47",
|
|
4
4
|
"description": "Core chat protocols, hooks, and utilities (UI-agnostic)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.umd.js",
|
|
@@ -11,6 +11,9 @@
|
|
|
11
11
|
"import": "./dist/index.esm.js",
|
|
12
12
|
"require": "./dist/index.umd.js",
|
|
13
13
|
"types": "./dist/lib/core.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./contracts": {
|
|
16
|
+
"types": "./dist/lib/contracts.d.ts"
|
|
14
17
|
}
|
|
15
18
|
},
|
|
16
19
|
"files": [
|