@dudousxd/nestjs-agent-react 0.15.0 → 0.17.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/README.md +46 -0
- package/dist/index.cjs +415 -215
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +118 -3
- package/dist/index.d.ts +118 -3
- package/dist/index.js +373 -177
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
2
|
import { ChatTransport, UIMessage, UIMessageChunk, DataUIPart, UIDataTypes } from 'ai';
|
|
3
3
|
import * as _dudousxd_nestjs_agent_core from '@dudousxd/nestjs-agent-core';
|
|
4
|
-
import { ThreadSummary, ThreadDetail, MessageAttachment, ToolCatalogEntry, SkillCatalogEntry, QuotaView, MessageFeedbackValue, MessageFeedback, StoredMessage } from '@dudousxd/nestjs-agent-core';
|
|
4
|
+
import { ThreadSummary, ThreadDetail, MessageAttachment, ToolCatalogEntry, SkillCatalogEntry, QuotaView, QuotaReport, ModelCatalogView, AgentCatalogEntry, MessageFeedbackValue, MessageFeedback, ModelCatalogEntry, QuotaWindow, QuotaBlock, StoredMessage } from '@dudousxd/nestjs-agent-core';
|
|
5
5
|
export { ElicitationInput, ElicitationInputType, validateElicitationAnswer as validateAnswer, validateElicitationValue as validateAnswerValue } from '@dudousxd/nestjs-agent-core';
|
|
6
6
|
import React__default from 'react';
|
|
7
7
|
import { a as TranscriptBlock, U as UsageSummary, b as TimestampInfo, C as ChatStatus, M as MessageUsageInfo, c as ToolCatalog, A as ApproveOptions, d as AnyToolUIPart, e as TranscriptFile, T as TranscriptUiBlock } from './model-gHqjNjLJ.cjs';
|
|
@@ -15,10 +15,12 @@ export { f as ApprovalBlockOptions, B as BuildBlocksOptions, g as CoercibleQuest
|
|
|
15
15
|
interface ThreadPatch {
|
|
16
16
|
title?: string;
|
|
17
17
|
defaultAgent?: string | null;
|
|
18
|
+
/** Pin a catalog model on the thread; `null` unpins it. */
|
|
19
|
+
model?: string | null;
|
|
18
20
|
}
|
|
19
21
|
/** Starting a turn: the body `POST <base>/chat` takes (see docs/stream-protocol.md). */
|
|
20
22
|
interface ChatStreamRequest {
|
|
21
|
-
/** `{ message, threadId?, agent?, attachments?, pageContext?, regenerate?, … }`. */
|
|
23
|
+
/** `{ message, threadId?, agent?, model?, attachments?, pageContext?, regenerate?, … }`. */
|
|
22
24
|
body: Record<string, unknown>;
|
|
23
25
|
/** Per-request headers the AI SDK was handed for this send. */
|
|
24
26
|
headers?: Record<string, string>;
|
|
@@ -104,6 +106,12 @@ interface AgentBackend {
|
|
|
104
106
|
listTools?(agent?: string): Promise<ToolCatalogEntry[]>;
|
|
105
107
|
listSkills?(threadId?: string): Promise<SkillCatalogEntry[]>;
|
|
106
108
|
getQuotaToday?(): Promise<QuotaView>;
|
|
109
|
+
/** `GET <base>/quota` — every budget window, and which one blocks sends, if any. */
|
|
110
|
+
getQuota?(): Promise<QuotaReport>;
|
|
111
|
+
/** `GET <base>/models?agent=` — what a model picker offers. */
|
|
112
|
+
listModels?(agent?: string): Promise<ModelCatalogView>;
|
|
113
|
+
/** `GET <base>/agents` — what an agent picker offers. */
|
|
114
|
+
listAgents?(): Promise<AgentCatalogEntry[]>;
|
|
107
115
|
setMessageFeedback?(messageId: string, input: MessageFeedbackInput): Promise<{
|
|
108
116
|
feedback: MessageFeedback | null;
|
|
109
117
|
}>;
|
|
@@ -286,6 +294,89 @@ declare class AgentChatTransport implements ChatTransport<UIMessage> {
|
|
|
286
294
|
private toChunkStream;
|
|
287
295
|
}
|
|
288
296
|
|
|
297
|
+
interface UseAgentsOptions {
|
|
298
|
+
/** `useAgentChat(...).backend`, or your own. Must implement `listAgents`. */
|
|
299
|
+
backend: AgentBackend;
|
|
300
|
+
/** `false` holds the request. Default `true`. */
|
|
301
|
+
enabled?: boolean;
|
|
302
|
+
}
|
|
303
|
+
interface AgentsState {
|
|
304
|
+
/** `[]` until loaded. */
|
|
305
|
+
agents: AgentCatalogEntry[];
|
|
306
|
+
/** The agent a turn runs as when none is named. */
|
|
307
|
+
defaultAgent: string | null;
|
|
308
|
+
isLoading: boolean;
|
|
309
|
+
error: Error | null;
|
|
310
|
+
refresh: () => Promise<void>;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* The registered agents (`GET <base>/agents`) — the data behind an agent picker. Send the pick as
|
|
314
|
+
* `useAgentChat({ agent })`, or pin it on a thread with `PATCH <base>/threads/:id { defaultAgent }`.
|
|
315
|
+
*/
|
|
316
|
+
declare function useAgents(options: UseAgentsOptions): AgentsState;
|
|
317
|
+
|
|
318
|
+
interface UseModelsOptions {
|
|
319
|
+
/** `useAgentChat(...).backend`, or your own. Must implement `listModels`. */
|
|
320
|
+
backend: AgentBackend;
|
|
321
|
+
/** The agent to list models for; omitted → the default agent. */
|
|
322
|
+
agent?: string;
|
|
323
|
+
/** `false` holds the request. Default `true`. */
|
|
324
|
+
enabled?: boolean;
|
|
325
|
+
}
|
|
326
|
+
/** A catalog entry with the provider it sits under, for a flat list or a search. */
|
|
327
|
+
interface ModelOption extends ModelCatalogEntry {
|
|
328
|
+
providerId: string;
|
|
329
|
+
providerLabel: string;
|
|
330
|
+
}
|
|
331
|
+
interface ModelsState {
|
|
332
|
+
/** Grouped as the server sent them. `[]` until loaded. */
|
|
333
|
+
providers: ModelCatalogView['providers'];
|
|
334
|
+
/** Every model, flattened in provider order. */
|
|
335
|
+
models: ModelOption[];
|
|
336
|
+
/** The model a turn runs on when none is picked, or `null` when the provider decides. */
|
|
337
|
+
defaultModel: string | null;
|
|
338
|
+
/** The entry for `id`, or `undefined`. */
|
|
339
|
+
find: (id: string | null | undefined) => ModelOption | undefined;
|
|
340
|
+
isLoading: boolean;
|
|
341
|
+
error: Error | null;
|
|
342
|
+
refresh: () => Promise<void>;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* The models this caller may pick (`GET <base>/models?agent=`), with badges and availability — the
|
|
346
|
+
* data behind a model picker. Headless: render the options however you like, then send the pick
|
|
347
|
+
* as `useAgentChat({ model })`, `sendMessage(msg, { body: { model } })`, or pin it on the thread
|
|
348
|
+
* with `chat.setThreadModel(id)`.
|
|
349
|
+
*/
|
|
350
|
+
declare function useModels(options: UseModelsOptions): ModelsState;
|
|
351
|
+
|
|
352
|
+
interface UseQuotaOptions {
|
|
353
|
+
/** `useAgentChat(...).backend`, or your own. Must implement `getQuota`. */
|
|
354
|
+
backend: AgentBackend;
|
|
355
|
+
/** `false` holds the request. Default `true`. */
|
|
356
|
+
enabled?: boolean;
|
|
357
|
+
/** Re-read every `pollMs` ms as well. Default: only on mount, after runs, and on `refresh`. */
|
|
358
|
+
pollMs?: number;
|
|
359
|
+
}
|
|
360
|
+
interface QuotaState {
|
|
361
|
+
/** The full report, once loaded. */
|
|
362
|
+
report: QuotaReport | undefined;
|
|
363
|
+
windows: QuotaWindow[];
|
|
364
|
+
/** The `day` / `month` windows, when the server reports them. */
|
|
365
|
+
day: QuotaWindow | undefined;
|
|
366
|
+
month: QuotaWindow | undefined;
|
|
367
|
+
/** The window that blocks sends, or `null` — pass it to `useAgentChat({ blocked })`. */
|
|
368
|
+
blocked: QuotaBlock | null;
|
|
369
|
+
isLoading: boolean;
|
|
370
|
+
error: Error | null;
|
|
371
|
+
refresh: () => Promise<void>;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* The caller's budget (`GET <base>/quota`): every window's usage against its ceilings, and which
|
|
375
|
+
* one — if any — blocks sends. Re-read after every run a chat on the same backend settles, so a
|
|
376
|
+
* meter moves with the conversation. Headless: draw the meter yourself.
|
|
377
|
+
*/
|
|
378
|
+
declare function useQuota(options: UseQuotaOptions): QuotaState;
|
|
379
|
+
|
|
289
380
|
interface UseMessageFeedbackOptions {
|
|
290
381
|
/** `useAgentChat(...).backend`, or your own. Must implement `setMessageFeedback`. */
|
|
291
382
|
backend: AgentBackend;
|
|
@@ -481,6 +572,12 @@ declare class AgentClient implements AgentBackend {
|
|
|
481
572
|
uploadAttachment(file: File, options?: UploadAttachmentOptions): Promise<MessageAttachment>;
|
|
482
573
|
promoteThread(id: string): Promise<OkResult>;
|
|
483
574
|
truncateFromMessage(threadId: string, messageId: string): Promise<OkResult>;
|
|
575
|
+
/** `GET /agent/models?agent=` — the models this caller may pick, grouped by provider. */
|
|
576
|
+
listModels(agent?: string): Promise<ModelCatalogView>;
|
|
577
|
+
/** `GET /agent/agents` — the registered agents, the default one flagged. */
|
|
578
|
+
listAgents(): Promise<AgentCatalogEntry[]>;
|
|
579
|
+
/** `GET /agent/quota` — the caller's budget windows and the one blocking sends, if any. */
|
|
580
|
+
getQuota(): Promise<QuotaReport>;
|
|
484
581
|
getQuotaToday(): Promise<QuotaToday>;
|
|
485
582
|
cancelStream(runId: string): Promise<CancelResult>;
|
|
486
583
|
/**
|
|
@@ -1308,6 +1405,18 @@ interface UseAgentChatOptions<B extends AgentBackend = AgentClient> {
|
|
|
1308
1405
|
client?: B;
|
|
1309
1406
|
/** Named agent to run each turn. */
|
|
1310
1407
|
agent?: string;
|
|
1408
|
+
/**
|
|
1409
|
+
* The quota window blocking sends — `useQuota(...).blocked`. While set, `sendMessage` and
|
|
1410
|
+
* `regenerate` refuse with {@link QuotaBlockedError} instead of starting a turn the server would
|
|
1411
|
+
* refuse anyway.
|
|
1412
|
+
*/
|
|
1413
|
+
blocked?: QuotaBlock | null;
|
|
1414
|
+
/**
|
|
1415
|
+
* Catalog model to run each turn on (see `useModels`), sent as the body's `model`. Read at every
|
|
1416
|
+
* send, so a picker can change it between turns. Omitted → the thread's pinned model, else the
|
|
1417
|
+
* server default. A single send can still override it with `sendMessage(msg, { body: { model } })`.
|
|
1418
|
+
*/
|
|
1419
|
+
model?: string;
|
|
1311
1420
|
/** Thread this chat is bound to. Omitted → backend creates one on send. */
|
|
1312
1421
|
threadId?: string;
|
|
1313
1422
|
/** Persisted history to seed `useChat` with (consumed on mount only). */
|
|
@@ -1447,6 +1556,7 @@ declare function useAgentChat<B extends AgentBackend = AgentClient>(options: Use
|
|
|
1447
1556
|
* on the first send. A getter, because the created id is learned mid-stream.
|
|
1448
1557
|
*/
|
|
1449
1558
|
getThreadId: () => string | undefined;
|
|
1559
|
+
setThreadModel: (model: string | null) => Promise<void>;
|
|
1450
1560
|
/** The backend this chat talks to — pass it to `useThreads`, `useMessageFeedback`, … */
|
|
1451
1561
|
backend: B;
|
|
1452
1562
|
/** Same object as {@link backend}; kept for callers that read it under its old name. */
|
|
@@ -1491,5 +1601,10 @@ declare function useAgentChat<B extends AgentBackend = AgentClient>(options: Use
|
|
|
1491
1601
|
addToolApprovalResponse: ai.ChatAddToolApproveResponseFunction;
|
|
1492
1602
|
clearError: () => void;
|
|
1493
1603
|
};
|
|
1604
|
+
/** A send refused on the client because a quota window is exhausted (`useAgentChat({ blocked })`). */
|
|
1605
|
+
declare class QuotaBlockedError extends Error {
|
|
1606
|
+
readonly block: QuotaBlock;
|
|
1607
|
+
constructor(block: QuotaBlock);
|
|
1608
|
+
}
|
|
1494
1609
|
|
|
1495
|
-
export { type AgentBackend, AgentBackendUnsupportedError, AgentChatTransport, type AgentChatTransportOptions, AgentClient, type AgentClientOptions, AgentHttpError, type AgentMessageMetadata, type AgentStreamMeta, type AggregatedTurnUsage, AnyToolUIPart, type ApprovalCountdown, ApproveOptions, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type CancelResult, type ChatBackground, ChatInput, type ChatInputProps, ChatStatus, type ChatStreamRequest, type ChatStreamResponse, type ChatTranscript, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type MessageFeedbackInput, type MessageFeedbackState, MessageItem, type MessageItemClassNames, type MessageItemProps, MessageItemView, type MessageItemViewProps, MessageList, type MessageListClassNames, type MessageListProps, MessageUsageInfo, type QuotaToday, type ReconnectOptions, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RenderUiFn, type ResumeStreamRequest, SPEECH_LANGUAGES, type SkillSuggestionData, type SkillsSourceOptions, type SpeechLanguage, type SpeechRecognitionHook, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type StreamConnectionState, type ThreadPatch, type ThreadsEvent, type ThreadsState, TimestampInfo, ToolCatalog, type ToolCatalogState, type TranscriptActionState, TranscriptBlock, type TranscriptCopyState, type TranscriptEditState, TranscriptFile, type TranscriptItem, type TranscriptItemOptions, type TranscriptStopState, TranscriptUiBlock, type TranscriptWindow, type TriggerMatch, type TriggerPosition, type UploadAttachmentOptions, UsageSummary, type UseAgentChatOptions, type UseApprovalCountdownOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseElapsedOptions, type UseMessageFeedbackOptions, type UseSpeechRecognitionOptions, type UseThreadsOptions, type UseToolCatalogOptions, type UseTranscriptItemOptions, applyCompletion, approvalCountdown, backgroundRunsFromThread, createSkillsSource, filterAutocompleteItems, findActiveTrigger, formatElapsed, loadStoredSpeechLang, notifyThreads, onThreadsEvent, persistSpeechLang, readReasoningMs, requireBackendMethod, storedMessageToUiMessage, storedThreadToUiMessages, useAgentChat, useApprovalCountdown, useChatTranscript, useComposerAutocomplete, useElapsed, useMessageFeedback, useSpeechRecognition, useStickToBottom, useThreads, useToolCatalog, useTranscriptItem };
|
|
1610
|
+
export { type AgentBackend, AgentBackendUnsupportedError, AgentChatTransport, type AgentChatTransportOptions, AgentClient, type AgentClientOptions, AgentHttpError, type AgentMessageMetadata, type AgentStreamMeta, type AgentsState, type AggregatedTurnUsage, AnyToolUIPart, type ApprovalCountdown, ApproveOptions, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type CancelResult, type ChatBackground, ChatInput, type ChatInputProps, ChatStatus, type ChatStreamRequest, type ChatStreamResponse, type ChatTranscript, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type MessageFeedbackInput, type MessageFeedbackState, MessageItem, type MessageItemClassNames, type MessageItemProps, MessageItemView, type MessageItemViewProps, MessageList, type MessageListClassNames, type MessageListProps, MessageUsageInfo, type ModelOption, type ModelsState, QuotaBlockedError, type QuotaState, type QuotaToday, type ReconnectOptions, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RenderUiFn, type ResumeStreamRequest, SPEECH_LANGUAGES, type SkillSuggestionData, type SkillsSourceOptions, type SpeechLanguage, type SpeechRecognitionHook, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type StreamConnectionState, type ThreadPatch, type ThreadsEvent, type ThreadsState, TimestampInfo, ToolCatalog, type ToolCatalogState, type TranscriptActionState, TranscriptBlock, type TranscriptCopyState, type TranscriptEditState, TranscriptFile, type TranscriptItem, type TranscriptItemOptions, type TranscriptStopState, TranscriptUiBlock, type TranscriptWindow, type TriggerMatch, type TriggerPosition, type UploadAttachmentOptions, UsageSummary, type UseAgentChatOptions, type UseAgentsOptions, type UseApprovalCountdownOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseElapsedOptions, type UseMessageFeedbackOptions, type UseModelsOptions, type UseQuotaOptions, type UseSpeechRecognitionOptions, type UseThreadsOptions, type UseToolCatalogOptions, type UseTranscriptItemOptions, applyCompletion, approvalCountdown, backgroundRunsFromThread, createSkillsSource, filterAutocompleteItems, findActiveTrigger, formatElapsed, loadStoredSpeechLang, notifyThreads, onThreadsEvent, persistSpeechLang, readReasoningMs, requireBackendMethod, storedMessageToUiMessage, storedThreadToUiMessages, useAgentChat, useAgents, useApprovalCountdown, useChatTranscript, useComposerAutocomplete, useElapsed, useMessageFeedback, useModels, useQuota, useSpeechRecognition, useStickToBottom, useThreads, useToolCatalog, useTranscriptItem };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as ai from 'ai';
|
|
2
2
|
import { ChatTransport, UIMessage, UIMessageChunk, DataUIPart, UIDataTypes } from 'ai';
|
|
3
3
|
import * as _dudousxd_nestjs_agent_core from '@dudousxd/nestjs-agent-core';
|
|
4
|
-
import { ThreadSummary, ThreadDetail, MessageAttachment, ToolCatalogEntry, SkillCatalogEntry, QuotaView, MessageFeedbackValue, MessageFeedback, StoredMessage } from '@dudousxd/nestjs-agent-core';
|
|
4
|
+
import { ThreadSummary, ThreadDetail, MessageAttachment, ToolCatalogEntry, SkillCatalogEntry, QuotaView, QuotaReport, ModelCatalogView, AgentCatalogEntry, MessageFeedbackValue, MessageFeedback, ModelCatalogEntry, QuotaWindow, QuotaBlock, StoredMessage } from '@dudousxd/nestjs-agent-core';
|
|
5
5
|
export { ElicitationInput, ElicitationInputType, validateElicitationAnswer as validateAnswer, validateElicitationValue as validateAnswerValue } from '@dudousxd/nestjs-agent-core';
|
|
6
6
|
import React__default from 'react';
|
|
7
7
|
import { a as TranscriptBlock, U as UsageSummary, b as TimestampInfo, C as ChatStatus, M as MessageUsageInfo, c as ToolCatalog, A as ApproveOptions, d as AnyToolUIPart, e as TranscriptFile, T as TranscriptUiBlock } from './model-gHqjNjLJ.js';
|
|
@@ -15,10 +15,12 @@ export { f as ApprovalBlockOptions, B as BuildBlocksOptions, g as CoercibleQuest
|
|
|
15
15
|
interface ThreadPatch {
|
|
16
16
|
title?: string;
|
|
17
17
|
defaultAgent?: string | null;
|
|
18
|
+
/** Pin a catalog model on the thread; `null` unpins it. */
|
|
19
|
+
model?: string | null;
|
|
18
20
|
}
|
|
19
21
|
/** Starting a turn: the body `POST <base>/chat` takes (see docs/stream-protocol.md). */
|
|
20
22
|
interface ChatStreamRequest {
|
|
21
|
-
/** `{ message, threadId?, agent?, attachments?, pageContext?, regenerate?, … }`. */
|
|
23
|
+
/** `{ message, threadId?, agent?, model?, attachments?, pageContext?, regenerate?, … }`. */
|
|
22
24
|
body: Record<string, unknown>;
|
|
23
25
|
/** Per-request headers the AI SDK was handed for this send. */
|
|
24
26
|
headers?: Record<string, string>;
|
|
@@ -104,6 +106,12 @@ interface AgentBackend {
|
|
|
104
106
|
listTools?(agent?: string): Promise<ToolCatalogEntry[]>;
|
|
105
107
|
listSkills?(threadId?: string): Promise<SkillCatalogEntry[]>;
|
|
106
108
|
getQuotaToday?(): Promise<QuotaView>;
|
|
109
|
+
/** `GET <base>/quota` — every budget window, and which one blocks sends, if any. */
|
|
110
|
+
getQuota?(): Promise<QuotaReport>;
|
|
111
|
+
/** `GET <base>/models?agent=` — what a model picker offers. */
|
|
112
|
+
listModels?(agent?: string): Promise<ModelCatalogView>;
|
|
113
|
+
/** `GET <base>/agents` — what an agent picker offers. */
|
|
114
|
+
listAgents?(): Promise<AgentCatalogEntry[]>;
|
|
107
115
|
setMessageFeedback?(messageId: string, input: MessageFeedbackInput): Promise<{
|
|
108
116
|
feedback: MessageFeedback | null;
|
|
109
117
|
}>;
|
|
@@ -286,6 +294,89 @@ declare class AgentChatTransport implements ChatTransport<UIMessage> {
|
|
|
286
294
|
private toChunkStream;
|
|
287
295
|
}
|
|
288
296
|
|
|
297
|
+
interface UseAgentsOptions {
|
|
298
|
+
/** `useAgentChat(...).backend`, or your own. Must implement `listAgents`. */
|
|
299
|
+
backend: AgentBackend;
|
|
300
|
+
/** `false` holds the request. Default `true`. */
|
|
301
|
+
enabled?: boolean;
|
|
302
|
+
}
|
|
303
|
+
interface AgentsState {
|
|
304
|
+
/** `[]` until loaded. */
|
|
305
|
+
agents: AgentCatalogEntry[];
|
|
306
|
+
/** The agent a turn runs as when none is named. */
|
|
307
|
+
defaultAgent: string | null;
|
|
308
|
+
isLoading: boolean;
|
|
309
|
+
error: Error | null;
|
|
310
|
+
refresh: () => Promise<void>;
|
|
311
|
+
}
|
|
312
|
+
/**
|
|
313
|
+
* The registered agents (`GET <base>/agents`) — the data behind an agent picker. Send the pick as
|
|
314
|
+
* `useAgentChat({ agent })`, or pin it on a thread with `PATCH <base>/threads/:id { defaultAgent }`.
|
|
315
|
+
*/
|
|
316
|
+
declare function useAgents(options: UseAgentsOptions): AgentsState;
|
|
317
|
+
|
|
318
|
+
interface UseModelsOptions {
|
|
319
|
+
/** `useAgentChat(...).backend`, or your own. Must implement `listModels`. */
|
|
320
|
+
backend: AgentBackend;
|
|
321
|
+
/** The agent to list models for; omitted → the default agent. */
|
|
322
|
+
agent?: string;
|
|
323
|
+
/** `false` holds the request. Default `true`. */
|
|
324
|
+
enabled?: boolean;
|
|
325
|
+
}
|
|
326
|
+
/** A catalog entry with the provider it sits under, for a flat list or a search. */
|
|
327
|
+
interface ModelOption extends ModelCatalogEntry {
|
|
328
|
+
providerId: string;
|
|
329
|
+
providerLabel: string;
|
|
330
|
+
}
|
|
331
|
+
interface ModelsState {
|
|
332
|
+
/** Grouped as the server sent them. `[]` until loaded. */
|
|
333
|
+
providers: ModelCatalogView['providers'];
|
|
334
|
+
/** Every model, flattened in provider order. */
|
|
335
|
+
models: ModelOption[];
|
|
336
|
+
/** The model a turn runs on when none is picked, or `null` when the provider decides. */
|
|
337
|
+
defaultModel: string | null;
|
|
338
|
+
/** The entry for `id`, or `undefined`. */
|
|
339
|
+
find: (id: string | null | undefined) => ModelOption | undefined;
|
|
340
|
+
isLoading: boolean;
|
|
341
|
+
error: Error | null;
|
|
342
|
+
refresh: () => Promise<void>;
|
|
343
|
+
}
|
|
344
|
+
/**
|
|
345
|
+
* The models this caller may pick (`GET <base>/models?agent=`), with badges and availability — the
|
|
346
|
+
* data behind a model picker. Headless: render the options however you like, then send the pick
|
|
347
|
+
* as `useAgentChat({ model })`, `sendMessage(msg, { body: { model } })`, or pin it on the thread
|
|
348
|
+
* with `chat.setThreadModel(id)`.
|
|
349
|
+
*/
|
|
350
|
+
declare function useModels(options: UseModelsOptions): ModelsState;
|
|
351
|
+
|
|
352
|
+
interface UseQuotaOptions {
|
|
353
|
+
/** `useAgentChat(...).backend`, or your own. Must implement `getQuota`. */
|
|
354
|
+
backend: AgentBackend;
|
|
355
|
+
/** `false` holds the request. Default `true`. */
|
|
356
|
+
enabled?: boolean;
|
|
357
|
+
/** Re-read every `pollMs` ms as well. Default: only on mount, after runs, and on `refresh`. */
|
|
358
|
+
pollMs?: number;
|
|
359
|
+
}
|
|
360
|
+
interface QuotaState {
|
|
361
|
+
/** The full report, once loaded. */
|
|
362
|
+
report: QuotaReport | undefined;
|
|
363
|
+
windows: QuotaWindow[];
|
|
364
|
+
/** The `day` / `month` windows, when the server reports them. */
|
|
365
|
+
day: QuotaWindow | undefined;
|
|
366
|
+
month: QuotaWindow | undefined;
|
|
367
|
+
/** The window that blocks sends, or `null` — pass it to `useAgentChat({ blocked })`. */
|
|
368
|
+
blocked: QuotaBlock | null;
|
|
369
|
+
isLoading: boolean;
|
|
370
|
+
error: Error | null;
|
|
371
|
+
refresh: () => Promise<void>;
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
374
|
+
* The caller's budget (`GET <base>/quota`): every window's usage against its ceilings, and which
|
|
375
|
+
* one — if any — blocks sends. Re-read after every run a chat on the same backend settles, so a
|
|
376
|
+
* meter moves with the conversation. Headless: draw the meter yourself.
|
|
377
|
+
*/
|
|
378
|
+
declare function useQuota(options: UseQuotaOptions): QuotaState;
|
|
379
|
+
|
|
289
380
|
interface UseMessageFeedbackOptions {
|
|
290
381
|
/** `useAgentChat(...).backend`, or your own. Must implement `setMessageFeedback`. */
|
|
291
382
|
backend: AgentBackend;
|
|
@@ -481,6 +572,12 @@ declare class AgentClient implements AgentBackend {
|
|
|
481
572
|
uploadAttachment(file: File, options?: UploadAttachmentOptions): Promise<MessageAttachment>;
|
|
482
573
|
promoteThread(id: string): Promise<OkResult>;
|
|
483
574
|
truncateFromMessage(threadId: string, messageId: string): Promise<OkResult>;
|
|
575
|
+
/** `GET /agent/models?agent=` — the models this caller may pick, grouped by provider. */
|
|
576
|
+
listModels(agent?: string): Promise<ModelCatalogView>;
|
|
577
|
+
/** `GET /agent/agents` — the registered agents, the default one flagged. */
|
|
578
|
+
listAgents(): Promise<AgentCatalogEntry[]>;
|
|
579
|
+
/** `GET /agent/quota` — the caller's budget windows and the one blocking sends, if any. */
|
|
580
|
+
getQuota(): Promise<QuotaReport>;
|
|
484
581
|
getQuotaToday(): Promise<QuotaToday>;
|
|
485
582
|
cancelStream(runId: string): Promise<CancelResult>;
|
|
486
583
|
/**
|
|
@@ -1308,6 +1405,18 @@ interface UseAgentChatOptions<B extends AgentBackend = AgentClient> {
|
|
|
1308
1405
|
client?: B;
|
|
1309
1406
|
/** Named agent to run each turn. */
|
|
1310
1407
|
agent?: string;
|
|
1408
|
+
/**
|
|
1409
|
+
* The quota window blocking sends — `useQuota(...).blocked`. While set, `sendMessage` and
|
|
1410
|
+
* `regenerate` refuse with {@link QuotaBlockedError} instead of starting a turn the server would
|
|
1411
|
+
* refuse anyway.
|
|
1412
|
+
*/
|
|
1413
|
+
blocked?: QuotaBlock | null;
|
|
1414
|
+
/**
|
|
1415
|
+
* Catalog model to run each turn on (see `useModels`), sent as the body's `model`. Read at every
|
|
1416
|
+
* send, so a picker can change it between turns. Omitted → the thread's pinned model, else the
|
|
1417
|
+
* server default. A single send can still override it with `sendMessage(msg, { body: { model } })`.
|
|
1418
|
+
*/
|
|
1419
|
+
model?: string;
|
|
1311
1420
|
/** Thread this chat is bound to. Omitted → backend creates one on send. */
|
|
1312
1421
|
threadId?: string;
|
|
1313
1422
|
/** Persisted history to seed `useChat` with (consumed on mount only). */
|
|
@@ -1447,6 +1556,7 @@ declare function useAgentChat<B extends AgentBackend = AgentClient>(options: Use
|
|
|
1447
1556
|
* on the first send. A getter, because the created id is learned mid-stream.
|
|
1448
1557
|
*/
|
|
1449
1558
|
getThreadId: () => string | undefined;
|
|
1559
|
+
setThreadModel: (model: string | null) => Promise<void>;
|
|
1450
1560
|
/** The backend this chat talks to — pass it to `useThreads`, `useMessageFeedback`, … */
|
|
1451
1561
|
backend: B;
|
|
1452
1562
|
/** Same object as {@link backend}; kept for callers that read it under its old name. */
|
|
@@ -1491,5 +1601,10 @@ declare function useAgentChat<B extends AgentBackend = AgentClient>(options: Use
|
|
|
1491
1601
|
addToolApprovalResponse: ai.ChatAddToolApproveResponseFunction;
|
|
1492
1602
|
clearError: () => void;
|
|
1493
1603
|
};
|
|
1604
|
+
/** A send refused on the client because a quota window is exhausted (`useAgentChat({ blocked })`). */
|
|
1605
|
+
declare class QuotaBlockedError extends Error {
|
|
1606
|
+
readonly block: QuotaBlock;
|
|
1607
|
+
constructor(block: QuotaBlock);
|
|
1608
|
+
}
|
|
1494
1609
|
|
|
1495
|
-
export { type AgentBackend, AgentBackendUnsupportedError, AgentChatTransport, type AgentChatTransportOptions, AgentClient, type AgentClientOptions, AgentHttpError, type AgentMessageMetadata, type AgentStreamMeta, type AggregatedTurnUsage, AnyToolUIPart, type ApprovalCountdown, ApproveOptions, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type CancelResult, type ChatBackground, ChatInput, type ChatInputProps, ChatStatus, type ChatStreamRequest, type ChatStreamResponse, type ChatTranscript, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type MessageFeedbackInput, type MessageFeedbackState, MessageItem, type MessageItemClassNames, type MessageItemProps, MessageItemView, type MessageItemViewProps, MessageList, type MessageListClassNames, type MessageListProps, MessageUsageInfo, type QuotaToday, type ReconnectOptions, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RenderUiFn, type ResumeStreamRequest, SPEECH_LANGUAGES, type SkillSuggestionData, type SkillsSourceOptions, type SpeechLanguage, type SpeechRecognitionHook, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type StreamConnectionState, type ThreadPatch, type ThreadsEvent, type ThreadsState, TimestampInfo, ToolCatalog, type ToolCatalogState, type TranscriptActionState, TranscriptBlock, type TranscriptCopyState, type TranscriptEditState, TranscriptFile, type TranscriptItem, type TranscriptItemOptions, type TranscriptStopState, TranscriptUiBlock, type TranscriptWindow, type TriggerMatch, type TriggerPosition, type UploadAttachmentOptions, UsageSummary, type UseAgentChatOptions, type UseApprovalCountdownOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseElapsedOptions, type UseMessageFeedbackOptions, type UseSpeechRecognitionOptions, type UseThreadsOptions, type UseToolCatalogOptions, type UseTranscriptItemOptions, applyCompletion, approvalCountdown, backgroundRunsFromThread, createSkillsSource, filterAutocompleteItems, findActiveTrigger, formatElapsed, loadStoredSpeechLang, notifyThreads, onThreadsEvent, persistSpeechLang, readReasoningMs, requireBackendMethod, storedMessageToUiMessage, storedThreadToUiMessages, useAgentChat, useApprovalCountdown, useChatTranscript, useComposerAutocomplete, useElapsed, useMessageFeedback, useSpeechRecognition, useStickToBottom, useThreads, useToolCatalog, useTranscriptItem };
|
|
1610
|
+
export { type AgentBackend, AgentBackendUnsupportedError, AgentChatTransport, type AgentChatTransportOptions, AgentClient, type AgentClientOptions, AgentHttpError, type AgentMessageMetadata, type AgentStreamMeta, type AgentsState, type AggregatedTurnUsage, AnyToolUIPart, type ApprovalCountdown, ApproveOptions, type AutocompleteInputProps, type AutocompleteItem, type AutocompleteListboxProps, type AutocompleteOptionProps, type AutocompleteSource, type BackgroundRun, type CancelResult, type ChatBackground, ChatInput, type ChatInputProps, ChatStatus, type ChatStreamRequest, type ChatStreamResponse, type ChatTranscript, type CompletionEdit, type ComposerAutocomplete, DEFAULT_SPEECH_LANG, type MessageFeedbackInput, type MessageFeedbackState, MessageItem, type MessageItemClassNames, type MessageItemProps, MessageItemView, type MessageItemViewProps, MessageList, type MessageListClassNames, type MessageListProps, MessageUsageInfo, type ModelOption, type ModelsState, QuotaBlockedError, type QuotaState, type QuotaToday, type ReconnectOptions, type RenderFilesFn, type RenderReasoningFn, type RenderTextFn, type RenderToolGroupFn, type RenderToolPartFn, type RenderUiFn, type ResumeStreamRequest, SPEECH_LANGUAGES, type SkillSuggestionData, type SkillsSourceOptions, type SpeechLanguage, type SpeechRecognitionHook, type StickToBottom, type StickToBottomOptions, type StoredTurnMetadata, type StreamConnectionState, type ThreadPatch, type ThreadsEvent, type ThreadsState, TimestampInfo, ToolCatalog, type ToolCatalogState, type TranscriptActionState, TranscriptBlock, type TranscriptCopyState, type TranscriptEditState, TranscriptFile, type TranscriptItem, type TranscriptItemOptions, type TranscriptStopState, TranscriptUiBlock, type TranscriptWindow, type TriggerMatch, type TriggerPosition, type UploadAttachmentOptions, UsageSummary, type UseAgentChatOptions, type UseAgentsOptions, type UseApprovalCountdownOptions, type UseChatTranscriptOptions, type UseComposerAutocompleteOptions, type UseElapsedOptions, type UseMessageFeedbackOptions, type UseModelsOptions, type UseQuotaOptions, type UseSpeechRecognitionOptions, type UseThreadsOptions, type UseToolCatalogOptions, type UseTranscriptItemOptions, applyCompletion, approvalCountdown, backgroundRunsFromThread, createSkillsSource, filterAutocompleteItems, findActiveTrigger, formatElapsed, loadStoredSpeechLang, notifyThreads, onThreadsEvent, persistSpeechLang, readReasoningMs, requireBackendMethod, storedMessageToUiMessage, storedThreadToUiMessages, useAgentChat, useAgents, useApprovalCountdown, useChatTranscript, useComposerAutocomplete, useElapsed, useMessageFeedback, useModels, useQuota, useSpeechRecognition, useStickToBottom, useThreads, useToolCatalog, useTranscriptItem };
|