@elqnt/agents 3.2.0 → 3.3.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/{agent-models-C36pvpUb.d.mts → agent-models-DLQlC7N6.d.mts} +143 -2
- package/dist/{agent-models-C36pvpUb.d.ts → agent-models-DLQlC7N6.d.ts} +143 -2
- package/dist/api/index.d.mts +67 -5
- package/dist/api/index.d.ts +67 -5
- package/dist/api/index.js +18 -2
- package/dist/api/index.js.map +1 -1
- package/dist/api/index.mjs +17 -1
- package/dist/api/server.d.mts +10 -2
- package/dist/api/server.d.ts +10 -2
- package/dist/api/server.js +16 -1
- package/dist/api/server.js.map +1 -1
- package/dist/api/server.mjs +15 -0
- package/dist/api/server.mjs.map +1 -1
- package/dist/chunk-2JDVRL35.js +133 -0
- package/dist/chunk-2JDVRL35.js.map +1 -0
- package/dist/chunk-3EHE4O57.mjs +133 -0
- package/dist/chunk-3EHE4O57.mjs.map +1 -0
- package/dist/{chunk-FR422IHO.mjs → chunk-BT33DRUI.mjs} +67 -1
- package/dist/chunk-BT33DRUI.mjs.map +1 -0
- package/dist/{chunk-SXYTVNKJ.mjs → chunk-JCPMUFOP.mjs} +7 -1
- package/dist/{chunk-SXYTVNKJ.mjs.map → chunk-JCPMUFOP.mjs.map} +1 -1
- package/dist/{chunk-IUKM3T2S.js → chunk-KA7N4YTF.js} +69 -3
- package/dist/chunk-KA7N4YTF.js.map +1 -0
- package/dist/{chunk-V5GHDXSW.mjs → chunk-MNFZXJ2Y.mjs} +500 -157
- package/dist/chunk-MNFZXJ2Y.mjs.map +1 -0
- package/dist/chunk-PKLT6GDN.js +1114 -0
- package/dist/chunk-PKLT6GDN.js.map +1 -0
- package/dist/{chunk-TPQS2XAW.js → chunk-VGWUFWOE.js} +8 -2
- package/dist/chunk-VGWUFWOE.js.map +1 -0
- package/dist/hooks/index.d.mts +158 -70
- package/dist/hooks/index.d.ts +158 -70
- package/dist/hooks/index.js +4 -3
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/index.mjs +7 -6
- package/dist/index.d.mts +7 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.js +27 -4
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +30 -7
- package/dist/models/index.d.mts +3 -2
- package/dist/models/index.d.ts +3 -2
- package/dist/models/index.js +8 -2
- package/dist/models/index.js.map +1 -1
- package/dist/models/index.mjs +7 -1
- package/dist/{sandbox-BHeWPjLU.d.mts → sandbox-DOxoM2Ge.d.mts} +1 -0
- package/dist/{sandbox-BHeWPjLU.d.ts → sandbox-DOxoM2Ge.d.ts} +1 -0
- package/dist/structured-Bs0IjwLD.d.mts +35 -0
- package/dist/structured-Bs0IjwLD.d.ts +35 -0
- package/dist/transport/index.d.mts +36 -0
- package/dist/transport/index.d.ts +36 -0
- package/dist/transport/index.js +8 -0
- package/dist/transport/index.js.map +1 -0
- package/dist/transport/index.mjs +8 -0
- package/dist/transport/index.mjs.map +1 -0
- package/dist/types-C2qd5f-E.d.mts +51 -0
- package/dist/types-k9PszCzt.d.ts +51 -0
- package/dist/utils/index.d.mts +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/package.json +11 -5
- package/dist/chunk-FR422IHO.mjs.map +0 -1
- package/dist/chunk-IUKM3T2S.js.map +0 -1
- package/dist/chunk-RGVWAFZP.js +0 -771
- package/dist/chunk-RGVWAFZP.js.map +0 -1
- package/dist/chunk-TPQS2XAW.js.map +0 -1
- package/dist/chunk-V5GHDXSW.mjs.map +0 -1
package/dist/hooks/index.d.mts
CHANGED
|
@@ -1,63 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { DateFilter,
|
|
1
|
+
import { ApiClientOptions } from '@elqnt/api-client';
|
|
2
|
+
import { A as Agent, aI as AgentSummary, ds as Skill, dV as SubAgent, eh as ToolDefinition, Z as AgentJob, a$ as AgentWidget, dD as SkillUserConfig, dk as ResolveSkillConfigResponse, aB as AgentStatusUpdate, eG as TriggerBackgroundAgentRequest, eH as TriggerBackgroundAgentResponse, bc as BackgroundAgentStatusResponse } from '../agent-models-DLQlC7N6.mjs';
|
|
3
|
+
export { ba as BackgroundAgentProgressEvent } from '../agent-models-DLQlC7N6.mjs';
|
|
4
|
+
import { DateFilter, SchedulerTask, SchedulerSchedule } from '../api/index.mjs';
|
|
5
|
+
import { ba as UserIntegration, ap as IntegrationProviderTS, aA as IntegrationTypeTS, h as CreateSandboxRequest, aW as Sandbox } from '../sandbox-DOxoM2Ge.mjs';
|
|
6
|
+
import { a as StructuredOutputRequest, b as StructuredOutputResponse } from '../structured-Bs0IjwLD.mjs';
|
|
7
|
+
import { ChatMessage, Attachment } from '@elqnt/chat/models';
|
|
8
|
+
export { B as BGAgentTransport, a as BGAgentTransportConfig } from '../types-C2qd5f-E.mjs';
|
|
5
9
|
import '@elqnt/types';
|
|
6
10
|
|
|
7
|
-
interface UseAsyncOptions {
|
|
8
|
-
onError?: (error: string) => void;
|
|
9
|
-
}
|
|
10
|
-
interface UseAsyncReturn<TResult, TArgs extends unknown[] = []> {
|
|
11
|
-
execute: (...args: TArgs) => Promise<TResult>;
|
|
12
|
-
loading: boolean;
|
|
13
|
-
error: string | null;
|
|
14
|
-
clearError: () => void;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Generic async hook for any promise-returning function.
|
|
18
|
-
* Uses a request counter to properly track concurrent requests.
|
|
19
|
-
*/
|
|
20
|
-
declare function useAsync<TResult, TArgs extends unknown[] = []>(asyncFn: (...args: TArgs) => Promise<TResult>, options?: UseAsyncOptions): UseAsyncReturn<TResult, TArgs>;
|
|
21
|
-
/**
|
|
22
|
-
* Specialized async hook for API operations that return ApiResponse.
|
|
23
|
-
* Automatically extracts data and handles API errors.
|
|
24
|
-
*
|
|
25
|
-
* @param asyncFn - Function that returns ApiResponse<TResponse>
|
|
26
|
-
* @param extractor - Function to extract the desired result from response data
|
|
27
|
-
* @param defaultValue - Default value to return on error
|
|
28
|
-
* @param options - Optional configuration
|
|
29
|
-
*
|
|
30
|
-
* @example
|
|
31
|
-
* ```tsx
|
|
32
|
-
* const { execute: listAgents, loading, error } = useApiAsync(
|
|
33
|
-
* () => listAgentsApi(optionsRef.current),
|
|
34
|
-
* (data) => data.agents,
|
|
35
|
-
* []
|
|
36
|
-
* );
|
|
37
|
-
* ```
|
|
38
|
-
*/
|
|
39
|
-
declare function useApiAsync<TResponse, TResult, TArgs extends unknown[] = []>(asyncFn: (...args: TArgs) => Promise<ApiResponse<TResponse>>, extractor: (data: TResponse) => TResult, defaultValue: TResult, options?: UseAsyncOptions): UseAsyncReturn<TResult, TArgs>;
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Creates a ref that stays synchronized with the provided options.
|
|
43
|
-
* Useful for accessing current options values in callbacks without
|
|
44
|
-
* causing re-renders or stale closure issues.
|
|
45
|
-
*
|
|
46
|
-
* @param options - The options object to track
|
|
47
|
-
* @returns A ref that always contains the latest options
|
|
48
|
-
*
|
|
49
|
-
* @example
|
|
50
|
-
* ```tsx
|
|
51
|
-
* const optionsRef = useOptionsRef(options);
|
|
52
|
-
*
|
|
53
|
-
* const fetchData = useCallback(async () => {
|
|
54
|
-
* // Always has the latest options, no stale closure
|
|
55
|
-
* const result = await api.fetch(optionsRef.current);
|
|
56
|
-
* }, []); // No need to include options in deps
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
59
|
-
declare function useOptionsRef<T>(options: T): React.MutableRefObject<T>;
|
|
60
|
-
|
|
61
11
|
type UseAgentsOptions = ApiClientOptions;
|
|
62
12
|
/**
|
|
63
13
|
* Hook for agent CRUD operations
|
|
@@ -82,11 +32,15 @@ declare function useAgents(options: UseAgentsOptions): {
|
|
|
82
32
|
updateAgent: (agentId: string, agent: Partial<Agent>) => Promise<Agent | null>;
|
|
83
33
|
deleteAgent: (agentId: string) => Promise<boolean>;
|
|
84
34
|
getDefaultAgent: () => Promise<Agent | null>;
|
|
35
|
+
exportAgent: (agentId: string) => Promise<Agent>;
|
|
36
|
+
importAgent: (agent: Agent) => Promise<Agent | null>;
|
|
85
37
|
};
|
|
38
|
+
|
|
39
|
+
type UseSkillsOptions = ApiClientOptions;
|
|
86
40
|
/**
|
|
87
41
|
* Hook for skill CRUD operations
|
|
88
42
|
*/
|
|
89
|
-
declare function useSkills(options:
|
|
43
|
+
declare function useSkills(options: UseSkillsOptions): {
|
|
90
44
|
loading: boolean;
|
|
91
45
|
error: string | null;
|
|
92
46
|
listSkills: () => Promise<Skill[]>;
|
|
@@ -96,10 +50,12 @@ declare function useSkills(options: UseAgentsOptions): {
|
|
|
96
50
|
deleteSkill: (skillId: string) => Promise<boolean>;
|
|
97
51
|
getCategories: () => Promise<string[]>;
|
|
98
52
|
};
|
|
53
|
+
|
|
54
|
+
type UseSubAgentsOptions = ApiClientOptions;
|
|
99
55
|
/**
|
|
100
56
|
* Hook for sub-agent CRUD operations
|
|
101
57
|
*/
|
|
102
|
-
declare function useSubAgents(options:
|
|
58
|
+
declare function useSubAgents(options: UseSubAgentsOptions): {
|
|
103
59
|
loading: boolean;
|
|
104
60
|
error: string | null;
|
|
105
61
|
listSubAgents: () => Promise<SubAgent[]>;
|
|
@@ -108,6 +64,8 @@ declare function useSubAgents(options: UseAgentsOptions): {
|
|
|
108
64
|
updateSubAgent: (subAgentId: string, subAgent: Partial<SubAgent>) => Promise<SubAgent | null>;
|
|
109
65
|
deleteSubAgent: (subAgentId: string) => Promise<boolean>;
|
|
110
66
|
};
|
|
67
|
+
|
|
68
|
+
type UseToolDefinitionsOptions = ApiClientOptions;
|
|
111
69
|
/**
|
|
112
70
|
* Hook for tool definition CRUD operations
|
|
113
71
|
*
|
|
@@ -121,7 +79,7 @@ declare function useSubAgents(options: UseAgentsOptions): {
|
|
|
121
79
|
* const toolDefs = await listToolDefinitions();
|
|
122
80
|
* ```
|
|
123
81
|
*/
|
|
124
|
-
declare function useToolDefinitions(options:
|
|
82
|
+
declare function useToolDefinitions(options: UseToolDefinitionsOptions): {
|
|
125
83
|
loading: boolean;
|
|
126
84
|
error: string | null;
|
|
127
85
|
listToolDefinitions: () => Promise<ToolDefinition[]>;
|
|
@@ -131,6 +89,8 @@ declare function useToolDefinitions(options: UseAgentsOptions): {
|
|
|
131
89
|
updateToolDefinition: (toolDefId: string, toolDefinition: Partial<ToolDefinition>) => Promise<ToolDefinition | null>;
|
|
132
90
|
deleteToolDefinition: (toolDefId: string) => Promise<boolean>;
|
|
133
91
|
};
|
|
92
|
+
|
|
93
|
+
type UseAgentJobsOptions = ApiClientOptions;
|
|
134
94
|
/**
|
|
135
95
|
* Hook for agent job CRUD operations
|
|
136
96
|
*
|
|
@@ -145,7 +105,7 @@ declare function useToolDefinitions(options: UseAgentsOptions): {
|
|
|
145
105
|
* await pauseAgentJob(jobId);
|
|
146
106
|
* ```
|
|
147
107
|
*/
|
|
148
|
-
declare function useAgentJobs(options:
|
|
108
|
+
declare function useAgentJobs(options: UseAgentJobsOptions): {
|
|
149
109
|
loading: boolean;
|
|
150
110
|
error: string | null;
|
|
151
111
|
listAgentJobs: () => Promise<AgentJob[]>;
|
|
@@ -156,7 +116,8 @@ declare function useAgentJobs(options: UseAgentsOptions): {
|
|
|
156
116
|
pauseAgentJob: (jobId: string) => Promise<AgentJob | null>;
|
|
157
117
|
resumeAgentJob: (jobId: string) => Promise<AgentJob | null>;
|
|
158
118
|
};
|
|
159
|
-
|
|
119
|
+
|
|
120
|
+
interface UseWidgetsOptions extends ApiClientOptions {
|
|
160
121
|
agentId: string;
|
|
161
122
|
}
|
|
162
123
|
/**
|
|
@@ -184,6 +145,8 @@ declare function useWidgets(options: UseWidgetsOptions): {
|
|
|
184
145
|
deleteWidget: (widgetId: string) => Promise<boolean>;
|
|
185
146
|
setDefaultWidget: (widgetId: string) => Promise<boolean>;
|
|
186
147
|
};
|
|
148
|
+
|
|
149
|
+
type UseSkillUserConfigOptions = ApiClientOptions;
|
|
187
150
|
/**
|
|
188
151
|
* Hook for skill user configuration operations
|
|
189
152
|
*
|
|
@@ -198,7 +161,7 @@ declare function useWidgets(options: UseWidgetsOptions): {
|
|
|
198
161
|
* await updateSkillUserConfig(skillId, { enabled: true });
|
|
199
162
|
* ```
|
|
200
163
|
*/
|
|
201
|
-
declare function useSkillUserConfig(options:
|
|
164
|
+
declare function useSkillUserConfig(options: UseSkillUserConfigOptions): {
|
|
202
165
|
loading: boolean;
|
|
203
166
|
error: string | null;
|
|
204
167
|
getSkillUserConfig: (skillId: string, agentId?: string | undefined) => Promise<SkillUserConfig | null>;
|
|
@@ -216,6 +179,8 @@ declare function useSkillUserConfig(options: UseAgentsOptions): {
|
|
|
216
179
|
} | undefined) => Promise<SkillUserConfig[]>;
|
|
217
180
|
resolveSkillConfig: (skillId: string, agentId: string) => Promise<ResolveSkillConfigResponse | null>;
|
|
218
181
|
};
|
|
182
|
+
|
|
183
|
+
type UseAnalyticsOptions = ApiClientOptions;
|
|
219
184
|
/**
|
|
220
185
|
* Hook for agent analytics operations
|
|
221
186
|
*
|
|
@@ -229,7 +194,7 @@ declare function useSkillUserConfig(options: UseAgentsOptions): {
|
|
|
229
194
|
* const chatsData = await getAgentChatsAnalytics({ from: '2024-01-01', to: '2024-12-31' });
|
|
230
195
|
* ```
|
|
231
196
|
*/
|
|
232
|
-
declare function useAnalytics(options:
|
|
197
|
+
declare function useAnalytics(options: UseAnalyticsOptions): {
|
|
233
198
|
loading: boolean;
|
|
234
199
|
error: string | null;
|
|
235
200
|
getAgentChatsAnalytics: (params: {
|
|
@@ -245,6 +210,8 @@ declare function useAnalytics(options: UseAgentsOptions): {
|
|
|
245
210
|
date_filter: DateFilter;
|
|
246
211
|
}) => Promise<unknown[]>;
|
|
247
212
|
};
|
|
213
|
+
|
|
214
|
+
type UseIntegrationsOptions = ApiClientOptions;
|
|
248
215
|
/**
|
|
249
216
|
* Hook for user integration operations (OAuth connections)
|
|
250
217
|
*
|
|
@@ -259,7 +226,7 @@ declare function useAnalytics(options: UseAgentsOptions): {
|
|
|
259
226
|
* const { auth_url } = await connectIntegration({ provider: 'google', integrationType: 'email', redirectUri: '/callback' });
|
|
260
227
|
* ```
|
|
261
228
|
*/
|
|
262
|
-
declare function useIntegrations(options:
|
|
229
|
+
declare function useIntegrations(options: UseIntegrationsOptions): {
|
|
263
230
|
loading: boolean;
|
|
264
231
|
error: string | null;
|
|
265
232
|
listIntegrations: () => Promise<UserIntegration[]>;
|
|
@@ -291,6 +258,8 @@ declare function useIntegrations(options: UseAgentsOptions): {
|
|
|
291
258
|
instancesCreated: number;
|
|
292
259
|
} | null>;
|
|
293
260
|
};
|
|
261
|
+
|
|
262
|
+
type UseSandboxOptions = ApiClientOptions;
|
|
294
263
|
/**
|
|
295
264
|
* Hook for sandbox operations (AI-generated HTML sandboxes)
|
|
296
265
|
*
|
|
@@ -305,7 +274,7 @@ declare function useIntegrations(options: UseAgentsOptions): {
|
|
|
305
274
|
* console.log(result.url); // sandbox URL
|
|
306
275
|
* ```
|
|
307
276
|
*/
|
|
308
|
-
declare function useSandbox(options:
|
|
277
|
+
declare function useSandbox(options: UseSandboxOptions): {
|
|
309
278
|
loading: boolean;
|
|
310
279
|
error: string | null;
|
|
311
280
|
createSandbox: (request: Omit<CreateSandboxRequest, "orgId">) => Promise<{
|
|
@@ -328,6 +297,36 @@ declare function useSandbox(options: UseAgentsOptions): {
|
|
|
328
297
|
}>;
|
|
329
298
|
deleteSandbox: (sandboxId: string) => Promise<boolean>;
|
|
330
299
|
};
|
|
300
|
+
|
|
301
|
+
type UseStructuredOutputOptions = ApiClientOptions;
|
|
302
|
+
/**
|
|
303
|
+
* Hook for the one-shot structured-output LLM primitive.
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* ```tsx
|
|
307
|
+
* const { run, loading, error, data } = useStructuredOutput<{ title: string }>({
|
|
308
|
+
* baseUrl: apiGatewayUrl,
|
|
309
|
+
* orgId: selectedOrgId,
|
|
310
|
+
* });
|
|
311
|
+
*
|
|
312
|
+
* await run({
|
|
313
|
+
* provider: "anthropic",
|
|
314
|
+
* model: "claude-sonnet-4-6",
|
|
315
|
+
* userPrompt: "Give me a title for a slide about onboarding.",
|
|
316
|
+
* schema: { type: "object", properties: { title: { type: "string" } }, required: ["title"] },
|
|
317
|
+
* schemaName: "slide_title",
|
|
318
|
+
* maxTokens: 256,
|
|
319
|
+
* });
|
|
320
|
+
* ```
|
|
321
|
+
*/
|
|
322
|
+
declare function useStructuredOutput<T = unknown>(options: UseStructuredOutputOptions): {
|
|
323
|
+
run: (request: StructuredOutputRequest) => Promise<StructuredOutputResponse<T> | null>;
|
|
324
|
+
loading: boolean;
|
|
325
|
+
error: string | null;
|
|
326
|
+
clearError: () => void;
|
|
327
|
+
};
|
|
328
|
+
|
|
329
|
+
type UseSchedulerTasksOptions = ApiClientOptions;
|
|
331
330
|
/**
|
|
332
331
|
* Hook for scheduler task operations
|
|
333
332
|
*
|
|
@@ -342,7 +341,7 @@ declare function useSandbox(options: UseAgentsOptions): {
|
|
|
342
341
|
* await snoozeTask(taskId, { amount: 30, unit: "minutes" });
|
|
343
342
|
* ```
|
|
344
343
|
*/
|
|
345
|
-
declare function useSchedulerTasks(options:
|
|
344
|
+
declare function useSchedulerTasks(options: UseSchedulerTasksOptions): {
|
|
346
345
|
loading: boolean;
|
|
347
346
|
error: string | null;
|
|
348
347
|
listTasks: (params?: {
|
|
@@ -361,6 +360,8 @@ declare function useSchedulerTasks(options: UseAgentsOptions): {
|
|
|
361
360
|
completeTask: (taskId: string) => Promise<SchedulerTask | null>;
|
|
362
361
|
startTask: (taskId: string) => Promise<SchedulerTask | null>;
|
|
363
362
|
};
|
|
363
|
+
|
|
364
|
+
type UseSchedulerSchedulesOptions = ApiClientOptions;
|
|
364
365
|
/**
|
|
365
366
|
* Hook for scheduler schedule operations (recurring jobs)
|
|
366
367
|
*
|
|
@@ -375,7 +376,7 @@ declare function useSchedulerTasks(options: UseAgentsOptions): {
|
|
|
375
376
|
* await pauseSchedule(scheduleId);
|
|
376
377
|
* ```
|
|
377
378
|
*/
|
|
378
|
-
declare function useSchedulerSchedules(options:
|
|
379
|
+
declare function useSchedulerSchedules(options: UseSchedulerSchedulesOptions): {
|
|
379
380
|
loading: boolean;
|
|
380
381
|
error: string | null;
|
|
381
382
|
listSchedules: (params?: {
|
|
@@ -392,4 +393,91 @@ declare function useSchedulerSchedules(options: UseAgentsOptions): {
|
|
|
392
393
|
runSchedule: (scheduleId: string) => Promise<SchedulerSchedule | null>;
|
|
393
394
|
};
|
|
394
395
|
|
|
395
|
-
|
|
396
|
+
/** Live state accumulated from SSE events for a single background agent */
|
|
397
|
+
interface BGAgentLiveState {
|
|
398
|
+
status: "running" | "completed" | "failed";
|
|
399
|
+
progressLog: string[];
|
|
400
|
+
latestMessage: string;
|
|
401
|
+
result?: string;
|
|
402
|
+
error?: string;
|
|
403
|
+
}
|
|
404
|
+
/** Options for useBackgroundAgents hook */
|
|
405
|
+
interface UseBackgroundAgentsOptions extends ApiClientOptions {
|
|
406
|
+
/** Chat service URL for SSE streaming (e.g., wss://chat.example.com or https://chat.example.com) */
|
|
407
|
+
chatServiceUrl?: string;
|
|
408
|
+
/** User ID (typically email) for chat operations */
|
|
409
|
+
userId?: string;
|
|
410
|
+
}
|
|
411
|
+
/** Background status reported by the agent via report_status tool */
|
|
412
|
+
type BackgroundStatus = "processing" | "completed" | "failed";
|
|
413
|
+
/** Watched chat state with messages */
|
|
414
|
+
interface WatchedChatState {
|
|
415
|
+
chatKey: string;
|
|
416
|
+
messages: ChatMessage[];
|
|
417
|
+
status: "loading" | "active" | "completed" | "error";
|
|
418
|
+
/** Background agent status (from report_status tool) */
|
|
419
|
+
backgroundStatus?: BackgroundStatus;
|
|
420
|
+
/** Background agent status message (from report_status tool) */
|
|
421
|
+
backgroundStatusMessage?: string;
|
|
422
|
+
/** History of all status updates for inline display */
|
|
423
|
+
statusHistory: AgentStatusUpdate[];
|
|
424
|
+
title?: string;
|
|
425
|
+
metadata?: Record<string, unknown>;
|
|
426
|
+
error?: string;
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* Hook for triggering background agents, streaming progress via SSE, and checking status.
|
|
430
|
+
*
|
|
431
|
+
* @example
|
|
432
|
+
* ```tsx
|
|
433
|
+
* const { startChat, sendMessage } = useChatContext();
|
|
434
|
+
* const { liveStates, createTask, streamJob, checkStatus } = useBackgroundAgents({
|
|
435
|
+
* baseUrl: apiGatewayUrl,
|
|
436
|
+
* orgId: selectedOrgId,
|
|
437
|
+
* startChat,
|
|
438
|
+
* sendMessage,
|
|
439
|
+
* });
|
|
440
|
+
*
|
|
441
|
+
* // Create a background task (simplified flow using chat)
|
|
442
|
+
* const chatKey = await createTask("Analyze the quarterly report");
|
|
443
|
+
*
|
|
444
|
+
* // Or trigger via jobs API (PostgreSQL-backed)
|
|
445
|
+
* const result = await triggerAgent({ name: "Analysis", prompt: "...", agentName: "Research Agent" });
|
|
446
|
+
* if (result?.jobId) streamJob(result.jobId);
|
|
447
|
+
* ```
|
|
448
|
+
*/
|
|
449
|
+
declare function useBackgroundAgents(options: UseBackgroundAgentsOptions): {
|
|
450
|
+
liveStates: Record<string, BGAgentLiveState>;
|
|
451
|
+
streamJob: (jobId: string) => void;
|
|
452
|
+
createTask: (prompt: string, attachments?: Attachment[]) => Promise<string | null>;
|
|
453
|
+
watchChat: (chatKey: string) => Promise<void>;
|
|
454
|
+
unwatchChat: (chatKey: string) => void;
|
|
455
|
+
watchedChats: Record<string, WatchedChatState>;
|
|
456
|
+
triggerAgent: (request: Pick<TriggerBackgroundAgentRequest, "name" | "prompt" | "agentName" | "context" | "enableSSE" | "description">) => Promise<TriggerBackgroundAgentResponse | null>;
|
|
457
|
+
checkStatus: (jobId: string) => Promise<BackgroundAgentStatusResponse | null>;
|
|
458
|
+
listAgentSummaries: () => Promise<AgentSummary[]>;
|
|
459
|
+
loading: boolean;
|
|
460
|
+
error: string | null;
|
|
461
|
+
};
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Creates a ref that stays synchronized with the provided options.
|
|
465
|
+
* Useful for accessing current options values in callbacks without
|
|
466
|
+
* causing re-renders or stale closure issues.
|
|
467
|
+
*
|
|
468
|
+
* @param options - The options object to track
|
|
469
|
+
* @returns A ref that always contains the latest options
|
|
470
|
+
*
|
|
471
|
+
* @example
|
|
472
|
+
* ```tsx
|
|
473
|
+
* const optionsRef = useOptionsRef(options);
|
|
474
|
+
*
|
|
475
|
+
* const fetchData = useCallback(async () => {
|
|
476
|
+
* // Always has the latest options, no stale closure
|
|
477
|
+
* const result = await api.fetch(optionsRef.current);
|
|
478
|
+
* }, []); // No need to include options in deps
|
|
479
|
+
* ```
|
|
480
|
+
*/
|
|
481
|
+
declare function useOptionsRef<T>(options: T): React.MutableRefObject<T>;
|
|
482
|
+
|
|
483
|
+
export { type BGAgentLiveState, type BackgroundStatus, type UseAgentJobsOptions, type UseAgentsOptions, type UseAnalyticsOptions, type UseBackgroundAgentsOptions, type UseIntegrationsOptions, type UseSandboxOptions, type UseSchedulerSchedulesOptions, type UseSchedulerTasksOptions, type UseSkillUserConfigOptions, type UseSkillsOptions, type UseStructuredOutputOptions, type UseSubAgentsOptions, type UseToolDefinitionsOptions, type UseWidgetsOptions, type WatchedChatState, useAgentJobs, useAgents, useAnalytics, useBackgroundAgents, useIntegrations, useOptionsRef, useSandbox, useSchedulerSchedules, useSchedulerTasks, useSkillUserConfig, useSkills, useStructuredOutput, useSubAgents, useToolDefinitions, useWidgets };
|