@inferencesh/sdk 0.6.27 → 0.6.29
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/agent/actions.js +8 -1
- package/dist/agent/reducer.js +6 -1
- package/dist/agent/types.d.ts +4 -1
- package/dist/api/agents.js +7 -0
- package/package.json +1 -1
package/dist/agent/actions.js
CHANGED
|
@@ -38,7 +38,7 @@ export function createActions(ctx) {
|
|
|
38
38
|
const chatId = getChatId();
|
|
39
39
|
// TODO: remove startsWith once the provider normalizes chatId to full ID after first fetchChat
|
|
40
40
|
// Support short ID matching (URL short IDs are prefixes of full IDs)
|
|
41
|
-
if (chatId && message.chat_id !== chatId && !message.chat_id.startsWith(chatId))
|
|
41
|
+
if (chatId && message.chat_id && message.chat_id !== chatId && !message.chat_id.startsWith(chatId))
|
|
42
42
|
return;
|
|
43
43
|
dispatch({ type: 'UPDATE_MESSAGE', payload: message });
|
|
44
44
|
// Dispatch client tool handlers when ready (in_progress or awaiting_input for backwards compat)
|
|
@@ -142,6 +142,13 @@ export function createActions(ctx) {
|
|
|
142
142
|
manager.addEventListener('chat_messages', (message) => {
|
|
143
143
|
updateMessage(message);
|
|
144
144
|
});
|
|
145
|
+
// Listen for AgentRun updates (state transitions, output)
|
|
146
|
+
manager.addEventListener('agent_runs', (run) => {
|
|
147
|
+
dispatch({ type: 'UPDATE_ACTIVE_RUN', payload: run });
|
|
148
|
+
const asChat = { active_run: run };
|
|
149
|
+
callbacks.onStatusChange?.(isChatBusy(asChat) ? 'streaming' : 'idle');
|
|
150
|
+
checkTurnEnd(asChat);
|
|
151
|
+
});
|
|
145
152
|
setStreamManager(manager);
|
|
146
153
|
manager.start();
|
|
147
154
|
};
|
package/dist/agent/reducer.js
CHANGED
|
@@ -29,12 +29,17 @@ export function chatReducer(state, action) {
|
|
|
29
29
|
return { ...state, chat, messages };
|
|
30
30
|
}
|
|
31
31
|
case 'UPDATE_CHAT': {
|
|
32
|
-
// Update chat metadata
|
|
32
|
+
// Update chat metadata without replacing messages
|
|
33
33
|
const chat = action.payload;
|
|
34
34
|
if (!chat)
|
|
35
35
|
return state;
|
|
36
36
|
return { ...state, chat };
|
|
37
37
|
}
|
|
38
|
+
case 'UPDATE_ACTIVE_RUN': {
|
|
39
|
+
if (!state.chat)
|
|
40
|
+
return state;
|
|
41
|
+
return { ...state, chat: { ...state.chat, active_run: action.payload } };
|
|
42
|
+
}
|
|
38
43
|
case 'SET_MESSAGES':
|
|
39
44
|
return { ...state, messages: action.payload };
|
|
40
45
|
case 'UPDATE_MESSAGE': {
|
package/dist/agent/types.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* Public types for the Agent chat module.
|
|
5
5
|
*/
|
|
6
6
|
import type { Dispatch } from 'react';
|
|
7
|
-
import type { ChatDTO, ChatMessageDTO, AgentTool, AgentConfigInput as GeneratedAgentConfig, CoreAppConfigInput as CoreAppConfig, FileRef } from '../types';
|
|
7
|
+
import type { AgentRunDTO, ChatDTO, ChatMessageDTO, AgentTool, AgentConfigInput as GeneratedAgentConfig, CoreAppConfigInput as CoreAppConfig, FileRef } from '../types';
|
|
8
8
|
import type { HttpClient } from '../http/client';
|
|
9
9
|
import type { StreamableManager } from '../http/streamable';
|
|
10
10
|
import type { PollManager } from '../http/poll';
|
|
@@ -187,6 +187,9 @@ export type ChatAction = {
|
|
|
187
187
|
} | {
|
|
188
188
|
type: 'UPDATE_CHAT';
|
|
189
189
|
payload: ChatDTO | null;
|
|
190
|
+
} | {
|
|
191
|
+
type: 'UPDATE_ACTIVE_RUN';
|
|
192
|
+
payload: AgentRunDTO;
|
|
190
193
|
} | {
|
|
191
194
|
type: 'SET_MESSAGES';
|
|
192
195
|
payload: ChatMessageDTO[];
|
package/dist/api/agents.js
CHANGED
|
@@ -163,6 +163,13 @@ export class Agent {
|
|
|
163
163
|
resolve();
|
|
164
164
|
}
|
|
165
165
|
});
|
|
166
|
+
this.stream.addEventListener('agent_runs', (run) => {
|
|
167
|
+
const asChat = { active_run: run };
|
|
168
|
+
options.onChat?.(asChat);
|
|
169
|
+
if (!isChatBusy(asChat)) {
|
|
170
|
+
resolve();
|
|
171
|
+
}
|
|
172
|
+
});
|
|
166
173
|
this.stream.addEventListener('chat_messages', (message) => {
|
|
167
174
|
options.onMessage?.(message);
|
|
168
175
|
if (message.tool_invocations && options.onToolCall) {
|