@inferencesh/sdk 0.6.53 → 0.6.54
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/api/agents.d.ts +10 -0
- package/dist/api/agents.js +18 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.js +1 -0
- package/package.json +1 -1
package/dist/api/agents.d.ts
CHANGED
|
@@ -57,6 +57,14 @@ export interface SendMessageOptions {
|
|
|
57
57
|
stream?: boolean;
|
|
58
58
|
/** Polling interval in ms when stream is false. Overrides client default. */
|
|
59
59
|
pollIntervalMs?: number;
|
|
60
|
+
/**
|
|
61
|
+
* Stops waiting for the turn. Aborting rejects sendMessage with
|
|
62
|
+
* `signal.reason` and closes the stream or poller; the agent keeps running
|
|
63
|
+
* server-side (use stopChat() to cancel it). A turn parked on a tool
|
|
64
|
+
* approval or an authorization counts as still running, so a client that
|
|
65
|
+
* cannot resolve those is the typical caller.
|
|
66
|
+
*/
|
|
67
|
+
signal?: AbortSignal;
|
|
60
68
|
}
|
|
61
69
|
export interface AgentRunOptions extends Omit<SendMessageOptions, 'stream'> {
|
|
62
70
|
/** Polling interval in ms (default: 2000) */
|
|
@@ -86,6 +94,8 @@ export declare class Agent {
|
|
|
86
94
|
userMessage: ChatMessageDTO;
|
|
87
95
|
assistantMessage: ChatMessageDTO;
|
|
88
96
|
}>;
|
|
97
|
+
/** Resolves with `wait`, or rejects with `signal.reason` and stops the stream/poller. */
|
|
98
|
+
private abortable;
|
|
89
99
|
/** Get chat by ID */
|
|
90
100
|
getChat(chatId?: string): Promise<ChatDTO | null>;
|
|
91
101
|
/** Stop the current chat generation */
|
package/dist/api/agents.js
CHANGED
|
@@ -59,6 +59,8 @@ export class Agent {
|
|
|
59
59
|
/** Send a message to the agent */
|
|
60
60
|
async sendMessage(text, options = {}) {
|
|
61
61
|
this.dispatchedToolCalls.clear();
|
|
62
|
+
if (options.signal?.aborted)
|
|
63
|
+
throw options.signal.reason;
|
|
62
64
|
const isTemplate = typeof this.config === 'string';
|
|
63
65
|
const hasCallbacks = !!(options.onMessage || options.onChat || options.onToolCall || options.onDelta);
|
|
64
66
|
// Process files - either already uploaded (FileDTO with uri) or needs upload (Blob)
|
|
@@ -132,10 +134,25 @@ export class Agent {
|
|
|
132
134
|
}
|
|
133
135
|
// Wait for completion
|
|
134
136
|
if (waitPromise) {
|
|
135
|
-
await waitPromise;
|
|
137
|
+
await this.abortable(waitPromise, options.signal);
|
|
136
138
|
}
|
|
137
139
|
return { userMessage: response.user_message, assistantMessage: response.assistant_message };
|
|
138
140
|
}
|
|
141
|
+
/** Resolves with `wait`, or rejects with `signal.reason` and stops the stream/poller. */
|
|
142
|
+
abortable(wait, signal) {
|
|
143
|
+
if (!signal)
|
|
144
|
+
return wait;
|
|
145
|
+
return new Promise((resolve, reject) => {
|
|
146
|
+
const onAbort = () => {
|
|
147
|
+
this.disconnect();
|
|
148
|
+
reject(signal.reason);
|
|
149
|
+
};
|
|
150
|
+
if (signal.aborted)
|
|
151
|
+
return onAbort();
|
|
152
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
153
|
+
wait.then(resolve, reject).finally(() => signal.removeEventListener('abort', onAbort));
|
|
154
|
+
});
|
|
155
|
+
}
|
|
139
156
|
/** Get chat by ID */
|
|
140
157
|
async getChat(chatId) {
|
|
141
158
|
const id = chatId || this.chatId;
|
package/dist/types.d.ts
CHANGED
|
@@ -1618,6 +1618,11 @@ export interface ChatDTO extends BaseModelDTO, PermissionModelDTO {
|
|
|
1618
1618
|
context?: {
|
|
1619
1619
|
[key: string]: string;
|
|
1620
1620
|
};
|
|
1621
|
+
/**
|
|
1622
|
+
* ChannelContext names the channel this chat came through (slack, a
|
|
1623
|
+
* wearable's tag, ...). Unset for chats started in the app or the SDK.
|
|
1624
|
+
*/
|
|
1625
|
+
channel_context?: ChannelContext;
|
|
1621
1626
|
agent_id?: string;
|
|
1622
1627
|
agent?: AgentDTO;
|
|
1623
1628
|
agent_version_id?: string;
|
|
@@ -4704,6 +4709,7 @@ export declare const NotificationTypePaymentFailed: NotificationType;
|
|
|
4704
4709
|
export declare const NotificationTypeUsageSummary: NotificationType;
|
|
4705
4710
|
export declare const NotificationTypeSpendingLimit: NotificationType;
|
|
4706
4711
|
export declare const NotificationTypeInvoice: NotificationType;
|
|
4712
|
+
export declare const NotificationTypeCreditNote: NotificationType;
|
|
4707
4713
|
export declare const NotificationTypeSubscriptionCreated: NotificationType;
|
|
4708
4714
|
export declare const NotificationTypeSubscriptionCredit: NotificationType;
|
|
4709
4715
|
export declare const NotificationTypeSubscriptionCanceled: NotificationType;
|
package/dist/types.js
CHANGED
|
@@ -859,6 +859,7 @@ export const NotificationTypePaymentFailed = "payment_failed";
|
|
|
859
859
|
export const NotificationTypeUsageSummary = "usage_summary";
|
|
860
860
|
export const NotificationTypeSpendingLimit = "spending_limit";
|
|
861
861
|
export const NotificationTypeInvoice = "invoice";
|
|
862
|
+
export const NotificationTypeCreditNote = "credit_note";
|
|
862
863
|
export const NotificationTypeSubscriptionCreated = "subscription_created";
|
|
863
864
|
export const NotificationTypeSubscriptionCredit = "subscription_credit";
|
|
864
865
|
export const NotificationTypeSubscriptionCanceled = "subscription_canceled";
|